solver/ConflictDatabase.h
00001 /*
00002  * ConflictDatabase.h
00003  *
00004  *  Created on: Jan 26, 2010
00005  *      Author: isil
00006  */
00007 
00008 #ifndef CONFLICTDATABASE_H_
00009 #define CONFLICTDATABASE_H_
00010 #include <set>
00011 #include <map>
00012 #include <unordered_set>
00013 using namespace std;
00014 
00015 class CNode;
00016 class Leaf;
00017 struct DBLeaf;
00018 struct DBClause;
00019 
00020 struct DBLeaf
00021 {
00022         Leaf* l;
00023         set<DBClause*> conflict_clauses; // the set of all conflict clauses in
00024                                                                         // which this leaf appears
00025 
00026         DBLeaf(Leaf* l, DBClause* cl);
00027 };
00028 
00029 struct DBClause
00030 {
00031         CNode* conflict_clause;
00032         set<CNode*> leaves; // the set of all leaves in this clause
00033 
00034         DBClause(CNode* cl, set<CNode*>& l);
00035 };
00036 
00037 class ConflictDatabase
00038 {
00039 private:
00040         static map<Leaf*, DBLeaf*> db_leaves;
00041         static set<CNode*> conflict_clauses;
00042 
00043 public:
00044         ConflictDatabase();
00045         /*
00046          * Adds a conflict clause to the library
00047          */
00048         static void add_conflict_clause(CNode* conflict_clause);
00049 
00050         /*
00051          * Gives the set of all conflict clauses relevant to the formula
00052          * currently being solved/simplified.
00053          */
00054         static void get_conflict_clauses(CNode* formula,
00055                         set<CNode*>& conflict_clauses);
00056 
00057         static void clear();
00058 
00059         static void print_conflict_clauses();
00060 
00061         ~ConflictDatabase();
00062 };
00063 
00064 
00065 #endif /* CONFLICTDATABASE_H_ */