1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Tim King, Dejan Jovanovic, Haniel Barbosa |
4 |
|
* |
5 |
|
* This file is part of the cvc5 project. |
6 |
|
* |
7 |
|
* Copyright (c) 2009-2021 by the authors listed in the file AUTHORS |
8 |
|
* in the top-level source directory and their institutional affiliations. |
9 |
|
* All rights reserved. See the file COPYING in the top-level source |
10 |
|
* directory for licensing information. |
11 |
|
* **************************************************************************** |
12 |
|
* |
13 |
|
* [[ Add one-line brief description here ]] |
14 |
|
* |
15 |
|
* [[ Add lengthier description here ]] |
16 |
|
* \todo document this file |
17 |
|
*/ |
18 |
|
|
19 |
|
#include "theory/booleans/theory_bool_rewriter.h" |
20 |
|
|
21 |
|
#include <algorithm> |
22 |
|
#include <unordered_set> |
23 |
|
|
24 |
|
#include "expr/node_value.h" |
25 |
|
#include "util/cardinality.h" |
26 |
|
|
27 |
|
namespace cvc5 { |
28 |
|
namespace theory { |
29 |
|
namespace booleans { |
30 |
|
|
31 |
12375820 |
RewriteResponse TheoryBoolRewriter::postRewrite(TNode node) { |
32 |
12375820 |
return preRewrite(node); |
33 |
|
} |
34 |
|
|
35 |
|
/** |
36 |
|
* flattenNode looks for children of same kind, and if found merges |
37 |
|
* them into the parent. |
38 |
|
* |
39 |
|
* It simultaneously handles a couple of other optimizations: |
40 |
|
* - trivialNode - if found during exploration, return that node itself |
41 |
|
* (like in case of OR, if "true" is found, makes sense to replace |
42 |
|
* whole formula with "true") |
43 |
|
* - skipNode - as name suggests, skip them |
44 |
|
* (like in case of OR, you may want to skip any "false" nodes found) |
45 |
|
* |
46 |
|
* Use a null node if you want to ignore any of the optimizations. |
47 |
|
*/ |
48 |
825065 |
RewriteResponse flattenNode(TNode n, TNode trivialNode, TNode skipNode) |
49 |
|
{ |
50 |
|
typedef std::unordered_set<TNode> node_set; |
51 |
|
|
52 |
1650130 |
node_set visited; |
53 |
825065 |
visited.insert(skipNode); |
54 |
|
|
55 |
1650130 |
std::vector<TNode> toProcess; |
56 |
825065 |
toProcess.push_back(n); |
57 |
|
|
58 |
825065 |
Kind k = n.getKind(); |
59 |
|
typedef std::vector<TNode> ChildList; |
60 |
1650130 |
ChildList childList; //TNode should be fine, since 'n' is still there |
61 |
|
|
62 |
2389525 |
for (unsigned i = 0; i < toProcess.size(); ++ i) { |
63 |
3145892 |
TNode current = toProcess[i]; |
64 |
9097406 |
for(unsigned j = 0, j_end = current.getNumChildren(); j < j_end; ++ j) { |
65 |
13781619 |
TNode child = current[j]; |
66 |
7532946 |
if(visited.find(child) != visited.end()) { |
67 |
1267301 |
continue; |
68 |
6265645 |
} else if(child == trivialNode) { |
69 |
16972 |
return RewriteResponse(REWRITE_DONE, trivialNode); |
70 |
|
} else { |
71 |
6248673 |
visited.insert(child); |
72 |
6248673 |
if(child.getKind() == k) |
73 |
757511 |
toProcess.push_back(child); |
74 |
|
else |
75 |
5491162 |
childList.push_back(child); |
76 |
|
} |
77 |
|
} |
78 |
|
} |
79 |
808093 |
if (childList.size() == 0) return RewriteResponse(REWRITE_DONE, skipNode); |
80 |
689585 |
if (childList.size() == 1) return RewriteResponse(REWRITE_AGAIN, childList[0]); |
81 |
|
|
82 |
|
/* Trickery to stay under number of children possible in a node */ |
83 |
522668 |
NodeManager* nodeManager = NodeManager::currentNM(); |
84 |
522668 |
if (childList.size() < expr::NodeValue::MAX_CHILDREN) |
85 |
|
{ |
86 |
1045336 |
Node retNode = nodeManager->mkNode(k, childList); |
87 |
522668 |
return RewriteResponse(REWRITE_DONE, retNode); |
88 |
|
} |
89 |
|
else |
90 |
|
{ |
91 |
|
Assert(childList.size() |
92 |
|
< static_cast<size_t>(expr::NodeValue::MAX_CHILDREN) |
93 |
|
* static_cast<size_t>(expr::NodeValue::MAX_CHILDREN)); |
94 |
|
NodeBuilder nb(k); |
95 |
|
ChildList::iterator cur = childList.begin(), next, en = childList.end(); |
96 |
|
while (cur != en) |
97 |
|
{ |
98 |
|
next = min(cur + expr::NodeValue::MAX_CHILDREN, en); |
99 |
|
nb << (nodeManager->mkNode(k, ChildList(cur, next))); |
100 |
|
cur = next; |
101 |
|
} |
102 |
|
return RewriteResponse(REWRITE_DONE, nb.constructNode()); |
103 |
|
} |
104 |
|
} |
105 |
|
|
106 |
|
// Equality parity returns |
107 |
|
// * 0 if no relation between a and b is found |
108 |
|
// * 1 if a == b |
109 |
|
// * 2 if a == not(b) |
110 |
|
// * 3 or b == not(a) |
111 |
5618172 |
inline int equalityParity(TNode a, TNode b){ |
112 |
5618172 |
if(a == b){ |
113 |
19713 |
return 1; |
114 |
5598459 |
}else if(a.getKind() == kind::NOT && a[0] == b){ |
115 |
211 |
return 2; |
116 |
5598248 |
}else if(b.getKind() == kind::NOT && b[0] == a){ |
117 |
3956 |
return 3; |
118 |
|
}else{ |
119 |
5594292 |
return 0; |
120 |
|
} |
121 |
|
} |
122 |
|
|
123 |
161929 |
inline Node makeNegation(TNode n){ |
124 |
161929 |
bool even = false; |
125 |
178585 |
while(n.getKind() == kind::NOT){ |
126 |
8328 |
n = n[0]; |
127 |
8328 |
even = !even; |
128 |
|
} |
129 |
161929 |
if(even){ |
130 |
8158 |
return n; |
131 |
|
} else { |
132 |
153771 |
if(n.isConst()){ |
133 |
9960 |
return NodeManager::currentNM()->mkConst(!n.getConst<bool>()); |
134 |
|
}else{ |
135 |
143811 |
return n.notNode(); |
136 |
|
} |
137 |
|
} |
138 |
|
} |
139 |
|
|
140 |
19602601 |
RewriteResponse TheoryBoolRewriter::preRewrite(TNode n) { |
141 |
19602601 |
NodeManager* nodeManager = NodeManager::currentNM(); |
142 |
39205202 |
Node tt = nodeManager->mkConst(true); |
143 |
39205202 |
Node ff = nodeManager->mkConst(false); |
144 |
|
|
145 |
19602601 |
switch(n.getKind()) { |
146 |
3925790 |
case kind::NOT: { |
147 |
3925790 |
if (n[0] == tt) return RewriteResponse(REWRITE_DONE, ff); |
148 |
3838609 |
if (n[0] == ff) return RewriteResponse(REWRITE_DONE, tt); |
149 |
3741896 |
if (n[0].getKind() == kind::NOT) return RewriteResponse(REWRITE_AGAIN, n[0][0]); |
150 |
3622871 |
break; |
151 |
|
} |
152 |
3959487 |
case kind::OR: { |
153 |
3959487 |
bool done = true; |
154 |
3959487 |
TNode::iterator i = n.begin(), iend = n.end(); |
155 |
27991373 |
for(; i != iend; ++i) { |
156 |
12075225 |
if (*i == tt) return RewriteResponse(REWRITE_DONE, tt); |
157 |
12015943 |
if (*i == ff) done = false; |
158 |
12015943 |
if ((*i).getKind() == kind::OR) done = false; |
159 |
|
} |
160 |
3900205 |
if (!done) { |
161 |
322625 |
return flattenNode(n, /* trivialNode = */ tt, /* skipNode = */ ff); |
162 |
|
} |
163 |
|
// x v ... v x --> x |
164 |
|
unsigned ind, size; |
165 |
3584184 |
for (ind = 0, size = n.getNumChildren(); ind < size - 1; ++ind) |
166 |
|
{ |
167 |
3580697 |
if (n[ind] != n[ind+1]) |
168 |
|
{ |
169 |
3574093 |
break; |
170 |
|
} |
171 |
|
} |
172 |
3577580 |
if (ind == size - 1) |
173 |
|
{ |
174 |
3487 |
return RewriteResponse(REWRITE_AGAIN, n[0]); |
175 |
|
} |
176 |
3574093 |
break; |
177 |
|
} |
178 |
5193552 |
case kind::AND: { |
179 |
5193552 |
bool done = true; |
180 |
5193552 |
TNode::iterator i = n.begin(), iend = n.end(); |
181 |
60274034 |
for(; i != iend; ++i) { |
182 |
27807505 |
if (*i == ff) return RewriteResponse(REWRITE_DONE, ff); |
183 |
27540241 |
if (*i == tt) done = false; |
184 |
27540241 |
if ((*i).getKind() == kind::AND) done = false; |
185 |
|
} |
186 |
4926288 |
if (!done) { |
187 |
1004880 |
RewriteResponse ret = flattenNode(n, /* trivialNode = */ ff, /* skipNode = */ tt); |
188 |
502440 |
Debug("bool-flatten") << n << ": " << ret.d_node << std::endl; |
189 |
502440 |
return ret; |
190 |
|
} |
191 |
|
// x ^ ... ^ x --> x |
192 |
|
unsigned ind, size; |
193 |
4451254 |
for (ind = 0, size = n.getNumChildren(); ind < size - 1; ++ind) |
194 |
|
{ |
195 |
4446381 |
if (n[ind] != n[ind+1]) |
196 |
|
{ |
197 |
4418975 |
break; |
198 |
|
} |
199 |
|
} |
200 |
4423848 |
if (ind == size - 1) |
201 |
|
{ |
202 |
4873 |
return RewriteResponse(REWRITE_AGAIN, n[0]); |
203 |
|
} |
204 |
4418975 |
break; |
205 |
|
} |
206 |
598449 |
case kind::IMPLIES: { |
207 |
598449 |
if (n[0] == ff || n[1] == tt) return RewriteResponse(REWRITE_DONE, tt); |
208 |
595147 |
if (n[0] == tt && n[1] == ff) return RewriteResponse(REWRITE_DONE, ff); |
209 |
595040 |
if (n[0] == tt) return RewriteResponse(REWRITE_AGAIN, n[1]); |
210 |
583344 |
if (n[1] == ff) return RewriteResponse(REWRITE_AGAIN, makeNegation(n[0])); |
211 |
573325 |
break; |
212 |
|
} |
213 |
1641418 |
case kind::EQUAL: { |
214 |
|
// rewrite simple cases of IFF |
215 |
1641418 |
if(n[0] == tt) { |
216 |
|
// IFF true x |
217 |
19120 |
return RewriteResponse(REWRITE_AGAIN, n[1]); |
218 |
1622298 |
} else if(n[1] == tt) { |
219 |
|
// IFF x true |
220 |
34063 |
return RewriteResponse(REWRITE_AGAIN, n[0]); |
221 |
1588235 |
} else if(n[0] == ff) { |
222 |
|
// IFF false x |
223 |
49876 |
return RewriteResponse(REWRITE_AGAIN, makeNegation(n[1])); |
224 |
1538359 |
} else if(n[1] == ff) { |
225 |
|
// IFF x false |
226 |
72867 |
return RewriteResponse(REWRITE_AGAIN, makeNegation(n[0])); |
227 |
1465492 |
} else if(n[0] == n[1]) { |
228 |
|
// IFF x x |
229 |
15207 |
return RewriteResponse(REWRITE_DONE, tt); |
230 |
1450285 |
} else if(n[0].getKind() == kind::NOT && n[0][0] == n[1]) { |
231 |
|
// IFF (NOT x) x |
232 |
421 |
return RewriteResponse(REWRITE_DONE, ff); |
233 |
1449864 |
} else if(n[1].getKind() == kind::NOT && n[1][0] == n[0]) { |
234 |
|
// IFF x (NOT x) |
235 |
662 |
return RewriteResponse(REWRITE_DONE, ff); |
236 |
1449202 |
} else if(n[0].getKind() == kind::EQUAL && n[1].getKind() == kind::EQUAL) { |
237 |
|
// a : (= i x) |
238 |
|
// i : (= j k) |
239 |
|
// x : (= y z) |
240 |
|
|
241 |
|
// assume wlog k, z are constants and j is the same symbol as y |
242 |
|
// (iff (= j k) (= j z)) |
243 |
|
// if k = z |
244 |
|
// then (iff (= j k) (= j k)) => true |
245 |
|
// else |
246 |
|
// (iff (= j k) (= j z)) <=> b |
247 |
|
// b : (and (not (= j k)) (not (= j z))) |
248 |
|
// (= j k) (= j z) | a b |
249 |
|
// f f | t t |
250 |
|
// f t | f f |
251 |
|
// t f | f f |
252 |
|
// t t | * f |
253 |
|
// * j cannot equal both k and z in a theory model |
254 |
40218 |
TNode t,c; |
255 |
20117 |
if (n[0][0].isConst()) { |
256 |
1372 |
c = n[0][0]; |
257 |
1372 |
t = n[0][1]; |
258 |
|
} |
259 |
18745 |
else if (n[0][1].isConst()) { |
260 |
1987 |
c = n[0][1]; |
261 |
1987 |
t = n[0][0]; |
262 |
|
} |
263 |
20117 |
bool matchesForm = false; |
264 |
20117 |
bool constantsEqual = false; |
265 |
20117 |
if (!c.isNull()) { |
266 |
3359 |
if (n[1][0] == t && n[1][1].isConst()) { |
267 |
8 |
matchesForm = true; |
268 |
8 |
constantsEqual = (n[1][1] == c); |
269 |
|
} |
270 |
3351 |
else if (n[1][1] == t && n[1][0].isConst()) { |
271 |
8 |
matchesForm = true; |
272 |
8 |
constantsEqual = (n[1][0] == c); |
273 |
|
} |
274 |
|
} |
275 |
20117 |
if(matchesForm){ |
276 |
16 |
if(constantsEqual){ |
277 |
1 |
return RewriteResponse(REWRITE_DONE, tt); |
278 |
|
}else{ |
279 |
30 |
Cardinality kappa = t.getType().getCardinality(); |
280 |
30 |
Cardinality two(2l); |
281 |
15 |
if(kappa.knownLessThanOrEqual(two)){ |
282 |
2 |
return RewriteResponse(REWRITE_DONE, ff); |
283 |
|
}else{ |
284 |
26 |
Node neitherEquality = (makeNegation(n[0])).andNode(makeNegation(n[1])); |
285 |
13 |
return RewriteResponse(REWRITE_AGAIN, neitherEquality); |
286 |
|
} |
287 |
|
} |
288 |
|
} |
289 |
|
} |
290 |
|
// sort |
291 |
1449186 |
if (n[0].getId() > n[1].getId()) |
292 |
|
{ |
293 |
|
return RewriteResponse(REWRITE_AGAIN, |
294 |
185200 |
nodeManager->mkNode(kind::EQUAL, n[1], n[0])); |
295 |
|
} |
296 |
1263986 |
return RewriteResponse(REWRITE_DONE, n); |
297 |
|
} |
298 |
1367125 |
case kind::XOR: { |
299 |
|
// rewrite simple cases of XOR |
300 |
1367125 |
if(n[0] == tt) { |
301 |
|
// XOR true x |
302 |
6868 |
return RewriteResponse(REWRITE_AGAIN, makeNegation(n[1])); |
303 |
1360257 |
} else if(n[1] == tt) { |
304 |
|
// XOR x true |
305 |
17643 |
return RewriteResponse(REWRITE_AGAIN, makeNegation(n[0])); |
306 |
1342614 |
} else if(n[0] == ff) { |
307 |
|
// XOR false x |
308 |
42943 |
return RewriteResponse(REWRITE_AGAIN, n[1]); |
309 |
1299671 |
} else if(n[1] == ff) { |
310 |
|
// XOR x false |
311 |
141786 |
return RewriteResponse(REWRITE_AGAIN, n[0]); |
312 |
1157885 |
} else if(n[0] == n[1]) { |
313 |
|
// XOR x x |
314 |
1003 |
return RewriteResponse(REWRITE_DONE, ff); |
315 |
1156882 |
} else if(n[0].getKind() == kind::NOT && n[0][0] == n[1]) { |
316 |
|
// XOR (NOT x) x |
317 |
31 |
return RewriteResponse(REWRITE_DONE, tt); |
318 |
1156851 |
} else if(n[1].getKind() == kind::NOT && n[1][0] == n[0]) { |
319 |
|
// XOR x (NOT x) |
320 |
213 |
return RewriteResponse(REWRITE_DONE, tt); |
321 |
|
} |
322 |
1156638 |
break; |
323 |
|
} |
324 |
2114240 |
case kind::ITE: { |
325 |
|
// non-Boolean-valued ITEs should have been removed in place of |
326 |
|
// a variable |
327 |
|
// rewrite simple cases of ITE |
328 |
2114240 |
if (n[0].isConst()) { |
329 |
256246 |
if (n[0] == tt) { |
330 |
|
// ITE true x y |
331 |
39986 |
Debug("bool-ite") << "TheoryBoolRewriter::preRewrite_ITE: n[0] ==tt " |
332 |
19993 |
<< n << ": " << n[1] << std::endl; |
333 |
19993 |
return RewriteResponse(REWRITE_AGAIN, n[1]); |
334 |
|
} else { |
335 |
236253 |
Assert(n[0] == ff); |
336 |
|
// ITE false x y |
337 |
472506 |
Debug("bool-ite") << "TheoryBoolRewriter::preRewrite_ITE: n[0] ==ff " |
338 |
236253 |
<< n << ": " << n[1] << std::endl; |
339 |
236253 |
return RewriteResponse(REWRITE_AGAIN, n[2]); |
340 |
|
} |
341 |
1857994 |
} else if (n[1].isConst()) { |
342 |
414400 |
if (n[1] == tt && n[2] == ff) { |
343 |
11888 |
Debug("bool-ite") |
344 |
5944 |
<< "TheoryBoolRewriter::preRewrite_ITE: n[1] ==tt && n[2] == ff " |
345 |
5944 |
<< n << ": " << n[0] << std::endl; |
346 |
5944 |
return RewriteResponse(REWRITE_AGAIN, n[0]); |
347 |
|
} |
348 |
408456 |
else if (n[1] == ff && n[2] == tt) { |
349 |
9260 |
Debug("bool-ite") |
350 |
4630 |
<< "TheoryBoolRewriter::preRewrite_ITE: n[1] ==ff && n[2] == tt " |
351 |
4630 |
<< n << ": " << n[0].notNode() << std::endl; |
352 |
4630 |
return RewriteResponse(REWRITE_AGAIN, makeNegation(n[0])); |
353 |
|
} |
354 |
|
} |
355 |
|
|
356 |
1847420 |
if (n[0].getKind() == kind::NOT) |
357 |
|
{ |
358 |
|
// ite(not(c), x, y) ---> ite(c, y, x) |
359 |
|
return RewriteResponse( |
360 |
145919 |
REWRITE_AGAIN, nodeManager->mkNode(kind::ITE, n[0][0], n[2], n[1])); |
361 |
|
} |
362 |
|
|
363 |
|
int parityTmp; |
364 |
1701501 |
if ((parityTmp = equalityParity(n[1], n[2])) != 0) { |
365 |
26840 |
Node resp = (parityTmp == 1) ? (Node)n[1] : n[0].eqNode(n[1]); |
366 |
26840 |
Debug("bool-ite") |
367 |
13420 |
<< "TheoryBoolRewriter::preRewrite_ITE: equalityParity n[1], n[2] " |
368 |
13420 |
<< parityTmp << " " << n << ": " << resp << std::endl; |
369 |
13420 |
return RewriteResponse(REWRITE_AGAIN, resp); |
370 |
|
// Curiously, this rewrite affects several benchmarks dramatically, including copy_array and some simple_startup - disable for now |
371 |
|
// } else if (n[0].getKind() == kind::NOT) { |
372 |
|
// return RewriteResponse(REWRITE_AGAIN, n[0][0].iteNode(n[2], n[1])); |
373 |
1688081 |
} else if(!n[1].isConst() && (parityTmp = equalityParity(n[0], n[1])) != 0){ |
374 |
|
// (parityTmp == 1) if n[0] == n[1] |
375 |
|
// otherwise, n[0] == not(n[1]) or not(n[0]) == n[1] |
376 |
|
|
377 |
|
// if n[1] is constant this can loop, this is possible in prewrite |
378 |
6856 |
Node resp = n[0].iteNode( (parityTmp == 1) ? tt : ff, n[2]); |
379 |
6856 |
Debug("bool-ite") |
380 |
3428 |
<< "TheoryBoolRewriter::preRewrite_ITE: equalityParity n[0], n[1] " |
381 |
3428 |
<< parityTmp << " " << n << ": " << resp << std::endl; |
382 |
3428 |
return RewriteResponse(REWRITE_AGAIN, resp); |
383 |
1684653 |
} else if(!n[2].isConst() && (parityTmp = equalityParity(n[0], n[2])) != 0){ |
384 |
|
// (parityTmp == 1) if n[0] == n[2] |
385 |
|
// otherwise, n[0] == not(n[2]) or not(n[0]) == n[2] |
386 |
5332 |
Node resp = n[0].iteNode(n[1], (parityTmp == 1) ? ff : tt); |
387 |
5332 |
Debug("bool-ite") |
388 |
2666 |
<< "TheoryBoolRewriter::preRewrite_ITE: equalityParity n[0], n[2] " |
389 |
2666 |
<< parityTmp << " " << n << ": " << resp << std::endl; |
390 |
2666 |
return RewriteResponse(REWRITE_AGAIN, resp); |
391 |
4924790 |
} else if(n[1].getKind() == kind::ITE && |
392 |
3242803 |
(parityTmp = equalityParity(n[0], n[1][0])) != 0){ |
393 |
|
// (parityTmp == 1) then n : (ite c (ite c x y) z) |
394 |
|
// (parityTmp > 1) then n : (ite c (ite (not c) x y) z) or |
395 |
|
// n: (ite (not c) (ite c x y) z) |
396 |
4008 |
Node resp = n[0].iteNode((parityTmp == 1) ? n[1][1] : n[1][2], n[2]); |
397 |
4008 |
Debug("bool-ite") |
398 |
2004 |
<< "TheoryBoolRewriter::preRewrite: equalityParity n[0], n[1][0] " |
399 |
2004 |
<< parityTmp << " " << n << ": " << resp << std::endl; |
400 |
2004 |
return RewriteResponse(REWRITE_AGAIN, resp); |
401 |
5244965 |
} else if(n[2].getKind() == kind::ITE && |
402 |
3564982 |
(parityTmp = equalityParity(n[0], n[2][0])) != 0){ |
403 |
|
// (parityTmp == 1) then n : (ite c x (ite c y z)) |
404 |
|
// (parityTmp > 1) then n : (ite c x (ite (not c) y z)) or |
405 |
|
// n: (ite (not c) x (ite c y z)) |
406 |
4724 |
Node resp = n[0].iteNode(n[1], (parityTmp == 1) ? n[2][2] : n[2][1]); |
407 |
4724 |
Debug("bool-ite") |
408 |
2362 |
<< "TheoryBoolRewriter::preRewrite: equalityParity n[0], n[2][0] " |
409 |
2362 |
<< parityTmp << " " << n << ": " << resp << std::endl; |
410 |
2362 |
return RewriteResponse(REWRITE_AGAIN, resp); |
411 |
|
} |
412 |
|
|
413 |
|
// Rewrites for ITEs with a constant branch. These rewrites are applied |
414 |
|
// after the parity rewrites above because they may simplify ITEs such as |
415 |
|
// `(ite c c true)` to `(ite c true true)`. As a result, we avoid |
416 |
|
// introducing an unnecessary conjunction/disjunction here. |
417 |
1677621 |
if (n[1].isConst() && (n[1] == tt || n[1] == ff)) |
418 |
|
{ |
419 |
|
// ITE C true y --> C v y |
420 |
|
// ITE C false y --> ~C ^ y |
421 |
|
Node resp = |
422 |
98154 |
n[1] == tt ? n[0].orNode(n[2]) : (n[0].negate()).andNode(n[2]); |
423 |
98154 |
Debug("bool-ite") << "TheoryBoolRewriter::preRewrite_ITE: n[1] const " |
424 |
49077 |
<< n << ": " << resp << std::endl; |
425 |
49077 |
return RewriteResponse(REWRITE_AGAIN, resp); |
426 |
|
} |
427 |
1628544 |
else if (n[2].isConst() && (n[2] == tt || n[2] == ff)) |
428 |
|
{ |
429 |
|
// ITE C x true --> ~C v x |
430 |
|
// ITE C x false --> C ^ x |
431 |
|
Node resp = |
432 |
137314 |
n[2] == tt ? (n[0].negate()).orNode(n[1]) : n[0].andNode(n[1]); |
433 |
137314 |
Debug("bool-ite") << "TheoryBoolRewriter::preRewrite_ITE: n[2] const " |
434 |
68657 |
<< n << ": " << resp << std::endl; |
435 |
68657 |
return RewriteResponse(REWRITE_AGAIN, resp); |
436 |
|
} |
437 |
|
|
438 |
1559887 |
break; |
439 |
|
} |
440 |
802540 |
default: |
441 |
802540 |
return RewriteResponse(REWRITE_DONE, n); |
442 |
|
} |
443 |
14905789 |
return RewriteResponse(REWRITE_DONE, n); |
444 |
|
} |
445 |
|
|
446 |
|
} // namespace booleans |
447 |
|
} // namespace theory |
448 |
31125 |
} // namespace cvc5 |