Skip to content

Commit 77ab3d6

Browse files
author
BaierD
committed
Add more uniform handling of prerequisites of interpolation API
1 parent 1b6f52b commit 77ab3d6

File tree

4 files changed

+34
-6
lines changed

4 files changed

+34
-6
lines changed

src/org/sosy_lab/java_smt/solvers/cvc5/CVC5InterpolatingProver.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ protected String addConstraintImpl(BooleanFormula constraint) throws Interrupted
8484
public BooleanFormula getInterpolant(Collection<String> pFormulasOfA)
8585
throws SolverException, InterruptedException {
8686
checkState(!closed);
87+
proverShutdownNotifier.shutdownIfNecessary();
88+
checkState(!wasLastSatCheckSat);
89+
checkState(!stackChangedSinceLastQuery);
8790
checkArgument(
8891
getAssertedConstraintIds().containsAll(pFormulasOfA),
8992
"interpolation can only be done over previously asserted formulas.");
@@ -101,6 +104,10 @@ public BooleanFormula getInterpolant(Collection<String> pFormulasOfA)
101104
@Override
102105
public List<BooleanFormula> getSeqInterpolants(List<? extends Collection<String>> partitions)
103106
throws SolverException, InterruptedException {
107+
checkState(!closed);
108+
proverShutdownNotifier.shutdownIfNecessary();
109+
checkState(!wasLastSatCheckSat);
110+
checkState(!stackChangedSinceLastQuery);
104111
checkArgument(!partitions.isEmpty(), "at least one partition should be available.");
105112
final ImmutableSet<String> assertedConstraintIds = getAssertedConstraintIds();
106113
checkArgument(

src/org/sosy_lab/java_smt/solvers/mathsat5/Mathsat5InterpolatingProver.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
package org.sosy_lab.java_smt.solvers.mathsat5;
1010

1111
import static com.google.common.base.Preconditions.checkArgument;
12+
import static com.google.common.base.Preconditions.checkState;
1213
import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_assert_formula;
1314
import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_create_itp_group;
1415
import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_get_interpolant;
@@ -99,8 +100,12 @@ protected long getMsatModel() throws SolverException {
99100
}
100101

101102
@Override
102-
public BooleanFormula getInterpolant(Collection<Integer> formulasOfA) throws SolverException {
103-
Preconditions.checkState(!closed);
103+
public BooleanFormula getInterpolant(Collection<Integer> formulasOfA)
104+
throws SolverException, InterruptedException {
105+
checkState(!closed);
106+
proverShutdownNotifier.shutdownIfNecessary();
107+
checkState(!wasLastSatCheckSat);
108+
checkState(!stackChangedSinceLastQuery);
104109
checkArgument(
105110
getAssertedConstraintIds().containsAll(formulasOfA),
106111
"interpolation can only be done over previously asserted formulas.");
@@ -125,7 +130,12 @@ public BooleanFormula getInterpolant(Collection<Integer> formulasOfA) throws Sol
125130

126131
@Override
127132
public List<BooleanFormula> getSeqInterpolants(
128-
List<? extends Collection<Integer>> partitionedFormulas) throws SolverException {
133+
List<? extends Collection<Integer>> partitionedFormulas)
134+
throws SolverException, InterruptedException {
135+
checkState(!closed);
136+
proverShutdownNotifier.shutdownIfNecessary();
137+
checkState(!wasLastSatCheckSat);
138+
checkState(!stackChangedSinceLastQuery);
129139
Preconditions.checkArgument(
130140
!partitionedFormulas.isEmpty(), "at least one partition should be available.");
131141
final ImmutableSet<Integer> assertedConstraintIds = getAssertedConstraintIds();

src/org/sosy_lab/java_smt/solvers/opensmt/OpenSmtInterpolatingProver.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,12 @@ protected void popImpl() {
7373
}
7474

7575
@Override
76-
public BooleanFormula getInterpolant(Collection<Integer> formulasOfA) {
76+
public BooleanFormula getInterpolant(Collection<Integer> formulasOfA)
77+
throws InterruptedException {
7778
checkState(!closed);
79+
proverShutdownNotifier.shutdownIfNecessary();
80+
checkState(!wasLastSatCheckSat);
81+
checkState(!stackChangedSinceLastQuery);
7882
checkArgument(
7983
getAssertedConstraintIds().containsAll(formulasOfA),
8084
"interpolation can only be done over previously asserted formulas.");

src/org/sosy_lab/java_smt/solvers/smtinterpol/SmtInterpolInterpolatingProver.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
package org.sosy_lab.java_smt.solvers.smtinterpol;
1010

1111
import static com.google.common.base.Preconditions.checkArgument;
12+
import static com.google.common.base.Preconditions.checkState;
1213

1314
import com.google.common.base.Preconditions;
1415
import com.google.common.collect.ImmutableList;
@@ -47,7 +48,10 @@ protected String addConstraintImpl(BooleanFormula constraint) throws Interrupted
4748
@Override
4849
public BooleanFormula getInterpolant(Collection<String> pTermNamesOfA)
4950
throws SolverException, InterruptedException {
50-
Preconditions.checkState(!closed);
51+
checkState(!closed);
52+
proverShutdownNotifier.shutdownIfNecessary();
53+
checkState(!wasLastSatCheckSat);
54+
checkState(!stackChangedSinceLastQuery);
5155
checkArgument(
5256
getAssertedConstraintIds().containsAll(pTermNamesOfA),
5357
"interpolation can only be done over previously asserted formulas.");
@@ -74,7 +78,10 @@ public BooleanFormula getInterpolant(Collection<String> pTermNamesOfA)
7478
public List<BooleanFormula> getTreeInterpolants(
7579
List<? extends Collection<String>> partitionedTermNames, int[] startOfSubTree)
7680
throws SolverException, InterruptedException {
77-
Preconditions.checkState(!closed);
81+
checkState(!closed);
82+
proverShutdownNotifier.shutdownIfNecessary();
83+
checkState(!wasLastSatCheckSat);
84+
checkState(!stackChangedSinceLastQuery);
7885
final ImmutableSet<String> assertedConstraintIds = getAssertedConstraintIds();
7986
checkArgument(
8087
partitionedTermNames.stream().allMatch(assertedConstraintIds::containsAll),

0 commit comments

Comments
 (0)