Class BasicProverWithAssumptionsWrapper<T,P extends BasicProverEnvironment<T>>
- java.lang.Object
-
- org.sosy_lab.java_smt.basicimpl.withAssumptionsWrapper.BasicProverWithAssumptionsWrapper<T,P>
-
- All Implemented Interfaces:
AutoCloseable,BasicProverEnvironment<T>
- Direct Known Subclasses:
InterpolatingProverWithAssumptionsWrapper,ProverWithAssumptionsWrapper
public class BasicProverWithAssumptionsWrapper<T,P extends BasicProverEnvironment<T>> extends Object implements BasicProverEnvironment<T>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.sosy_lab.java_smt.api.BasicProverEnvironment
BasicProverEnvironment.AllSatCallback<R>
-
-
Field Summary
Fields Modifier and Type Field Description protected Pdelegateprotected List<BooleanFormula>solverAssumptionsAsFormula-
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 TaddConstraint(BooleanFormula constraint)Add a constraint to the latest backtracking point.<R> RallSat(BasicProverEnvironment.AllSatCallback<R> pCallback, List<BooleanFormula> pImportant)Get all satisfying assignments of the current environment with regard to a subset of terms, and create a region representing all those models.protected voidclearAssumptions()voidclose()Closes the prover environment.ModelgetModel()Get a satisfying assignment.ImmutableList<Model.ValueAssignment>getModelAssignments()Get a list of satisfying assignments.ImmutableMap<String,String>getStatistics()Get statistics for a concrete ProverEnvironment in a solver.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.protected voidregisterPushedFormula(T pPushResult)overridden in subclass.intsize()Get the number of backtracking points/levels on the current stack.StringtoString()Optional<List<BooleanFormula>>unsatCoreOverAssumptions(Collection<BooleanFormula> pAssumptions)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, wait, wait, wait
-
Methods inherited from interface org.sosy_lab.java_smt.api.BasicProverEnvironment
getEvaluator, push, registerUserPropagator
-
-
-
-
Field Detail
-
delegate
protected final P extends BasicProverEnvironment<T> delegate
-
solverAssumptionsAsFormula
protected final List<BooleanFormula> solverAssumptionsAsFormula
-
-
Method Detail
-
clearAssumptions
protected void clearAssumptions()
-
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 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
-
registerPushedFormula
protected void registerPushedFormula(T pPushResult)
overridden in subclass.
-
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
-
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> pAssumptions) 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:
pAssumptions- 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
-
getStatistics
public ImmutableMap<String,String> getStatistics()
Description copied from interface:BasicProverEnvironmentGet statistics for a concrete ProverEnvironment in a solver. The returned mapping is intended to provide solver-internal statistics for only this instance. The keys can differ between individual solvers.Calling the statistics several times for the same
ProverEnvironments returns accumulated number, i.e., we currently do not provide any possibility to reset the statistics. Calling the statistics for differentProverEnvironments returns independent statistics.We do not guarantee any specific key to be present, as this depends on the used solver. We might even return an empty mapping if the solver does not support calling this method or is in an invalid state.
- Specified by:
getStatisticsin interfaceBasicProverEnvironment<T>- See Also:
SolverContext.getStatistics()
-
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> pCallback, List<BooleanFormula> pImportant) 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>pImportant- 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
-
-