ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
watch.h File Reference
#include "keatures.h"
#include "reference.h"
#include "stack.h"
#include "vector.h"
#include <stdbool.h>
#include "global.h"
Include dependency graph for watch.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  binary_tagged_literal
 
struct  binary_tagged_reference
 
union  watch
 
struct  litwatch
 
struct  litpair
 
struct  litriple
 

Macros

#define EMPTY_WATCHES(W)
 
#define SIZE_WATCHES(W)
 
#define PUSH_WATCHES(W, E)
 
#define LAST_WATCH_POINTER(WS)
 
#define BEGIN_WATCHES(WS)
 
#define END_WATCHES(WS)
 
#define BEGIN_CONST_WATCHES(WS)
 
#define END_CONST_WATCHES(WS)
 
#define RELEASE_WATCHES(WS)
 
#define SET_END_OF_WATCHES(WS, P)
 
#define REMOVE_WATCHES(W, E)
 
#define WATCHES(LIT)
 
#define all_binary_blocking_watch_ref(WATCH, REF, WATCHES)
 
#define all_binary_blocking_watches(WATCH, WATCHES)
 
#define all_binary_large_watches(WATCH, WATCHES)
 

Typedefs

typedef typedefABC_NAMESPACE_HEADER_START union watch watch
 
typedef struct binary_tagged_literal watch_type
 
typedef struct binary_tagged_literal binary_watch
 
typedef struct binary_tagged_literal blocking_watch
 
typedef struct binary_tagged_reference large_watch
 
typedef vector watches
 
typedef struct litwatch litwatch
 
typedef struct litpair litpair
 
typedef struct litriple litriple
 

Functions

typedef STACK (litwatch) litwatches
 
typedef STACK (litpair) litpairs
 
typedef STACK (litriple) litriples
 
void kissat_remove_binary_watch (struct kissat *, watches *, unsigned)
 
void kissat_remove_blocking_watch (struct kissat *, watches *, reference)
 
void kissat_substitute_large_watch (struct kissat *, watches *, watch src, watch dst)
 
void kissat_flush_all_connected (struct kissat *)
 
void kissat_flush_large_watches (struct kissat *)
 
void kissat_watch_large_clauses (struct kissat *)
 
void kissat_flush_large_connected (struct kissat *)
 
void kissat_connect_irredundant_large_clauses (struct kissat *)
 

Macro Definition Documentation

◆ all_binary_blocking_watch_ref

