cadical 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE.txt +26 -0
- data/README.md +101 -0
- data/ext/cadical/cadical/LICENSE +28 -0
- data/ext/cadical/cadical/README.md +65 -0
- data/ext/cadical/cadical/VERSION +1 -0
- data/ext/cadical/cadical/src/analyze.cpp +1360 -0
- data/ext/cadical/cadical/src/arena.cpp +30 -0
- data/ext/cadical/cadical/src/arena.hpp +105 -0
- data/ext/cadical/cadical/src/assume.cpp +616 -0
- data/ext/cadical/cadical/src/averages.cpp +34 -0
- data/ext/cadical/cadical/src/averages.hpp +37 -0
- data/ext/cadical/cadical/src/backbone.cpp +631 -0
- data/ext/cadical/cadical/src/backtrack.cpp +177 -0
- data/ext/cadical/cadical/src/backward.cpp +231 -0
- data/ext/cadical/cadical/src/bins.cpp +22 -0
- data/ext/cadical/cadical/src/bins.hpp +22 -0
- data/ext/cadical/cadical/src/block.cpp +824 -0
- data/ext/cadical/cadical/src/block.hpp +37 -0
- data/ext/cadical/cadical/src/cadical.cpp +1026 -0
- data/ext/cadical/cadical/src/cadical.hpp +1419 -0
- data/ext/cadical/cadical/src/ccadical.cpp +208 -0
- data/ext/cadical/cadical/src/ccadical.h +74 -0
- data/ext/cadical/cadical/src/checker.cpp +649 -0
- data/ext/cadical/cadical/src/checker.hpp +173 -0
- data/ext/cadical/cadical/src/clause.cpp +689 -0
- data/ext/cadical/cadical/src/clause.hpp +190 -0
- data/ext/cadical/cadical/src/collect.cpp +545 -0
- data/ext/cadical/cadical/src/compact.cpp +550 -0
- data/ext/cadical/cadical/src/condition.cpp +940 -0
- data/ext/cadical/cadical/src/config.cpp +101 -0
- data/ext/cadical/cadical/src/config.hpp +20 -0
- data/ext/cadical/cadical/src/congruence.cpp +7880 -0
- data/ext/cadical/cadical/src/congruence.hpp +757 -0
- data/ext/cadical/cadical/src/constrain.cpp +64 -0
- data/ext/cadical/cadical/src/contract.cpp +27 -0
- data/ext/cadical/cadical/src/contract.hpp +139 -0
- data/ext/cadical/cadical/src/cover.cpp +704 -0
- data/ext/cadical/cadical/src/cover.hpp +34 -0
- data/ext/cadical/cadical/src/decide.cpp +347 -0
- data/ext/cadical/cadical/src/decompose.cpp +738 -0
- data/ext/cadical/cadical/src/decompose.hpp +23 -0
- data/ext/cadical/cadical/src/deduplicate.cpp +275 -0
- data/ext/cadical/cadical/src/definition.cpp +283 -0
- data/ext/cadical/cadical/src/delay.hpp +38 -0
- data/ext/cadical/cadical/src/drattracer.cpp +153 -0
- data/ext/cadical/cadical/src/drattracer.hpp +55 -0
- data/ext/cadical/cadical/src/elim.cpp +1171 -0
- data/ext/cadical/cadical/src/elim.hpp +53 -0
- data/ext/cadical/cadical/src/elimfast.cpp +570 -0
- data/ext/cadical/cadical/src/ema.cpp +95 -0
- data/ext/cadical/cadical/src/ema.hpp +68 -0
- data/ext/cadical/cadical/src/extend.cpp +289 -0
- data/ext/cadical/cadical/src/external.cpp +1034 -0
- data/ext/cadical/cadical/src/external.hpp +487 -0
- data/ext/cadical/cadical/src/external_propagate.cpp +1316 -0
- data/ext/cadical/cadical/src/factor.cpp +1011 -0
- data/ext/cadical/cadical/src/factor.hpp +54 -0
- data/ext/cadical/cadical/src/file.cpp +506 -0
- data/ext/cadical/cadical/src/file.hpp +210 -0
- data/ext/cadical/cadical/src/flags.cpp +135 -0
- data/ext/cadical/cadical/src/flags.hpp +93 -0
- data/ext/cadical/cadical/src/flip.cpp +269 -0
- data/ext/cadical/cadical/src/format.cpp +89 -0
- data/ext/cadical/cadical/src/format.hpp +36 -0
- data/ext/cadical/cadical/src/frattracer.cpp +277 -0
- data/ext/cadical/cadical/src/frattracer.hpp +67 -0
- data/ext/cadical/cadical/src/gates.cpp +766 -0
- data/ext/cadical/cadical/src/heap.hpp +212 -0
- data/ext/cadical/cadical/src/idruptracer.cpp +566 -0
- data/ext/cadical/cadical/src/idruptracer.hpp +112 -0
- data/ext/cadical/cadical/src/instantiate.cpp +365 -0
- data/ext/cadical/cadical/src/instantiate.hpp +45 -0
- data/ext/cadical/cadical/src/internal.cpp +1265 -0
- data/ext/cadical/cadical/src/internal.hpp +1941 -0
- data/ext/cadical/cadical/src/inttypes.hpp +34 -0
- data/ext/cadical/cadical/src/ipasir.cpp +47 -0
- data/ext/cadical/cadical/src/ipasir.h +37 -0
- data/ext/cadical/cadical/src/kitten.c +2599 -0
- data/ext/cadical/cadical/src/kitten.h +97 -0
- data/ext/cadical/cadical/src/level.hpp +33 -0
- data/ext/cadical/cadical/src/lidruptracer.cpp +657 -0
- data/ext/cadical/cadical/src/lidruptracer.hpp +122 -0
- data/ext/cadical/cadical/src/limit.cpp +146 -0
- data/ext/cadical/cadical/src/limit.hpp +168 -0
- data/ext/cadical/cadical/src/logging.cpp +214 -0
- data/ext/cadical/cadical/src/logging.hpp +98 -0
- data/ext/cadical/cadical/src/lookahead.cpp +520 -0
- data/ext/cadical/cadical/src/lratchecker.cpp +833 -0
- data/ext/cadical/cadical/src/lratchecker.hpp +168 -0
- data/ext/cadical/cadical/src/lrattracer.cpp +200 -0
- data/ext/cadical/cadical/src/lrattracer.hpp +61 -0
- data/ext/cadical/cadical/src/lucky.cpp +506 -0
- data/ext/cadical/cadical/src/message.cpp +218 -0
- data/ext/cadical/cadical/src/message.hpp +65 -0
- data/ext/cadical/cadical/src/minimize.cpp +224 -0
- data/ext/cadical/cadical/src/mobical.cpp +5588 -0
- data/ext/cadical/cadical/src/occs.cpp +52 -0
- data/ext/cadical/cadical/src/occs.hpp +36 -0
- data/ext/cadical/cadical/src/options.cpp +359 -0
- data/ext/cadical/cadical/src/options.hpp +442 -0
- data/ext/cadical/cadical/src/parse.cpp +471 -0
- data/ext/cadical/cadical/src/parse.hpp +75 -0
- data/ext/cadical/cadical/src/phases.cpp +56 -0
- data/ext/cadical/cadical/src/phases.hpp +19 -0
- data/ext/cadical/cadical/src/probe.cpp +990 -0
- data/ext/cadical/cadical/src/profile.cpp +107 -0
- data/ext/cadical/cadical/src/profile.hpp +283 -0
- data/ext/cadical/cadical/src/proof.cpp +691 -0
- data/ext/cadical/cadical/src/proof.hpp +125 -0
- data/ext/cadical/cadical/src/propagate.cpp +584 -0
- data/ext/cadical/cadical/src/queue.cpp +90 -0
- data/ext/cadical/cadical/src/queue.hpp +74 -0
- data/ext/cadical/cadical/src/radix.hpp +180 -0
- data/ext/cadical/cadical/src/random.cpp +207 -0
- data/ext/cadical/cadical/src/random.h +44 -0
- data/ext/cadical/cadical/src/random.hpp +98 -0
- data/ext/cadical/cadical/src/range.hpp +125 -0
- data/ext/cadical/cadical/src/reap.cpp +127 -0
- data/ext/cadical/cadical/src/reap.hpp +28 -0
- data/ext/cadical/cadical/src/reduce.cpp +278 -0
- data/ext/cadical/cadical/src/reluctant.hpp +82 -0
- data/ext/cadical/cadical/src/rephase.cpp +402 -0
- data/ext/cadical/cadical/src/report.cpp +313 -0
- data/ext/cadical/cadical/src/resources.cpp +160 -0
- data/ext/cadical/cadical/src/resources.hpp +16 -0
- data/ext/cadical/cadical/src/restart.cpp +178 -0
- data/ext/cadical/cadical/src/restore.cpp +267 -0
- data/ext/cadical/cadical/src/score.cpp +51 -0
- data/ext/cadical/cadical/src/score.hpp +16 -0
- data/ext/cadical/cadical/src/shrink.cpp +507 -0
- data/ext/cadical/cadical/src/signal.cpp +136 -0
- data/ext/cadical/cadical/src/signal.hpp +33 -0
- data/ext/cadical/cadical/src/solution.cpp +50 -0
- data/ext/cadical/cadical/src/solver.cpp +1871 -0
- data/ext/cadical/cadical/src/stable.cpp +31 -0
- data/ext/cadical/cadical/src/stack.h +110 -0
- data/ext/cadical/cadical/src/stats.cpp +920 -0
- data/ext/cadical/cadical/src/stats.hpp +418 -0
- data/ext/cadical/cadical/src/subsume.cpp +645 -0
- data/ext/cadical/cadical/src/sweep.cpp +1960 -0
- data/ext/cadical/cadical/src/sweep.hpp +61 -0
- data/ext/cadical/cadical/src/terminal.cpp +38 -0
- data/ext/cadical/cadical/src/terminal.hpp +96 -0
- data/ext/cadical/cadical/src/ternary.cpp +450 -0
- data/ext/cadical/cadical/src/testing.hpp +24 -0
- data/ext/cadical/cadical/src/tier.cpp +189 -0
- data/ext/cadical/cadical/src/tracer.hpp +186 -0
- data/ext/cadical/cadical/src/transred.cpp +253 -0
- data/ext/cadical/cadical/src/unstable.cpp +29 -0
- data/ext/cadical/cadical/src/util.cpp +129 -0
- data/ext/cadical/cadical/src/util.hpp +181 -0
- data/ext/cadical/cadical/src/var.cpp +39 -0
- data/ext/cadical/cadical/src/var.hpp +22 -0
- data/ext/cadical/cadical/src/veripbtracer.cpp +427 -0
- data/ext/cadical/cadical/src/veripbtracer.hpp +106 -0
- data/ext/cadical/cadical/src/version.cpp +107 -0
- data/ext/cadical/cadical/src/version.hpp +13 -0
- data/ext/cadical/cadical/src/vivify.cpp +1893 -0
- data/ext/cadical/cadical/src/vivify.hpp +50 -0
- data/ext/cadical/cadical/src/walk.cpp +1088 -0
- data/ext/cadical/cadical/src/walk.hpp +91 -0
- data/ext/cadical/cadical/src/walk_full_occs.cpp +966 -0
- data/ext/cadical/cadical/src/warmup.cpp +403 -0
- data/ext/cadical/cadical/src/watch.cpp +126 -0
- data/ext/cadical/cadical/src/watch.hpp +77 -0
- data/ext/cadical/cadical_ext.c +778 -0
- data/ext/cadical/extconf.rb +26 -0
- data/lib/cadical/version.rb +3 -0
- data/lib/cadical.rb +12 -0
- metadata +218 -0
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
#include "internal.hpp"
|
|
2
|
+
|
|
3
|
+
namespace CaDiCaL {
|
|
4
|
+
|
|
5
|
+
/*------------------------------------------------------------------------*/
|
|
6
|
+
|
|
7
|
+
VeripbTracer::VeripbTracer (Internal *i, File *f, bool b, bool a, bool c)
|
|
8
|
+
: internal (i), file (f), with_antecedents (a), checked_deletions (c),
|
|
9
|
+
num_clauses (0), size_clauses (0), clauses (0), last_hash (0),
|
|
10
|
+
last_id (0), last_clause (0)
|
|
11
|
+
#ifndef QUIET
|
|
12
|
+
,
|
|
13
|
+
added (0), deleted (0)
|
|
14
|
+
#endif
|
|
15
|
+
{
|
|
16
|
+
(void) internal;
|
|
17
|
+
|
|
18
|
+
// Initialize random number table for hash function.
|
|
19
|
+
//
|
|
20
|
+
Random random (42);
|
|
21
|
+
for (unsigned n = 0; n < num_nonces; n++) {
|
|
22
|
+
uint64_t nonce = random.next ();
|
|
23
|
+
if (!(nonce & 1))
|
|
24
|
+
nonce++;
|
|
25
|
+
assert (nonce), assert (nonce & 1);
|
|
26
|
+
nonces[n] = nonce;
|
|
27
|
+
}
|
|
28
|
+
#ifndef NDEBUG
|
|
29
|
+
binary = b;
|
|
30
|
+
#else
|
|
31
|
+
(void) b;
|
|
32
|
+
#endif
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
void VeripbTracer::connect_internal (Internal *i) {
|
|
36
|
+
internal = i;
|
|
37
|
+
file->connect_internal (internal);
|
|
38
|
+
LOG ("VERIPB TRACER connected to internal");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
VeripbTracer::~VeripbTracer () {
|
|
42
|
+
LOG ("VERIPB TRACER delete");
|
|
43
|
+
delete file;
|
|
44
|
+
for (size_t i = 0; i < size_clauses; i++)
|
|
45
|
+
for (HashId *c = clauses[i], *next; c; c = next)
|
|
46
|
+
next = c->next, delete_clause (c);
|
|
47
|
+
delete[] clauses;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/*------------------------------------------------------------------------*/
|
|
51
|
+
|
|
52
|
+
void VeripbTracer::enlarge_clauses () {
|
|
53
|
+
assert (num_clauses == size_clauses);
|
|
54
|
+
const uint64_t new_size_clauses = size_clauses ? 2 * size_clauses : 1;
|
|
55
|
+
LOG ("VeriPB Tracer enlarging clauses from %" PRIu64 " to %" PRIu64,
|
|
56
|
+
(uint64_t) size_clauses, (uint64_t) new_size_clauses);
|
|
57
|
+
HashId **new_clauses;
|
|
58
|
+
new_clauses = new HashId *[new_size_clauses];
|
|
59
|
+
clear_n (new_clauses, new_size_clauses);
|
|
60
|
+
for (uint64_t i = 0; i < size_clauses; i++) {
|
|
61
|
+
for (HashId *c = clauses[i], *next; c; c = next) {
|
|
62
|
+
next = c->next;
|
|
63
|
+
const uint64_t h = reduce_hash (c->hash, new_size_clauses);
|
|
64
|
+
c->next = new_clauses[h];
|
|
65
|
+
new_clauses[h] = c;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
delete[] clauses;
|
|
69
|
+
clauses = new_clauses;
|
|
70
|
+
size_clauses = new_size_clauses;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
HashId *VeripbTracer::new_clause () {
|
|
74
|
+
HashId *res = new HashId ();
|
|
75
|
+
res->next = 0;
|
|
76
|
+
res->hash = last_hash;
|
|
77
|
+
res->id = last_id;
|
|
78
|
+
last_clause = res;
|
|
79
|
+
num_clauses++;
|
|
80
|
+
return res;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
void VeripbTracer::delete_clause (HashId *c) {
|
|
84
|
+
assert (c);
|
|
85
|
+
num_clauses--;
|
|
86
|
+
delete c;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
uint64_t VeripbTracer::reduce_hash (uint64_t hash, uint64_t size) {
|
|
90
|
+
assert (size > 0);
|
|
91
|
+
unsigned shift = 32;
|
|
92
|
+
uint64_t res = hash;
|
|
93
|
+
while ((((uint64_t) 1) << shift) > size) {
|
|
94
|
+
res ^= res >> shift;
|
|
95
|
+
shift >>= 1;
|
|
96
|
+
}
|
|
97
|
+
res &= size - 1;
|
|
98
|
+
assert (res < size);
|
|
99
|
+
return res;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
uint64_t VeripbTracer::compute_hash (const int64_t id) {
|
|
103
|
+
assert (id > 0);
|
|
104
|
+
unsigned j = id % num_nonces; // Dont know if this is a good
|
|
105
|
+
uint64_t tmp = nonces[j] * (uint64_t) id; // hash funktion or even better
|
|
106
|
+
return last_hash = tmp; // than just using id.
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
bool VeripbTracer::find_and_delete (const int64_t id) {
|
|
110
|
+
if (!num_clauses)
|
|
111
|
+
return false;
|
|
112
|
+
/*
|
|
113
|
+
if (last_clause && last_clause->id == id) {
|
|
114
|
+
const uint64_t h = reduce_hash (last_clause->hash, size_clauses);
|
|
115
|
+
clauses[h] = last_clause->next;
|
|
116
|
+
delete last_clause;
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
*/
|
|
120
|
+
HashId **res = 0, *c;
|
|
121
|
+
const uint64_t hash = compute_hash (id);
|
|
122
|
+
const uint64_t h = reduce_hash (hash, size_clauses);
|
|
123
|
+
for (res = clauses + h; (c = *res); res = &c->next) {
|
|
124
|
+
if (c->hash == hash && c->id == id) {
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
if (!c->next)
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
if (!c)
|
|
131
|
+
return false;
|
|
132
|
+
assert (c && res);
|
|
133
|
+
*res = c->next;
|
|
134
|
+
delete_clause (c);
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
void VeripbTracer::insert () {
|
|
139
|
+
if (num_clauses == size_clauses)
|
|
140
|
+
enlarge_clauses ();
|
|
141
|
+
const uint64_t h = reduce_hash (compute_hash (last_id), size_clauses);
|
|
142
|
+
HashId *c = new_clause ();
|
|
143
|
+
c->next = clauses[h];
|
|
144
|
+
clauses[h] = c;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/*------------------------------------------------------------------------*/
|
|
148
|
+
|
|
149
|
+
inline void VeripbTracer::put_binary_zero () {
|
|
150
|
+
assert (binary);
|
|
151
|
+
assert (file);
|
|
152
|
+
file->put ((unsigned char) 0);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
inline void VeripbTracer::put_binary_lit (int lit) {
|
|
156
|
+
assert (binary);
|
|
157
|
+
assert (file);
|
|
158
|
+
assert (lit != INT_MIN);
|
|
159
|
+
unsigned x = 2 * abs (lit) + (lit < 0);
|
|
160
|
+
unsigned char ch;
|
|
161
|
+
while (x & ~0x7f) {
|
|
162
|
+
ch = (x & 0x7f) | 0x80;
|
|
163
|
+
file->put (ch);
|
|
164
|
+
x >>= 7;
|
|
165
|
+
}
|
|
166
|
+
ch = x;
|
|
167
|
+
file->put (ch);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
inline void VeripbTracer::put_binary_id (int64_t id, bool can_be_negative) {
|
|
171
|
+
assert (binary);
|
|
172
|
+
assert (file);
|
|
173
|
+
uint64_t x = abs (id);
|
|
174
|
+
if (can_be_negative) {
|
|
175
|
+
x = 2 * x + (id < 0);
|
|
176
|
+
}
|
|
177
|
+
unsigned char ch;
|
|
178
|
+
while (x & ~0x7f) {
|
|
179
|
+
ch = (x & 0x7f) | 0x80;
|
|
180
|
+
file->put (ch);
|
|
181
|
+
x >>= 7;
|
|
182
|
+
}
|
|
183
|
+
ch = x;
|
|
184
|
+
file->put (ch);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/*------------------------------------------------------------------------*/
|
|
188
|
+
|
|
189
|
+
void VeripbTracer::veripb_add_derived_clause (int64_t id, bool redundant,
|
|
190
|
+
int witness,
|
|
191
|
+
const vector<int> &clause) {
|
|
192
|
+
assert (witness == clause[0]);
|
|
193
|
+
file->put ("red ");
|
|
194
|
+
for (const auto &external_lit : clause) {
|
|
195
|
+
file->put ("1 ");
|
|
196
|
+
if (external_lit < 0)
|
|
197
|
+
file->put ('~');
|
|
198
|
+
file->put ('x');
|
|
199
|
+
file->put (abs (external_lit));
|
|
200
|
+
file->put (' ');
|
|
201
|
+
}
|
|
202
|
+
file->put (">= 1 : ");
|
|
203
|
+
file->put ('x');
|
|
204
|
+
file->put (abs (witness));
|
|
205
|
+
file->put (" -> ");
|
|
206
|
+
if (witness < 0)
|
|
207
|
+
file->put ("0");
|
|
208
|
+
else
|
|
209
|
+
file->put ("1");
|
|
210
|
+
file->put (";\n");
|
|
211
|
+
if (!redundant && checked_deletions) {
|
|
212
|
+
file->put ("core id ");
|
|
213
|
+
file->put (id);
|
|
214
|
+
file->put (";\n");
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
void VeripbTracer::veripb_add_derived_clause (
|
|
219
|
+
int64_t id, bool redundant, const vector<int> &clause,
|
|
220
|
+
const vector<int64_t> &chain) {
|
|
221
|
+
file->put ("pol ");
|
|
222
|
+
bool first = true;
|
|
223
|
+
assert (!chain.empty ());
|
|
224
|
+
for (auto p = chain.rbegin (); p != chain.rend (); p++) {
|
|
225
|
+
auto cid = *p;
|
|
226
|
+
if (first) {
|
|
227
|
+
first = false;
|
|
228
|
+
file->put (cid);
|
|
229
|
+
} else {
|
|
230
|
+
file->put (' ');
|
|
231
|
+
file->put (cid);
|
|
232
|
+
file->put (" + s");
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
file->put (";\n");
|
|
236
|
+
file->put ("e ");
|
|
237
|
+
for (const auto &external_lit : clause) {
|
|
238
|
+
file->put ("1 ");
|
|
239
|
+
if (external_lit < 0)
|
|
240
|
+
file->put ('~');
|
|
241
|
+
file->put ('x');
|
|
242
|
+
file->put (abs (external_lit));
|
|
243
|
+
file->put (' ');
|
|
244
|
+
}
|
|
245
|
+
file->put (">= 1 : ");
|
|
246
|
+
file->put (id);
|
|
247
|
+
file->put (";\n");
|
|
248
|
+
if (!redundant && checked_deletions) {
|
|
249
|
+
file->put ("core id ");
|
|
250
|
+
file->put (id);
|
|
251
|
+
file->put (";\n");
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
void VeripbTracer::veripb_add_derived_clause (int64_t id, bool redundant,
|
|
256
|
+
const vector<int> &clause) {
|
|
257
|
+
file->put ("rup ");
|
|
258
|
+
for (const auto &external_lit : clause) {
|
|
259
|
+
file->put ("1 ");
|
|
260
|
+
if (external_lit < 0)
|
|
261
|
+
file->put ('~');
|
|
262
|
+
file->put ('x');
|
|
263
|
+
file->put (abs (external_lit));
|
|
264
|
+
file->put (' ');
|
|
265
|
+
}
|
|
266
|
+
file->put (">= 1;\n");
|
|
267
|
+
if (!redundant && checked_deletions) {
|
|
268
|
+
file->put ("core id ");
|
|
269
|
+
file->put (id);
|
|
270
|
+
file->put (";\n");
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
void VeripbTracer::veripb_begin_proof (int64_t reserved_ids) {
|
|
275
|
+
file->put ("pseudo-Boolean proof version 3.0\n");
|
|
276
|
+
file->put ("f ");
|
|
277
|
+
file->put (reserved_ids);
|
|
278
|
+
file->put (";\n");
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
void VeripbTracer::veripb_delete_clause (int64_t id, bool redundant) {
|
|
282
|
+
if (!redundant && checked_deletions && find_and_delete (id))
|
|
283
|
+
return;
|
|
284
|
+
if (redundant || !checked_deletions)
|
|
285
|
+
file->put ("del id ");
|
|
286
|
+
else {
|
|
287
|
+
file->put ("delc ");
|
|
288
|
+
}
|
|
289
|
+
file->put (id);
|
|
290
|
+
file->put (";\n");
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
void VeripbTracer::veripb_report_status (bool unsat, int64_t conflict_id) {
|
|
294
|
+
file->put ("output NONE;\n");
|
|
295
|
+
if (unsat) {
|
|
296
|
+
file->put ("conclusion UNSAT : ");
|
|
297
|
+
file->put (conflict_id);
|
|
298
|
+
file->put (";\n");
|
|
299
|
+
} else
|
|
300
|
+
file->put ("conclusion NONE;\n");
|
|
301
|
+
file->put ("end pseudo-Boolean proof;\n");
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
void VeripbTracer::veripb_strengthen (int64_t id) {
|
|
305
|
+
if (!checked_deletions)
|
|
306
|
+
return;
|
|
307
|
+
file->put ("core id ");
|
|
308
|
+
file->put (id);
|
|
309
|
+
file->put (";\n");
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/*------------------------------------------------------------------------*/
|
|
313
|
+
|
|
314
|
+
void VeripbTracer::begin_proof (int64_t id) {
|
|
315
|
+
if (file->closed ())
|
|
316
|
+
return;
|
|
317
|
+
LOG ("VERIPB TRACER tracing start of proof with %" PRId64
|
|
318
|
+
"original clauses",
|
|
319
|
+
id);
|
|
320
|
+
veripb_begin_proof (id);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
void VeripbTracer::add_derived_clause (int64_t id, bool redundant,
|
|
324
|
+
int witness,
|
|
325
|
+
const vector<int> &clause,
|
|
326
|
+
const vector<int64_t> &chain) {
|
|
327
|
+
if (file->closed ())
|
|
328
|
+
return;
|
|
329
|
+
LOG ("VERIPB TRACER tracing addition of derived clause[%" PRId64 "]", id);
|
|
330
|
+
if (witness)
|
|
331
|
+
veripb_add_derived_clause (id, redundant, witness, clause);
|
|
332
|
+
else if (with_antecedents)
|
|
333
|
+
veripb_add_derived_clause (id, redundant, clause, chain);
|
|
334
|
+
else
|
|
335
|
+
veripb_add_derived_clause (id, redundant, clause);
|
|
336
|
+
#ifndef QUIET
|
|
337
|
+
added++;
|
|
338
|
+
#endif
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
void VeripbTracer::delete_clause (int64_t id, bool redundant,
|
|
342
|
+
const vector<int> &) {
|
|
343
|
+
if (file->closed ())
|
|
344
|
+
return;
|
|
345
|
+
LOG ("VERIPB TRACER tracing deletion of clause[%" PRId64 "]", id);
|
|
346
|
+
veripb_delete_clause (id, redundant);
|
|
347
|
+
#ifndef QUIET
|
|
348
|
+
deleted++;
|
|
349
|
+
#endif
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
void VeripbTracer::report_status (int status, int64_t conflict_id) {
|
|
353
|
+
if (file->closed ())
|
|
354
|
+
return;
|
|
355
|
+
#ifdef LOGGING
|
|
356
|
+
if (conflict_id)
|
|
357
|
+
LOG ("VERIPB TRACER tracing finalization of proof with empty "
|
|
358
|
+
"clause[%" PRId64 "]",
|
|
359
|
+
conflict_id);
|
|
360
|
+
#endif
|
|
361
|
+
veripb_report_status (status == UNSATISFIABLE, conflict_id);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
void VeripbTracer::weaken_minus (int64_t id, const vector<int> &) {
|
|
365
|
+
if (!checked_deletions)
|
|
366
|
+
return;
|
|
367
|
+
if (file->closed ())
|
|
368
|
+
return;
|
|
369
|
+
LOG ("VERIPB TRACER tracing weaken minus of clause[%" PRId64 "]", id);
|
|
370
|
+
last_id = id;
|
|
371
|
+
insert ();
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
void VeripbTracer::strengthen (int64_t id) {
|
|
375
|
+
if (file->closed ())
|
|
376
|
+
return;
|
|
377
|
+
LOG ("VERIPB TRACER tracing strengthen of clause[%" PRId64 "]", id);
|
|
378
|
+
veripb_strengthen (id);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/*------------------------------------------------------------------------*/
|
|
382
|
+
|
|
383
|
+
bool VeripbTracer::closed () { return file->closed (); }
|
|
384
|
+
|
|
385
|
+
#ifndef QUIET
|
|
386
|
+
|
|
387
|
+
void VeripbTracer::print_statistics () {
|
|
388
|
+
// TODO complete
|
|
389
|
+
uint64_t bytes = file->bytes ();
|
|
390
|
+
uint64_t total = added + deleted;
|
|
391
|
+
MSG ("VeriPB %" PRId64 " added clauses %.2f%%", added,
|
|
392
|
+
percent (added, total));
|
|
393
|
+
MSG ("VeriPB %" PRId64 " deleted clauses %.2f%%", deleted,
|
|
394
|
+
percent (deleted, total));
|
|
395
|
+
MSG ("VeriPB %" PRId64 " bytes (%.2f MB)", bytes,
|
|
396
|
+
bytes / (double) (1 << 20));
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
#endif
|
|
400
|
+
|
|
401
|
+
void VeripbTracer::close (bool print) {
|
|
402
|
+
assert (!closed ());
|
|
403
|
+
file->close ();
|
|
404
|
+
#ifndef QUIET
|
|
405
|
+
if (print) {
|
|
406
|
+
MSG ("VeriPB proof file '%s' closed", file->name ());
|
|
407
|
+
print_statistics ();
|
|
408
|
+
}
|
|
409
|
+
#else
|
|
410
|
+
(void) print;
|
|
411
|
+
#endif
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
void VeripbTracer::flush (bool print) {
|
|
415
|
+
assert (!closed ());
|
|
416
|
+
file->flush ();
|
|
417
|
+
#ifndef QUIET
|
|
418
|
+
if (print) {
|
|
419
|
+
MSG ("VeriPB proof file '%s' flushed", file->name ());
|
|
420
|
+
print_statistics ();
|
|
421
|
+
}
|
|
422
|
+
#else
|
|
423
|
+
(void) print;
|
|
424
|
+
#endif
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
} // namespace CaDiCaL
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
#ifndef _veripbtracer_h_INCLUDED
|
|
2
|
+
#define _veripbtracer_h_INCLUDED
|
|
3
|
+
|
|
4
|
+
#include "file.hpp"
|
|
5
|
+
#include "tracer.hpp"
|
|
6
|
+
|
|
7
|
+
namespace CaDiCaL {
|
|
8
|
+
|
|
9
|
+
struct HashId {
|
|
10
|
+
HashId *next; // collision chain link for hash table
|
|
11
|
+
uint64_t hash; // previously computed full 64-bit hash
|
|
12
|
+
int64_t id; // id of clause
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
class VeripbTracer : public FileTracer {
|
|
16
|
+
|
|
17
|
+
Internal *internal;
|
|
18
|
+
File *file;
|
|
19
|
+
#ifndef NDEBUG
|
|
20
|
+
bool binary;
|
|
21
|
+
#endif
|
|
22
|
+
bool with_antecedents;
|
|
23
|
+
bool checked_deletions;
|
|
24
|
+
|
|
25
|
+
// hash table for checked deletions
|
|
26
|
+
//
|
|
27
|
+
uint64_t num_clauses; // number of clauses in hash table
|
|
28
|
+
uint64_t size_clauses; // size of clause hash table
|
|
29
|
+
HashId **clauses; // hash table of clauses
|
|
30
|
+
|
|
31
|
+
static const unsigned num_nonces = 4;
|
|
32
|
+
|
|
33
|
+
uint64_t nonces[num_nonces]; // random numbers for hashing
|
|
34
|
+
uint64_t last_hash; // last computed hash value of clause
|
|
35
|
+
int64_t last_id; // id of the last added clause
|
|
36
|
+
HashId *last_clause;
|
|
37
|
+
uint64_t compute_hash (int64_t); // compute and save hash value of clause
|
|
38
|
+
|
|
39
|
+
HashId *new_clause ();
|
|
40
|
+
void delete_clause (HashId *);
|
|
41
|
+
|
|
42
|
+
// Reduce hash value to the actual size.
|
|
43
|
+
//
|
|
44
|
+
static uint64_t reduce_hash (uint64_t hash, uint64_t size);
|
|
45
|
+
|
|
46
|
+
void enlarge_clauses (); // enlarge hash table for clauses
|
|
47
|
+
void insert (); // insert clause in hash table
|
|
48
|
+
bool
|
|
49
|
+
find_and_delete (const int64_t); // find clause position in hash table
|
|
50
|
+
|
|
51
|
+
#ifndef QUIET
|
|
52
|
+
int64_t added, deleted;
|
|
53
|
+
#endif
|
|
54
|
+
std::vector<int64_t> delete_ids;
|
|
55
|
+
|
|
56
|
+
void put_binary_zero ();
|
|
57
|
+
void put_binary_lit (int external_lit);
|
|
58
|
+
void put_binary_id (int64_t id, bool = false);
|
|
59
|
+
|
|
60
|
+
// support veriPB
|
|
61
|
+
void veripb_add_derived_clause (int64_t, bool redundant, int witness,
|
|
62
|
+
const std::vector<int> &clause);
|
|
63
|
+
void veripb_add_derived_clause (int64_t, bool redundant,
|
|
64
|
+
const std::vector<int> &clause,
|
|
65
|
+
const std::vector<int64_t> &chain);
|
|
66
|
+
void veripb_add_derived_clause (int64_t, bool redundant,
|
|
67
|
+
const std::vector<int> &clause);
|
|
68
|
+
void veripb_begin_proof (int64_t reserved_ids);
|
|
69
|
+
void veripb_delete_clause (int64_t id, bool redundant);
|
|
70
|
+
void veripb_report_status (bool unsat, int64_t conflict_id);
|
|
71
|
+
void veripb_strengthen (int64_t);
|
|
72
|
+
|
|
73
|
+
public:
|
|
74
|
+
// own and delete 'file'
|
|
75
|
+
VeripbTracer (Internal *, File *file, bool, bool, bool);
|
|
76
|
+
~VeripbTracer ();
|
|
77
|
+
|
|
78
|
+
void connect_internal (Internal *i) override;
|
|
79
|
+
void begin_proof (int64_t) override;
|
|
80
|
+
|
|
81
|
+
void add_original_clause (int64_t, bool, const std::vector<int> &,
|
|
82
|
+
bool = false) override {} // skip
|
|
83
|
+
|
|
84
|
+
void add_derived_clause (int64_t, bool, int, const std::vector<int> &,
|
|
85
|
+
const std::vector<int64_t> &) override;
|
|
86
|
+
|
|
87
|
+
void delete_clause (int64_t, bool, const std::vector<int> &) override;
|
|
88
|
+
void finalize_clause (int64_t, const std::vector<int> &) override {
|
|
89
|
+
} // skip
|
|
90
|
+
|
|
91
|
+
void report_status (int, int64_t) override;
|
|
92
|
+
|
|
93
|
+
void weaken_minus (int64_t, const std::vector<int> &) override;
|
|
94
|
+
void strengthen (int64_t) override;
|
|
95
|
+
|
|
96
|
+
#ifndef QUIET
|
|
97
|
+
void print_statistics ();
|
|
98
|
+
#endif
|
|
99
|
+
bool closed () override;
|
|
100
|
+
void close (bool) override;
|
|
101
|
+
void flush (bool) override;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
} // namespace CaDiCaL
|
|
105
|
+
|
|
106
|
+
#endif
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/*------------------------------------------------------------------------*/
|
|
2
|
+
|
|
3
|
+
// To simplify the build process without 'make', you can disable the
|
|
4
|
+
// generation of 'build.hpp' through '../scripts/make-build-header.sh' by
|
|
5
|
+
// defining '-DNBUILD'. Then we try to guess part of the configuration.
|
|
6
|
+
|
|
7
|
+
#ifndef NBUILD
|
|
8
|
+
#if __GNUC__ > 4
|
|
9
|
+
#if __has_include(<build.hpp>)
|
|
10
|
+
#include "build.hpp"
|
|
11
|
+
#endif // __has_include
|
|
12
|
+
#else
|
|
13
|
+
#include "build.hpp"
|
|
14
|
+
#endif // __GNUC > 4
|
|
15
|
+
#endif // NBUILD
|
|
16
|
+
|
|
17
|
+
/*------------------------------------------------------------------------*/
|
|
18
|
+
|
|
19
|
+
// We prefer short 3 character version numbers made of digits and lower case
|
|
20
|
+
// letters only, which gives 36^3 = 46656 different versions. The following
|
|
21
|
+
// macro is used for the non-standard build process and only set from
|
|
22
|
+
// the file '../VERSION' with '../scripts/update-version.sh'. The standard
|
|
23
|
+
// build process relies on 'VERSION' to be defined in 'build.hpp'.
|
|
24
|
+
|
|
25
|
+
#ifdef NBUILD
|
|
26
|
+
#ifndef VERSION
|
|
27
|
+
#define VERSION "3.0.0"
|
|
28
|
+
#endif // VERSION
|
|
29
|
+
#endif // NBUILD
|
|
30
|
+
|
|
31
|
+
/*------------------------------------------------------------------------*/
|
|
32
|
+
|
|
33
|
+
// The copyright of the code is here.
|
|
34
|
+
|
|
35
|
+
static const char *COPYRIGHT = "Copyright (c) 2016-2025";
|
|
36
|
+
static const char *AUTHORS =
|
|
37
|
+
"A. Biere, M. Fleury, N. Froleyks, K. Fazekas, F. Pollitt, T. Faller";
|
|
38
|
+
static const char *AFFILIATIONS =
|
|
39
|
+
"JKU Linz, University of Freiburg, TU Wien";
|
|
40
|
+
|
|
41
|
+
/*------------------------------------------------------------------------*/
|
|
42
|
+
|
|
43
|
+
// Again if we do not have 'NBUILD' or if something during configuration is
|
|
44
|
+
// broken we still want to be able to compile the solver. In this case we
|
|
45
|
+
// then try our best to figure out 'COMPILER' and 'DATE', but for
|
|
46
|
+
// 'IDENTIFIER' and 'FLAGS' we can only use the '0' string, which marks
|
|
47
|
+
// those as unknown.
|
|
48
|
+
|
|
49
|
+
#ifndef COMPILER
|
|
50
|
+
#ifdef __clang__
|
|
51
|
+
#ifdef __VERSION__
|
|
52
|
+
#define COMPILER "clang++-" __VERSION__
|
|
53
|
+
#else
|
|
54
|
+
#define COMPILER "clang++"
|
|
55
|
+
#endif
|
|
56
|
+
#elif defined(__GNUC__)
|
|
57
|
+
#ifdef __VERSION__
|
|
58
|
+
#define COMPILER "g++-" __VERSION__
|
|
59
|
+
#else
|
|
60
|
+
#define COMPILER "g++"
|
|
61
|
+
#endif
|
|
62
|
+
#else
|
|
63
|
+
#define COMPILER 0
|
|
64
|
+
#endif
|
|
65
|
+
#endif
|
|
66
|
+
|
|
67
|
+
// GIT SHA2 identifier.
|
|
68
|
+
//
|
|
69
|
+
#ifndef IDENTIFIER
|
|
70
|
+
#define IDENTIFIER 0
|
|
71
|
+
#endif
|
|
72
|
+
#ifdef SHORTID
|
|
73
|
+
#define SHORTIDSTR "-" SHORTID
|
|
74
|
+
#else
|
|
75
|
+
#define SHORTIDSTR ""
|
|
76
|
+
#define SHORTID 0
|
|
77
|
+
#endif
|
|
78
|
+
|
|
79
|
+
// Compilation flags.
|
|
80
|
+
//
|
|
81
|
+
#ifndef FLAGS
|
|
82
|
+
#define FLAGS 0
|
|
83
|
+
#endif
|
|
84
|
+
|
|
85
|
+
// Build Time and operating system.
|
|
86
|
+
//
|
|
87
|
+
#ifndef DATE
|
|
88
|
+
#define DATE __DATE__ " " __TIME__
|
|
89
|
+
#endif
|
|
90
|
+
|
|
91
|
+
/*------------------------------------------------------------------------*/
|
|
92
|
+
|
|
93
|
+
#include "version.hpp"
|
|
94
|
+
|
|
95
|
+
namespace CaDiCaL {
|
|
96
|
+
|
|
97
|
+
const char *version () { return VERSION; }
|
|
98
|
+
const char *copyright () { return COPYRIGHT; }
|
|
99
|
+
const char *authors () { return AUTHORS; }
|
|
100
|
+
const char *affiliations () { return AFFILIATIONS; }
|
|
101
|
+
const char *signature () { return "cadical-" VERSION SHORTIDSTR; }
|
|
102
|
+
const char *identifier () { return IDENTIFIER; }
|
|
103
|
+
const char *compiler () { return COMPILER; }
|
|
104
|
+
const char *date () { return DATE; }
|
|
105
|
+
const char *flags () { return FLAGS; }
|
|
106
|
+
|
|
107
|
+
} // namespace CaDiCaL
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
namespace CaDiCaL {
|
|
2
|
+
|
|
3
|
+
const char *version ();
|
|
4
|
+
const char *copyright ();
|
|
5
|
+
const char *authors ();
|
|
6
|
+
const char *affiliations ();
|
|
7
|
+
const char *signature ();
|
|
8
|
+
const char *identifier ();
|
|
9
|
+
const char *compiler ();
|
|
10
|
+
const char *date ();
|
|
11
|
+
const char *flags ();
|
|
12
|
+
|
|
13
|
+
} // namespace CaDiCaL
|