Skip to content

Commit cef593b

Browse files
authored
Merge pull request #783 from viperproject/dspil_disable_nlri
Option disabling non-linear integer arithmetic
2 parents 2453aac + 234e733 commit cef593b

4 files changed

Lines changed: 30 additions & 1 deletion

File tree

src/main/scala/Config.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,12 @@ class Config(args: Seq[String]) extends SilFrontendConfig(args, "Silicon") {
230230
noshort = true
231231
)
232232

233+
val disableNL: ScallopOption[Boolean] = opt[Boolean]("disableNL",
234+
descr = "Disable non-linear integer arithmetic when using Z3",
235+
default = Some(false),
236+
noshort = true
237+
)
238+
233239
private val rawProverSaturationTimeout = opt[Int]("proverSaturationTimeout",
234240
descr = ( "Timeout (in ms) used for the prover's state saturation calls (default: 100). "
235241
+ "A timeout of 0 disables all saturation checks."
@@ -813,6 +819,12 @@ class Config(args: Seq[String]) extends SilFrontendConfig(args, "Silicon") {
813819
sys.error(s"Unexpected combination: $other")
814820
}
815821

822+
validateOpt(disableNL, prover) {
823+
case (Some(true), n) if (n != Some(Z3ProverStdIO.name) && n != Some(Z3ProverAPI.name)) =>
824+
Left(s"Option ${disableNL.name} is only supported with Z3")
825+
case _ => Right(())
826+
}
827+
816828
validateOpt(counterexample, moreCompleteExhale, exhaleModeOption) {
817829
case (Some(_), Some(false), None) |
818830
(Some(_), Some(_), Some(ExhaleMode.Greedy)) =>

src/main/scala/decider/Z3ProverAPI.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ class Z3ProverAPI(uniqueId: String,
135135
case (k, v) =>
136136
params.add(removeSmtPrefix(k), v)
137137
}
138+
if (Verifier.config.disableNL.getOrElse(false)) {
139+
params.add("arith.nl", false)
140+
}
138141
val userProvidedArgs = Verifier.config.proverConfigArgs
139142
prover = ctx.mkSolver()
140143
val descrs = prover.getParameterDescriptions

src/main/scala/decider/Z3ProverStdIO.scala

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,12 @@ class Z3ProverStdIO(uniqueId: String,
6565
Paths.get(Verifier.config.z3Exe)
6666
}
6767

68-
override def emitSettings(contents: Iterable[String]): Unit = emit(contents)
68+
override def emitSettings(contents: Iterable[String]): Unit = {
69+
emit(contents)
70+
if (Verifier.config.disableNL.getOrElse(false)) {
71+
comment("We disable non-linear integer arithmetic")
72+
writeLine(s"(set-option :smt.arith.nl false)")
73+
readSuccess()
74+
}
75+
}
6976
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
method f(x: Int, y: Int) returns (res: Int)
2+
requires 0 <= x <= 10
3+
requires 0 <= y <= 10
4+
ensures 0 <= res <= 100 // this fails with --disableNL
5+
{
6+
res := x * y
7+
}

0 commit comments

Comments
 (0)