translator.h

Go to the documentation of this file.
00001 /*****************************************************************************/
00002 /*!
00003  * \file translator.h
00004  * \brief An exception to be thrown by the smtlib translator.
00005  * 
00006  * Author: Clark Barrett
00007  * 
00008  * Created: Sat Jun 25 18:03:09 2005
00009  *
00010  * <hr>
00011  *
00012  * License to use, copy, modify, sell and/or distribute this software
00013  * and its documentation for any purpose is hereby granted without
00014  * royalty, subject to the terms and conditions defined in the \ref
00015  * LICENSE file provided with this distribution.
00016  * 
00017  * <hr>
00018  * 
00019  */
00020 /*****************************************************************************/
00021 
00022 #ifndef _cvc3__translator_h_
00023 #define _cvc3__translator_h_
00024 
00025 #include <string>
00026 #include <fstream>
00027 #include <vector>
00028 #include "queryresult.h"
00029 
00030 namespace CVC3 {
00031 
00032 class Expr;
00033 class Type;
00034 class ExprManager;
00035 class ExprStream;
00036 class TheoryCore;
00037 class TheoryUF;
00038 class TheoryArith;
00039 class TheoryArray;
00040 class TheoryQuant;
00041 class TheoryRecords;
00042 class TheorySimulate;
00043 class TheoryBitvector;
00044 class TheoryDatatype;
00045 template <class Data> class ExprMap;
00046 
00047 //! Used to keep track of which subset of arith is being used
00048 typedef enum {
00049   NOT_USED = 0,
00050   TERMS_ONLY,
00051   DIFF_ONLY,
00052   LINEAR,
00053   NONLINEAR
00054 } ArithLang;
00055 
00056 //All the translation code should go here
00057 class Translator {
00058   ExprManager* d_em;
00059   const bool& d_translate;
00060   const bool& d_real2int;
00061   const bool& d_convertArith;
00062   const std::string& d_convertToDiff;
00063   bool d_iteLiftArith;
00064   const std::string& d_expResult;
00065   const std::string& d_category;
00066   bool d_convertArray;
00067   bool d_combineAssump;
00068 
00069   //! The log file for top-level API calls in the CVC3 input language
00070   std::ostream* d_osdump;
00071   std::ofstream d_osdumpFile;
00072   std::ifstream d_tmpFile;
00073   bool d_dump, d_dumpFileOpen;
00074 
00075   bool d_intIntArray, d_intRealArray, d_intIntRealArray, d_ax, d_unknown;
00076   bool d_realUsed;
00077   bool d_intUsed;
00078   bool d_intConstUsed;
00079   ArithLang d_langUsed;
00080   bool d_UFIDL_ok;
00081   bool d_arithUsed;
00082 
00083   Expr* d_zeroVar;
00084 
00085   TheoryCore* d_theoryCore;
00086   TheoryUF* d_theoryUF;
00087   TheoryArith* d_theoryArith;
00088   TheoryArray* d_theoryArray;
00089   TheoryQuant* d_theoryQuant;
00090   TheoryRecords* d_theoryRecords;
00091   TheorySimulate* d_theorySimulate;
00092   TheoryBitvector* d_theoryBitvector;
00093   TheoryDatatype* d_theoryDatatype;
00094 
00095   std::vector<Expr> d_dumpExprs;
00096 
00097   std::string fileToSMTLIBIdentifier(const std::string& filename);
00098   Expr preprocessRec(const Expr& e, ExprMap<Expr>& cache);
00099   Expr preprocess(const Expr& e, ExprMap<Expr>& cache);
00100   Expr preprocess2Rec(const Expr& e, ExprMap<Expr>& cache, Type desiredType);
00101   Expr preprocess2(const Expr& e, ExprMap<Expr>& cache);
00102   bool containsArray(const Expr& e);
00103   Expr processType(const Expr& e);
00104 
00105 public:
00106   // Constructors
00107   Translator(ExprManager* em,
00108              const bool& translate,
00109              const bool& real2int,
00110              const bool& convertArith,
00111              const std::string& convertToDiff,
00112              bool iteLiftArith,
00113              const std::string& expResult,
00114              const std::string& category,
00115              bool convertArray,
00116              bool combineAssump);
00117 
00118   bool start(const std::string& dumpFile);
00119   void dump(const Expr& e, bool dumpOnly = false);
00120   bool dumpAssertion(const Expr& e);
00121   bool dumpQuery(const Expr& e);
00122   void dumpQueryResult(QueryResult qres);
00123   void finish();
00124 
00125   void setTheoryCore(TheoryCore* theoryCore) { d_theoryCore = theoryCore; }
00126   void setTheoryUF(TheoryUF* theoryUF) { d_theoryUF = theoryUF; }
00127   void setTheoryArith(TheoryArith* theoryArith) { d_theoryArith = theoryArith; }
00128   void setTheoryArray(TheoryArray* theoryArray) { d_theoryArray = theoryArray; }
00129   void setTheoryQuant(TheoryQuant* theoryQuant) { d_theoryQuant = theoryQuant; }
00130   void setTheoryRecords(TheoryRecords* theoryRecords) { d_theoryRecords = theoryRecords; }
00131   void setTheorySimulate(TheorySimulate* theorySimulate) { d_theorySimulate = theorySimulate; }
00132   void setTheoryBitvector(TheoryBitvector* theoryBitvector) { d_theoryBitvector = theoryBitvector; }
00133   void setTheoryDatatype(TheoryDatatype* theoryDatatype) { d_theoryDatatype = theoryDatatype; }
00134 
00135   const std::string fixConstName(const std::string& s);
00136   //! Returns true if expression has been printed
00137   /*! If false is returned, array theory should print expression as usual */
00138   bool printArrayExpr(ExprStream& os, const Expr& e);
00139 
00140   Expr zeroVar();
00141 
00142   // Destructor
00143   virtual ~Translator() { }
00144 
00145 }; // end of class Translator
00146 
00147 } // end of namespace CVC3 
00148 
00149 #endif

Generated on Tue Jul 3 14:33:42 2007 for CVC3 by  doxygen 1.5.1