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 |
12166420 |
RewriteResponse TheoryBoolRewriter::postRewrite(TNode node) { |
32 |
12166420 |
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 |
802820 |
RewriteResponse flattenNode(TNode n, TNode trivialNode, TNode skipNode) |
49 |
|
{ |
50 |
|
typedef std::unordered_set<TNode> node_set; |
51 |
|
|
52 |
1605640 |
node_set visited; |
53 |
802820 |
visited.insert(skipNode); |
54 |
|
|
55 |
1605640 |
std::vector<TNode> toProcess; |
56 |
802820 |
toProcess.push_back(n); |
57 |
|
|
58 |
802820 |
Kind k = n.getKind(); |
59 |
|
typedef std::vector<TNode> ChildList; |
60 |
1605640 |
ChildList childList; //TNode should be fine, since 'n' is still there |
61 |
|
|
62 |
2287792 |
for (unsigned i = 0; i < toProcess.size(); ++ i) { |
63 |
2984982 |
TNode current = toProcess[i]; |
64 |
10430788 |
for(unsigned j = 0, j_end = current.getNumChildren(); j < j_end; ++ j) { |
65 |
16141478 |
TNode child = current[j]; |
66 |
8945816 |
if(visited.find(child) != visited.end()) { |
67 |
1735116 |
continue; |
68 |
7210700 |
} else if(child == trivialNode) { |
69 |
15038 |
return RewriteResponse(REWRITE_DONE, trivialNode); |
70 |
|
} else { |
71 |
7195662 |
visited.insert(child); |
72 |
7195662 |
if(child.getKind() == k) |
73 |
698024 |
toProcess.push_back(child); |
74 |
|
else |
75 |
6497638 |
childList.push_back(child); |
76 |
|
} |
77 |
|
} |
78 |
|
} |
79 |
787782 |
if (childList.size() == 0) return RewriteResponse(REWRITE_DONE, skipNode); |
80 |
681697 |
if (childList.size() == 1) return RewriteResponse(REWRITE_AGAIN, childList[0]); |
81 |
|
|
82 |
|
/* Trickery to stay under number of children possible in a node */ |
83 |
533916 |
NodeManager* nodeManager = NodeManager::currentNM(); |
84 |
533916 |
if (childList.size() < expr::NodeValue::MAX_CHILDREN) |
85 |
|
{ |
86 |
1067832 |
Node retNode = nodeManager->mkNode(k, childList); |
87 |
533916 |
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 |
5180396 |
inline int equalityParity(TNode a, TNode b){ |
112 |
5180396 |
if(a == b){ |
113 |
15975 |
return 1; |
114 |
5164421 |
}else if(a.getKind() == kind::NOT && a[0] == b){ |
115 |
136 |
return 2; |
116 |
5164285 |
}else if(b.getKind() == kind::NOT && b[0] == a){ |
117 |
3590 |
return 3; |
118 |
|
}else{ |
119 |
5160695 |
return 0; |
120 |
|
} |
121 |
|
} |
122 |
|
|
123 |
159318 |
inline Node makeNegation(TNode n){ |
124 |
159318 |
bool even = false; |
125 |
173702 |
while(n.getKind() == kind::NOT){ |
126 |
7192 |
n = n[0]; |
127 |
7192 |
even = !even; |
128 |
|
} |
129 |
159318 |
if(even){ |
130 |
7044 |
return n; |
131 |
|
} else { |
132 |
152274 |
if(n.isConst()){ |
133 |
12806 |
return NodeManager::currentNM()->mkConst(!n.getConst<bool>()); |
134 |
|
}else{ |
135 |
139468 |
return n.notNode(); |
136 |
|
} |
137 |
|
} |
138 |
|
} |
139 |
|
|
140 |
19320977 |
RewriteResponse TheoryBoolRewriter::preRewrite(TNode n) { |
141 |
19320977 |
NodeManager* nodeManager = NodeManager::currentNM(); |
142 |
38641954 |
Node tt = nodeManager->mkConst(true); |
143 |
38641954 |
Node ff = nodeManager->mkConst(false); |
144 |
|
|
145 |
19320977 |
switch(n.getKind()) { |
146 |
3818437 |
case kind::NOT: { |
147 |
3818437 |
if (n[0] == tt) return RewriteResponse(REWRITE_DONE, ff); |
148 |
3741948 |
if (n[0] == ff) return RewriteResponse(REWRITE_DONE, tt); |
149 |
3632182 |
if (n[0].getKind() == kind::NOT) return RewriteResponse(REWRITE_AGAIN, n[0][0]); |
150 |
3458050 |
break; |
151 |
|
} |
152 |
4650444 |
case kind::OR: { |
153 |
4650444 |
bool done = true; |
154 |
4650444 |
TNode::iterator i = n.begin(), iend = n.end(); |
155 |
32837722 |
for(; i != iend; ++i) { |
156 |
14171333 |
if (*i == tt) return RewriteResponse(REWRITE_DONE, tt); |
157 |
14093639 |
if (*i == ff) done = false; |
158 |
14093639 |
if ((*i).getKind() == kind::OR) done = false; |
159 |
|
} |
160 |
4572750 |
if (!done) { |
161 |
297889 |
return flattenNode(n, /* trivialNode = */ tt, /* skipNode = */ ff); |
162 |
|
} |
163 |
|
// x v ... v x --> x |
164 |
|
unsigned ind, size; |
165 |
4282855 |
for (ind = 0, size = n.getNumChildren(); ind < size - 1; ++ind) |
166 |
|
{ |
167 |
4279488 |
if (n[ind] != n[ind+1]) |
168 |
|
{ |
169 |
4271494 |
break; |
170 |
|
} |
171 |
|
} |
172 |
4274861 |
if (ind == size - 1) |
173 |
|
{ |
174 |
3367 |
return RewriteResponse(REWRITE_AGAIN, n[0]); |
175 |
|
} |
176 |
4271494 |
break; |
177 |
|
} |
178 |
4686682 |
case kind::AND: { |
179 |
4686682 |
bool done = true; |
180 |
4686682 |
TNode::iterator i = n.begin(), iend = n.end(); |
181 |
61043792 |
for(; i != iend; ++i) { |
182 |
28445157 |
if (*i == ff) return RewriteResponse(REWRITE_DONE, ff); |
183 |
28178555 |
if (*i == tt) done = false; |
184 |
28178555 |
if ((*i).getKind() == kind::AND) done = false; |
185 |
|
} |
186 |
4420080 |
if (!done) { |
187 |
1009862 |
RewriteResponse ret = flattenNode(n, /* trivialNode = */ ff, /* skipNode = */ tt); |
188 |
504931 |
Debug("bool-flatten") << n << ": " << ret.d_node << std::endl; |
189 |
504931 |
return ret; |
190 |
|
} |
191 |
|
// x ^ ... ^ x --> x |
192 |
|
unsigned ind, size; |
193 |
3946529 |
for (ind = 0, size = n.getNumChildren(); ind < size - 1; ++ind) |
194 |
|
{ |
195 |
3941772 |
if (n[ind] != n[ind+1]) |
196 |
|
{ |
197 |
3910392 |
break; |
198 |
|
} |
199 |
|
} |
200 |
3915149 |
if (ind == size - 1) |
201 |
|
{ |
202 |
4757 |
return RewriteResponse(REWRITE_AGAIN, n[0]); |
203 |
|
} |
204 |
3910392 |
break; |
205 |
|
} |
206 |
508152 |
case kind::IMPLIES: { |
207 |
508152 |
if (n[0] == ff || n[1] == tt) return RewriteResponse(REWRITE_DONE, tt); |
208 |
505499 |
if (n[0] == tt && n[1] == ff) return RewriteResponse(REWRITE_DONE, ff); |
209 |
505394 |
if (n[0] == tt) return RewriteResponse(REWRITE_AGAIN, n[1]); |
210 |
494446 |
if (n[1] == ff) return RewriteResponse(REWRITE_AGAIN, makeNegation(n[0])); |
211 |
474834 |
break; |
212 |
|
} |
213 |
1699865 |
case kind::EQUAL: { |
214 |
|
// rewrite simple cases of IFF |
215 |
1699865 |
if(n[0] == tt) { |
216 |
|
// IFF true x |
217 |
20302 |
return RewriteResponse(REWRITE_AGAIN, n[1]); |
218 |
1679563 |
} else if(n[1] == tt) { |
219 |
|
// IFF x true |
220 |
29405 |
return RewriteResponse(REWRITE_AGAIN, n[0]); |
221 |
1650158 |
} else if(n[0] == ff) { |
222 |
|
// IFF false x |
223 |
48464 |
return RewriteResponse(REWRITE_AGAIN, makeNegation(n[1])); |
224 |
1601694 |
} else if(n[1] == ff) { |
225 |
|
// IFF x false |
226 |
65678 |
return RewriteResponse(REWRITE_AGAIN, makeNegation(n[0])); |
227 |
1536016 |
} else if(n[0] == n[1]) { |
228 |
|
// IFF x x |
229 |
34517 |
return RewriteResponse(REWRITE_DONE, tt); |
230 |
1501499 |
} else if(n[0].getKind() == kind::NOT && n[0][0] == n[1]) { |
231 |
|
// IFF (NOT x) x |
232 |
314 |
return RewriteResponse(REWRITE_DONE, ff); |
233 |
1501185 |
} else if(n[1].getKind() == kind::NOT && n[1][0] == n[0]) { |
234 |
|
// IFF x (NOT x) |
235 |
600 |
return RewriteResponse(REWRITE_DONE, ff); |
236 |
1500585 |
} 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 |
40834 |
TNode t,c; |
255 |
20425 |
if (n[0][0].isConst()) { |
256 |
893 |
c = n[0][0]; |
257 |
893 |
t = n[0][1]; |
258 |
|
} |
259 |
19532 |
else if (n[0][1].isConst()) { |
260 |
1798 |
c = n[0][1]; |
261 |
1798 |
t = n[0][0]; |
262 |
|
} |
263 |
20425 |
bool matchesForm = false; |
264 |
20425 |
bool constantsEqual = false; |
265 |
20425 |
if (!c.isNull()) { |
266 |
2691 |
if (n[1][0] == t && n[1][1].isConst()) { |
267 |
8 |
matchesForm = true; |
268 |
8 |
constantsEqual = (n[1][1] == c); |
269 |
|
} |
270 |
2683 |
else if (n[1][1] == t && n[1][0].isConst()) { |
271 |
8 |
matchesForm = true; |
272 |
8 |
constantsEqual = (n[1][0] == c); |
273 |
|
} |
274 |
|
} |
275 |
20425 |
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 |
1500569 |
if (n[0].getId() > n[1].getId()) |
292 |
|
{ |
293 |
|
return RewriteResponse(REWRITE_AGAIN, |
294 |
221924 |
nodeManager->mkNode(kind::EQUAL, n[1], n[0])); |
295 |
|
} |
296 |
1278645 |
return RewriteResponse(REWRITE_DONE, n); |
297 |
|
} |
298 |
1212514 |
case kind::XOR: { |
299 |
|
// rewrite simple cases of XOR |
300 |
1212514 |
if(n[0] == tt) { |
301 |
|
// XOR true x |
302 |
6235 |
return RewriteResponse(REWRITE_AGAIN, makeNegation(n[1])); |
303 |
1206279 |
} else if(n[1] == tt) { |
304 |
|
// XOR x true |
305 |
15599 |
return RewriteResponse(REWRITE_AGAIN, makeNegation(n[0])); |
306 |
1190680 |
} else if(n[0] == ff) { |
307 |
|
// XOR false x |
308 |
37986 |
return RewriteResponse(REWRITE_AGAIN, n[1]); |
309 |
1152694 |
} else if(n[1] == ff) { |
310 |
|
// XOR x false |
311 |
114649 |
return RewriteResponse(REWRITE_AGAIN, n[0]); |
312 |
1038045 |
} else if(n[0] == n[1]) { |
313 |
|
// XOR x x |
314 |
939 |
return RewriteResponse(REWRITE_DONE, ff); |
315 |
1037106 |
} else if(n[0].getKind() == kind::NOT && n[0][0] == n[1]) { |
316 |
|
// XOR (NOT x) x |
317 |
28 |
return RewriteResponse(REWRITE_DONE, tt); |
318 |
1037078 |
} else if(n[1].getKind() == kind::NOT && n[1][0] == n[0]) { |
319 |
|
// XOR x (NOT x) |
320 |
195 |
return RewriteResponse(REWRITE_DONE, tt); |
321 |
|
} |
322 |
1036883 |
break; |
323 |
|
} |
324 |
1927452 |
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 |
1927452 |
if (n[0].isConst()) { |
329 |
247792 |
if (n[0] == tt) { |
330 |
|
// ITE true x y |
331 |
35800 |
Debug("bool-ite") << "TheoryBoolRewriter::preRewrite_ITE: n[0] ==tt " |
332 |
17900 |
<< n << ": " << n[1] << std::endl; |
333 |
17900 |
return RewriteResponse(REWRITE_AGAIN, n[1]); |
334 |
|
} else { |
335 |
229892 |
Assert(n[0] == ff); |
336 |
|
// ITE false x y |
337 |
459784 |
Debug("bool-ite") << "TheoryBoolRewriter::preRewrite_ITE: n[0] ==ff " |
338 |
229892 |
<< n << ": " << n[1] << std::endl; |
339 |
229892 |
return RewriteResponse(REWRITE_AGAIN, n[2]); |
340 |
|
} |
341 |
1679660 |
} else if (n[1].isConst()) { |
342 |
403277 |
if (n[1] == tt && n[2] == ff) { |
343 |
9638 |
Debug("bool-ite") |
344 |
4819 |
<< "TheoryBoolRewriter::preRewrite_ITE: n[1] ==tt && n[2] == ff " |
345 |
4819 |
<< n << ": " << n[0] << std::endl; |
346 |
4819 |
return RewriteResponse(REWRITE_AGAIN, n[0]); |
347 |
|
} |
348 |
398458 |
else if (n[1] == ff && n[2] == tt) { |
349 |
7408 |
Debug("bool-ite") |
350 |
3704 |
<< "TheoryBoolRewriter::preRewrite_ITE: n[1] ==ff && n[2] == tt " |
351 |
3704 |
<< n << ": " << n[0].notNode() << std::endl; |
352 |
3704 |
return RewriteResponse(REWRITE_AGAIN, makeNegation(n[0])); |
353 |
|
} |
354 |
|
} |
355 |
|
|
356 |
1671137 |
if (n[0].getKind() == kind::NOT) |
357 |
|
{ |
358 |
|
// ite(not(c), x, y) ---> ite(c, y, x) |
359 |
|
return RewriteResponse( |
360 |
118942 |
REWRITE_AGAIN, nodeManager->mkNode(kind::ITE, n[0][0], n[2], n[1])); |
361 |
|
} |
362 |
|
|
363 |
|
int parityTmp; |
364 |
1552195 |
if ((parityTmp = equalityParity(n[1], n[2])) != 0) { |
365 |
24456 |
Node resp = (parityTmp == 1) ? (Node)n[1] : n[0].eqNode(n[1]); |
366 |
24456 |
Debug("bool-ite") |
367 |
12228 |
<< "TheoryBoolRewriter::preRewrite_ITE: equalityParity n[1], n[2] " |
368 |
12228 |
<< parityTmp << " " << n << ": " << resp << std::endl; |
369 |
12228 |
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 |
1539967 |
} 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 |
5874 |
Node resp = n[0].iteNode( (parityTmp == 1) ? tt : ff, n[2]); |
379 |
5874 |
Debug("bool-ite") |
380 |
2937 |
<< "TheoryBoolRewriter::preRewrite_ITE: equalityParity n[0], n[1] " |
381 |
2937 |
<< parityTmp << " " << n << ": " << resp << std::endl; |
382 |
2937 |
return RewriteResponse(REWRITE_AGAIN, resp); |
383 |
1537030 |
} 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 |
874 |
Node resp = n[0].iteNode(n[1], (parityTmp == 1) ? ff : tt); |
387 |
874 |
Debug("bool-ite") |
388 |
437 |
<< "TheoryBoolRewriter::preRewrite_ITE: equalityParity n[0], n[2] " |
389 |
437 |
<< parityTmp << " " << n << ": " << resp << std::endl; |
390 |
437 |
return RewriteResponse(REWRITE_AGAIN, resp); |
391 |
4466827 |
} else if(n[1].getKind() == kind::ITE && |
392 |
2930234 |
(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 |
4104 |
Node resp = n[0].iteNode((parityTmp == 1) ? n[1][1] : n[1][2], n[2]); |
397 |
4104 |
Debug("bool-ite") |
398 |
2052 |
<< "TheoryBoolRewriter::preRewrite: equalityParity n[0], n[1][0] " |
399 |
2052 |
<< parityTmp << " " << n << ": " << resp << std::endl; |
400 |
2052 |
return RewriteResponse(REWRITE_AGAIN, resp); |
401 |
5004400 |
} else if(n[2].getKind() == kind::ITE && |
402 |
3469859 |
(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 |
4094 |
Node resp = n[0].iteNode(n[1], (parityTmp == 1) ? n[2][2] : n[2][1]); |
407 |
4094 |
Debug("bool-ite") |
408 |
2047 |
<< "TheoryBoolRewriter::preRewrite: equalityParity n[0], n[2][0] " |
409 |
2047 |
<< parityTmp << " " << n << ": " << resp << std::endl; |
410 |
2047 |
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 |
1532494 |
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 |
153122 |
n[1] == tt ? n[0].orNode(n[2]) : (n[0].negate()).andNode(n[2]); |
423 |
153122 |
Debug("bool-ite") << "TheoryBoolRewriter::preRewrite_ITE: n[1] const " |
424 |
76561 |
<< n << ": " << resp << std::endl; |
425 |
76561 |
return RewriteResponse(REWRITE_AGAIN, resp); |
426 |
|
} |
427 |
1455933 |
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 |
111264 |
n[2] == tt ? (n[0].negate()).orNode(n[1]) : n[0].andNode(n[1]); |
433 |
111264 |
Debug("bool-ite") << "TheoryBoolRewriter::preRewrite_ITE: n[2] const " |
434 |
55632 |
<< n << ": " << resp << std::endl; |
435 |
55632 |
return RewriteResponse(REWRITE_AGAIN, resp); |
436 |
|
} |
437 |
|
|
438 |
1400301 |
break; |
439 |
|
} |
440 |
817431 |
default: |
441 |
817431 |
return RewriteResponse(REWRITE_DONE, n); |
442 |
|
} |
443 |
14551954 |
return RewriteResponse(REWRITE_DONE, n); |
444 |
|
} |
445 |
|
|
446 |
|
} // namespace booleans |
447 |
|
} // namespace theory |
448 |
29340 |
} // namespace cvc5 |