15static size_t remove_duplicated_binaries_with_literal (
kissat *
solver,
33 const value marked = marks[other];
41 const unsigned not_other =
NOT (other);
42 if (marks[not_other]) {
44 "duplicate hyper unary resolution on %s "
48 "duplicate hyper unary resolution on %s "
57 for (
const watch *r = begin; r != q; r++)
58 marks[r->binary.lit] = 0;
63 size_t removed = end - q;
65 LOG (
"removed %zu watches with literal %s", removed,
LOGLIT (
lit));
70static void remove_all_duplicated_binary_clauses (
kissat *
solver) {
71 LOG (
"removing all duplicated irredundant binary clauses");
72#if !defined(KISSAT_QUIET) || !defined(KISSAT_NDEBUG)
85 const unsigned int lit =
LIT (idx);
86 const unsigned int not_lit =
NOT (
lit);
87#if !defined(KISSAT_QUIET) || !defined(KISSAT_NDEBUG)
90 remove_duplicated_binaries_with_literal (
solver,
lit);
91#if !defined(KISSAT_QUIET) || !defined(KISSAT_NDEBUG)
94 remove_duplicated_binaries_with_literal (
solver, not_lit);
100 LOG (
"found %zu hyper unary resolved units", units);
106 LOG (
"skipping satisfied resolved unit %s",
LOGLIT (unit));
110 LOG (
"found falsified resolved unit %s",
LOGLIT (unit));
113 solver->inconsistent =
true;
116 LOG (
"new resolved unit clause %s",
LOGLIT (unit));
120 if (!
solver->inconsistent)
124 REPORT (!removed && !units,
'2');
127static void find_forward_subsumption_candidates (
kissat *
solver,
128 references *candidates) {
129 const unsigned clslim =
GET_OPTION (subsumeclslim);
134 clause *last_irredundant = kissat_last_irredundant_clause (
solver);
137 if (last_irredundant && c > last_irredundant)
144 if (c->size > clslim)
149 const unsigned idx =
IDX (
lit);
153 if (values[
lit] > 0) {
164 const unsigned ref = kissat_reference_clause (
solver, c);
169static inline unsigned
177#define GET_SIZE_OF_REFERENCE(REF) \
178 get_size_of_reference (solver, arena, (REF))
180static void sort_forward_subsumption_candidates (
kissat *
solver,
181 references *candidates) {
189 bool binaries,
unsigned *remove,
197 if (size_watches > limit)
203 uint64_t steps = 1 + kissat_cache_lines (size_watches,
sizeof (
watch));
225 const unsigned not_other =
NOT (other);
226 if (marks[not_other]) {
269 const unsigned not_other =
NOT (other);
270 if (!marks[not_other]) {
284 LOGCLS (d,
"forward subsuming");
303 ADD (subsumption_checks, checks);
304 ADD (forward_checks, checks);
305 ADD (forward_steps, steps);
312 const unsigned limit =
GET_OPTION (subsumeocclim);
317 const unsigned idx =
IDX (
lit);
323 if (forward_literal (
solver,
lit,
true, remove, limit))
326 if (forward_literal (
solver,
NOT (
lit),
false, remove, limit))
334 unsigneds *new_binaries) {
336 LOGCLS2 (c,
"trying to forward subsume");
359 if (c->
garbage || non_false <= 1)
367 LOGCLS (c,
"found falsified clause");
370 solver->inconsistent =
true;
374 if (non_false == 1) {
376 LOG (
"new remaining non-false literal unit clause %s",
LOGLIT (unit));
384 const bool subsume = forward_marked_clause (
solver, c, &remove);
390 LOGCLS (c,
"forward subsumed");
393 INC (forward_subsumed);
395 *strengthened =
true;
397 INC (forward_strengthened);
398 LOGCLS (c,
"forward strengthening by removing %s in",
LOGLIT (remove));
399 if (non_false == 2) {
402 LOG (
"forward strengthened unit clause %s",
LOGLIT (unit));
410 kissat_mark_removed_literal (
solver, remove);
412 unsigned *lits = c->
lits;
413 unsigned new_size = 0;
414 for (
unsigned i = 0; i < c->
size; i++) {
415 const unsigned lit = lits[i];
422 lits[new_size++] =
lit;
434 LOGCLS (c,
"forward strengthened");
439 const size_t bytes = kissat_actual_bytes_of_clause (c);
440 ADD (arena_garbage, bytes);
460 LOGBINARY (first, second,
"forward strengthened");
461 kissat_watch_other (
solver, first, second);
462 kissat_watch_other (
solver, second, first);
465 solver->statistics_.clauses_irredundant--;
467 solver->statistics_.clauses_binary++;
488 const unsigned idx =
IDX (
lit);
506 if (min_occs > occlim)
508 LOG (
"connecting %s with %zu occurrences",
LOGLIT (min_lit), min_occs);
510 kissat_connect_literal (
solver, min_lit, ref);
513static bool forward_subsume_all_clauses (
kissat *
solver) {
514 references candidates;
517 find_forward_subsumption_candidates (
solver, &candidates);
521 solver,
"forward",
GET (forward_subsumptions),
522 "scheduled %zu irredundant clauses %.0f%%", scheduled,
523 kissat_percent (scheduled,
solver->statistics_.clauses_irredundant));
525 sort_forward_subsumption_candidates (
solver, &candidates);
532 size_t strengthened = 0;
535 const unsigned occlim =
GET_OPTION (subsumeocclim);
537 unsigneds new_binaries;
545 while (
p != end_of_candidates) {
546 if (
solver->statistics_.forward_steps > steps_limit)
557 bool not_subsumed_but_strengthened =
false;
558 if (forward_subsumed_clause (
559 solver, c, ¬_subsumed_but_strengthened, &new_binaries)) {
563 }
else if (not_subsumed_but_strengthened) {
571 connect_subsuming (
solver, occlim, c);
577 "subsumed %zu clauses %.2f%% of %zu checked %.0f%%",
578 subsumed, kissat_percent (subsumed, checked), checked,
579 kissat_percent (checked, scheduled));
582 "strengthened %zu clauses %.2f%% of %zu checked %.0f%%",
583 strengthened, kissat_percent (strengthened, checked),
584 checked, kissat_percent (checked, scheduled));
585 if (!subsumed && !strengthened)
587 "no clause subsumed nor strengthened "
588 "out of %zu checked %.0f%%",
589 checked, kissat_percent (checked, scheduled));
597 unsigned reactivated = 0;
614 const unsigned idx =
IDX (
lit);
619 "reactivating subsume flag of %s "
620 "in remaining or strengthened",
632 for (
unsigned i = 0; i < 2; i++) {
633 const unsigned lit = lits[i];
634 const unsigned idx =
IDX (
lit);
639 "reactivating subsume flag of %s "
640 "in strengthened binary clause",
650 "marked %u variables %.0f%% to be reconsidered "
651 "in next forward subsumption",
653 kissat_percent (reactivated,
solver->active));
657 "%zu unchecked clauses remain %.0f%%", remain,
658 kissat_percent (remain, scheduled));
661 "all %zu scheduled clauses checked", scheduled);
669 else if (reactivated)
675 completed ?
"" :
"in");
684 INC (forward_subsumptions);
686 remove_all_duplicated_binary_clauses (
solver);
687 bool complete =
true;
688 if (!
solver->inconsistent)
689 complete = forward_subsume_all_clauses (
solver);
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
ABC_NAMESPACE_HEADER_START typedef word ward
void kissat_learned_unit(kissat *solver, unsigned lit)
#define all_stack(T, E, S)
ABC_NAMESPACE_IMPL_START typedef signed char value
#define CHECK_AND_ADD_EMPTY(...)
#define CHECK_SHRINK_CLAUSE(...)
void kissat_mark_clause_as_garbage(kissat *solver, clause *c)
void kissat_delete_binary(kissat *solver, unsigned a, unsigned b)
void kissat_flush_units_while_connected(kissat *solver)
bool kissat_forward_subsume_during_elimination(kissat *solver)
#define GET_SIZE_OF_REFERENCE(REF)
#define all_variables(IDX)
#define all_literals_in_clause(LIT, C)
#define KISSAT_assert(ignore)
#define SET_EFFORT_LIMIT(LIMIT, NAME, THRESHHOLD)
#define kissat_very_verbose(...)
#define kissat_phase(...)
#define ADD_EMPTY_TO_PROOF(...)
#define SHRINK_CLAUSE_IN_PROOF(...)
#define RADIX_SORT(VTYPE, RTYPE, N, V, RANK)
ABC_NAMESPACE_HEADER_START typedef unsigned reference
#define VALID_INTERNAL_LITERAL(LIT)
#define forward_terminated_1
#define BEGIN_WATCHES(WS)
#define SET_END_OF_WATCHES(WS, P)