ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
lratchecker.hpp
Go to the documentation of this file.
1#ifndef _lratchecker_hpp_INCLUDED
2#define _lratchecker_hpp_INCLUDED
3
4#include "global.h"
5
6/*------------------------------------------------------------------------*/
7#include <unordered_map>
8
10
11namespace CaDiCaL {
12
13/*------------------------------------------------------------------------*/
14
15// This checker implements an LRUP checker.
16// It requires LRAT-style proof chains for each learned clause
17//
18// Most of the infrastructure is taken from checker, but without the
19// propagation
20
21/*------------------------------------------------------------------------*/
22
24 LratCheckerClause *next; // collision chain link for hash table
25 uint64_t hash; // previously computed full 64-bit hash
26 int64_t id; // id of clause
27 bool garbage; // for garbage clauses
28 unsigned size;
29 bool used;
31 int literals[1]; // 'literals' of length 'size'
32};
33
34/*------------------------------------------------------------------------*/
35
36class LratChecker : public StatTracer {
37
38 Internal *internal;
39
40 // Capacity of variable values.
41 //
42 int64_t size_vars;
43
44 // The 'watchers' and 'marks' data structures are not that time critical
45 // and thus we access them by first mapping a literal to 'unsigned'.
46 //
47 static unsigned l2u (int lit);
48
49 signed char &checked_lit (int lit);
50 signed char &mark (int lit);
51
52 vector<signed char> checked_lits;
53 vector<signed char> marks; // mark bits of literals
54 unordered_map<int64_t, vector<int>> clauses_to_reconstruct;
55 vector<int> assumptions;
56 vector<int> constraint;
57 bool concluded;
58
59 uint64_t num_clauses; // number of clauses in hash table
60 uint64_t num_finalized;
61 uint64_t num_garbage; // number of garbage clauses
62 uint64_t size_clauses; // size of clause hash table
63 LratCheckerClause **clauses; // hash table of clauses
64 LratCheckerClause *garbage; // linked list of garbage clauses
65
66 vector<int> imported_clause; // original clause for reporting
67 vector<int64_t> assumption_clauses;
68
69 void enlarge_vars (int64_t idx);
70 void import_literal (int lit);
71 void import_clause (const vector<int> &);
72
73 static const unsigned num_nonces = 4;
74
75 uint64_t nonces[num_nonces]; // random numbers for hashing
76 uint64_t last_hash; // last computed hash value of clause
77 int64_t last_id; // id of the last added/deleted clause
78 int64_t current_id; // id of the last added clause
79 uint64_t compute_hash (int64_t); // compute and save hash value of clause
80
81 // Reduce hash value to the actual size.
82 //
83 static uint64_t reduce_hash (uint64_t hash, uint64_t size);
84
85 void enlarge_clauses (); // enlarge hash table for clauses
86 void insert (); // insert clause in hash table
88 find (const int64_t); // find clause position in hash table
89
90 void add_clause (const char *type);
91
92 void collect_garbage_clauses ();
93
94 LratCheckerClause *new_clause ();
95 void delete_clause (LratCheckerClause *);
96
97 bool check (vector<int64_t>); // check RUP
98 bool check_resolution (vector<int64_t>); // check resolution
99 bool check_blocked (vector<int64_t>); // check ER
100
101 struct {
102
103 int64_t added; // number of added clauses
104 int64_t original; // number of added original clauses
105 int64_t derived; // number of added derived clauses
106
107 int64_t deleted; // number of deleted clauses
108 int64_t finalized; // number of finalized clauses
109
110 int64_t insertions; // number of clauses added to hash table
111 int64_t collisions; // number of hash collisions in 'find'
112 int64_t searches; // number of searched clauses in 'find'
113
114 int64_t checks; // number of implication checks
115
116 int64_t collections; // garbage collections
117
118 } stats;
119
120public:
122 virtual ~LratChecker ();
123
124 void connect_internal (Internal *i) override;
125 void begin_proof (int64_t) override;
126
127 void add_original_clause (int64_t, bool, const vector<int> &,
128 bool restore) override;
129 void restore_clause (int64_t, const vector<int> &);
130
131 // check the proof chain for the new clause and add it to the checker
132 void add_derived_clause (int64_t, bool, const vector<int> &,
133 const vector<int64_t> &) override;
134
135 // check if the clause is present and delete it from the checker
136 void delete_clause (int64_t, bool, const vector<int> &) override;
137 // check if the clause is present and delete it from the checker
138 void weaken_minus (int64_t, const vector<int> &) override;
139
140 // check if the clause is present and delete it from the checker
141 void finalize_clause (int64_t, const vector<int> &) override;
142
143 // check the proof chain of the assumption clause and delete it
144 // immediately also check that they contain only assumptions and
145 // constraints
146 void add_assumption_clause (int64_t, const vector<int> &,
147 const vector<int64_t> &) override;
148
149 // mark lit as assumption
150 void add_assumption (int) override;
151
152 // mark lits as constraint
153 void add_constraint (const vector<int> &) override;
154
155 void reset_assumptions () override;
156
157 // check if all clauses have been deleted
158 void report_status (int, int64_t) override;
159
160 void conclude_unsat (ConclusionType, const vector<int64_t> &) override;
161
162 void print_stats () override;
163 void dump (); // for debugging purposes only
164};
165
166} // namespace CaDiCaL
167
169
170#endif
#define ABC_NAMESPACE_CXX_HEADER_START
#define ABC_NAMESPACE_CXX_HEADER_END
void report_status(int, int64_t) override
void add_constraint(const vector< int > &) override
void begin_proof(int64_t) override
void weaken_minus(int64_t, const vector< int > &) override
void conclude_unsat(ConclusionType, const vector< int64_t > &) override
void reset_assumptions() override
void print_stats() override
void add_derived_clause(int64_t, bool, const vector< int > &, const vector< int64_t > &) override
void add_assumption_clause(int64_t, const vector< int > &, const vector< int64_t > &) override
void restore_clause(int64_t, const vector< int > &)
void add_original_clause(int64_t, bool, const vector< int > &, bool restore) override
void connect_internal(Internal *i) override
void add_assumption(int) override
void finalize_clause(int64_t, const vector< int > &) override
type
CUBE COVER and CUBE typedefs ///.
Definition exor.h:90
ConclusionType
Definition tracer.hpp:15
int lit
Definition satVec.h:130
LratCheckerClause * next
signed char mark
Definition value.h:8