00001 #ifndef SVC_API_impl_h
00002 #define SVC_API_impl_h
00003
00004 #include "SVC_API.h"
00005 #include "Atomifier.h"
00006 #include "CNF_Converter.h"
00007 #include "SAT_API.h"
00008 #include "compat_hash_map.h"
00009
00010 namespace CVCL {
00011
00012
00013
00014
00015
00016
00017
00018 class SVC_API_impl : public SVC_API {
00019 protected:
00020 Expr_Manager *_pem;
00021 Prop_Var_Manager* _ppvm;
00022 std::hash_map<int, std::vector<Expr>*> *_pfanout_table;
00023 std::vector<Expr> _vecMap;
00024 std::vector<Expr> _connectQueue;
00025 std::vector<Expr> _conditions;
00026 std::vector<int> _conditionVars;
00027 std::vector<int> _conditionIndex;
00028 std::vector<Expr> _assumptionStack;
00029 std::vector<int> _assumptionIndex;
00030 int _verbosity;
00031
00032 PAtomifier _patomifier;
00033 CNF_Formula_For_Exprs *_cnfFormula;
00034 CNF_Converter *_cnfConverter;
00035 PSAT_API _psatapi;
00036 bool _ready;
00037
00038 class varinfo {
00039 public:
00040 int kind;
00041 std::vector<int> fanins;
00042 std::vector<int> fanouts;
00043 int value;
00044 int next;
00045 int prev;
00046 varinfo() : kind(-1), value(-1), next(0), prev(0) {}
00047 };
00048
00049 std::vector<varinfo> _vars;
00050 int _splitterCacheTag;
00051 int _splitterCacheTag2;
00052
00053 bool AddConditions(long lVar);
00054 void UpdateValue(long v, int value);
00055 bool FindSplitterRec(long v, int value, long *pv);
00056 bool GetImplicationsRec(long v, long *pv, int *pvalue);
00057 bool IsStable() { return _nonassertable_facts->Done(); }
00058
00059 public:
00060 SVC_API_impl(Expr_Manager *pem);
00061 ~SVC_API_impl();
00062 bool CheckSat(const Expr &e);
00063
00064 void Push();
00065 void Pop();
00066 bool SVCAssert(long lVar);
00067 bool SVCDeny(long lVar);
00068 bool GetConfClause(std::vector<int>* literals);
00069 bool IsConsistent();
00070
00071 bool HasSVCExpr(long lVar);
00072 bool OKToSplit(long lVar);
00073 void ResetVariable(long v);
00074
00075 void Connect(const Expr& e, long v);
00076 void Connect1(const Expr& eFrom, const Expr& eTo);
00077
00078 bool FindSplitter(long *v);
00079 void GetImplications(long *pv, int *pvalue);
00080
00081 void SetVerbosity(int i) { _verbosity = i; _patomifier->SetVerbosity(i); }
00082 int Verbosity() { return _verbosity; }
00083 void PrintVar(long lVar);
00084 void PrintWithType(const Expr& e);
00085 void Reset(void);
00086 bool Ready(void);
00087
00088 PSAT_API SatAPI() { return _psatapi; }
00089 std::vector<Expr>& VecMap() { return _vecMap; }
00090 };
00091
00092 }
00093
00094 #endif