CVC3
Functions

Abstract Theory Interface

Theories

Abstract Theory Interface. More...

Collaboration diagram for Abstract Theory Interface:

Functions


Detailed Description

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 theory_api_howto.


Function Documentation

virtual void CVC3::Theory::addSharedTerm ( const Expr e) [inline, virtual, inherited]

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::TheoryArith, CVC3::TheoryArith3, CVC3::TheoryArithNew, CVC3::TheoryArithOld, CVC3::TheoryArray, CVC3::TheoryBitvector, CVC3::TheoryCore, CVC3::TheoryDatatype, CVC3::TheoryQuant, and CVC3::TheoryUF.

Definition at line 127 of file theory.h.

Referenced by CVC3::TheoryCore::collectBasicVars(), and CVC3::TheoryCore::setupTerm().

virtual void CVC3::Theory::assertFact ( const Theorem e) [pure virtual, inherited]

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::TheoryArith, CVC3::TheoryArith3, CVC3::TheoryArithNew, CVC3::TheoryArithOld, CVC3::TheoryArray, CVC3::TheoryBitvector, CVC3::TheoryCore, CVC3::TheoryDatatype, CVC3::TheoryQuant, CVC3::TheoryRecords, CVC3::TheorySimulate, and CVC3::TheoryUF.

Referenced by CVC3::TheoryCore::assertFormula().

virtual void CVC3::Theory::checkSat ( bool  fullEffort) [pure virtual, inherited]

Check for satisfiability in the theory.

Parameters:
fullEffortwhen 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::TheoryArith, CVC3::TheoryArith3, CVC3::TheoryArithNew, CVC3::TheoryArithOld, CVC3::TheoryArray, CVC3::TheoryBitvector, CVC3::TheoryCore, CVC3::TheoryDatatype, CVC3::TheoryDatatypeLazy, CVC3::TheoryQuant, CVC3::TheoryRecords, CVC3::TheorySimulate, and CVC3::TheoryUF.

virtual Theorem CVC3::Theory::rewrite ( const Expr e) [inline, virtual, inherited]

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::TheoryArith, CVC3::TheoryArith3, CVC3::TheoryArithNew, CVC3::TheoryArithOld, CVC3::TheoryArray, CVC3::TheoryBitvector, CVC3::TheoryCore, CVC3::TheoryDatatype, CVC3::TheoryQuant, CVC3::TheoryRecords, CVC3::TheorySimulate, and CVC3::TheoryUF.

Definition at line 159 of file theory.h.

References CVC3::Theory::reflexivityRule().

Referenced by CVC3::TheoryCore::rewrite().

virtual Theorem CVC3::Theory::theoryPreprocess ( const Expr e) [inline, virtual, inherited]

Theory-specific preprocessing.

This gets called each time a new assumption or query is preprocessed. By default it does nothing.

Reimplemented in CVC3::TheoryQuant.

Definition at line 164 of file theory.h.

References CVC3::Theory::reflexivityRule().

Referenced by CVC3::TheoryCore::callTheoryPreprocess().

virtual void CVC3::Theory::setup ( const Expr e) [inline, virtual, inherited]

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.

See also:
update

Reimplemented in CVC3::TheoryArith, CVC3::TheoryArith3, CVC3::TheoryArithNew, CVC3::TheoryArithOld, CVC3::TheoryArray, CVC3::TheoryBitvector, CVC3::TheoryCore, CVC3::TheoryDatatype, CVC3::TheoryDatatypeLazy, CVC3::TheoryQuant, CVC3::TheoryRecords, and CVC3::TheoryUF.

Definition at line 172 of file theory.h.

Referenced by CVC3::TheoryCore::setupTerm().

virtual void CVC3::Theory::update ( const Theorem e,
const Expr d 
) [inline, virtual, inherited]

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.

See also:
setup

Reimplemented in CVC3::TheoryArith, CVC3::TheoryArith3, CVC3::TheoryArithNew, CVC3::TheoryArithOld, CVC3::TheoryArray, CVC3::TheoryBitvector, CVC3::TheoryCore, CVC3::TheoryDatatype, CVC3::TheoryDatatypeLazy, CVC3::TheoryQuant, CVC3::TheoryRecords, and CVC3::TheoryUF.

