CVC3

theory_uf.h

Go to the documentation of this file.
00001 /*****************************************************************************/
00002 /*!
00003  * \file theory_uf.h
00004  * 
00005  * Author: Clark Barrett
00006  * 
00007  * Created: Fri Jan 17 18:25:40 2003
00008  *
00009  * <hr>
00010  *
00011  * License to use, copy, modify, sell and/or distribute this software
00012  * and its documentation for any purpose is hereby granted without
00013  * royalty, subject to the terms and conditions defined in the \ref
00014  * LICENSE file provided with this distribution.
00015  * 
00016  * <hr>
00017  * 
00018  */
00019 /*****************************************************************************/
00020 
00021 #ifndef _cvc3__include__theory_uf_h_
00022 #define _cvc3__include__theory_uf_h_
00023 
00024 #include "theory.h"
00025 #include "cdmap.h"
00026 
00027 namespace CVC3 {
00028 
00029 class UFProofRules;
00030 
00031   //! Local kinds for transitive closure of binary relations
00032  typedef enum {
00033    TRANS_CLOSURE = 500,
00034    OLD_ARROW // for backward compatibility with old function declarations
00035  } UFKinds;
00036 
00037 /*****************************************************************************/
00038 /*!
00039  *\class TheoryUF
00040  *\ingroup Theories
00041  *\brief This theory handles uninterpreted functions.
00042  *
00043  * Author: Clark Barrett
00044  *
00045  * Created: Sat Feb  8 14:51:19 2003
00046  */
00047 /*****************************************************************************/
00048 class TheoryUF :public Theory {
00049   UFProofRules* d_rules;  
00050   //! Flag to include function applications to the concrete model
00051   const bool& d_applicationsInModel;
00052 
00053   // For computing transitive closure of binary relations
00054   typedef struct TCMapPair {
00055     ExprMap<CDList<Theorem>*> appearsFirstMap;
00056     ExprMap<CDList<Theorem>*> appearsSecondMap;
00057   } TCMapPair;
00058 
00059   ExprMap<TCMapPair*> d_transClosureMap;
00060 
00061   //! Backtracking list of function applications
00062   /*! Used for building concrete models and beta-reducing
00063    *  lambda-expressions. */
00064   CDList<Expr> d_funApplications;
00065   //! Pointer to the last unprocessed element (for lambda expansions)
00066   CDO<size_t> d_funApplicationsIdx;
00067   //! The pointers to the last unprocessed shared pair
00068   CDO<size_t> d_sharedIdx1, d_sharedIdx2;
00069   //! The set of all shared terms
00070   CDMap<Expr, bool> d_sharedTermsMap;
00071 
00072 public:
00073   TheoryUF(TheoryCore* core);
00074   ~TheoryUF();
00075 
00076   // Trusted method that creates the proof rules class (used in constructor).
00077   // Implemented in uf_theorem_producer.cpp
00078   UFProofRules* createProofRules();
00079 
00080   // Theory interface
00081   void addSharedTerm(const Expr& e);
00082   void assertFact(const Theorem& e);
00083   void checkSat(bool fullEffort);
00084   Theorem rewrite(const Expr& e);
00085   void setup(const Expr& e);
00086   void update(const Theorem& e, const Expr& d);
00087   void checkType(const Expr& e);
00088   Cardinality finiteTypeInfo(Expr& e, Unsigned& n,
00089                              bool enumerate, bool computeSize);
00090   void computeType(const Expr& e);
00091   Type computeBaseType(const Type& t);
00092   void computeModelTerm(const Expr& e, std::vector<Expr>& v);
00093   void computeModel(const Expr& e, std::vector<Expr>& vars);
00094   Expr computeTCC(const Expr& e);
00095   virtual Expr parseExprOp(const Expr& e);
00096   ExprStream& print(ExprStream& os, const Expr& e);
00097 
00098   //! Create a new LAMBDA-abstraction
00099   Expr lambdaExpr(const std::vector<Expr>& vars, const Expr& body);
00100   //! Create a transitive closure expression
00101   Expr transClosureExpr(const std::string& name,
00102       const Expr& e1, const Expr& e2);
00103 private:
00104   void printSmtLibShared(ExprStream& os, const Expr& e);
00105 };
00106 
00107 }
00108 
00109 #endif