#define all_binary_blocking_watch_ref ( WATCH,
REF,
WATCHES )
Value:
watch WATCH, \
*WATCH##_PTR = (KISSAT_assert (solver->watching), BEGIN_WATCHES (WATCHES)), \
*const WATCH##_END = END_WATCHES (WATCHES); \
WATCH##_PTR != WATCH##_END && \
((WATCH = *WATCH##_PTR), \
(REF = WATCH.type.binary ? INVALID_REF : WATCH##_PTR[1].large.ref), \
true); \
WATCH##_PTR += 1u + !WATCH.type.binary
#define KISSAT_assert(ignore)
Definition global.h:13
#define solver
Definition kitten.c:211
#define INVALID_REF
Definition reference.h:16
Definition watch.h:41
large_watch large
Definition watch.h:45
watch_type type
Definition watch.h:42
#define BEGIN_WATCHES(WS)
Definition watch.h:115
#define END_WATCHES(WS)
Definition watch.h:118
#define WATCHES(LIT)
Definition watch.h:137

Definition at line 141 of file watch.h.

141#define all_binary_blocking_watch_ref(WATCH, REF, WATCHES) \
142 watch WATCH, \
143 *WATCH##_PTR = (KISSAT_assert (solver->watching), BEGIN_WATCHES (WATCHES)), \
144 *const WATCH##_END = END_WATCHES (WATCHES); \
145 WATCH##_PTR != WATCH##_END && \
146 ((WATCH = *WATCH##_PTR), \
147 (REF = WATCH.type.binary ? INVALID_REF : WATCH##_PTR[1].large.ref), \
148 true); \
149 WATCH##_PTR += 1u + !WATCH.type.binary

◆ all_binary_blocking_watches

#define all_binary_blocking_watches ( WATCH,
WATCHES )
Value:
watch WATCH, \
*WATCH##_PTR = (KISSAT_assert (solver->watching), BEGIN_WATCHES (WATCHES)), \
*const WATCH##_END = END_WATCHES (WATCHES); \
WATCH##_PTR != WATCH##_END && ((WATCH = *WATCH##_PTR), true); \
WATCH##_PTR += 1u + !WATCH.type.binary

Definition at line 151 of file watch.h.

151#define all_binary_blocking_watches(WATCH, WATCHES) \
152 watch WATCH, \
153 *WATCH##_PTR = (KISSAT_assert (solver->watching), BEGIN_WATCHES (WATCHES)), \
154 *const WATCH##_END = END_WATCHES (WATCHES); \
155 WATCH##_PTR != WATCH##_END && ((WATCH = *WATCH##_PTR), true); \
156 WATCH##_PTR += 1u + !WATCH.type.binary

◆ all_binary_large_watches

#define all_binary_large_watches ( WATCH,
WATCHES )
Value:
watch WATCH, \
*WATCH##_PTR = \
*const WATCH##_END = END_WATCHES (WATCHES); \
WATCH##_PTR != WATCH##_END && ((WATCH = *WATCH##_PTR), true); \
++WATCH##_PTR

Definition at line 158 of file watch.h.

158#define all_binary_large_watches(WATCH, WATCHES) \
159 watch WATCH, \
160 *WATCH##_PTR = \
161 (KISSAT_assert (!solver->watching), BEGIN_WATCHES (WATCHES)), \
162 *const WATCH##_END = END_WATCHES (WATCHES); \
163 WATCH##_PTR != WATCH##_END && ((WATCH = *WATCH##_PTR), true); \
164 ++WATCH##_PTR

◆ BEGIN_CONST_WATCHES

#define BEGIN_CONST_WATCHES ( WS)
Value:
((union watch *) kissat_begin_const_vector (solver, &(WS)))

Definition at line 120 of file watch.h.

120#define BEGIN_CONST_WATCHES(WS) \
121 ((union watch *) kissat_begin_const_vector (solver, &(WS)))

◆ BEGIN_WATCHES

#define BEGIN_WATCHES ( WS)
Value:
((union watch *) kissat_begin_vector (solver, &(WS)))

Definition at line 115 of file watch.h.

115#define BEGIN_WATCHES(WS) \
116 ((union watch *) kissat_begin_vector (solver, &(WS)))

◆ EMPTY_WATCHES

#define EMPTY_WATCHES ( W)
Value:
kissat_empty_vector (&W)

Definition at line 103 of file watch.h.

◆ END_CONST_WATCHES

#define END_CONST_WATCHES ( WS)
Value:
((union watch *) kissat_end_const_vector (solver, &(WS)))

Definition at line 123 of file watch.h.

123#define END_CONST_WATCHES(WS) \
124 ((union watch *) kissat_end_const_vector (solver, &(WS)))

◆ END_WATCHES

#define END_WATCHES ( WS)
Value:
((union watch *) kissat_end_vector (solver, &(WS)))

Definition at line 118 of file watch.h.

◆ LAST_WATCH_POINTER

#define LAST_WATCH_POINTER ( WS)
Value:
(watch *) kissat_last_vector_pointer (solver, &WS)

Definition at line 112 of file watch.h.

112#define LAST_WATCH_POINTER(WS) \
113 (watch *) kissat_last_vector_pointer (solver, &WS)

◆ PUSH_WATCHES

#define PUSH_WATCHES ( W,
E )
Value:
do { \
KISSAT_assert (sizeof (E) == sizeof (unsigned)); \
kissat_push_vectors (solver, &(W), (E).raw); \
} while (0)

Definition at line 106 of file watch.h.

106#define PUSH_WATCHES(W, E) \
107 do { \
108 KISSAT_assert (sizeof (E) == sizeof (unsigned)); \
109 kissat_push_vectors (solver, &(W), (E).raw); \
110 } while (0)

◆ RELEASE_WATCHES

#define RELEASE_WATCHES ( WS)
Value:
kissat_release_vector (solver, &(WS))

Definition at line 126 of file watch.h.

◆ REMOVE_WATCHES

#define REMOVE_WATCHES ( W,
E )
Value:
void kissat_remove_from_vector(kissat *solver, vector *vector, unsigned remove)
Definition vector.c:238

