ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
internal.hpp
Go to the documentation of this file.
1#ifndef _internal_hpp_INCLUDED
2#define _internal_hpp_INCLUDED
3
4#include "global.h"
5
6/*------------------------------------------------------------------------*/
7
8// Wrapped build specific headers which should go first.
9
10#include "inttypes.hpp"
11
12/*------------------------------------------------------------------------*/
13
14// Common 'C' headers.
15
16#include <cassert>
17#include <cctype>
18#include <climits>
19#include <cmath>
20#include <csignal>
21#include <cstdio>
22#include <cstdlib>
23#include <cstring>
24
25// Less common 'C' header.
26
27#ifndef WIN32
28extern "C" {
29#include <unistd.h>
30}
31#endif
32
33/*------------------------------------------------------------------------*/
34
35// Common 'C++' headers.
36
37#include <algorithm>
38#include <queue>
39#include <string>
40#include <unordered_set>
41#include <vector>
42
43/*------------------------------------------------------------------------*/
44
45// All internal headers are included here. This gives a nice overview on
46// what is needed altogether. The 'Internal' class needs almost all the
47// headers anyhow (since the idea is to avoid pointer references as much as
48// possible). Most implementation files need to see the definition of the
49// 'Internal' too. Thus there is no real advantage in trying to reduce the
50// number of header files included here. The other benefit of having all
51// header files here is that '.cpp' files then only need to include this.
52
53#include "arena.hpp"
54#include "averages.hpp"
55#include "bins.hpp"
56#include "block.hpp"
57#include "cadical.hpp"
58#include "checker.hpp"
59#include "clause.hpp"
60#include "config.hpp"
61#include "congruence.hpp"
62#include "contract.hpp"
63#include "cover.hpp"
64#include "decompose.hpp"
65#include "drattracer.hpp"
66#include "elim.hpp"
67#include "ema.hpp"
68#include "external.hpp"
69#include "factor.hpp"
70#include "file.hpp"
71#include "flags.hpp"
72#include "format.hpp"
73#include "frattracer.hpp"
74#include "heap.hpp"
75#include "idruptracer.hpp"
76#include "instantiate.hpp"
77#include "internal.hpp"
78#include "level.hpp"
79#include "lidruptracer.hpp"
80#include "limit.hpp"
81#include "logging.hpp"
82#include "lratchecker.hpp"
83#include "lrattracer.hpp"
84#include "message.hpp"
85#include "occs.hpp"
86#include "options.hpp"
87#include "parse.hpp"
88#include "phases.hpp"
89#include "profile.hpp"
90#include "proof.hpp"
91#include "queue.hpp"
92#include "radix.hpp"
93#include "random.hpp"
94#include "range.hpp"
95#include "reap.hpp"
96#include "reluctant.hpp"
97#include "resources.hpp"
98#include "score.hpp"
99#include "stats.hpp"
100#include "sweep.hpp"
101#include "terminal.hpp"
102#include "tracer.hpp"
103#include "util.hpp"
104#include "var.hpp"
105#include "veripbtracer.hpp"
106#include "version.hpp"
107#include "vivify.hpp"
108#include "watch.hpp"
109
110// c headers
111//extern "C" {
112#include "kitten.h"
113//}
114/*------------------------------------------------------------------------*/
115
117
118namespace CaDiCaL {
119
120using namespace std;
121
122struct Coveror;
123struct External;
124struct Walker;
125class Tracer;
126class FileTracer;
127class StatTracer;
128
130 int status = 0;
131 std::vector<std::vector<int>> cubes;
132};
133
134/*------------------------------------------------------------------------*/
135
136struct Internal {
137
138 /*----------------------------------------------------------------------*/
139
140 // The actual internal state of the solver is set and maintained in this
141 // section. This is currently only used for debugging and testing.
142
143 enum Mode {
144 BLOCK = (1 << 0),
145 CONDITION = (1 << 1),
146 CONGRUENCE = (1 << 2),
147 COVER = (1 << 3),
148 DECOMP = (1 << 4),
149 DEDUP = (1 << 5),
150 ELIM = (1 << 6),
151 FACTOR = (1 << 7),
152 LUCKY = (1 << 8),
153 PROBE = (1 << 9),
154 SEARCH = (1 << 10),
155 SIMPLIFY = (1 << 11),
156 SUBSUME = (1 << 12),
157 SWEEP = (1 << 13),
158 TERNARY = (1 << 14),
159 TRANSRED = (1 << 15),
160 VIVIFY = (1 << 16),
161 WALK = (1 << 17),
162 };
163
164 bool in_mode (Mode m) const { return (mode & m) != 0; }
165 void set_mode (Mode m) {
166 CADICAL_assert (!(mode & m));
167 mode |= m;
168 }
169 void reset_mode (Mode m) {
170 CADICAL_assert (mode & m);
171 mode &= ~m;
172 }
173 void require_mode (Mode m) const { CADICAL_assert (mode & m), (void) m; }
174
175 /*----------------------------------------------------------------------*/
176
177 int mode; // current internal state
178 int tier1[2] = {
179 2, 2}; // tier1 limit for 0=focused, 1=stable; aka tier1[stable]
180 int tier2[2] = {
181 6, 6}; // tier2 limit for 0=focused, 1=stable; aka tier1[stable]
182 bool unsat; // empty clause found or learned
183 bool iterating; // report learned unit ('i' line)
184 bool localsearching; // true during local search
185 bool lookingahead; // true during look ahead
186 bool preprocessing; // true during preprocessing
187 bool protected_reasons; // referenced reasons are protected
188 bool force_saved_phase; // force saved phase in decision
189 bool searching_lucky_phases; // during 'lucky_phases'
190 bool stable; // true during stabilization phase
191 bool reported; // reported in this solving call
192 bool external_prop; // true if an external propagator is connected
193 bool did_external_prop; // true if ext. propagation happened
194 bool external_prop_is_lazy; // true if the external propagator is lazy
195 bool forced_backt_allowed; // external propagator can force backtracking
196 bool private_steps; // no notification of ext. prop during these steps
197 char rephased; // last type of resetting phases
198 Reluctant reluctant; // restart counter in stable mode
199 size_t vsize; // actually allocated variable data size
200 int max_var; // internal maximum variable index
201 int64_t clause_id; // last used id for clauses
202 int64_t original_id; // ids for original clauses to produce LRAT
203 int64_t reserved_ids; // number of reserved ids for original clauses
204 int64_t conflict_id; // store conflict id for finalize (frat)
205 int64_t saved_decisions; // to compute decision rate average
206 bool concluded; // keeps track of conclude
207 vector<int64_t> conclusion; // store ids of conclusion clauses
209 unit_clauses_idx; // keep track of unit_clauses (LRAT/FRAT)
210 vector<int64_t> lrat_chain; // create LRAT in solver: option lratdirect
211 vector<int64_t> mini_chain; // used to create LRAT in minimize
212 vector<int64_t> minimize_chain; // used to create LRAT in minimize
213 vector<int64_t> unit_chain; // used to avoid duplicate units
214 vector<Clause *> inst_chain; // for LRAT in instantiate
216 probehbr_chains; // only used if opts.probehbr=false
217 bool lrat; // generate LRAT internally
218 bool frat; // finalize non-deleted clauses in proof
219 int level; // decision level ('control.size () - 1')
220 Phases phases; // saved, target and best phases
221 signed char *vals; // assignment [-max_var,max_var]
222 vector<signed char> marks; // signed marks [1,max_var]
223 vector<unsigned> frozentab; // frozen counters [1,max_var]
224 vector<int> i2e; // maps internal 'idx' to external 'lit'
225 vector<unsigned> relevanttab; // Reference counts for observed variables.
226 Queue queue; // variable move to front decision queue
227 Links links; // table of links for decision queue
228 double score_inc; // current score increment
229 ScoreSchedule scores; // score based decision priority queue
230 vector<double> stab; // table of variable scores [1,max_var]
231 vector<Var> vtab; // variable table [1,max_var]
232 vector<int> parents; // parent literals during probing
233 vector<Flags> ftab; // variable and literal flags
234 vector<int64_t> btab; // enqueue time stamps for queue
235 vector<int64_t> gtab; // time stamp table to recompute glue
236 vector<Occs> otab; // table of occurrences for all literals
237 vector<Occs> rtab; // table of redundant occurrences
238 vector<int> ptab; // table for caching probing attempts
239 vector<int64_t> ntab; // number of one-sided occurrences table
240 vector<Bins> big; // binary implication graph
241 vector<Watches> wtab; // table of watches for all literals
242 Clause *conflict; // set in 'propagation', reset in 'analyze'
243 Clause *ignore; // ignored during 'vivify_propagate'
244 Clause *dummy_binary; // Dummy binary clause for subsumption
245 Clause *external_reason; // used as reason at external propagations
246 Clause *newest_clause; // used in external_propagate
247 bool force_no_backtrack; // for new clauses with external propagator
248 bool from_propagator; // differentiate new clauses...
249 bool ext_clause_forgettable; // Is new clause from propagator forgettable
250 int tainted_literal; // used for ILB
251 size_t notified; // next trail position to notify external prop
252 Clause *probe_reason; // set during probing
253 size_t propagated; // next trail position to propagate
254 size_t propagated2; // next binary trail position to propagate
255 size_t propergated; // propagated without blocking literals
256 size_t best_assigned; // best maximum assigned ever
257 size_t target_assigned; // maximum assigned without conflict
258 size_t no_conflict_until; // largest trail prefix without conflict
259 vector<int> trail; // currently assigned literals
260 vector<int> clause; // simplified in parsing & learning
261 vector<int> assumptions; // assumed literals
262 vector<int> constraint; // literals of the constraint
263 bool unsat_constraint; // constraint used for unsatisfiability?
264 bool marked_failed; // are the failed assumptions marked?
265 vector<int> original; // original added literals
266 vector<int> levels; // decision levels in learned clause
267 vector<int> analyzed; // analyzed literals in 'analyze'
268 vector<int> unit_analyzed; // to avoid duplicate units in lrat_chain
269 vector<int> sign_marked; // literals skipped in 'decompose'
270 vector<int> minimized; // removable or poison in 'minimize'
271 vector<int> shrinkable; // removable or poison in 'shrink'
272 Reap reap; // radix heap for shrink
273
274 vector<int> sweep_schedule; // remember sweep varibles to reschedule
275 bool sweep_incomplete; // sweep
276
278
279 size_t num_assigned; // check for satisfied
280
281 vector<int> probes; // remaining scheduled probes
282 vector<Level> control; // 'level + 1 == control.size ()'
283 vector<Clause *> clauses; // ordered collection of all clauses
284 Averages averages; // glue, size, jump moving averages
285 Delay delay[2]; // Delay certain functions
286 Delay congruence_delay; // Delay congruence if not successful recently
287 Limit lim; // limits for various phases
288 Last last; // statistics at last occurrence
289 Inc inc; // increments on limits
290
293
294 Proof *proof; // abstraction layer between solver and tracers
296 tracers; // proof tracing objects (ie interpolant calculator)
298 file_tracers; // file proof tracers (ie DRAT, LRAT...)
300
301 Options opts; // run-time options
302 Stats stats; // statistics
303#ifndef CADICAL_QUIET
304 Profiles profiles; // time profiles for various functions
305 bool force_phase_messages; // force 'phase (...)' messages
306#endif
307 Arena arena; // memory arena for moving garbage collector
308 Format error_message; // provide persistent error message
309 string prefix; // verbose messages prefix
310
311 Internal *internal; // proxy to 'this' in macros
312 External *external; // proxy to 'external' buddy in 'Solver'
313
314 const unsigned max_used = 255; // must fix into the header of the clause!
315 /*----------------------------------------------------------------------*/
316
317 // Asynchronous termination flag written by 'terminate' and read by
318 // 'terminated_asynchronously' (the latter at the end of this header).
319 //
320 volatile bool termination_forced;
321
322 /*----------------------------------------------------------------------*/
323
324 const Range vars; // Provides safe variable iteration.
325 const Sange lits; // Provides safe literal iteration.
326
327 /*----------------------------------------------------------------------*/
328
329 Internal ();
330 ~Internal ();
331
332 /*----------------------------------------------------------------------*/
333
334 // Internal delegates and helpers for corresponding functions in
335 // 'External' and 'Solver'. The 'init_vars' function initializes
336 // variables up to and including the requested variable index.
337 //
338 void init_vars (int new_max_var);
339
340 void init_enqueue (int idx);
341 void init_queue (int old_max_var, int new_max_var);
342
343 void init_scores (int old_max_var, int new_max_var);
344
345 void add_original_lit (int lit);
346
347 // only able to restore irredundant clause
348 void finish_added_clause_with_id (int64_t id, bool restore = false);
349
350 // Reserve ids for original clauses to produce lrat
351 void reserve_ids (int number);
352
353 // Enlarge tables.
354 //
355 void enlarge_vals (size_t new_vsize);
356 void enlarge (int new_max_var);
357
358 // A variable is 'active' if it is not eliminated nor fixed.
359 //
360 bool active (int lit) { return flags (lit).active (); }
361
362 int active () const {
363 int res = stats.active;
364#ifndef CADICAL_NDEBUG
365 int tmp = max_var;
366 tmp -= stats.unused;
367 tmp -= stats.now.fixed;
368 tmp -= stats.now.eliminated;
369 tmp -= stats.now.substituted;
370 tmp -= stats.now.pure;
371 CADICAL_assert (tmp >= 0);
372 CADICAL_assert (tmp == res);
373#endif
374 return res;
375 }
376
377 void reactivate (int lit); // During 'restore'.
378
379 // Currently remaining active redundant and irredundant clauses.
380
381 int64_t redundant () const { return stats.current.redundant; }
382
383 int64_t irredundant () const { return stats.current.irredundant; }
384
385 double clause_variable_ratio () const {
386 return relative (irredundant (), active ());
387 }
388
389 // Scale values relative to clause variable ratio.
390 //
391 double scale (double v) const;
392
393 // Unsigned literals (abs) with checks.
394 //
395 int vidx (int lit) const {
396 int idx;
398 CADICAL_assert (lit != INT_MIN);
399 idx = abs (lit);
400 CADICAL_assert (idx <= max_var);
401 return idx;
402 }
403
404 // Unsigned version with LSB denoting sign. This is used in indexing
405 // arrays by literals. The idea is to keep the elements in such an array
406 // for both the positive and negated version of a literal close together.
407 //
408 unsigned vlit (int lit) const {
409 return (lit < 0) + 2u * (unsigned) vidx (lit);
410 }
411
412 int u2i (unsigned u) {
413 CADICAL_assert (u > 1);
414 int res = u / 2;
415 CADICAL_assert (res <= max_var);
416 if (u & 1)
417 res = -res;
418 return res;
419 }
420
421 int citten2lit (unsigned ulit) {
422 int res = (ulit / 2) + 1;
423 CADICAL_assert (res <= max_var);
424 if (ulit & 1)
425 res = -res;
426 return res;
427 }
428
429 unsigned lit2citten (int lit) {
430 int idx = vidx (lit) - 1;
431 return (lit < 0) + 2u * (unsigned) idx;
432 }
433
434 int64_t unit_id (int lit) const {
436 CADICAL_assert (val (lit) > 0);
437 const unsigned uidx = vlit (lit);
438 int64_t id = unit_clauses_idx[uidx];
439 CADICAL_assert (id);
440 return id;
441 }
442
443 inline int64_t &unit_clauses (int uidx) {
445 CADICAL_assert (uidx > 0);
446 CADICAL_assert ((size_t) uidx < unit_clauses_idx.size ());
447 return unit_clauses_idx[uidx];
448 }
449
450 // Helper functions to access variable and literal data.
451 //
452 Var &var (int lit) { return vtab[vidx (lit)]; }
453 Link &link (int lit) { return links[vidx (lit)]; }
454 Flags &flags (int lit) { return ftab[vidx (lit)]; }
455 int64_t &bumped (int lit) { return btab[vidx (lit)]; }
456 int &propfixed (int lit) { return ptab[vlit (lit)]; }
457 double &score (int lit) { return stab[vidx (lit)]; }
458
459 const Flags &flags (int lit) const { return ftab[vidx (lit)]; }
460
461 bool occurring () const { return !otab.empty (); }
462 bool watching () const { return !wtab.empty (); }
463
464 Bins &bins (int lit) { return big[vlit (lit)]; }
465 Occs &occs (int lit) { return otab[vlit (lit)]; }
466 int64_t &noccs (int lit) { return ntab[vlit (lit)]; }
467 Watches &watches (int lit) { return wtab[vlit (lit)]; }
468
469 // Variable bumping through exponential VSIDS (EVSIDS) as in MiniSAT.
470 //
471 bool use_scores () const { return opts.score && stable; }
472 void bump_variable_score (int lit);
475
476 // Marking variables with a sign (positive or negative).
477 //
478 signed char marked (int lit) const {
479 signed char res = marks[vidx (lit)];
480 if (lit < 0)
481 res = -res;
482 return res;
483 }
484 void mark (int lit) {
486 marks[vidx (lit)] = sign (lit);
487 CADICAL_assert (marked (lit) > 0);
488 CADICAL_assert (marked (-lit) < 0);
489 }
490 void unmark (int lit) {
491 marks[vidx (lit)] = 0;
493 }
494
495 // Use only bits 6 and 7 to store the sign or zero. The remaining
496 // bits can be used as additional flags.
497 //
498 signed char marked67 (int lit) const {
499 signed char res = marks[vidx (lit)] >> 6;
500 if (lit < 0)
501 res = -res;
502 return res;
503 }
504 void mark67 (int lit) {
505 signed char &m = marks[vidx (lit)];
506 const signed char mask = 0x3f;
507#ifndef CADICAL_NDEBUG
508 const signed char bits = m & mask;
509#endif
510 m = (m & mask) | (sign (lit) << 6);
511 CADICAL_assert (marked (lit) > 0);
512 CADICAL_assert (marked (-lit) < 0);
513 CADICAL_assert ((m & mask) == bits);
515 CADICAL_assert (marked67 (-lit) < 0);
516 }
517 void unmark67 (int lit) {
518 signed char &m = marks[vidx (lit)];
519 const signed char mask = 0x3f;
520#ifndef CADICAL_NDEBUG
521 const signed bits = m & mask;
522#endif
523 m &= mask;
524 CADICAL_assert ((m & mask) == bits);
525 }
526
528 for (const auto &lit : lits)
529 unmark (lit);
530 }
531
532 // The other 6 bits of the 'marks' bytes can be used as additional
533 // (unsigned) marking bits. Currently we only use the least significant
534 // bit in 'condition' to mark variables in the conditional part.
535 //
536 bool getbit (int lit, int bit) const {
537 CADICAL_assert (0 <= bit), CADICAL_assert (bit < 6);
538 return marks[vidx (lit)] & (1 << bit);
539 }
540 void setbit (int lit, int bit) {
541 CADICAL_assert (0 <= bit), CADICAL_assert (bit < 6);
542 CADICAL_assert (!getbit (lit, bit));
543 marks[vidx (lit)] |= (1 << bit);
544 CADICAL_assert (getbit (lit, bit));
545 }
546 void unsetbit (int lit, int bit) {
547 CADICAL_assert (0 <= bit), CADICAL_assert (bit < 6);
548 CADICAL_assert (getbit (lit, bit));
549 marks[vidx (lit)] &= ~(1 << bit);
550 CADICAL_assert (!getbit (lit, bit));
551 }
552
553 // Marking individual literals.
554 //
555 bool marked2 (int lit) const {
556 unsigned res = marks[vidx (lit)];
557 CADICAL_assert (res <= 3);
558 unsigned bit = bign (lit);
559 return (res & bit) != 0;
560 }
561 void mark2 (int lit) {
562 marks[vidx (lit)] |= bign (lit);
564 }
565
566 // marks bits 1,2,3 and 4,5,6 depending on fact and sign of lit
567 //
568 bool getfact (int lit, int fact) const {
569 CADICAL_assert (fact == 1 || fact == 2 || fact == 4);
570 int res = marks[vidx (lit)];
571 if (lit < 0) {
572 res >>= 3;
573 } else {
574 res &= 7;
575 }
576 // CADICAL_assert (!res || res == 1 || res == 2 || res == 4);
577 return res & fact;
578 }
579
580 void markfact (int lit, int fact) {
581 CADICAL_assert (fact == 1 || fact == 2 || fact == 4);
582 CADICAL_assert (!getfact (lit, fact));
583#ifndef CADICAL_NDEBUG
584 int before = getfact (-lit, fact);
585#endif
586 int res = marks[vidx (lit)];
587 if (lit < 0) {
588 res |= fact << 3;
589 } else {
590 res |= fact;
591 }
592 marks[vidx (lit)] = res;
593 CADICAL_assert (getfact (lit, fact));
594#ifndef CADICAL_NDEBUG
595 CADICAL_assert (getfact (-lit, fact) == before);
596#endif
597 }
598
599 void unmarkfact (int lit, int fact) {
600 CADICAL_assert (fact == 1 || fact == 2 || fact == 4);
601 CADICAL_assert (getfact (lit, fact));
602 int res = marks[vidx (lit)];
603 if (lit < 0) {
604 res &= ~(fact << 3);
605 } else {
606 res &= ~fact;
607 }
608 marks[vidx (lit)] = res;
609 CADICAL_assert (!getfact (lit, fact));
610 }
611
612 // Marking and unmarking of all literals in a clause.
613 //
614 void mark_clause (); // mark 'this->clause'
615 void mark (Clause *);
616 void mark2 (Clause *);
617 void unmark_clause (); // unmark 'this->clause'
618 void unmark (Clause *);
619
620 // Watch literal 'lit' in clause with blocking literal 'blit'.
621 // Inlined here, since it occurs in the tight inner loop of 'propagate'.
622 //
623 inline void watch_literal (int lit, int blit, Clause *c) {
624 CADICAL_assert (lit != blit);
625 Watches &ws = watches (lit);
626 ws.push_back (Watch (blit, c));
627 LOG (c, "watch %d blit %d in", lit, blit);
628 }
629
630 // Add two watches to a clause. This is used initially during allocation
631 // of a clause and during connecting back all watches after preprocessing.
632 //
633 inline void watch_clause (Clause *c) {
634 const int l0 = c->literals[0];
635 const int l1 = c->literals[1];
636 watch_literal (l0, l1, c);
637 watch_literal (l1, l0, c);
638 }
639
640 inline void unwatch_clause (Clause *c) {
641 const int l0 = c->literals[0];
642 const int l1 = c->literals[1];
643 remove_watch (watches (l0), c);
644 remove_watch (watches (l1), c);
645 }
646
647 // Update queue to point to last potentially still unassigned variable.
648 // All variables after 'queue.unassigned' in bump order are assumed to be
649 // assigned. Then update the 'queue.bumped' field and log it. This is
650 // inlined here since it occurs in several inner loops.
651 //
652 inline void update_queue_unassigned (int idx) {
653 CADICAL_assert (0 < idx);
654 CADICAL_assert (idx <= max_var);
655 queue.unassigned = idx;
656 queue.bumped = btab[idx];
657 LOG ("queue unassigned now %d bumped %" PRId64 "", idx, btab[idx]);
658 }
659
660 void bump_queue (int idx);
661
662 // Mark (active) variables as eliminated, substituted, pure or fixed,
663 // which turns them into inactive variables.
664 //
665 void mark_eliminated (int);
666 void mark_substituted (int);
667 void mark_active (int);
668 void mark_fixed (int);
669 void mark_pure (int);
670
671 // Managing clauses in 'clause.cpp'. Without explicit 'Clause' argument
672 // these functions work on the global temporary 'clause'.
673 //
674 Clause *new_clause (bool red, int glue = 0);
675 void promote_clause (Clause *, int new_glue);
676 void promote_clause_glue_only (Clause *, int new_glue);
677 size_t shrink_clause (Clause *, int new_size);
678 void minimize_sort_clause ();
680 void reset_shrinkable ();
681 void mark_shrinkable_as_removable (int, std::vector<int>::size_type);
682 int shrink_literal (int, int, unsigned);
683 unsigned shrunken_block_uip (int, int,
684 std::vector<int>::reverse_iterator &,
685 std::vector<int>::reverse_iterator &,
686 std::vector<int>::size_type, const int);
687 void shrunken_block_no_uip (const std::vector<int>::reverse_iterator &,
688 const std::vector<int>::reverse_iterator &,
689 unsigned &, const int);
690 void push_literals_of_block (const std::vector<int>::reverse_iterator &,
691 const std::vector<int>::reverse_iterator &,
692 int, unsigned);
693 unsigned shrink_next (int, unsigned &, unsigned &);
694 std::vector<int>::reverse_iterator
695 minimize_and_shrink_block (std::vector<int>::reverse_iterator &,
696 unsigned int &, unsigned int &, const int);
697 unsigned shrink_block (std::vector<int>::reverse_iterator &,
698 std::vector<int>::reverse_iterator &, int,
699 unsigned &, unsigned &, const int, unsigned);
700 unsigned shrink_along_reason (int, int, bool, bool &, unsigned);
701
702 void deallocate_clause (Clause *);
703 void delete_clause (Clause *);
704 void mark_garbage (Clause *);
705 void assign_original_unit (int64_t, int);
706 void add_new_original_clause (int64_t);
708 Clause *new_hyper_binary_resolved_clause (bool red, int glue);
709 Clause *new_clause_as (const Clause *orig);
711
712 // Forward reasoning through propagation in 'propagate.cpp'.
713 //
714 int assignment_level (int lit, Clause *);
715 void build_chain_for_units (int lit, Clause *reason, bool forced);
716 void build_chain_for_empty ();
717 void search_assign (int lit, Clause *);
718 void search_assign_driving (int lit, Clause *reason);
719 void search_assign_external (int lit);
720 void search_assume_decision (int decision);
721 void assign_unit (int lit);
722 int64_t cache_lines (size_t bytes) { return (bytes + 127) / 128; }
723 int64_t cache_lines (size_t n, size_t bytes) {
724 return cache_lines (n * bytes);
725 }
726 bool propagate ();
727
728#ifdef PROFILE_MODE
729 bool propagate_wrapper ();
730 bool propagate_unstable ();
731 bool propagate_stable ();
732 void analyze_wrapper ();
733 void analyze_unstable ();
734 void analyze_stable ();
735 int decide_wrapper ();
736 int decide_stable ();
737 int decide_unstable ();
738#else
739#define propagate_wrapper propagate
740#define analyze_wrapper analyze
741#define decide_wrapper decide
742#endif
743
744 void propergate (); // Repropagate without blocking literals.
745
746 // Undo and restart in 'backtrack.cpp'.
747 //
748 void unassign (int lit);
750 void backtrack (int target_level = 0);
751 void backtrack_without_updating_phases (int target_level = 0);
752
753 // Minimized learned clauses in 'minimize.cpp'.
754 //
755 bool minimize_literal (int lit, int depth = 0);
756 void minimize_clause ();
757 void calculate_minimize_chain (int lit, std::vector<int> &stack);
758
759 // Learning from conflicts in 'analyze.cc'.
760 //
761 void learn_empty_clause ();
762 void learn_unit_clause (int lit);
763
764 void bump_variable (int lit);
765 void bump_variables ();
766 int recompute_glue (Clause *);
767 void bump_clause (Clause *);
768 void bump_clause2 (Clause *);
771 void clear_analyzed_levels ();
773 bool bump_also_reason_literal (int lit);
774 void bump_also_reason_literals (int lit, int depth_limit,
775 size_t size_limit);
777 void analyze_literal (int lit, int &open, int &resolvent_size,
778 int &antecedent_size);
779 void analyze_reason (int lit, Clause *, int &open, int &resolvent_size,
780 int &antecedent_size);
781 Clause *new_driving_clause (const int glue, int &jump);
782 int find_conflict_level (int &forced);
784 void otfs_strengthen_clause (Clause *, int, int,
785 const std::vector<int> &);
786 void otfs_subsume_clause (Clause *subsuming, Clause *subsumed);
787 int otfs_find_backtrack_level (int &forced);
788 Clause *on_the_fly_strengthen (Clause *conflict, int lit);
790 void analyze ();
791 void iterate (); // report learned unit clause
792
793 // Learning from external propagator in 'external_propagate.cpp'
794 //
795 bool external_propagate ();
797 void add_external_clause (int propagated_lit = 0,
798 bool no_backtrack = false);
799 Clause *learn_external_reason_clause (int lit, int falsified_elit = 0,
800 bool no_backtrack = false);
803 void explain_reason (int lit, Clause *, int &open);
805 void handle_external_clause (Clause *);
806 void notify_assignments ();
807 void notify_decision ();
808 void notify_backtrack (size_t new_level);
809 void force_backtrack (size_t new_level);
810 int ask_decision ();
811 bool ask_external_clause ();
812 void add_observed_var (int ilit);
813 void remove_observed_var (int ilit);
814 bool observed (int ilit) const;
815 bool is_decision (int ilit);
817 void set_tainted_literal ();
820 void renotify_full_trail ();
821 void connect_propagator ();
822 void mark_garbage_external_forgettable (int64_t id);
823 bool is_external_forgettable (int64_t id);
824#ifndef CADICAL_NDEBUG
825 bool get_merged_literals (std::vector<int> &);
826 void get_all_fixed_literals (std::vector<int> &);
827#endif
828
829 void recompute_tier ();
830 // Use last learned clause to subsume some more.
831 //
833
834 // Restarting policy in 'restart.cc'.
835 //
836 bool stabilizing ();
837 bool restarting ();
838 int reuse_trail ();
839 void restart ();
840
841 // Functions to set and reset certain 'phases'.
842 //
843 void clear_phases (vector<signed char> &); // reset argument to zero
844 void copy_phases (vector<signed char> &); // copy 'saved' to argument
845
846 // Resetting the saved phased in 'rephase.cpp'.
847 //
848 bool rephasing ();
849 char rephase_best ();
850 char rephase_flipping ();
851 char rephase_inverted ();
852 char rephase_original ();
853 char rephase_random ();
854 char rephase_walk ();
855 void shuffle_scores ();
856 void shuffle_queue ();
857 void rephase ();
858
859 // Lucky feasible case checking.
860 //
861 int unlucky (int res);
871
872 // Asynchronous terminating check.
873 //
874 bool terminated_asynchronously (int factor = 1);
875
876 bool search_limits_hit ();
877
878 void terminate () {
879 LOG ("forcing asynchronous termination");
880 termination_forced = true;
881 }
882
883 // Reducing means determining useless clauses with 'reduce' in
884 // 'reduce.cpp' as well as root level satisfied clause and then removing
885 // those which are not used as reason anymore with garbage collection.
886 //
887 bool flushing ();
888 bool reducing ();
889 void protect_reasons ();
893 void unprotect_reasons ();
894 void reduce ();
895
896 // Garbage collection in 'collect.cpp' called from 'reduce' and during
897 // inprocessing and preprocessing.
898 //
902 void copy_clause (Clause *);
903 void flush_watches (int lit, Watches &);
904 size_t flush_occs (int lit);
909 void check_clause_stats ();
910 void check_var_stats ();
911 bool arenaing ();
912 void garbage_collection ();
913
914 // only remove binary clauses from the watches
916
917 // Set-up occurrence list counters and containers.
918 //
919 void init_occs ();
920 void init_bins ();
921 void init_noccs ();
922 void clear_noccs ();
923 void clear_occs ();
924 void reset_occs ();
925 void reset_bins ();
926 void reset_noccs ();
927
928 // Operators on watches.
929 //
930 void init_watches ();
931 void connect_watches (bool irredundant_only = false);
933 void sort_watches ();
934 void clear_watches ();
935 void reset_watches ();
936
937 // Regular forward subsumption checking in 'subsume.cpp'.
938 //
939 void strengthen_clause (Clause *, int);
940 void subsume_clause (Clause *subsuming, Clause *subsumed);
941 int subsume_check (Clause *subsuming, Clause *subsumed);
943 void reset_subsume_bits ();
944 bool subsume_round ();
945 void subsume ();
946
947 // Covered clause elimination of large clauses.
948 //
951 void cover_push_extension (int lit, Coveror &);
953 bool cover_propagate_covered (int lit, Coveror &);
954 bool cover_clause (Clause *c, Coveror &);
955 int64_t cover_round ();
956 bool cover ();
957
958 // Strengthening through vivification in 'vivify.cpp'.
959 //
960 void demote_clause (Clause *);
961 void flush_vivification_schedule (std::vector<Clause *> &, int64_t &);
963 void vivify_subsume_clause (Clause *subsuming, Clause *subsumed);
965 void vivify_initialize (Vivifier &vivifier, int64_t &ticks);
966 inline void vivify_prioritize_leftovers (char, size_t prioritized,
967 std::vector<Clause *> &schedule);
969 void vivify_sort_watched (Clause *c);
970 bool vivify_instantiate (
971 const std::vector<int> &, Clause *,
972 std::vector<std::tuple<int, Clause *, bool>> &lrat_stack,
973 int64_t &ticks);
974 void vivify_analyze_redundant (Vivifier &, Clause *start, bool &);
975 void vivify_build_lrat (int, Clause *,
976 std::vector<std::tuple<int, Clause *, bool>> &);
977 void vivify_chain_for_units (int lit, Clause *reason);
979 void vivify_assign (int lit, Clause *);
980 void vivify_assume (int lit);
981 bool vivify_propagate (int64_t &);
982 void vivify_deduce (Clause *candidate, Clause *conflct, int implied,
983 Clause **, bool &);
985 void vivify_analyze (Clause *start, bool &, Clause **,
986 const Clause *const, int implied, bool &);
987 bool vivify_shrinkable (const std::vector<int> &sorted, Clause *c);
988 void vivify_round (Vivifier &, int64_t delta);
989 bool vivify ();
990
991 // Compacting (shrinking internal variable tables) in 'compact.cpp'
992 //
993 bool compacting ();
994 void compact ();
995
996 // Transitive reduction of binary implication graph in 'transred.cpp'
997 //
998 void transred ();
999
1000 // We monitor the maximum size and glue of clauses during 'reduce' and
1001 // thus can predict if a redundant extended clause is likely to be kept in
1002 // the next 'reduce' phase. These clauses are target of subsumption and
1003 // vivification checks, in addition to irredundant clauses. Their
1004 // variables are also marked as being 'added'.
1005 //
1007 if (!c->redundant)
1008 return true;
1009 if (c->glue <= tier2[false])
1010 return true;
1011 if (c->glue > lim.keptglue)
1012 return false;
1013 if (c->size > lim.keptsize)
1014 return false;
1015 return true;
1016 }
1017
1018 // We mark variables in added or shrunken clauses as 'subsume' candidates
1019 // if the clause is likely to be kept in the next 'reduce' phase (see last
1020 // function above). This gives a persistent (across consecutive
1021 // interleaved search and inprocessing phases) set of variables which have
1022 // to be reconsidered in subsumption checks, i.e., only clauses with
1023 // 'subsume' marked variables are checked to be forward subsumed.
1024 // A similar technique is used to reduce the effort in hyper ternary
1025 // resolution to focus on variables in new ternary clauses.
1026 //
1027 void mark_subsume (int lit) {
1028 Flags &f = flags (lit);
1029 if (f.subsume)
1030 return;
1031 LOG ("marking %d as subsuming literal candidate", abs (lit));
1032 stats.mark.subsume++;
1033 f.subsume = true;
1034 }
1035 void mark_ternary (int lit) {
1036 Flags &f = flags (lit);
1037 if (f.ternary)
1038 return;
1039 LOG ("marking %d as ternary resolution literal candidate", abs (lit));
1040 stats.mark.ternary++;
1041 f.ternary = true;
1042 }
1043 void mark_factor (int lit) {
1044 Flags &f = flags (lit);
1045 const unsigned bit = bign (lit);
1046 if (f.factor & bit)
1047 return;
1048 LOG ("marking %d as factor literal candidate", lit);
1049 stats.mark.factor++;
1050 f.factor |= bit;
1051 }
1052 void mark_added (int lit, int size, bool redundant);
1053 void mark_added (Clause *);
1054
1055 bool marked_subsume (int lit) const { return flags (lit).subsume; }
1056
1057 // If irredundant clauses are removed or literals in clauses are removed,
1058 // then variables in such clauses should be reconsidered to be eliminated
1059 // through bounded variable elimination. In contrast to 'subsume' the
1060 // 'elim' flag is restricted to 'irredundant' clauses only. For blocked
1061 // clause elimination it is better to have a more precise signed version,
1062 // which allows to independently mark positive and negative literals.
1063 //
1064 void mark_elim (int lit) {
1065 Flags &f = flags (lit);
1066 if (f.elim)
1067 return;
1068 LOG ("marking %d as elimination literal candidate", lit);
1069 stats.mark.elim++;
1070 f.elim = true;
1071 }
1072 void mark_block (int lit) {
1073 Flags &f = flags (lit);
1074 const unsigned bit = bign (lit);
1075 if (f.block & bit)
1076 return;
1077 LOG ("marking %d as blocking literal candidate", lit);
1078 stats.mark.block++;
1079 f.block |= bit;
1080 }
1081 void mark_removed (int lit) {
1082 mark_elim (lit);
1083 mark_block (-lit);
1084 }
1085 void mark_removed (Clause *, int except = 0);
1086
1087 // The following two functions are only used for testing & debugging.
1088
1089 bool marked_block (int lit) const {
1090 const Flags &f = flags (lit);
1091 const unsigned bit = bign (lit);
1092 return (f.block & bit) != 0;
1093 }
1094 void unmark_block (int lit) {
1095 Flags &f = flags (lit);
1096 const unsigned bit = bign (lit);
1097 f.block &= ~bit;
1098 }
1099
1100 // During scheduling literals for blocked clause elimination we skip those
1101 // literals which occur negated in a too large clause.
1102 //
1103 void mark_skip (int lit) {
1104 Flags &f = flags (lit);
1105 const unsigned bit = bign (lit);
1106 if (f.skip & bit)
1107 return;
1108 LOG ("marking %d to be skipped as blocking literal", lit);
1109 f.skip |= bit;
1110 }
1111 bool marked_skip (int lit) {
1112 const Flags &f = flags (lit);
1113 const unsigned bit = bign (lit);
1114 return (f.skip & bit) != 0;
1115 }
1116
1117 // During decompose ignore literals where we already built LRAT chains
1118 //
1120 Flags &f = flags (lit);
1121 const unsigned bit = bign (lit);
1122 CADICAL_assert ((f.marked_signed & bit) == 0);
1123 sign_marked.push_back (lit);
1124 f.marked_signed |= bit;
1125 }
1127 Flags &f = flags (lit);
1128 const unsigned bit = bign (lit);
1129 f.marked_signed &= ~bit;
1130 }
1132 const Flags &f = flags (lit);
1133 const unsigned bit = bign (lit);
1134 return (f.marked_signed & bit) != 0;
1135 }
1137
1138 // Blocked Clause elimination in 'block.cpp'.
1139 //
1140 bool is_blocked_clause (Clause *c, int pivot);
1141 void block_schedule (Blocker &);
1142 size_t block_candidates (Blocker &, int lit);
1146 void block_pure_literal (Blocker &, int lit);
1147 void block_reschedule_clause (Blocker &, int lit, Clause *);
1148 void block_reschedule (Blocker &, int lit);
1149 void block_literal (Blocker &, int lit);
1150 bool block ();
1151
1152 // Find gates in 'gates.cpp' for bounded variable substitution.
1153 //
1156 void mark_binary_literals (Eliminator &, int pivot);
1157 void find_and_gate (Eliminator &, int pivot);
1158 void find_equivalence (Eliminator &, int pivot);
1159
1160 bool get_ternary_clause (Clause *, int &, int &, int &);
1161 bool match_ternary_clause (Clause *, int, int, int);
1162 Clause *find_ternary_clause (int, int, int);
1163
1164 bool get_clause (Clause *, vector<int> &);
1165 bool is_clause (Clause *, const vector<int> &);
1166 Clause *find_clause (const vector<int> &);
1167 void find_xor_gate (Eliminator &, int pivot);
1168
1169 void find_if_then_else (Eliminator &, int pivot);
1170
1171 Clause *find_binary_clause (int, int);
1172 void find_gate_clauses (Eliminator &, int pivot);
1174
1175 // mine definitions for cadical_kitten in 'definition.cpp'
1176 //
1177 void find_definition (Eliminator &, int);
1178 void init_citten ();
1179 void reset_citten ();
1181
1182 // Bounded variable elimination in 'elim.cpp'.
1183 //
1184 bool ineliminating ();
1185 double compute_elim_score (unsigned lit);
1188 bool resolve_clauses (Eliminator &, Clause *, int pivot, Clause *, bool);
1189 void mark_eliminated_clauses_as_garbage (Eliminator &, int pivot, bool &);
1190 bool elim_resolvents_are_bounded (Eliminator &, int pivot);
1192 void elim_update_removed_clause (Eliminator &, Clause *, int except = 0);
1194 void elim_add_resolvents (Eliminator &, int pivot);
1197 void elim_propagate (Eliminator &, int unit);
1199 void try_to_eliminate_variable (Eliminator &, int pivot, bool &);
1201 int elim_round (bool &completed, bool &);
1202 void elim (bool update_limits = true);
1203
1204 int64_t flush_elimfast_occs (int lit);
1205 void elimfast_add_resolvents (Eliminator &, int pivot);
1206 bool elimfast_resolvents_are_bounded (Eliminator &, int pivot);
1207 void try_to_fasteliminate_variable (Eliminator &, int pivot, bool &);
1208 int elimfast_round (bool &completed, bool &);
1209 void elimfast ();
1210
1211 // sweeping in 'sweep.cpp'
1212 int sweep_solve ();
1214 bool cadical_kitten_ticks_limit_hit (Sweeper &sweeper, const char *when);
1218 int sweep_repr (Sweeper &sweeper, int lit);
1219 void add_literal_to_environment (Sweeper &sweeper, unsigned depth, int);
1220 void sweep_clause (Sweeper &sweeper, unsigned depth, Clause *);
1221 void sweep_add_clause (Sweeper &sweeper, unsigned depth);
1222 void add_core (Sweeper &sweeper, unsigned core_idx);
1223 void save_core (Sweeper &sweeper, unsigned core);
1224 void clear_core (Sweeper &sweeper, unsigned core_idx);
1231 void flip_backbone_literals (struct Sweeper &sweeper);
1233 int64_t add_sweep_binary (sweep_proof_clause, int lit, int other);
1234 bool scheduled_variable (Sweeper &sweeper, int idx);
1235 void schedule_inner (Sweeper &sweeper, int idx);
1236 void schedule_outer (Sweeper &sweeper, int idx);
1238 void substitute_connected_clauses (Sweeper &sweeper, int lit, int other,
1239 int64_t id);
1240 void sweep_remove (Sweeper &sweeper, int lit);
1242 const char *sweep_variable (Sweeper &sweeper, int idx);
1243 bool scheduable_variable (Sweeper &sweeper, int idx, size_t *occ_ptr);
1245 bool sweep_equivalence_candidates (Sweeper &sweeper, int lit, int other);
1247 unsigned incomplete_variables ();
1249 unsigned schedule_sweeping (Sweeper &sweeper);
1250 void unschedule_sweeping (Sweeper &sweeper, unsigned swept,
1251 unsigned scheduled);
1252 bool sweep ();
1254 void sweep_sparse_mode ();
1256 void sweep_substitute_lrat (Clause *c, int64_t id);
1258 void sweep_update_noccs (Clause *c);
1259 void delete_sweep_binary (const sweep_binary &sb);
1260 bool can_sweep_clause (Clause *c);
1261 bool sweep_flip (int);
1262 int sweep_flip_and_implicant (int);
1264
1265 // factor
1266 void factor_mode ();
1267 void reset_factor_mode ();
1268 double tied_next_factor_score (int);
1271 size_t first_factor (Factoring &, int);
1272 void clear_nounted (vector<int> &);
1274 Quotient *best_quotient (Factoring &, size_t *);
1275 int next_factor (Factoring &, unsigned *);
1276 void factorize_next (Factoring &, int, unsigned);
1281 void add_factored_divider (Quotient *, int);
1282 void blocked_clause (Quotient *q, int);
1283 void add_factored_quotient (Quotient *, int not_fresh);
1285 void delete_unfactored (Quotient *q);
1288 void update_factor_candidate (Factoring &, int);
1290 bool run_factorization (int64_t limit);
1291 bool factor ();
1294
1295 // instantiate
1296 //
1297 void inst_assign (int lit);
1298 bool inst_propagate ();
1300 bool instantiate_candidate (int lit, Clause *);
1301 void instantiate (Instantiator &);
1302
1303 void new_trail_level (int lit);
1304
1305 // Hyper ternary resolution.
1306 //
1307 bool ternary_find_binary_clause (int, int);
1308 bool ternary_find_ternary_clause (int, int, int);
1311 bool hyper_ternary_resolve (Clause *, int, Clause *);
1312 void ternary_lit (int pivot, int64_t &steps, int64_t &htrs);
1313 void ternary_idx (int idx, int64_t &steps, int64_t &htrs);
1314 bool ternary_round (int64_t &steps, int64_t &htrs);
1315 bool ternary ();
1316
1317 // Probing in 'probe.cpp'.
1318 //
1319 bool inprobing ();
1320 void failed_literal (int lit);
1321 void probe_lrat_for_units (int lit);
1322 void probe_assign_unit (int lit);
1323 void probe_assign_decision (int lit);
1324 void probe_assign (int lit, int parent);
1327 void set_parent_reason_literal (int lit, int reason);
1328 void clean_probehbr_lrat ();
1329 void init_probehbr_lrat ();
1330 void get_probehbr_lrat (int lit, int uip);
1331 void set_probehbr_lrat (int lit, int uip);
1333 void probe_dominator_lrat (int dom, Clause *reason);
1334 int probe_dominator (int a, int b);
1336 void probe_propagate2 ();
1337 bool probe_propagate ();
1338 bool is_binary_clause (Clause *c, int &, int &);
1339 void generate_probes ();
1340 void flush_probes ();
1341 int next_probe ();
1342 bool probe ();
1343 void inprobe (bool update_limits = true);
1344
1345 // ProbSAT/WalkSAT implementation called initially or from 'rephase'.
1346 //
1347 void walk_save_minimum (Walker &);
1349 unsigned walk_break_value (int lit);
1350 int walk_pick_lit (Walker &, Clause *);
1351 void walk_flip_lit (Walker &, int lit);
1352 int walk_round (int64_t limit, bool prev);
1353 void walk ();
1354
1355 // Detect strongly connected components in the binary implication graph
1356 // (BIG) and equivalent literal substitution (ELS) in 'decompose.cpp'.
1357 //
1359 void build_lrat_for_clause (const vector<vector<Clause *>> &dfs_chains,
1360 bool invert = false);
1362 void decompose_analyze_binary_chain (DFS *dfs, int);
1363 bool decompose_round ();
1364 void decompose ();
1365
1366 void reset_limits (); // Reset after 'solve' call.
1367
1368 // Try flipping a literal while not falsifying a model.
1369
1370 bool flip (int lit);
1371 bool flippable (int lit);
1372
1373 // Assumption handling.
1374 //
1375 void assume_analyze_literal (int lit);
1376 void assume_analyze_reason (int lit, Clause *reason);
1377 void assume (int); // New assumption literal.
1378 bool failed (int lit); // Literal failed assumption?
1379 void reset_assumptions (); // Reset after 'solve' call.
1380 void sort_and_reuse_assumptions (); // reorder the assumptions in order to
1381 // reuse parts of the trail
1382 void failing (); // Prepare failed assumptions.
1383
1384 bool assumed (int lit) { // Marked as assumption.
1385 Flags &f = flags (lit);
1386 const unsigned bit = bign (lit);
1387 return (f.assumed & bit) != 0;
1388 }
1389
1390 // Add temporary clause as constraint.
1391 //
1392 void constrain (int); // Add literal to constraint.
1393 bool
1394 failed_constraint (); // Was constraint used to proof unsatisfiablity?
1395 void reset_constraint (); // Reset after 'solve' call.
1396
1397 // Propagate the current set of assumptions and return the
1398 // non-witness assigned literals
1399 int propagate_assumptions ();
1400 void implied (std::vector<int> &entrailed);
1401
1402 // Forcing decision variables to a certain phase.
1403 //
1404 void phase (int lit);
1405 void unphase (int lit);
1406
1407 // Globally blocked clause elimination.
1408 //
1409 bool is_autarky_literal (int lit) const;
1410 bool is_conditional_literal (int lit) const;
1413 //
1414 bool is_in_candidate_clause (int lit) const;
1415 void mark_in_candidate_clause (int lit);
1417 //
1418 void condition_assign (int lit);
1419 void condition_unassign (int lit);
1420 //
1421 bool conditioning ();
1422 long condition_round (long unassigned_literal_propagation_limit);
1423 void condition (bool update_limits = true);
1424
1425 // Part on picking the next decision in 'decide.cpp'.
1426 //
1427 bool satisfied ();
1431 int decide_phase (int idx, bool target);
1432 int likely_phase (int idx);
1433 bool better_decision (int lit, int other);
1434 int decide (); // 0=decision, 20=failed
1435
1436 // Internal functions to enable explicit search limits.
1437 //
1438 void limit_terminate (int);
1439 void limit_decisions (int); // Force decision limit.
1440 void limit_conflicts (int); // Force conflict limit.
1441 void limit_preprocessing (int); // Enable 'n' preprocessing rounds.
1442 void limit_local_search (int); // Enable 'n' local search rounds.
1443
1444 // External versions can access limits by 'name'.
1445 //
1446 static bool is_valid_limit (const char *name);
1447 bool limit (const char *name, int); // 'true' if 'name' valid
1448
1449 // Set all the CDCL search limits and increments for scheduling
1450 // inprocessing, restarts, clause database reductions, etc.
1451 //
1452 void init_report_limits ();
1454 void init_search_limits ();
1455
1456 // The computed averages are local to the 'stable' and 'unstable' phase.
1457 // Their main use is to be reported in 'report', except for the 'glue'
1458 // averages, which are used to schedule (prohibit actually) restarts
1459 // during 'unstable' phases ('stable' phases use reluctant doubling).
1460 //
1461 void init_averages ();
1462 void swap_averages ();
1463
1466
1467 // Main solve & search functions in 'internal.cpp'.
1468 //
1469 // We have three pre-solving techniques. These consist of preprocessing,
1470 // local search and searching for lucky phases, which in full solving
1471 // mode except for the last are usually optional and then followed by
1472 // the main CDCL search loop with inprocessing. If only preprocessing
1473 // is requested from 'External::simplify' only preprocessing is called
1474 // though. This is all orchestrated by the 'solve' function.
1475 //
1476 int already_solved ();
1477 int restore_clauses ();
1478 bool preprocess_round (int round);
1479 void preprocess_quickly ();
1480 int preprocess ();
1481 int local_search_round (int round);
1482 int local_search ();
1483 int lucky_phases ();
1485 void reset_solving ();
1486 int solve (bool preprocess_only = false);
1487 void finalize (int);
1488
1489 //
1490 int lookahead ();
1493 int lookahead_probing ();
1494 int lookahead_next_probe ();
1495 void lookahead_flush_probes ();
1497 std::vector<int> lookahead_populate_locc ();
1498 int lookahead_locc (const std::vector<int> &);
1499
1500 bool terminating_asked ();
1501
1502#ifndef CADICAL_QUIET
1503 // Built in profiling in 'profile.cpp' (see also 'profile.hpp').
1504 //
1505 void start_profiling (Profile &p, double);
1506 void stop_profiling (Profile &p, double);
1507
1508 double update_profiles (); // Returns 'time ()'.
1509 void print_profile ();
1510#endif
1511
1512 // Get the value of an internal literal: -1=false, 0=unassigned, 1=true.
1513 // We use a redundant table for both negative and positive literals. This
1514 // allows a branch-less check for the value of literal and is considered
1515 // substantially faster than negating the result if the argument is
1516 // negative. We also avoid taking the absolute value.
1517 //
1518 signed char val (int lit) const {
1522 return vals[lit];
1523 }
1524
1525 // As suggested by Matt Ginsberg it might be useful to factor-out a common
1526 // setter function for setting and resetting the value of a literal.
1527 //
1528 void set_val (int lit, signed char val) {
1529 CADICAL_assert (-1 <= val);
1530 CADICAL_assert (val <= 1);
1534 vals[lit] = val;
1535 vals[-lit] = -val;
1536 }
1537
1538 // As 'val' but restricted to the root-level value of a literal.
1539 // It is not that time critical and also needs to check the decision level
1540 // of the variable anyhow.
1541 //
1542 int fixed (int lit) {
1546 const int idx = vidx (lit);
1547 int res = vals[idx];
1548 if (res && vtab[idx].level)
1549 res = 0;
1550 if (lit < 0)
1551 res = -res;
1552 return res;
1553 }
1554
1555 // Map back an internal literal to an external.
1556 //
1557 int externalize (int lit) {
1558 CADICAL_assert (lit != INT_MIN);
1559 const int idx = abs (lit);
1560 CADICAL_assert (idx);
1561 CADICAL_assert (idx <= max_var);
1562 int res = i2e[idx];
1563 if (lit < 0)
1564 res = -res;
1565 return res;
1566 }
1567
1568 // Explicit freezing and melting of variables.
1569 //
1570 void freeze (int lit) {
1571 int idx = vidx (lit);
1572 if ((size_t) idx >= frozentab.size ()) {
1573 size_t new_vsize = vsize ? 2 * vsize : 1 + (size_t) max_var;
1574 while (new_vsize <= (size_t) max_var)
1575 new_vsize *= 2;
1576 frozentab.resize (new_vsize);
1577 }
1578 unsigned &ref = frozentab[idx];
1579 if (ref < UINT_MAX) {
1580 ref++;
1581 LOG ("variable %d frozen %u times", idx, ref);
1582 } else
1583 LOG ("variable %d remains frozen forever", idx);
1584 }
1585 void melt (int lit) {
1586 int idx = vidx (lit);
1587 unsigned &ref = frozentab[idx];
1588 if (ref < UINT_MAX) {
1589 if (!--ref) {
1590 if (relevanttab[idx]) {
1591 LOG ("variable %d is observed, can not be completely molten",
1592 idx);
1593 ref++;
1594 } else
1595 LOG ("variable %d completely molten", idx);
1596 } else
1597 LOG ("variable %d melted once but remains frozen %u times", lit,
1598 ref);
1599 } else
1600 LOG ("variable %d remains frozen forever", idx);
1601 }
1602 bool frozen (int lit) {
1603 return (size_t) vidx (lit) < frozentab.size () &&
1604 frozentab[vidx (lit)] > 0;
1605 }
1606
1607 // Congruence closure
1608 bool extract_gates ();
1609
1610 // Parsing functions in 'parse.cpp'.
1611 //
1612 const char *parse_dimacs (FILE *);
1613 const char *parse_dimacs (const char *);
1614 const char *parse_solution (const char *);
1615
1616 // Enable and disable proof logging and checking.
1617 //
1618 void new_proof_on_demand ();
1619 void force_lrat (); // sets lrat=true
1620 void resize_unit_clauses_idx (); // resizes unit_clauses_idx
1621 void close_trace (bool stats = false); // Stop proof tracing.
1622 void flush_trace (bool stats = false); // Flush proof trace file.
1623 void trace (File *); // Start write proof file.
1624 void check (); // Enable online proof checking.
1625
1626 void connect_proof_tracer (Tracer *tracer, bool antecedents,
1627 bool finalize_clauses = false);
1628 void connect_proof_tracer (InternalTracer *tracer, bool antecedents,
1629 bool finalize_clauses = false);
1630 void connect_proof_tracer (StatTracer *tracer, bool antecedents,
1631 bool finalize_clauses = false);
1632 void connect_proof_tracer (FileTracer *tracer, bool antecedents,
1633 bool finalize_clauses = false);
1634 bool disconnect_proof_tracer (Tracer *tracer);
1635 bool disconnect_proof_tracer (StatTracer *tracer);
1636 bool disconnect_proof_tracer (FileTracer *tracer);
1637 void conclude_unsat ();
1638 void reset_concluded ();
1639
1640 // Dump to '<stdout>' as DIMACS for debugging.
1641 //
1642 void dump (Clause *);
1643 void dump ();
1644
1645 // Export and traverse all irredundant (non-unit) clauses.
1646 //
1648
1649 // Export and traverse all irredundant (non-unit) clauses.
1650 //
1652
1653 /*----------------------------------------------------------------------*/
1654
1655 double solve_time (); // accumulated time spent in 'solve ()'
1656
1657 double process_time () const; // since solver was initialized
1658 double real_time () const; // since solver was initialized
1659
1660 double time () { return opts.realtime ? real_time () : process_time (); }
1661
1662 // Regularly reports what is going on in 'report.cpp'.
1663 //
1664 void report (char type, int verbose_level = 0);
1665 void report_solving (int);
1666
1667 void print_statistics ();
1668 void print_resource_usage ();
1669
1670 /*----------------------------------------------------------------------*/
1671
1672#ifndef CADICAL_QUIET
1673
1674 void print_prefix ();
1675
1676 // Non-verbose messages and warnings, i.e., always printed unless 'quiet'
1677 // is set, which disables messages at run-time, or even 'CADICAL_QUIET' is defined
1678 // through the configuration option './configure --quiet', which disables
1679 // such messages completely at compile-time.
1680 //
1681 void vmessage (const char *, va_list &);
1682 void message (const char *, ...) CADICAL_ATTRIBUTE_FORMAT (2, 3);
1683 void message (); // empty line
1684
1685 // Verbose messages with explicit verbose 'level' controlled by
1686 // 'opts.verbose' (verbose level '0' gives the same as 'message').
1687 //
1688 void vverbose (int level, const char *fmt, va_list &);
1689 void verbose (int level, const char *fmt, ...)
1691 void verbose (int level);
1692
1693 // This is for printing section headers in the form
1694 //
1695 // c ---- [ <title> ] ---------------------
1696 //
1697 // nicely aligned (and of course is ignored if 'quiet' is set).
1698 //
1699 void section (const char *title);
1700
1701 // Print verbose message about phases if 'opts.verbose > 1' (but not if
1702 // 'quiet' is set). Note that setting 'log' or '-l' forces all verbose
1703 // output (and also ignores 'quiet' set to true'). The 'phase' argument
1704 // is used to print a 'phase' prefix for the message as follows:
1705 //
1706 // c [<phase>] ...
1707 //
1708 void phase (const char *phase, const char *, ...)
1710
1711 // Same as the last 'phase' above except that the prefix gets a count:
1712 //
1713 // c [<phase>-<count>] ...
1714 //
1715 void phase (const char *phase, int64_t count, const char *, ...)
1717#endif
1718
1719 // Print error messages which are really always printed (even if 'quiet'
1720 // is set). This leads to exit the current process with exit status '1'.
1721 //
1722 // TODO add possibility to use a call back instead of calling exit.
1723 //
1724 void error_message_end ();
1725 void verror (const char *, va_list &);
1726 void error (const char *, ...) CADICAL_ATTRIBUTE_FORMAT (2, 3);
1727 void error_message_start ();
1728
1729 // Warning messages.
1730 //
1731 void warning (const char *, ...) CADICAL_ATTRIBUTE_FORMAT (2, 3);
1732};
1733
1734// Fatal internal error which leads to abort.
1735//
1736void fatal_message_start ();
1737void fatal_message_end ();
1738void fatal (const char *, ...) CADICAL_ATTRIBUTE_FORMAT (1, 2);
1739
1740/*------------------------------------------------------------------------*/
1741
1742// Has to be put here, i.e., not into 'score.hpp', since we need the
1743// definition of 'Internal::score' above (after '#include "score.hpp"').
1744
1745inline bool score_smaller::operator() (unsigned a, unsigned b) {
1746
1747 // Avoid computing twice 'abs' in 'score ()'.
1748 //
1749 CADICAL_assert (1 <= a);
1750 CADICAL_assert (a <= (unsigned) internal->max_var);
1751 CADICAL_assert (1 <= b);
1752 CADICAL_assert (b <= (unsigned) internal->max_var);
1753 double s = internal->stab[a];
1754 double t = internal->stab[b];
1755
1756 if (s < t)
1757 return true;
1758 if (s > t)
1759 return false;
1760
1761 return a > b;
1762}
1763
1764/*------------------------------------------------------------------------*/
1765
1766// Implemented here for keeping it all inline (requires Internal::fixed).
1767
1768inline int External::fixed (int elit) const {
1769 CADICAL_assert (elit);
1770 CADICAL_assert (elit != INT_MIN);
1771 int eidx = abs (elit);
1772 if (eidx > max_var)
1773 return 0;
1774 int ilit = e2i[eidx];
1775 if (!ilit)
1776 return 0;
1777 if (elit < 0)
1778 ilit = -ilit;
1779 return internal->fixed (ilit);
1780}
1781
1782/*------------------------------------------------------------------------*/
1783
1784// We want to have termination checks inlined, particularly the first
1785// function which appears in preprocessor loops. Even though this first
1786// 'termination_forced' is set asynchronously, this should not lead to a
1787// data race issue (it also has been declared 'volatile').
1788
1790 // First way of asynchronous termination is through 'terminate' which sets
1791 // the 'termination_forced' flag directly. The second way is through a
1792 // call back to a 'terminator' if it is non-zero, which however is costly.
1793 //
1794 if (termination_forced) {
1795 LOG ("termination asynchronously forced");
1796 return true;
1797 }
1798
1799 // This is only for testing and debugging asynchronous termination calls.
1800 // In production code this could be removed but then should not be costly
1801 // and keeping it will allow to test correctness of asynchronous
1802 // termination on the production platform too. After this triggers we
1803 // have to set the 'termination_forced' flag, such that subsequent calls
1804 // to this function do not check this again.
1805 //
1806 if (lim.terminate.forced) {
1807 CADICAL_assert (lim.terminate.forced > 0);
1808 if (lim.terminate.forced-- == 1) {
1809 LOG ("internally forcing termination");
1810 termination_forced = true;
1811 return true;
1812 }
1813 LOG ("decremented internal forced termination limit to %d",
1814 lim.terminate.forced);
1815 }
1816
1817 // The second way of asynchronous termination is through registering and
1818 // calling an external 'Terminator' object. This is of course more costly
1819 // than just checking a (volatile though) boolean flag, particularly in
1820 // tight loops. To avoid this cost we only call the terminator in
1821 // intervals of 'opts.terminateint', which in addition can be scaled up by
1822 // the argument 'factor'. If the terminator returns 'true' we set the
1823 // 'termination_forced' flag to 'true' in order to remember the
1824 // termination status and to avoid the terminator again. Setting this
1825 // flag leads to the first test above to succeed in subsequent calls.
1826 //
1827 if (external->terminator && !lim.terminate.check--) {
1828 CADICAL_assert (factor > 0);
1829 CADICAL_assert (INT_MAX / factor > opts.terminateint);
1830 lim.terminate.check = factor * opts.terminateint;
1831 if (external->terminator->terminate ()) {
1832 termination_forced = true; // Cache it.
1833 LOG ("connected terminator forces termination");
1834 return true;
1835 }
1836 }
1837
1838 return false;
1839}
1840
1841/*------------------------------------------------------------------------*/
1842
1846
1847 if (lim.conflicts >= 0 && stats.conflicts >= lim.conflicts) {
1848 LOG ("conflict limit %" PRId64 " reached", lim.conflicts);
1849 return true;
1850 }
1851
1852 if (lim.decisions >= 0 && stats.decisions >= lim.decisions) {
1853 LOG ("decision limit %" PRId64 " reached", lim.decisions);
1854 return true;
1855 }
1856
1857 return false;
1858}
1859
1860/*------------------------------------------------------------------------*/
1861
1862} // namespace CaDiCaL
1863
1865
1866#endif
#define ABC_NAMESPACE_CXX_HEADER_START
#define ABC_NAMESPACE_CXX_HEADER_END
#define CADICAL_assert(ignore)
Definition global.h:14
#define CADICAL_ATTRIBUTE_FORMAT(FORMAT_POSITION, VARIADIC_ARGUMENT_POSITION)
Definition cadical.hpp:1105
#define LOG(...)
Definition reap.hpp:11
bool trace
Definition globals.c:36
Cube * p
Definition exorList.c:222
type
CUBE COVER and CUBE typedefs ///.
Definition exor.h:90
#define propagate_wrapper
Definition internal.hpp:739
#define analyze_wrapper
Definition internal.hpp:740
#define decide_wrapper
Definition internal.hpp:741
#define inline
Definition kitPerm.c:28
char * name
Definition main.h:24
unsigned bign(int lit)
Definition util.hpp:23
vector< Bin > Bins
Definition bins.hpp:19
void fatal_message_start()
void remove_watch(Watches &ws, Clause *clause)
Definition watch.hpp:50
int sign(int lit)
Definition util.hpp:22
double relative(double a, double b)
Definition util.hpp:20
std::vector< Link > Links
Definition queue.hpp:21
void fatal_message_end()
void fatal(const char *fmt,...)
vector< Clause * > Occs
Definition occs.hpp:18
const char * flags()
vector< Watch > Watches
Definition watch.hpp:45
heap< score_smaller > ScoreSchedule
Definition score.hpp:16
int lit
Definition satVec.h:130
std::vector< std::vector< int > > cubes
Definition internal.hpp:131
Internal * internal
Definition external.hpp:61
vector< int > e2i
Definition external.hpp:67
int fixed(int elit) const
unsigned char marked_signed
Definition flags.hpp:32
unsigned char skip
Definition flags.hpp:38
unsigned char block
Definition flags.hpp:37
unsigned char assumed
Definition flags.hpp:42
unsigned char factor
Definition flags.hpp:33
void vivify_round(Vivifier &, int64_t delta)
Clause * new_factor_clause()
bool is_blocked_clause(Clause *c, int pivot)
void unsetbit(int lit, int bit)
Definition internal.hpp:546
double clause_variable_ratio() const
Definition internal.hpp:385
bool cover_clause(Clause *c, Coveror &)
int & propfixed(int lit)
Definition internal.hpp:456
void increase_elimination_bound()
const char * parse_solution(const char *)
unsigned shrunken_block_uip(int, int, std::vector< int >::reverse_iterator &, std::vector< int >::reverse_iterator &, std::vector< int >::size_type, const int)
void elim_update_removed_lit(Eliminator &, int lit)
void citten_clear_track_log_terminate()
void elimfast_add_resolvents(Eliminator &, int pivot)
int next_decision_variable_with_best_score()
void update_queue_unassigned(int idx)
Definition internal.hpp:652
void save_add_clear_core(Sweeper &sweeper)
void mark_duplicated_binary_clauses_as_garbage()
void watch_literal(int lit, int blit, Clause *c)
Definition internal.hpp:623
void mark_shrinkable_as_removable(int, std::vector< int >::size_type)
bool marked_block(int lit) const
External * external
Definition internal.hpp:312
int64_t cache_lines(size_t bytes)
Definition internal.hpp:722
unsigned schedule_all_other_not_scheduled_yet(Sweeper &sweeper)
vector< int > ptab
Definition internal.hpp:238
int try_to_subsume_clause(Clause *, vector< Clause * > &shrunken)
bool get_clause(Clause *, vector< int > &)
bool vivify_clause(Vivifier &, Clause *candidate)
void try_to_fasteliminate_variable(Eliminator &, int pivot, bool &)
void sweep_dense_propagate(Sweeper &sweeper)
void condition_assign(int lit)
Clause * find_binary_clause(int, int)
int64_t irredundant() const
Definition internal.hpp:383
void mark_decomposed(int lit)
void elim_backward_clause(Eliminator &, Clause *)
vector< unsigned > relevanttab
Definition internal.hpp:225
void inprobe(bool update_limits=true)
void unschedule_sweeping(Sweeper &sweeper, unsigned swept, unsigned scheduled)
vector< int > analyzed
Definition internal.hpp:267
void block_reschedule_clause(Blocker &, int lit, Clause *)
void sweep_refine(Sweeper &sweeper)
void mark67(int lit)
Definition internal.hpp:504
void flush_trace(bool stats=false)
void elim_update_added_clause(Eliminator &, Clause *)
int next_scheduled(Sweeper &sweeper)
long condition_round(long unassigned_literal_propagation_limit)
void sweep_update_noccs(Clause *c)
unsigned incomplete_variables()
void covered_literal_addition(int lit, Coveror &)
void copy_clause(Clause *)
void vivify_sort_watched(Clause *c)
void unwatch_clause(Clause *c)
Definition internal.hpp:640
void add_literal_to_environment(Sweeper &sweeper, unsigned depth, int)
void new_trail_level(int lit)
void promote_clause_glue_only(Clause *, int new_glue)
Var & var(int lit)
Definition internal.hpp:452
void assume_analyze_literal(int lit)
void sweep_substitute_lrat(Clause *c, int64_t id)
size_t first_factor(Factoring &, int)
int64_t cache_lines(size_t n, size_t bytes)
Definition internal.hpp:723
Delay delaying_vivify_irredundant
Definition internal.hpp:291
vector< StatTracer * > stat_tracers
Definition internal.hpp:299
unsigned reschedule_previously_remaining(Sweeper &sweeper)
void unmark_in_candidate_clause(int lit)
Clause * new_hyper_ternary_resolved_clause_and_watch(bool red, bool)
void block_literal_with_at_least_two_negative_occs(Blocker &, int lit)
Quotient * best_quotient(Factoring &, size_t *)
void mark_garbage(Clause *)
double scale(double v) const
bool ext_clause_forgettable
Definition internal.hpp:249
vector< unsigned > frozentab
Definition internal.hpp:223
void vivify_prioritize_leftovers(char, size_t prioritized, std::vector< Clause * > &schedule)
vector< int64_t > lrat_chain
Definition internal.hpp:210
vector< int64_t > gtab
Definition internal.hpp:235
Clause * wrapped_learn_external_reason_clause(int lit)
int second_literal_in_binary_clause(Eliminator &, Clause *, int first)
int elim_round(bool &completed, bool &)
vector< int64_t > unit_clauses_idx
Definition internal.hpp:209
void assume_analyze_reason(int lit, Clause *reason)
bool searching_lucky_phases
Definition internal.hpp:189
void bump_clause(Clause *)
int vidx(int lit) const
Definition internal.hpp:395
cadical_kitten * citten
Definition internal.hpp:277
bool scheduled_variable(Sweeper &sweeper, int idx)
void bump_also_reason_literals(int lit, int depth_limit, size_t size_limit)
vector< int > constraint
Definition internal.hpp:262
void flush_watches(int lit, Watches &)
void init_scores(int old_max_var, int new_max_var)
void force_backtrack(size_t new_level)
void setbit(int lit, int bit)
Definition internal.hpp:540
vector< Bins > big
Definition internal.hpp:240
bool is_binary_clause(Clause *c, int &, int &)
void report(char type, int verbose_level=0)
bool cadical_kitten_ticks_limit_hit(Sweeper &sweeper, const char *when)
bool bump_also_reason_literal(int lit)
void sweep_add_clause(Sweeper &sweeper, unsigned depth)
void void error_message_start()
void probe_post_dominator_lrat(vector< Clause * > &, int, int)
void mark_redundant_clauses_with_eliminated_variables_as_garbage()
Clause * new_learned_redundant_clause(int glue)
void decompose_analyze_binary_chain(DFS *dfs, int)
int u2i(unsigned u)
Definition internal.hpp:412
void error(const char *,...) CADICAL_ATTRIBUTE_FORMAT(2
void sweep_remove(Sweeper &sweeper, int lit)
void mark_ternary(int lit)
bool is_conditional_literal(int lit) const
void unphase(int lit)
void unmark(int lit)
Definition internal.hpp:490
void add_external_clause(int propagated_lit=0, bool no_backtrack=false)
void block_literal(Blocker &, int lit)
bool get_ternary_clause(Clause *, int &, int &, int &)
void implied(std::vector< int > &entrailed)
const Flags & flags(int lit) const
Definition internal.hpp:459
bool run_factorization(int64_t limit)
void find_if_then_else(Eliminator &, int pivot)
Flags & flags(int lit)
Definition internal.hpp:454
void factorize_next(Factoring &, int, unsigned)
void find_equivalence(Eliminator &, int pivot)
int local_search_round(int round)
vector< int > trail
Definition internal.hpp:259
void mark(int lit)
Definition internal.hpp:484
void close_trace(bool stats=false)
static bool is_valid_limit(const char *name)
bool in_mode(Mode m) const
Definition internal.hpp:164
int fixed(int lit)
Clause * walk_pick_clause(Walker &)
void find_gate_clauses(Eliminator &, int pivot)
void unmark67(int lit)
Definition internal.hpp:517
void vivify_analyze_redundant(Vivifier &, Clause *start, bool &)
Bins & bins(int lit)
Definition internal.hpp:464
const unsigned max_used
Definition internal.hpp:314
bool is_clause(Clause *, const vector< int > &)
bool terminated_asynchronously(int factor=1)
Clause * block_impossible(Blocker &, int lit)
const Sange lits
Definition internal.hpp:325
void mark_removed(int lit)
vector< Tracer * > tracers
Definition internal.hpp:296
void promote_clause(Clause *, int new_glue)
void add_new_original_clause(int64_t)
bool disconnect_proof_tracer(Tracer *tracer)
void vivify_assume(int lit)
unsigned schedule_sweeping(Sweeper &sweeper)
CubesWithStatus generate_cubes(int, int)
void update_factored(Factoring &factoring, Quotient *q)
void eagerly_remove_from_occurences(Clause *c)
int externalize(int lit)
void limit_local_search(int)
void shrunken_block_no_uip(const std::vector< int >::reverse_iterator &, const std::vector< int >::reverse_iterator &, unsigned &, const int)
Clause * on_the_fly_strengthen(Clause *conflict, int lit)
Clause * dummy_binary
Definition internal.hpp:244
void mark_garbage_external_forgettable(int64_t id)
void flush_vivification_schedule(std::vector< Clause * > &, int64_t &)
void vivify_increment_stats(const Vivifier &vivifier)
bool self_subsuming_factor(Quotient *)
void watch_clause(Clause *c)
Definition internal.hpp:633
int64_t saved_decisions
Definition internal.hpp:205
void limit_terminate(int)
void sweep_set_cadical_kitten_ticks_limit(Sweeper &sweeper)
void cover_push_extension(int lit, Coveror &)
Link & link(int lit)
Definition internal.hpp:453
bool can_sweep_clause(Clause *c)
void clear_flauses(vector< Clause * > &)
void verror(const char *, va_list &)
void resize_factoring(Factoring &factoring, int lit)
void mark_substituted(int)
vector< Var > vtab
Definition internal.hpp:231
void schedule_outer(Sweeper &sweeper, int idx)
void clear_sweeper(Sweeper &sweeper)
void init_queue(int old_max_var, int new_max_var)
void find_and_gate(Eliminator &, int pivot)
void remove_falsified_literals(Clause *)
bool marked_subsume(int lit) const
bool frozen(int lit)
bool better_decision(int lit, int other)
void mark_eliminated(int)
bool marked_skip(int lit)
void warning(const char *,...) CADICAL_ATTRIBUTE_FORMAT(2
void vivify_subsume_clause(Clause *subsuming, Clause *subsumed)
bool resolve_clauses(Eliminator &, Clause *, int pivot, Clause *, bool)
void release_sweeper(Sweeper &sweeper)
void clear_phases(vector< signed char > &)
void block_pure_literal(Blocker &, int lit)
void condition(bool update_limits=true)
void probe_assign_unit(int lit)
void mark_as_conditional_literal(int lit)
bool apply_factoring(Factoring &factoring, Quotient *q)
void block_reschedule(Blocker &, int lit)
const char * sweep_variable(Sweeper &sweeper, int idx)
void try_to_eliminate_variable(Eliminator &, int pivot, bool &)
int decide_phase(int idx, bool target)
void search_assume_decision(int decision)
bool propagate_out_of_order_units()
void otfs_strengthen_clause(Clause *, int, int, const std::vector< int > &)
void finish_added_clause_with_id(int64_t id, bool restore=false)
int sweep_flip_and_implicant(int)
void calculate_minimize_chain(int lit, std::vector< int > &stack)
void unmark_block(int lit)
void demote_clause(Clause *)
void walk_flip_lit(Walker &, int lit)
Clause * learn_external_reason_clause(int lit, int falsified_elit=0, bool no_backtrack=false)
int shrink_literal(int, int, unsigned)
Clause * find_clause(const vector< int > &)
void sweep_empty_clause(Sweeper &sweeper)
void sweep_substitute_new_equivalences(Sweeper &sweeper)
void elim(bool update_limits=true)
vector< int64_t > conclusion
Definition internal.hpp:207
void eagerly_subsume_recently_learned_clauses(Clause *)
bool watching() const
Definition internal.hpp:462
void add_factored_quotient(Quotient *, int not_fresh)
signed char val(int lit) const
bool limit(const char *name, int)
vector< Clause * > inst_chain
Definition internal.hpp:214
void flush_unmatched_clauses(Quotient *)
signed char marked(int lit) const
Definition internal.hpp:478
int64_t unit_id(int lit) const
Definition internal.hpp:434
void collect_instantiation_candidates(Instantiator &)
bool traverse_constraint(ClauseIterator &)
void unmark_gate_clauses(Eliminator &)
int64_t flush_elimfast_occs(int lit)
void connect_proof_tracer(Tracer *tracer, bool antecedents, bool finalize_clauses=false)
vector< int > i2e
Definition internal.hpp:224
void add_original_lit(int lit)
bool minimize_literal(int lit, int depth=0)
int clause_contains_fixed_literal(Clause *)
void schedule_factorization(Factoring &)
double process_time() const
vector< int64_t > unit_chain
Definition internal.hpp:213
void init_sweeper(Sweeper &sweeper)
bool ternary_find_binary_clause(int, int)
vector< int > sweep_schedule
Definition internal.hpp:274
int likely_phase(int idx)
void set_val(int lit, signed char val)
Clause * new_clause(bool red, int glue=0)
bool sweep_extract_fixed(Sweeper &sweeper, int lit)
int walk_pick_lit(Walker &, Clause *)
bool lucky_propagate_discrepency(int)
Quotient * new_quotient(Factoring &, int)
void deallocate_clause(Clause *)
size_t no_conflict_until
Definition internal.hpp:258
unsigned lit2citten(int lit)
Definition internal.hpp:429
bool use_scores() const
Definition internal.hpp:471
void vivify_build_lrat(int, Clause *, std::vector< std::tuple< int, Clause *, bool > > &)
bool ternary_find_ternary_clause(int, int, int)
vector< int64_t > ntab
Definition internal.hpp:239
void set_parent_reason_literal(int lit, int reason)
std::vector< int > lookahead_populate_locc()
void backtrack_without_updating_phases(int target_level=0)
void reset_subsume_bits()
bool elimfast_resolvents_are_bounded(Eliminator &, int pivot)
std::vector< int >::reverse_iterator minimize_and_shrink_block(std::vector< int >::reverse_iterator &, unsigned int &, unsigned int &, const int)
void otfs_subsume_clause(Clause *subsuming, Clause *subsumed)
void failed_literal(int lit)
void unmark_binary_literals(Eliminator &)
Clause * newest_clause
Definition internal.hpp:246
int next_factor(Factoring &, unsigned *)
void bump_variable(int lit)
void subsume_clause(Clause *subsuming, Clause *subsumed)
void release_quotients(Factoring &)
void limit_preprocessing(int)
int elimfast_round(bool &completed, bool &)
void mark_useless_redundant_clauses_as_garbage()
vector< int > sign_marked
Definition internal.hpp:269
vector< int > assumptions
Definition internal.hpp:261
void probe_assign(int lit, int parent)
void reset_mode(Mode m)
Definition internal.hpp:169
void explain_reason(int lit, Clause *, int &open)
bool active(int lit)
Definition internal.hpp:360
double compute_elim_score(unsigned lit)
void push_literals_of_block(const std::vector< int >::reverse_iterator &, const std::vector< int >::reverse_iterator &, int, unsigned)
void save_core(Sweeper &sweeper, unsigned core)
void backtrack(int target_level=0)
void sweep_refine_backbone(Sweeper &sweeper)
void find_xor_gate(Eliminator &, int pivot)
int recompute_glue(Clause *)
const char * parse_dimacs(FILE *)
void sweep_refine_partition(Sweeper &sweeper)
bool assumed(int lit)
void reserve_ids(int number)
void enlarge_vals(size_t new_vsize)
void elim_update_removed_clause(Eliminator &, Clause *, int except=0)
int64_t & noccs(int lit)
Definition internal.hpp:466
int find_conflict_level(int &forced)
void block_literal_with_one_negative_occ(Blocker &, int lit)
unsigned vlit(int lit) const
Definition internal.hpp:408
int unlucky(int res)
vector< Occs > rtab
Definition internal.hpp:237
void mark2(int lit)
Definition internal.hpp:561
void sweep_dense_mode_and_watch_irredundant()
void clear_core(Sweeper &sweeper, unsigned core_idx)
void asymmetric_literal_addition(int lit, Coveror &)
void set_mode(Mode m)
Definition internal.hpp:165
void bump_clause2(Clause *)
unsigned shrink_along_reason(int, int, bool, bool &, unsigned)
bool is_autarky_literal(int lit) const
void strengthen_clause(Clause *, int)
void block_schedule(Blocker &)
unsigned shrink_block(std::vector< int >::reverse_iterator &, std::vector< int >::reverse_iterator &, int, unsigned &, unsigned &, const int, unsigned)
bool ternary_round(int64_t &steps, int64_t &htrs)
signed char marked67(int lit) const
Definition internal.hpp:498
vector< int > unit_analyzed
Definition internal.hpp:268
Reluctant reluctant
Definition internal.hpp:198
int sweep_repr(Sweeper &sweeper, int lit)
void probe_assign_decision(int lit)
void elim_backward_clauses(Eliminator &)
bool cover_propagate_asymmetric(int lit, Clause *ignore, Coveror &)
bool cover_propagate_covered(int lit, Coveror &)
void init_backbone_and_partition(Sweeper &sweeper)
void mark_elim(int lit)
void vivify_strengthen(Clause *candidate)
void limit_decisions(int)
vector< int64_t > minimize_chain
Definition internal.hpp:212
void vivify_analyze(Clause *start, bool &, Clause **, const Clause *const, int implied, bool &)
void build_lrat_for_clause(const vector< vector< Clause * > > &dfs_chains, bool invert=false)
int next_decision_variable_on_queue()
vector< Clause * > clauses
Definition internal.hpp:283
void walk_save_minimum(Walker &)
signed char * vals
Definition internal.hpp:221
void mark_eliminated_clauses_as_garbage(Eliminator &, int pivot, bool &)
void reactivate(int lit)
vector< vector< vector< int64_t > > > probehbr_chains
Definition internal.hpp:216
void vivify_deduce(Clause *candidate, Clause *conflct, int implied, Clause **, bool &)
vector< signed char > marks
Definition internal.hpp:222
void init_vars(int new_max_var)
void ternary_idx(int idx, int64_t &steps, int64_t &htrs)
vector< int64_t > btab
Definition internal.hpp:234
Clause * new_resolved_irredundant_clause()
void flip_backbone_literals(struct Sweeper &sweeper)
Clause * new_hyper_binary_resolved_clause(bool red, int glue)
int solve(bool preprocess_only=false)
vector< int > shrinkable
Definition internal.hpp:271
void mark_binary_literals(Eliminator &, int pivot)
int try_to_satisfy_formula_by_saved_phases()
void update_factor_candidate(Factoring &, int)
const Range vars
Definition internal.hpp:324
int assignment_level(int lit, Clause *)
void vivify_chain_for_units(int lit, Clause *reason)
bool flippable(int lit)
void search_assign_external(int lit)
void mark_block(int lit)
int64_t add_sweep_binary(sweep_proof_clause, int lit, int other)
int probe_dominator(int a, int b)
void blocked_clause(Quotient *q, int)
vector< int > minimized
Definition internal.hpp:270
double & score(int lit)
Definition internal.hpp:457
void require_mode(Mode m) const
Definition internal.hpp:173
void get_probehbr_lrat(int lit, int uip)
void add_factored_divider(Quotient *, int)
bool consider_to_vivify_clause(Clause *candidate)
void substitute_connected_clauses(Sweeper &sweeper, int lit, int other, int64_t id)
void unmarkfact(int lit, int fact)
Definition internal.hpp:599
bool instantiate_candidate(int lit, Clause *)
bool vivify_propagate(int64_t &)
void bump_queue(int idx)
void add_core(Sweeper &sweeper, unsigned core_idx)
bool flip(int lit)
size_t block_candidates(Blocker &, int lit)
vector< Clause * > decompose_analyze_binary_clauses(DFS *dfs, int from)
bool preprocess_round(int round)
int lookahead_locc(const std::vector< int > &)
void analyze_literal(int lit, int &open, int &resolvent_size, int &antecedent_size)
Clause * new_driving_clause(const int glue, int &jump)
int get_parent_reason_literal(int lit)
int trivially_false_satisfiable()
bool scheduable_variable(Sweeper &sweeper, int idx, size_t *occ_ptr)
void decompose_conflicting_scc_lrat(DFS *dfs, vector< int > &)
unsigned walk_break_value(int lit)
vector< int > original
Definition internal.hpp:265
void vivify_assign(int lit, Clause *)
Clause * external_reason
Definition internal.hpp:245
int otfs_find_backtrack_level(int &forced)
void copy_phases(vector< signed char > &)
vector< Level > control
Definition internal.hpp:282
int64_t & unit_clauses(int uidx)
Definition internal.hpp:443
double tied_next_factor_score(int)
void delete_sweep_binary(const sweep_binary &sb)
vector< double > stab
Definition internal.hpp:230
Occs & occs(int lit)
Definition internal.hpp:465
vector< int > parents
Definition internal.hpp:232
void probe_lrat_for_units(int lit)
bool occurring() const
Definition internal.hpp:461
void init_enqueue(int idx)
void markfact(int lit, int fact)
Definition internal.hpp:580
bool marked2(int lit) const
Definition internal.hpp:555
void bump_variable_score(int lit)
void mark_satisfied_clauses_as_garbage()
Internal * internal
Definition internal.hpp:311
size_t shrink_clause(Clause *, int new_size)
ScoreSchedule scores
Definition internal.hpp:229
int active() const
Definition internal.hpp:362
int subsume_check(Clause *subsuming, Clause *subsumed)
int citten2lit(unsigned ulit)
Definition internal.hpp:421
void notify_backtrack(size_t new_level)
void learn_unit_clause(int lit)
unsigned shrink_next(int, unsigned &, unsigned &)
const char * parse_dimacs(const char *)
void schedule_inner(Sweeper &sweeper, int idx)
void mark_subsume(int lit)
void mark_factor(int lit)
void sweep_clause(Sweeper &sweeper, unsigned depth, Clause *)
void probe_dominator_lrat(int dom, Clause *reason)
void mark_added(int lit, int size, bool redundant)
bool marked_decomposed(int lit)
void mark_skip(int lit)
void mark_clauses_to_be_flushed()
void flip_partition_literals(struct Sweeper &sweeper)
Clause * probe_reason
Definition internal.hpp:252
void vivify_initialize(Vivifier &vivifier, int64_t &ticks)
bool match_ternary_clause(Clause *, int, int, int)
Clause * new_clause_as(const Clause *orig)
void unmark_decomposed(int lit)
void add_self_subsuming_factor(Quotient *, Quotient *)
void assign_original_unit(int64_t, int)
void condition_unassign(int lit)
void enlarge(int new_max_var)
void melt(int lit)
bool observed(int ilit) const
vector< FileTracer * > file_tracers
Definition internal.hpp:298
Clause * find_ternary_clause(int, int, int)
int second_literal_in_binary_clause_lrat(Clause *, int first)
void elim_propagate(Eliminator &, int unit)
int64_t & bumped(int lit)
Definition internal.hpp:455
vector< int64_t > mini_chain
Definition internal.hpp:211
void mark_in_candidate_clause(int lit)
vector< int > probes
Definition internal.hpp:281
void clear_nounted(vector< int > &)
bool vivify_instantiate(const std::vector< int > &, Clause *, std::vector< std::tuple< int, Clause *, bool > > &lrat_stack, int64_t &ticks)
Watches & watches(int lit)
Definition internal.hpp:467
Clause * new_hyper_ternary_resolved_clause(bool red)
void analyze_reason(int lit, Clause *, int &open, int &resolvent_size, int &antecedent_size)
bool likely_to_be_kept_clause(Clause *c)
void delete_clause(Clause *)
bool traverse_clauses(ClauseIterator &)
void set_probehbr_lrat(int lit, int uip)
vector< Occs > otab
Definition internal.hpp:236
void freeze(int lit)
bool sweep_backbone_candidate(Sweeper &sweeper, int lit)
void search_assign_driving(int lit, Clause *reason)
bool sweep_equivalence_candidates(Sweeper &sweeper, int lit, int other)
int64_t redundant() const
Definition internal.hpp:381
int hyper_binary_resolve(Clause *)
bool is_in_candidate_clause(int lit) const
void compute_tier_limits(Vivifier &)
void delete_unfactored(Quotient *q)
int determine_actual_backtrack_level(int jump)
bool hyper_ternary_resolve(Clause *, int, Clause *)
void limit_conflicts(int)
bool elim_resolvents_are_bounded(Eliminator &, int pivot)
void search_assign(int lit, Clause *)
volatile bool termination_forced
Definition internal.hpp:320
void build_chain_for_units(int lit, Clause *reason, bool forced)
size_t flush_occs(int lit)
void unmark_as_conditional_literal(int lit)
void instantiate(Instantiator &)
vector< Watches > wtab
Definition internal.hpp:241
void mark_incomplete(Sweeper &sweeper)
bool vivify_shrinkable(const std::vector< int > &sorted, Clause *c)
void ternary_lit(int pivot, int64_t &steps, int64_t &htrs)
bool getfact(int lit, int fact) const
Definition internal.hpp:568
bool getbit(int lit, int bit) const
Definition internal.hpp:536
vector< int > levels
Definition internal.hpp:266
int walk_round(int64_t limit, bool prev)
void elim_on_the_fly_self_subsumption(Eliminator &, Clause *, int)
void unmark(vector< int > &lits)
Definition internal.hpp:527
void find_definition(Eliminator &, int)
vector< int > clause
Definition internal.hpp:260
void elim_add_resolvents(Eliminator &, int pivot)
vector< Flags > ftab
Definition internal.hpp:233
void connect_watches(bool irredundant_only=false)
score_smaller(Internal *i)
Definition score.hpp:12
Internal * internal
Definition score.hpp:11
signed char mark
Definition value.h:8
struct vivifier vivifier
Definition vivify.c:167
vector watches
Definition watch.h:49
#define const
Definition zconf.h:196