27 const unsigned uidx = 2 *
lit;
29 const double neg =
internal->ntab[uidx + 1];
34 double sum = 0, prod = 0;
36 sum =
opts.elimsum * (
pos + neg);
38 prod =
opts.elimprod * (
pos * neg);
45 const auto s =
internal->compute_elim_score (a);
46 const auto t =
internal->compute_elim_score (b);
99 for (
const auto &
lit : *c) {
106 const int idx = abs (
lit);
120 const int idx = abs (
lit);
125 LOG (
"rescheduling %d for elimination after removing clause", idx);
133 for (
const auto &
lit : *c) {
151 work.push_back (root);
152 while (i < work.
size ()) {
154 LOG (
"elimination propagation of %d",
lit);
157 for (
const auto &c : ns) {
161 for (
const auto &other : *c) {
162 const signed char tmp =
val (other);
175 LOG (c,
"elimination propagation of %d finds %d satisfied",
lit,
180 LOG (
"empty clause during elimination propagation of %d",
lit);
186 }
else if (unit != INT_MIN) {
187 LOG (
"new unit %d during elimination propagation of %d", unit,
lit);
190 work.push_back (unit);
196 for (
const auto &c : ps) {
199 LOG (c,
"elimination propagation of %d produces satisfied",
lit);
216 LOG (c,
"pivot %d on-the-fly self-subsuming resolution", pivot);
218 stats.strengthened++;
220 for (
const auto &
lit : *c) {
223 const signed char tmp =
val (
lit);
271 const bool propagate_eagerly) {
289 int tautological = 0;
297 for (
const auto &
lit : *c) {
303 const signed char tmp =
val (
lit);
307 }
else if (tmp < 0) {
336 for (
const auto &
lit : *d) {
342 signed char tmp =
val (
lit);
346 }
else if (tmp < 0) {
368 const int64_t size =
clause.size ();
384 LOG (c,
"first antecedent");
385 LOG (d,
"second antecedent");
389 LOG (
"resolvent tautological on %d", tautological);
396 LOG (
"empty resolvent");
403 LOG (
"unit resolvent %d", unit);
406 if (propagate_eagerly)
418 if (s > size && t > size) {
424 LOG (d,
"double pivot %d on-the-fly self-subsuming resolution", -pivot);
453 if (propagate_eagerly)
469 const bool substitute = !eliminator.
gates.empty ();
472 LOG (
"trying to substitute %d", pivot);
481 const int64_t
pos = ps.
size ();
482 const int64_t neg = ns.
size ();
484 return lim.elimbound >= 0;
485 const int64_t bound =
pos + neg +
lim.elimbound;
487 LOG (
"checking number resolvents on %d bounded by "
488 "%" PRId64
" = %" PRId64
" + %" PRId64
" + %" PRId64,
489 pivot, bound,
pos, neg,
lim.elimbound);
496 int64_t resolvents = 0;
498 for (
const auto &c : ps) {
502 for (
const auto &d : ns) {
506 if (!resolve_gates && substitute && c->gate == d->gate)
508 stats.elimrestried++;
511 int size =
clause.size ();
513 LOG (
"now at least %" PRId64
514 " non-tautological resolvents on pivot %d",
516 if (size >
opts.elimclslim) {
517 LOG (
"resolvent size %d too big after %" PRId64
519 size, resolvents, pivot);
522 if (resolvents > bound) {
523 LOG (
"too many non-tautological resolvents on %d", pivot);
528 else if (
val (pivot))
533 LOG (
"need %" PRId64
" <= %" PRId64
" non-tautological resolvents",
545 const bool substitute = !eliminator.
gates.empty ();
548 LOG (
"substituting pivot %d by resolving with %zd gate clauses", pivot,
554 stats.eliminated_equi++;
557 stats.eliminated_and++;
560 stats.eliminated_ite++;
563 stats.eliminated_xor++;
566 stats.eliminated_def++;
572 LOG (
"adding all resolvents on %d", pivot);
580 int64_t resolvents = 0;
592 if (!resolve_gates && substitute && c->gate == d->gate)
608 LOG (
"added %" PRId64
" resolvents to eliminate %d", resolvents, pivot);
617 Eliminator &eliminator,
int pivot,
bool &deleted_binary_clause) {
620 LOG (
"marking irredundant clauses with %d as garbage", pivot);
622 const int64_t substitute = eliminator.
gates.
size ();
624 LOG (
"pushing %" PRId64
" gate clauses on extension stack", substitute);
625#ifndef CADICAL_NDEBUG
629 for (
const auto &c : ps) {
633 if (!substitute || c->gate) {
635 proof->weaken_minus (c);
637 deleted_binary_clause =
true;
638 external->push_clause_on_extension_stack (c, pivot);
639#ifndef CADICAL_NDEBUG
648 LOG (
"marking irredundant clauses with %d as garbage", -pivot);
651 for (
const auto &d : ns) {
655 if (!substitute || d->gate) {
657 proof->weaken_minus (d);
659 deleted_binary_clause =
true;
660 external->push_clause_on_extension_stack (d, -pivot);
661#ifndef CADICAL_NDEBUG
682 bool &deleted_binary_clause) {
697 LOG (
"pivot %d occurs positively %" PRId64
698 " times and negatively %" PRId64
" times",
703 if (
pos && neg >
opts.elimocclim) {
704 LOG (
"too many occurrences thus not eliminated %d", pivot);
709 LOG (
"trying to eliminate %d", pivot);
723 LOG (
"number of resolvents on %d are bounded", pivot);
727 deleted_binary_clause);
731 LOG (
"too many resolvents on %d so not eliminated", pivot);
743 for (
const auto &c :
clauses) {
744 if (c->garbage || !c->redundant)
747 for (
const auto &
lit : *c) {
779 int64_t marked_before =
last.elim.marked;
783 int64_t resolution_limit;
785 if (
opts.elimlimited) {
786 int64_t delta =
stats.propagations.search;
787 delta *= 1e-3 *
opts.elimeffort;
788 if (delta <
opts.elimmineff)
789 delta =
opts.elimmineff;
790 if (delta >
opts.elimmaxeff)
791 delta =
opts.elimmaxeff;
792 delta = max (delta, (int64_t) 2l *
active ());
795 "limit of %" PRId64
" resolutions", delta);
797 resolution_limit =
stats.elimres + delta;
799 PHASE (
"elim-round",
stats.elimrounds,
"resolutions unlimited");
800 resolution_limit = LONG_MAX;
809 for (
const auto &c :
clauses) {
810 if (c->garbage || c->redundant)
812 bool satisfied =
false, falsified =
false;
813 for (
const auto &
lit : *c) {
814 const signed char tmp =
val (
lit);
825 for (
const auto &
lit : *c) {
845 for (
auto idx :
vars) {
852 LOG (
"scheduling %d for elimination initially", idx);
859 int64_t scheduled = schedule.
size ();
863 "scheduled %" PRId64
" variables %.0f%% for elimination",
869 if (!c->garbage && !c->redundant)
870 for (
const auto &
lit : *c)
875 const int64_t old_resolutions =
stats.elimres;
877 const int old_eliminated =
stats.all.eliminated;
878 const int old_fixed =
stats.all.fixed;
883 const int64_t garbage_limit = (2 *
stats.irrlits / 3) + (1 << 20);
893 stats.elimres <= resolution_limit && !schedule.
empty ()) {
894 int idx = schedule.
front ();
896 flags (idx).elim =
false;
901 if (
stats.garbage.literals <= garbage_limit)
911 completed = !schedule.
size ();
914 last.elim.marked = marked_before;
917 "tried to eliminate %" PRId64
" variables %.0f%% (%zd remain)",
918 tried,
percent (tried, scheduled), schedule.
size ());
937 int eliminated =
stats.all.eliminated - old_eliminated;
939 int64_t resolutions =
stats.elimres - old_resolutions;
941 "eliminated %d variables %.0f%% in %" PRId64
" resolutions",
942 eliminated,
percent (eliminated, scheduled), resolutions);
945 last.elim.subsumephases =
stats.subsumephases;
946 const int units =
stats.all.fixed - old_fixed;
947 report (
'e', !
opts.reportall && !(eliminated + units));
968 if (
lim.elimbound >=
opts.elimboundmax)
971 if (
lim.elimbound < 0)
973 else if (!
lim.elimbound)
978 if (
lim.elimbound >
opts.elimboundmax)
979 lim.elimbound =
opts.elimboundmax;
982 "new elimination bound %" PRId64
"",
lim.elimbound);
989 for (
auto idx :
vars) {
999 LOG (
"marked %d variables as elimination candidates", count);
1033 "starting at most %d elimination rounds",
opts.elimrounds);
1040#ifndef CADICAL_QUIET
1041 int old_active_variables =
active ();
1042 int old_eliminated =
stats.all.eliminated;
1048 if (
last.elim.subsumephases ==
stats.subsumephases)
1066 bool phase_complete =
false, deleted_binary_clause =
false;
1069#ifndef CADICAL_QUIET
1073 bool round_complete =
false;
1075#ifndef CADICAL_QUIET
1078 elim_round (round_complete, deleted_binary_clause);
1080 if (!round_complete) {
1081 PHASE (
"elim-phase",
stats.elimphases,
"last round %d incomplete %s",
1082 round, eliminated ?
"but successful" :
"and unsuccessful");
1087 if (round++ >=
opts.elimrounds) {
1088 PHASE (
"elim-phase",
stats.elimphases,
"round limit %d hit (%s)",
1090 eliminated ?
"though last round successful"
1091 :
"last round unsuccessful anyhow");
1110 "no new variable elimination candidates");
1113 phase_complete =
true;
1116 if (phase_complete) {
1117 stats.elimcompleted++;
1119 "fully completed elimination %" PRId64
1120 " at elimination bound %" PRId64
"",
1121 stats.elimcompleted,
lim.elimbound);
1124 "incomplete elimination %" PRId64
1125 " at elimination bound %" PRId64
"",
1126 stats.elimcompleted + 1,
lim.elimbound);
1130 if (deleted_binary_clause)
1136 LOG (
"elimination derived empty clause");
1138 LOG (
"elimination produced %zd units",
1141 LOG (
"propagating units after elimination results in empty clause");
1152#ifndef CADICAL_QUIET
1153 eliminated =
stats.all.eliminated - old_eliminated;
1154 PHASE (
"elim-phase",
stats.elimphases,
"eliminated %d variables %.2f%%",
1155 eliminated,
percent (eliminated, old_active_variables));
1167 lim.elim =
stats.conflicts + delta;
1170 "new limit at %" PRId64
" conflicts after %" PRId64
" conflicts",
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
#define CADICAL_assert(ignore)
cadical_kitten * cadical_kitten_init(void)
void cadical_kitten_release(cadical_kitten *cadical_kitten)
bool contains(unsigned e) const
void push_back(unsigned e)
heap< elim_more > ElimSchedule
void erase_occs(Occs &os)
double percent(double a, double b)
#define START_SIMPLIFIER(S, M)
#define STOP_SIMPLIFIER(S, M)
void delete_garbage_clauses()
void increase_elimination_bound()
void elim_update_removed_lit(Eliminator &, int lit)
void elim_update_added_clause(Eliminator &, Clause *)
void garbage_collection()
void mark_garbage(Clause *)
double scale(double v) const
vector< int64_t > lrat_chain
int elim_round(bool &completed, bool &)
void report(char type, int verbose_level=0)
void mark_redundant_clauses_with_eliminated_variables_as_garbage()
void find_gate_clauses(Eliminator &, int pivot)
bool terminated_asynchronously(int factor=1)
void learn_empty_clause()
void assign_unit(int lit)
void mark_eliminated(int)
bool resolve_clauses(Eliminator &, Clause *, int pivot, Clause *, bool)
void try_to_eliminate_variable(Eliminator &, int pivot, bool &)
void elim(bool update_limits=true)
signed char val(int lit) const
signed char marked(int lit) const
int64_t unit_id(int lit) const
void collect_instantiation_candidates(Instantiator &)
void unmark_gate_clauses(Eliminator &)
double compute_elim_score(unsigned lit)
void backtrack(int target_level=0)
void elim_update_removed_clause(Eliminator &, Clause *, int except=0)
void elim_backward_clauses(Eliminator &)
vector< Clause * > clauses
void mark_eliminated_clauses_as_garbage(Eliminator &, int pivot, bool &)
Clause * new_resolved_irredundant_clause()
void clear_analyzed_literals()
void elim_propagate(Eliminator &, int unit)
bool elim_resolvents_are_bounded(Eliminator &, int pivot)
void build_chain_for_units(int lit, Clause *reason, bool forced)
size_t flush_occs(int lit)
void instantiate(Instantiator &)
void elim_on_the_fly_self_subsumption(Eliminator &, Clause *, int)
void elim_add_resolvents(Eliminator &, int pivot)
void connect_watches(bool irredundant_only=false)
bool operator()(unsigned a, unsigned b)