Definition at line 134 of file watch.h.

134#define REMOVE_WATCHES(W, E) \
135 kissat_remove_from_vector (solver, &(W), (E).raw)

◆ SET_END_OF_WATCHES

#define SET_END_OF_WATCHES ( WS,
P )
Value:
do { \
size_t SIZE = (unsigned *) (P) - kissat_begin_vector (solver, &WS); \
kissat_resize_vector (solver, &WS, SIZE); \
} while (0)
#define SIZE(set)
Definition espresso.h:112

Definition at line 128 of file watch.h.

128#define SET_END_OF_WATCHES(WS, P) \
129 do { \
130 size_t SIZE = (unsigned *) (P) - kissat_begin_vector (solver, &WS); \
131 kissat_resize_vector (solver, &WS, SIZE); \
132 } while (0)

◆ SIZE_WATCHES

#define SIZE_WATCHES ( W)
Value:
kissat_size_vector (&W)

Definition at line 104 of file watch.h.

◆ WATCHES

#define WATCHES ( LIT)
Value:
(solver->watches[KISSAT_assert ((LIT) < LITS), (LIT)])
#define LITS
Definition internal.h:251
#define LIT(IDX)
Definition literal.h:31

Definition at line 137 of file watch.h.

Typedef Documentation

◆ binary_watch

Definition at line 17 of file watch.h.

◆ blocking_watch

Definition at line 18 of file watch.h.

◆ large_watch

Definition at line 19 of file watch.h.

◆ litpair

typedef struct litpair litpair

Definition at line 52 of file watch.h.

◆ litriple

typedef struct litriple litriple

Definition at line 53 of file watch.h.

◆ litwatch

typedef struct litwatch litwatch

Definition at line 51 of file watch.h.

◆ watch

typedef typedefABC_NAMESPACE_HEADER_START union watch watch

Definition at line 14 of file watch.h.

◆ watch_type

Definition at line 16 of file watch.h.

◆ watches

typedef vector watches

Definition at line 49 of file watch.h.

Function Documentation

◆ kissat_connect_irredundant_large_clauses()

void kissat_connect_irredundant_large_clauses ( struct kissat * solver)

Definition at line 171 of file watch.c.

171 {
172 KISSAT_assert (!solver->watching);
173 LOG ("connecting all large irredundant clauses");
174
175 clause *last_irredundant = kissat_last_irredundant_clause (solver);
176
177 const value *const values = solver->values;
178 watches *all_watches = solver->watches;
179 ward *const arena = BEGIN_STACK (solver->arena);
180
181 for (all_clauses (c)) {
182 if (last_irredundant && c > last_irredundant)
183 break;
184 if (c->redundant)
185 continue;
186 if (c->garbage)
187 continue;
188 bool satisfied = false;
189 KISSAT_assert (!solver->level);
190 for (all_literals_in_clause (lit, c)) {
191 const value value = values[lit];
192 if (value <= 0)
193 continue;
194 satisfied = true;
195 break;
196 }
197 if (satisfied) {
199 continue;
200 }
201 const reference ref = (ward *) c - arena;
202 kissat_inlined_connect_clause (solver, all_watches, c, ref);
203 }
204}
ABC_NAMESPACE_HEADER_START typedef word ward
Definition arena.h:12
#define BEGIN_STACK(S)
Definition stack.h:46
#define LOG(...)
ABC_NAMESPACE_IMPL_START typedef signed char value
void kissat_mark_clause_as_garbage(kissat *solver, clause *c)
Definition clause.c:164
#define all_clauses(C)
Definition internal.h:279
#define all_literals_in_clause(LIT, C)
Definition clause.h:47
unsigned short ref
Definition giaNewBdd.h:38
ABC_NAMESPACE_HEADER_START typedef unsigned reference
Definition reference.h:9
int lit
Definition satVec.h:130
vector watches
Definition watch.h:49
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kissat_flush_all_connected()

