Class Solver_simplify
- All Implemented Interfaces:
ISolver
Note on implementation. Simplify allows only either pushing an assertion to the background or checking that it is valid. Assertions that are pushed (via BG_PUSH) appear to be filtered out of counterexamples. Thus for now we will only use BG_PUSH for background theory axioms; for the rest we will accumulate all assertions into one giant AND (in the conjunction field) and then assert them all at once to Simplify when check-sat is called. The usual push and pop will not be sent to Simplify - rather we save the state of 'conjunction' ourselves. This implements the letter if not the spirit of push and pop, and it may have performance implications. If it does, we'll optimize the implementation then.
Several methods (declare_fun, define_fun, pop, push) send an auxiliary command (BG_PUSH/BG_POP) to the Simplify process and don't inspect its raw response: unlike the main protocol commands (assert, check-sat, ...), nothing in this project's test suite or documentation records what Simplify's failure response for one of these auxiliary commands actually looks like, so there's no format to parse against without guessing (see issue #68).
Extends AbstractSolver (for its real-process plumbing: the shared
solverProcess field, options/checkSatStatus), not Solver_test
(issue #97): Simplify's real process speaks its own bespoke, non-SMT-LIB Lisp-like
protocol (BG_PUSH/an accumulated conjunction sent with check-sat -- see above),
so AbstractSolver's generic defaults (which translate a command to standard
SMT-LIB concrete syntax and send that directly) are not usable for Simplify at all --
every operation below is either genuinely Simplify-specific (talks to the real process
in its own protocol) or a client-side simulation transplanted directly from Solver_test (the operations Simplify's real process cannot itself be asked about at
all: get-model/get-proof/get-unsat-core/etc., reset/reset-assertions, and the
declare/define-sort family, none of which the real BG_PUSH-based protocol below has any
way to express). symTable/assertionSetStack/logicSet are this
class's own copies of exactly what Solver_test tracks, for exactly the same
reason: this class has no real process to ask instead.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.smtlib.AbstractSolver
AbstractSolver.Pending, AbstractSolver.Shape, AbstractSolver.StackChangeNested classes/interfaces inherited from interface org.smtlib.ISolver
ISolver.CreationException -
Field Summary
FieldsModifier and TypeFieldDescriptionThe data structure that maintains this class's own local simulation of the solver's assertion set stack -- seeSolver_test.assertionSetStack.protected StringInternal state variable - set non-null once the logic is set -- seeSolver_test.logicSet.The symbol table used for this class's own local type-checking simulation (see the class Javadoc) -- a straight copy ofSolver_test's own field of the same name and visibility (public forC_what's sake, though that extension command no longer recognizes this class as a symbol-table-bearing solver now that it isn't aSolver_test-- see this session's own restructuring notes; no test exercises "what" against Simplify).Fields inherited from class org.smtlib.AbstractSolver
checkSatStatus, END_WAIT_MILLIS, endedByTimeLimit, isMac, isWindows, linesOffset, options, printSuccess, printSuccessResponse, smtConfig, SOLVER_EXITED, solverProcess -
Constructor Summary
ConstructorsConstructorDescriptionSolver_simplify(SMT.Configuration smtConfig, String executable) Constructor with standard signature for invocation through reflectionSolver_simplify(SMT.Configuration smtConfig, String[] command) Launches the given command as is (a .command property, #147), without adding the flags the executable form adds -
Method Summary
Modifier and TypeMethodDescriptionassertExpr(IExpr expr) Adds the given expression to the current assertion-stack frame.Checks whether the current assertion set is satisfiable under the current logic.check_sat_assuming(IExpr... exprs) check-sat-assuming postdates Simplify by well over a decade (added in SMT-LIB 2.6; Simplify's protocol has no concept of it), and this class has no override for it -- without one, it silently inheritsSolver_test's stub (this class's superclass, the type-check-only pseudo-solver), which never talks to the real Simplify process at all and just echoes back whatever :status a script happened to declare (or "unknown" if none), regardless of whether the assumed literals are actually satisfiable.Datatypes postdate Simplify (added in SMT-LIB 2.6) and its untyped translation (see the class javadoc: "Simplify has no type definitions") has no way to express a datatype's constructors/selectors.Declares a new uninterpreted function (or constant); returns success or an SMT error responseDefines a named function or constant; returns success or an SMT error responseRecursive function definitions postdate Simplify (added in SMT-LIB 2.6) and its axiom-based translation (seedefine_fun(org.smtlib.ICommand.Idefine_fun)/declare_fun(org.smtlib.ICommand.Ideclare_fun)) has no way to express recursion.echo(IExpr.IStringLiteral arg) Echoes the argument string back to the output channel.protected Stringexit()Terminates the solver; no further commands are permitted.get_info(IExpr.IKeyword key) Simplify has no get-info; answered hereget_option(IExpr.IKeyword key) Simplify has no get-option; answered from the values kept by set_optionbooleanNever pipelined: commands are executed here, not sent to a processpop(int number) Removes the given number of assertion-stack frames from the solver state.push(int number) Adds the given number of empty assertion-stack frames to the solver state.reset()Transplanted fromSolver_test.reset(): this class has no real process operation to ask for a reset (Simplify's protocol has no such concept), so this remains an entirely local, client-side reset exactly as it was as an inherited Solver_test method -- it does not, and did not before this restructuring, reset any BG_PUSH state already accumulated in the real Simplify process itself.Transplanted fromSolver_test.reset_assertions().set_info(IExpr.IKeyword key, IAttributeValue value) A set-logic the solver accepts ends sat or unsat mode; one it rejects (as SMT-LIB requires outside start mode) changes nothing.set_option(IExpr.IKeyword option, IAttributeValue value) Simplify has no set-option; options are kept here, and the :produce- options answer unsupported since Simplify cannot produce models, proofs or coresstart()Starts the solver; this is not an SMT-LIB command, but it is convenient in some implementations to separate the starting and initialization from the construction of the solver instance.Methods inherited from class org.smtlib.AbstractSolver
checkImmediateExit, checkPrintSuccess, checkSatStatus, checkShape, checkStatus, comment, correctResponse, earlierSourceLine, errorStopsSolver, execute, executePipelined, exitedResponse, finishPipelined, forceExit, hasPending, inSatMode, interrupt, inUnsatMode, isFlatResponse, isTimeLimitResponse, lineNumberPatterns, logSolverDiagnostics, modelResponse, nextSolverLine, normalizeForTesting, outOfStep, parseResponse, proofResponse, readPipelined, recordChange, reportsEarlierLines, reportSeedIgnored, requireNoChangeSinceCheck, requireOptionEnabled, requireSatOrUnknown, requireUnsat, responseEnd, selfReportsImmediateExit, sendChange, sendCommand, sendExitCommand, sendFailure, sendFailure, sendPipelined, sendScriptText, sendSeed, set_option_impl, setSourceLine, shapeOf, smt, solverName, solverPrintsSuccess, successOrEmpty, timeLimitResponse, timeLimitResponseAfterExit, translate, unsatAssumptionsElements, unsatCoreElements, withSourceLinesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.smtlib.ISolver
checkSatStatus, comment, execute, forceExit, setSourceLine, smt, solverName
-
Field Details
-
symTable
The symbol table used for this class's own local type-checking simulation (see the class Javadoc) -- a straight copy ofSolver_test's own field of the same name and visibility (public forC_what's sake, though that extension command no longer recognizes this class as a symbol-table-bearing solver now that it isn't aSolver_test-- see this session's own restructuring notes; no test exercises "what" against Simplify). -
assertionSetStack
The data structure that maintains this class's own local simulation of the solver's assertion set stack -- seeSolver_test.assertionSetStack. -
logicSet
Internal state variable - set non-null once the logic is set -- seeSolver_test.logicSet.
-
-
Constructor Details
-
Solver_simplify
Constructor with standard signature for invocation through reflection -
Solver_simplify
Launches the given command as is (a .command property, #147), without adding the flags the executable form adds
-
-
Method Details
-
start
Description copied from interface:ISolverStarts the solver; this is not an SMT-LIB command, but it is convenient in some implementations to separate the starting and initialization from the construction of the solver instance.- Specified by:
startin interfaceISolver- Overrides:
startin classAbstractSolver- Returns:
- success or an SMT error response
- See Also:
-
exit
Description copied from interface:ISolverTerminates the solver; no further commands are permitted.- Specified by:
exitin interfaceISolver- Overrides:
exitin classAbstractSolver- Returns:
- success or an SMT error response
- See Also:
-
echo
Description copied from interface:ISolverEchoes the argument string back to the output channel.- Specified by:
echoin interfaceISolver- Overrides:
echoin classAbstractSolver- Returns:
- the argument as an IResponse
-
pipelines
Never pipelined: commands are executed here, not sent to a process- Overrides:
pipelinesin classAbstractSolver
-
assertExpr
Description copied from interface:ISolverAdds the given expression to the current assertion-stack frame. The SMT-LIB command name isassert; the Java method name differs to avoid the Java reserved word.- Specified by:
assertExprin interfaceISolver- Overrides:
assertExprin classAbstractSolver- Returns:
- success or an SMT error response
- See Also:
-
encode
-
reset
Transplanted fromSolver_test.reset(): this class has no real process operation to ask for a reset (Simplify's protocol has no such concept), so this remains an entirely local, client-side reset exactly as it was as an inherited Solver_test method -- it does not, and did not before this restructuring, reset any BG_PUSH state already accumulated in the real Simplify process itself.- Specified by:
resetin interfaceISolver- Overrides:
resetin classAbstractSolver- Returns:
- success or an SMT error response
- See Also:
-
reset_assertions
Transplanted fromSolver_test.reset_assertions().- Specified by:
reset_assertionsin interfaceISolver- Overrides:
reset_assertionsin classAbstractSolver- Returns:
- success or an SMT error response
- See Also:
-
check_sat_assuming
check-sat-assuming postdates Simplify by well over a decade (added in SMT-LIB 2.6; Simplify's protocol has no concept of it), and this class has no override for it -- without one, it silently inheritsSolver_test's stub (this class's superclass, the type-check-only pseudo-solver), which never talks to the real Simplify process at all and just echoes back whatever :status a script happened to declare (or "unknown" if none), regardless of whether the assumed literals are actually satisfiable. That's not a graceful "can't do this," it's a wrong answer that looks like a real one. Report it as unsupported instead, matching how every other genuinely-unavailable feature in this class (produce-models, produce-proofs, etc., inset_option(org.smtlib.IExpr.IKeyword, org.smtlib.IAttributeValue)) is already handled.The validation below (logic-set check, then type-checking each assumed literal) duplicates
Solver_test.check_sat_assuming(org.smtlib.IExpr...)'s own precondition checks rather than callingsuper.check_sat_assuming(exprs)and inspecting the result -- that method's only non-error path sets checkSatStatus to the misleading status this override exists to avoid, as a side effect that would happen before this method ever got a chance to override the *return value*. Real, structural errors (bad sorts, undeclared symbols, logic not yet set) should still be reported precisely, matching what a real solver would catch before ever getting to "I don't support this" -- only well-formed input falls through to unsupported.- Specified by:
check_sat_assumingin interfaceISolver- Overrides:
check_sat_assumingin classAbstractSolver- Returns:
- sat, unsat, unknown, or an SMT error response
- See Also:
-
define_fun_rec
Recursive function definitions postdate Simplify (added in SMT-LIB 2.6) and its axiom-based translation (seedefine_fun(org.smtlib.ICommand.Idefine_fun)/declare_fun(org.smtlib.ICommand.Ideclare_fun)) has no way to express recursion. Without an override,Solver_test's version would register it in the local type-checking symbol table and report success without the real Simplify process ever learning about it -- misleading, same ascheck_sat_assuming(org.smtlib.IExpr...). Validation logic duplicated fromSolver_test.define_fun_rec(org.smtlib.ICommand.Idefine_fun_rec)for the same reason given there: real structural errors (e.g. an undeclared parameter/result sort) must still be reported precisely, not masked behind "unsupported".- Specified by:
define_fun_recin interfaceISolver- Overrides:
define_fun_recin classAbstractSolver- See Also:
-
define_funs_rec
- Specified by:
define_funs_recin interfaceISolver- Overrides:
define_funs_recin classAbstractSolver- See Also:
-
declare_datatype
Datatypes postdate Simplify (added in SMT-LIB 2.6) and its untyped translation (see the class javadoc: "Simplify has no type definitions") has no way to express a datatype's constructors/selectors. Seedefine_fun_rec(org.smtlib.ICommand.Idefine_fun_rec)for why this needs an explicit override rather than falling through toSolver_test's local-symbol-table-only version. Only name-clash validation is duplicated here (via the public, staticTypeChecker.validateDatatypeNames(org.smtlib.SymbolTable, org.smtlib.SMT.Configuration, java.util.List<org.smtlib.IExpr.ISortDeclaration>, java.util.List<org.smtlib.ISort.IDatatype>)) --Solver_test's deeper per-constructor/selector validation and symbol-table registration lives in a private method this class cannot reach, and isn't worth reimplementing here: nothing declared inside an unsupported datatype could ever usefully resolve against Simplify's real (untyped) process anyway.- Specified by:
declare_datatypein interfaceISolver- Overrides:
declare_datatypein classAbstractSolver
-
declare_datatypes
- Specified by:
declare_datatypesin interfaceISolver- Overrides:
declare_datatypesin classAbstractSolver
-
check_sat
Description copied from interface:ISolverChecks whether the current assertion set is satisfiable under the current logic.- Specified by:
check_satin interfaceISolver- Overrides:
check_satin classAbstractSolver- Returns:
- sat, unsat, unknown, or an SMT error response
- See Also:
-
declare_fun
Description copied from interface:ISolverDeclares a new uninterpreted function (or constant); returns success or an SMT error response- Specified by:
declare_funin interfaceISolver- Overrides:
declare_funin classAbstractSolver- See Also:
-
define_fun
Description copied from interface:ISolverDefines a named function or constant; returns success or an SMT error response- Specified by:
define_funin interfaceISolver- Overrides:
define_funin classAbstractSolver- See Also:
-
pop
Description copied from interface:ISolverRemoves the given number of assertion-stack frames from the solver state.- Specified by:
popin interfaceISolver- Overrides:
popin classAbstractSolver- Parameters:
number- non-negative number of frames to pop- Returns:
- success or an SMT error response
- See Also:
-
push
Description copied from interface:ISolverAdds the given number of empty assertion-stack frames to the solver state.- Specified by:
pushin interfaceISolver- Overrides:
pushin classAbstractSolver- Parameters:
number- non-negative number of frames to push- Returns:
- success or an SMT error response
- See Also:
-
set_logic
Description copied from class:AbstractSolverA set-logic the solver accepts ends sat or unsat mode; one it rejects (as SMT-LIB requires outside start mode) changes nothing.- Specified by:
set_logicin interfaceISolver- Overrides:
set_logicin classAbstractSolver- Parameters:
logicName- the name of the logicpos- source position used only for error messages; may be null- Returns:
- success or unsupported or an SMT error response
- See Also:
-
set_option
Simplify has no set-option; options are kept here, and the :produce- options answer unsupported since Simplify cannot produce models, proofs or cores- Specified by:
set_optionin interfaceISolver- Overrides:
set_optionin classAbstractSolver- Parameters:
option- the keyword naming the optionvalue- the value to set- Returns:
- success, unsupported, or an SMT error response
- See Also:
-
get_option
Simplify has no get-option; answered from the values kept by set_option- Specified by:
get_optionin interfaceISolver- Overrides:
get_optionin classAbstractSolver- Parameters:
key- the keyword naming the option- Returns:
- the option value, or unsupported, or an SMT error response
- See Also:
-
get_info
Simplify has no get-info; answered here- Specified by:
get_infoin interfaceISolver- Overrides:
get_infoin classAbstractSolver- Parameters:
key- the info keyword- Returns:
- the info value, or unsupported, or an SMT error response
- See Also:
-
get_assertions
- Specified by:
get_assertionsin interfaceISolver- Overrides:
get_assertionsin classAbstractSolver- Returns:
- a sequence of asserted terms, unsupported, or an SMT error response
- See Also:
-
get_value
- Specified by:
get_valuein interfaceISolver- Overrides:
get_valuein classAbstractSolver- Parameters:
terms- expressions to evaluate- Returns:
- a list of term–value pairs, unsupported, or an SMT error response
- See Also:
-
get_assignment
- Specified by:
get_assignmentin interfaceISolver- Overrides:
get_assignmentin classAbstractSolver- Returns:
- a list of name–Boolean pairs, unsupported, or an SMT error response
- See Also:
-
get_proof
- Specified by:
get_proofin interfaceISolver- Overrides:
get_proofin classAbstractSolver- Returns:
- a proof, unsupported, or an SMT error response
- See Also:
-
get_model
- Specified by:
get_modelin interfaceISolver- Overrides:
get_modelin classAbstractSolver- Returns:
- a model, unsupported, or an SMT error response
- See Also:
-
get_unsat_assumptions
- Specified by:
get_unsat_assumptionsin interfaceISolver- Overrides:
get_unsat_assumptionsin classAbstractSolver- Returns:
- a list of assumption literals, unsupported, or an SMT error response
- See Also:
-
get_unsat_core
- Specified by:
get_unsat_corein interfaceISolver- Overrides:
get_unsat_corein classAbstractSolver- Returns:
- a list of formula names, unsupported, or an SMT error response
- See Also:
-
declare_const
- Specified by:
declare_constin interfaceISolver- Overrides:
declare_constin classAbstractSolver- See Also:
-
define_const
- Specified by:
define_constin interfaceISolver- Overrides:
define_constin classAbstractSolver- See Also:
-
declare_sort
- Specified by:
declare_sortin interfaceISolver- Overrides:
declare_sortin classAbstractSolver- See Also:
-
declare_sort_parameter
- Specified by:
declare_sort_parameterin interfaceISolver- Overrides:
declare_sort_parameterin classAbstractSolver- See Also:
-
define_sort
- Specified by:
define_sortin interfaceISolver- Overrides:
define_sortin classAbstractSolver- See Also:
-
set_info
- Specified by:
set_infoin interfaceISolver- Overrides:
set_infoin classAbstractSolver- Parameters:
key- the info keywordvalue- the attribute value- Returns:
- success, unsupported, or an SMT error response
- See Also:
-
translate
- Throws:
IVisitor.VisitorException
-