CVC3
|
This theory handles datatypes. More...
#include <theory_datatype.h>
Inherits CVC3::Theory.
Inherited by CVC3::TheoryDatatypeLazy.
Public Member Functions | |
TheoryDatatype (TheoryCore *theoryCore) | |
virtual | ~TheoryDatatype () |
DatatypeProofRules * | createProofRules () |
void | addSharedTerm (const Expr &e) |
Notify theory of a new shared term. | |
void | assertFact (const Theorem &e) |
Assert a new fact to the decision procedure. | |
virtual void | checkSat (bool fullEffort) |
Check for satisfiability in the theory. | |
Theorem | rewrite (const Expr &e) |
Theory-specific rewrite rules. | |
virtual void | setup (const Expr &e) |
Set up the term e for call-backs when e or its children change. | |
virtual void | update (const Theorem &e, const Expr &d) |
Notify a theory of a new equality. | |
Theorem | solve (const Theorem &e) |
An optional solver. | |
void | checkType (const Expr &e) |
Check that e is a valid Type expr. | |
Cardinality | finiteTypeInfo (Expr &e, Unsigned &n, bool enumerate, bool computeSize) |
Compute information related to finiteness of types. | |
void | computeType (const Expr &e) |
Compute and store the type of e. | |
void | computeModelTerm (const Expr &e, std::vector< Expr > &v) |
Add variables from 'e' to 'v' for constructing a concrete model. | |
Expr | computeTCC (const Expr &e) |
Compute and cache the TCC of e. | |
Expr | parseExprOp (const Expr &e) |
Theory-specific parsing implemented by the DP. | |
ExprStream & | print (ExprStream &os, const Expr &e) |
Theory-specific pretty-printing. | |
Expr | dataType (const std::string &name, const std::vector< std::string > &constructors, const std::vector< std::vector< std::string > > &selectors, const std::vector< std::vector< Expr > > &types) |
Expr | dataType (const std::vector< std::string > &names, const std::vector< std::vector< std::string > > &constructors, const std::vector< std::vector< std::vector< std::string > > > &selectors, const std::vector< std::vector< std::vector< Expr > > > &types) |
Expr | datatypeConsExpr (const std::string &constructor, const std::vector< Expr > &args) |
Expr | datatypeSelExpr (const std::string &selector, const Expr &arg) |
Expr | datatypeTestExpr (const std::string &constructor, const Expr &arg) |
const std::pair< Expr, unsigned > & | getSelectorInfo (const Expr &e) |
Expr | getConsForTester (const Expr &e) |
unsigned | getConsPos (const Expr &e) |
Expr | getConstant (const Type &t) |
const Op & | getReachablePredicate (const Type &t) |
bool | canCollapse (const Expr &e) |
![]() | |
Theory (TheoryCore *theoryCore, const std::string &name) | |
Whether theory has been used (for smtlib translator) | |
virtual | ~Theory (void) |
Destructor. | |
ExprManager * | getEM () |
Access to ExprManager. | |
TheoryCore * | theoryCore () |
Get a pointer to theoryCore. | |
CommonProofRules * | getCommonRules () |
Get a pointer to common proof rules. | |
const std::string & | getName () const |
Get the name of the theory (for debugging purposes) | |
virtual void | setUsed () |
Set the "used" flag on this theory (for smtlib translator) | |
virtual bool | theoryUsed () |
Get whether theory has been used (for smtlib translator) | |
virtual Theorem | theoryPreprocess (const Expr &e) |
Theory-specific preprocessing. | |
virtual void | checkAssertEqInvariant (const Theorem &e) |
A debug check used by the primary solver. | |
virtual Theorem | simplifyOp (const Expr &e) |
Recursive simplification step. | |
virtual Type | computeBaseType (const Type &tp) |
Compute the base type of the top-level operator of an arbitrary type. | |
virtual Expr | computeTypePred (const Type &t, const Expr &e) |
Theory specific computation of the subtyping predicate for type t applied to the expression e. | |
virtual void | refineCounterExample () |
Process disequalities from the arrangement for model generation. | |
virtual void | computeModelBasic (const std::vector< Expr > &v) |
Assign concrete values to basic-type variables in v. | |
virtual void | computeModel (const Expr &e, std::vector< Expr > &vars) |
Compute the value of a compound variable from the more primitive ones. | |
virtual void | assertTypePred (const Expr &e, const Theorem &pred) |
Receives all the type predicates for the types of the given theory. | |
virtual Theorem | rewriteAtomic (const Expr &e) |
Theory-specific rewrites for atomic formulas. | |
virtual void | notifyInconsistent (const Theorem &thm) |
Notification of conflict. | |
virtual void | registerAtom (const Expr &e, const Theorem &thm) |
virtual void | registerAtom (const Expr &e) |
Theory-specific registration of atoms. | |
virtual bool | inconsistent () |
Check if the current context is inconsistent. | |
virtual void | setInconsistent (const Theorem &e) |
Make the context inconsistent; The formula proved by e must FALSE. | |
virtual void | setIncomplete (const std::string &reason) |
Mark the current decision branch as possibly incomplete. | |
virtual Theorem | simplify (const Expr &e) |
Simplify a term e and return a Theorem(e==e') | |
Expr | simplifyExpr (const Expr &e) |
Simplify a term e w.r.t. the current context. | |
virtual void | enqueueFact (const Theorem &e) |
Submit a derived fact to the core from a decision procedure. | |
virtual void | enqueueSE (const Theorem &e) |
Check if the current context is inconsistent. | |
virtual void | assertEqualities (const Theorem &e) |
Handle new equalities (usually asserted through addFact) | |
virtual Expr | parseExpr (const Expr &e) |
Parse the generic expression. | |
virtual void | assignValue (const Expr &t, const Expr &val) |
Assigns t a concrete value val. Used in model generation. | |
virtual void | assignValue (const Theorem &thm) |
Record a derived assignment to a variable (LHS). | |
void | registerKinds (Theory *theory, std::vector< int > &kinds) |
Register new kinds with the given theory. | |
void | unregisterKinds (Theory *theory, std::vector< int > &kinds) |
Unregister kinds for a theory. | |
void | registerTheory (Theory *theory, std::vector< int > &kinds, bool hasSolver=false) |
Register a new theory. | |
void | unregisterTheory (Theory *theory, std::vector< int > &kinds, bool hasSolver) |
Unregister a theory. | |
int | getNumTheories () |
Return the number of registered theories. | |
bool | hasTheory (int kind) |
Test whether a kind maps to any theory. | |
Theory * | theoryOf (int kind) |
Return the theory associated with a kind. | |
Theory * | theoryOf (const Type &e) |
Return the theory associated with a type. | |
Theory * | theoryOf (const Expr &e) |
Return the theory associated with an Expr. | |
Theorem | find (const Expr &e) |
Return the theorem that e is equal to its find. | |
const Theorem & | findRef (const Expr &e) |
Return the find as a reference: expr must have a find. | |
Theorem | findReduce (const Expr &e) |
Return find-reduced version of e. | |
bool | findReduced (const Expr &e) |
Return true iff e is find-reduced. | |
Expr | findExpr (const Expr &e) |
Return the find of e, or e if it has no find. | |
Expr | getTCC (const Expr &e) |
Compute the TCC of e, or the subtyping predicate, if e is a type. | |
Type | getBaseType (const Expr &e) |
Compute (or look up in cache) the base type of e and return the result. | |
Type | getBaseType (const Type &tp) |
Compute the base type from an arbitrary type. | |
Expr | getTypePred (const Type &t, const Expr &e) |
Calls the correct theory to compute a type predicate. | |
Theorem | updateHelper (const Expr &e) |
Update the children of the term e. | |
void | setupCC (const Expr &e) |
Setup a term for congruence closure (must have sig and rep attributes) | |
void | updateCC (const Theorem &e, const Expr &d) |
Update a term w.r.t. congruence closure (must be setup with setupCC()) | |
Theorem | rewriteCC (const Expr &e) |
Rewrite a term w.r.t. congruence closure (must be setup with setupCC()) | |
void | getModelTerm (const Expr &e, std::vector< Expr > &v) |
Calls the correct theory to get all of the terms that need to be assigned values in the concrete model. | |
Theorem | getModelValue (const Expr &e) |
Fetch the concrete assignment to the variable during model generation. | |
void | addSplitter (const Expr &e, int priority=0) |
Suggest a splitter to the SearchEngine. | |
void | addGlobalLemma (const Theorem &thm, int priority=0) |
Add a global lemma. | |
bool | isLeaf (const Expr &e) |
Test if e is an i-leaf term for the current theory. | |
bool | isLeafIn (const Expr &e1, const Expr &e2) |
Test if e1 is an i-leaf in e2. | |
bool | leavesAreSimp (const Expr &e) |
Test if all i-leaves of e are simplified. | |
Type | boolType () |
Return BOOLEAN type. | |
const Expr & | falseExpr () |
Return FALSE Expr. | |
const Expr & | trueExpr () |
Return TRUE Expr. | |
Expr | newVar (const std::string &name, const Type &type) |
Create a new variable given its name and type. | |
Expr | newVar (const std::string &name, const Type &type, const Expr &def) |
Create a new named expression given its name, type, and definition. | |
Op | newFunction (const std::string &name, const Type &type, bool computeTransClosure) |
Create a new uninterpreted function. | |
Op | lookupFunction (const std::string &name, Type *type) |
Look up a function by name. | |
Op | newFunction (const std::string &name, const Type &type, const Expr &def) |
Create a new defined function. | |
Expr | addBoundVar (const std::string &name, const Type &type) |
Create and add a new bound variable to the stack, for parseExprOp(). | |
Expr | addBoundVar (const std::string &name, const Type &type, const Expr &def) |
Create and add a new bound named def to the stack, for parseExprOp(). | |
Expr | lookupVar (const std::string &name, Type *type) |
Lookup variable and return it and its type. Return NULL Expr if it doesn't exist yet. | |
Type | newTypeExpr (const std::string &name) |
Create a new uninterpreted type with the given name. | |
Type | lookupTypeExpr (const std::string &name) |
Lookup type by name. Return Null if no such type exists. | |
Type | newTypeExpr (const std::string &name, const Type &def) |
Create a new type abbreviation with the given name. | |
Type | newSubtypeExpr (const Expr &pred, const Expr &witness) |
Create a new subtype expression. | |
Expr | resolveID (const std::string &name) |
Resolve an identifier, for use in parseExprOp() | |
void | installID (const std::string &name, const Expr &e) |
Install name as a new identifier associated with Expr e. | |
Theorem | typePred (const Expr &e) |
Return BOOLEAN type. | |
Theorem | reflexivityRule (const Expr &a) |
==> a == a | |
Theorem | symmetryRule (const Theorem &a1_eq_a2) |
a1 == a2 ==> a2 == a1 | |
Theorem | transitivityRule (const Theorem &a1_eq_a2, const Theorem &a2_eq_a3) |
(a1 == a2) & (a2 == a3) ==> (a1 == a3) | |
Theorem | substitutivityRule (const Op &op, const std::vector< Theorem > &thms) |
(c_1 == d_1) & ... & (c_n == d_n) ==> op(c_1,...,c_n) == op(d_1,...,d_n) | |
Theorem | substitutivityRule (const Expr &e, const Theorem &t) |
Special case for unary operators. | |
Theorem | substitutivityRule (const Expr &e, const Theorem &t1, const Theorem &t2) |
Special case for binary operators. | |
Theorem | substitutivityRule (const Expr &e, const std::vector< unsigned > &changed, const std::vector< Theorem > &thms) |
Optimized: only positions which changed are included. | |
Theorem | substitutivityRule (const Expr &e, int changed, const Theorem &thm) |
Optimized: only a single position changed. | |
Theorem | iffMP (const Theorem &e1, const Theorem &e1_iff_e2) |
e1 AND (e1 IFF e2) ==> e2 | |
Theorem | rewriteAnd (const Expr &e) |
==> AND(e1,e2) IFF [simplified expr] | |
Theorem | rewriteOr (const Expr &e) |
==> OR(e1,...,en) IFF [simplified expr] | |
Theorem | rewriteIte (const Expr &e) |
Derived rule for rewriting ITE. | |
Theorem | renameExpr (const Expr &e) |
Derived rule to create a new name for an expression. | |
Protected Member Functions | |
virtual void | instantiate (const Expr &e, const Unsigned &u) |
virtual void | initializeLabels (const Expr &e, const Type &t) |
virtual void | mergeLabels (const Theorem &thm, const Expr &e1, const Expr &e2) |
virtual void | mergeLabels (const Theorem &thm, const Expr &e, unsigned position, bool positive) |
Protected Attributes | |
DatatypeProofRules * | d_rules |
ExprMap< ExprMap< unsigned > > | d_datatypes |
ExprMap< std::vector< Expr > > | d_constructorMap |
ExprMap< std::pair< Expr, unsigned > > | d_selectorMap |
ExprMap< Expr > | d_testerMap |
ExprMap< Op > | d_reach |
CDMap< Expr, SmartCDO< Unsigned > > | d_labels |
CDList< Theorem > | d_facts |
CDList< Expr > | d_splitters |
CDO< unsigned > | d_splittersIndex |
CDO< bool > | d_splitterAsserted |
const bool & | d_smartSplits |
ExprMap< bool > | d_getConstantStack |
![]() | |
bool | d_theoryUsed |
This theory handles datatypes.
Author: Clark Barrett
Created: Wed Dec 1 22:27:12 2004
Definition at line 52 of file theory_datatype.h.
TheoryDatatype::TheoryDatatype | ( | TheoryCore * | theoryCore | ) |
Definition at line 41 of file theory_datatype.cpp.
References CVC3::CONSTRUCTOR, createProofRules(), d_rules, CVC3::DATATYPE, CVC3::DATATYPE_DECL, CVC3::Theory::getEM(), CVC3::ExprManager::newKind(), CVC3::Theory::registerTheory(), CVC3::SELECTOR, and CVC3::TESTER.
|
virtual |
Definition at line 70 of file theory_datatype.cpp.
References d_rules.
Reimplemented in CVC3::TheoryDatatypeLazy.
Definition at line 75 of file theory_datatype.cpp.
References CVC3::Type::arity(), CVC3::ExprMap< Data >::begin(), d_datatypes, d_facts, d_rules, DebugAssert, CVC3::DatatypeProofRules::dummyTheorem(), CVC3::ExprMap< Data >::end(), CVC3::Theory::enqueueFact(), CVC3::Expr::eqExpr(), EXISTS, CVC3::ExprMap< Data >::find(), CVC3::Theory::findExpr(), CVC3::Theory::getBaseType(), CVC3::Theory::getEM(), CVC3::Type::getExpr(), CVC3::Expr::hasFind(), CVC3::isConstructor(), CVC3::Expr::isFinite(), CVC3::Expr::isSelected(), CVC3::Expr::mkOp(), CVC3::ExprManager::newClosureExpr(), CVC3::Type::toString(), and CVC3::Expr::toString().
Referenced by initializeLabels(), and mergeLabels().
Reimplemented in CVC3::TheoryDatatypeLazy.
Definition at line 112 of file theory_datatype.cpp.
References d_datatypes, d_labels, d_smartSplits, d_splitters, DebugAssert, CVC3::ExprMap< Data >::end(), CVC3::CDMap< Key, Data, HashFcn >::end(), CVC3::ExprMap< Data >::find(), CVC3::CDMap< Key, Data, HashFcn >::find(), CVC3::Theory::findExpr(), CVC3::getConstructor(), CVC3::Type::getExpr(), CVC3::CDMap< Key, Data, HashFcn >::insert(), instantiate(), CVC3::isConstructor(), CVC3::Expr::isFinite(), CVC3::CDList< T >::push_back(), CVC3::Theory::theoryCore(), and CVC3::Expr::toString().
Referenced by addSharedTerm(), assertFact(), setup(), and update().
|
protectedvirtual |
Reimplemented in CVC3::TheoryDatatypeLazy.
Definition at line 144 of file theory_datatype.cpp.
References d_facts, d_labels, d_rules, DebugAssert, CVC3::DatatypeProofRules::dummyTheorem(), CVC3::CDMap< Key, Data, HashFcn >::end(), CVC3::Theory::falseExpr(), CVC3::CDMap< Key, Data, HashFcn >::find(), CVC3::Theory::findExpr(), CVC3::Theory::getBaseType(), CVC3::Expr::hasFind(), instantiate(), CVC3::Theorem::isNull(), CVC3::CDList< T >::push_back(), and CVC3::Theory::setInconsistent().
Referenced by assertFact(), setup(), and update().
|
protectedvirtual |
Reimplemented in CVC3::TheoryDatatypeLazy.
Definition at line 167 of file theory_datatype.cpp.
References d_facts, d_labels, d_rules, DebugAssert, CVC3::DatatypeProofRules::dummyTheorem(), CVC3::CDMap< Key, Data, HashFcn >::end(), CVC3::Theory::falseExpr(), CVC3::CDMap< Key, Data, HashFcn >::find(), CVC3::Theory::findExpr(), CVC3::Expr::hasFind(), instantiate(), CVC3::CDList< T >::push_back(), and CVC3::Theory::setInconsistent().
DatatypeProofRules * TheoryDatatype::createProofRules | ( | ) |
Definition at line 42 of file datatype_theorem_producer.cpp.
Referenced by TheoryDatatype().
|
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 191 of file theory_datatype.cpp.
References CVC3::Expr::addToNotify(), d_labels, CVC3::DATATYPE, CVC3::CDMap< Key, Data, HashFcn >::end(), CVC3::CDMap< Key, Data, HashFcn >::find(), CVC3::Theory::getBaseType(), and initializeLabels().
|
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 201 of file theory_datatype.cpp.
References CVC3::Expr::addToNotify(), CVC3::Expr::andExpr(), CVC3::ExprMap< Data >::begin(), d_constructorMap, d_datatypes, d_facts, d_labels, d_rules, CVC3::DATATYPE, datatypeTestExpr(), CVC3::DatatypeProofRules::dummyTheorem(), CVC3::ExprMap< Data >::end(), CVC3::CDMap< Key, Data, HashFcn >::end(), CVC3::Theory::enqueueFact(), CVC3::Expr::eqExpr(), CVC3::CDMap< Key, Data, HashFcn >::find(), CVC3::Theory::getBaseType(), getConsForTester(), getConsPos(), CVC3::Type::getExpr(), CVC3::Theorem::getExpr(), CVC3::Expr::getOpExpr(), CVC3::Expr::getOpKind(), CVC3::Expr::impExpr(), initializeLabels(), CVC3::Expr::isNot(), CVC3::Expr::isNull(), CVC3::Theorem::isRewrite(), mergeLabels(), and CVC3::TESTER.
|
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.
Reimplemented in CVC3::TheoryDatatypeLazy.
Definition at line 260 of file theory_datatype.cpp.
References CVC3::Theory::addSplitter(), CVC3::ExprMap< Data >::begin(), d_datatypes, d_facts, d_labels, d_rules, d_smartSplits, d_splitterAsserted, d_splitters, d_splittersIndex, datatypeTestExpr(), DebugAssert, CVC3::DatatypeProofRules::dummyTheorem(), CVC3::ExprMap< Data >::end(), CVC3::CDMap< Key, Data, HashFcn >::end(), CVC3::Theory::enqueueFact(), CVC3::ExprMap< Data >::find(), CVC3::CDMap< Key, Data, HashFcn >::find(), CVC3::Theory::findExpr(), CVC3::Theory::getBaseType(), getConsPos(), CVC3::Type::getExpr(), CVC3::Expr::getOpExpr(), getSelectorInfo(), CVC3::isSelector(), OR, CVC3::CDList< T >::size(), CVC3::Type::toString(), and CVC3::Expr::toString().
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 320 of file theory_datatype.cpp.
References canCollapse(), d_facts, d_rules, CVC3::Theorem::getRHS(), CVC3::isConstructor(), CVC3::isSelector(), CVC3::isTester(), CVC3::Theory::reflexivityRule(), CVC3::DatatypeProofRules::rewriteSelCons(), CVC3::DatatypeProofRules::rewriteTestCons(), CVC3::Theory::simplify(), and CVC3::Theory::transitivityRule().
|
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.
Reimplemented in CVC3::TheoryDatatypeLazy.
Definition at line 339 of file theory_datatype.cpp.
References CVC3::Expr::addToNotify(), APPLY, CVC3::Expr::arity(), d_labels, d_rules, d_smartSplits, d_splitters, CVC3::DATATYPE, CVC3::CDMap< Key, Data, HashFcn >::end(), CVC3::Theory::enqueueFact(), CVC3::CDMap< Key, Data, HashFcn >::find(), CVC3::Theory::getBaseType(), CVC3::Expr::getKind(), initializeLabels(), CVC3::isConstructor(), CVC3::isSelector(), mergeLabels(), CVC3::DatatypeProofRules::noCycle(), CVC3::CDList< T >::push_back(), CVC3::Expr::setSelected(), and CVC3::Theory::setupCC().
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.
Reimplemented in CVC3::TheoryDatatypeLazy.
Definition at line 359 of file theory_datatype.cpp.
References CVC3::Expr::addToNotify(), CVC3::Expr::arity(), canCollapse(), d_facts, d_labels, d_rules, CVC3::DATATYPE, DebugAssert, CVC3::DatatypeProofRules::decompose(), CVC3::CDMap< Key, Data, HashFcn >::end(), CVC3::Theory::enqueueFact(), CVC3::CDMap< Key, Data, HashFcn >::find(), CVC3::Theory::getBaseType(), CVC3::Theory::getEM(), CVC3::Theorem::getLHS(), CVC3::Expr::getOpExpr(), CVC3::Expr::getRep(), CVC3::Theorem::getRHS(), CVC3::Expr::getSig(), initializeLabels(), CVC3::ExprManager::invalidateSimpCache(), CVC3::Expr::isApply(), CVC3::isConstructor(), CVC3::Theorem::isNull(), CVC3::Expr::isNull(), CVC3::Expr::isSelected(), CVC3::isSelector(), CVC3::isTester(), mergeLabels(), CVC3::CDList< T >::push_back(), CVC3::DatatypeProofRules::rewriteSelCons(), CVC3::DatatypeProofRules::rewriteTestCons(), CVC3::Expr::setRep(), CVC3::Expr::setSelected(), CVC3::Expr::setSig(), CVC3::Theory::symmetryRule(), 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 425 of file theory_datatype.cpp.
References DebugAssert, CVC3::Theorem::getLHS(), CVC3::Theorem::getRHS(), CVC3::isConstructor(), CVC3::Theorem::isRewrite(), CVC3::Expr::isTerm(), and CVC3::Theory::symmetryRule().
|
virtual |
Check that e is a valid Type expr.
Reimplemented from CVC3::Theory.
Definition at line 436 of file theory_datatype.cpp.
References CVC3::Expr::arity(), CVC3::CONSTRUCTOR, CVC3::DATATYPE, FatalAssert, CVC3::Theory::getEM(), CVC3::Expr::getKind(), CVC3::Expr::isString(), CVC3::Theory::resolveID(), CVC3::SELECTOR, CVC3::TESTER, and CVC3::Expr::toString().
|
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.
Reimplemented from CVC3::Theory.
Definition at line 457 of file theory_datatype.cpp.
References CVC3::Expr::arity(), CVC3::ExprMap< Data >::begin(), CVC3::CARD_FINITE, CVC3::CARD_INFINITE, CVC3::CARD_UNKNOWN, CVC3::ExprMap< Data >::count(), d_datatypes, d_getConstantStack, CVC3::DATATYPE, DebugAssert, CVC3::ExprMap< Data >::end(), CVC3::ExprMap< Data >::erase(), CVC3::Theory::finiteTypeInfo(), CVC3::Type::getExpr(), CVC3::Expr::getKind(), CVC3::Expr::getType(), CVC3::Expr::mkOp(), CVC3::Theory::theoryOf(), CVC3::Expr::typeEnumerateFinite(), and CVC3::Expr::typeSizeFinite().
|
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 562 of file theory_datatype.cpp.
References CVC3::Expr::arity(), ARROW, CVC3::Expr::begin(), CVC3::CONSTRUCTOR, CVC3::DATATYPE, DebugAssert, CVC3::Expr::end(), CVC3::Theory::getBaseType(), CVC3::Type::getExpr(), CVC3::Op::getExpr(), CVC3::Expr::getKind(), CVC3::Expr::getOp(), CVC3::Expr::getOpKind(), CVC3::Expr::isApply(), CVC3::Type::isNull(), CVC3::SELECTOR, CVC3::Expr::setType(), CVC3::TESTER, and CVC3::Expr::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 607 of file theory_datatype.cpp.
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 612 of file theory_datatype.cpp.
References CVC3::Expr::andExpr(), APPLY, CVC3::Expr::arity(), CVC3::Theory::computeTCC(), CVC3::CONSTRUCTOR, datatypeTestExpr(), DebugAssert, CVC3::Expr::getKind(), CVC3::Expr::getOpExpr(), getSelectorInfo(), CVC3::Expr::isApply(), CVC3::SELECTOR, CVC3::Expr::toString(), and CVC3::Theory::trueExpr().
Theory-specific parsing implemented by the DP.
Reimplemented from CVC3::Theory.
Definition at line 731 of file theory_datatype.cpp.
References CVC3::Expr::arity(), CVC3::ExprMap< Data >::count(), CVC3::DATATYPE, DebugAssert, CVC3::Theory::getEM(), CVC3::ExprManager::getKind(), CVC3::Expr::getKind(), CVC3::Expr::getString(), ID, CVC3::ExprMap< Data >::insert(), CVC3::Theory::parseExpr(), RAW_LIST, and CVC3::Expr::toString().
|
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 639 of file theory_datatype.cpp.
References APPLY, CVC3::Expr::arity(), CVC3::ExprMap< Data >::begin(), CVC3::Expr::begin(), CVC3::CONSTRUCTOR, d_constructorMap, d_datatypes, CVC3::DATATYPE, CVC3::DATATYPE_DECL, DebugAssert, CVC3::ExprMap< Data >::end(), CVC3::Expr::end(), std::endl(), FatalAssert, CVC3::ExprMap< Data >::find(), CVC3::Theory::getEM(), CVC3::Expr::getKind(), CVC3::Expr::getName(), CVC3::Expr::getOpExpr(), CVC3::Expr::getString(), CVC3::Expr::isString(), CVC3::Expr::isSymbol(), CVC3::ExprStream::lang(), CVC3::LISP_LANG, CVC3::pop(), CVC3::PRESENTATION_LANG, CVC3::Expr::printAST(), CVC3::push(), CVC3::SELECTOR, CVC3::SMTLIB_LANG, CVC3::space(), and CVC3::TESTER.
Expr TheoryDatatype::dataType | ( | const std::string & | name, |
const std::vector< std::string > & | constructors, | ||
const std::vector< std::vector< std::string > > & | selectors, | ||
const std::vector< std::vector< Expr > > & | types | ||
) |
Definition at line 859 of file theory_datatype.cpp.
Expr TheoryDatatype::dataType | ( | const std::vector< std::string > & | names, |
const std::vector< std::vector< std::string > > & | constructors, | ||
const std::vector< std::vector< std::vector< std::string > > > & | selectors, | ||
const std::vector< std::vector< std::vector< Expr > > > & | types | ||
) |
Definition at line 878 of file theory_datatype.cpp.
References CVC3::Type::anyType(), CVC3::Expr::arity(), CVC3::ExprMap< Data >::begin(), CVC3::Theory::boolType(), CVC3::CONSTRUCTOR, d_constructorMap, d_datatypes, d_reach, d_selectorMap, d_testerMap, CVC3::DATATYPE, CVC3::DATATYPE_DECL, CVC3::ExprMap< Data >::end(), CVC3::Type::funType(), CVC3::Theory::getBaseType(), CVC3::Theory::getEM(), CVC3::Type::getExpr(), CVC3::Op::getExpr(), CVC3::Expr::getName(), CVC3::Theory::installID(), CVC3::int2string(), CVC3::Type::isBool(), CVC3::isDatatype(), CVC3::Expr::isFinite(), CVC3::Type::isFunction(), CVC3::Type::isNull(), CVC3::Expr::isNull(), CVC3::Expr::isWellFounded(), CVC3::Theory::newFunction(), CVC3::ExprManager::newSymbolExpr(), CVC3::Theory::resolveID(), CVC3::SELECTOR, CVC3::Expr::setFinite(), CVC3::Expr::setType(), CVC3::Expr::setWellFounded(), CVC3::TESTER, and CVC3::TRANS_CLOSURE.
Expr TheoryDatatype::datatypeConsExpr | ( | const std::string & | constructor, |
const std::vector< Expr > & | args | ||
) |
Definition at line 1086 of file theory_datatype.cpp.
References CVC3::CONSTRUCTOR, CVC3::Expr::getKind(), CVC3::Expr::isNull(), CVC3::Expr::isSymbol(), CVC3::Expr::mkOp(), CVC3::Theory::resolveID(), and CVC3::Expr::toString().
Definition at line 1100 of file theory_datatype.cpp.
References CVC3::Expr::getKind(), CVC3::Expr::isNull(), CVC3::Expr::isSymbol(), CVC3::Expr::mkOp(), CVC3::Theory::resolveID(), CVC3::SELECTOR, and CVC3::Expr::toString().
Definition at line 1112 of file theory_datatype.cpp.
References CVC3::Expr::getKind(), CVC3::Expr::isNull(), CVC3::Expr::isSymbol(), CVC3::Expr::mkOp(), CVC3::Theory::resolveID(), CVC3::TESTER, and CVC3::Expr::toString().
Referenced by assertFact(), CVC3::TheoryDatatypeLazy::checkSat(), checkSat(), and computeTCC().
Definition at line 1124 of file theory_datatype.cpp.
References d_selectorMap, DebugAssert, CVC3::ExprMap< Data >::end(), CVC3::ExprMap< Data >::find(), CVC3::Expr::getKind(), CVC3::SELECTOR, and CVC3::Expr::toString().
Referenced by canCollapse(), checkSat(), and computeTCC().
Definition at line 1134 of file theory_datatype.cpp.
References d_testerMap, DebugAssert, CVC3::ExprMap< Data >::end(), CVC3::ExprMap< Data >::find(), CVC3::Expr::getKind(), CVC3::TESTER, and CVC3::Expr::toString().
Referenced by assertFact().
unsigned TheoryDatatype::getConsPos | ( | const Expr & | e | ) |
Definition at line 1145 of file theory_datatype.cpp.
References CVC3::CONSTRUCTOR, d_datatypes, DebugAssert, CVC3::ExprMap< Data >::end(), CVC3::ExprMap< Data >::find(), CVC3::Theory::getBaseType(), CVC3::Expr::getKind(), CVC3::isDatatype(), and CVC3::Expr::toString().
Referenced by assertFact(), canCollapse(), and checkSat().
Definition at line 1161 of file theory_datatype.cpp.
References CVC3::Expr::arity(), CVC3::ExprMap< Data >::begin(), CVC3::ExprMap< Data >::count(), d_datatypes, d_getConstantStack, DebugAssert, CVC3::ExprMap< Data >::end(), FatalAssert, CVC3::ExprMap< Data >::find(), CVC3::Theory::getBaseType(), CVC3::Type::getExpr(), CVC3::Type::isBool(), CVC3::isDatatype(), CVC3::Type::isFunction(), CVC3::Expr::isNull(), CVC3::Expr::mkOp(), CVC3::Theory::newVar(), CVC3::Theory::resolveID(), CVC3::ExprMap< Data >::size(), CVC3::Type::toString(), and CVC3::Expr::toString().
Definition at line 1228 of file theory_datatype.cpp.
References d_reach, DebugAssert, CVC3::ExprMap< Data >::end(), CVC3::ExprMap< Data >::find(), CVC3::Type::getExpr(), and CVC3::isDatatype().
bool TheoryDatatype::canCollapse | ( | const Expr & | e | ) |
Definition at line 1237 of file theory_datatype.cpp.
References CVC3::Expr::arity(), d_labels, DebugAssert, CVC3::CDMap< Key, Data, HashFcn >::end(), CVC3::CDMap< Key, Data, HashFcn >::find(), CVC3::Theory::findExpr(), getConsPos(), CVC3::Expr::getOpExpr(), getSelectorInfo(), CVC3::isConstructor(), and CVC3::isSelector().
Referenced by rewrite(), CVC3::TheoryDatatypeLazy::update(), and update().
|
protected |
Definition at line 54 of file theory_datatype.h.
Referenced by assertFact(), checkSat(), CVC3::TheoryDatatypeLazy::instantiate(), instantiate(), CVC3::TheoryDatatypeLazy::mergeLabels(), mergeLabels(), rewrite(), CVC3::TheoryDatatypeLazy::setup(), setup(), TheoryDatatype(), CVC3::TheoryDatatypeLazy::update(), update(), and ~TheoryDatatype().
Definition at line 57 of file theory_datatype.h.
Referenced by assertFact(), CVC3::TheoryDatatypeLazy::checkSat(), checkSat(), dataType(), finiteTypeInfo(), getConsPos(), getConstant(), CVC3::TheoryDatatypeLazy::initializeLabels(), initializeLabels(), CVC3::TheoryDatatypeLazy::instantiate(), instantiate(), and print().
Definition at line 59 of file theory_datatype.h.
Referenced by assertFact(), dataType(), and print().
Definition at line 61 of file theory_datatype.h.
Referenced by dataType(), and getSelectorInfo().
Definition at line 63 of file theory_datatype.h.
Referenced by dataType(), and getConsForTester().
Definition at line 64 of file theory_datatype.h.
Referenced by dataType(), and getReachablePredicate().
Definition at line 66 of file theory_datatype.h.
Referenced by addSharedTerm(), assertFact(), canCollapse(), CVC3::TheoryDatatypeLazy::checkSat(), checkSat(), CVC3::TheoryDatatypeLazy::initializeLabels(), initializeLabels(), CVC3::TheoryDatatypeLazy::mergeLabels(), mergeLabels(), CVC3::TheoryDatatypeLazy::setup(), setup(), and update().
Definition at line 68 of file theory_datatype.h.
Referenced by assertFact(), CVC3::TheoryDatatypeLazy::checkSat(), checkSat(), CVC3::TheoryDatatypeLazy::instantiate(), instantiate(), CVC3::TheoryDatatypeLazy::mergeLabels(), mergeLabels(), rewrite(), CVC3::TheoryDatatypeLazy::update(), and update().
Definition at line 69 of file theory_datatype.h.
Referenced by CVC3::TheoryDatatypeLazy::checkSat(), checkSat(), CVC3::TheoryDatatypeLazy::initializeLabels(), initializeLabels(), and setup().
|
protected |
Definition at line 70 of file theory_datatype.h.
Referenced by CVC3::TheoryDatatypeLazy::checkSat(), and checkSat().
|
protected |
Definition at line 71 of file theory_datatype.h.
Referenced by CVC3::TheoryDatatypeLazy::checkSat(), and checkSat().
|
protected |
Definition at line 72 of file theory_datatype.h.
Referenced by checkSat(), initializeLabels(), and setup().
|
protected |
Definition at line 73 of file theory_datatype.h.
Referenced by finiteTypeInfo(), and getConstant().