void kissat_flush_all_connected ( struct kissat * solver)

Definition at line 104 of file watch.c.

104 {
105 KISSAT_assert (!solver->watching);
106 LOG ("flush all connected binaries and clauses");
107 watches *all_watches = solver->watches;
108 for (all_literals (lit))
109 RELEASE_WATCHES (all_watches[lit]);
110}
#define all_literals(LIT)
Definition internal.h:274
#define RELEASE_WATCHES(WS)
Definition watch.h:126

◆ kissat_flush_large_connected()

void kissat_flush_large_connected ( struct kissat * solver)

Definition at line 206 of file watch.c.

206 {
207 KISSAT_assert (!solver->watching);
208 LOG ("flushing large connected clause references");
209 size_t flushed = 0;
210 for (all_literals (lit)) {
212 watch *begin = BEGIN_WATCHES (*watches), *q = begin;
213 const watch *const end_watches = END_WATCHES (*watches), *p = q;
214 while (p != end_watches) {
215 const watch head = *p++;
216 if (head.type.binary)
217 *q++ = head;
218 else
219 flushed++;
220 }
222 }
223 LOG ("flushed %zu large clause references", flushed);
224 (void) flushed;
225}
Cube * p
Definition exorList.c:222
#define SET_END_OF_WATCHES(WS, P)
Definition watch.h:128
Here is the caller graph for this function:

◆ kissat_flush_large_watches()

void kissat_flush_large_watches ( struct kissat * solver)

Definition at line 112 of file watch.c.

112 {
113 KISSAT_assert (solver->watching);
114 LOG ("flush large clause watches");
115 watches *all_watches = solver->watches;
116 signed char *marks = solver->marks;
117 for (all_literals (lit)) {
118 watches *lit_watches = all_watches + lit;
119 watch *begin = BEGIN_WATCHES (*lit_watches), *q = begin;
120 const watch *const end = END_WATCHES (*lit_watches), *p = q;
121 while (p != end) {
122 const watch watch = *q++ = *p++;
123 if (!watch.type.binary)
124 p++, q--;
125 else {
126 const unsigned other = watch.binary.lit;
127 if (marks[other]) {
128 if (lit < other) {
129 LOGBINARY (lit, other, "flushing duplicated");
131 }
132 q--;
133 } else
134 marks[other] = 1;
135 }
136 }
137 SET_END_OF_WATCHES (*lit_watches, q);
138 for (p = begin; p != q; p++) {
139 KISSAT_assert (p->type.binary);
140 marks[p->binary.lit] = 0;
141 }
142 }
143}
void kissat_delete_binary(kissat *solver, unsigned a, unsigned b)
Definition clause.c:181
#define LOGBINARY(...)
Definition logging.h:442
binary_watch binary
Definition watch.h:43
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kissat_remove_binary_watch()

void kissat_remove_binary_watch ( struct kissat * solver,
watches * watches,
unsigned lit )

Definition at line 8 of file watch.c.

9 {
10 watch *const begin = BEGIN_WATCHES (*watches);
11 watch *const end = END_WATCHES (*watches);
12 watch *q = begin;
13 watch const *p = q;
14#ifndef KISSAT_NDEBUG
15 bool found = false;
16#endif
17 while (p != end) {
18 const watch watch = *q++ = *p++;
19 if (!watch.type.binary) {
20 *q++ = *p++;
21 continue;
22 }
23 const unsigned other = watch.binary.lit;
24 if (other != lit)
25 continue;
26#ifndef KISSAT_NDEBUG
27 KISSAT_assert (!found);
28 found = true;
29#endif
30 q--;
31 }
32 KISSAT_assert (found);
33#ifdef KISSAT_COMPACT
34 watches->size -= 1;
35#else
36 KISSAT_assert (begin + 1 <= end);
37 watches->end -= 1;
38#endif
39 const watch empty = {.raw = INVALID_VECTOR_ELEMENT};
40 end[-1] = empty;
41 KISSAT_assert (solver->vectors.usable < MAX_SECTOR - 1);
42 solver->vectors.usable += 1;
44}
#define INVALID_VECTOR_ELEMENT
Definition vector.h:20
#define kissat_check_vectors(...)
Definition vector.h:47
#define MAX_SECTOR
Definition vector.h:22

