ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
propdense.c
Go to the documentation of this file.
1#include "propdense.h"
2#include "fastassign.h"
3
5
6static inline bool non_watching_propagate_literal (kissat *solver,
7 unsigned lit) {
8 KISSAT_assert (!solver->watching);
9 LOG ("propagating %s", LOGLIT (lit));
10 KISSAT_assert (VALUE (lit) > 0);
11 const unsigned not_lit = NOT (lit);
12
13 watches *watches = &WATCHES (not_lit);
14 const size_t size_watches = SIZE_WATCHES (*watches);
15 unsigned ticks = 1 + kissat_cache_lines (size_watches, sizeof (watch));
16
17 ward *const arena = BEGIN_STACK (solver->arena);
18 assigned *assigned = solver->assigned;
19 value *values = solver->values;
20 flags *flags = solver->flags;
21
23 if (watch.type.binary) {
24 const unsigned other = watch.binary.lit;
26 const value other_value = values[other];
27 if (other_value > 0)
28 continue;
29 if (other_value < 0) {
30 LOGBINARY (not_lit, other, "conflicting");
31 return false;
32 }
33 const unsigned other_idx = IDX (other);
34 if (flags[other_idx].eliminated)
35 continue;
36 KISSAT_assert (!solver->level);
37 kissat_fast_binary_assign (solver, solver->probing, 0, values,
38 assigned, other, not_lit);
39 } else {
40 const reference ref = watch.large.ref;
41 KISSAT_assert (ref < SIZE_STACK (solver->arena));
42 clause *c = (clause *) (arena + ref);
43 KISSAT_assert (c->size > 2);
45 ticks++;
46 if (c->garbage)
47 continue;
48 unsigned non_false = 0;
49 unsigned unit = INVALID_LIT;
50 bool satisfied = false;
51 for (all_literals_in_clause (other, c)) {
52 if (other == not_lit)
53 continue;
55 const value other_value = values[other];
56 if (other_value < 0)
57 continue;
58 if (other_value > 0) {
59 satisfied = true;
60 KISSAT_assert (!solver->level);
61 LOGCLS (c, "%s satisfied", LOGLIT (other));
63 break;
64 }
65 if (!non_false++)
66 unit = other;
67 else if (non_false > 1)
68 break;
69 }
70 if (satisfied)
71 continue;
72 if (!non_false) {
73 LOGREF (ref, "conflicting");
74 return false;
75 }
76 if (non_false == 1)
77 kissat_fast_assign_reference (solver, values, assigned, unit, ref,
78 c);
79 }
80 }
81
82 ADD (ticks, ticks);
83 ADD (dense_ticks, ticks);
84
85 return true;
86}
87
89 KISSAT_assert (!solver->level);
90 KISSAT_assert (!solver->watching);
91 KISSAT_assert (!solver->inconsistent);
92 START (propagate);
93 unsigned *propagate = solver->propagate;
94 bool res = true;
95 while (res && propagate != END_ARRAY (solver->trail))
96 res = non_watching_propagate_literal (solver, *propagate++);
97 const unsigned propagated = propagate - solver->propagate;
98 solver->propagate = propagate;
99 ADD (dense_propagations, propagated);
100 ADD (propagations, propagated);
101 if (!res) {
102 KISSAT_assert (!solver->inconsistent);
103 LOG ("inconsistent root propagation");
106 solver->inconsistent = true;
107 }
108 STOP (propagate);
109 return res;
110}
111
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
ABC_NAMESPACE_HEADER_START typedef word ward
Definition arena.h:12
#define END_ARRAY
Definition array.h:51
#define BEGIN_STACK(S)
Definition stack.h:46
#define SIZE_STACK(S)
Definition stack.h:19
#define INVALID_LIT
#define ADD(NAME, DELTA)
#define LOG(...)
ABC_NAMESPACE_IMPL_START typedef signed char value
#define CHECK_AND_ADD_EMPTY(...)
Definition check.h:146
void kissat_mark_clause_as_garbage(kissat *solver, clause *c)
Definition clause.c:164
#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 LOGREF(...)
Definition logging.h:433
#define LOGBINARY(...)
Definition logging.h:442
#define LOGCLS(...)
Definition logging.h:415
#define LOGLIT(...)
Definition logging.hpp:99
unsigned short ref
Definition giaNewBdd.h:38
#define STOP(P)
Definition profile.hpp:158
#define START(P)
Definition profile.hpp:150
#define ADD_EMPTY_TO_PROOF(...)
Definition proof.h:135
bool kissat_dense_propagate(kissat *solver)
Definition propdense.c:88
ABC_NAMESPACE_HEADER_START typedef unsigned reference
Definition reference.h:9
int lit
Definition satVec.h:130
#define VALID_INTERNAL_LITERAL(LIT)
Definition literal.h:23
#define IDX(LIT)
Definition literal.h:28
#define NOT(LIT)
Definition literal.h:33
bool redundant
Definition clause.h:28
unsigned size
Definition clause.h:37
bool garbage
Definition clause.h:25
Definition flags.h:11
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
#define VALUE(LIT)
Definition value.h:10
#define SIZE_WATCHES(W)
Definition watch.h:104
vector watches
Definition watch.h:49
#define all_binary_large_watches(WATCH, WATCHES)
Definition watch.h:158
#define WATCHES(LIT)
Definition watch.h:137