Skip to content

Commit 10e09aa

Browse files
committed
Remove --no-incremental option and enable no-inc: prefix on solvers
1 parent f3709ec commit 10e09aa

File tree

4 files changed

+52
-51
lines changed

4 files changed

+52
-51
lines changed

src/it/scala/inox/tip/TipTestSuite.scala

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,16 @@ import scala.language.existentials
1010
class TipTestSuite extends TestSuite with ResourceUtils {
1111

1212
override def configurations = Seq(
13-
Seq(optSelectedSolvers(Set("nativez3")), optCheckModels(true)),
14-
Seq(optSelectedSolvers(Set("smt-z3")), optCheckModels(true)),
15-
Seq(optSelectedSolvers(Set("smt-cvc4")), optCheckModels(true)),
16-
Seq(optSelectedSolvers(Set("smt-z3")), optCheckModels(true), optAssumeChecked(true)),
17-
Seq(optSelectedSolvers(Set("smt-z3")), optCheckModels(true), optNonIncremental(true))
13+
Seq(optSelectedSolvers(Set("nativez3")), optCheckModels(true)),
14+
Seq(optSelectedSolvers(Set("smt-z3")), optCheckModels(true)),
15+
Seq(optSelectedSolvers(Set("smt-cvc4")), optCheckModels(true)),
16+
Seq(optSelectedSolvers(Set("smt-z3")), optCheckModels(true), optAssumeChecked(true)),
17+
Seq(optSelectedSolvers(Set("no-inc:smt-z3")), optCheckModels(true))
1818
)
1919

2020
override protected def optionsString(options: Options): String = {
2121
"solver=" + options.findOptionOrDefault(optSelectedSolvers).head +
22-
(if (options.findOptionOrDefault(optAssumeChecked)) " assumechecked" else "") +
23-
(if (options.findOptionOrDefault(optNonIncremental)) " --no-incremental" else "")
22+
(if (options.findOptionOrDefault(optAssumeChecked)) " assumechecked" else "")
2423
}
2524

2625
private def ignoreSAT(ctx: Context, file: java.io.File): FilterStatus =

src/main/scala/inox/Main.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ trait MainHelpers {
4646
protected def getOptions: Map[OptionDef[_], Description] = Map(
4747
optHelp -> Description(General, "Show help message"),
4848
optNoColors -> Description(General, "Disable colored output and non-ascii characters (enable this option for better support in IDEs)"),
49-
optNonIncremental -> Description(General, "Disable incremental mode in solvers"),
5049
optTimeout -> Description(General, "Set a timeout for the solver (in sec.)"),
5150
optSelectedSolvers -> Description(General, {
5251
"Use solvers s1,s2,...\nAvailable: " +
5352
solvers.SolverFactory.solverNames.toSeq.sortBy(_._1).map {
5453
case (name, desc) => f"\n $name%-14s : $desc"
55-
}.mkString("")
54+
}.mkString("") +
55+
"\nYou can prefix the solvers unrollz3, smt-z3, smt-z3:<exec>, smt-cvc4, with 'noinc:' to use them in non-incremental mode"
5656
}),
5757
optDebug -> Description(General, {
5858
val sects = debugSections.toSeq.map(_.name).sorted

src/main/scala/inox/Options.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,5 +232,3 @@ object optSelectedSolvers extends SetOptionDef[String] {
232232
}
233233

234234
object optNoColors extends inox.FlagOptionDef("no-colors", false)
235-
236-
object optNonIncremental extends inox.FlagOptionDef("no-incremental", false)

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

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -90,44 +90,24 @@ object SolverFactory {
9090
// extract <exec> in "smt-z3:<exec>"
9191
private def getZ3Executable(name: String): String = name.drop(7)
9292

93-
def getFromName(name: String, force: Boolean = false)
93+
def getFromName(noIncName: String, force: Boolean = false)
9494
(p: Program, ctx: Context)
9595
(enc: ProgramTransformer {
9696
val sourceProgram: p.type
9797
val targetProgram: Program { val trees: inox.trees.type }
9898
})(implicit sem: p.Semantics): SolverFactory { val program: p.type; type S <: TimeoutSolver { val program: p.type } } = {
9999

100-
val nonIncremental = ctx.options.findOptionOrDefault(optNonIncremental)
101-
def nonIncrementalWrap[T, M](targetProgram: Program)(
102-
nme: String,
103-
targetSem: targetProgram.Semantics,
104-
underlyingSolver: () => AbstractSolver {
105-
val program: targetProgram.type
106-
type Trees = T
107-
type Model = M
108-
}):
109-
AbstractSolver {
110-
val program: targetProgram.type
111-
type Trees = T
112-
type Model = M
113-
} = {
114-
115-
if (nonIncremental) {
116-
new {
117-
val program: targetProgram.type = targetProgram
118-
val context = ctx
119-
} with NonIncrementalSolver {
120-
type Trees = T
121-
type Model = M
122-
val semantics: targetProgram.Semantics = targetSem
123-
def name = s"no-inc:$nme"
100+
val nonIncremental = noIncName.startsWith("no-inc:")
101+
val name = if (nonIncremental) noIncName.drop(7) else noIncName
124102

125-
def underlying() = underlyingSolver()
126-
}
127-
} else {
128-
underlyingSolver()
129-
}
130-
}
103+
if (
104+
nonIncremental &&
105+
name != "smt-cvc4" &&
106+
name != "unrollz3" &&
107+
name != "smt-z3" &&
108+
!name.startsWith("smt-z3:")
109+
)
110+
throw FatalError(s"Non incremental mode is not available for solver $name")
131111

132112
val finalName = if (force) {
133113
name
@@ -161,14 +141,36 @@ object SolverFactory {
161141
}
162142
}
163143

164-
if (
165-
nonIncremental &&
166-
finalName != "smt-cvc4" &&
167-
finalName != "unrollz3" &&
168-
finalName != "smt-z3" &&
169-
!finalName.startsWith("smt-z3:")
170-
)
171-
throw FatalError(s"Option --no-incremental is not compatible with solver $finalName")
144+
def nonIncrementalWrap[T, M](targetProgram: Program)(
145+
nme: String,
146+
targetSem: targetProgram.Semantics,
147+
underlyingSolver: () => AbstractSolver {
148+
val program: targetProgram.type
149+
type Trees = T
150+
type Model = M
151+
}): AbstractSolver {
152+
val program: targetProgram.type
153+
type Trees = T
154+
type Model = M
155+
} = {
156+
157+
if (nonIncremental) {
158+
new {
159+
val program: targetProgram.type = targetProgram
160+
val context = ctx
161+
} with NonIncrementalSolver {
162+
type Trees = T
163+
type Model = M
164+
val semantics: targetProgram.Semantics = targetSem
165+
def name = s"no-inc:$nme"
166+
167+
def underlying() = underlyingSolver()
168+
}
169+
} else {
170+
underlyingSolver()
171+
}
172+
}
173+
172174

173175
finalName match {
174176
case "nativez3" => create(p)(finalName, {
@@ -365,7 +367,9 @@ object SolverFactory {
365367
}
366368
}
367369

368-
def supportedSolver(s: String) = solverNames.contains(s) || s.startsWith("smt-z3:")
370+
private def supportedSolverRaw(s: String) = solverNames.contains(s) || s.startsWith("smt-z3:")
371+
def supportedSolver(s: String) =
372+
supportedSolverRaw(s) || (s.startsWith("no-inc:") && supportedSolverRaw(s.drop(7)))
369373

370374
def getFromSettings(p: Program, ctx: Context)
371375
(enc: ProgramTransformer {

0 commit comments

Comments
 (0)