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 |
12465265 |
RewriteResponse TheoryBoolRewriter::postRewrite(TNode node) { |
32 |
12465265 |
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 |
825562 |
RewriteResponse flattenNode(TNode n, TNode trivialNode, TNode skipNode) |
49 |
|
{ |
50 |
|
typedef std::unordered_set<TNode> node_set; |
51 |
|
|
52 |
1651124 |
node_set visited; |
53 |
825562 |
visited.insert(skipNode); |
54 |
|
|
55 |
1651124 |
std::vector<TNode> toProcess; |
56 |
825562 |
toProcess.push_back(n); |
57 |
|
|
58 |
825562 |
Kind k = n.getKind(); |
59 |
|
typedef std::vector<TNode> ChildList; |
60 |
1651124 |
ChildList childList; //TNode should be fine, since 'n' is still there |
61 |
|
|
62 |
2392358 |
for (unsigned i = 0; i < toProcess.size(); ++ i) { |
63 |
3150585 |
TNode current = toProcess[i]; |
64 |
9104864 |
for(unsigned j = 0, j_end = current.getNumChildren(); j < j_end; ++ j) { |
65 |
13792438 |
TNode child = current[j]; |
66 |
7538068 |
if(visited.find(child) != visited.end()) { |
67 |
1266705 |
continue; |
68 |
6271363 |
} else if(child == trivialNode) { |
69 |
16993 |
return RewriteResponse(REWRITE_DONE, trivialNode); |
70 |
|
} else { |
71 |
6254370 |
visited.insert(child); |
72 |
6254370 |
if(child.getKind() == k) |
73 |
759369 |
toProcess.push_back(child); |
74 |
|
else |
75 |
5495001 |
childList.push_back(child); |
76 |
|
} |
77 |
|
} |
78 |
|
} |
79 |
808569 |
if (childList.size() == 0) return RewriteResponse(REWRITE_DONE, skipNode); |
80 |
690046 |
if (childList.size() == 1) return RewriteResponse(REWRITE_AGAIN, childList[0]); |
81 |
|
|
82 |
|
/* Trickery to stay under number of children possible in a node */ |
83 |
522896 |
NodeManager* nodeManager = NodeManager::currentNM(); |
84 |
522896 |
if (childList.size() < expr::NodeValue::MAX_CHILDREN) |
85 |
|
{ |
86 |
1045792 |
Node retNode = nodeManager->mkNode(k, childList); |
87 |
522896 |
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 |
5595799 |
inline int equalityParity(TNode a, TNode b){ |
112 |
5595799 |
if(a == b){ |
113 |
19386 |
return 1; |
114 |
5576413 |
}else if(a.getKind() == kind::NOT && a[0] == b){ |
115 |
211 |
return 2; |
116 |
5576202 |
}else if(b.getKind() == kind::NOT && b[0] == a){ |
117 |
3956 |
return 3; |
118 |
|
}else{ |
119 |
5572246 |
return 0; |
120 |
|
} |
121 |
|
} |
122 |
|
|
123 |
162039 |
inline Node makeNegation(TNode n){ |
124 |
162039 |
bool even = false; |
125 |
178739 |
while(n.getKind() == kind::NOT){ |
126 |
8350 |
n = n[0]; |
127 |
8350 |
even = !even; |
128 |
|
} |
129 |
162039 |
if(even){ |
130 |
8180 |
return n; |
131 |
|
} else { |
132 |
153859 |
if(n.isConst()){ |
133 |
9961 |
return NodeManager::currentNM()->mkConst(!n.getConst<bool>()); |
134 |
|
}else{ |
135 |
143898 |
return n.notNode(); |
136 |
|
} |
137 |
|
} |
138 |
|
} |
139 |
|
|
140 |
19743686 |
RewriteResponse TheoryBoolRewriter::preRewrite(TNode n) { |
141 |
19743686 |
NodeManager* nodeManager = NodeManager::currentNM(); |
142 |
39487372 |
Node tt = nodeManager->mkConst(true); |
143 |
39487372 |
Node ff = nodeManager->mkConst(false); |
144 |
|
|
145 |
19743686 |
switch(n.getKind()) { |
146 |
4051561 |
case kind::NOT: { |
147 |
4051561 |
if (n[0] == tt) return RewriteResponse(REWRITE_DONE, ff); |
148 |
3962369 |
if (n[0] == ff) return RewriteResponse(REWRITE_DONE, tt); |
149 |
3863737 |
if (n[0].getKind() == kind::NOT) return RewriteResponse(REWRITE_AGAIN, n[0][0]); |
150 |
3727491 |
break; |
151 |
|
} |
152 |
3953026 |
case kind::OR: { |
153 |
3953026 |
bool done = true; |
154 |
3953026 |
TNode::iterator i = n.begin(), iend = n.end(); |
155 |
27908858 |
for(; i != iend; ++i) { |
156 |
12037201 |
if (*i == tt) return RewriteResponse(REWRITE_DONE, tt); |
157 |
11977916 |
if (*i == ff) done = false; |
158 |
11977916 |
if ((*i).getKind() == kind::OR) done = false; |
159 |
|
} |
160 |
3893741 |
if (!done) { |
161 |
323084 |
return flattenNode(n, /* trivialNode = */ tt, /* skipNode = */ ff); |
162 |
|
} |
163 |
|
// x v ... v x --> x |
164 |
|
unsigned ind, size; |
165 |
3577250 |
for (ind = 0, size = n.getNumChildren(); ind < size - 1; ++ind) |
166 |
|
{ |
167 |
3573762 |
if (n[ind] != n[ind+1]) |
168 |
|
{ |
169 |
3567169 |
break; |
170 |
|
} |
171 |
|
} |
172 |
3570657 |
if (ind == size - 1) |
173 |
|
{ |
174 |
3488 |
return RewriteResponse(REWRITE_AGAIN, n[0]); |
175 |
|
} |
176 |
3567169 |
break; |
177 |
|
} |
178 |
5213575 |
case kind::AND: { |
179 |
5213575 |
bool done = true; |
180 |
5213575 |
TNode::iterator i = n.begin(), iend = n.end(); |
181 |
60651155 |
for(; i != iend; ++i) { |
182 |
27986125 |
if (*i == ff) return RewriteResponse(REWRITE_DONE, ff); |
183 |
27718790 |
if (*i == tt) done = false; |
184 |
27718790 |
if ((*i).getKind() == kind::AND) done = false; |
185 |
|
} |
186 |
4946240 |
if (!done) { |
187 |
1004956 |
RewriteResponse ret = flattenNode(n, /* trivialNode = */ ff, /* skipNode = */ tt); |
188 |
502478 |
Debug("bool-flatten") << n << ": " << ret.d_node << std::endl; |
189 |
502478 |
return ret; |
190 |
|
} |
191 |
|
// x ^ ... ^ x --> x |
192 |
|
unsigned ind, size; |
193 |
4471252 |
for (ind = 0, size = n.getNumChildren(); ind < size - 1; ++ind) |
194 |
|
{ |
195 |
4466391 |
if (n[ind] != n[ind+1]) |
196 |
|
{ |
197 |
4438901 |
break; |
198 |
|
} |
199 |
|
} |
200 |
4443762 |
if (ind == size - 1) |
201 |
|
{ |
202 |
4861 |
return RewriteResponse(REWRITE_AGAIN, n[0]); |
203 |
|
} |
204 |
4438901 |
break; |
205 |
|
} |
206 |
603535 |
case kind::IMPLIES: { |
207 |
603535 |
if (n[0] == ff || n[1] == tt) return RewriteResponse(REWRITE_DONE, tt); |
208 |
600230 |
if (n[0] == tt && n[1] == ff) return RewriteResponse(REWRITE_DONE, ff); |
209 |
600123 |
if (n[0] == tt) return RewriteResponse(REWRITE_AGAIN, n[1]); |
210 |
588411 |
if (n[1] == ff) return RewriteResponse(REWRITE_AGAIN, makeNegation(n[0])); |
211 |
578506 |
break; |
212 |
|
} |
213 |
1645115 |
case kind::EQUAL: { |
214 |
|
// rewrite simple cases of IFF |
215 |
1645115 |
if(n[0] == tt) { |
216 |
|
// IFF true x |
217 |
19196 |
return RewriteResponse(REWRITE_AGAIN, n[1]); |
218 |
1625919 |
} else if(n[1] == tt) { |
219 |
|
// IFF x true |
220 |
33960 |
return RewriteResponse(REWRITE_AGAIN, n[0]); |
221 |
1591959 |
} else if(n[0] == ff) { |
222 |
|
// IFF false x |
223 |
50102 |
return RewriteResponse(REWRITE_AGAIN, makeNegation(n[1])); |
224 |
1541857 |
} else if(n[1] == ff) { |
225 |
|
// IFF x false |
226 |
72855 |
return RewriteResponse(REWRITE_AGAIN, makeNegation(n[0])); |
227 |
1469002 |
} else if(n[0] == n[1]) { |
228 |
|
// IFF x x |
229 |
15102 |
return RewriteResponse(REWRITE_DONE, tt); |
230 |
1453900 |
} 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 |
1453479 |
} 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 |
1452817 |
} 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 |
40290 |
TNode t,c; |
255 |
20153 |
if (n[0][0].isConst()) { |
256 |
1372 |
c = n[0][0]; |
257 |
1372 |
t = n[0][1]; |
258 |
|
} |
259 |
18781 |
else if (n[0][1].isConst()) { |
260 |
2011 |
c = n[0][1]; |
261 |
2011 |
t = n[0][0]; |
262 |
|
} |
263 |
20153 |
bool matchesForm = false; |
264 |
20153 |
bool constantsEqual = false; |
265 |
20153 |
if (!c.isNull()) { |
266 |
3383 |
if (n[1][0] == t && n[1][1].isConst()) { |
267 |
8 |
matchesForm = true; |
268 |
8 |
constantsEqual = (n[1][1] == c); |
269 |
|
} |
270 |
3375 |
else if (n[1][1] == t && n[1][0].isConst()) { |
271 |
8 |
matchesForm = true; |
272 |
8 |
constantsEqual = (n[1][0] == c); |
273 |
|
} |
274 |
|
} |
275 |
20153 |
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 |
1452801 |
if (n[0].getId() > n[1].getId()) |
292 |
|
{ |
293 |
|
return RewriteResponse(REWRITE_AGAIN, |
294 |
185356 |
nodeManager->mkNode(kind::EQUAL, n[1], n[0])); |
295 |
|
} |
296 |
1267445 |
return RewriteResponse(REWRITE_DONE, n); |
297 |
|
} |
298 |
1367380 |
case kind::XOR: { |
299 |
|
// rewrite simple cases of XOR |
300 |
1367380 |
if(n[0] == tt) { |
301 |
|
// XOR true x |
302 |
6880 |
return RewriteResponse(REWRITE_AGAIN, makeNegation(n[1])); |
303 |
1360500 |
} else if(n[1] == tt) { |
304 |
|
// XOR x true |
305 |
17647 |
return RewriteResponse(REWRITE_AGAIN, makeNegation(n[0])); |
306 |
1342853 |
} else if(n[0] == ff) { |
307 |
|
// XOR false x |
308 |
42701 |
return RewriteResponse(REWRITE_AGAIN, n[1]); |
309 |
1300152 |
} else if(n[1] == ff) { |
310 |
|
// XOR x false |
311 |
142098 |
return RewriteResponse(REWRITE_AGAIN, n[0]); |
312 |
1158054 |
} else if(n[0] == n[1]) { |
313 |
|
// XOR x x |
314 |
1001 |
return RewriteResponse(REWRITE_DONE, ff); |
315 |
1157053 |
} 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 |
1157022 |
} 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 |
1156809 |
break; |
323 |
|
} |
324 |
2104015 |
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 |
2104015 |
if (n[0].isConst()) { |
329 |
256040 |
if (n[0] == tt) { |
330 |
|
// ITE true x y |
331 |
40026 |
Debug("bool-ite") << "TheoryBoolRewriter::preRewrite_ITE: n[0] ==tt " |
332 |
20013 |
<< n << ": " << n[1] << std::endl; |
333 |
20013 |
return RewriteResponse(REWRITE_AGAIN, n[1]); |
334 |
|
} else { |
335 |
236027 |
Assert(n[0] == ff); |
336 |
|
// ITE false x y |
337 |
472054 |
Debug("bool-ite") << "TheoryBoolRewriter::preRewrite_ITE: n[0] ==ff " |
338 |
236027 |
<< n << ": " << n[1] << std::endl; |
339 |
236027 |
return RewriteResponse(REWRITE_AGAIN, n[2]); |
340 |
|
} |
341 |
1847975 |
} else if (n[1].isConst()) { |
342 |
407876 |
if (n[1] == tt && n[2] == ff) { |
343 |
11868 |
Debug("bool-ite") |
344 |
5934 |
<< "TheoryBoolRewriter::preRewrite_ITE: n[1] ==tt && n[2] == ff " |
345 |
5934 |
<< n << ": " << n[0] << std::endl; |
346 |
5934 |
return RewriteResponse(REWRITE_AGAIN, n[0]); |
347 |
|
} |
348 |
401942 |
else if (n[1] == ff && n[2] == tt) { |
349 |
9248 |
Debug("bool-ite") |
350 |
4624 |
<< "TheoryBoolRewriter::preRewrite_ITE: n[1] ==ff && n[2] == tt " |
351 |
4624 |
<< n << ": " << n[0].notNode() << std::endl; |
352 |
4624 |
return RewriteResponse(REWRITE_AGAIN, makeNegation(n[0])); |
353 |
|
} |
354 |
|
} |
355 |
|
|
356 |
1837417 |
if (n[0].getKind() == kind::NOT) |
357 |
|
{ |
358 |
|
// ite(not(c), x, y) ---> ite(c, y, x) |
359 |
|
return RewriteResponse( |
360 |
145708 |
REWRITE_AGAIN, nodeManager->mkNode(kind::ITE, n[0][0], n[2], n[1])); |
361 |
|
} |
362 |
|
|
363 |
|
int parityTmp; |
364 |
1691709 |
if ((parityTmp = equalityParity(n[1], n[2])) != 0) { |
365 |
26806 |
Node resp = (parityTmp == 1) ? (Node)n[1] : n[0].eqNode(n[1]); |
366 |
26806 |
Debug("bool-ite") |
367 |
13403 |
<< "TheoryBoolRewriter::preRewrite_ITE: equalityParity n[1], n[2] " |
368 |
13403 |
<< parityTmp << " " << n << ": " << resp << std::endl; |
369 |
13403 |
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 |
1678306 |
} 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 |
1674878 |
} 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 |
4906671 |
} else if(n[1].getKind() == kind::ITE && |
392 |
3234459 |
(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 |
3432 |
Node resp = n[0].iteNode((parityTmp == 1) ? n[1][1] : n[1][2], n[2]); |
397 |
3432 |
Debug("bool-ite") |
398 |
1716 |
<< "TheoryBoolRewriter::preRewrite: equalityParity n[0], n[1][0] " |
399 |
1716 |
<< parityTmp << " " << n << ": " << resp << std::endl; |
400 |
1716 |
return RewriteResponse(REWRITE_AGAIN, resp); |
401 |
5216319 |
} else if(n[2].getKind() == kind::ITE && |
402 |
3545823 |
(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 |
4680 |
Node resp = n[0].iteNode(n[1], (parityTmp == 1) ? n[2][2] : n[2][1]); |
407 |
4680 |
Debug("bool-ite") |
408 |
2340 |
<< "TheoryBoolRewriter::preRewrite: equalityParity n[0], n[2][0] " |
409 |
2340 |
<< parityTmp << " " << n << ": " << resp << std::endl; |
410 |
2340 |
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 |
1668156 |
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 |
98016 |
n[1] == tt ? n[0].orNode(n[2]) : (n[0].negate()).andNode(n[2]); |
423 |
98016 |
Debug("bool-ite") << "TheoryBoolRewriter::preRewrite_ITE: n[1] const " |
424 |
49008 |
<< n << ": " << resp << std::endl; |
425 |
49008 |
return RewriteResponse(REWRITE_AGAIN, resp); |
426 |
|
} |
427 |
1619148 |
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 |
136268 |
n[2] == tt ? (n[0].negate()).orNode(n[1]) : n[0].andNode(n[1]); |
433 |
136268 |
Debug("bool-ite") << "TheoryBoolRewriter::preRewrite_ITE: n[2] const " |
434 |
68134 |
<< n << ": " << resp << std::endl; |
435 |
68134 |
return RewriteResponse(REWRITE_AGAIN, resp); |
436 |
|
} |
437 |
|
|
438 |
1551014 |
break; |
439 |
|
} |
440 |
805479 |
default: |
441 |
805479 |
return RewriteResponse(REWRITE_DONE, n); |
442 |
|
} |
443 |
15019890 |
return RewriteResponse(REWRITE_DONE, n); |
444 |
|
} |
445 |
|
|
446 |
|
} // namespace booleans |
447 |
|
} // namespace theory |
448 |
31137 |
} // namespace cvc5 |