CVC3
|
This theory handles arrays. More...
#include <theory_array.h>
Inherits CVC3::Theory.
This theory handles arrays.
Author: Clark Barrett
Created: Thu Feb 27 00:38:20 2003
Definition at line 50 of file theory_array.h.
TheoryArray::TheoryArray | ( | TheoryCore * | core | ) |
Definition at line 42 of file theory_array.cpp.
References CVC3::ARRAY, CVC3::ARRAY_LITERAL, createProofRules(), d_rules, CVC3::Theory::getEM(), CVC3::ExprManager::newKind(), CVC3::READ, CVC3::Theory::registerTheory(), and CVC3::WRITE.
TheoryArray::~TheoryArray | ( | ) |
Definition at line 73 of file theory_array.cpp.
References d_rules.
Derived rule.
Definition at line 345 of file theory_array.cpp.
References d_rules, DebugAssert, CVC3::Theorem::getRHS(), CVC3::ArrayProofRules::interchangeIndices(), CVC3::Theorem::isNull(), CVC3::isWrite(), CVC3::Theory::reflexivityRule(), CVC3::Theory::substitutivityRule(), and CVC3::Theory::transitivityRule().
ArrayProofRules * TheoryArray::createProofRules | ( | ) |
Definition at line 41 of file array_theorem_producer.cpp.
Referenced by TheoryArray().
void TheoryArray::addSharedTerm | ( | const Expr & | e | ) | [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 CVC3::Theory.
Definition at line 78 of file theory_array.cpp.
References CVC3::Expr::addToNotify(), CVC3::Expr::arity(), CVC3::CDMap< Key, Data, HashFcn >::count(), d_sharedSubterms, d_sharedSubtermsList, CVC3::isRead(), CVC3::isWrite(), CVC3::Expr::notArrayNormalized(), CVC3::CDList< T >::push_back(), CVC3::Expr::toString(), and TRACE.
Referenced by assertFact(), setup(), and update().
void TheoryArray::assertFact | ( | const Theorem & | e | ) | [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 CVC3::Theory.
Definition at line 106 of file theory_array.cpp.
References addSharedTerm(), CVC3::ArrayProofRules::arrayNotEq(), d_inCheckSat, d_rules, DebugAssert, CVC3::Theory::enqueueFact(), EQ, FatalAssert, CVC3::Theory::getBaseType(), CVC3::Theorem::getExpr(), CVC3::Expr::getOpKind(), CVC3::isArray(), CVC3::isWrite(), NOT, CVC3::Theory::theoryCore(), CVC3::Expr::toString(), and TRACE.
void TheoryArray::checkSat | ( | bool | fullEffort | ) | [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 CVC3::Theory.
Definition at line 154 of file theory_array.cpp.
References CVC3::Theory::addSplitter(), CVC3::Theory::assertEqualities(), Hash::hash_set< _Key, _HashFcn, _EqualKey >::begin(), CVC3::ExprMap< Data >::begin(), CVC3::BVCONST, d_inCheckSat, d_index, d_reads, d_rules, d_sharedSubterms, d_sharedSubtermsList, DebugAssert, Hash::hash_set< _Key, _HashFcn, _EqualKey >::end(), CVC3::ExprMap< Data >::end(), CVC3::CDMap< Key, Data, HashFcn >::end(), CVC3::Theory::enqueueFact(), CVC3::Expr::eqExpr(), FatalAssert, CVC3::CDMap< Key, Data, HashFcn >::find(), CVC3::Theory::find(), findAtom(), CVC3::Theory::findExpr(), getBaseArray(), CVC3::Expr::getRep(), CVC3::Theorem::getRHS(), CVC3::Expr::getSig(), CVC3::Expr::hasFind(), CVC3::Expr::hasRep(), CVC3::Theory::iffMP(), Hash::hash_set< _Key, _HashFcn, _EqualKey >::insert(), CVC3::int2string(), CVC3::ArrayProofRules::interchangeIndices(), CVC3::Expr::isAbsAtomicFormula(), CVC3::Expr::isAtomic(), CVC3::Expr::isBoolConst(), CVC3::Expr::isFalse(), CVC3::Theorem::isNull(), CVC3::isRead(), CVC3::Theorem::isRefl(), CVC3::Expr::isTrue(), CVC3::isWrite(), CVC3::Expr::notArrayNormalized(), CVC3::ArrayProofRules::propagateIndexDiseq(), CVC3::READ, CVC3::Theory::rewriteIte(), CVC3::ArrayProofRules::rewriteReadWrite(), CVC3::ArrayProofRules::rewriteRedundantWrite1(), CVC3::Theory::simplify(), CVC3::CDList< T >::size(), CVC3::Theory::substitutivityRule(), CVC3::Expr::toString(), TRACE, and CVC3::Theory::transitivityRule().
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 CVC3::Theory.
Definition at line 368 of file theory_array.cpp.
References CVC3::ARRAY_LITERAL, d_liftReadIte, d_rules, DebugAssert, EQ, FatalAssert, CVC3::Theory::findExpr(), CVC3::Theory::getBaseType(), CVC3::Theory::getCommonRules(), CVC3::Expr::getKind(), CVC3::Expr::getRep(), CVC3::Theorem::getRHS(), IF_DEBUG, CVC3::ArrayProofRules::interchangeIndices(), CVC3::isArray(), CVC3::Expr::isAtomic(), CVC3::Theorem::isNull(), CVC3::isRead(), CVC3::Theorem::isRefl(), CVC3::Expr::isVar(), CVC3::isWrite(), ITE, MiniSat::left(), CVC3::ArrayProofRules::liftReadIte(), NOT, pullIndex(), CVC3::READ, CVC3::ArrayProofRules::readArrayLiteral(), CVC3::Theory::reflexivityRule(), CVC3::ArrayProofRules::rewriteReadWrite(), CVC3::ArrayProofRules::rewriteRedundantWrite1(), CVC3::ArrayProofRules::rewriteRedundantWrite2(), CVC3::ArrayProofRules::rewriteSameStore(), CVC3::CommonProofRules::rewriteUsingSymmetry(), CVC3::ArrayProofRules::rewriteWriteWrite(), MiniSat::right(), CVC3::Expr::setRewriteNormal(), CVC3::Theory::simplify(), CVC3::Theory::substitutivityRule(), CVC3::Theory::symmetryRule(), CVC3::Theory::transitivityRule(), and CVC3::WRITE.
Referenced by computeModel().
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.
Reimplemented from CVC3::Theory.
Definition at line 490 of file theory_array.cpp.
References addSharedTerm(), CVC3::Expr::addToNotify(), CVC3::Expr::arity(), CVC3::Type::card(), CVC3::CARD_INFINITE, CVC3::CDMap< Key, Data, HashFcn >::count(), d_reads, d_sharedSubterms, d_sharedSubtermsList, DebugAssert, CVC3::Theory::findExpr(), CVC3::Expr::getType(), CVC3::Expr::isAtomic(), CVC3::Expr::isEq(), CVC3::Expr::isNot(), CVC3::isRead(), CVC3::isWrite(), CVC3::Expr::notArrayNormalized(), pullIndex(), CVC3::CDList< T >::push_back(), CVC3::READ, CVC3::Theory::reflexivityRule(), CVC3::Expr::setNotArrayNormalized(), CVC3::Expr::setRep(), CVC3::Expr::setSig(), CVC3::TheoryCore::setupTerm(), CVC3::Expr::setUsesCC(), CVC3::Theory::simplifyExpr(), CVC3::Theory::theoryCore(), CVC3::Theory::theoryOf(), and TRACE.
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 from CVC3::Theory.
Definition at line 550 of file theory_array.cpp.
References addSharedTerm(), CVC3::Expr::addToNotify(), CVC3::Expr::arity(), CVC3::Theory::assertEqualities(), CVC3::CDMap< Key, Data, HashFcn >::count(), d_rules, d_sharedSubterms, d_sharedSubtermsList, DebugAssert, CVC3::CDMap< Key, Data, HashFcn >::end(), CVC3::Theory::enqueueFact(), CVC3::Theory::find(), CVC3::CDMap< Key, Data, HashFcn >::find(), CVC3::Theory::findRef(), CVC3::Theory::getEM(), CVC3::Theorem::getLHS(), CVC3::Expr::getRep(), CVC3::Theorem::getRHS(), CVC3::Expr::getSig(), CVC3::Expr::hasFind(), CVC3::Theory::inconsistent(), CVC3::ArrayProofRules::interchangeIndices(), CVC3::ExprManager::invalidateSimpCache(), CVC3::Expr::isAtomic(), CVC3::Theorem::isNull(), CVC3::Expr::isNull(), CVC3::isRead(), CVC3::Theorem::isRefl(), CVC3::isWrite(), CVC3::Expr::notArrayNormalized(), pullIndex(), CVC3::CDList< T >::push_back(), CVC3::READ, CVC3::Theory::renameExpr(), CVC3::ArrayProofRules::rewriteReadWrite(), CVC3::ArrayProofRules::rewriteRedundantWrite1(), CVC3::ArrayProofRules::rewriteRedundantWrite2(), CVC3::Expr::setNotArrayNormalized(), CVC3::Expr::setRep(), CVC3::Expr::setSig(), CVC3::Theory::simplify(), CVC3::Theory::substitutivityRule(), CVC3::Theory::symmetryRule(), CVC3::Expr::toString(), CVC3::Theory::transitivityRule(), and CVC3::Theory::updateHelper().
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 CVC3::Theory.
Definition at line 718 of file theory_array.cpp.
References DebugAssert, CVC3::Theorem::getExpr(), CVC3::Expr::isEq(), CVC3::isWrite(), CVC3::Theory::symmetryRule(), and CVC3::Expr::toString().
void TheoryArray::checkType | ( | const Expr & | e | ) | [virtual] |
Check that e is a valid Type expr.
Reimplemented from CVC3::Theory.
Definition at line 731 of file theory_array.cpp.
References CVC3::Expr::arity(), CVC3::ARRAY, DebugAssert, CVC3::Theory::getEM(), CVC3::Expr::getKind(), CVC3::Type::isBool(), and CVC3::Type::isFunction().
Cardinality TheoryArray::finiteTypeInfo | ( | Expr & | e, |
Unsigned & | n, | ||
bool | enumerate, | ||
bool | computeSize | ||
) | [virtual] |
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 from CVC3::Theory.
Definition at line 757 of file theory_array.cpp.
References CVC3::ARRAY, CVC3::arrayLiteral(), CVC3::Type::card(), CVC3::CARD_FINITE, CVC3::CARD_INFINITE, CVC3::Type::enumerateFinite(), CVC3::Theory::getEM(), CVC3::Expr::getKind(), and CVC3::Type::sizeFinite().
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 CVC3::Theory.
Definition at line 810 of file theory_array.cpp.
References CVC3::Type::anyType(), CVC3::Expr::arity(), CVC3::ARRAY_LITERAL, CVC3::arrayType(), DebugAssert, CVC3::Theory::getBaseType(), CVC3::Expr::getBody(), CVC3::Theory::getEM(), CVC3::Expr::getKind(), CVC3::Expr::getType(), CVC3::Expr::getVars(), CVC3::isArray(), CVC3::Expr::isClosure(), CVC3::READ, CVC3::Expr::setType(), CVC3::Type::toString(), CVC3::Expr::toString(), and CVC3::WRITE.
Compute the base type of the top-level operator of an arbitrary type.
Reimplemented from CVC3::Theory.
Definition at line 887 of file theory_array.cpp.
References CVC3::Expr::arity(), CVC3::ARRAY, CVC3::Expr::begin(), DebugAssert, CVC3::Expr::end(), CVC3::Theory::getBaseType(), CVC3::Type::getExpr(), CVC3::Expr::getKind(), CVC3::Expr::getOp(), and CVC3::Type::toString().
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 CVC3::Theory.
Definition at line 899 of file theory_array.cpp.
References CVC3::ARRAY, CVC3::CDList< T >::begin(), d_reads, DebugAssert, CVC3::CDList< T >::end(), CVC3::Type::getExpr(), CVC3::Expr::getKind(), CVC3::Expr::getType(), CVC3::isRead(), CVC3::READ, and CVC3::WRITE.
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 CVC3::Theory.
Definition at line 939 of file theory_array.cpp.
References CVC3::ARRAY, CVC3::arrayLiteral(), CVC3::Theory::assignValue(), CVC3::ExprHashMap< Data >::begin(), CVC3::CDList< T >::begin(), d_applicationsInModel, d_reads, DebugAssert, CVC3::ExprHashMap< Data >::end(), CVC3::CDList< T >::end(), CVC3::Expr::eqExpr(), CVC3::Theory::getBaseType(), CVC3::Theory::getEM(), CVC3::Expr::getKind(), CVC3::Theorem::getLHS(), CVC3::Theory::getModelValue(), CVC3::Theorem::getRHS(), CVC3::Expr::getType(), CVC3::int2string(), CVC3::isArray(), CVC3::Expr::isNull(), CVC3::isRead(), CVC3::Expr::iteExpr(), CVC3::READ, CVC3::Theory::reflexivityRule(), rewrite(), CVC3::Expr::setType(), CVC3::ExprHashMap< Data >::size(), CVC3::Theory::substitutivityRule(), CVC3::Theory::symmetryRule(), CVC3::Expr::toString(), TRACE, CVC3::Theory::transitivityRule(), and CVC3::WRITE.
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 CVC3::Theory.
Definition at line 1041 of file theory_array.cpp.
References CVC3::andExpr(), CVC3::Expr::andExpr(), CVC3::Expr::arity(), CVC3::ARRAY_LITERAL, CVC3::Theory::computeTCC(), DebugAssert, CVC3::Expr::getKind(), CVC3::Theorem::getRHS(), CVC3::Expr::getType(), CVC3::Theory::getTypePred(), CVC3::READ, CVC3::Theory::rewriteAnd(), CVC3::Expr::toString(), and CVC3::WRITE.
Theory-specific parsing implemented by the DP.
Reimplemented from CVC3::Theory.
Definition at line 1193 of file theory_array.cpp.
References CVC3::Theory::addBoundVar(), CVC3::Expr::arity(), CVC3::ARRAY, CVC3::ARRAY_LITERAL, CVC3::Expr::begin(), DebugAssert, CVC3::Expr::end(), CVC3::Expr::getEM(), CVC3::Theory::getEM(), CVC3::ExprManager::getKind(), CVC3::Expr::getKind(), ID, CVC3::ExprManager::newClosureExpr(), CVC3::Theory::parseExpr(), RAW_LIST, CVC3::READ, CVC3::Expr::toString(), and CVC3::WRITE.
ExprStream & TheoryArray::print | ( | ExprStream & | os, |
const Expr & | e | ||
) | [virtual] |
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 CVC3::Theory.
Definition at line 1072 of file theory_array.cpp.
References CVC3::Expr::arity(), CVC3::ARRAY, CVC3::ARRAY_LITERAL, CVC3::Theory::d_theoryUsed, debug_write, CVC3::Expr::getBody(), CVC3::Expr::getKind(), IF_DEBUG, CVC3::ExprStream::lang(), CVC3::LISP_LANG, CVC3::pop(), CVC3::popdag(), CVC3::PRESENTATION_LANG, CVC3::Expr::printAST(), CVC3::push(), CVC3::pushdag(), CVC3::READ, CVC3::SMTLIB_LANG, CVC3::SMTLIB_V2_LANG, CVC3::space(), CVC3::Theory::theoryCore(), and CVC3::WRITE.
Definition at line 1254 of file theory_array.cpp.
References CVC3::Expr::getKind(), and CVC3::WRITE.
Referenced by checkSat().
ArrayProofRules* CVC3::TheoryArray::d_rules [private] |
Definition at line 51 of file theory_array.h.
Referenced by assertFact(), checkSat(), pullIndex(), rewrite(), TheoryArray(), update(), and ~TheoryArray().
CDList<Expr> CVC3::TheoryArray::d_reads [private] |
Backtracking list of array reads, for building concrete models.
Definition at line 54 of file theory_array.h.
Referenced by checkSat(), computeModel(), computeModelTerm(), and setup().
ExprMap<Theorem> CVC3::TheoryArray::d_renameThms [private] |
Set of renaming theorems indexed by t.
Definition at line 56 of file theory_array.h.
const bool& CVC3::TheoryArray::d_applicationsInModel [private] |
Flag to include array reads to the concrete model.
Definition at line 58 of file theory_array.h.
Referenced by computeModel().
const bool& CVC3::TheoryArray::d_liftReadIte [private] |
Flag to lift ite's over reads.
Definition at line 60 of file theory_array.h.
Referenced by rewrite().
CDMap<Expr,Expr> CVC3::TheoryArray::d_sharedSubterms [private] |
Backtracking database of subterms of shared terms.
Definition at line 63 of file theory_array.h.
Referenced by addSharedTerm(), checkSat(), setup(), and update().
CDList<Expr> CVC3::TheoryArray::d_sharedSubtermsList [private] |
Backtracking database of subterms of shared terms.
Definition at line 65 of file theory_array.h.
Referenced by addSharedTerm(), checkSat(), setup(), and update().
CDO<unsigned> CVC3::TheoryArray::d_index [private] |
CDO<size_t> CVC3::TheoryArray::d_sharedIdx1 [private] |
Definition at line 69 of file theory_array.h.
CDO<size_t> CVC3::TheoryArray::d_sharedIdx2 [private] |
Definition at line 69 of file theory_array.h.
int CVC3::TheoryArray::d_inCheckSat [private] |
Flag for use in checkSat.
Definition at line 72 of file theory_array.h.
Referenced by assertFact(), and checkSat().