00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 #include "minisat_types.h"
00024 
00025 using namespace std;
00026 
00027 namespace MiniSat {
00028 
00029   
00030   Clause* Clause::s_decision = NULL;
00031   Clause* Clause::s_theoryImplication = NULL;
00032 
00033   Clause* Clause_new(const vector<Lit>& ps, int id) {
00034     DebugAssert(sizeof(Lit)   == sizeof(uint), "MiniSat::Types::Clause_new Lit");
00035     DebugAssert(sizeof(float) == sizeof(uint), "MiniSat::Types::Clause_new float");
00036     DebugAssert(sizeof(id)    == sizeof(uint), "MiniSat::Types::Clause_new id");
00037 
00038     
00039     
00040     
00041     void* mem = xmalloc<char>(sizeof(uint)*(ps.size() + 2));
00042     return new (mem) Clause(false, ps, id);
00043   }
00044 
00045   Clause* Lemma_new(const vector<Lit>& ps, int id, int pushID) {
00046     DebugAssert(sizeof(Lit)      == sizeof(uint), "MiniSat::Types::Lemma_new Lit");
00047     DebugAssert(sizeof(float)    == sizeof(uint), "MiniSat::Types::Lemma_new float");
00048     DebugAssert(sizeof(id)       == sizeof(uint), "MiniSat::Types::Lemma_new id");
00049 
00050     
00051     
00052     
00053     
00054     
00055     void* mem = xmalloc<char>(sizeof(uint)*(ps.size() + 4));
00056     Clause* clause = new (mem) Clause(true, ps, id);
00057     clause->pushID() = pushID;
00058     return clause;
00059   }
00060 
00061   Clause* Clause::Decision() {
00062     if (s_decision == NULL) {
00063       vector<Lit> lits;
00064       s_decision = Clause_new(lits, -1);
00065     }
00066     
00067     return s_decision;
00068   }
00069   
00070   Clause* Clause::TheoryImplication() {
00071     if (s_theoryImplication == NULL) {
00072       vector<Lit> lits;
00073       s_theoryImplication = Clause_new(lits, -2);
00074     }
00075     
00076     return s_theoryImplication;
00077   }
00078 
00079   void Clause::toLit(vector<Lit>& literals) const {
00080     for (int i = 0; i < size(); ++i) {
00081       literals.push_back(data[i]);
00082     }
00083   }
00084 
00085 }