Definition at line 189 of file theory.h.

Referenced by CVC3::TheoryCore::processNotify().

virtual Theorem CVC3::Theory::solve ( const Theorem e) [inline, virtual, inherited]

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::TheoryArith, CVC3::TheoryArith3, CVC3::TheoryArithNew, CVC3::TheoryArithOld, CVC3::TheoryArray, CVC3::TheoryBitvector, CVC3::TheoryCore, and CVC3::TheoryDatatype.

Definition at line 204 of file theory.h.

Referenced by CVC3::TheoryCore::checkEquation(), and CVC3::TheoryCore::solve().

virtual void CVC3::Theory::checkAssertEqInvariant ( const Theorem e) [inline, virtual, inherited]

A debug check used by the primary solver.

Reimplemented in CVC3::TheoryArith, CVC3::TheoryArith3, CVC3::TheoryArithNew, and CVC3::TheoryArithOld.

Definition at line 206 of file theory.h.

Referenced by CVC3::TheoryCore::assertEqualities().

Theorem Theory::simplifyOp ( const Expr e) [virtual, inherited]

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::TheoryBitvector, and 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().

virtual void CVC3::Theory::checkType ( const Expr e) [inline, virtual, inherited]
virtual Cardinality CVC3::Theory::finiteTypeInfo ( Expr e,
Unsigned n,
bool  enumerate,
bool  computeSize 
) [inline, virtual, inherited]

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.

1. Returns Cardinality of the type (finite, infinite, or unknown) 2. If cardinality = finite and enumerate is true, sets e to the nth element of the type if it can sets e to NULL if n is out of bounds or if unable to compute nth element 3. If cardinality = finite and computeSize is true, sets n to the size of the type if it can sets n to 0 otherwise

Reimplemented in CVC3::TheoryArith, CVC3::TheoryArith3, CVC3::TheoryArithNew, CVC3::TheoryArithOld, CVC3::TheoryArray, CVC3::TheoryBitvector, CVC3::TheoryCore, CVC3::TheoryDatatype, CVC3::TheoryRecords, and CVC3::TheoryUF.

Definition at line 252 of file theory.h.

References CVC3::CARD_INFINITE.

Referenced by CVC3::TheoryUF::finiteTypeInfo(), and CVC3::TheoryDatatype::finiteTypeInfo().

virtual void CVC3::Theory::computeType ( const Expr e) [inline, virtual, inherited]

Compute and store the type of e.

Parameters:
eis 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::TheoryArith, CVC3::TheoryArith3, CVC3::TheoryArithNew, CVC3::TheoryArithOld, CVC3::TheoryArray, CVC3::TheoryBitvector, CVC3::TheoryCore, CVC3::TheoryDatatype, CVC3::TheoryQuant, CVC3::TheoryRecords, CVC3::TheorySimulate, and CVC3::TheoryUF.

Definition at line 263 of file theory.h.

Referenced by CVC3::TheoryUF::computeType(), and CVC3::TypeComputerCore::computeType().

virtual Type CVC3::Theory::computeBaseType ( const Type tp) [inline, virtual, inherited]

Compute the base type of the top-level operator of an arbitrary type.

Reimplemented in CVC3::TheoryArith, CVC3::TheoryArith3, CVC3::TheoryArithNew, CVC3::TheoryArithOld, CVC3::TheoryArray, CVC3::TheoryCore, CVC3::TheoryRecords, and CVC3::TheoryUF.

Definition at line 265 of file theory.h.

Referenced by CVC3::Theory::getBaseType().

virtual Expr CVC3::Theory::computeTypePred ( const Type t,
const Expr e 
) [inline, virtual, inherited]

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::TheoryArith, CVC3::TheoryArith3, CVC3::TheoryArithNew, CVC3::TheoryArithOld, CVC3::TheoryBitvector, CVC3::TheoryCore, 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().

Expr Theory::computeTCC ( const Expr e) [virtual, inherited]

Compute and cache the TCC of e.

