CVC3  2.4.1
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
CVC3::TheoryDatatypeLazy Class Reference

This theory handles datatypes. More...

#include <theory_datatype_lazy.h>

Inheritance diagram for CVC3::TheoryDatatypeLazy:
CVC3::TheoryDatatype CVC3::Theory

Public Member Functions

 TheoryDatatypeLazy (TheoryCore *theoryCore)
 
 ~TheoryDatatypeLazy ()
 
void checkSat (bool fullEffort)
 Check for satisfiability in the theory. More...
 
void setup (const Expr &e)
 Set up the term e for call-backs when e or its children change. More...
 
void update (const Theorem &e, const Expr &d)
 Notify a theory of a new equality. More...
 
- Public Member Functions inherited from CVC3::TheoryDatatype
 TheoryDatatype (TheoryCore *theoryCore)
 
virtual ~TheoryDatatype ()
 
DatatypeProofRulescreateProofRules ()
 
void addSharedTerm (const Expr &e)
 Notify theory of a new shared term. More...
 
void assertFact (const Theorem &e)
 Assert a new fact to the decision procedure. More...
 
Theorem rewrite (const Expr &e)
 Theory-specific rewrite rules. More...
 
Theorem solve (const Theorem &e)
 An optional solver. More...
 
void checkType (const Expr &e)
 Check that e is a valid Type expr. More...
 
Cardinality finiteTypeInfo (Expr &e, Unsigned &n, bool enumerate, bool computeSize)
 Compute information related to finiteness of types. More...
 
void computeType (const Expr &e)
 Compute and store the type of e. More...
 
void computeModelTerm (const Expr &e, std::vector< Expr > &v)
 Add variables from 'e' to 'v' for constructing a concrete model. More...
 
Expr computeTCC (const Expr &e)
 Compute and cache the TCC of e. More...
 
Expr parseExprOp (const Expr &e)
 Theory-specific parsing implemented by the DP. More...
 
ExprStreamprint (ExprStream &os, const Expr &e)
 Theory-specific pretty-printing. More...
 
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 OpgetReachablePredicate (const Type &t)
 
bool canCollapse (const Expr &e)
 
- Public Member Functions inherited from CVC3::Theory
 Theory (TheoryCore *theoryCore, const std::string &name)
 Whether theory has been used (for smtlib translator) More...
 
virtual ~Theory (void)
 Destructor. More...
 
ExprManagergetEM ()
 Access to ExprManager. More...
 
TheoryCoretheoryCore ()
 Get a pointer to theoryCore. More...
 
CommonProofRulesgetCommonRules ()
 Get a pointer to common proof rules. More...
 
const std::string & getName () const
 Get the name of the theory (for debugging purposes) More...
 
virtual void setUsed ()
 Set the "used" flag on this theory (for smtlib translator) More...
 
virtual bool theoryUsed ()
 Get whether theory has been used (for smtlib translator) More...
 
virtual Theorem theoryPreprocess (const Expr &e)
 Theory-specific preprocessing. More...
 
virtual void checkAssertEqInvariant (const Theorem &e)
 A debug check used by the primary solver. More...
 
virtual Theorem simplifyOp (const Expr &e)
 Recursive simplification step. More...
 
virtual Type computeBaseType (const Type &tp)
 Compute the base type of the top-level operator of an arbitrary type. More...
 
virtual Expr computeTypePred (const Type &t, const Expr &e)
 Theory specific computation of the subtyping predicate for type t applied to the expression e. More...
 
virtual void refineCounterExample ()
 Process disequalities from the arrangement for model generation. More...
 
virtual void computeModelBasic (const std::vector< Expr > &v)
 Assign concrete values to basic-type variables in v. More...
 
virtual void computeModel (const Expr &e, std::vector< Expr > &vars)
 Compute the value of a compound variable from the more primitive ones. More...
 
virtual void assertTypePred (const Expr &e, const Theorem &pred)
 Receives all the type predicates for the types of the given theory. More...
 
virtual Theorem rewriteAtomic (const Expr &e)
 Theory-specific rewrites for atomic formulas. More...
 
virtual void notifyInconsistent (const Theorem &thm)
 Notification of conflict. More...
 
virtual void registerAtom (const Expr &e, const Theorem &thm)
 
virtual void registerAtom (const Expr &e)
 Theory-specific registration of atoms. More...
 
virtual bool inconsistent ()
 Check if the current context is inconsistent. More...
 
virtual void setInconsistent (const Theorem &e)
 Make the context inconsistent; The formula proved by e must FALSE. More...
 
virtual void setIncomplete (const std::string &reason)
 Mark the current decision branch as possibly incomplete. More...
 
