10static Clause external_reason_clause;
33 profiles (this), force_phase_messages (
false),
59#define PROFILE(NAME, LEVEL) \
60 if (PROFILE_ACTIVE (NAME)) \
100static signed char *ignore_clang_analyze_memory_leak_warning;
103 signed char *new_vals;
104 const size_t bytes = 2u * new_vsize;
105 new_vals =
new signed char[bytes];
106 memset (new_vals, 0, bytes);
107 ignore_clang_analyze_memory_leak_warning = new_vals;
108 new_vals += new_vsize;
124 size_t new_vsize =
vsize ? 2 *
vsize : 1 + (size_t) new_max_var;
125 while (new_vsize <= (
size_t) new_max_var)
127 LOG (
"enlarge internal size from %zd to new size %zd",
vsize, new_vsize);
131 enlarge_only (
wtab, 2 * new_vsize);
132 enlarge_only (
vtab, new_vsize);
133 enlarge_zero (
parents, new_vsize);
134 enlarge_only (
links, new_vsize);
135 enlarge_zero (
btab, new_vsize);
136 enlarge_zero (
gtab, new_vsize);
137 enlarge_zero (
stab, new_vsize);
138 enlarge_init (
ptab, 2 * new_vsize, -1);
139 enlarge_only (
ftab, new_vsize);
144 const signed char val =
opts.phase ? 1 : -1;
145 enlarge_init (
phases.saved, new_vsize,
val);
146 enlarge_zero (
phases.forced, new_vsize);
147 enlarge_zero (
phases.target, new_vsize);
148 enlarge_zero (
phases.best, new_vsize);
149 enlarge_zero (
phases.prev, new_vsize);
150 enlarge_zero (
phases.min, new_vsize);
151 enlarge_zero (
marks, new_vsize);
159 LOG (
"initializing %d internal variables from %d to %d",
161 if ((
size_t) new_max_var >=
vsize)
163#ifndef CADICAL_NDEBUG
164 for (int64_t i = -new_max_var; i < -
max_var; i++)
166 for (
unsigned i =
max_var + 1; i <= (unsigned) new_max_var; i++)
168 for (uint64_t i = 2 * ((uint64_t)
max_var + 1);
169 i <= 2 * (uint64_t) new_max_var + 1; i++)
177 int initialized = new_max_var - old_max_var;
178 stats.vars += initialized;
179 stats.unused += initialized;
180 stats.inactive += initialized;
181 LOG (
"finished initializing %d internal variables", initialized);
195 proof->add_external_original_clause (
id,
false,
external->eclause);
200 if (forgettable &&
opts.check) {
204 external->forgettable_original[id] = {1};
206 for (
auto const &elit :
external->eclause)
207 external->forgettable_original[id].push_back (elit);
210 "clause added to external forgettable map:");
224 proof->add_external_original_clause (
id,
false,
external->eclause,
235 LOG (
"reserving %d ids", number);
249bool Internal::propagate_wrapper () {
251 return propagate_stable ();
253 return propagate_unstable ();
256void Internal::analyze_wrapper () {
263int Internal::decide_wrapper () {
265 return decide_stable ();
267 return decide_unstable ();
349 proof->solve_query ();
351 if (
opts.ilbassumptions)
368 last_assumption_level++;
398 if (
level >= last_assumption_level)
421 last_assumption_level++;
423 size_t trail_limit =
trail.size();
424 if (
level > last_assumption_level)
425 trail_limit =
control[last_assumption_level + 1].trail;
427 for (
size_t i = 0; i < trail_limit; i++)
428 entrailed.push_back (
trail[i]);
440 lim.recompute_tier = 5000;
445 const bool incremental =
lim.initialized;
447 LOG (
"reinitializing preprocessing limits incrementally");
449 LOG (
"initializing preprocessing limits and increments");
451 const char *
mode = 0;
458 last.elim.marked = -1;
463 LOG (
"%s elim limit %" PRId64
" after %" PRId64
" conflicts",
mode,
468 lim.elimbound =
opts.elimboundmin;
469 LOG (
"elimination bound %" PRId64
"",
lim.elimbound);
475 last.ternary.marked = -1;
478 LOG (
"initial compact limit %" PRId64
" increment %" PRId64
"",
487 double delta = log10 (
stats.added.irredundant);
488 delta = delta * delta;
489 lim.inprobe =
stats.conflicts +
opts.inprobeint * delta;
493 LOG (
"%s probe limit %" PRId64
" after %" PRId64
" conflicts",
mode,
504 LOG (
"%s condition limit %" PRId64
" increment %" PRId64,
mode,
511 if (
inc.preprocessing <= 0) {
512 lim.preprocessing = 0;
513 LOG (
"no preprocessing");
515 lim.preprocessing =
inc.preprocessing;
516 LOG (
"limiting to %" PRId64
" preprocessing rounds",
lim.preprocessing);
522 const bool incremental =
lim.initialized;
524 LOG (
"reinitializing search limits incrementally");
526 LOG (
"initializing search limits and increments");
528 const char *
mode = 0;
535 last.reduce.conflicts = -1;
540 LOG (
"%s reduce limit %" PRId64
" after %" PRId64
" conflicts",
mode,
553 LOG (
"%s flush limit %" PRId64
" interval %" PRId64
"",
mode,
lim.flush,
561 lim.rephased[0] =
lim.rephased[1] = 0;
562 LOG (
"new rephase limit %" PRId64
" after %" PRId64
" conflicts",
570 LOG (
"new restart limit %" PRId64
" increment %" PRId64
"",
lim.restart,
578 LOG (
"starting in always forced stable phase");
580 LOG (
"starting in default non-stable phase");
582 }
else if (
opts.stabilize &&
opts.stabilizeonly) {
583 LOG (
"keeping always forced stable phase");
586 LOG (
"switching back to default non-stable phase");
590 LOG (
"keeping non-stable phase");
595 LOG (
"initial stabilize limit %" PRId64
" after %d conflicts",
596 lim.stabilize, (
int)
opts.stabilizeinit);
599 if (
opts.stabilize &&
opts.reluctant) {
600 LOG (
"new restart reluctant doubling sequence period %d",
610 if (
inc.conflicts < 0) {
612 LOG (
"no limit on conflicts");
615 LOG (
"conflict limit after %" PRId64
" conflicts at %" PRId64
617 inc.conflicts,
lim.conflicts);
620 if (
inc.decisions < 0) {
622 LOG (
"no limit on decisions");
625 LOG (
"conflict limit after %" PRId64
" decisions at %" PRId64
627 inc.decisions,
lim.decisions);
634 if (
inc.localsearch <= 0) {
636 LOG (
"no local search");
638 lim.localsearch =
inc.localsearch;
639 LOG (
"limiting to %" PRId64
" local search rounds",
lim.localsearch);
644 lim.initialized =
true;
660 before.clauses =
stats.current.irredundant;
661 stats.preprocessings++;
665 "starting round %d with %" PRId64
" variables and %" PRId64
667 round, before.vars, before.clauses);
668 int old_elimbound =
lim.elimbound;
677 after.clauses =
stats.current.irredundant;
681 "finished round %d with %" PRId64
" variables and %" PRId64
683 round, after.vars, after.clauses);
688 if (after.vars < before.vars)
690 if (old_elimbound <
lim.elimbound)
701 if (!
opts.preprocesslight)
708 before.clauses =
stats.current.irredundant;
713 "starting with %" PRId64
" variables and %" PRId64
" clauses",
714 before.vars, before.clauses);
730 after.clauses =
stats.current.irredundant;
734 "finished with %" PRId64
" variables and %" PRId64
" clauses",
735 after.vars, after.clauses);
742 for (
int i = 0; i <
lim.preprocessing; i++)
753 LOG (
"satisfying formula by saved phases");
760 LOG (
"external notifications are turned off during preprocessing.");
766 LOG (
"formula indeed satisfied by saved phases");
769 LOG (
"inconsistent assumptions with redundant clauses and phases");
772 LOG (
"saved phases do not satisfy redundant clauses");
784 LOG (
"external notifications are turned back on.");
797 LOG (
"producing failed assumptions");
810 LOG (
"formula is actually unsatisfiable unconditionally");
812 LOG (
"assumptions indeed failing");
834 if (LONG_MAX / round >
limit)
863 for (
int i = 1; !res && i <=
lim.localsearch; i++)
867 LOG (
"local search determined formula to be satisfiable");
870 }
else if (res == 20) {
871 LOG (
"local search determined assumptions to be inconsistent");
888 proof->solve_query ();
890 if (
opts.ilbassumptions)
903 LOG (
"internal solving in preprocessing only mode");
905 LOG (
"internal solving in full mode");
908 if (!res && preprocess_only &&
level)
914 if (!preprocess_only)
917 if (!preprocess_only) {
923 if (!preprocess_only) {
944 LOG (
"already inconsistent");
950 LOG (
"root level propagation produces conflict");
981 LOG (
"reset forced termination");
987 if (
opts.restoreall <= 1 &&
external->tainted.empty ()) {
988 LOG (
"no tainted literals and nothing to restore");
996 LOG (
"root level propagation after restore produces conflict");
1015 LOG (
"external notifications are turned off during preprocessing.");
1033 LOG (
"external notifications are turned back on.");
1047 for (
const auto &evar :
external->vars) {
1049 const auto eidx = 2 * evar;
1051 int64_t
id =
external->ext_units[eidx];
1054 id =
external->ext_units[eidx + 1];
1057 proof->finalize_external_unit (
id, evar *
sign);
1061 for (
const auto &
lit :
lits) {
1064 const unsigned eidx = (elit < 0) + 2u * (
unsigned) abs (elit);
1065 const int64_t
id =
external->ext_units[eidx];
1079 if (!c->garbage || (c->size == 2 && !c->flushed))
1080 proof->finalize_clause (c);
1109 for (
const auto &
lit : *c)
1110 printf (
"%d ",
lit);
1116 for (
auto idx :
vars)
1122 printf (
"p cnf %d %" PRId64
"\n",
max_var, m);
1123 for (
auto idx :
vars) {
1124 const int tmp =
fixed (idx);
1126 printf (
"%d 0\n", tmp < 0 ? -idx : idx);
1132 printf (
"%d 0\n",
lit);
1144 return it.
clause (eclause);
1149 const int tmp =
fixed (ilit);
1157 eclause.push_back (elit);
1169 return it.
clause (eclause);
1170 for (
const auto &c :
clauses) {
1176 for (
const auto &ilit : *c) {
1177 const int tmp =
fixed (ilit);
1185 eclause.push_back (elit);
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
#define CADICAL_assert(ignore)
virtual bool clause(const std::vector< int > &)=0
#define propagate_wrapper
#define START_OUTER_WALK()
#define STOP_OUTER_WALK()
void sort_and_reuse_assumptions()
void notify_assignments()
vector< unsigned > relevanttab
void inprobe(bool update_limits=true)
vector< StatTracer * > stat_tracers
double scale(double v) const
bool ext_clause_forgettable
vector< int64_t > unit_clauses_idx
bool external_check_solution()
bool searching_lucky_phases
void init_scores(int old_max_var, int new_max_var)
void preprocess_quickly()
void report(char type, int verbose_level=0)
void renotify_trail_after_ilb()
void implied(std::vector< int > &entrailed)
int local_search_round(int round)
bool terminated_asynchronously(int factor=1)
vector< Tracer * > tracers
void add_new_original_clause(int64_t)
void learn_empty_clause()
void init_queue(int old_max_var, int new_max_var)
void condition(bool update_limits=true)
void init_report_limits()
void finish_added_clause_with_id(int64_t id, bool restore=false)
void elim(bool update_limits=true)
signed char val(int lit) const
bool limit(const char *name, int)
bool traverse_constraint(ClauseIterator &)
void add_original_lit(int lit)
void init_search_limits()
void produce_failed_assumptions()
int propagate_assumptions()
vector< int > assumptions
void backtrack(int target_level=0)
void reserve_ids(int number)
void enlarge_vals(size_t new_vsize)
void init_preprocessing_limits()
unsigned vlit(int lit) const
bool forced_backt_allowed
vector< Clause * > clauses
void renotify_trail_after_local_search()
vector< signed char > marks
void init_vars(int new_max_var)
int cdcl_loop_with_inprocessing()
bool external_propagate()
int solve(bool preprocess_only=false)
int try_to_satisfy_formula_by_saved_phases()
bool preprocess_round(int round)
int64_t & unit_clauses(int uidx)
void enlarge(int new_max_var)
bool external_prop_is_lazy
vector< FileTracer * > file_tracers
void delete_clause(Clause *)
bool traverse_clauses(ClauseIterator &)
volatile bool termination_forced
int walk_round(int64_t limit, bool prev)