@@ -65,14 +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
- " smt-z3:EXEC " -> " Z3 through SMT-LIB with custom executable name" ,
75
- " 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"
76
76
)
77
77
78
78
private val fallbacks = Map (
@@ -87,6 +87,9 @@ object SolverFactory {
87
87
88
88
private var reported : Boolean = false
89
89
90
+ // extract <exec> in "smt-z3:<exec>"
91
+ private def getZ3Executable (name : String ): String = name.drop(7 )
92
+
90
93
def getFromName (name : String , force : Boolean = false )
91
94
(p : Program , ctx : Context )
92
95
(enc : ProgramTransformer {
@@ -110,7 +113,17 @@ object SolverFactory {
110
113
replacement
111
114
112
115
case Some (_) => name
113
- case None if name.startsWith(" smt-z3:" ) => 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)
114
127
115
128
case _ => throw FatalError (" Unknown solver: " + name)
116
129
}
@@ -228,7 +241,7 @@ object SolverFactory {
228
241
val progEnc = fullEnc andThen theoryEnc
229
242
val targetProg = progEnc.targetProgram
230
243
val targetSem = targetProg.getSemantics
231
- val executableName = if (finalName == " smt-z3" ) " z3" else finalName.drop( 7 )
244
+ val executableName = if (finalName == " smt-z3" ) " z3" else getZ3Executable(finalName )
232
245
233
246
() => new {
234
247
val program : p.type = p
@@ -311,7 +324,7 @@ object SolverFactory {
311
324
}
312
325
}
313
326
314
- val solvers : Set [ String ] = solverNames.map(_._1).toSet
327
+ def supportedSolver ( s : String ) = solverNames.contains(s) || s.startsWith( " smt-z3: " )
315
328
316
329
def getFromSettings (p : Program , ctx : Context )
317
330
(enc : ProgramTransformer {
0 commit comments