◆ kissat_remove_blocking_watch()

void kissat_remove_blocking_watch ( struct kissat * solver,
watches * watches,
reference ref )

Definition at line 46 of file watch.c.

47 {
48 KISSAT_assert (solver->watching);
49 watch *const begin = BEGIN_WATCHES (*watches);
50 watch *const end = END_WATCHES (*watches);
51 watch *q = begin;
52 watch const *p = q;
53#ifndef KISSAT_NDEBUG
54 bool found = false;
55#endif
56 while (p != end) {
57 const watch head = *q++ = *p++;
58 if (head.type.binary)
59 continue;
60 const watch tail = *q++ = *p++;
61 if (tail.raw != ref)
62 continue;
63#ifndef KISSAT_NDEBUG
64 KISSAT_assert (!found);
65 found = true;
66#endif
67 q -= 2;
68 }
69 KISSAT_assert (found);
70#ifdef KISSAT_COMPACT
71 watches->size -= 2;
72#else
73 KISSAT_assert (begin + 2 <= end);
74 watches->end -= 2;
75#endif
76 const watch empty = {.raw = INVALID_VECTOR_ELEMENT};
77 end[-2] = end[-1] = empty;
78 KISSAT_assert (solver->vectors.usable < MAX_SECTOR - 2);
79 solver->vectors.usable += 2;
81}
unsigned raw
Definition watch.h:46

◆ kissat_substitute_large_watch()

void kissat_substitute_large_watch ( struct kissat * solver,
watches * watches,
watch src,
watch dst )

Definition at line 83 of file watch.c.

84 {
85 KISSAT_assert (!solver->watching);
86 watch *const begin = BEGIN_WATCHES (*watches);
87 const watch *const end = END_WATCHES (*watches);
88#ifndef KISSAT_NDEBUG
89 bool found = false;
90#endif
91 for (watch *p = begin; p != end; p++) {
92 const watch head = *p;
93 if (head.raw != src.raw)
94 continue;
95#ifndef KISSAT_NDEBUG
96 found = true;
97#endif
98 *p = dst;
99 break;
100 }
101 KISSAT_assert (found);
102}

◆ kissat_watch_large_clauses()

void kissat_watch_large_clauses ( struct kissat * solver)

Definition at line 145 of file watch.c.

145 {
146 LOG ("watching all large clauses");
147 KISSAT_assert (solver->watching);
148
149 const value *const values = solver->values;
150 const assigned *const assigned = solver->assigned;
151 watches *watches = solver->watches;
152 ward *const arena = BEGIN_STACK (solver->arena);
153
154 for (all_clauses (c)) {
155 if (c->garbage)
156 continue;
157
158 unsigned *lits = c->lits;
159 kissat_sort_literals (solver, values, assigned, c->size, lits);
160 c->searched = 2;
161
162 const reference ref = (ward *) c - arena;
163 const unsigned l0 = lits[0];
164 const unsigned l1 = lits[1];
165
166 kissat_push_blocking_watch (solver, watches + l0, l1, ref);
167 kissat_push_blocking_watch (solver, watches + l1, l0, ref);
168 }
169}
void kissat_sort_literals(struct kissat *, unsigned size, unsigned *lits)
Definition sort.c:85
Here is the call graph for this function:
Here is the caller graph for this function:

◆ STACK() [1/3]

typedef STACK ( litpair )

◆ STACK() [2/3]

typedef STACK ( litriple )

◆ STACK() [3/3]

typedef STACK ( litwatch )