ilang  1.1.4
ILAng: A Modeling and Verification Platform for SoCs
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros
inv_cnf.h
1 // Hongce Zhang
4 
5 #ifndef INV_CNF_H__
6 #define INV_CNF_H__
7 
8 #include <ilang/config.h>
9 #ifdef INVSYN_INTERFACE
10 
11 #include <set>
12 #include <string>
13 #include <tuple>
14 #include <unordered_map>
15 #include <vector>
16 
17 namespace ilang {
18 
20 class InvariantInCnf {
21 public:
22  // Type definitions
24  typedef std::tuple<bool, std::string, unsigned> literal;
26  typedef std::vector<literal> clause;
28  typedef std::unordered_map<std::string, clause> cnf_t;
29 
30  // helper functions
32  static std::string Lit2Str(const literal& l);
34  static void CanonicalizeClause(clause& c);
36  static std::string Clause2Str(const clause& c);
38  static void VarsToClause(const std::set<std::string>& vars, clause& out);
39 
40 public:
42  void ExportInCnfFormat(std::ostream& os) const;
44  void ExportInCociFormat(std::ostream& os) const;
46  void ImportFromFile(std::istream& os);
47 
48 public:
49  // members function : insert clause
51  void InsertClause(clause& c);
52 
53  // insert clause (from another clause, so no need to reorder)
54  void InsertClauseNoReorder(const clause& c);
55 
56  // members function : insert clause if it does not exist before
58  void InsertClauseNewerFromReference(clause& c, const InvariantInCnf& ref);
59 
60  // members function : insert the incremental clauses
62  void InsertClauseIncremental(const InvariantInCnf& ref);
63 
65  const cnf_t& GetCnfs() const { return _cnf_; }
67  void Clear();
68 
69 protected:
70  // members
72  cnf_t _cnf_;
73 
74 }; // class InvariantInCnf
75 
76 }; // namespace ilang
77 
78 #endif // INVSYN_INTERFACE
79 
80 #endif // INV_CNF_H__