Class AbstractProver<T>
- All Implemented Interfaces:
AutoCloseable,BasicProverEnvironment<T>
- Direct Known Subclasses:
AbstractProverWithAllSat
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.sosy_lab.java_smt.api.BasicProverEnvironment
BasicProverEnvironment.AllSatCallback<R> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected booleanprotected final booleanprotected final booleanprotected final booleanprotected final booleanprotected final booleanprotected booleanFields inherited from interface org.sosy_lab.java_smt.api.BasicProverEnvironment
ASSUMPTION_SOLVING_NOT_SUPPORTED, NO_MODEL_HELP, UNSAT_CORE_NOT_SUPPORTED, UNSAT_CORE_WITH_ASSUMPTIONS_NOT_SUPPORTED -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractProver(Set<SolverContext.ProverOptions> pOptions) -
Method Summary
Modifier and TypeMethodDescriptionfinal @Nullable TaddConstraint(BooleanFormula constraint) Add a constraint to the latest backtracking point.protected abstract @Nullable TaddConstraintImpl(BooleanFormula constraint) check()Performs an optimization-aware check and returns the optimization status.protected voidChecks whether the prover has been closed already.protected final voidprotected final voidprotected final voidcheckGenerateInterpolants(Collection<T> formulasOfA) protected final voidprotected final voidcheckGenerateSeqInterpolants(List<? extends Collection<T>> partitionedFormulas) protected final voidcheckGenerateTreeInterpolants(List<? extends Collection<T>> partitionedFormulas, int[] startOfSubTree) protected final voidprotected final voidprotected OptimizationProverEnvironment.OptStatusImplementation of optimization-aware satisfiability-check.voidclose()Closes the prover environment.protected voidprotected ImmutableSet<T>protected ImmutableSet<BooleanFormula>protected ImmutableMap<T,BooleanFormula> Flatten and inverse the prover-stack and return all asserted constraints.final EvaluatorGet a temporary view on the current satisfying assignment.protected Evaluatorfinal ModelgetModel()Get a satisfying assignment.protected abstract Modelprotected abstract booleanfinal booleanisUnsat()Check whether the conjunction of all formulas on the stack is unsatisfiable.protected abstract booleanfinal voidpop()Remove one backtracking point/level from the current stack.protected abstract voidpopImpl()final voidpush()Create a new backtracking point, i.e., a new level on the assertion stack.protected abstract voidpushImpl()protected <E extends Evaluator>
EregisterEvaluator(E pEvaluator) This method registers the Evaluator to be cleaned up before the next change on the prover stack.intsize()Get the number of backtracking points/levels on the current stack.protected voidunregisterEvaluator(Evaluator pEvaluator) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.sosy_lab.java_smt.api.BasicProverEnvironment
allSat, getModelAssignments, getStatistics, getUnsatCore, isUnsatWithAssumptions, push, registerUserPropagator, unsatCoreOverAssumptions
-
Field Details
-
generateModels
protected final boolean generateModels -
generateAllSat
protected final boolean generateAllSat -
generateUnsatCores
protected final boolean generateUnsatCores -
generateUnsatCoresOverAssumptions
protected final boolean generateUnsatCoresOverAssumptions -
enableSL
protected final boolean enableSL -
closed
protected boolean closed -
wasLastSatCheckSatisfiable
protected boolean wasLastSatCheckSatisfiable -
changedSinceLastSatQuery
protected boolean changedSinceLastSatQuery
-
-
Constructor Details
-
AbstractProver
-
-
Method Details
-
checkGenerateModels
protected final void checkGenerateModels() -
checkGenerateAllSat
protected final void checkGenerateAllSat() -
checkGenerateUnsatCores
protected final void checkGenerateUnsatCores() -
checkGenerateUnsatCoresOverAssumptions
protected final void checkGenerateUnsatCoresOverAssumptions() -
checkClosed
protected void checkClosed()Checks whether the prover has been closed already. Only to be used if this is the only check performed in a call. -
checkGenerateInterpolants
-
checkGenerateSeqInterpolants
protected final void checkGenerateSeqInterpolants(List<? extends Collection<T>> partitionedFormulas) -
checkGenerateTreeInterpolants
protected final void checkGenerateTreeInterpolants(List<? extends Collection<T>> partitionedFormulas, int[] startOfSubTree) -
checkEnableSeparationLogic
protected final void checkEnableSeparationLogic() -
hasPersistentModel
protected abstract boolean hasPersistentModel() -
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>
-
push
Description 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
-
pushImpl
- Throws:
InterruptedException
-
pop
public final 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>
-
popImpl
protected abstract void popImpl() -
addConstraint
@CanIgnoreReturnValue public final @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
-
addConstraintImpl
protected abstract @Nullable T addConstraintImpl(BooleanFormula constraint) throws InterruptedException - Throws:
InterruptedException
-
isUnsat
Check whether the conjunction of all formulas on the stack is unsatisfiable.- Specified by:
isUnsatin interfaceBasicProverEnvironment<T>- Throws:
SolverExceptionInterruptedException
-
isUnsatImpl
- Throws:
SolverExceptionInterruptedException
-
check
public final OptimizationProverEnvironment.OptStatus check() throws InterruptedException, SolverExceptionPerforms an optimization-aware check and returns the optimization status.This method is the public entry point for optimization checks. It validates that the prover is open, resets internal change-tracking state, and delegates solver-specific work to
checkImpl(). Subclasses that implement optimization support must provide the actual checking logic incheckImpl().The signature of this method matches that of
OptimizationProverEnvironment.check(), to allow overrides in subclasses that implement bothBasicProverEnvironmentandOptimizationProverEnvironment.- Returns:
- the optimization status;
OptimizationProverEnvironment.OptStatus.OPTindicates a satisfiable/optimal result - Throws:
InterruptedExceptionSolverException
-
checkImpl
protected OptimizationProverEnvironment.OptStatus checkImpl() throws InterruptedException, SolverExceptionImplementation of optimization-aware satisfiability-check.- Throws:
InterruptedException- if the thread is interrupted during the checkSolverException- if the underlying solver reports an errorUnsupportedOperationException- if optimization is not supported by this prover
-
getAssertedFormulas
-
getAssertedConstraintIds
-
getAssertedFormulasById
-
getModel
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
-
getModelImpl
- Throws:
SolverException
-
getEvaluator
Description copied from interface:BasicProverEnvironmentGet a temporary view on the current satisfying assignment. This should be called only immediately after anBasicProverEnvironment.isUnsat()call that returnedfalse. The evaluator should no longer be used as soon as any constraints are added to, pushed, or popped from the prover stack.- Specified by:
getEvaluatorin interfaceBasicProverEnvironment<T>- Throws:
SolverException
-
getEvaluatorImpl
- Throws:
SolverException
-
registerEvaluator
This method registers the Evaluator to be cleaned up before the next change on the prover stack. -
unregisterEvaluator
-
closeAllEvaluators
protected void closeAllEvaluators() -
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>
-