Parameters:
eis 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::TheoryArith, CVC3::TheoryArith3, CVC3::TheoryArithNew, CVC3::TheoryArithOld, CVC3::TheoryArray, CVC3::TheoryBitvector, CVC3::TheoryCore, CVC3::TheoryDatatype, CVC3::TheoryQuant, CVC3::TheoryRecords, CVC3::TheorySimulate, and CVC3::TheoryUF.

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::TheoryUF::computeTCC(), CVC3::TheoryRecords::computeTCC(), CVC3::TheoryDatatype::computeTCC(), CVC3::TheoryCore::computeTCC(), CVC3::TheoryArray::computeTCC(), CVC3::TheoryArithOld::computeTCC(), CVC3::TheoryArithNew::computeTCC(), CVC3::TheoryArith3::computeTCC(), and CVC3::Theory::getTCC().

virtual Expr CVC3::Theory::parseExprOp ( const Expr e) [inline, virtual, inherited]
virtual ExprStream& CVC3::Theory::print ( ExprStream os,
const Expr e 
) [inline, virtual, inherited]

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::TheoryArith, CVC3::TheoryArith3, CVC3::TheoryArithNew, CVC3::TheoryArithOld, CVC3::TheoryArray, CVC3::TheoryBitvector, CVC3::TheoryCore, CVC3::TheoryDatatype, CVC3::TheoryQuant, CVC3::TheoryRecords, CVC3::TheorySimulate, and CVC3::TheoryUF.

Definition at line 302 of file theory.h.

References CVC3::Expr::printAST().

void Theory::computeModelTerm ( const Expr e,
std::vector< Expr > &  v 
) [virtual, inherited]

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::TheoryArith, CVC3::TheoryArith3, CVC3::TheoryArithNew, CVC3::TheoryArithOld, CVC3::TheoryArray, CVC3::TheoryBitvector, CVC3::TheoryDatatype, CVC3::TheoryRecords, and CVC3::TheoryUF.

Definition at line 47 of file theory.cpp.

References TRACE.

Referenced by CVC3::Theory::getModelTerm().

virtual void CVC3::Theory::refineCounterExample ( ) [inline, virtual, inherited]

Process disequalities from the arrangement for model generation.

Reimplemented in CVC3::TheoryArith, CVC3::TheoryArith3, CVC3::TheoryArithNew, CVC3::TheoryArithOld, and CVC3::TheoryCore.

Definition at line 310 of file theory.h.

virtual void CVC3::Theory::computeModelBasic ( const std::vector< Expr > &  v) [inline, virtual, inherited]

Assign concrete values to basic-type variables in v.

Reimplemented in CVC3::TheoryArith, CVC3::TheoryArith3, CVC3::TheoryArithNew, CVC3::TheoryArithOld, and CVC3::TheoryCore.

Definition at line 312 of file theory.h.

virtual void CVC3::Theory::computeModel ( const Expr e,
std::vector< Expr > &  vars 
) [inline, virtual, inherited]

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.

Parameters:
eis the compound type expression to assign a value;
varsare 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::TheoryArith, CVC3::TheoryArith3, CVC3::TheoryArithNew, CVC3::TheoryArithOld, CVC3::TheoryArray, CVC3::TheoryBitvector, CVC3::TheoryRecords, and CVC3::TheoryUF.

Definition at line 334 of file theory.h.

References CVC3::Theory::assignValue(), and CVC3::Theory::find().

Referenced by CVC3::TheoryCore::collectModelValues().

virtual void CVC3::Theory::assertTypePred ( const Expr e,
const Theorem pred 
) [inline, virtual, inherited]

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.

Parameters:
eis the expression for which the type predicate is computed
predis 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().

virtual Theorem CVC3::Theory::rewriteAtomic ( const Expr e) [inline, virtual, inherited]

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().

virtual void CVC3::Theory::notifyInconsistent ( const Theorem thm) [inline, virtual, inherited]

Notification of conflict.

Decision procedures implement this method when they want to be notified about a conflict.

Note: Used only by quantifier theory

Parameters:
thmis the theorem of FALSE given to setInconsistent()

Reimplemented in CVC3::TheoryQuant.

Definition at line 376 of file theory.h.

void Theory::registerAtom ( const Expr e,
const Theorem thm 
) [virtual, inherited]

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().

virtual void CVC3::Theory::registerAtom ( const Expr e) [inline, virtual, inherited]

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, and CVC3::TheoryArithOld.

Definition at line 387 of file theory.h.