-
Notifications
You must be signed in to change notification settings - Fork 54
Model usage: fix usage of model values and model evaluation after changing the underlying context. #553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Model usage: fix usage of model values and model evaluation after changing the underlying context. #553
Changes from 4 commits
69d6659
76decb1
1609130
ddca71a
ac8cb0c
91a2bbf
1cb28e3
9df6812
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,7 +47,6 @@ public boolean terminate() { | |
| private final BitwuzlaFormulaManager manager; | ||
|
|
||
| private final BitwuzlaFormulaCreator creator; | ||
| protected boolean wasLastSatCheckSat = false; // and stack is not changed | ||
|
|
||
| protected BitwuzlaTheoremProver( | ||
| BitwuzlaFormulaManager pManager, | ||
|
|
@@ -81,6 +80,11 @@ private Bitwuzla createEnvironment(Set<ProverOptions> pProverOptions, Options pS | |
| return new Bitwuzla(creator.getTermManager(), pSolverOptions); | ||
| } | ||
|
|
||
| @Override | ||
| protected boolean hasPersistentModel() { | ||
| return false; | ||
| } | ||
|
|
||
| /** | ||
| * Remove one backtracking point/level from the current stack. This removes the latest level | ||
| * including all of its formulas, i.e., all formulas that were added for this backtracking point. | ||
|
|
@@ -92,7 +96,6 @@ public void popImpl() { | |
|
|
||
| @Override | ||
| public @Nullable Void addConstraintImpl(BooleanFormula constraint) throws InterruptedException { | ||
| wasLastSatCheckSat = false; | ||
| Term formula = creator.extractInfo(constraint); | ||
| env.assert_formula(formula); | ||
| for (Term t : creator.getConstraintsForTerm(formula)) { | ||
|
|
@@ -114,8 +117,10 @@ public void pushImpl() throws InterruptedException { | |
| } | ||
|
|
||
| private boolean readSATResult(Result resultValue) throws SolverException, InterruptedException { | ||
| changedSinceLastSatQuery = false; | ||
| wasLastSatCheckSatisfiable = false; | ||
| if (resultValue == Result.SAT) { | ||
| wasLastSatCheckSat = true; | ||
| wasLastSatCheckSatisfiable = true; | ||
| return false; | ||
| } else if (resultValue == Result.UNSAT) { | ||
| return true; | ||
|
|
@@ -130,7 +135,6 @@ private boolean readSATResult(Result resultValue) throws SolverException, Interr | |
| @Override | ||
| public boolean isUnsat() throws SolverException, InterruptedException { | ||
| Preconditions.checkState(!closed); | ||
| wasLastSatCheckSat = false; | ||
| final Result result = env.check_sat(); | ||
| return readSATResult(result); | ||
| } | ||
|
|
@@ -145,7 +149,6 @@ public boolean isUnsat() throws SolverException, InterruptedException { | |
| public boolean isUnsatWithAssumptions(Collection<BooleanFormula> assumptions) | ||
| throws SolverException, InterruptedException { | ||
| Preconditions.checkState(!closed); | ||
| wasLastSatCheckSat = false; | ||
|
|
||
| Collection<Term> newAssumptions = new LinkedHashSet<>(); | ||
| for (BooleanFormula formula : assumptions) { | ||
|
|
@@ -170,8 +173,6 @@ public boolean isUnsatWithAssumptions(Collection<BooleanFormula> assumptions) | |
| @SuppressWarnings("resource") | ||
| @Override | ||
| public Model getModel() throws SolverException { | ||
| Preconditions.checkState(!closed); | ||
| Preconditions.checkState(wasLastSatCheckSat, NO_MODEL_HELP); | ||
| checkGenerateModels(); | ||
| return new CachingModel( | ||
| registerEvaluator( | ||
|
|
@@ -196,9 +197,7 @@ private List<BooleanFormula> getUnsatCore0() { | |
| */ | ||
| @Override | ||
| public List<BooleanFormula> getUnsatCore() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. UnsatCores can also affect solver states (e.g. in Z3). It might be a good idea to generally assume that they do?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you give an example? Why would Z3 change its state when calling |
||
| Preconditions.checkState(!closed); | ||
| checkGenerateUnsatCores(); | ||
| Preconditions.checkState(!wasLastSatCheckSat); | ||
| return getUnsatCore0(); | ||
| } | ||
|
|
||
|
|
@@ -214,9 +213,7 @@ public List<BooleanFormula> getUnsatCore() { | |
| public Optional<List<BooleanFormula>> unsatCoreOverAssumptions( | ||
| Collection<BooleanFormula> assumptions) throws SolverException, InterruptedException { | ||
| Preconditions.checkNotNull(assumptions); | ||
| Preconditions.checkState(!closed); | ||
| checkGenerateUnsatCores(); // FIXME: JavaDoc say ProverOptions.GENERATE_UNSAT_CORE is not needed | ||
| Preconditions.checkState(!wasLastSatCheckSat); | ||
| checkGenerateUnsatCoresOverAssumptions(); | ||
| boolean sat = !isUnsatWithAssumptions(assumptions); | ||
| return sat ? Optional.empty() : Optional.of(getUnsatCore0()); | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.