virtual Theorem simplify (const Expr &e)
 Simplify a term e and return a Theorem(e==e') More...
 
Expr simplifyExpr (const Expr &e)
 Simplify a term e w.r.t. the current context. More...
 
virtual void enqueueFact (const Theorem &e)
 Submit a derived fact to the core from a decision procedure. More...
 
virtual void enqueueSE (const Theorem &e)
 Check if the current context is inconsistent. More...
 
virtual void assertEqualities (const Theorem &e)
 Handle new equalities (usually asserted through addFact) More...
 
virtual Expr parseExpr (const Expr &e)
 Parse the generic expression. More...
 
virtual void assignValue (const Expr &t, const Expr &val)
 Assigns t a concrete value val. Used in model generation. More...
 
virtual void assignValue (const Theorem &thm)
 Record a derived assignment to a variable (LHS). More...
 
void registerKinds (Theory *theory, std::vector< int > &kinds)
 Register new kinds with the given theory. More...
 
void unregisterKinds (Theory *theory, std::vector< int > &kinds)
 Unregister kinds for a theory. More...
 
void registerTheory (Theory *theory, std::vector< int > &kinds, bool hasSolver=false)
 Register a new theory. More...
 
void unregisterTheory (Theory *theory, std::vector< int > &kinds, bool hasSolver)
 Unregister a theory. More...
 
int getNumTheories ()
 Return the number of registered theories. More...
 
bool hasTheory (int kind)
 Test whether a kind maps to any theory. More...
 
TheorytheoryOf (int kind)
 Return the theory associated with a kind. More...
 
TheorytheoryOf (const Type &e)
 Return the theory associated with a type. More...
 
TheorytheoryOf (const Expr &e)
 Return the theory associated with an Expr. More...
 
Theorem find (const Expr &e)
 Return the theorem that e is equal to its find. More...
 
const TheoremfindRef (const Expr &e)
 Return the find as a reference: expr must have a find. More...
 
Theorem findReduce (const Expr &e)
 Return find-reduced version of e. More...
 
bool findReduced (const Expr &e)
 Return true iff e is find-reduced. More...
 
Expr findExpr (const Expr &e)
 Return the find of e, or e if it has no find. More...
 
Expr getTCC (const Expr &e)
 Compute the TCC of e, or the subtyping predicate, if e is a type. More...
 
Type getBaseType (const Expr &e)
 Compute (or look up in cache) the base type of e and return the result. More...
 
Type getBaseType (const Type &tp)
 Compute the base type from an arbitrary type. More...
 
Expr getTypePred (const Type &t, const Expr &e)
 Calls the correct theory to compute a type predicate. More...
 
Theorem updateHelper (const Expr &e)
 Update the children of the term e. More...
 
void setupCC (const Expr &e)
 Setup a term for congruence closure (must have sig and rep attributes) More...
 
void updateCC (const Theorem &e, const Expr &d)
 Update a term w.r.t. congruence closure (must be setup with setupCC()) More...
 
Theorem rewriteCC (const Expr &e)
 Rewrite a term w.r.t. congruence closure (must be setup with setupCC()) More...
 
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. More...
 
Theorem getModelValue (const Expr &e)
 Fetch the concrete assignment to the variable during model generation. More...
 
void addSplitter (const Expr &e, int priority=0)
 Suggest a splitter to the SearchEngine. More...
 
void addGlobalLemma (const Theorem &thm, int priority=0)
 Add a global lemma. More...
 
bool isLeaf (const Expr &e)
 Test if e is an i-leaf term for the current theory. More...
 
bool isLeafIn (const Expr &e1, const Expr &e2)
 Test if e1 is an i-leaf in e2. More...
 
bool leavesAreSimp (const Expr &e)
 Test if all i-leaves of e are simplified. More...
 
Type boolType ()
 Return BOOLEAN type. More...
 
const ExprfalseExpr ()
 Return FALSE Expr. More...
 
const ExprtrueExpr ()
 Return TRUE Expr. More...
 
Expr newVar (const std::string &name, const Type &type)
 Create a new variable given its name and type. More...
 
Expr newVar (const std::string &name, const Type &type, const Expr &def)
 Create a new named expression given its name, type, and definition. More...
 
Op newFunction (const std::string &name, const Type &type, bool computeTransClosure)
 Create a new uninterpreted function. More...
 
Op lookupFunction (const std::string &name, Type *type)
 Look up a function by name. More...
 
Op newFunction (const std::string &name, const Type &type, const Expr &def)
 Create a new defined function. More...
 
Expr addBoundVar (const std::string &name, const Type &type)
 Create and add a new bound variable to the stack, for parseExprOp(). More...
 
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(). More...
 
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. More...
 
Type newTypeExpr (const std::string &name)
 Create a new uninterpreted type with the given name. More...
 
Type lookupTypeExpr (const std::string &name)
 Lookup type by name. Return Null if no such type exists. More...
 
Type newTypeExpr (const std::string &name, const Type &def)
 Create a new type abbreviation with the given name. More...
 
Type newSubtypeExpr (const Expr &pred, const Expr &witness)
 Create a new subtype expression. More...
 
Expr resolveID (const std::string &name)
 Resolve an identifier, for use in parseExprOp() More...
 
void installID (const std::string &name, const Expr &e)
 Install name as a new identifier associated with Expr e. More...
 
Theorem typePred (const Expr &e)
 Return BOOLEAN type. More...
 
Theorem reflexivityRule (const Expr &a)
 ==> a == a More...
 
Theorem symmetryRule (const Theorem &a1_eq_a2)
 a1 == a2 ==> a2 == a1 More...
 
Theorem transitivityRule (const Theorem &a1_eq_a2, const Theorem &a2_eq_a3)
 (a1 == a2) & (a2 == a3) ==> (a1 == a3) More...
 
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) More...
 
