Class ReusableStackInterpolatingProver<T>
- java.lang.Object
-
- org.sosy_lab.java_smt.basicimpl.reusableStack.ReusableStackInterpolatingProver<T>
-
- All Implemented Interfaces:
AutoCloseable,BasicProverEnvironment<T>,InterpolatingProverEnvironment<T>
public class ReusableStackInterpolatingProver<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
NO_MODEL_HELP
-
-
Constructor Summary
Constructors Constructor Description ReusableStackInterpolatingProver(InterpolatingProverEnvironment<T> pDelegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TaddConstraint(BooleanFormula pConstraint)Add constraint to the context.<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> pFormulasOfA)Get an interpolant for two groups of formulas.ModelgetModel()Get a satisfying assignment.ImmutableList<Model.ValueAssignment>getModelAssignments()Get a list of satisfying assignments.List<BooleanFormula>getSeqInterpolants(List<? extends Collection<T>> pPartitionedFormulas)This method returns interpolants of an 'inductive sequence'.List<BooleanFormula>getTreeInterpolants(List<? extends Collection<T>> pPartitionedFormulas, int[] pStartOfSubTree)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> pAssumptions)Check whether the conjunction of all formulas on the stack together with the list of assumptions is satisfiable.voidpop()Remove one formula from the environment stack.voidpush()Create backtracking point.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, getModel, getModelAssignments, getUnsatCore, isUnsat, isUnsatWithAssumptions, pop, push, push, unsatCoreOverAssumptions
-
Methods inherited from interface org.sosy_lab.java_smt.api.InterpolatingProverEnvironment
getSeqInterpolants0, getTreeInterpolants0
-
-
-
-
Constructor Detail
-
ReusableStackInterpolatingProver
public ReusableStackInterpolatingProver(InterpolatingProverEnvironment<T> pDelegate)
-
-
Method Detail
-
getInterpolant
public BooleanFormula getInterpolant(Collection<T> pFormulasOfA) 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 (all?) solvers as long as the same proof is used, i.e. all interpolants are computed after the same SAT-check.
- Specified by:
getInterpolantin interfaceInterpolatingProverEnvironment<T>- Parameters:
pFormulasOfA- 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>> pPartitionedFormulas) 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:
- a '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>> pPartitionedFormulas, int[] pStartOfSubTree) 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:
pPartitionedFormulas- of formulaspStartOfSubTree- 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
-
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> pAssumptions) 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:
pAssumptions- A list of literals.- Throws:
SolverExceptionInterruptedException
-
push
public final void push()
Description copied from interface:BasicProverEnvironmentCreate backtracking point.- Specified by:
pushin interfaceBasicProverEnvironment<T>
-
pop
public void pop()
Description copied from interface:BasicProverEnvironmentRemove one formula from the environment stack.- Specified by:
popin interfaceBasicProverEnvironment<T>
-
addConstraint
public T addConstraint(BooleanFormula pConstraint) throws InterruptedException
Description copied from interface:BasicProverEnvironmentAdd constraint to the context.- Specified by:
addConstraintin interfaceBasicProverEnvironment<T>- Throws:
InterruptedException
-
getModel
public Model getModel() throws SolverException
Description copied from interface:BasicProverEnvironmentGet a satisfying assignment. This should be called only immediately after anBasicProverEnvironment.isUnsat()call that returnedfalse. A model might contain additional symbols with their evaluation, if a solver uses its own temporary symbols. There should be at least a value-assignment for each free symbol.- Specified by:
getModelin interfaceBasicProverEnvironment<T>- Throws:
SolverException
-
getModelAssignments
public ImmutableList<Model.ValueAssignment> getModelAssignments() throws SolverException
Description copied from interface:BasicProverEnvironmentGet a list of satisfying assignments. This is equivalent toImmutableList.copyOf(getModel()), but removes the need for callingModel.close().Note that if you need to iterate multiple times over the model it may be more efficient to use this method instead of
BasicProverEnvironment.getModel()(depending on the solver).- Specified by:
getModelAssignmentsin 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.- 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
-
-