#include <theory_arith.h>
Author: Clark Barrett
Created: Sat Feb 8 14:44:32 2003
Definition at line 70 of file theory_arith.h.
CVC3::TheoryArith::TheoryArith | ( | TheoryCore * | core, | |
const std::string & | name | |||
) | [inline] |
Definition at line 97 of file theory_arith.h.
CVC3::TheoryArith::~TheoryArith | ( | ) | [inline] |
Definition at line 99 of file theory_arith.h.
Canonize the expression e, assuming all children are canonical.
Implemented in CVC3::TheoryArith3, CVC3::TheoryArithNew, and CVC3::TheoryArithOld.
Referenced by canonRec(), and canonThm().
Canonize the expression e recursively.
Definition at line 31 of file theory_arith.cpp.
References CVC3::Expr::arity(), canon(), canonThm(), CVC3::Theorem::getLHS(), CVC3::Theorem::getRHS(), CVC3::Theory::isLeaf(), CVC3::Theory::reflexivityRule(), and CVC3::Theory::substitutivityRule().
Referenced by canonSimp(), and rewriteToDiff().
void TheoryArith::printRational | ( | ExprStream & | os, | |
const Rational & | r, | |||
bool | printAsReal = false | |||
) | [protected] |
Print a rational in SMT-LIB format.
Definition at line 54 of file theory_arith.cpp.
References DebugAssert, CVC3::Rational::getDenominator(), CVC3::Rational::getNumerator(), CVC3::Rational::isInteger(), CVC3::push(), CVC3::space(), and CVC3::Rational::toString().
Referenced by CVC3::TheoryArithOld::print(), CVC3::TheoryArithNew::print(), and CVC3::TheoryArith3::print().
bool TheoryArith::isAtomicArithTerm | ( | const Expr & | e | ) | [protected] |
Whether any ite's appear in the arithmetic part of the term e.
Definition at line 91 of file theory_arith.cpp.
References CVC3::Expr::arity(), CVC3::DIVIDE, CVC3::Expr::getKind(), CVC3::INTDIV, CVC3::ITE, CVC3::MINUS, CVC3::MOD, CVC3::MULT, CVC3::PLUS, CVC3::POW, CVC3::RATIONAL_EXPR, and CVC3::UMINUS.
Referenced by isAtomicArithFormula().
simplify leaves and then canonize
Definition at line 233 of file theory_arith.cpp.
References CVC3::Expr::arity(), canonRec(), canonThm(), DebugAssert, CVC3::Theory::find(), CVC3::Theorem::getLHS(), CVC3::Theorem::getRHS(), CVC3::Theory::isLeaf(), CVC3::Theory::substitutivityRule(), and CVC3::Theory::transitivityRule().
Referenced by CVC3::TheoryArithOld::checkAssertEqInvariant(), CVC3::TheoryArith3::checkAssertEqInvariant(), CVC3::TheoryArithOld::checkSat(), recursiveCanonSimpCheck(), CVC3::TheoryArithNew::update(), and CVC3::TheoryArith3::update().
bool TheoryArith::recursiveCanonSimpCheck | ( | const Expr & | e | ) | [protected] |
helper for checkAssertEqInvariant
Definition at line 259 of file theory_arith.cpp.
References CVC3::Expr::begin(), canonSimp(), CVC3::Expr::end(), CVC3::Theorem::getRHS(), and CVC3::Expr::hasFind().
Referenced by CVC3::TheoryArithOld::checkAssertEqInvariant(), and CVC3::TheoryArith3::checkAssertEqInvariant().
virtual void CVC3::TheoryArith::addMultiplicativeSignSplit | ( | const Theorem & | case_split_thm | ) | [inline, virtual] |
virtual bool CVC3::TheoryArith::addPairToArithOrder | ( | const Expr & | smaller, | |
const Expr & | bigger | |||
) | [inline, virtual] |
Record that smaller should be smaller than bigger in the variable order. Should be implemented in decision procedures that support it.
Reimplemented in CVC3::TheoryArithOld.
Definition at line 107 of file theory_arith.h.
Referenced by CVC3::VCL::addPairToArithOrder().
Return whether e is syntactically identical to a rational constant.
Definition at line 133 of file theory_arith.cpp.
References CVC3::Expr::getKind(), CVC3::Expr::getRational(), CVC3::isDivide(), CVC3::Expr::isRational(), CVC3::isUMinus(), and CVC3::REAL_CONST.
Referenced by CVC3::Translator::preprocessRec().
bool TheoryArith::isAtomicArithFormula | ( | const Expr & | e | ) |
Whether any ite's appear in the arithmetic part of the formula e.
Definition at line 119 of file theory_arith.cpp.
References CVC3::EQ, CVC3::GE, CVC3::Expr::getKind(), CVC3::GT, isAtomicArithTerm(), CVC3::LE, and CVC3::LT.
Referenced by CVC3::Translator::preprocessRec().
Rewrite an atom to look like x - y op c if possible--for smtlib translation.
Definition at line 165 of file theory_arith.cpp.
References CVC3::Expr::arity(), canonRec(), DebugAssert, CVC3::EQ, CVC3::Theory::falseExpr(), CVC3::GE, CVC3::Theory::getEM(), CVC3::Expr::getKind(), CVC3::Expr::getRational(), CVC3::Theorem::getRHS(), CVC3::TheoryCore::getTranslator(), CVC3::GT, CVC3::isRational(), CVC3::LE, CVC3::LT, CVC3::MULT, CVC3::ExprManager::newRatExpr(), CVC3::PLUS, rat(), CVC3::RATIONAL_EXPR, CVC3::Theory::theoryCore(), CVC3::Theory::trueExpr(), and CVC3::Translator::zeroVar().
Referenced by CVC3::Translator::preprocessRec().
Composition of canon(const Expr&) by transitivity: take e0 = e1, canonize e1 to e2, return e0 = e2.
Definition at line 119 of file theory_arith.h.
References canon(), CVC3::Theorem::getRHS(), and CVC3::Theory::transitivityRule().
Referenced by CVC3::TheoryArithOld::canon(), CVC3::TheoryArithNew::canon(), CVC3::TheoryArith3::canon(), canonRec(), canonSimp(), CVC3::TheoryArithOld::substAndCanonize(), CVC3::TheoryArithNew::substAndCanonize(), CVC3::TheoryArith3::substAndCanonize(), CVC3::TheoryArithNew::substAndCanonizeModTableaux(), and CVC3::TheoryArithNew::substAndCanonizeTableaux().
virtual void CVC3::TheoryArith::separateMonomial | ( | const Expr & | e, | |
Expr & | c, | |||
Expr & | var | |||
) | [pure virtual] |
Separate monomial e = c*p1*...*pn into c and 1*p1*...*pn.
Implemented in CVC3::TheoryArith3, CVC3::TheoryArithNew, and CVC3::TheoryArithOld.
virtual void CVC3::TheoryArith::addSharedTerm | ( | const Expr & | e | ) | [pure 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.
Implemented in CVC3::TheoryArith3, CVC3::TheoryArithNew, and CVC3::TheoryArithOld.
virtual void CVC3::TheoryArith::assertFact | ( | const Theorem & | e | ) | [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.
Implements CVC3::Theory.
Implemented in CVC3::TheoryArith3, CVC3::TheoryArithNew, and CVC3::TheoryArithOld.
virtual void CVC3::TheoryArith::refineCounterExample | ( | ) | [pure virtual] |
Process disequalities from the arrangement for model generation.
Reimplemented from CVC3::Theory.
Implemented in CVC3::TheoryArith3, CVC3::TheoryArithNew, and CVC3::TheoryArithOld.
virtual void CVC3::TheoryArith::computeModelBasic | ( | const std::vector< Expr > & | v | ) | [pure virtual] |
Assign concrete values to basic-type variables in v.
Reimplemented from CVC3::Theory.
Implemented in CVC3::TheoryArith3, CVC3::TheoryArithNew, and CVC3::TheoryArithOld.
virtual void CVC3::TheoryArith::computeModel | ( | const Expr & | e, | |
std::vector< Expr > & | vars | |||
) | [pure virtual] |
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). |
Reimplemented from CVC3::Theory.
Implemented in CVC3::TheoryArith3, CVC3::TheoryArithNew, and CVC3::TheoryArithOld.
virtual void CVC3::TheoryArith::checkSat | ( | bool | fullEffort | ) | [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. |
Implements CVC3::Theory.
Implemented in CVC3::TheoryArith3, CVC3::TheoryArithNew, and CVC3::TheoryArithOld.
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.
Implemented in CVC3::TheoryArith3, CVC3::TheoryArithNew, and CVC3::TheoryArithOld.
virtual void CVC3::TheoryArith::setup | ( | const Expr & | e | ) | [pure 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.
Implemented in CVC3::TheoryArith3, CVC3::TheoryArithNew, and CVC3::TheoryArithOld.
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.
Implemented in CVC3::TheoryArith3, CVC3::TheoryArithNew, and CVC3::TheoryArithOld.
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.
Implemented in CVC3::TheoryArith3, CVC3::TheoryArithNew, and CVC3::TheoryArithOld.
virtual void CVC3::TheoryArith::checkAssertEqInvariant | ( | const Theorem & | e | ) | [pure virtual] |
A debug check used by the primary solver.
Reimplemented from CVC3::Theory.
Implemented in CVC3::TheoryArith3, CVC3::TheoryArithNew, and CVC3::TheoryArithOld.
virtual void CVC3::TheoryArith::checkType | ( | const Expr & | e | ) | [pure virtual] |
Check that e is a valid Type expr.
Reimplemented from CVC3::Theory.
Implemented in CVC3::TheoryArith3, CVC3::TheoryArithNew, and CVC3::TheoryArithOld.
virtual Cardinality CVC3::TheoryArith::finiteTypeInfo | ( | Expr & | e, | |
Unsigned & | n, | |||
bool | enumerate, | |||
bool | computeSize | |||
) | [pure 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.
Implemented in CVC3::TheoryArith3, CVC3::TheoryArithNew, and CVC3::TheoryArithOld.
virtual void CVC3::TheoryArith::computeType | ( | const Expr & | e | ) | [pure virtual] |
Compute and store the type of e.
e | is the expression whose type is computed. |
Reimplemented from CVC3::Theory.
Implemented in CVC3::TheoryArith3, CVC3::TheoryArithNew, and CVC3::TheoryArithOld.
Compute the base type of the top-level operator of an arbitrary type.
Reimplemented from CVC3::Theory.
Implemented in CVC3::TheoryArith3, CVC3::TheoryArithNew, and CVC3::TheoryArithOld.
virtual void CVC3::TheoryArith::computeModelTerm | ( | const Expr & | e, | |
std::vector< Expr > & | v | |||
) | [pure virtual] |
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.
Implemented in CVC3::TheoryArith3, CVC3::TheoryArithNew, and CVC3::TheoryArithOld.
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 from CVC3::Theory.
Implemented in CVC3::TheoryArith3, CVC3::TheoryArithNew, and CVC3::TheoryArithOld.
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. |
The default implementation is to compute TCCs recursively for all children, and return their conjunction.
Reimplemented from CVC3::Theory.
Implemented in CVC3::TheoryArith3, CVC3::TheoryArithNew, and CVC3::TheoryArithOld.
virtual ExprStream& CVC3::TheoryArith::print | ( | ExprStream & | os, | |
const Expr & | e | |||
) | [pure 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.
Implemented in CVC3::TheoryArith3, CVC3::TheoryArithNew, and CVC3::TheoryArithOld.
Theory-specific parsing implemented by the DP.
Reimplemented from CVC3::Theory.
Implemented in CVC3::TheoryArith3, CVC3::TheoryArithNew, and CVC3::TheoryArithOld.
Type CVC3::TheoryArith::realType | ( | ) | [inline] |
Definition at line 151 of file theory_arith.h.
References d_realType.
Referenced by CVC3::TheoryArithOld::computeBaseType(), CVC3::TheoryArithNew::computeBaseType(), CVC3::TheoryArith3::computeBaseType(), CVC3::Translator::preprocess2Rec(), CVC3::Translator::preprocessRec(), CVC3::VCL::realType(), CVC3::ArithTheoremProducerOld::realType(), CVC3::ArithTheoremProducer3::realType(), CVC3::ArithTheoremProducer::realType(), and CVC3::Translator::zeroVar().
Type CVC3::TheoryArith::intType | ( | ) | [inline] |
Definition at line 152 of file theory_arith.h.
References d_intType.
Referenced by CVC3::VCL::intType(), CVC3::ArithTheoremProducerOld::intType(), CVC3::ArithTheoremProducer3::intType(), CVC3::ArithTheoremProducer::intType(), CVC3::ArithTheoremProducerOld::IsIntegerElim(), CVC3::ArithTheoremProducer3::IsIntegerElim(), CVC3::ArithTheoremProducer::IsIntegerElim(), CVC3::Translator::preprocess2Rec(), CVC3::Translator::preprocessRec(), CVC3::Translator::processType(), CVC3::TheoryArithNew::solve(), CVC3::TheoryArith3::solve(), CVC3::TheoryArithOld::TheoryArithOld::DifferenceLogicGraph::tryUpdate(), and CVC3::Translator::zeroVar().
Definition at line 153 of file theory_arith.h.
References CVC3::SUBRANGE.
Referenced by CVC3::VCL::subrangeType().
Definition at line 155 of file theory_arith.h.
References CVC3::Theory::getEM(), and CVC3::ExprManager::newRatExpr().
Referenced by CVC3::TheoryArithOld::addToBuffer(), CVC3::TheoryArithOld::assignVariables(), CVC3::TheoryArithNew::assignVariables(), CVC3::TheoryArith3::assignVariables(), CVC3::TheoryArithOld::computeNormalFactor(), CVC3::TheoryArithNew::computeNormalFactor(), CVC3::TheoryArith3::computeNormalFactor(), CVC3::TheoryArithOld::computeTCC(), CVC3::TheoryArithNew::computeTCC(), CVC3::TheoryArith3::computeTCC(), CVC3::TheoryArithOld::doSolve(), CVC3::TheoryArith3::doSolve(), CVC3::TheoryArithOld::extractTermsFromInequality(), CVC3::TheoryArithOld::findRationalBound(), CVC3::TheoryArithOld::finiteTypeInfo(), CVC3::TheoryArithNew::finiteTypeInfo(), CVC3::TheoryArith3::finiteTypeInfo(), grayShadow(), CVC3::TheoryArithOld::isolateVariable(), CVC3::TheoryArith3::isolateVariable(), CVC3::TheoryArithNew::normalize(), CVC3::TheoryArithOld::normalizeProjectIneqs(), CVC3::TheoryArith3::normalizeProjectIneqs(), CVC3::TheoryArithNew::pivotRule(), CVC3::TheoryArithNew::processFiniteInterval(), CVC3::TheoryArith3::processFiniteInterval(), CVC3::TheoryArithOld::processRealEq(), CVC3::TheoryArithNew::processRealEq(), CVC3::TheoryArith3::processRealEq(), CVC3::TheoryArithOld::processSimpleIntEq(), CVC3::TheoryArithNew::processSimpleIntEq(), CVC3::TheoryArith3::processSimpleIntEq(), CVC3::TheoryArithOld::rewrite(), CVC3::TheoryArithNew::rewrite(), rewriteToDiff(), CVC3::TheoryArithOld::separateMonomial(), CVC3::TheoryArithNew::separateMonomial(), CVC3::TheoryArith3::separateMonomial(), CVC3::TheoryArithOld::TheoryArithOld(), CVC3::TheoryArithOld::tryPropagate(), CVC3::TheoryArithOld::updateSubsumptionDB(), and CVC3::TheoryArith3::updateSubsumptionDB().
Construct the dark shadow expression representing lhs <= rhs.
Definition at line 158 of file theory_arith.h.
References CVC3::DARK_SHADOW.
Referenced by CVC3::ArithTheoremProducerOld::darkShadow(), CVC3::ArithTheoremProducer3::darkShadow(), and CVC3::ArithTheoremProducer::darkShadow().
Expr CVC3::TheoryArith::grayShadow | ( | const Expr & | v, | |
const Expr & | e, | |||
const Rational & | c1, | |||
const Rational & | c2 | |||
) | [inline] |
Construct the gray shadow expression representing c1 <= v - e <= c2.
Alternatively, v = e + i for some i s.t. c1 <= i <= c2
Definition at line 164 of file theory_arith.h.
References CVC3::GRAY_SHADOW, and rat().
Referenced by CVC3::ArithTheoremProducerOld::grayShadow(), CVC3::ArithTheoremProducer3::grayShadow(), and CVC3::ArithTheoremProducer::grayShadow().
bool TheoryArith::leavesAreNumConst | ( | const Expr & | e | ) |
Definition at line 270 of file theory_arith.cpp.
References CVC3::Expr::arity(), DebugAssert, CVC3::Expr::getTerminalsConstFlag(), CVC3::Expr::isAtomic(), CVC3::Expr::isITE(), CVC3::Theory::isLeaf(), CVC3::Expr::isPropAtom(), CVC3::Expr::isRational(), CVC3::Expr::isTerm(), CVC3::Expr::setTerminalsConstFlag(), CVC3::Theory::theoryOf(), and CVC3::Expr::validTerminalsConstFlag().
Referenced by CVC3::TheoryArithOld::rewrite(), CVC3::ArithTheoremProducerOld::rewriteLeavesConst(), and CVC3::ExprTransform::simplifyWithCare().
Type CVC3::TheoryArith::d_realType [protected] |
Definition at line 72 of file theory_arith.h.
Referenced by CVC3::TheoryArithOld::computeType(), CVC3::TheoryArithNew::computeType(), CVC3::TheoryArith3::computeType(), CVC3::TheoryArithOld::currentMaxCoefficient(), realType(), CVC3::TheoryArith3::TheoryArith3(), CVC3::TheoryArithNew::TheoryArithNew(), CVC3::TheoryArithOld::TheoryArithOld(), and CVC3::TheoryArithOld::updateStats().
Type CVC3::TheoryArith::d_intType [protected] |
Definition at line 73 of file theory_arith.h.
Referenced by CVC3::TheoryArithOld::computeType(), CVC3::TheoryArithNew::computeType(), CVC3::TheoryArith3::computeType(), intType(), CVC3::TheoryArith3::TheoryArith3(), CVC3::TheoryArithNew::TheoryArithNew(), and CVC3::TheoryArithOld::TheoryArithOld().
std::vector<int> CVC3::TheoryArith::d_kinds [protected] |
Definition at line 74 of file theory_arith.h.
Referenced by CVC3::TheoryArithOld::TheoryArithOld(), and CVC3::TheoryArithOld::~TheoryArithOld().