CVC3::TheoryDatatype Class Reference
[Theories]

This theory handles datatypes. More...

#include <theory_datatype.h>

Inheritance diagram for CVC3::TheoryDatatype:

Inheritance graph
[legend]
Collaboration diagram for CVC3::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 51 of file theory_datatype.h.


Member Typedef Documentation

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

Definition at line 60 of file theory_datatype.h.


Constructor & Destructor Documentation

TheoryDatatype::TheoryDatatype ( TheoryCore theoryCore  ) 

Definition at line 41 of file theory_datatype.cpp.

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

TheoryDatatype::~TheoryDatatype (  )  [virtual]

Definition at line 68 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 73 of file theory_datatype.cpp.

References CVC3::Type::arity(), d_datatypes, d_facts, d_rules, DebugAssert, CVC3::DatatypeProofRules::dummyTheorem(), CVC3::Theory::enqueueFact(), CVC3::Expr::eqExpr(), CVC3::EXISTS, 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::Expr::toString(), and CVC3::Type::toString().

Referenced by initializeLabels(), and mergeLabels().

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

Reimplemented in CVC3::TheoryDatatypeLazy.

Definition at line 110 of file theory_datatype.cpp.

References d_datatypes, d_labels, d_smartSplits, d_splitters, DebugAssert, CVC3::Theory::findExpr(), CVC3::getConstructor(), CVC3::Type::getExpr(), instantiate(), CVC3::isConstructor(), CVC3::Expr::isFinite(), CVC3::Theory::theoryCore(), and CVC3::Expr::toString().

Referenced by addSharedTerm(), and setup().

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

Reimplemented in CVC3::TheoryDatatypeLazy.

Definition at line 143 of file theory_datatype.cpp.

References d_facts, d_labels, d_rules, DebugAssert, CVC3::DatatypeProofRules::dummyTheorem(), CVC3::Theory::falseExpr(), CVC3::Theory::findExpr(), CVC3::Theory::getBaseType(), CVC3::Expr::hasFind(), instantiate(), CVC3::Theorem::isNull(), and CVC3::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 CVC3::TheoryDatatypeLazy.

Definition at line 166 of file theory_datatype.cpp.

References d_facts, d_labels, d_rules, DebugAssert, CVC3::DatatypeProofRules::dummyTheorem(), CVC3::Theory::falseExpr(), CVC3::Theory::findExpr(), CVC3::Expr::hasFind(), instantiate(), and CVC3::Theory::setInconsistent().

DatatypeProofRules * TheoryDatatype::createProofRules (  ) 

Definition at line 42 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 CVC3::Theory.

Definition at line 190 of file theory_datatype.cpp.

References CVC3::Expr::addToNotify(), d_labels, CVC3::DATATYPE, CVC3::Theory::getBaseType(), 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 CVC3::Theory.

Definition at line 200 of file theory_datatype.cpp.

References getConsForTester(), getConsPos(), CVC3::Theorem::getExpr(), CVC3::Theorem::isRewrite(), mergeLabels(), and CVC3::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 CVC3::Theory.

Reimplemented in CVC3::TheoryDatatypeLazy.

Definition at line 218 of file theory_datatype.cpp.

References CVC3::Theory::addSplitter(), d_datatypes, d_facts, d_labels, d_rules, d_smartSplits, d_splitterAsserted, d_splitters, d_splittersIndex, datatypeTestExpr(), DebugAssert, CVC3::DatatypeProofRules::dummyTheorem(), CVC3::Theory::enqueueFact(), CVC3::Theory::findExpr(), CVC3::Theory::getBaseType(), getConsPos(), CVC3::Type::getExpr(), getSelectorInfo(), CVC3::isSelector(), CVC3::OR, and CVC3::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 CVC3::Theory.

Definition at line 278 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().

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 CVC3::Theory.

Reimplemented in CVC3::TheoryDatatypeLazy.

Definition at line 297 of file theory_datatype.cpp.

References CVC3::Expr::addToNotify(), CVC3::APPLY, d_labels, d_rules, d_smartSplits, d_splitters, CVC3::DATATYPE, CVC3::Theory::enqueueFact(), CVC3::Theory::getBaseType(), CVC3::Expr::getKind(), initializeLabels(), CVC3::isConstructor(), CVC3::isSelector(), mergeLabels(), CVC3::DatatypeProofRules::noCycle(), and CVC3::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 CVC3::Theory.

Reimplemented in CVC3::TheoryDatatypeLazy.

Definition at line 317 of file theory_datatype.cpp.

References CVC3::Expr::arity(), canCollapse(), d_facts, d_rules, CVC3::DatatypeProofRules::decompose(), CVC3::Theory::enqueueFact(), CVC3::Theorem::getLHS(), CVC3::Expr::getOpExpr(), CVC3::Expr::getRep(), CVC3::Theorem::getRHS(), CVC3::Expr::getSig(), CVC3::Expr::isApply(), CVC3::isConstructor(), CVC3::Theorem::isNull(), CVC3::Expr::isNull(), CVC3::Expr::isSelected(), CVC3::isSelector(), CVC3::isTester(), mergeLabels(), 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().

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 CVC3::Theory.

Definition at line 375 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().

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

Check that e is a valid Type expr.

Reimplemented from CVC3::Theory.

Definition at line 386 of file theory_datatype.cpp.

References CVC3::Expr::arity(), CVC3::CONSTRUCTOR, CVC3::DATATYPE, DebugAssert, CVC3::Theory::getEM(), CVC3::Expr::getKind(), CVC3::Expr::isString(), CVC3::Theory::resolveID(), CVC3::SELECTOR, CVC3::TESTER, and CVC3::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 CVC3::Theory.

Definition at line 407 of file theory_datatype.cpp.

References CVC3::Expr::arity(), CVC3::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::Expr::lookupType(), CVC3::SELECTOR, CVC3::Expr::setType(), CVC3::TESTER, and CVC3::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 CVC3::Theory.

Definition at line 452 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 CVC3::Theory.

Definition at line 457 of file theory_datatype.cpp.

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

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

Theory-specific parsing implemented by the DP.

Reimplemented from CVC3::Theory.

Definition at line 535 of file theory_datatype.cpp.

References CVC3::Expr::arity(), CVC3::ExprMap< Data >::count(), dataType(), CVC3::DATATYPE, DebugAssert, CVC3::Theory::getEM(), CVC3::ExprManager::getKind(), CVC3::Expr::getKind(), CVC3::Expr::getString(), CVC3::ID, CVC3::ExprMap< Data >::insert(), CVC3::Theory::parseExpr(), CVC3::RAW_LIST, and CVC3::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 CVC3::Theory.

Definition at line 484 of file theory_datatype.cpp.

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

Type 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 647 of file theory_datatype.cpp.

Referenced by CVC3::VCL::dataType(), and parseExprOp().

void 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 
)

Definition at line 668 of file theory_datatype.cpp.

References CVC3::Type::anyType(), CVC3::Theory::boolType(), CVC3::CONSTRUCTOR, d_datatypes, d_reach, d_selectorMap, d_testerMap, CVC3::DATATYPE, CVC3::Type::funType(), CVC3::Theory::getBaseType(), CVC3::Theory::getEM(), CVC3::Type::getExpr(), CVC3::Op::getExpr(), CVC3::Expr::getName(), CVC3::Theory::installID(), CVC3::Type::isBool(), CVC3::isDatatype(), CVC3::Type::isFunction(), CVC3::Type::isNull(), CVC3::Expr::isNull(), CVC3::Theory::newFunction(), CVC3::ExprManager::newSymbolExpr(), CVC3::Theory::resolveID(), CVC3::SELECTOR, 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 869 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().

Referenced by CVC3::VCL::datatypeConsExpr().

Expr TheoryDatatype::datatypeSelExpr ( const std::string &  selector,
const Expr arg 
)

Definition at line 883 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().

Referenced by CVC3::VCL::datatypeSelExpr().

Expr TheoryDatatype::datatypeTestExpr ( const std::string &  constructor,
const Expr arg 
)

Definition at line 895 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 CVC3::TheoryDatatypeLazy::checkSat(), checkSat(), computeTCC(), and CVC3::VCL::datatypeTestExpr().

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

Definition at line 907 of file theory_datatype.cpp.

References d_selectorMap, DebugAssert, CVC3::Expr::getKind(), CVC3::SELECTOR, and CVC3::Expr::toString().

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

Expr TheoryDatatype::getConsForTester ( const Expr e  ) 

Definition at line 917 of file theory_datatype.cpp.

References d_testerMap, DebugAssert, CVC3::Expr::getKind(), CVC3::TESTER, and CVC3::Expr::toString().

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

unsigned TheoryDatatype::getConsPos ( const Expr e  ) 

Definition at line 928 of file theory_datatype.cpp.

References CVC3::CONSTRUCTOR, d_datatypes, DebugAssert, CVC3::Theory::getBaseType(), CVC3::Expr::getKind(), CVC3::isDatatype(), and CVC3::Expr::toString().

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

Expr TheoryDatatype::getConstant ( const Type t  ) 

Definition at line 944 of file theory_datatype.cpp.

References CVC3::Expr::arity(), CVC3::ExprMap< Data >::begin(), d_datatypes, DebugAssert, FatalAssert, CVC3::Theory::getBaseType(), CVC3::Type::getExpr(), CVC3::Type::isBool(), CVC3::isDatatype(), CVC3::Type::isFunction(), CVC3::Expr::isNull(), CVC3::Theory::newVar(), CVC3::Theory::resolveID(), CVC3::Type::toString(), and CVC3::Expr::toString().

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

const Op & TheoryDatatype::getReachablePredicate ( const Type t  ) 

Definition at line 982 of file theory_datatype.cpp.

References d_reach, DebugAssert, CVC3::Type::getExpr(), and CVC3::isDatatype().

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

bool TheoryDatatype::canCollapse ( const Expr e  ) 

Definition at line 991 of file theory_datatype.cpp.

References CVC3::Expr::arity(), d_labels, DebugAssert, CVC3::Theory::findExpr(), getConsPos(), getSelectorInfo(), CVC3::isConstructor(), and CVC3::isSelector().

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


Member Data Documentation

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

Definition at line 53 of file theory_datatype.h.

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

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

Definition at line 55 of file theory_datatype.h.

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

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

Definition at line 56 of file theory_datatype.h.

Referenced by dataType(), and getSelectorInfo().

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

Definition at line 57 of file theory_datatype.h.

Referenced by dataType(), and getConsForTester().

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

Definition at line 58 of file theory_datatype.h.

Referenced by dataType(), and getReachablePredicate().

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

Definition at line 61 of file theory_datatype.h.

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

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

Definition at line 63 of file theory_datatype.h.

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

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

Definition at line 64 of file theory_datatype.h.

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

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

Definition at line 65 of file theory_datatype.h.

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

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

Definition at line 66 of file theory_datatype.h.

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

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

Definition at line 67 of file theory_datatype.h.

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


The documentation for this class was generated from the following files:
Generated on Tue Jul 3 14:39:02 2007 for CVC3 by  doxygen 1.5.1