Class DebuggingInterpolatingProverEnvironment<T>
- java.lang.Object
-
- org.sosy_lab.java_smt.delegate.debugging.DebuggingInterpolatingProverEnvironment<T>
-
- All Implemented Interfaces:
AutoCloseable,BasicProverEnvironment<T>,InterpolatingProverEnvironment<T>
public class DebuggingInterpolatingProverEnvironment<T> extends Object implements InterpolatingProverEnvironment<T>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.sosy_lab.java_smt.api.BasicProverEnvironment
BasicProverEnvironment.AllSatCallback<R>
-
-
Field Summary
-
Fields inherited from interface org.sosy_lab.java_smt.api.BasicProverEnvironment
ASSUMPTION_SOLVING_NOT_SUPPORTED, NO_MODEL_HELP, UNSAT_CORE_NOT_SUPPORTED
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @Nullable TaddConstraint(BooleanFormula constraint)Add a constraint to the latest backtracking point.<R> RallSat(BasicProverEnvironment.AllSatCallback<R> callback, List<BooleanFormula> important)Get all satisfying assignments of the current environment with regard to a subset of terms, and create a region representing all those models.voidclose()Closes the prover environment.BooleanFormulagetInterpolant(Collection<T> formulasOfA)Get an interpolant for two groups of formulas.ModelgetModel()Get a satisfying assignment.List<BooleanFormula>getSeqInterpolants(List<? extends Collection<T>> partitionedFormulas)This method returns interpolants of an 'inductive sequence'.List<BooleanFormula>getTreeInterpolants(List<? extends Collection<T>> partitionedFormulas, int[] startOfSubTree)Compute a sequence of interpolants.List<BooleanFormula>getUnsatCore()Get an unsat core.booleanisUnsat()Check whether the conjunction of all formulas on the stack is unsatisfiable.booleanisUnsatWithAssumptions(Collection<BooleanFormula> assumptions)Check whether the conjunction of all formulas on the stack together with the list of assumptions is satisfiable.voidpop()Remove one backtracking point/level from the current stack.voidpush()Create a new backtracking point, i.e., a new level on the assertion stack.intsize()Get the number of backtracking points/levels on the current stack.Optional<List<BooleanFormula>>unsatCoreOverAssumptions(Collection<BooleanFormula> assumptions)Returns an UNSAT core (if it exists, otherwiseOptional.empty()), over the chosen assumptions.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.sosy_lab.java_smt.api.BasicProverEnvironment
addConstraint, allSat, close, getEvaluator, getModel, getModelAssignments, getStatistics, getUnsatCore, isUnsat, isUnsatWithAssumptions, pop, push, push, registerUserPropagator, size, unsatCoreOverAssumptions
-
Methods inherited from interface org.sosy_lab.java_smt.api.InterpolatingProverEnvironment
getSeqInterpolants0, getTreeInterpolants0
-
-
-
-
Method Detail
-
getInterpolant
public BooleanFormula getInterpolant(Collection<T> formulasOfA) throws SolverException, InterruptedException
Description copied from interface:InterpolatingProverEnvironmentGet an interpolant for two groups of formulas. This should be called only immediately after anBasicProverEnvironment.isUnsat()call that returnedtrue.There is no direct guarantee that the interpolants returned are part of an inductive sequence', however this seems to work for most solvers as long as the same proof is used, i.e. all interpolants are computed after the same SAT-check. If a solver does not use the same internal proof for several interpolation queries (such as CVC5), then the returned interpolants might not satisfy the sequence-criteria. We suggest the proper method
InterpolatingProverEnvironment.getSeqInterpolants(java.util.List<? extends java.util.Collection<T>>)for that case.- Specified by:
getInterpolantin interfaceInterpolatingProverEnvironment<T>- Parameters:
formulasOfA- A collection of values returned byBasicProverEnvironment.push(BooleanFormula). All the corresponding formulas from group A, the remaining formulas form group B.- Returns:
- An interpolant for A and B
- Throws:
SolverException- if interpolant cannot be computed, for example because interpolation procedure is incompleteInterruptedException
-
getSeqInterpolants
public List<BooleanFormula> getSeqInterpolants(List<? extends Collection<T>> partitionedFormulas) throws SolverException, InterruptedException
Description copied from interface:InterpolatingProverEnvironmentThis method returns interpolants of an 'inductive sequence'. This property must be supported by the interpolation-strategy of the underlying SMT-solver! Depending on the underlying SMT-solver this method might be faster than N direct calls to getInterpolant().The prover stack should contain the partitioned formulas, but any order is allowed. For an input of N partitions we return N-1 interpolants. Any asserted formula that is on the prover stack and not part of the partitioned list, will be used for background theory and its symbols can appear in any interpolant.
- Specified by:
getSeqInterpolantsin interfaceInterpolatingProverEnvironment<T>- Returns:
- an 'inductive sequence' of interpolants, such that the implication
AND(I_i, P_i) => I_(i+1)is satisfied for all i, where P_i is the conjunction of all formulas in partition i. - Throws:
SolverException- if interpolant cannot be computed, for example because interpolation procedure is incompleteInterruptedException
-
getTreeInterpolants
public List<BooleanFormula> getTreeInterpolants(List<? extends Collection<T>> partitionedFormulas, int[] startOfSubTree) throws SolverException, InterruptedException
Description copied from interface:InterpolatingProverEnvironmentCompute a sequence of interpolants. The nesting array describes the start of the subtree for tree interpolants. For inductive sequences of interpolants use a nesting array completely filled with 0.Example:
A D | | B E | / C | F H | / G arrayIndex = [0,1,2,3,4,5,6,7] // only for demonstration, not needed partition = [A,B,D,E,C,F,H,G] // post-order of tree startOfSubTree = [0,0,2,2,0,0,6,0] // index of left-most leaf of the current element
The prover stack should contain the partitioned formulas. For an input of N partitions (nodes in the tree) we return N-1 interpolants (one interpolant for/below each node except the root). Any asserted formula that is on the prover stack and not part of the partitioned list, will be used for background theory and its symbols can appear in any interpolant.
- Specified by:
getTreeInterpolantsin interfaceInterpolatingProverEnvironment<T>- Parameters:
partitionedFormulas- of formulasstartOfSubTree- The start of the subtree containing the formula at this index as root.- Returns:
- Tree interpolants respecting the nesting relation.
- Throws:
SolverException- if interpolant cannot be computed, for example because interpolation procedure is incompleteInterruptedException
-
pop
public void pop()
Description copied from interface:BasicProverEnvironmentRemove 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.- Specified by:
popin interfaceBasicProverEnvironment<T>
-
addConstraint
public @Nullable T addConstraint(BooleanFormula constraint) throws InterruptedException
Description copied from interface:BasicProverEnvironmentAdd a constraint to the latest backtracking point.- Specified by:
addConstraintin interfaceBasicProverEnvironment<T>- Throws:
InterruptedException
-
push
public void push() throws InterruptedExceptionDescription copied from interface:BasicProverEnvironmentCreate a new backtracking point, i.e., a new level on the assertion stack. Each level can hold several asserted formulas.If formulas are added before creating the first backtracking point, they can not be removed via a POP-operation.
- Specified by:
pushin interfaceBasicProverEnvironment<T>- Throws:
InterruptedException
-
size
public int size()
Description copied from interface:BasicProverEnvironmentGet the number of backtracking points/levels on the current stack.Caution: This is the number of PUSH-operations, and not necessarily equal to the number of asserted formulas. On any level there can be an arbitrary number of asserted formulas. Even with size of 0, formulas can already be asserted (at bottom level).
- Specified by:
sizein interfaceBasicProverEnvironment<T>
-
isUnsat
public boolean isUnsat() throws SolverException, InterruptedExceptionDescription copied from interface:BasicProverEnvironmentCheck whether the conjunction of all formulas on the stack is unsatisfiable.- Specified by:
isUnsatin interfaceBasicProverEnvironment<T>- Throws:
SolverExceptionInterruptedException
-
isUnsatWithAssumptions
public boolean isUnsatWithAssumptions(Collection<BooleanFormula> assumptions) throws SolverException, InterruptedException
Description copied from interface:BasicProverEnvironmentCheck whether the conjunction of all formulas on the stack together with the list of assumptions is satisfiable.- Specified by:
isUnsatWithAssumptionsin interfaceBasicProverEnvironment<T>- Parameters:
assumptions- A list of literals.- Throws:
SolverExceptionInterruptedException
-
getModel
public Model getModel() throws SolverException
Description copied from interface:BasicProverEnvironmentGet a satisfying assignment. This method should be called only immediately after anBasicProverEnvironment.isUnsat()call that returnedfalse.Some solvers (such as MathSAT or Z3) guarantee that a model stays constant and valid as long as the solver context is available, even if constraints are added to, pushed or popped from the prover stack. If the solver does not provide this guarantee, the model will be invalidated by the next such operation, and using it will lead to an exception.
A model might not provide values for all symbols known to the solver, but it should at least provide values for all free symbols occurring in the asserted formulas. For other symbols, the behavior is solver-dependent, e.g., the model might provide default values or leave them undefined. For uninterpreted functions, the model should provide values for all instantiations. For arrays, the model should provide values for all accessed indices. For both, uninterpreted functions and arrays, some solvers do not provide all instantiations, but only most of them. A model might contain additional symbols with their evaluation, if a solver uses its own temporary symbols.
- Specified by:
getModelin interfaceBasicProverEnvironment<T>- Throws:
SolverException
-
getUnsatCore
public List<BooleanFormula> getUnsatCore()
Description copied from interface:BasicProverEnvironmentGet an unsat core. This should be called only immediately after anBasicProverEnvironment.isUnsat()call that returnedfalse.- Specified by:
getUnsatCorein interfaceBasicProverEnvironment<T>
-
unsatCoreOverAssumptions
public Optional<List<BooleanFormula>> unsatCoreOverAssumptions(Collection<BooleanFormula> assumptions) throws SolverException, InterruptedException
Description copied from interface:BasicProverEnvironmentReturns an UNSAT core (if it exists, otherwiseOptional.empty()), over the chosen assumptions. Does NOT require theSolverContext.ProverOptions.GENERATE_UNSAT_COREoption to work.- Specified by:
unsatCoreOverAssumptionsin interfaceBasicProverEnvironment<T>- Parameters:
assumptions- Selected assumptions- Returns:
- Empty optional if the constraints with assumptions are satisfiable, subset of assumptions which is unsatisfiable with the original constraints otherwise.
- Throws:
SolverExceptionInterruptedException
-
close
public void close()
Description copied from interface:BasicProverEnvironmentCloses the prover environment. The object should be discarded, and should not be used after closing. The first call of this method will close the prover instance, further calls are ignored.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceBasicProverEnvironment<T>
-
allSat
public <R> R allSat(BasicProverEnvironment.AllSatCallback<R> callback, List<BooleanFormula> important) throws InterruptedException, SolverException
Description copied from interface:BasicProverEnvironmentGet all satisfying assignments of the current environment with regard to a subset of terms, and create a region representing all those models.- Specified by:
allSatin interfaceBasicProverEnvironment<T>important- A set of (positive) variables appearing in the asserted queries. Only these variables will appear in the region.- Returns:
- A region representing all satisfying models of the formula.
- Throws:
InterruptedExceptionSolverException
-
-