Skip to content

Commit 8a2beb5

Browse files
committed
Add support for smt-z3 with custom executable name
1 parent 6bcf926 commit 8a2beb5

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/main/scala/inox/Options.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,10 @@ object optSelectedSolvers extends SetOptionDef[String] {
223223
val name = "solvers"
224224
val default = Set("nativez3")
225225
val elementParser: OptionParser[String] = { s =>
226-
stringParser(s).filter(solvers.SolverFactory.solverNames contains _)
226+
stringParser(s).filter(name =>
227+
solvers.SolverFactory.solverNames.contains(name) ||
228+
name.startsWith("smt-z3:")
229+
)
227230
}
228231

229232
val usageRhs = "s1,s2,..."

src/main/scala/inox/solvers/SolverFactory.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ object SolverFactory {
7171
"smt-cvc4" -> "CVC4 through SMT-LIB",
7272
"smt-z3" -> "Z3 through SMT-LIB",
7373
"smt-z3-opt" -> "Z3 optimizer through SMT-LIB",
74+
"smt-z3:EXEC" -> "Z3 through SMT-LIB with custom executable name",
7475
"princess" -> "Princess with inox unrolling"
7576
)
7677

@@ -109,6 +110,7 @@ object SolverFactory {
109110
replacement
110111

111112
case Some(_) => name
113+
case None if name.startsWith("smt-z3:") => name
112114

113115
case _ => throw FatalError("Unknown solver: " + name)
114116
}
@@ -189,13 +191,14 @@ object SolverFactory {
189191
}
190192
})
191193

192-
case "smt-z3" => create(p)(finalName, {
194+
case _ if finalName.startsWith("smt-z3") => create(p)(finalName, {
193195
val chooseEnc = ChooseEncoder(p)(enc)
194196
val fullEnc = enc andThen chooseEnc
195197
val theoryEnc = theories.Z3(fullEnc.targetProgram)
196198
val progEnc = fullEnc andThen theoryEnc
197199
val targetProg = progEnc.targetProgram
198200
val targetSem = targetProg.getSemantics
201+
val executableName = if (finalName == "smt-z3") "z3" else finalName.drop(7)
199202

200203
() => new {
201204
val program: p.type = p
@@ -215,6 +218,7 @@ object SolverFactory {
215218
val context = ctx
216219
} with smtlib.Z3Solver {
217220
val semantics: program.Semantics = targetSem
221+
override def targetName = executableName
218222
}
219223
}
220224
})

src/main/scala/inox/solvers/smtlib/Z3Target.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ trait Z3Target extends SMTLIBTarget with SMTLIBDebugger {
5858
protected val interpreter = {
5959
val opts = interpreterOpts
6060
reporter.debug("Invoking solver "+targetName+" with "+opts.mkString(" "))
61-
new Z3Interpreter("z3", opts.toArray) {
61+
new Z3Interpreter(targetName, opts.toArray) {
6262
override lazy val parser: Z3Parser = new Z3Parser(new Lexer(out))
6363
}
6464
}

0 commit comments

Comments
 (0)