CVCL::TheoryArray Class Reference

This theory handles arrays. More...

#include <theory_array.h>

Inheritance diagram for CVCL::TheoryArray:

Inheritance graph
Collaboration diagram for CVCL::TheoryArray:

Collaboration graph
List of all members.

Public Member Functions

Private Member Functions

Private Attributes

Detailed Description

This theory handles arrays.

Author: Clark Barrett

Created: Thu Feb 27 00:38:20 2003

Definition at line 58 of file theory_array.h.

Constructor & Destructor Documentation

TheoryArray::TheoryArray TheoryCore core  ) 

Definition at line 61 of file theory_array.cpp.

References CVCL::ARRAY, CVCL::ARRAY_LITERAL, createProofRules(), d_rules, CVCL::Theory::getEM(), CVCL::ExprManager::newKind(), CVCL::READ, CVCL::Theory::registerTheory(), and CVCL::WRITE.

TheoryArray::~TheoryArray  ) 

Definition at line 85 of file theory_array.cpp.

References d_rules.

Member Function Documentation

Theorem TheoryArray::renameExpr const Expr e  )  [private]

Definition at line 47 of file theory_array.cpp.

References CVCL::TheoryCore::addToVarDB(), CVCL::Theory::getCommonRules(), CVCL::Theorem::getRHS(), CVCL::Theorem::isRewrite(), CVCL::Expr::isSkolem(), CVCL::Theory::theoryCore(), CVCL::Theorem::toString(), and CVCL::CommonProofRules::varIntroSkolem().

Referenced by update().

ArrayProofRules * TheoryArray::createProofRules  ) 

Definition at line 49 of file array_theorem_producer.cpp.

References CVCL::Theory::theoryCore().

Referenced by TheoryArray().

void CVCL::TheoryArray::addSharedTerm const Expr e  )  [inline, virtual]

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 from CVCL::Theory.

Definition at line 80 of file theory_array.h.

void CVCL::TheoryArray::assertFact const Theorem e  )  [inline, 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.

Implements CVCL::Theory.

Definition at line 81 of file theory_array.h.

void CVCL::TheoryArray::checkSat bool  fullEffort  )  [inline, 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.

Implements CVCL::Theory.

Definition at line 82 of file theory_array.h.

Theorem TheoryArray::rewrite const Expr e  )  [virtual]

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 from CVCL::Theory.

Definition at line 90 of file theory_array.cpp.

Referenced by computeModel(), and update().

CVCL::TheoryArray::IF_DEBUG Theorem   rewriteDebug(const Expr &e)  ) 

void TheoryArray::setup const Expr e  )  [virtual]

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:

Reimplemented from CVCL::Theory.

Definition at line 189 of file theory_array.cpp.

References CVCL::Expr::addToNotify(), CVCL::Expr::arity(), d_reads, CVCL::Expr::isAtomic(), CVCL::Expr::isEq(), CVCL::Expr::isNot(), CVCL::isRead(), CVCL::isWrite(), CVCL::CDList< T >::push_back(), CVCL::READ, CVCL::Theory::reflexivityRule(), CVCL::Expr::setRep(), CVCL::Expr::setSig(), CVCL::TheoryCore::setupTerm(), CVCL::Theory::simplifyExpr(), CVCL::Theory::theoryCore(), and CVCL::TRACE.

void TheoryArray::update const Theorem e,
const Expr d

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:

Reimplemented from CVCL::Theory.

Definition at line 216 of file theory_array.cpp.

References CVCL::Expr::addToNotify(), CVCL::Expr::arity(), d_rules, CVCL::Theory::enqueueEquality(), CVCL::Theory::enqueueFact(), CVCL::Theory::find(), CVCL::Expr::getRep(), CVCL::Theorem::getRHS(), CVCL::Expr::getSig(), CVCL::Expr::isAtomic(), CVCL::Theorem::isNull(), CVCL::isRead(), CVCL::isWrite(), renameExpr(), rewrite(), CVCL::ArrayProofRules::rewriteReadWrite(), CVCL::Expr::setRep(), CVCL::Expr::setSig(), CVCL::Theory::symmetryRule(), CVCL::Expr::toString(), CVCL::Theory::transitivityRule(), and CVCL::Theory::updateHelper().

Theorem TheoryArray::solve const Theorem eThm  )  [virtual]

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 from CVCL::Theory.

Definition at line 281 of file theory_array.cpp.

References CVCL::Theorem::getExpr(), CVCL::Expr::isEq(), CVCL::isWrite(), CVCL::Theory::symmetryRule(), and CVCL::Expr::toString().

void TheoryArray::checkType const Expr e  )  [virtual]

Check that e is a valid Type expr.

Reimplemented from CVCL::Theory.

Definition at line 294 of file theory_array.cpp.

References CVCL::Expr::arity(), CVCL::ARRAY, CVCL::Theory::getEM(), CVCL::Expr::getKind(), CVCL::Type::isBool(), and CVCL::Type::isFunction().

void TheoryArray::computeType const Expr e  )  [virtual]

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 from CVCL::Theory.

Definition at line 320 of file theory_array.cpp.

References CVCL::Expr::arity(), CVCL::ARRAY_LITERAL, CVCL::arrayType(), CVCL::Theory::getBaseType(), CVCL::Expr::getBody(), CVCL::Expr::getKind(), CVCL::Expr::getType(), CVCL::Expr::getVars(), CVCL::isArray(), CVCL::Expr::isClosure(), CVCL::READ, CVCL::Expr::setType(), CVCL::Type::toString(), CVCL::Expr::toString(), and CVCL::WRITE.

