@@ -65,13 +65,14 @@ object SolverFactory {
65
65
import unrolling ._
66
66
67
67
val solverNames = Map (
68
- " nativez3" -> " Native Z3 with z3-templates for unrolling" ,
69
- " nativez3-opt" -> " Native Z3 optimizer with z3-templates for unrolling" ,
70
- " unrollz3" -> " Native Z3 with inox-templates for unrolling" ,
71
- " smt-cvc4" -> " CVC4 through SMT-LIB" ,
72
- " smt-z3" -> " Z3 through SMT-LIB" ,
73
- " smt-z3-opt" -> " Z3 optimizer through SMT-LIB" ,
74
- " princess" -> " Princess with inox unrolling"
68
+ " nativez3" -> " Native Z3 with z3-templates for unrolling" ,
69
+ " nativez3-opt" -> " Native Z3 optimizer with z3-templates for unrolling" ,
70
+ " unrollz3" -> " Native Z3 with inox-templates for unrolling" ,
71
+ " smt-cvc4" -> " CVC4 through SMT-LIB" ,
72
+ " smt-z3" -> " Z3 through SMT-LIB" ,
73
+ " smt-z3-opt" -> " Z3 optimizer through SMT-LIB" ,
74
+ " smt-z3:<exec>" -> " Z3 through SMT-LIB with custom executable name" ,
75
+ " princess" -> " Princess with inox unrolling"
75
76
)
76
77
77
78
private val fallbacks = Map (
@@ -86,6 +87,9 @@ object SolverFactory {
86
87
87
88
private var reported : Boolean = false
88
89
90
+ // extract <exec> in "smt-z3:<exec>"
91
+ private def getZ3Executable (name : String ): String = name.drop(7 )
92
+
89
93
def getFromName (name : String , force : Boolean = false )
90
94
(p : Program , ctx : Context )
91
95
(enc : ProgramTransformer {
@@ -109,6 +113,17 @@ object SolverFactory {
109
113
replacement
110
114
111
115
case Some (_) => name
116
+ case None if name.startsWith(" smt-z3:" ) =>
117
+ val z3Exec = getZ3Executable(name)
118
+ val hasZ3Exec = try {
119
+ new Z3Interpreter (z3Exec, Array (" -in" , " -smt2" ))
120
+ true
121
+ } catch {
122
+ case _ : java.io.IOException => false
123
+ }
124
+
125
+ if (hasZ3Exec) name
126
+ else throw FatalError (" Unknown solver: " + z3Exec)
112
127
113
128
case _ => throw FatalError (" Unknown solver: " + name)
114
129
}
@@ -189,7 +204,7 @@ object SolverFactory {
189
204
}
190
205
})
191
206
192
- case " smt-z3" => create(p)(finalName, {
207
+ case " smt-z3-opt " => create(p)(finalName, {
193
208
val chooseEnc = ChooseEncoder (p)(enc)
194
209
val fullEnc = enc andThen chooseEnc
195
210
val theoryEnc = theories.Z3 (fullEnc.targetProgram)
@@ -201,7 +216,7 @@ object SolverFactory {
201
216
val program : p.type = p
202
217
val context = ctx
203
218
val encoder : enc.type = enc
204
- } with UnrollingSolver with TimeoutSolver with tip. TipDebugger {
219
+ } with UnrollingOptimizer with TimeoutSolver {
205
220
override protected val semantics = sem
206
221
override protected val chooses : chooseEnc.type = chooseEnc
207
222
override protected val theories : theoryEnc.type = theoryEnc
@@ -213,25 +228,26 @@ object SolverFactory {
213
228
protected val underlying = new {
214
229
val program : progEnc.targetProgram.type = progEnc.targetProgram
215
230
val context = ctx
216
- } with smtlib.Z3Solver {
231
+ } with smtlib.optimization. Z3Optimizer {
217
232
val semantics : program.Semantics = targetSem
218
233
}
219
234
}
220
235
})
221
236
222
- case " smt-z3-opt " => create(p)(finalName, {
237
+ case _ if finalName == " smt-z3" || finalName.startsWith( " smt-z3: " ) => create(p)(finalName, {
223
238
val chooseEnc = ChooseEncoder (p)(enc)
224
239
val fullEnc = enc andThen chooseEnc
225
240
val theoryEnc = theories.Z3 (fullEnc.targetProgram)
226
241
val progEnc = fullEnc andThen theoryEnc
227
242
val targetProg = progEnc.targetProgram
228
243
val targetSem = targetProg.getSemantics
244
+ val executableName = if (finalName == " smt-z3" ) " z3" else getZ3Executable(finalName)
229
245
230
246
() => new {
231
247
val program : p.type = p
232
248
val context = ctx
233
249
val encoder : enc.type = enc
234
- } with UnrollingOptimizer with TimeoutSolver {
250
+ } with UnrollingSolver with TimeoutSolver with tip. TipDebugger {
235
251
override protected val semantics = sem
236
252
override protected val chooses : chooseEnc.type = chooseEnc
237
253
override protected val theories : theoryEnc.type = theoryEnc
@@ -243,8 +259,9 @@ object SolverFactory {
243
259
protected val underlying = new {
244
260
val program : progEnc.targetProgram.type = progEnc.targetProgram
245
261
val context = ctx
246
- } with smtlib.optimization. Z3Optimizer {
262
+ } with smtlib.Z3Solver {
247
263
val semantics : program.Semantics = targetSem
264
+ override def targetName = executableName
248
265
}
249
266
}
250
267
})
@@ -307,7 +324,7 @@ object SolverFactory {
307
324
}
308
325
}
309
326
310
- val solvers : Set [ String ] = solverNames.map(_._1).toSet
327
+ def supportedSolver ( s : String ) = solverNames.contains(s) || s.startsWith( " smt-z3: " )
311
328
312
329
def getFromSettings (p : Program , ctx : Context )
313
330
(enc : ProgramTransformer {
0 commit comments