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,824 @@
|
|
|
1
|
+
#include "internal.hpp"
|
|
2
|
+
|
|
3
|
+
namespace CaDiCaL {
|
|
4
|
+
|
|
5
|
+
/*------------------------------------------------------------------------*/
|
|
6
|
+
|
|
7
|
+
// This implements an inprocessing version of blocked clause elimination and
|
|
8
|
+
// is assumed to be triggered just before bounded variable elimination. It
|
|
9
|
+
// has a separate 'block' flag while variable elimination uses 'elim'.
|
|
10
|
+
// Thus it only tries to block clauses on a literal which was removed in an
|
|
11
|
+
// irredundant clause in negated form before and has not been tried to use
|
|
12
|
+
// as blocking literal since then.
|
|
13
|
+
|
|
14
|
+
/*------------------------------------------------------------------------*/
|
|
15
|
+
|
|
16
|
+
inline bool block_more_occs_size::operator() (unsigned a, unsigned b) {
|
|
17
|
+
size_t s = internal->noccs (-internal->u2i (a));
|
|
18
|
+
size_t t = internal->noccs (-internal->u2i (b));
|
|
19
|
+
if (s > t)
|
|
20
|
+
return true;
|
|
21
|
+
if (s < t)
|
|
22
|
+
return false;
|
|
23
|
+
s = internal->noccs (internal->u2i (a));
|
|
24
|
+
t = internal->noccs (internal->u2i (b));
|
|
25
|
+
if (s > t)
|
|
26
|
+
return true;
|
|
27
|
+
if (s < t)
|
|
28
|
+
return false;
|
|
29
|
+
return a > b;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/*------------------------------------------------------------------------*/
|
|
33
|
+
|
|
34
|
+
// Determine whether 'c' is blocked on 'lit', by first marking all its
|
|
35
|
+
// literals and then checking all resolvents with negative clauses (with
|
|
36
|
+
// '-lit') are tautological. We use a move-to-front scheme for both the
|
|
37
|
+
// occurrence list of negative clauses (with '-lit') and then for literals
|
|
38
|
+
// within each such clause. The clause move-to-front scheme has the goal to
|
|
39
|
+
// find non-tautological clauses faster in the future, while the literal
|
|
40
|
+
// move-to-front scheme has the goal to faster find the matching literal,
|
|
41
|
+
// which makes the resolvent tautological (again in the future).
|
|
42
|
+
|
|
43
|
+
bool Internal::is_blocked_clause (Clause *c, int lit) {
|
|
44
|
+
|
|
45
|
+
LOG (c, "trying to block on %d", lit);
|
|
46
|
+
|
|
47
|
+
assert (c->size >= opts.blockminclslim);
|
|
48
|
+
assert (c->size <= opts.blockmaxclslim);
|
|
49
|
+
assert (active (lit));
|
|
50
|
+
assert (!val (lit));
|
|
51
|
+
assert (!c->garbage);
|
|
52
|
+
assert (!c->redundant);
|
|
53
|
+
assert (!level);
|
|
54
|
+
|
|
55
|
+
mark (c); // First mark all literals in 'c'.
|
|
56
|
+
|
|
57
|
+
Occs &os = occs (-lit);
|
|
58
|
+
LOG ("resolving against at most %zd clauses with %d", os.size (), -lit);
|
|
59
|
+
|
|
60
|
+
bool res = true; // Result is true if all resolvents tautological.
|
|
61
|
+
|
|
62
|
+
// Can not use 'auto' here since we update 'os' during traversal.
|
|
63
|
+
//
|
|
64
|
+
const auto end_of_os = os.end ();
|
|
65
|
+
auto i = os.begin ();
|
|
66
|
+
|
|
67
|
+
Clause *prev_d = 0; // Previous non-tautological clause.
|
|
68
|
+
|
|
69
|
+
for (; i != end_of_os; i++) {
|
|
70
|
+
// Move the first clause with non-tautological resolvent to the front of
|
|
71
|
+
// the occurrence list to improve finding it faster later.
|
|
72
|
+
//
|
|
73
|
+
Clause *d = *i;
|
|
74
|
+
|
|
75
|
+
assert (!d->garbage);
|
|
76
|
+
assert (!d->redundant);
|
|
77
|
+
assert (d->size <= opts.blockmaxclslim);
|
|
78
|
+
|
|
79
|
+
*i = prev_d; // Move previous non-tautological clause
|
|
80
|
+
prev_d = d; // backwards but remember clause at this position.
|
|
81
|
+
|
|
82
|
+
LOG (d, "resolving on %d against", lit);
|
|
83
|
+
stats.blockres++;
|
|
84
|
+
|
|
85
|
+
int prev_other = 0; // Previous non-tautological literal.
|
|
86
|
+
|
|
87
|
+
// No 'auto' since we update literals of 'd' during traversal.
|
|
88
|
+
//
|
|
89
|
+
const const_literal_iterator end_of_d = d->end ();
|
|
90
|
+
literal_iterator l;
|
|
91
|
+
|
|
92
|
+
for (l = d->begin (); l != end_of_d; l++) {
|
|
93
|
+
// Same move-to-front mechanism for literals within a clause. It
|
|
94
|
+
// moves the first negatively marked literal to the front to find it
|
|
95
|
+
// faster in the future.
|
|
96
|
+
//
|
|
97
|
+
const int other = *l;
|
|
98
|
+
*l = prev_other;
|
|
99
|
+
prev_other = other;
|
|
100
|
+
if (other == -lit)
|
|
101
|
+
continue;
|
|
102
|
+
assert (other != lit);
|
|
103
|
+
assert (active (other));
|
|
104
|
+
assert (!val (other));
|
|
105
|
+
if (marked (other) < 0) {
|
|
106
|
+
LOG ("found tautological literal %d", other);
|
|
107
|
+
d->literals[0] = other; // Move to front of 'd'.
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (l == end_of_d) {
|
|
113
|
+
LOG ("no tautological literal found");
|
|
114
|
+
//
|
|
115
|
+
// Since we did not find a tautological literal we restore the old
|
|
116
|
+
// order of literals in the clause.
|
|
117
|
+
//
|
|
118
|
+
const const_literal_iterator begin_of_d = d->begin ();
|
|
119
|
+
while (l-- != begin_of_d) {
|
|
120
|
+
const int other = *l;
|
|
121
|
+
*l = prev_other;
|
|
122
|
+
prev_other = other;
|
|
123
|
+
}
|
|
124
|
+
res = false; // Now 'd' is a witness that 'c' is not blocked.
|
|
125
|
+
os[0] = d; // Move it to the front of the occurrence list.
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
unmark (c); // ... all literals of the candidate clause.
|
|
130
|
+
|
|
131
|
+
// If all resolvents are tautological and thus the clause is blocked we
|
|
132
|
+
// restore the old order of clauses in the occurrence list of '-lit'.
|
|
133
|
+
//
|
|
134
|
+
if (res) {
|
|
135
|
+
assert (i == end_of_os);
|
|
136
|
+
const auto boc = os.begin ();
|
|
137
|
+
while (i != boc) {
|
|
138
|
+
Clause *d = *--i;
|
|
139
|
+
*i = prev_d;
|
|
140
|
+
prev_d = d;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return res;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/*------------------------------------------------------------------------*/
|
|
148
|
+
|
|
149
|
+
void Internal::block_schedule (Blocker &blocker) {
|
|
150
|
+
// Set skip flags for all literals in too large clauses.
|
|
151
|
+
//
|
|
152
|
+
for (const auto &c : clauses) {
|
|
153
|
+
|
|
154
|
+
if (c->garbage)
|
|
155
|
+
continue;
|
|
156
|
+
if (c->redundant)
|
|
157
|
+
continue;
|
|
158
|
+
if (c->size <= opts.blockmaxclslim)
|
|
159
|
+
continue;
|
|
160
|
+
|
|
161
|
+
for (const auto &lit : *c)
|
|
162
|
+
mark_skip (-lit);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Connect all literal occurrences in irredundant clauses.
|
|
166
|
+
//
|
|
167
|
+
for (const auto &c : clauses) {
|
|
168
|
+
|
|
169
|
+
if (c->garbage)
|
|
170
|
+
continue;
|
|
171
|
+
if (c->redundant)
|
|
172
|
+
continue;
|
|
173
|
+
|
|
174
|
+
for (const auto &lit : *c) {
|
|
175
|
+
assert (active (lit));
|
|
176
|
+
assert (!val (lit));
|
|
177
|
+
occs (lit).push_back (c);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// We establish the invariant that 'noccs' gives the number of actual
|
|
182
|
+
// occurrences of 'lit' in non-garbage clauses, while 'occs' might still
|
|
183
|
+
// refer to garbage clauses, thus 'noccs (lit) <= occs (lit).size ()'. It
|
|
184
|
+
// is expensive to remove references to garbage clauses from 'occs' during
|
|
185
|
+
// blocked clause elimination, but decrementing 'noccs' is cheap.
|
|
186
|
+
|
|
187
|
+
for (auto lit : lits) {
|
|
188
|
+
if (!active (lit))
|
|
189
|
+
continue;
|
|
190
|
+
assert (!val (lit));
|
|
191
|
+
Occs &os = occs (lit);
|
|
192
|
+
noccs (lit) = os.size ();
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Now we fill the schedule (priority queue) of candidate literals to be
|
|
196
|
+
// tried as blocking literals. It is probably slightly faster to do this
|
|
197
|
+
// in one go after all occurrences have been determined, instead of
|
|
198
|
+
// filling the priority queue during pushing occurrences. Filling the
|
|
199
|
+
// schedule can not be fused with the previous loop (easily) since we
|
|
200
|
+
// first have to initialize 'noccs' for both 'lit' and '-lit'.
|
|
201
|
+
|
|
202
|
+
#ifndef QUIET
|
|
203
|
+
int skipped = 0;
|
|
204
|
+
#endif
|
|
205
|
+
|
|
206
|
+
for (auto idx : vars) {
|
|
207
|
+
if (!active (idx))
|
|
208
|
+
continue;
|
|
209
|
+
if (frozen (idx)) {
|
|
210
|
+
#ifndef QUIET
|
|
211
|
+
skipped += 2;
|
|
212
|
+
#endif
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
assert (!val (idx));
|
|
216
|
+
for (int sign = -1; sign <= 1; sign += 2) {
|
|
217
|
+
const int lit = sign * idx;
|
|
218
|
+
if (marked_skip (lit)) {
|
|
219
|
+
#ifndef QUIET
|
|
220
|
+
skipped++;
|
|
221
|
+
#endif
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
if (!marked_block (lit))
|
|
225
|
+
continue;
|
|
226
|
+
unmark_block (lit);
|
|
227
|
+
LOG ("scheduling %d with %" PRId64 " positive and %" PRId64
|
|
228
|
+
" negative occurrences",
|
|
229
|
+
lit, noccs (lit), noccs (-lit));
|
|
230
|
+
blocker.schedule.push_back (vlit (lit));
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
PHASE ("block", stats.blockings,
|
|
235
|
+
"scheduled %zd candidate literals %.2f%% (%d skipped %.2f%%)",
|
|
236
|
+
blocker.schedule.size (),
|
|
237
|
+
percent (blocker.schedule.size (), 2.0 * active ()), skipped,
|
|
238
|
+
percent (skipped, 2.0 * active ()));
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/*------------------------------------------------------------------------*/
|
|
242
|
+
|
|
243
|
+
// A literal is pure if it only occurs positive. Then all clauses in which
|
|
244
|
+
// it occurs are blocked on it. This special case can be implemented faster
|
|
245
|
+
// than trying to block literals with at least one negative occurrence and
|
|
246
|
+
// is thus handled separately. It also allows to avoid pushing blocked
|
|
247
|
+
// clauses onto the extension stack.
|
|
248
|
+
|
|
249
|
+
void Internal::block_pure_literal (Blocker &blocker, int lit) {
|
|
250
|
+
if (frozen (lit))
|
|
251
|
+
return;
|
|
252
|
+
assert (active (lit));
|
|
253
|
+
|
|
254
|
+
Occs &pos = occs (lit);
|
|
255
|
+
Occs &nos = occs (-lit);
|
|
256
|
+
|
|
257
|
+
assert (!noccs (-lit));
|
|
258
|
+
#ifndef NDEBUG
|
|
259
|
+
for (const auto &c : nos)
|
|
260
|
+
assert (c->garbage);
|
|
261
|
+
#endif
|
|
262
|
+
stats.blockpurelits++;
|
|
263
|
+
LOG ("found pure literal %d", lit);
|
|
264
|
+
#ifdef LOGGING
|
|
265
|
+
int64_t pured = 0;
|
|
266
|
+
#endif
|
|
267
|
+
for (const auto &c : pos) {
|
|
268
|
+
if (c->garbage)
|
|
269
|
+
continue;
|
|
270
|
+
assert (!c->redundant);
|
|
271
|
+
LOG (c, "pure literal %d in", lit);
|
|
272
|
+
blocker.reschedule.push_back (c);
|
|
273
|
+
if (proof) {
|
|
274
|
+
proof->weaken_minus (c);
|
|
275
|
+
}
|
|
276
|
+
external->push_clause_on_extension_stack (c, lit);
|
|
277
|
+
stats.blockpured++;
|
|
278
|
+
mark_garbage (c);
|
|
279
|
+
#ifdef LOGGING
|
|
280
|
+
pured++;
|
|
281
|
+
#endif
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
erase_vector (pos);
|
|
285
|
+
erase_vector (nos);
|
|
286
|
+
|
|
287
|
+
mark_pure (lit);
|
|
288
|
+
stats.blockpured++;
|
|
289
|
+
LOG ("blocking %" PRId64 " clauses on pure literal %d", pured, lit);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/*------------------------------------------------------------------------*/
|
|
293
|
+
|
|
294
|
+
// If there is only one negative clause with '-lit' it is faster to mark it
|
|
295
|
+
// instead of marking all the positive clauses with 'lit' one after the
|
|
296
|
+
// other and then resolving against the negative clause.
|
|
297
|
+
|
|
298
|
+
void Internal::block_literal_with_one_negative_occ (Blocker &blocker,
|
|
299
|
+
int lit) {
|
|
300
|
+
assert (active (lit));
|
|
301
|
+
assert (!frozen (lit));
|
|
302
|
+
assert (noccs (lit) > 0);
|
|
303
|
+
assert (noccs (-lit) == 1);
|
|
304
|
+
|
|
305
|
+
Occs &nos = occs (-lit);
|
|
306
|
+
assert (nos.size () >= 1);
|
|
307
|
+
|
|
308
|
+
Clause *d = 0;
|
|
309
|
+
for (const auto &c : nos) {
|
|
310
|
+
if (c->garbage)
|
|
311
|
+
continue;
|
|
312
|
+
assert (!d);
|
|
313
|
+
d = c;
|
|
314
|
+
#ifndef NDEBUG
|
|
315
|
+
break;
|
|
316
|
+
#endif
|
|
317
|
+
}
|
|
318
|
+
assert (d);
|
|
319
|
+
nos.resize (1);
|
|
320
|
+
nos[0] = d;
|
|
321
|
+
|
|
322
|
+
if (d && d->size > opts.blockmaxclslim) {
|
|
323
|
+
LOG (d, "skipped common antecedent");
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
assert (!d->garbage);
|
|
328
|
+
assert (!d->redundant);
|
|
329
|
+
assert (d->size <= opts.blockmaxclslim);
|
|
330
|
+
|
|
331
|
+
LOG (d, "common %d antecedent", lit);
|
|
332
|
+
mark (d);
|
|
333
|
+
int64_t blocked = 0;
|
|
334
|
+
#ifdef LOGGING
|
|
335
|
+
int64_t skipped = 0;
|
|
336
|
+
#endif
|
|
337
|
+
Occs &pos = occs (lit);
|
|
338
|
+
|
|
339
|
+
// Again no 'auto' since 'pos' is update during traversal.
|
|
340
|
+
//
|
|
341
|
+
const auto eop = pos.end ();
|
|
342
|
+
auto j = pos.begin (), i = j;
|
|
343
|
+
|
|
344
|
+
for (; i != eop; i++) {
|
|
345
|
+
Clause *c = *j++ = *i;
|
|
346
|
+
|
|
347
|
+
if (c->garbage) {
|
|
348
|
+
j--;
|
|
349
|
+
continue;
|
|
350
|
+
}
|
|
351
|
+
if (c->size > opts.blockmaxclslim) {
|
|
352
|
+
#ifdef LOGGING
|
|
353
|
+
skipped++;
|
|
354
|
+
#endif
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
if (c->size < opts.blockminclslim) {
|
|
358
|
+
#ifdef LOGGING
|
|
359
|
+
skipped++;
|
|
360
|
+
#endif
|
|
361
|
+
continue;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
LOG (c, "trying to block on %d", lit);
|
|
365
|
+
|
|
366
|
+
// We use the same literal move-to-front strategy as in
|
|
367
|
+
// 'is_blocked_clause'. See there for more explanations.
|
|
368
|
+
|
|
369
|
+
int prev_other = 0; // Previous non-tautological literal.
|
|
370
|
+
|
|
371
|
+
// No 'auto' since literals of 'c' are updated during traversal.
|
|
372
|
+
//
|
|
373
|
+
const const_literal_iterator end_of_c = c->end ();
|
|
374
|
+
literal_iterator l;
|
|
375
|
+
|
|
376
|
+
for (l = c->begin (); l != end_of_c; l++) {
|
|
377
|
+
const int other = *l;
|
|
378
|
+
*l = prev_other;
|
|
379
|
+
prev_other = other;
|
|
380
|
+
if (other == lit)
|
|
381
|
+
continue;
|
|
382
|
+
assert (other != -lit);
|
|
383
|
+
assert (active (other));
|
|
384
|
+
assert (!val (other));
|
|
385
|
+
if (marked (other) < 0) {
|
|
386
|
+
LOG ("found tautological literal %d", other);
|
|
387
|
+
c->literals[0] = other; // Move to front of 'c'.
|
|
388
|
+
break;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
if (l == end_of_c) {
|
|
393
|
+
LOG ("no tautological literal found");
|
|
394
|
+
|
|
395
|
+
// Restore old literal order in the clause because.
|
|
396
|
+
|
|
397
|
+
const const_literal_iterator begin_of_c = c->begin ();
|
|
398
|
+
while (l-- != begin_of_c) {
|
|
399
|
+
const int other = *l;
|
|
400
|
+
*l = prev_other;
|
|
401
|
+
prev_other = other;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
continue; // ... with next candidate 'c' in 'pos'.
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
blocked++;
|
|
408
|
+
LOG (c, "blocked");
|
|
409
|
+
if (proof) {
|
|
410
|
+
proof->weaken_minus (c);
|
|
411
|
+
}
|
|
412
|
+
external->push_clause_on_extension_stack (c, lit);
|
|
413
|
+
blocker.reschedule.push_back (c);
|
|
414
|
+
mark_garbage (c);
|
|
415
|
+
j--;
|
|
416
|
+
}
|
|
417
|
+
if (j == pos.begin ())
|
|
418
|
+
erase_vector (pos);
|
|
419
|
+
else
|
|
420
|
+
pos.resize (j - pos.begin ());
|
|
421
|
+
|
|
422
|
+
stats.blocked += blocked;
|
|
423
|
+
LOG ("blocked %" PRId64 " clauses on %d (skipped %" PRId64 ")", blocked,
|
|
424
|
+
lit, skipped);
|
|
425
|
+
|
|
426
|
+
unmark (d);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/*------------------------------------------------------------------------*/
|
|
430
|
+
|
|
431
|
+
// Determine the set of candidate clauses with 'lit', which are checked to
|
|
432
|
+
// be blocked by 'lit'. Filter out too large and small clauses and which do
|
|
433
|
+
// not have any negated other literal in any of the clauses with '-lit'.
|
|
434
|
+
|
|
435
|
+
size_t Internal::block_candidates (Blocker &blocker, int lit) {
|
|
436
|
+
|
|
437
|
+
assert (blocker.candidates.empty ());
|
|
438
|
+
|
|
439
|
+
Occs &pos = occs (lit); // Positive occurrences of 'lit'.
|
|
440
|
+
Occs &nos = occs (-lit);
|
|
441
|
+
|
|
442
|
+
assert ((size_t) noccs (lit) <= pos.size ());
|
|
443
|
+
assert ((size_t) noccs (-lit) == nos.size ()); // Already flushed.
|
|
444
|
+
|
|
445
|
+
// Mark all literals in clauses with '-lit'. Note that 'mark2' uses
|
|
446
|
+
// separate bits for 'lit' and '-lit'.
|
|
447
|
+
//
|
|
448
|
+
for (const auto &c : nos)
|
|
449
|
+
mark2 (c);
|
|
450
|
+
|
|
451
|
+
const auto eop = pos.end ();
|
|
452
|
+
auto j = pos.begin (), i = j;
|
|
453
|
+
|
|
454
|
+
for (; i != eop; i++) {
|
|
455
|
+
Clause *c = *j++ = *i;
|
|
456
|
+
if (c->garbage) {
|
|
457
|
+
j--;
|
|
458
|
+
continue;
|
|
459
|
+
}
|
|
460
|
+
assert (!c->redundant);
|
|
461
|
+
if (c->size > opts.blockmaxclslim)
|
|
462
|
+
continue;
|
|
463
|
+
if (c->size < opts.blockminclslim)
|
|
464
|
+
continue;
|
|
465
|
+
const const_literal_iterator eoc = c->end ();
|
|
466
|
+
const_literal_iterator l;
|
|
467
|
+
for (l = c->begin (); l != eoc; l++) {
|
|
468
|
+
const int other = *l;
|
|
469
|
+
if (other == lit)
|
|
470
|
+
continue;
|
|
471
|
+
assert (other != -lit);
|
|
472
|
+
assert (active (other));
|
|
473
|
+
assert (!val (other));
|
|
474
|
+
if (marked2 (-other))
|
|
475
|
+
break;
|
|
476
|
+
}
|
|
477
|
+
if (l != eoc)
|
|
478
|
+
blocker.candidates.push_back (c);
|
|
479
|
+
}
|
|
480
|
+
if (j == pos.begin ())
|
|
481
|
+
erase_vector (pos);
|
|
482
|
+
else
|
|
483
|
+
pos.resize (j - pos.begin ());
|
|
484
|
+
|
|
485
|
+
assert (pos.size () == (size_t) noccs (lit)); // Now also flushed.
|
|
486
|
+
|
|
487
|
+
for (const auto &c : nos)
|
|
488
|
+
unmark (c);
|
|
489
|
+
|
|
490
|
+
return blocker.candidates.size ();
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/*------------------------------------------------------------------------*/
|
|
494
|
+
|
|
495
|
+
// Try to find a clause with '-lit' which does not have any literal in
|
|
496
|
+
// clauses with 'lit'. If such a clause exists no candidate clause can be
|
|
497
|
+
// blocked on 'lit' since all candidates would produce a non-tautological
|
|
498
|
+
// resolvent with that clause.
|
|
499
|
+
|
|
500
|
+
Clause *Internal::block_impossible (Blocker &blocker, int lit) {
|
|
501
|
+
assert (noccs (-lit) > 1);
|
|
502
|
+
assert (blocker.candidates.size () > 1);
|
|
503
|
+
|
|
504
|
+
for (const auto &c : blocker.candidates)
|
|
505
|
+
mark2 (c);
|
|
506
|
+
|
|
507
|
+
Occs &nos = occs (-lit);
|
|
508
|
+
Clause *res = 0;
|
|
509
|
+
|
|
510
|
+
for (const auto &c : nos) {
|
|
511
|
+
assert (!c->garbage);
|
|
512
|
+
assert (!c->redundant);
|
|
513
|
+
assert (c->size <= opts.blockmaxclslim);
|
|
514
|
+
const const_literal_iterator eoc = c->end ();
|
|
515
|
+
const_literal_iterator l;
|
|
516
|
+
for (l = c->begin (); l != eoc; l++) {
|
|
517
|
+
const int other = *l;
|
|
518
|
+
if (other == -lit)
|
|
519
|
+
continue;
|
|
520
|
+
assert (other != lit);
|
|
521
|
+
assert (active (other));
|
|
522
|
+
assert (!val (other));
|
|
523
|
+
if (marked2 (-other))
|
|
524
|
+
break;
|
|
525
|
+
}
|
|
526
|
+
if (l == eoc)
|
|
527
|
+
res = c;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
for (const auto &c : blocker.candidates)
|
|
531
|
+
unmark (c);
|
|
532
|
+
|
|
533
|
+
if (res) {
|
|
534
|
+
LOG (res, "common non-tautological resolvent producing");
|
|
535
|
+
blocker.candidates.clear ();
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
return res;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/*------------------------------------------------------------------------*/
|
|
542
|
+
|
|
543
|
+
// In the general case we have at least two negative occurrences.
|
|
544
|
+
|
|
545
|
+
void Internal::block_literal_with_at_least_two_negative_occs (
|
|
546
|
+
Blocker &blocker, int lit) {
|
|
547
|
+
assert (active (lit));
|
|
548
|
+
assert (!frozen (lit));
|
|
549
|
+
assert (noccs (lit) > 0);
|
|
550
|
+
assert (noccs (-lit) > 1);
|
|
551
|
+
|
|
552
|
+
Occs &nos = occs (-lit);
|
|
553
|
+
assert ((size_t) noccs (-lit) <= nos.size ());
|
|
554
|
+
|
|
555
|
+
int max_size = 0;
|
|
556
|
+
|
|
557
|
+
// Flush all garbage clauses in occurrence list 'nos' of '-lit' and
|
|
558
|
+
// determine the maximum size of negative clauses (with '-lit').
|
|
559
|
+
//
|
|
560
|
+
const auto eon = nos.end ();
|
|
561
|
+
auto j = nos.begin (), i = j;
|
|
562
|
+
for (; i != eon; i++) {
|
|
563
|
+
Clause *c = *j++ = *i;
|
|
564
|
+
if (c->garbage)
|
|
565
|
+
j--;
|
|
566
|
+
else if (c->size > max_size)
|
|
567
|
+
max_size = c->size;
|
|
568
|
+
}
|
|
569
|
+
if (j == nos.begin ())
|
|
570
|
+
erase_vector (nos);
|
|
571
|
+
else
|
|
572
|
+
nos.resize (j - nos.begin ());
|
|
573
|
+
|
|
574
|
+
assert (nos.size () == (size_t) noccs (-lit));
|
|
575
|
+
assert (nos.size () > 1);
|
|
576
|
+
|
|
577
|
+
// If the maximum size of a negative clause (with '-lit') exceeds the
|
|
578
|
+
// maximum clause size limit ignore this candidate literal.
|
|
579
|
+
//
|
|
580
|
+
if (max_size > opts.blockmaxclslim) {
|
|
581
|
+
LOG ("maximum size %d of clauses with %d exceeds clause size limit %d",
|
|
582
|
+
max_size, -lit, opts.blockmaxclslim);
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
LOG ("maximum size %d of clauses with %d", max_size, -lit);
|
|
587
|
+
|
|
588
|
+
// We filter candidate clauses with positive occurrence of 'lit' in
|
|
589
|
+
// 'blocker.candidates' and return if no candidate clause remains.
|
|
590
|
+
// Candidates should be small enough and should have at least one literal
|
|
591
|
+
// which occurs negated in one of the clauses with '-lit'.
|
|
592
|
+
//
|
|
593
|
+
size_t candidates = block_candidates (blocker, lit);
|
|
594
|
+
if (!candidates) {
|
|
595
|
+
LOG ("no candidate clauses found");
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
LOG ("found %zd candidate clauses", candidates);
|
|
600
|
+
|
|
601
|
+
// We further search for a clause with '-lit' that has no literal
|
|
602
|
+
// negated in any of the candidate clauses (except 'lit'). If such a
|
|
603
|
+
// clause exists, we know that none of the candidates is blocked.
|
|
604
|
+
//
|
|
605
|
+
if (candidates > 1 && block_impossible (blocker, lit)) {
|
|
606
|
+
LOG ("impossible to block any candidate clause on %d", lit);
|
|
607
|
+
assert (blocker.candidates.empty ());
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
LOG ("trying to block %zd clauses out of %" PRId64 " with literal %d",
|
|
612
|
+
candidates, noccs (lit), lit);
|
|
613
|
+
|
|
614
|
+
int64_t blocked = 0;
|
|
615
|
+
|
|
616
|
+
// Go over all remaining candidates and try to block them on 'lit'.
|
|
617
|
+
//
|
|
618
|
+
for (const auto &c : blocker.candidates) {
|
|
619
|
+
assert (!c->garbage);
|
|
620
|
+
assert (!c->redundant);
|
|
621
|
+
if (!is_blocked_clause (c, lit))
|
|
622
|
+
continue;
|
|
623
|
+
blocked++;
|
|
624
|
+
LOG (c, "blocked");
|
|
625
|
+
if (proof) {
|
|
626
|
+
proof->weaken_minus (c);
|
|
627
|
+
}
|
|
628
|
+
external->push_clause_on_extension_stack (c, lit);
|
|
629
|
+
blocker.reschedule.push_back (c);
|
|
630
|
+
mark_garbage (c);
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
LOG ("blocked %" PRId64
|
|
634
|
+
" clauses on %d out of %zd candidates in %zd occurrences",
|
|
635
|
+
blocked, lit, blocker.candidates.size (), occs (lit).size ());
|
|
636
|
+
|
|
637
|
+
blocker.candidates.clear ();
|
|
638
|
+
stats.blocked += blocked;
|
|
639
|
+
if (blocked)
|
|
640
|
+
flush_occs (lit);
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
/*------------------------------------------------------------------------*/
|
|
644
|
+
|
|
645
|
+
// Reschedule literals in a clause (except 'lit') which was blocked.
|
|
646
|
+
|
|
647
|
+
void Internal::block_reschedule_clause (Blocker &blocker, int lit,
|
|
648
|
+
Clause *c) {
|
|
649
|
+
#ifdef NDEBUG
|
|
650
|
+
(void) lit;
|
|
651
|
+
#endif
|
|
652
|
+
assert (c->garbage);
|
|
653
|
+
|
|
654
|
+
for (const auto &other : *c) {
|
|
655
|
+
|
|
656
|
+
int64_t &n = noccs (other);
|
|
657
|
+
assert (n > 0);
|
|
658
|
+
n--;
|
|
659
|
+
|
|
660
|
+
LOG ("updating %d with %" PRId64 " positive and %" PRId64
|
|
661
|
+
" negative occurrences",
|
|
662
|
+
other, noccs (other), noccs (-other));
|
|
663
|
+
|
|
664
|
+
if (blocker.schedule.contains (vlit (-other)))
|
|
665
|
+
blocker.schedule.update (vlit (-other));
|
|
666
|
+
else if (active (other) && !frozen (other) && !marked_skip (-other)) {
|
|
667
|
+
LOG ("rescheduling to block clauses on %d", -other);
|
|
668
|
+
blocker.schedule.push_back (vlit (-other));
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
if (blocker.schedule.contains (vlit (other))) {
|
|
672
|
+
assert (other != lit);
|
|
673
|
+
blocker.schedule.update (vlit (other));
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
// Reschedule all literals in clauses blocked by 'lit' (except 'lit').
|
|
679
|
+
|
|
680
|
+
void Internal::block_reschedule (Blocker &blocker, int lit) {
|
|
681
|
+
while (!blocker.reschedule.empty ()) {
|
|
682
|
+
Clause *c = blocker.reschedule.back ();
|
|
683
|
+
blocker.reschedule.pop_back ();
|
|
684
|
+
block_reschedule_clause (blocker, lit, c);
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
/*------------------------------------------------------------------------*/
|
|
689
|
+
|
|
690
|
+
void Internal::block_literal (Blocker &blocker, int lit) {
|
|
691
|
+
assert (!marked_skip (lit));
|
|
692
|
+
|
|
693
|
+
if (!active (lit))
|
|
694
|
+
return; // Pure literal '-lit'.
|
|
695
|
+
if (frozen (lit))
|
|
696
|
+
return;
|
|
697
|
+
|
|
698
|
+
assert (!val (lit));
|
|
699
|
+
|
|
700
|
+
// If the maximum number of a negative clauses (with '-lit') exceeds the
|
|
701
|
+
// occurrence limit ignore this candidate literal.
|
|
702
|
+
//
|
|
703
|
+
if (noccs (-lit) > opts.blockocclim)
|
|
704
|
+
return;
|
|
705
|
+
|
|
706
|
+
LOG ("blocking literal candidate %d "
|
|
707
|
+
"with %" PRId64 " positive and %" PRId64 " negative occurrences",
|
|
708
|
+
lit, noccs (lit), noccs (-lit));
|
|
709
|
+
|
|
710
|
+
stats.blockcands++;
|
|
711
|
+
|
|
712
|
+
assert (blocker.reschedule.empty ());
|
|
713
|
+
assert (blocker.candidates.empty ());
|
|
714
|
+
|
|
715
|
+
if (!noccs (-lit))
|
|
716
|
+
block_pure_literal (blocker, lit);
|
|
717
|
+
else if (!noccs (lit)) {
|
|
718
|
+
// Rare situation, where the clause length limit was hit for 'lit' and
|
|
719
|
+
// '-lit' is skipped and then it becomes pure. Can be ignored. We also
|
|
720
|
+
// so it once happening for a 'elimboundmin=-1' and zero positive and
|
|
721
|
+
// one negative occurrence.
|
|
722
|
+
} else if (noccs (-lit) == 1)
|
|
723
|
+
block_literal_with_one_negative_occ (blocker, lit);
|
|
724
|
+
else
|
|
725
|
+
block_literal_with_at_least_two_negative_occs (blocker, lit);
|
|
726
|
+
|
|
727
|
+
// Done with blocked clause elimination on this literal and we do not
|
|
728
|
+
// have to try blocked clause elimination on it again until irredundant
|
|
729
|
+
// clauses with its negation are removed.
|
|
730
|
+
//
|
|
731
|
+
assert (!frozen (lit)); // just to be sure ...
|
|
732
|
+
unmark_block (lit);
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
/*------------------------------------------------------------------------*/
|
|
736
|
+
|
|
737
|
+
bool Internal::block () {
|
|
738
|
+
|
|
739
|
+
if (!opts.block)
|
|
740
|
+
return false;
|
|
741
|
+
if (unsat)
|
|
742
|
+
return false;
|
|
743
|
+
if (!stats.current.irredundant)
|
|
744
|
+
return false;
|
|
745
|
+
if (terminated_asynchronously ())
|
|
746
|
+
return false;
|
|
747
|
+
|
|
748
|
+
if (propagated < trail.size ()) {
|
|
749
|
+
LOG ("need to propagate %zd units first", trail.size () - propagated);
|
|
750
|
+
init_watches ();
|
|
751
|
+
connect_watches ();
|
|
752
|
+
if (!propagate ()) {
|
|
753
|
+
LOG ("propagating units results in empty clause");
|
|
754
|
+
learn_empty_clause ();
|
|
755
|
+
assert (unsat);
|
|
756
|
+
}
|
|
757
|
+
clear_watches ();
|
|
758
|
+
reset_watches ();
|
|
759
|
+
if (unsat)
|
|
760
|
+
return false;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
START_SIMPLIFIER (block, BLOCK);
|
|
764
|
+
|
|
765
|
+
stats.blockings++;
|
|
766
|
+
|
|
767
|
+
LOG ("block-%" PRId64 "", stats.blockings);
|
|
768
|
+
|
|
769
|
+
assert (!level);
|
|
770
|
+
assert (!watching ());
|
|
771
|
+
assert (!occurring ());
|
|
772
|
+
|
|
773
|
+
mark_satisfied_clauses_as_garbage ();
|
|
774
|
+
|
|
775
|
+
init_occs (); // Occurrence lists for all literals.
|
|
776
|
+
init_noccs (); // Number of occurrences to avoid flushing garbage clauses.
|
|
777
|
+
|
|
778
|
+
Blocker blocker (this);
|
|
779
|
+
block_schedule (blocker);
|
|
780
|
+
|
|
781
|
+
int64_t blocked = stats.blocked;
|
|
782
|
+
int64_t resolutions = stats.blockres;
|
|
783
|
+
int64_t purelits = stats.blockpurelits;
|
|
784
|
+
int64_t pured = stats.blockpured;
|
|
785
|
+
|
|
786
|
+
while (!terminated_asynchronously () && !blocker.schedule.empty ()) {
|
|
787
|
+
int lit = u2i (blocker.schedule.front ());
|
|
788
|
+
blocker.schedule.pop_front ();
|
|
789
|
+
block_literal (blocker, lit);
|
|
790
|
+
block_reschedule (blocker, lit);
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
blocker.erase ();
|
|
794
|
+
reset_noccs ();
|
|
795
|
+
reset_occs ();
|
|
796
|
+
|
|
797
|
+
resolutions = stats.blockres - resolutions;
|
|
798
|
+
blocked = stats.blocked - blocked;
|
|
799
|
+
|
|
800
|
+
PHASE ("block", stats.blockings,
|
|
801
|
+
"blocked %" PRId64 " clauses in %" PRId64 " resolutions", blocked,
|
|
802
|
+
resolutions);
|
|
803
|
+
|
|
804
|
+
pured = stats.blockpured - pured;
|
|
805
|
+
purelits = stats.blockpurelits - purelits;
|
|
806
|
+
|
|
807
|
+
if (pured)
|
|
808
|
+
mark_redundant_clauses_with_eliminated_variables_as_garbage ();
|
|
809
|
+
|
|
810
|
+
if (purelits)
|
|
811
|
+
PHASE ("block", stats.blockings,
|
|
812
|
+
"found %" PRId64 " pure literals in %" PRId64 " clauses",
|
|
813
|
+
purelits, pured);
|
|
814
|
+
else
|
|
815
|
+
PHASE ("block", stats.blockings, "no pure literals found");
|
|
816
|
+
|
|
817
|
+
report ('b', !opts.reportall && !blocked);
|
|
818
|
+
|
|
819
|
+
STOP_SIMPLIFIER (block, BLOCK);
|
|
820
|
+
|
|
821
|
+
return blocked;
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
} // namespace CaDiCaL
|