CVCL::TheoryDatatype Class Reference
[Theories]

This theory handles datatypes. More...

#include <theory_datatype.h>

Inheritance diagram for CVCL::TheoryDatatype:

Inheritance graph
[legend]
Collaboration diagram for CVCL::TheoryDatatype:

Collaboration graph
[legend]
List of all members.

Public Member Functions

Protected Types

Protected Member Functions

Protected Attributes


Detailed Description

This theory handles datatypes.

Author: Clark Barrett

Created: Wed Dec 1 22:27:12 2004

Definition at line 59 of file theory_datatype.h.


Member Typedef Documentation

typedef unsigned CVCL::TheoryDatatype::bigunsigned [protected]
 

Definition at line 68 of file theory_datatype.h.


Constructor & Destructor Documentation

TheoryDatatype::TheoryDatatype TheoryCore theoryCore  ) 
 

Definition at line 49 of file theory_datatype.cpp.

References CVCL::CONSTRUCTOR, createProofRules(), d_rules, CVCL::DATATYPE, CVCL::Theory::getEM(), CVCL::ExprManager::newKind(), CVCL::Theory::registerTheory(), CVCL::SELECTOR, and CVCL::TESTER.

TheoryDatatype::~TheoryDatatype  )  [virtual]
 

Definition at line 76 of file theory_datatype.cpp.

References d_rules.


Member Function Documentation

void TheoryDatatype::instantiate const Expr e,
const bigunsigned u
[protected, virtual]
 

Definition at line 81 of file theory_datatype.cpp.

References CVCL::Type::arity(), CVCL::ExprMap< Data >::begin(), d_datatypes, d_facts, d_rules, CVCL::DatatypeProofRules::dummyTheorem(), CVCL::ExprMap< Data >::end(), CVCL::Theory::enqueueFact(), CVCL::Expr::eqExpr(), CVCL::EXISTS, CVCL::ExprMap< Data >::find(), CVCL::Theory::findExpr(), CVCL::Theory::getEM(), CVCL::Type::getExpr(), CVCL::Expr::getType(), CVCL::Expr::hasFind(), CVCL::isConstructor(), CVCL::Expr::isFinite(), CVCL::Expr::isSelected(), CVCL::Expr::mkOp(), CVCL::ExprManager::newClosureExpr(), CVCL::Expr::toString(), and CVCL::Type::toString().

Referenced by initializeLabels(), and mergeLabels().

void TheoryDatatype::initializeLabels const Expr e,
const Type t
[protected, virtual]
 

Reimplemented in CVCL::TheoryDatatypeLazy.

Definition at line 118 of file theory_datatype.cpp.

References d_datatypes, d_labels, d_smartSplits, d_splitters, CVCL::CDMap< Key, Data, HashFcn >::end(), CVCL::ExprMap< Data >::end(), CVCL::CDMap< Key, Data, HashFcn >::find(), CVCL::ExprMap< Data >::find(), CVCL::Theory::findExpr(), CVCL::getConstructor(), CVCL::Type::getExpr(), CVCL::CDMap< Key, Data, HashFcn >::insert(), instantiate(), CVCL::isConstructor(), CVCL::Expr::isFinite(), CVCL::CDList< T >::push_back(), CVCL::ExprMap< Data >::size(), CVCL::Theory::theoryCore(), and CVCL::Expr::toString().

Referenced by addSharedTerm(), and setup().

void TheoryDatatype::mergeLabels const Theorem thm,
const Expr e1,
const Expr e2
[protected, virtual]
 

Reimplemented in CVCL::TheoryDatatypeLazy.

Definition at line 151 of file theory_datatype.cpp.

References d_facts, d_labels, d_rules, CVCL::DatatypeProofRules::dummyTheorem(), CVCL::CDMap< Key, Data, HashFcn >::end(), CVCL::Theory::falseExpr(), CVCL::CDMap< Key, Data, HashFcn >::find(), CVCL::Theory::findExpr(), CVCL::Expr::getType(), CVCL::Expr::hasFind(), instantiate(), CVCL::Theorem::isNull(), CVCL::CDList< T >::push_back(), and CVCL::Theory::setInconsistent().

Referenced by assertFact(), setup(), and update().

void TheoryDatatype::mergeLabels const Theorem thm,
const Expr e,
unsigned  position,
bool  positive
[protected, virtual]
 

Reimplemented in CVCL::TheoryDatatypeLazy.

Definition at line 174 of file theory_datatype.cpp.