Type TheoryArray::computeBaseType const Type t  )  [virtual]

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

Reimplemented from CVCL::Theory.

Definition at line 392 of file theory_array.cpp.

References CVCL::Expr::arity(), CVCL::ARRAY, CVCL::Expr::begin(), CVCL::Expr::end(), CVCL::Theory::getBaseType(), CVCL::Type::getExpr(), CVCL::Expr::getKind(), CVCL::Expr::getOp(), and CVCL::Type::toString().

void TheoryArray::computeModelTerm const Expr e,
std::vector< Expr > &  v

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 from CVCL::Theory.

Definition at line 404 of file theory_array.cpp.

References CVCL::ARRAY, CVCL::CDList< T >::begin(), d_reads, CVCL::CDList< T >::end(), CVCL::Type::getExpr(), CVCL::Expr::getKind(), CVCL::Expr::getType(), CVCL::isRead(), CVCL::READ, and CVCL::WRITE.

void TheoryArray::computeModel const Expr e,
std::vector< Expr > &  v

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 from CVCL::Theory.

Definition at line 444 of file theory_array.cpp.

References CVCL::Type::arity(), CVCL::ARRAY, CVCL::arrayLiteral(), CVCL::Theory::assignValue(), CVCL::ExprHashMap< Data >::begin(), CVCL::CDList< T >::begin(), d_applicationsInModel, d_reads, CVCL::ExprHashMap< Data >::end(), CVCL::CDList< T >::end(), CVCL::Expr::eqExpr(), CVCL::Theory::getBaseType(), CVCL::Theory::getEM(), CVCL::Expr::getKind(), CVCL::Theorem::getLHS(), CVCL::Theory::getModelValue(), CVCL::Theorem::getRHS(), CVCL::Expr::getType(), CVCL::int2string(), CVCL::isArray(), CVCL::Expr::isNull(), CVCL::isRead(), CVCL::Expr::iteExpr(), CVCL::CDList< T >::push_back(), CVCL::READ, CVCL::Theory::reflexivityRule(), rewrite(), CVCL::Expr::setType(), CVCL::ExprHashMap< Data >::size(), CVCL::Theory::substitutivityRule(), CVCL::Theory::symmetryRule(), CVCL::Expr::toString(), CVCL::TRACE, CVCL::Theory::transitivityRule(), and CVCL::WRITE.

Expr TheoryArray::computeTCC const Expr e  )  [virtual]

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 from CVCL::Theory.

Definition at line 546 of file theory_array.cpp.

References CVCL::andExpr(), CVCL::Expr::andExpr(), CVCL::ARRAY_LITERAL, CVCL::Theory::computeTCC(), CVCL::Theorem::getRHS(), CVCL::Theory::getTypePred(), CVCL::READ, CVCL::Theory::rewriteAnd(), and CVCL::WRITE.

Expr TheoryArray::parseExprOp const Expr e  )  [virtual]

Theory-specific parsing implemented by the DP.

Reimplemented from CVCL::Theory.

Definition at line 681 of file theory_array.cpp.

References CVCL::Theory::addBoundVar(), CVCL::Expr::arity(), CVCL::ARRAY, CVCL::ARRAY_LITERAL, CVCL::Expr::begin(), CVCL::Expr::end(), CVCL::Expr::getEM(), CVCL::Theory::getEM(), CVCL::ExprManager::getKind(), CVCL::Expr::getKind(), CVCL::Expr::getString(), CVCL::ID, CVCL::ExprManager::newClosureExpr(), CVCL::Theory::parseExpr(), CVCL::RAW_LIST, CVCL::READ, CVCL::Expr::toString(), CVCL::TRACE, and CVCL::WRITE.

ExprStream & TheoryArray::print ExprStream os,
const Expr e

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 from CVCL::Theory.

Definition at line 575 of file theory_array.cpp.

References CVCL::Expr::arity(), CVCL::ARRAY, CVCL::ARRAY_LITERAL, CVCL::Theory::d_theoryUsed, CVCL::Expr::getKind(), CVCL::ExprStream::lang(), CVCL::LISP_LANG, CVCL::pop(), CVCL::popdag(), CVCL::PRESENTATION_LANG, CVCL::Expr::printAST(), CVCL::push(), CVCL::pushdag(), CVCL::READ, CVCL::SMTLIB_LANG, CVCL::space(), and CVCL::WRITE.

Member Data Documentation

ArrayProofRules* CVCL::TheoryArray::d_rules [private]

Definition at line 59 of file theory_array.h.

Referenced by TheoryArray(), update(), and ~TheoryArray().

CDList<Expr> CVCL::TheoryArray::d_reads [private]

Backtracking list of array reads, for building concrete models.

Definition at line 62 of file theory_array.h.

Referenced by computeModel(), computeModelTerm(), and setup().

ExprMap<Theorem> CVCL::TheoryArray::d_renameThms [private]

Set of renaming theorems $\exists x. t = x$ indexed by t.

Definition at line 64 of file theory_array.h.

const bool& CVCL::TheoryArray::d_applicationsInModel [private]

Flag to include array reads to the concrete model.

Definition at line 66 of file theory_array.h.

Referenced by computeModel().

The documentation for this class was generated from the following files:
Generated on Thu Apr 13 16:57:44 2006 for CVC Lite by  doxygen 1.4.4