#include "ifthenelse.h"
#include "eliminate.h"
#include "gates.h"
#include "inline.h"
Go to the source code of this file.
◆ kissat_find_if_then_else_gate()
| bool kissat_find_if_then_else_gate |
( |
kissat * | solver, |
|
|
unsigned | lit, |
|
|
unsigned | negative ) |
Definition at line 97 of file ifthenelse.c.
98 {
100 return false;
104 if (begin == end)
105 return false;
106 uint64_t large_clauses = 0;
107 for (
const watch *
p = begin;
p != end;
p++)
109 large_clauses++;
110 const uint64_t limit =
GET_OPTION (eliminateocclim);
111 if (large_clauses * large_clauses > limit)
112 return false;
113 const watch *
const last = end - 1;
114 uint64_t steps = 0;
115 for (
const watch *p1 = begin; steps < limit && p1 != last; p1++) {
118 continue;
120 if (!get_ternary_clause (
solver, p1->large.ref, &
a1, &
b1, &c1))
121 continue;
127 for (
const watch *p2 = p1 + 1; steps < limit && p2 != end; p2++) {
130 continue;
131 unsigned a2, b2, c2;
132 if (!get_ternary_clause (
solver, p2->large.ref, &a2, &b2, &c2))
133 continue;
135 SWAP (
unsigned, a2, b2);
137 SWAP (
unsigned, a2, c2);
140 SWAP (
unsigned, b2, c2);
142 continue;
143 const unsigned not_b2 =
NOT (b2);
145 continue;
146 solver->resolve_gate =
false;
147 const unsigned not_lit =
NOT (
lit);
148 const unsigned not_c1 =
NOT (c1);
149 const watch *
const p3 =
150 find_ternary_clause (
solver, &steps, not_lit,
b1, not_c1);
151 if (!p3)
152 continue;
153 const unsigned not_c2 =
NOT (c2);
154 const watch *
const p4 =
155 find_ternary_clause (
solver, &steps, not_lit, b2, not_c2);
156 if (!p4)
157 continue;
158 watch w3 = p3 < p4 ? *p3 : *p4;
159 watch w4 = p3 < p4 ? *p4 : *p3;
162 LOGWATCH (not_lit, w3,
"3rd if-then-else");
163 LOGWATCH (not_lit, w4,
"4th if-then-else");
164 LOG (
"found if-then-else gate %s = (%s ? %s : %s)",
LOGLIT (
lit),
171 INC (if_then_else_extracted);
172 return true;
173 }
174 }
175 return false;
176}
#define GATE_ELIMINATED(...)
#define KISSAT_assert(ignore)
#define BEGIN_WATCHES(WS)