References d_facts, d_labels, d_rules, CVCL::DatatypeProofRules::dummyTheorem(), CVCL::CDMap< Key, Data, HashFcn >::end(), CVCL::Theory::falseExpr(), CVCL::CDMap< Key, Data, HashFcn >::find(), CVCL::Theory::findExpr(), CVCL::Expr::hasFind(), instantiate(), CVCL::CDList< T >::push_back(), and CVCL::Theory::setInconsistent().

DatatypeProofRules * TheoryDatatype::createProofRules  ) 
 

Definition at line 50 of file datatype_theorem_producer.cpp.

Referenced by TheoryDatatype().

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

Definition at line 198 of file theory_datatype.cpp.

References CVCL::Expr::addToNotify(), d_labels, CVCL::DATATYPE, CVCL::CDMap< Key, Data, HashFcn >::end(), CVCL::CDMap< Key, Data, HashFcn >::find(), CVCL::Type::getExpr(), CVCL::Expr::getKind(), CVCL::Expr::getType(), and initializeLabels().

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

Definition at line 208 of file theory_datatype.cpp.

References getConsForTester(), getConsPos(), CVCL::Theorem::getExpr(), CVCL::Expr::getOpExpr(), CVCL::Expr::getOpKind(), CVCL::Expr::isNot(), CVCL::Theorem::isRewrite(), mergeLabels(), and CVCL::TESTER.

void TheoryDatatype::checkSat bool  fullEffort  )  [virtual]
 

Check for satisfiability in the theory.

Parameters:
fullEffort when it is false, checkSat can do as much or as little work as it likes, though simple inferences and checks for consistency should be done to increase efficiency. If fullEffort is true, checkSat must check whether the set of facts given by assertFact together with the arrangement of shared terms (provided by addSharedTerm) induced by the global find database equivalence relation are satisfiable. If satisfiable, checkSat does nothing.
If satisfiability can be acheived by merging some of the shared terms, a new fact must be enqueued using enqueueFact (this fact need not be a literal). If there is no way to make things satisfiable, setInconsistent must be called.

Implements CVCL::Theory.

Reimplemented in CVCL::TheoryDatatypeLazy.

Definition at line 226 of file theory_datatype.cpp.

References CVCL::Theory::addSplitter(), CVCL::ExprMap< Data >::begin(), d_datatypes, d_labels, d_smartSplits, d_splitterAsserted, d_splitters, d_splittersIndex, datatypeTestExpr(), CVCL::ExprMap< Data >::end(), CVCL::CDMap< Key, Data, HashFcn >::end(), CVCL::ExprMap< Data >::find(), CVCL::CDMap< Key, Data, HashFcn >::find(), CVCL::Theory::findExpr(), getConsPos(), CVCL::Type::getExpr(), CVCL::Expr::getOpExpr(), getSelectorInfo(), CVCL::Expr::getType(), CVCL::Expr::isFinite(), CVCL::isSelector(), CVCL::CDList< T >::size(), CVCL::Expr::toString(), and CVCL::Type::toString().

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

Theory-specific rewrite rules.

By default, rewrite just returns a reflexive theorem stating that the input expression is equivalent to itself. However, rewrite is allowed to return any theorem which describes how the input expression is equivalent to some new expression. rewrite should be used to perform simplifications, normalization, and any other preprocessing on theory-specific expressions that needs to be done.

Reimplemented from CVCL::Theory.

Definition at line 284 of file theory_datatype.cpp.

References canCollapse(), d_facts, d_rules, CVCL::Theorem::getRHS(), CVCL::isConstructor(), CVCL::isSelector(), CVCL::isTester(), CVCL::Theory::reflexivityRule(), CVCL::DatatypeProofRules::rewriteSelCons(), CVCL::DatatypeProofRules::rewriteTestCons(), CVCL::Theory::simplify(), and CVCL::Theory::transitivityRule().

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

Reimplemented in CVCL::TheoryDatatypeLazy.

Definition at line 303 of file theory_datatype.cpp.

References CVCL::Expr::addToNotify(), CVCL::APPLY, CVCL::Expr::arity(), d_labels, d_rules, d_smartSplits, d_splitters, CVCL::DATATYPE, CVCL::CDMap< Key, Data, HashFcn >::end(), CVCL::Theory::enqueueFact(), CVCL::CDMap< Key, Data, HashFcn >::find(), CVCL::Type::getExpr(), CVCL::Expr::getKind(), CVCL::Expr::getType(), initializeLabels(), CVCL::isConstructor(), CVCL::isSelector(), mergeLabels(), CVCL::DatatypeProofRules::noCycle(), CVCL::CDList< T >::push_back(), CVCL::Expr::setSelected(), and CVCL::Theory::setupCC().

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

Reimplemented in CVCL::TheoryDatatypeLazy.

Definition at line 323 of file theory_datatype.cpp.

References CVCL::Expr::addToNotify(), CVCL::Expr::arity(), canCollapse(), d_facts, d_rules, CVCL::DatatypeProofRules::decompose(), CVCL::Theory::enqueueFact(), CVCL::Theorem::getLHS(), CVCL::Expr::getOpExpr(), CVCL::Expr::getRep(), CVCL::Theorem::getRHS(), CVCL::Expr::getSig(), CVCL::Expr::isApply(), CVCL::isConstructor(), CVCL::Theorem::isNull(), CVCL::Expr::isNull(), CVCL::Expr::isSelected(), CVCL::isSelector(), CVCL::isTester(), mergeLabels(), CVCL::CDList< T >::push_back(), CVCL::DatatypeProofRules::rewriteSelCons(), CVCL::DatatypeProofRules::rewriteTestCons(), CVCL::Expr::setRep(), CVCL::Expr::setSelected(), CVCL::Expr::setSig(), CVCL::Theory::symmetryRule(), CVCL::Theory::transitivityRule(), and CVCL::Theory::updateHelper().

Theorem TheoryDatatype::solve const Theorem e  )  [virtual]
 

An optional solver.

The solve method can be used to implement a Shostak-style solver. Since solvers do not in general combine, the following technique is used. One theory is designated as the primary solver (in our case, it is the theory of arithmetic). For each equation that enters the core framework, the primary solver is called to ensure that the equation is in solved form with respect to the primary theory.

After the primary solver, the solver for the theory associated with the equation is called. This solver can do whatever it likes, as long as the result is still in solved form with respect to the primary solver. This is a slight generalization of what is described in my (Clark)'s PhD thesis.

Reimplemented from CVCL::Theory.

Definition at line 381 of file theory_datatype.cpp.

References CVCL::Theorem::getLHS(), CVCL::Theorem::getRHS(), CVCL::isConstructor(), CVCL::Theorem::isRewrite(), CVCL::Expr::isTerm(), and CVCL::Theory::symmetryRule().

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

Check that e is a valid Type expr.

Reimplemented from CVCL::Theory.

Definition at line 392 of file theory_datatype.cpp.

References CVCL::Expr::arity(), CVCL::CONSTRUCTOR, CVCL::DATATYPE, CVCL::Theory::getEM(), CVCL::Expr::getKind(), CVCL::Expr::isString(), CVCL::Theory::resolveID(), CVCL::SELECTOR, CVCL::TESTER, and CVCL::Expr::toString().

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

Compute and store the type of e.

Parameters:
e is the expression whose type is computed.
This function computes the type of the top-level operator of e, and recurses into children using getType(), if necessary.

Reimplemented from CVCL::Theory.

Definition at line 413 of file theory_datatype.cpp.

References CVCL::Expr::arity(), CVCL::ARROW, CVCL::Expr::begin(), CVCL::CONSTRUCTOR, CVCL::DATATYPE, CVCL::Expr::end(), CVCL::Theory::getBaseType(), CVCL::Type::getExpr(), CVCL::Op::getExpr(), CVCL::Expr::getKind(), CVCL::Expr::getOp(), CVCL::Expr::getOpKind(), CVCL::Expr::isApply(), CVCL::Type::isNull(), CVCL::Expr::lookupType(), CVCL::SELECTOR, CVCL::Expr::setType(), CVCL::TESTER, and CVCL::Expr::toString().

void TheoryDatatype::computeModelTerm const Expr e,
std::vector< Expr > &  v
[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 CVCL::Theory.

Definition at line 460 of file theory_datatype.cpp.

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

Compute and cache the TCC of e.

Parameters:
e is an expression (term or formula). This function computes the TCC of e which is true iff the expression is defined.
This function computes the TCC or predicate of the top-level operator of e, and recurses into children using getTCC(), if necessary.

The default implementation is to compute TCCs recursively for all children, and return their conjunction.

Reimplemented from CVCL::Theory.

Definition at line 465 of file theory_datatype.cpp.

References CVCL::Expr::andExpr(), CVCL::APPLY, CVCL::Theory::computeTCC(), CVCL::CONSTRUCTOR, datatypeTestExpr(), CVCL::Expr::getKind(), getSelectorInfo(), CVCL::SELECTOR, and CVCL::Theory::trueExpr().

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

Theory-specific parsing implemented by the DP.

Reimplemented from CVCL::Theory.

Definition at line 543 of file theory_datatype.cpp.

References CVCL::Expr::arity(), CVCL::ExprMap< Data >::count(), dataType(), CVCL::DATATYPE, CVCL::Theory::getEM(), CVCL::ExprManager::getKind(), CVCL::Expr::getKind(), CVCL::Expr::getString(), CVCL::ID, CVCL::ExprMap< Data >::insert(), CVCL::Theory::parseExpr(), CVCL::RAW_LIST, and CVCL::Expr::toString().

ExprStream & TheoryDatatype::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 CVCL::Theory.

Definition at line 492 of file theory_datatype.cpp.

References CVCL::APPLY, CVCL::Expr::arity(), CVCL::Expr::begin(), CVCL::CONSTRUCTOR, CVCL::DATATYPE, CVCL::Expr::end(), CVCL::Theory::getEM(), CVCL::Expr::getKind(), CVCL::Expr::getName(), CVCL::Expr::getOpExpr(), CVCL::Expr::getString(), CVCL::Expr::isString(), CVCL::Expr::isSymbol(), CVCL::ExprStream::lang(), CVCL::LISP_LANG, CVCL::PRESENTATION_LANG, CVCL::Expr::printAST(), CVCL::push(), CVCL::SELECTOR, CVCL::SMTLIB_LANG, CVCL::space(), and CVCL::TESTER.

Type CVCL::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
 

Referenced by parseExprOp().

void CVCL::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,
std::vector< Type > &  returnTypes
 

Expr CVCL::TheoryDatatype::datatypeConsExpr const std::string &  constructor,
const std::vector< Expr > &  args
 

Expr CVCL::TheoryDatatype::datatypeSelExpr const std::string &  selector,
const Expr arg
 

Expr CVCL::TheoryDatatype::datatypeTestExpr const std::string &  constructor,
const Expr arg
 

Referenced by CVCL::TheoryDatatypeLazy::checkSat(), checkSat(), and computeTCC().

const pair< Expr, unsigned > & TheoryDatatype::getSelectorInfo const Expr e  ) 
 

Definition at line 915 of file theory_datatype.cpp.

References d_selectorMap, CVCL::ExprMap< Data >::end(), CVCL::ExprMap< Data >::find(), CVCL::Expr::getKind(), CVCL::SELECTOR, and CVCL::Expr::toString().

Referenced by canCollapse(), checkSat(), computeTCC(), and CVCL::DatatypeTheoremProducer::rewriteSelCons().

Expr TheoryDatatype::getConsForTester const Expr e  ) 
 

Definition at line 925 of file theory_datatype.cpp.

References d_testerMap, CVCL::ExprMap< Data >::end(), CVCL::ExprMap< Data >::find(), CVCL::Expr::getKind(), CVCL::TESTER, and CVCL::Expr::toString().

Referenced by assertFact(), and CVCL::DatatypeTheoremProducer::rewriteTestCons().

unsigned TheoryDatatype::getConsPos const Expr e  ) 
 

Definition at line 936 of file theory_datatype.cpp.

References CVCL::Type::arity(), CVCL::CONSTRUCTOR, d_datatypes, CVCL::ExprMap< Data >::end(), CVCL::ExprMap< Data >::find(), CVCL::Type::getExpr(), CVCL::Expr::getKind(), CVCL::Expr::getType(), CVCL::isDatatype(), CVCL::Type::isFunction(), CVCL::Expr::toString(), and CVCL::Type::toString().

Referenced by assertFact(), canCollapse(), and checkSat().

Expr TheoryDatatype::getConstant const Type t  ) 
 

Definition at line 952 of file theory_datatype.cpp.

References CVCL::Expr::arity(), CVCL::ExprMap< Data >::begin(), d_datatypes, CVCL::ExprMap< Data >::end(), CVCL::ExprMap< Data >::find(), CVCL::Type::getExpr(), CVCL::Expr::getType(), CVCL::Type::isBool(), CVCL::isDatatype(), CVCL::Type::isFunction(), CVCL::Expr::isNull(), CVCL::Expr::isWellFounded(), CVCL::Expr::mkOp(), CVCL::Theory::newVar(), CVCL::Theory::resolveID(), CVCL::Type::toString(), and CVCL::Expr::toString().

Referenced by CVCL::DatatypeTheoremProducer::rewriteSelCons().

const Op & TheoryDatatype::getReachablePredicate const Type t  ) 
 

Definition at line 990 of file theory_datatype.cpp.

References d_reach, CVCL::ExprMap< Data >::end(), CVCL::ExprMap< Data >::find(), CVCL::Type::getExpr(), and CVCL::isDatatype().

Referenced by CVCL::DatatypeTheoremProducer::noCycle().

bool TheoryDatatype::canCollapse const Expr e  ) 
 

Definition at line 999 of file theory_datatype.cpp.

References CVCL::Expr::arity(), d_labels, CVCL::CDMap< Key, Data, HashFcn >::end(), CVCL::CDMap< Key, Data, HashFcn >::find(), CVCL::Theory::findExpr(), getConsPos(), CVCL::Expr::getOpExpr(), getSelectorInfo(), CVCL::isConstructor(), and CVCL::isSelector().

Referenced by rewrite(), CVCL::DatatypeTheoremProducer::rewriteSelCons(), CVCL::TheoryDatatypeLazy::update(), and update().


Member Data Documentation

DatatypeProofRules* CVCL::TheoryDatatype::d_rules [protected]
 

Definition at line 61 of file theory_datatype.h.

Referenced by CVCL::TheoryDatatypeLazy::instantiate(), instantiate(), CVCL::TheoryDatatypeLazy::mergeLabels(), mergeLabels(), rewrite(), CVCL::TheoryDatatypeLazy::setup(), setup(), TheoryDatatype(), CVCL::TheoryDatatypeLazy::update(), update(), and ~TheoryDatatype().

ExprMap<ExprMap<unsigned> > CVCL::TheoryDatatype::d_datatypes [protected]
 

Definition at line 63 of file theory_datatype.h.

Referenced by CVCL::TheoryDatatypeLazy::checkSat(), checkSat(), getConsPos(), getConstant(), CVCL::TheoryDatatypeLazy::initializeLabels(), initializeLabels(), CVCL::TheoryDatatypeLazy::instantiate(), and instantiate().

ExprMap<std::pair<Expr,unsigned> > CVCL::TheoryDatatype::d_selectorMap [protected]
 

Definition at line 64 of file theory_datatype.h.

Referenced by getSelectorInfo().

ExprMap<Expr> CVCL::TheoryDatatype::d_testerMap [protected]
 

Definition at line 65 of file theory_datatype.h.

Referenced by getConsForTester().

ExprMap<Op> CVCL::TheoryDatatype::d_reach [protected]
 

Definition at line 66 of file theory_datatype.h.

Referenced by getReachablePredicate().

CDMap<Expr, SmartCDO<bigunsigned> > CVCL::TheoryDatatype::d_labels [protected]
 

Definition at line 69 of file theory_datatype.h.

Referenced by addSharedTerm(), canCollapse(), CVCL::TheoryDatatypeLazy::checkSat(), checkSat(), CVCL::TheoryDatatypeLazy::initializeLabels(), initializeLabels(), CVCL::TheoryDatatypeLazy::mergeLabels(), mergeLabels(), CVCL::TheoryDatatypeLazy::setup(), and setup().

CDList<Theorem> CVCL::TheoryDatatype::d_facts [protected]
 

Definition at line 71 of file theory_datatype.h.

Referenced by CVCL::TheoryDatatypeLazy::checkSat(), CVCL::TheoryDatatypeLazy::instantiate(), instantiate(), CVCL::TheoryDatatypeLazy::mergeLabels(), mergeLabels(), rewrite(), CVCL::TheoryDatatypeLazy::update(), and update().

CDList<Expr> CVCL::TheoryDatatype::d_splitters [protected]
 

Definition at line 72 of file theory_datatype.h.

Referenced by CVCL::TheoryDatatypeLazy::checkSat(), checkSat(), CVCL::TheoryDatatypeLazy::initializeLabels(), initializeLabels(), and setup().

CDO<unsigned> CVCL::TheoryDatatype::d_splittersIndex [protected]
 

Definition at line 73 of file theory_datatype.h.

Referenced by CVCL::TheoryDatatypeLazy::checkSat(), and checkSat().

CDO<bool> CVCL::TheoryDatatype::d_splitterAsserted [protected]
 

Definition at line 74 of file theory_datatype.h.

Referenced by CVCL::TheoryDatatypeLazy::checkSat(), and checkSat().

const bool& CVCL::TheoryDatatype::d_smartSplits [protected]
 

Definition at line 75 of file theory_datatype.h.

Referenced by checkSat(), initializeLabels(), and setup().


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