ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
collect.c
Go to the documentation of this file.
1#define INLINE_SORT
2
3#include "collect.h"
4#include "allocate.h"
5#include "colors.h"
6#include "compact.h"
7#include "inline.h"
8#include "print.h"
9#include "report.h"
10#include "sort.c"
11#include "trail.h"
12
13#include <inttypes.h>
14#include <string.h>
15
17
18static void flush_watched_clauses_by_literal (kissat *solver, unsigned lit,
19 bool compact,
20 reference start) {
21 KISSAT_assert (start != INVALID_REF);
22
23 const value *const values = solver->values;
24 const assigned *const all_assigned = solver->assigned;
25
26 const value lit_value = values[lit];
27 const assigned *const lit_assigned = all_assigned + IDX (lit);
28 const value lit_fixed =
29 (lit_value && !lit_assigned->level) ? lit_value : 0;
30 const unsigned mlit = kissat_map_literal (solver, lit, true);
31
32 watches *lit_watches = &WATCHES (lit);
33 watch *begin = BEGIN_WATCHES (*lit_watches), *q = begin;
34 const watch *const end_of_watches = END_WATCHES (*lit_watches), *p = q;
35
36 while (p != end_of_watches) {
37 watch head = *p++;
38 if (head.type.binary) {
39 const unsigned other = head.binary.lit;
40 const unsigned other_idx = IDX (other);
41 const value other_value = values[other];
42 const value other_fixed =
43 (other_value && !all_assigned[other_idx].level) ? other_value : 0;
44 const unsigned mother = kissat_map_literal (solver, other, compact);
45 if (lit_fixed > 0 || other_fixed > 0 || mother == INVALID_LIT) {
46 if (lit < other)
48 } else {
49 KISSAT_assert (!lit_fixed);
50 KISSAT_assert (!other_fixed);
51
52 {
53 head.binary.lit = mother;
54 *q++ = head;
55#ifdef LOGGING
56 if (lit < other) {
57 LOGBINARY (lit, other, "SRC");
58 LOGBINARY (mlit, mother, "DST");
59 }
60#endif
61 }
62 }
63 } else {
64 KISSAT_assert (solver->watching);
65 const watch tail = *p++;
66 if (!lit_fixed) {
67 const reference ref = tail.large.ref;
68 if (ref < start) {
69 *q++ = head;
70 *q++ = tail;
71 }
72 }
73 }
74 }
75
76 KISSAT_assert (!lit_fixed || q == begin);
77 SET_END_OF_WATCHES (*lit_watches, q);
78#ifdef LOGGING
79 const size_t size_lit_watches = SIZE_WATCHES (*lit_watches);
80 LOG ("keeping %zu watches[%u]", size_lit_watches, lit);
81#endif
82 if (!compact)
83 return;
84
85 if (mlit == INVALID_LIT)
86 return;
87
88 watches *mlit_watches = &WATCHES (mlit);
89#if defined(LOGGING) || !defined(KISSAT_NDEBUG)
90 const size_t size_mlit_watches = SIZE_WATCHES (*mlit_watches);
91#endif
92 if (lit_fixed)
93 KISSAT_assert (!size_mlit_watches);
94 else if (mlit < lit) {
95 KISSAT_assert (mlit != INVALID_LIT);
96 KISSAT_assert (mlit < lit);
97 *mlit_watches = *lit_watches;
98 LOG ("copied watches[%u] = watches[%u] (size %zu)", mlit, lit,
99 size_mlit_watches);
100 memset (lit_watches, 0, sizeof *lit_watches);
101 } else
102 KISSAT_assert (mlit == lit);
103}
104
105static void flush_all_watched_clauses (kissat *solver, bool compact,
106 reference start) {
107 KISSAT_assert (solver->watching);
108 LOG ("starting to flush watches at clause[%" REFERENCE_FORMAT "]", start);
109 for (all_variables (idx)) {
110 const unsigned lit = LIT (idx);
111 flush_watched_clauses_by_literal (solver, lit, compact, start);
112 const unsigned not_lit = NOT (lit);
113 flush_watched_clauses_by_literal (solver, not_lit, compact, start);
114 }
115}
116
117static void update_large_reason (kissat *solver, assigned *assigned,
118 unsigned forced, clause *dst) {
119 KISSAT_assert (dst->reason);
120 KISSAT_assert (forced != INVALID_LIT);
121 reference dst_ref = kissat_reference_clause (solver, dst);
122 const unsigned forced_idx = IDX (forced);
123 struct assigned *a = assigned + forced_idx;
124 KISSAT_assert (!a->binary);
125 if (a->reason != dst_ref) {
126 LOG ("reason reference %u of %s updated to %u", a->reason,
127 LOGLIT (forced), dst_ref);
128 a->reason = dst_ref;
129 }
130 dst->reason = false;
131}
132
133static unsigned get_forced (const value *values, clause *dst) {
134 KISSAT_assert (dst->reason);
135 unsigned forced = INVALID_LIT;
136 for (all_literals_in_clause (lit, dst)) {
137 const value value = values[lit];
138 if (value <= 0)
139 continue;
140 forced = lit;
141 break;
142 }
143 KISSAT_assert (forced != INVALID_LIT);
144 return forced;
145}
146
147static void get_forced_and_update_large_reason (kissat *solver,
149 const value *const values,
150 clause *dst) {
151 const unsigned forced = get_forced (values, dst);
152 update_large_reason (solver, assigned, forced, dst);
153}
154
155static void update_first_reducible (kissat *solver, const clause *end,
156 clause *first_reducible) {
157 if (first_reducible >= end) {
158 LOG ("first reducible after end of arena");
159 solver->first_reducible = INVALID_REF;
160 } else if (first_reducible) {
161 LOGCLS (first_reducible, "updating first reducible clause to");
162 solver->first_reducible =
163 kissat_reference_clause (solver, first_reducible);
164 } else {
165 LOG ("first reducible clause becomes invalid");
166 solver->first_reducible = INVALID_REF;
167 }
168}
169
170static void update_last_irredundant (kissat *solver, const clause *end,
171 clause *last_irredundant) {
172 if (!last_irredundant) {
173 LOG ("no more large irredundant clauses left");
174 solver->last_irredundant = INVALID_REF;
175 } else if (end <= last_irredundant) {
176 LOG ("last irredundant clause after end of arena");
177 solver->last_irredundant = INVALID_REF;
178 } else {
179 LOGCLS (last_irredundant, "updating last irredundant clause to");
180 reference ref = kissat_reference_clause (solver, last_irredundant);
181 solver->last_irredundant = ref;
182 }
183}
184
187 KISSAT_assert (!reducible->garbage);
188 KISSAT_assert (reducible->redundant);
189 if (solver->first_reducible != INVALID_REF) {
190 reference ref = kissat_reference_clause (solver, reducible);
191 if (ref >= solver->first_reducible) {
192 LOG ("no need to update larger first reducible");
193 return;
194 }
195 }
196 clause *end = (clause *) END_STACK (solver->arena);
197 update_first_reducible (solver, end, reducible);
198}
199
202 KISSAT_assert (!irredundant->garbage);
203 KISSAT_assert (!irredundant->redundant);
204 if (solver->last_irredundant != INVALID_REF) {
205 reference ref = kissat_reference_clause (solver, irredundant);
206 if (ref <= solver->last_irredundant) {
207 LOG ("no need to update smaller last irredundant");
208 return;
209 }
210 }
211 clause *end = (clause *) END_STACK (solver->arena);
212 update_last_irredundant (solver, end, irredundant);
213}
214
215static void move_redundant_clauses_to_the_end (kissat *solver,
216 reference ref) {
217 INC (moved);
218 KISSAT_assert (ref != INVALID_REF);
219#ifndef KISSAT_NDEBUG
220 const size_t size = SIZE_STACK (solver->arena);
221 KISSAT_assert ((size_t) ref <= size);
222#endif
223 clause *begin = (clause *) (BEGIN_STACK (solver->arena) + ref);
224 clause *end = (clause *) END_STACK (solver->arena);
225 size_t bytes_redundant = (char *) end - (char *) begin;
226 kissat_phase (solver, "move", GET (moved),
227 "moving redundant clauses of %s to the end",
228 FORMAT_BYTES (bytes_redundant));
230 clause *redundant = (clause *) kissat_malloc (solver, bytes_redundant);
231 clause *p = begin, *q = begin, *r = redundant;
232
233 const value *const values = solver->values;
234 assigned *assigned = solver->assigned;
235
236 clause *last_irredundant = kissat_last_irredundant_clause (solver);
237
238 while (p != end) {
239 KISSAT_assert (!p->shrunken);
240 size_t bytes = kissat_bytes_of_clause (p->size);
241 if (p->redundant) {
242 memcpy (r, p, bytes);
243 r = (clause *) (bytes + (char *) r);
244 } else {
245 LOGCLS (p, "old DST");
246 memmove (q, p, bytes);
247 LOGCLS (q, "new DST");
248 last_irredundant = q;
249 if (q->reason)
250 get_forced_and_update_large_reason (solver, assigned, values, q);
251 q = (clause *) (bytes + (char *) q);
252 }
253 p = (clause *) (bytes + (char *) p);
254 }
255 r = redundant;
256 clause *first_reducible = 0;
257 while (q != end) {
258 size_t bytes = kissat_bytes_of_clause (r->size);
259 memcpy (q, r, bytes);
260 LOGCLS (q, "new DST");
261 if (q->reason)
262 get_forced_and_update_large_reason (solver, assigned, values, q);
263 KISSAT_assert (q->redundant);
264 if (!first_reducible)
265 first_reducible = q;
266 r = (clause *) (bytes + (char *) r);
267 q = (clause *) (bytes + (char *) q);
268 }
269 KISSAT_assert ((char *) r <= (char *) redundant + bytes_redundant);
270 kissat_free (solver, redundant, bytes_redundant);
271
272 KISSAT_assert (!first_reducible || first_reducible < q);
273
274 update_first_reducible (solver, q, first_reducible);
275 update_last_irredundant (solver, q, last_irredundant);
277}
278
279static reference sparse_sweep_garbage_clauses (kissat *solver, bool compact,
280 reference start) {
281 KISSAT_assert (solver->watching);
282 LOG ("sparse garbage collection starting at clause[%" REFERENCE_FORMAT
283 "]",
284 start);
285#ifdef CHECKING_OR_PROVING
286 const bool checking_or_proving = kissat_checking_or_proving (solver);
287#endif
289 KISSAT_assert (EMPTY_STACK (solver->removed));
290
291 const value *const values = solver->values;
292 assigned *assigned = solver->assigned;
293
294#ifndef KISSAT_QUIET
295 size_t flushed_garbage_clauses = 0;
296 size_t flushed_satisfied_clauses = 0;
297#endif
298 size_t flushed = 0;
299
300 clause *begin = (clause *) BEGIN_STACK (solver->arena);
301 const clause *const end = (clause *) END_STACK (solver->arena);
302
303 clause *first, *src, *dst;
304 if (start)
305 first = kissat_dereference_clause (solver, start);
306 else
307 first = begin;
308 src = dst = first;
309
310 clause *first_redundant = 0;
311 clause *first_reducible = 0;
312 clause *last_irredundant;
313
314 if (start)
315 last_irredundant = kissat_last_irredundant_clause (solver);
316 else
317 last_irredundant = 0;
318#ifdef LOGGING
319 size_t redundant_bytes = 0;
320#endif
321 for (clause *next; src != end; src = next) {
322 if (src->garbage) {
323 next = kissat_delete_clause (solver, src);
324#ifndef KISSAT_QUIET
325 flushed_garbage_clauses++;
326#endif
327 if (last_irredundant == src) {
328 if (first == begin)
329 last_irredundant = 0;
330 else
331 last_irredundant = first;
332 }
333 continue;
334 }
335
336 KISSAT_assert (src->size > 1);
337 LOGCLS (src, "SRC");
338 next = kissat_next_clause (src);
339#if !defined(KISSAT_NDEBUG) || defined(CHECKING_OR_PROVING)
340 const unsigned old_size = src->size;
341#endif
342 KISSAT_assert (SIZE_OF_CLAUSE_HEADER == sizeof (unsigned));
343 *(unsigned *) dst = *(unsigned *) src;
344
345 unsigned *q = dst->lits;
346
347 unsigned mfirst = INVALID_LIT;
348 unsigned msecond = INVALID_LIT;
349 unsigned forced = INVALID_LIT;
350 unsigned other = INVALID_LIT;
351 unsigned non_false = 0;
352
353 bool satisfied = false;
354
355 for (all_literals_in_clause (lit, src)) {
356#ifdef CHECKING_OR_PROVING
357 if (checking_or_proving)
358 PUSH_STACK (solver->removed, lit);
359#endif
360 if (satisfied)
361 continue;
362
363 const value tmp = values[lit];
364 const unsigned idx = IDX (lit);
365 const unsigned level = tmp ? assigned[idx].level : INVALID_LEVEL;
366
367 if (tmp < 0 && !level)
368 flushed++;
369 else if (tmp > 0 && !level) {
370 KISSAT_assert (!satisfied);
371 KISSAT_assert (!dst->reason);
372 LOG ("SRC satisfied by %s", LOGLIT (lit));
373 satisfied = true;
374 } else {
375 const unsigned mlit = kissat_map_literal (solver, lit, compact);
376
377 if (tmp > 0) {
379 forced = non_false++ ? INVALID_LIT : lit;
380 } else if (tmp < 0)
381 other = lit;
382
383 if (mfirst == INVALID_LIT)
384 mfirst = mlit;
385 else if (msecond == INVALID_LIT)
386 msecond = mlit;
387
388 *q++ = mlit;
389
390#ifdef CHECKING_OR_PROVING
391 if (checking_or_proving)
392 PUSH_STACK (solver->added, lit);
393#endif
394 }
395 }
396
397 if (satisfied) {
398 if (dst->redundant)
399 DEC (clauses_redundant);
400 else
401 DEC (clauses_irredundant);
402#ifndef KISSAT_QUIET
403 flushed_satisfied_clauses++;
404#endif
405#ifdef CHECKING_OR_PROVING
406 if (checking_or_proving) {
407 REMOVE_CHECKER_STACK (solver->removed);
409 CLEAR_STACK (solver->added);
410 CLEAR_STACK (solver->removed);
411 }
412#endif
413 if (last_irredundant == src) {
414 if (first == begin)
415 last_irredundant = 0;
416 else
417 last_irredundant = first;
418 }
419 continue;
420 }
421
422 const unsigned new_size = q - dst->lits;
423 KISSAT_assert (new_size <= old_size);
424 KISSAT_assert (1 < new_size);
425
426 if (new_size == 2) {
427 KISSAT_assert (mfirst != INVALID_LIT);
428 KISSAT_assert (msecond != INVALID_LIT);
429
430 statistics *statistics = &solver->statistics_;
431 KISSAT_assert (statistics->clauses_binary < UINT64_MAX);
432 statistics->clauses_binary++;
433 bool redundant = dst->redundant;
434 if (redundant) {
435 KISSAT_assert (statistics->clauses_redundant > 0);
436 statistics->clauses_redundant--;
437 redundant = false;
438 } else {
439 KISSAT_assert (statistics->clauses_irredundant > 0);
440 statistics->clauses_irredundant--;
441 }
442 LOGBINARY (mfirst, msecond, "DST");
443 kissat_watch_binary (solver, mfirst, msecond);
444
445 if (dst->reason) {
446 KISSAT_assert (non_false == 1);
447 KISSAT_assert (other != INVALID_LIT);
448 KISSAT_assert (forced != INVALID_LIT);
449
450 const unsigned forced_idx = IDX (forced);
451 struct assigned *a = assigned + forced_idx;
452 KISSAT_assert (!a->binary);
453
454 LOGBINARY (mfirst, msecond,
455 "reason clause[%u] of %s updated to binary reason",
456 a->reason, LOGLIT (forced));
457
458 a->binary = true;
459 a->reason = other;
460 }
461
462 if (!redundant && last_irredundant == src) {
463 if (first == begin)
464 last_irredundant = 0;
465 else
466 last_irredundant = first;
467 }
468 } else {
469 KISSAT_assert (2 < new_size);
470
471 dst->size = new_size;
472 dst->shrunken = false;
473 dst->searched = 2;
474
475 LOGCLS (dst, "DST");
476 if (dst->reason)
477 update_large_reason (solver, assigned, forced, dst);
478
479 clause *next_dst = kissat_next_clause (dst);
480
481 if (dst->redundant) {
482 if (!first_reducible)
483 first_reducible = dst;
484#ifdef LOGGING
485 redundant_bytes += (char *) next_dst - (char *) dst;
486#endif
487 if (!first_redundant)
488 first_redundant = dst;
489 } else
490 last_irredundant = dst;
491
492 dst = next_dst;
493 }
494
495#ifdef CHECKING_OR_PROVING
496 if (!checking_or_proving)
497 continue;
498
499 if (new_size != old_size) {
500 KISSAT_assert (1 < new_size);
501 KISSAT_assert (new_size < old_size);
502
504 ADD_STACK_TO_PROOF (solver->added);
505
506 REMOVE_CHECKER_STACK (solver->removed);
508 }
509 CLEAR_STACK (solver->added);
510 CLEAR_STACK (solver->removed);
511#endif
512 }
513
514 update_first_reducible (solver, dst, first_reducible);
515 update_last_irredundant (solver, dst, last_irredundant);
517
518 if (first_redundant)
519 LOGCLS (first_redundant, "determined first redundant clause as");
520
521#if !defined(KISSAT_QUIET) || defined(METRICS)
522 size_t bytes = (char *) END_STACK (solver->arena) - (char *) dst;
523#endif
524#ifndef KISSAT_QUIET
525 if (flushed)
526 kissat_phase (solver, "collect", GET (garbage_collections),
527 "flushed %zu falsified literals in large clauses",
528 flushed);
529 size_t flushed_clauses =
530 flushed_satisfied_clauses + flushed_garbage_clauses;
531 if (flushed_satisfied_clauses)
533 solver, "collect", GET (garbage_collections),
534 "flushed %zu satisfied large clauses %.0f%%",
535 flushed_satisfied_clauses,
536 kissat_percent (flushed_satisfied_clauses, flushed_clauses));
537 if (flushed_garbage_clauses)
539 solver, "collect", GET (garbage_collections),
540 "flushed %zu large garbage clauses %.0f%%", flushed_garbage_clauses,
541 kissat_percent (flushed_garbage_clauses, flushed_clauses));
542 kissat_phase (solver, "collect", GET (garbage_collections),
543 "collected %s in total", FORMAT_BYTES (bytes));
544#endif
545 ADD (flushed, flushed);
546#ifdef METRICS
547 ADD (allocated_collected, bytes);
548#endif
549
551
552 if (first_redundant && last_irredundant &&
553 first_redundant < last_irredundant) {
554#ifdef LOGGING
555 size_t move_bytes = (char *) dst - (char *) first_redundant;
556 LOG ("redundant bytes %s (%.0f%%) out of %s moving bytes",
557 FORMAT_BYTES (redundant_bytes),
558 kissat_percent (redundant_bytes, move_bytes),
559 FORMAT_BYTES (move_bytes));
560#endif
561 KISSAT_assert (first_redundant < dst);
562 res = kissat_reference_clause (solver, first_redundant);
563 KISSAT_assert (res != INVALID_REF);
564 }
565
566 SET_END_OF_STACK (solver->arena, (ward *) dst);
568
569#ifdef METRICS
570 if (solver->statistics_.arena_garbage)
571 kissat_very_verbose (solver, "still %s garbage left in arena",
572 FORMAT_BYTES (solver->statistics_.arena_garbage));
573 else
574 kissat_very_verbose (solver, "all garbage clauses in arena collected");
575#endif
576
577 return res;
578}
579
580static void rewatch_clauses (kissat *solver, reference start) {
581 LOG ("rewatching clause[%" REFERENCE_FORMAT "] and following clauses",
582 start);
583 KISSAT_assert (solver->watching);
584
585 const value *const values = solver->values;
586 const assigned *const assigned = solver->assigned;
587 watches *watches = solver->watches;
588 ward *const arena = BEGIN_STACK (solver->arena);
589
590 clause *end = (clause *) END_STACK (solver->arena);
591 clause *c = (clause *) (BEGIN_STACK (solver->arena) + start);
592 KISSAT_assert (c <= end);
593
594 for (clause *next; c != end; c = next) {
595 next = kissat_next_clause (c);
596
597 unsigned *lits = c->lits;
598 kissat_sort_literals (solver, values, assigned, c->size, lits);
599 c->searched = 2;
600
601 const reference ref = (ward *) c - arena;
602 const unsigned l0 = lits[0];
603 const unsigned l1 = lits[1];
604
605 kissat_push_blocking_watch (solver, watches + l0, l1, ref);
606 kissat_push_blocking_watch (solver, watches + l1, l0, ref);
607 }
608}
609
610void kissat_sparse_collect (kissat *solver, bool compact, reference start) {
611 KISSAT_assert (solver->watching);
612 START (collect);
613 INC (garbage_collections);
614 INC (sparse_gcs);
615 REPORT (1, 'G');
616 unsigned vars, mfixed;
617 if (compact)
618 vars = kissat_compact_literals (solver, &mfixed);
619 else {
620 vars = solver->vars;
621 mfixed = INVALID_LIT;
622 }
623 flush_all_watched_clauses (solver, compact, start);
624 reference move = sparse_sweep_garbage_clauses (solver, compact, start);
625 if (compact)
626 kissat_finalize_compacting (solver, vars, mfixed);
627 if (move != INVALID_REF)
628 move_redundant_clauses_to_the_end (solver, move);
629 rewatch_clauses (solver, start);
630 REPORT (1, 'C');
632 STOP (collect);
633}
634
636 if (!GET_OPTION (compact))
637 return false;
638 unsigned inactive = solver->vars - solver->active;
639 unsigned limit = GET_OPTION (compactlim) / 1e2 * solver->vars;
640 bool compact = (inactive > limit);
641 LOG ("%u inactive variables %.0f%% <= limit %u %.0f%%", inactive,
642 kissat_percent (inactive, solver->vars), limit,
643 kissat_percent (limit, solver->vars));
644 return compact;
645}
646
648 KISSAT_assert (!solver->level);
649 KISSAT_assert (!solver->inconsistent);
650 KISSAT_assert (solver->watching);
651 KISSAT_assert (kissat_trail_flushed (solver));
652 if (solver->statistics_.units) {
653 bool compact = GET_OPTION (compact);
654 kissat_sparse_collect (solver, compact, 0);
655 }
656 REPORT (0, '.');
657}
658
659static void dense_sweep_garbage_clauses (kissat *solver) {
660 KISSAT_assert (!solver->level);
661 KISSAT_assert (!solver->watching);
662
663 LOG ("dense garbage collection");
664
665#ifndef KISSAT_QUIET
666 size_t flushed_garbage_clauses = 0;
667#endif
668 clause *first_reducible = 0;
669 clause *last_irredundant = 0;
670
671 clause *begin = (clause *) BEGIN_STACK (solver->arena);
672 const clause *const end = (clause *) END_STACK (solver->arena);
673
674 clause *src = begin;
675 clause *dst = src;
676
677 for (clause *next; src != end; src = next) {
678 if (src->garbage) {
679 next = kissat_delete_clause (solver, src);
680#ifndef KISSAT_QUIET
681 flushed_garbage_clauses++;
682#endif
683 continue;
684 }
685 KISSAT_assert (src->size > 1);
686 LOGCLS (src, "SRC");
687 next = kissat_next_clause (src);
688 KISSAT_assert (SIZE_OF_CLAUSE_HEADER == sizeof (unsigned));
689 *(unsigned *) dst = *(unsigned *) src;
690 dst->searched = src->searched;
691 dst->size = src->size;
692 dst->shrunken = false;
693 memmove (dst->lits, src->lits, src->size * sizeof (unsigned));
694 LOGCLS (dst, "DST");
695 if (!dst->redundant)
696 last_irredundant = dst;
697 else if (!first_reducible)
698 first_reducible = dst;
699 dst = kissat_next_clause (dst);
700 }
701
702 update_first_reducible (solver, dst, first_reducible);
703 update_last_irredundant (solver, dst, last_irredundant);
705
706#if !defined(KISSAT_QUIET) || defined(METRICS)
707 size_t bytes = (char *) END_STACK (solver->arena) - (char *) dst;
708#endif
709 kissat_phase (solver, "collect", GET (garbage_collections),
710 "flushed %zu large garbage clauses",
711 flushed_garbage_clauses);
712 kissat_phase (solver, "collect", GET (garbage_collections),
713 "collected %s in total", FORMAT_BYTES (bytes));
714#ifdef METRICS
715 ADD (allocated_collected, bytes);
716#endif
717
718 SET_END_OF_STACK (solver->arena, (ward *) dst);
720
721#ifdef METRICS
722 if (solver->statistics_.arena_garbage)
723 kissat_very_verbose (solver, "still %s garbage left in arena",
724 FORMAT_BYTES (solver->statistics_.arena_garbage));
725 else
726 kissat_very_verbose (solver, "all garbage clauses in arena collected");
727#endif
728}
729
731 KISSAT_assert (!solver->watching);
732 KISSAT_assert (!solver->level);
733 START (collect);
734 INC (garbage_collections);
735 INC (dense_garbage_collections);
736 REPORT (1, 'G');
737 dense_sweep_garbage_clauses (solver);
738 REPORT (1, 'C');
739 STOP (collect);
740}
741
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
void * kissat_malloc(kissat *solver, size_t bytes)
Definition allocate.c:49
void kissat_free(kissat *solver, void *ptr, size_t bytes)
Definition allocate.c:61
void kissat_shrink_arena(kissat *solver)
Definition arena.c:68
ABC_NAMESPACE_HEADER_START typedef word ward
Definition arena.h:12
#define INVALID_LEVEL
Definition assign.h:12
#define BEGIN_STACK(S)
Definition stack.h:46
#define SIZE_STACK(S)
Definition stack.h:19
#define EMPTY_STACK(S)
Definition stack.h:18
#define SET_END_OF_STACK(S, P)
Definition stack.h:62
#define CLEAR_STACK(S)
Definition stack.h:50
#define PUSH_STACK(S, E)
Definition stack.h:39
#define END_STACK(S)
Definition stack.h:48
#define INVALID_LIT
#define ADD(NAME, DELTA)
#define INC(NAME)
#define LOG(...)
ABC_NAMESPACE_IMPL_START typedef signed char value
#define CHECK_AND_ADD_STACK(...)
Definition check.h:152
#define REMOVE_CHECKER_STACK(...)
Definition check.h:173
clause * kissat_delete_clause(kissat *solver, clause *c)
Definition clause.c:171
void kissat_delete_binary(kissat *solver, unsigned a, unsigned b)
Definition clause.c:181
void kissat_update_last_irredundant(kissat *solver, clause *irredundant)
Definition collect.c:200
void kissat_update_first_reducible(kissat *solver, clause *reducible)
Definition collect.c:185
void kissat_dense_collect(kissat *solver)
Definition collect.c:730
bool kissat_compacting(kissat *solver)
Definition collect.c:635
void kissat_initial_sparse_collect(kissat *solver)
Definition collect.c:647
void kissat_sparse_collect(kissat *solver, bool compact, reference start)
Definition collect.c:610
unsigned kissat_compact_literals(kissat *solver, unsigned *mfixed_ptr)
Definition compact.c:21
void kissat_finalize_compacting(kissat *solver, unsigned vars, unsigned mfixed)
Definition compact.c:322
pcover irredundant()
Cube * p
Definition exorList.c:222
#define FORMAT_BYTES(BYTES)
Definition format.h:31
ABC_NAMESPACE_IMPL_START void kissat_reset_last_learned(kissat *solver)
Definition internal.c:22
#define all_variables(IDX)
Definition internal.h:269
#define SIZE_OF_CLAUSE_HEADER
Definition clause.h:42
void kissat_sort_literals(struct kissat *, unsigned size, unsigned *lits)
Definition sort.c:85
#define all_literals_in_clause(LIT, C)
Definition clause.h:47
#define KISSAT_assert(ignore)
Definition global.h:13
#define solver
Definition kitten.c:211
#define LOGBINARY(...)
Definition logging.h:442
#define LOGCLS(...)
Definition logging.h:415
#define LOGLIT(...)
Definition logging.hpp:99
unsigned long long size
Definition giaNewBdd.h:39
unsigned short ref
Definition giaNewBdd.h:38
#define GET_OPTION(N)
Definition options.h:295
#define kissat_very_verbose(...)
Definition print.h:52
#define kissat_phase(...)
Definition print.h:48
#define STOP(P)
Definition profile.hpp:158
#define START(P)
Definition profile.hpp:150
#define ADD_STACK_TO_PROOF(...)
Definition proof.h:138
#define DELETE_STACK_FROM_PROOF(...)
Definition proof.h:161
#define INVALID_REF
Definition reference.h:16
ABC_NAMESPACE_HEADER_START typedef unsigned reference
Definition reference.h:9
#define REFERENCE_FORMAT
Definition reference.h:11
#define REPORT(...)
Definition report.h:10
int lit
Definition satVec.h:130
#define LIT(IDX)
Definition literal.h:31
#define IDX(LIT)
Definition literal.h:28
#define NOT(LIT)
Definition literal.h:33
#define kissat_check_statistics(...)
Definition statistics.h:464
#define GET(NAME)
Definition statistics.h:416
#define DEC(NAME)
Definition statistics.h:413
bool binary
Definition assign.h:23
unsigned reason
Definition assign.h:28
unsigned level
Definition assign.h:19
bool reason
Definition clause.h:27
unsigned lits[3]
Definition clause.h:39
bool redundant
Definition clause.h:28
unsigned searched
Definition clause.h:36
unsigned size
Definition clause.h:37
bool shrunken
Definition clause.h:29
bool garbage
Definition clause.h:25
void kissat_mark_reason_clauses(kissat *solver, reference start)
Definition trail.c:20
Definition watch.h:41
large_watch large
Definition watch.h:45
watch_type type
Definition watch.h:42
binary_watch binary
Definition watch.h:43
char * memcpy()
char * memset()
char * memmove()
#define SIZE_WATCHES(W)
Definition watch.h:104
#define BEGIN_WATCHES(WS)
Definition watch.h:115
#define END_WATCHES(WS)
Definition watch.h:118
#define SET_END_OF_WATCHES(WS, P)
Definition watch.h:128
vector watches
Definition watch.h:49
#define WATCHES(LIT)
Definition watch.h:137