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

Go to the source code of this file.

Functions

bool kissat_find_and_gate (struct kissat *, unsigned lit, unsigned negative)
 

Function Documentation

◆ kissat_find_and_gate()

bool kissat_find_and_gate ( struct kissat * solver,
unsigned lit,
unsigned negative )

Definition at line 8 of file ands.c.

9 {
10 if (!GET_OPTION (ands))
11 return false;
12 size_t marked = kissat_mark_binaries (solver, lit);
13 if (!marked)
14 return false;
15 if (marked < 2) {
17 return false;
18 }
19
20 unsigned not_lit = NOT (lit);
21 watches *not_watches = &WATCHES (not_lit);
22
23 ward *const arena = BEGIN_STACK (solver->arena);
24 value *marks = solver->marks;
25 const value *const values = solver->values;
26
27 clause *base = 0;
28 for (all_binary_large_watches (watch, *not_watches)) {
29 if (watch.type.binary)
30 continue;
31 const reference ref = watch.large.ref;
32 KISSAT_assert (ref < SIZE_STACK (solver->arena));
33 clause *c = (clause *) (arena + ref);
35 base = c;
36 for (all_literals_in_clause (other, c)) {
37 if (other == not_lit)
38 continue;
39 const value value = values[other];
40 if (value > 0) {
42 base = 0;
43 break;
44 }
45 if (value < 0)
46 continue;
47 const unsigned not_other = NOT (other);
48 signed char mark = marks[not_other];
49 if (mark)
50 continue;
51 base = 0;
52 break;
53 }
54 if (base)
55 break;
56 }
57 if (!base) {
59 return false;
60 }
61 LOGCLS (base, "found and gate %s base clause", LOGLIT (not_lit));
62 for (all_literals_in_clause (other, base)) {
63 if (other == not_lit)
64 continue;
65 if (values[other])
66 continue;
67 const unsigned not_other = NOT (other);
68 KISSAT_assert (marks[not_other]);
69 marks[not_other] = 0;
70 }
71 watch tmp = kissat_binary_watch (0);
74 if (!watch.type.binary)
75 continue;
76 const unsigned other = watch.binary.lit;
77 KISSAT_assert (!solver->values[other]);
78 if (marks[other]) {
79 marks[other] = 0;
80 continue;
81 }
82 tmp.binary.lit = other;
83 PUSH_STACK (solver->gates[negative], tmp);
84 }
85 tmp = kissat_large_watch (kissat_reference_clause (solver, base));
86 PUSH_STACK (solver->gates[!negative], tmp);
87 solver->gate_eliminated = GATE_ELIMINATED (ands);
88 INC (ands_extracted);
89 return true;
90}
ABC_NAMESPACE_HEADER_START typedef word ward
Definition arena.h:12
#define BEGIN_STACK(S)
Definition stack.h:46
#define SIZE_STACK(S)
Definition stack.h:19
#define PUSH_STACK(S, E)
Definition stack.h:39
#define INVALID_LIT
#define INC(NAME)
ABC_NAMESPACE_IMPL_START typedef signed char value
void kissat_eliminate_clause(kissat *solver, clause *c, unsigned lit)
Definition eliminate.c:128
void kissat_unmark_binaries(kissat *solver, unsigned lit)
Definition gates.c:28
ABC_NAMESPACE_IMPL_START size_t kissat_mark_binaries(kissat *solver, unsigned lit)
Definition gates.c:11
#define GATE_ELIMINATED(...)
Definition gates.h:20
#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 LOGCLS(...)
Definition logging.h:415
#define LOGLIT(...)
Definition logging.hpp:99
unsigned short ref
Definition giaNewBdd.h:38
#define GET_OPTION(N)
Definition options.h:295
ABC_NAMESPACE_HEADER_START typedef unsigned reference
Definition reference.h:9
int lit
Definition satVec.h:130
#define NOT(LIT)
Definition literal.h:33
bool garbage
Definition clause.h:25
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
signed char mark
Definition value.h:8
vector watches
Definition watch.h:49
#define all_binary_large_watches(WATCH, WATCHES)
Definition watch.h:158
#define WATCHES(LIT)
Definition watch.h:137
Here is the call graph for this function:
Here is the caller graph for this function: