CVC3
2.4.1
|
Abstract Theory Interface. More...
Functions | |
virtual void | CVC3::Theory::addSharedTerm (const Expr &e) |
Notify theory of a new shared term. | |
virtual void | CVC3::Theory::assertFact (const Theorem &e)=0 |
Assert a new fact to the decision procedure. | |
virtual void | CVC3::Theory::checkSat (bool fullEffort)=0 |
Check for satisfiability in the theory. | |
virtual Theorem | CVC3::Theory::rewrite (const Expr &e) |
Theory-specific rewrite rules. | |
virtual Theorem | CVC3::Theory::theoryPreprocess (const Expr &e) |
Theory-specific preprocessing. | |
virtual void | CVC3::Theory::setup (const Expr &e) |
Set up the term e for call-backs when e or its children change. | |
virtual void | CVC3::Theory::update (const Theorem &e, const Expr &d) |
Notify a theory of a new equality. | |
virtual Theorem | CVC3::Theory::solve (const Theorem &e) |
An optional solver. | |
virtual void | CVC3::Theory::checkAssertEqInvariant (const Theorem &e) |
A debug check used by the primary solver. | |
virtual Theorem | CVC3::Theory::simplifyOp (const Expr &e) |
Recursive simplification step. | |
virtual void | CVC3::Theory::checkType (const Expr &e) |
Check that e is a valid Type expr. | |
virtual Cardinality | CVC3::Theory::finiteTypeInfo (Expr &e, Unsigned &n, bool enumerate, bool computeSize) |
Compute information related to finiteness of types. | |
virtual void | CVC3::Theory::computeType (const Expr &e) |
Compute and store the type of e. | |
virtual Type | CVC3::Theory::computeBaseType (const Type &tp) |
Compute the base type of the top-level operator of an arbitrary type. | |
virtual Expr | CVC3::Theory::computeTypePred (const Type &t, const Expr &e) |
Theory specific computation of the subtyping predicate for type t applied to the expression e. | |
virtual Expr | CVC3::Theory::computeTCC (const Expr &e) |
Compute and cache the TCC of e. | |
virtual Expr | CVC3::Theory::parseExprOp (const Expr &e) |
Theory-specific parsing implemented by the DP. | |
virtual ExprStream & | CVC3::Theory::print (ExprStream &os, const Expr &e) |
Theory-specific pretty-printing. | |
virtual void | CVC3::Theory::computeModelTerm (const Expr &e, std::vector< Expr > &v) |
Add variables from 'e' to 'v' for constructing a concrete model. | |
virtual void | CVC3::Theory::refineCounterExample () |
Process disequalities from the arrangement for model generation. | |
virtual void | CVC3::Theory::computeModelBasic (const std::vector< Expr > &v) |
Assign concrete values to basic-type variables in v. | |
virtual void | CVC3::Theory::computeModel (const Expr &e, std::vector< Expr > &vars) |
Compute the value of a compound variable from the more primitive ones. | |
virtual void | CVC3::Theory::assertTypePred (const Expr &e, const Theorem &pred) |
Receives all the type predicates for the types of the given theory. | |
virtual Theorem | CVC3::Theory::rewriteAtomic (const Expr &e) |
Theory-specific rewrites for atomic formulas. | |
virtual void | CVC3::Theory::notifyInconsistent (const Theorem &thm) |
Notification of conflict. | |
virtual void | CVC3::Theory::registerAtom (const Expr &e, const Theorem &thm) |
virtual void | CVC3::Theory::registerAtom (const Expr &e) |
Theory-specific registration of atoms. |
Abstract Theory Interface.
These are the theory-specific methods which provide the decision procedure functionality for a new theory. At the very least, a theory must implement the checkSat method. The other methods can be used to make the implementation more convenient. For more information on this API, see Clark Barrett's PhD dissertation and HOWTO Write a Decision Procedure.
|
inlinevirtual |
Notify theory of a new shared term.
When a term e associated with theory i occurs as a child of an expression associated with theory j, the framework calls i->addSharedTerm(e) and j->addSharedTerm(e)
Reimplemented in CVC3::TheoryQuant, CVC3::TheoryCore, CVC3::TheoryArithOld, CVC3::TheoryArith3, CVC3::TheoryBitvector, CVC3::TheoryArithNew, CVC3::TheoryArith, CVC3::TheoryDatatype, CVC3::TheoryArray, and CVC3::TheoryUF.
Definition at line 127 of file theory.h.
Referenced by CVC3::TheoryCore::collectBasicVars(), and CVC3::TheoryCore::setupTerm().
|
pure virtual |
Assert a new fact to the decision procedure.
Each fact that makes it into the core framework is assigned to exactly one theory: the theory associated with that fact. assertFact is called to inform the theory that a new fact has been assigned to the theory.
Implemented in CVC3::TheoryQuant, CVC3::TheoryCore, CVC3::TheoryArithOld, CVC3::TheoryArith3, CVC3::TheoryBitvector, CVC3::TheoryArithNew, CVC3::TheoryArith, CVC3::TheoryDatatype, CVC3::TheoryArray, CVC3::TheoryUF, CVC3::TheoryRecords, and CVC3::TheorySimulate.
Referenced by CVC3::TheoryCore::assertFormula().
|
pure virtual |
Check for satisfiability in the theory.
fullEffort | when it is false, checkSat can do as much or as little work as it likes, though simple inferences and checks for consistency should be done to increase efficiency. If fullEffort is true, checkSat must check whether the set of facts given by assertFact together with the arrangement of shared terms (provided by addSharedTerm) induced by the global find database equivalence relation are satisfiable. If satisfiable, checkSat does nothing. |
If satisfiability can be acheived by merging some of the shared terms, a new fact must be enqueued using enqueueFact (this fact need not be a literal). If there is no way to make things satisfiable, setInconsistent must be called.
Implemented in CVC3::TheoryQuant, CVC3::TheoryCore, CVC3::TheoryArithOld, CVC3::TheoryArith3, CVC3::TheoryBitvector, CVC3::TheoryArithNew, CVC3::TheoryArith, CVC3::TheoryDatatype, CVC3::TheoryArray, CVC3::TheoryUF, CVC3::TheoryRecords, CVC3::TheoryDatatypeLazy, and CVC3::TheorySimulate.
|
inlinevirtual |
Theory-specific rewrite rules.
By default, rewrite just returns a reflexive theorem stating that the input expression is equivalent to itself. However, rewrite is allowed to return any theorem which describes how the input expression is equivalent to some new expression. rewrite should be used to perform simplifications, normalization, and any other preprocessing on theory-specific expressions that needs to be done.
Reimplemented in CVC3::TheoryCore, CVC3::TheoryArithOld, CVC3::TheoryArith3, CVC3::TheoryBitvector, CVC3::TheoryArithNew, CVC3::TheoryArith, CVC3::TheoryDatatype, CVC3::TheoryArray, CVC3::TheoryUF, CVC3::TheoryRecords, and CVC3::TheorySimulate.
Definition at line 159 of file theory.h.
References CVC3::Theory::reflexivityRule().
Referenced by CVC3::TheoryCore::rewrite().
|
inlinevirtual |
Theory-specific preprocessing.
This gets called each time a new assumption or query is preprocessed. By default it does nothing.
Definition at line 164 of file theory.h.
References CVC3::Theory::reflexivityRule().
Referenced by CVC3::TheoryCore::callTheoryPreprocess().
|
inlinevirtual |
Set up the term e for call-backs when e or its children change.
setup is called once for each expression associated with the theory. It is typically used to setup theory-specific data for an expression and to add call-back information for use with update.
Reimplemented in CVC3::TheoryQuant, CVC3::TheoryCore, CVC3::TheoryArithOld, CVC3::TheoryArith3, CVC3::TheoryBitvector, CVC3::TheoryArithNew, CVC3::TheoryArith, CVC3::TheoryDatatype, CVC3::TheoryArray, CVC3::TheoryRecords, CVC3::TheoryUF, and CVC3::TheoryDatatypeLazy.
Definition at line 172 of file theory.h.
Referenced by CVC3::TheoryCore::setupTerm().
Notify a theory of a new equality.
update is a call-back used by the notify mechanism of the core theory. It works as follows. When an equation t1 = t2 makes it into the core framework, the two find equivalence classes for t1 and t2 are merged. The result is that t2 is the new equivalence class representative and t1 is no longer an equivalence class representative. When this happens, the notify list of t1 is traversed. Notify list entries consist of a theory and an expression d. For each entry (i,d), i->update(e, d) is called, where e is the theorem corresponding to the equality t1=t2.
To add the entry (i,d) to a term t1's notify list, a call must be made to t1.addNotify(i,d). This is typically done in setup.
Reimplemented in CVC3::TheoryQuant, CVC3::TheoryCore, CVC3::TheoryArithOld, CVC3::TheoryArith3, CVC3::TheoryBitvector, CVC3::TheoryArithNew, CVC3::TheoryArith, CVC3::TheoryDatatype, CVC3::TheoryArray, CVC3::TheoryRecords, CVC3::TheoryUF, and CVC3::TheoryDatatypeLazy.
Definition at line 189 of file theory.h.
Referenced by CVC3::TheoryCore::processNotify().
|
inlinevirtual |
An optional solver.
The solve method can be used to implement a Shostak-style solver. Since solvers do not in general combine, the following technique is used. One theory is designated as the primary solver (in our case, it is the theory of arithmetic). For each equation that enters the core framework, the primary solver is called to ensure that the equation is in solved form with respect to the primary theory.
After the primary solver, the solver for the theory associated with the equation is called. This solver can do whatever it likes, as long as the result is still in solved form with respect to the primary solver. This is a slight generalization of what is described in my (Clark)'s PhD thesis.
Reimplemented in CVC3::TheoryCore, CVC3::TheoryArithOld, CVC3::TheoryArith3, CVC3::TheoryBitvector, CVC3::TheoryArithNew, CVC3::TheoryArith, CVC3::TheoryDatatype, and CVC3::TheoryArray.
Definition at line 204 of file theory.h.
Referenced by CVC3::TheoryCore::checkEquation(), and CVC3::TheoryCore::solve().
|
inlinevirtual |
A debug check used by the primary solver.
Reimplemented in CVC3::TheoryArithOld, CVC3::TheoryArith3, CVC3::TheoryArithNew, and CVC3::TheoryArith.
Definition at line 206 of file theory.h.
Referenced by CVC3::TheoryCore::assertEqualities().
Recursive simplification step.
INVARIANT: the result is a Theorem(e=e'), where e' is a fully simplified version of e. To simplify subexpressions recursively, call simplify() function.
This theory-specific method is called when the simplifier descends top-down into the expression. Normally, every kid is simplified recursively, and the results are combined into the new parent with the same operator (Op). This functionality is provided with the default implementation.
However, in some expressions some kids may not matter in the result, and can be skipped. For instance, if the first kid in a long AND simplifies to FALSE, then the entire expression simplifies to FALSE, and the remaining kids do not need to be simplified.
This call is a chance for a DP to provide these types of optimizations during the top-down phase of simplification.
Reimplemented in CVC3::TheoryCore.
Definition at line 53 of file theory.cpp.
References CVC3::Expr::arity(), CVC3::Theory::d_commonRules, CVC3::Theory::d_theoryCore, CVC3::Theorem::isRefl(), CVC3::Theory::reflexivityRule(), CVC3::TheoryCore::simplify(), and CVC3::CommonProofRules::substitutivityRule().
|
inlinevirtual |
Check that e is a valid Type expr.
Reimplemented in CVC3::TheoryCore, CVC3::TheoryArithOld, CVC3::TheoryArith3, CVC3::TheoryBitvector, CVC3::TheoryArithNew, CVC3::TheoryArith, CVC3::TheoryDatatype, CVC3::TheoryArray, CVC3::TheoryUF, and CVC3::TheoryRecords.
Definition at line 236 of file theory.h.
References CVC3::Expr::toString().
|
inlinevirtual |
Compute information related to finiteness of types.
Used by the TypeComputer defined in TheoryCore (theories should not call this funtion directly – they should use the methods in Type instead). Each theory should implement this if it contains any types that could be non-infinite.
Reimplemented in CVC3::TheoryCore, CVC3::TheoryArithOld, CVC3::TheoryArith3, CVC3::TheoryBitvector, CVC3::TheoryArithNew, CVC3::TheoryArith, CVC3::TheoryDatatype, CVC3::TheoryArray, CVC3::TheoryUF, and CVC3::TheoryRecords.
Definition at line 252 of file theory.h.
References CVC3::CARD_INFINITE.
Referenced by CVC3::TheoryUF::finiteTypeInfo(), and CVC3::TheoryDatatype::finiteTypeInfo().
|
inlinevirtual |
Compute and store the type of e.
e | is the expression whose type is computed. |
This function computes the type of the top-level operator of e, and recurses into children using getType(), if necessary.
Reimplemented in CVC3::TheoryQuant, CVC3::TheoryCore, CVC3::TheoryArithOld, CVC3::TheoryArith3, CVC3::TheoryBitvector, CVC3::TheoryArithNew, CVC3::TheoryArith, CVC3::TheoryDatatype, CVC3::TheoryArray, CVC3::TheoryUF, CVC3::TheoryRecords, and CVC3::TheorySimulate.
Definition at line 263 of file theory.h.
Referenced by CVC3::TypeComputerCore::computeType(), and CVC3::TheoryUF::computeType().
|
inlinevirtual |
Compute the base type of the top-level operator of an arbitrary type.
Reimplemented in CVC3::TheoryCore, CVC3::TheoryArithOld, CVC3::TheoryArith3, CVC3::TheoryArithNew, CVC3::TheoryArith, CVC3::TheoryArray, CVC3::TheoryUF, and CVC3::TheoryRecords.
Definition at line 265 of file theory.h.
Referenced by CVC3::Theory::getBaseType().
Theory specific computation of the subtyping predicate for type t applied to the expression e.
By default returns true. Each theory needs to compute subtype predicates for the types associated with it. So, for example, the theory of records will take a record type [# f1: T1, f2: T2 #] and an expression e and will return the subtyping predicate for e, namely: computeTypePred(T1, e.f1) AND computeTypePred(T2, e.f2)
Reimplemented in CVC3::TheoryCore, CVC3::TheoryArithOld, CVC3::TheoryArith3, CVC3::TheoryBitvector, CVC3::TheoryArithNew, CVC3::TheoryArith, and CVC3::TheoryRecords.
Definition at line 275 of file theory.h.
References CVC3::Expr::getEM(), and CVC3::ExprManager::trueExpr().
Referenced by CVC3::TheoryCore::computeTypePred(), and CVC3::Theory::getTypePred().
Compute and cache the TCC of e.
e | is an expression (term or formula). This function computes the TCC of e which is true iff the expression is defined. |
This function computes the TCC or predicate of the top-level operator of e, and recurses into children using getTCC(), if necessary.
The default implementation is to compute TCCs recursively for all children, and return their conjunction.
Reimplemented in CVC3::TheoryQuant, CVC3::TheoryCore, CVC3::TheoryArithOld, CVC3::TheoryArith3, CVC3::TheoryBitvector, CVC3::TheoryArithNew, CVC3::TheoryArith, CVC3::TheoryDatatype, CVC3::TheoryArray, CVC3::TheoryUF, CVC3::TheoryRecords, and CVC3::TheorySimulate.
Definition at line 81 of file theory.cpp.
References CVC3::andExpr(), CVC3::Expr::begin(), CVC3::Theory::d_commonRules, CVC3::Expr::end(), CVC3::Theorem::getRHS(), CVC3::Theory::getTCC(), CVC3::CommonProofRules::rewriteAnd(), and CVC3::Theory::trueExpr().
Referenced by CVC3::TheoryRecords::computeTCC(), CVC3::TheoryUF::computeTCC(), CVC3::TheoryArray::computeTCC(), CVC3::TheoryDatatype::computeTCC(), CVC3::TheoryArithNew::computeTCC(), CVC3::TheoryArith3::computeTCC(), CVC3::TheoryArithOld::computeTCC(), CVC3::TheoryCore::computeTCC(), and CVC3::Theory::getTCC().
|
inlinevirtual |
Theory-specific parsing implemented by the DP.
Reimplemented in CVC3::TheoryQuant, CVC3::TheoryCore, CVC3::TheoryArithOld, CVC3::TheoryArith3, CVC3::TheoryBitvector, CVC3::TheoryArithNew, CVC3::TheoryArith, CVC3::TheoryDatatype, CVC3::TheoryArray, CVC3::TheoryUF, CVC3::TheoryRecords, and CVC3::TheorySimulate.
Definition at line 292 of file theory.h.
Referenced by CVC3::TheoryCore::parseExpr().
|
inlinevirtual |
Theory-specific pretty-printing.
By default, print the top node in AST, and resume pretty-printing the children. The same call e.print(os) can be used in DP-specific printers to use AST printing for the given node. In fact, it is strongly recommended to add e.print(os) as the default for all the cases/kinds that are not handled by the particular pretty-printer.
Reimplemented in CVC3::TheoryQuant, CVC3::TheoryCore, CVC3::TheoryArithOld, CVC3::TheoryArith3, CVC3::TheoryBitvector, CVC3::TheoryArithNew, CVC3::TheoryArith, CVC3::TheoryDatatype, CVC3::TheoryArray, CVC3::TheoryUF, CVC3::TheoryRecords, and CVC3::TheorySimulate.
Definition at line 302 of file theory.h.
References CVC3::Expr::printAST().
Add variables from 'e' to 'v' for constructing a concrete model.
If e is already of primitive type, do NOT add it to v.
Reimplemented in CVC3::TheoryArithOld, CVC3::TheoryArith3, CVC3::TheoryBitvector, CVC3::TheoryArithNew, CVC3::TheoryArith, CVC3::TheoryDatatype, CVC3::TheoryArray, CVC3::TheoryUF, and CVC3::TheoryRecords.
Definition at line 47 of file theory.cpp.
References TRACE.
Referenced by CVC3::Theory::getModelTerm().
|
inlinevirtual |
Process disequalities from the arrangement for model generation.
Reimplemented in CVC3::TheoryCore, CVC3::TheoryArithOld, CVC3::TheoryArith3, CVC3::TheoryArithNew, and CVC3::TheoryArith.
|
inlinevirtual |
Assign concrete values to basic-type variables in v.
Reimplemented in CVC3::TheoryCore, CVC3::TheoryArithOld, CVC3::TheoryArith3, CVC3::TheoryArithNew, and CVC3::TheoryArith.
|
inlinevirtual |
Compute the value of a compound variable from the more primitive ones.
The more primitive variables for e are already assigned concrete values, and are available through getModelValue().
The new value for e must be assigned using assignValue() method.
e | is the compound type expression to assign a value; |
vars | are the variables actually assigned. Normally, 'e' is the only element of vars. However, e.g. in the case of uninterpreted functions, assigning 'f' means assigning all relevant applications of 'f' to constant values (f(0), f(5), etc.). Such applications might not be known before the model is constructed (they may be of the form f(x), f(y+z), etc., where x,y,z are still unassigned). |
Populating 'vars' is an opportunity for a DP to change the set of top-level "variables" to assign, if needed. In particular, it may drop 'e' from the model entirely, if it is already a concrete value by itself.
Reimplemented in CVC3::TheoryArithOld, CVC3::TheoryArith3, CVC3::TheoryBitvector, CVC3::TheoryArithNew, CVC3::TheoryArith, CVC3::TheoryArray, CVC3::TheoryUF, and CVC3::TheoryRecords.
Definition at line 334 of file theory.h.
References CVC3::Theory::assignValue(), and CVC3::Theory::find().
Referenced by CVC3::TheoryCore::collectModelValues().
Receives all the type predicates for the types of the given theory.
Type predicates may be expensive to enqueue eagerly, and DPs may choose to postpone them, or transform them to something more efficient. By default, the asserted type predicate is immediately enqueued as a new fact.
Note: Used only by bitvector theory.
e | is the expression for which the type predicate is computed |
pred | is the predicate theorem P(e) |
Reimplemented in CVC3::TheoryBitvector.
Definition at line 350 of file theory.h.
References CVC3::Theory::enqueueFact().
Referenced by CVC3::TheoryCore::setupTerm().
|
inlinevirtual |
Theory-specific rewrites for atomic formulas.
The intended use is to convert complex atomic formulas into an equivalent Boolean combination of simpler formulas. Such conversion may be harmful for algebraic rewrites, and is not always desirable to have in rewrite() method.
Note: Used only by bitvector theory and rewriteLiteral in core.
However, if rewrite() alone cannot solve the problem, and the SAT solver needs to be envoked, these additional rewrites may ease the job for the SAT solver.
Reimplemented in CVC3::TheoryBitvector.
Definition at line 365 of file theory.h.
References CVC3::Theory::reflexivityRule().
Referenced by CVC3::TheoryCore::rewriteLiteral().
|
inlinevirtual |
Notification of conflict.
Decision procedures implement this method when they want to be notified about a conflict.
Note: Used only by quantifier theory
thm | is the theorem of FALSE given to setInconsistent() |
Reimplemented in CVC3::TheoryQuant.
Reimplemented in CVC3::TheoryCore.
Definition at line 91 of file theory.cpp.
References CVC3::Theory::d_theoryCore, and CVC3::TheoryCore::registerAtom().
Referenced by CVC3::SearchImplBase::registerAtom().
|
inlinevirtual |
Theory-specific registration of atoms.
If a theory wants to implement its own theory propagation, it should implement this method and use it to collect all atoms that the core is interested in. If the theory can deduce the atom or its negation, it should do so (using enqueueFact).
Reimplemented in CVC3::TheoryArithNew.