CVC3

dpllt_basic.h

Go to the documentation of this file.
00001 /*****************************************************************************/
00002 /*!
00003  *\file dpllt_basic.h
00004  *\brief Basic implementation of dpllt module
00005  *
00006  * Author: Clark Barrett
00007  *
00008  * Created: Mon Dec 12 19:06:58 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 #ifndef _cvc3__sat__dpllt_basic_h_
00022 #define _cvc3__sat__dpllt_basic_h_
00023 
00024 #include "dpllt.h"
00025 #include "sat_api.h"
00026 #include "cdo.h"
00027 #include "proof.h" 
00028 #include "cnf_manager.h"
00029  
00030 namespace SAT {
00031 
00032 class DPLLTBasic :public DPLLT {
00033 
00034   CVC3::ContextManager* d_cm;
00035 
00036   bool d_ready;
00037   SatSolver* d_mng;
00038   CNF_Formula_Impl* d_cnf;
00039   CD_CNF_Formula* d_assertions;
00040 
00041   std::vector<SatSolver*> d_mngStack;
00042   std::vector<CNF_Formula_Impl*> d_cnfStack;
00043   std::vector<CD_CNF_Formula*> d_assertionsStack;
00044   bool d_printStats;
00045 
00046   CVC3::CDO<unsigned> d_pushLevel;
00047   CVC3::CDO<bool> d_readyPrev;  
00048   CVC3::CDO<unsigned> d_prevStackSize;
00049   CVC3::CDO<unsigned> d_prevAStackSize;
00050 
00051   void createManager();
00052   void generate_CDB (CNF_Formula_Impl& cnf);
00053   void handle_result(SatSolver::SATStatus outcome);
00054   void verify_solution();
00055 
00056 public:
00057   DPLLTBasic(TheoryAPI* theoryAPI, Decider* decider, CVC3::ContextManager* cm,
00058        bool printStats = false);
00059   virtual ~DPLLTBasic();
00060 
00061   void addNewClause(const Clause& c);
00062   void addNewClauses(CNF_Formula_Impl& cnf);
00063 
00064   SatSolver::Lit cvc2SAT(Lit l)
00065   { return l.isNull() ? SatSolver::Lit() :
00066       d_mng->MakeLit(d_mng->GetVar(l.getVar()), l.isPositive() ? 0 : 1); }
00067 
00068   Lit SAT2cvc(SatSolver::Lit l)
00069   { return l.IsNull() ? Lit() :
00070                         Lit(d_mng->GetVarIndex(d_mng->GetVarFromLit(l)),
00071                             d_mng->GetPhaseFromLit(l) == 0); }
00072 
00073   SatSolver* satSolver() { return d_mng; }
00074 
00075   // Implementation of virtual DPLLT methods
00076 
00077   void push();
00078   void pop();
00079   void addAssertion(const CNF_Formula& cnf);
00080   virtual std::vector<SAT::Lit> getCurAssignments() ;
00081   virtual std::vector<std::vector<SAT::Lit> > getCurClauses();
00082 
00083   CVC3::QueryResult checkSat(const CNF_Formula& cnf);
00084   CVC3::QueryResult continueCheck(const CNF_Formula& cnf);
00085   Var::Val getValue(Var v) { return Var::Val(d_mng->GetVarAssignment(d_mng->GetVar(v))); }
00086   
00087   CVC3::Proof getSatProof(CNF_Manager*, CVC3::TheoryCore*);
00088 
00089 };
00090 
00091 }
00092 
00093 #endif