Theorem substitutivityRule (const Expr &e, const Theorem &t)
 Special case for unary operators. More...
 
Theorem substitutivityRule (const Expr &e, const Theorem &t1, const Theorem &t2)
 Special case for binary operators. More...
 
Theorem substitutivityRule (const Expr &e, const std::vector< unsigned > &changed, const std::vector< Theorem > &thms)
 Optimized: only positions which changed are included. More...
 
Theorem substitutivityRule (const Expr &e, int changed, const Theorem &thm)
 Optimized: only a single position changed. More...
 
Theorem iffMP (const Theorem &e1, const Theorem &e1_iff_e2)
 e1 AND (e1 IFF e2) ==> e2 More...
 
Theorem rewriteAnd (const Expr &e)
 ==> AND(e1,e2) IFF [simplified expr] More...
 
Theorem rewriteOr (const Expr &e)
 ==> OR(e1,...,en) IFF [simplified expr] More...
 
Theorem rewriteIte (const Expr &e)
 Derived rule for rewriting ITE. More...
 
Theorem renameExpr (const Expr &e)
 Derived rule to create a new name for an expression. More...
 

Private Types

enum  ProcessKinds { MERGE1 = 0, MERGE2, ENQUEUE }
 

Private Member Functions

void instantiate (const Expr &e, const Unsigned &u)
 
void initializeLabels (const Expr &e, const Type &t)
 
void mergeLabels (const Theorem &thm, const Expr &e1, const Expr &e2)
 
void mergeLabels (const Theorem &thm, const Expr &e, unsigned position, bool positive)
 

Private Attributes

CDList< Theoremd_processQueue
 
CDList< ProcessKindsd_processQueueKind
 
CDO< unsigned > d_processIndex
 
CDO< bool > d_typeComplete
 

Additional Inherited Members

- Protected Attributes inherited from CVC3::TheoryDatatype
DatatypeProofRulesd_rules
 
ExprMap< ExprMap< unsigned > > d_datatypes
 
ExprMap< std::vector< Expr > > d_constructorMap
 
ExprMap< std::pair< Expr,
unsigned > > 
d_selectorMap
 
ExprMap< Exprd_testerMap
 
ExprMap< Opd_reach
 
CDMap< Expr, SmartCDO< Unsigned > > d_labels
 
CDList< Theoremd_facts
 
CDList< Exprd_splitters
 
CDO< unsigned > d_splittersIndex
 
CDO< bool > d_splitterAsserted
 
const bool & d_smartSplits
 
ExprMap< bool > d_getConstantStack
 

Detailed Description

This theory handles datatypes.

Author: Clark Barrett

Created: Wed Dec 1 22:27:12 2004

Definition at line 42 of file theory_datatype_lazy.h.

Member Enumeration Documentation

Enumerator
MERGE1 
MERGE2 
ENQUEUE 

Definition at line 44 of file theory_datatype_lazy.h.

Constructor & Destructor Documentation

TheoryDatatypeLazy::TheoryDatatypeLazy ( TheoryCore theoryCore)

Definition at line 41 of file theory_datatype_lazy.cpp.

CVC3::TheoryDatatypeLazy::~TheoryDatatypeLazy ( )
inline

Definition at line 64 of file theory_datatype_lazy.h.

Member Function Documentation

