@@ -25,41 +25,55 @@ trait NonIncrementalSolver extends AbstractSolver { self =>
25
25
def assertCnstr (expression : Trees ): Unit = assertions += expression
26
26
def reset (): Unit = assertions.clear()
27
27
def free (): Unit = for (solver <- currentSolver) solver.free()
28
- def interrupt (): Unit = for (solver <- currentSolver) solver.interrupt()
28
+
29
+ var interrupted = false
30
+
31
+ def interrupt (): Unit = {
32
+ interrupted = true
33
+ for (solver <- currentSolver) solver.interrupt()
34
+ }
29
35
30
36
override def check (config : CheckConfiguration ): config.Response [Model , Assumptions ] = {
31
- assert(currentSolver.isEmpty,
32
- " `currentSolver` should be empty when invoking `check` in NonIncrementalSolver" )
33
- val newSolver = underlying()
34
- try {
35
- currentSolver = Some (newSolver)
36
- for (expression <- assertions)
37
- newSolver.assertCnstr(expression)
38
- val res = newSolver.check(config)
39
- currentSolver = None
40
- res
41
- } finally {
42
- newSolver.free()
37
+ if (! interrupted) {
38
+ assert(currentSolver.isEmpty,
39
+ " `currentSolver` should be empty when invoking `check` in NonIncrementalSolver" )
40
+ val newSolver = underlying()
41
+ try {
42
+ currentSolver = Some (newSolver)
43
+ for (expression <- assertions)
44
+ newSolver.assertCnstr(expression)
45
+ val res = newSolver.check(config)
46
+ currentSolver = None
47
+ res
48
+ } finally {
49
+ newSolver.free()
50
+ }
51
+ } else {
52
+ config.cast(SolverResponses .Unknown )
43
53
}
44
54
}
45
55
46
56
override def checkAssumptions (config : Configuration )
47
57
(assumptions : Set [Trees ]): config.Response [Model , Assumptions ] = {
48
- assert(currentSolver.isEmpty,
49
- " `currentSolver` should be empty when invoking `checkAssumptions` in NonIncrementalSolver" )
50
- val newSolver = underlying()
51
- try {
52
- currentSolver = Some (newSolver)
53
- for (expression <- assertions)
54
- newSolver.assertCnstr(expression)
55
- // we assert the assumptions to address: https://github.com/Z3Prover/z3/issues/5257
56
- for (assumption <- assumptions)
57
- newSolver.assertCnstr(assumption)
58
- val res = newSolver.checkAssumptions(config)(Set ())
59
- currentSolver = None
60
- res
61
- } finally {
62
- newSolver.free()
58
+ if (! interrupted) {
59
+ assert(currentSolver.isEmpty,
60
+ " `currentSolver` should be empty when invoking `checkAssumptions` in NonIncrementalSolver" )
61
+ val newSolver = underlying()
62
+ try {
63
+ currentSolver = Some (newSolver)
64
+ for (expression <- assertions)
65
+ newSolver.assertCnstr(expression)
66
+ // we assert the assumptions to address: https://github.com/Z3Prover/z3/issues/5257
67
+ for (assumption <- assumptions)
68
+ newSolver.assertCnstr(assumption)
69
+ val res = newSolver.checkAssumptions(config)(Set ())
70
+ currentSolver = None
71
+ res
72
+ } finally {
73
+ newSolver.free()
74
+ }
75
+ } else {
76
+ config.cast(SolverResponses .Unknown )
63
77
}
64
78
}
65
79
0 commit comments