CVC3  2.4.1
Public Member Functions | Private Member Functions | Private Attributes
CVC3::TheorySimulate Class Reference

"Theory" of symbolic simulation. More...

#include <theory_simulate.h>

Inheritance diagram for CVC3::TheorySimulate:
CVC3::Theory

List of all members.

Public Member Functions

 TheorySimulate (TheoryCore *core)
 Constructor.
 ~TheorySimulate ()
 Destructor.
void assertFact (const Theorem &e)
 Assert a new fact to the decision procedure.
void checkSat (bool fullEffort)
 Check for satisfiability in the theory.
Theorem rewrite (const Expr &e)
 Theory-specific rewrite rules.
void computeType (const Expr &e)
 Compute and store the type of e.
Expr computeTCC (const Expr &e)
 Compute and cache the TCC of e.
Expr parseExprOp (const Expr &e)
 Theory-specific parsing implemented by the DP.
ExprStreamprint (ExprStream &os, const Expr &e)
 Theory-specific pretty-printing.
- Public Member Functions inherited from CVC3::Theory
 Theory (TheoryCore *theoryCore, const std::string &name)
 Whether theory has been used (for smtlib translator)
virtual ~Theory (void)
 Destructor.
ExprManagergetEM ()
 Access to ExprManager.
TheoryCoretheoryCore ()
 Get a pointer to theoryCore.
CommonProofRulesgetCommonRules ()
 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 void addSharedTerm (const Expr &e)
 Notify theory of a new shared term.
virtual Theorem theoryPreprocess (const Expr &e)
 Theory-specific preprocessing.
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.
virtual Theorem solve (const Theorem &e)
 An optional solver.
virtual void checkAssertEqInvariant (const Theorem &e)
 A debug check used by the primary solver.
virtual Theorem simplifyOp (const Expr &e)
 Recursive simplification step.
virtual void checkType (const Expr &e)
 Check that e is a valid Type expr.
virtual Cardinality finiteTypeInfo (Expr &e, Unsigned &n, bool enumerate, bool computeSize)
 Compute information related to finiteness of types.
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 computeModelTerm (const Expr &e, std::vector< Expr > &v)
 Add variables from 'e' to 'v' for constructing a concrete model.
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.
TheorytheoryOf (int kind)
 Return the theory associated with a kind.
TheorytheoryOf (const Type &e)
 Return the theory associated with a type.
TheorytheoryOf (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 TheoremfindRef (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 ExprfalseExpr ()
 Return FALSE Expr.
const ExprtrueExpr ()
 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.

Private Member Functions

SimulateProofRulescreateProofRules ()
 Create proof rules for this theory.

Private Attributes

SimulateProofRulesd_rules
 Our local proof rules.

Additional Inherited Members

- Protected Attributes inherited from CVC3::Theory
bool d_theoryUsed

Detailed Description

"Theory" of symbolic simulation.

Author: Sergey Berezin

Created: Tue Oct 7 10:13:15 2003

This theory owns the SIMULATE operator. It's job is to replace the above expressions by their definitions using rewrite rules.

Definition at line 46 of file theory_simulate.h.


Constructor & Destructor Documentation

TheorySimulate::TheorySimulate ( TheoryCore core)

Constructor.

Definition at line 35 of file theory_simulate.cpp.

References createProofRules(), d_rules, CVC3::Theory::registerTheory(), and SIMULATE.

TheorySimulate::~TheorySimulate ( )

Destructor.

Definition at line 47 of file theory_simulate.cpp.

References d_rules.


Member Function Documentation

SimulateProofRules * TheorySimulate::createProofRules ( )
private

Create proof rules for this theory.

Definition at line 38 of file simulate_theorem_producer.cpp.

Referenced by TheorySimulate().

void CVC3::TheorySimulate::assertFact ( const Theorem e)
inlinevirtual

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 58 of file theory_simulate.h.

void CVC3::TheorySimulate::checkSat ( bool  fullEffort)
inlinevirtual

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.

Implements CVC3::Theory.

Definition at line 59 of file theory_simulate.h.

Theorem TheorySimulate::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 53 of file theory_simulate.cpp.

References d_rules, CVC3::SimulateProofRules::expandSimulate(), CVC3::Expr::getKind(), CVC3::Theory::reflexivityRule(), and SIMULATE.

void TheorySimulate::computeType ( const Expr e)
virtual

Compute and store the type of e.

Parameters:
eis 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 65 of file theory_simulate.cpp.

References CVC3::Type::arity(), CVC3::Expr::arity(), DebugAssert, CVC3::Type::funType(), CVC3::Theory::getBaseType(), CVC3::Expr::getKind(), CVC3::int2string(), CVC3::Type::isFunction(), CVC3::isRational(), CVC3::isReal(), CVC3::Expr::setType(), SIMULATE, CVC3::Type::toString(), and CVC3::Expr::toString().

Expr TheorySimulate::computeTCC ( const Expr e)
virtual

Compute and cache the TCC of e.

Parameters:
eis 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 164 of file theory_simulate.cpp.

References CVC3::andExpr(), CVC3::Type::arity(), CVC3::Expr::arity(), DebugAssert, CVC3::ExprManager::falseExpr(), CVC3::Theory::getEM(), CVC3::Expr::getKind(), CVC3::Expr::getRational(), CVC3::Theorem::getRHS(), CVC3::Theory::getTypePred(), CVC3::Type::isFunction(), CVC3::Theory::rewriteAnd(), SIMULATE, CVC3::Expr::toString(), and CVC3::ExprManager::trueExpr().

Expr TheorySimulate::parseExprOp ( const Expr e)
virtual
ExprStream & TheorySimulate::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 215 of file theory_simulate.cpp.

References CVC3::Expr::arity(), CVC3::Theory::d_theoryUsed, CVC3::Expr::getKind(), CVC3::ExprStream::lang(), CVC3::LISP_LANG, CVC3::pop(), CVC3::PRESENTATION_LANG, CVC3::Expr::printAST(), CVC3::push(), SIMULATE, CVC3::SMTLIB_LANG, CVC3::SMTLIB_V2_LANG, and CVC3::space().


Member Data Documentation

SimulateProofRules* CVC3::TheorySimulate::d_rules
private

Our local proof rules.

Definition at line 49 of file theory_simulate.h.

Referenced by rewrite(), TheorySimulate(), and ~TheorySimulate().


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