void TheoryDatatypeLazy::instantiate ( const Expr e,
const Unsigned u 
)
privatevirtual
void TheoryDatatypeLazy::initializeLabels ( const Expr e,
const Type t 
)
privatevirtual
void TheoryDatatypeLazy::mergeLabels ( const Theorem thm,
const Expr e1,
const Expr e2 
)
privatevirtual
void TheoryDatatypeLazy::mergeLabels ( const Theorem thm,
const Expr e,
unsigned  position,
bool  positive 
)
privatevirtual
void TheoryDatatypeLazy::checkSat ( bool  fullEffort)
virtual

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.

Reimplemented from CVC3::TheoryDatatype.

Definition at line 178 of file theory_datatype_lazy.cpp.

References CVC3::Theory::addSplitter(), CVC3::ExprMap< Data >::begin(), CVC3::TheoryDatatype::d_datatypes, CVC3::TheoryDatatype::d_facts, CVC3::TheoryDatatype::d_labels, d_processIndex, d_processQueue, d_processQueueKind, CVC3::TheoryDatatype::d_splitterAsserted, CVC3::TheoryDatatype::d_splitters, CVC3::TheoryDatatype::d_splittersIndex, d_typeComplete, CVC3::TheoryDatatype::datatypeTestExpr(), DebugAssert, ENQUEUE, CVC3::Theory::enqueueFact(), CVC3::Theory::findExpr(), CVC3::Type::getExpr(), CVC3::Theorem::getLHS(), CVC3::Theorem::getRHS(), CVC3::Expr::getType(), CVC3::Expr::isSelected(), MERGE1, MERGE2, mergeLabels(), CVC3::Expr::setSelected(), CVC3::CDList< T >::size(), CVC3::Type::toString(), and CVC3::Expr::toString().

void TheoryDatatypeLazy::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
update

Reimplemented from CVC3::TheoryDatatype.

Definition at line 246 of file theory_datatype_lazy.cpp.

References CVC3::Expr::addToNotify(), APPLY, CVC3::Expr::arity(), CVC3::TheoryDatatype::d_labels, d_processQueue, d_processQueueKind, CVC3::TheoryDatatype::d_rules, CVC3::DATATYPE, ENQUEUE, CVC3::Type::getExpr(), CVC3::Expr::getKind(), CVC3::Expr::getType(), initializeLabels(), CVC3::isConstructor(), CVC3::isSelector(), MERGE2, CVC3::DatatypeProofRules::noCycle(), CVC3::CDList< T >::push_back(), CVC3::Theory::reflexivityRule(), CVC3::Expr::setSelected(), and CVC3::Theory::setupCC().

void TheoryDatatypeLazy::update ( const Theorem e,
const Expr d 
)
virtual

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 from CVC3::TheoryDatatype.

Definition at line 267 of file theory_datatype_lazy.cpp.

References CVC3::Expr::addToNotify(), CVC3::Expr::arity(), CVC3::TheoryDatatype::canCollapse(), CVC3::TheoryDatatype::d_facts, d_processQueue, d_processQueueKind, CVC3::TheoryDatatype::d_rules, CVC3::DatatypeProofRules::decompose(), ENQUEUE, CVC3::Theory::getEM(), CVC3::Theorem::getLHS(), CVC3::Expr::getOpExpr(), CVC3::Expr::getRep(), CVC3::Theorem::getRHS(), CVC3::Expr::getSig(), CVC3::ExprManager::invalidateSimpCache(), CVC3::Expr::isApply(), CVC3::isConstructor(), CVC3::Theorem::isNull(), CVC3::Expr::isNull(), CVC3::isSelector(), CVC3::isTester(), MERGE2, CVC3::CDList< T >::push_back(), CVC3::DatatypeProofRules::rewriteSelCons(), CVC3::DatatypeProofRules::rewriteTestCons(), CVC3::Expr::setRep(), CVC3::Expr::setSig(), CVC3::Theory::symmetryRule(), CVC3::Theory::transitivityRule(), and CVC3::Theory::updateHelper().

Member Data Documentation

CDList<Theorem> CVC3::TheoryDatatypeLazy::d_processQueue
private

Definition at line 50 of file theory_datatype_lazy.h.

Referenced by checkSat(), instantiate(), setup(), and update().

CDList<ProcessKinds> CVC3::TheoryDatatypeLazy::d_processQueueKind
private

Definition at line 51 of file theory_datatype_lazy.h.

Referenced by checkSat(), instantiate(), setup(), and update().

CDO<unsigned> CVC3::TheoryDatatypeLazy::d_processIndex
private

Definition at line 52 of file theory_datatype_lazy.h.

Referenced by checkSat().

CDO<bool> CVC3::TheoryDatatypeLazy::d_typeComplete
private

Definition at line 53 of file theory_datatype_lazy.h.

Referenced by checkSat(), and initializeLabels().


The documentation for this class was generated from the following files: