SMTStabilizer API
Public API documentation for SMTStabilizer
Loading...
Searching...
No Matches
dag.h
Go to the documentation of this file.
1/* -*- Header -*-
2 *
3 * The Directed Acyclic Graph (DAG) Class
4 *
5 * Author: Fuqi Jia <jiafq@ios.ac.cn>
6 *
7 * Copyright (C) 2025 Fuqi Jia
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 * DEALINGS IN THE SOFTWARE.
26 */
27
28// Modified by Xiang Zhang, 2026
29// Additional changes licensed under the MIT License
30
31#ifndef DAG_HEADER
32#define DAG_HEADER
33
34#include <algorithm>
35#include <array>
36#include <cstdlib>
37#include <ctime>
38#include <fstream>
39#include <functional> // for std::hash
40#include <iostream>
41#include <list>
42#include <memory>
43#include <string>
44#include <unordered_map>
45#include <unordered_set>
46#include <vector>
47
48#include "kind.h"
49#include "sort.h"
50#include "util.h"
51#include "value.h"
52
53namespace stabilizer::parser {
54// Forward declaration of DAGNode class
55class DAGNode;
56
57// define hash function and equal function for std::pair<const DAGNode*, const
58// DAGNode*>
60 size_t
61 operator()(const std::pair<const DAGNode *, const DAGNode *> &p) const {
62 return std::hash<const void *>()(p.first) ^
63 std::hash<const void *>()(p.second);
64 }
65};
66
68 bool operator()(const std::pair<const DAGNode *, const DAGNode *> &p1,
69 const std::pair<const DAGNode *, const DAGNode *> &p2) const {
70 return p1.first == p2.first && p1.second == p2.second;
71 }
72};
73
74class DAGNode {
75 // <sort, kind, name> --- <sort, node_kind, name>
76 private:
77 std::shared_ptr<Sort> sort;
79 std::string name;
80 std::shared_ptr<Value> value;
81 std::vector<std::shared_ptr<DAGNode>> children;
82
83 std::string children_hash;
84 mutable size_t cached_hash_code;
85 mutable bool hash_computed;
86 mutable size_t _use_count;
87
88 public:
89 DAGNode(std::shared_ptr<Sort> sort, NODE_KIND kind, std::string name, std::vector<std::shared_ptr<DAGNode>> children)
90 : sort(sort), kind(kind), name(name), value(nullptr), children(children) {
91 // value is not used for hash
92 if (children.empty()) {
93 children_hash = "";
94 }
95 else {
96 size_t combined_hash = 0;
97 for (size_t i = 0; i < children.size(); i++) {
98 size_t child_hash = children[i]->hashCode();
99 combined_hash ^= child_hash + 0x9e3779b9 + (combined_hash << 6) +
100 (combined_hash >> 2);
101 }
102 children_hash = std::to_string(combined_hash);
103 }
105 hash_computed = false;
106 _use_count = 0;
107
108 if (kind == NODE_KIND::NT_CONST) {
110 value = newValue(Number(name, true));
111 }
112 else if (TypeChecker::isReal(name)) {
113 value = newValue(Number(name, false));
114 }
115 // TODO for value
116 }
117 }
118 DAGNode(std::shared_ptr<Sort> sort, NODE_KIND kind, std::string name)
119 : sort(sort), kind(kind), name(name), value(nullptr) {
120 children_hash = "";
122 hash_computed = false;
123 _use_count = 0;
124
125 if (kind == NODE_KIND::NT_CONST) {
127 value = newValue(Number(name, true));
128 }
129 else if (TypeChecker::isReal(name)) {
130 value = newValue(Number(name, false));
131 }
132 // TODO for value
133 }
134 }
135 DAGNode(std::shared_ptr<Sort> sort, NODE_KIND kind)
136 : sort(sort), kind(kind), name(""), value(nullptr) {
137 children_hash = "";
139 hash_computed = false;
140 _use_count = 0;
141
142 if (kind == NODE_KIND::NT_CONST) {
143 value = newValue(Number());
144 }
145 }
146 DAGNode(std::shared_ptr<Sort> sort)
147 : sort(sort), kind(NODE_KIND::NT_UNKNOWN), name(""), value(nullptr) {
148 children_hash = "";
150 hash_computed = false;
151 _use_count = 0;
152
153 if (kind == NODE_KIND::NT_CONST) {
154 value = newValue(Number());
155 }
156 }
158 : sort(SortManager::NULL_SORT), kind(NODE_KIND::NT_UNKNOWN), name(""), value(nullptr), children_hash(""), cached_hash_code(0), hash_computed(false), _use_count(1) {
159 children_hash = "";
160 }
161 DAGNode(const DAGNode &other)
162 : sort(other.sort), kind(other.kind), name(other.name), value(other.value), children(other.children), children_hash(other.children_hash), cached_hash_code(0), hash_computed(false), _use_count(1) {}
163
164 // other initialization
166 : sort(SortManager::NULL_SORT), kind(kind), name(name), value(nullptr) {
167 children_hash = "";
169 hash_computed = false;
170 _use_count = 0;
171
172 if (kind == NODE_KIND::NT_CONST) {
174 value = newValue(Number(name, true));
175 }
176 else if (TypeChecker::isReal(name)) {
177 value = newValue(Number(name, false));
178 }
179 }
180 }
182 : sort(SortManager::NULL_SORT), kind(kind), name(""), value(nullptr) {
183 children_hash = "";
185 hash_computed = false;
186 _use_count = 0;
187
188 if (kind == NODE_KIND::NT_CONST) {
189 value = newValue(Number());
190 }
191 }
192 DAGNode(std::shared_ptr<Sort> sort, const Integer &v)
194 children_hash = "";
196 hash_computed = false;
197 _use_count = 0;
198 name = v.toString();
199 }
200 DAGNode(std::shared_ptr<Sort> sort, const Real &v)
202 children_hash = "";
204 hash_computed = false;
205 _use_count = 0;
206 name = v.toString();
207 }
208 DAGNode(std::shared_ptr<Sort> sort, const double &v)
210 children_hash = "";
212 hash_computed = false;
213 _use_count = 0;
214 name = std::to_string(v);
215 }
216 DAGNode(std::shared_ptr<Sort> sort, const int &v)
218 children_hash = "";
220 hash_computed = false;
221 _use_count = 0;
222 name = std::to_string(v);
223 }
224 DAGNode(std::shared_ptr<Sort> sort, const bool &v)
226 children_hash = "";
228 hash_computed = false;
229 _use_count = 0;
230 name = v ? "true" : "false";
231 }
232
233 // only constant
234 DAGNode(const std::string &n) {
235 children_hash = "";
237 hash_computed = false;
238 _use_count = 0;
239 if (n == "true") {
242 }
243 else if (n == "false") {
246 }
247 else if (n == "pi") {
250 }
251 else if (n == "e") {
254 }
255 else if (n == "inf") {
258 }
259 else if (n == "NaN" || n == "+NaN" || n == "-NaN") {
262 }
263 else if (n == "epsilon") {
266 }
267 else if (n == "NULL") {
270 }
271 else if (TypeChecker::isInt(n)) {
274 value = newValue(Number(n, true));
275 }
276 else if (TypeChecker::isReal(n)) {
279 value = newValue(Number(n, false));
280 }
281 else if (TypeChecker::isString(n)) {
284 }
285 else {
288 }
289 name = n;
290 }
291
292 void clear() {
294 children.clear();
295 children_hash = "";
297 hash_computed = false;
298 name = "";
299 _use_count = 0;
300 }
301
302 bool operator==(const DAGNode elem) {
303 return (sort == elem.sort && kind == elem.kind && name == elem.name &&
305 }
306 bool operator!=(const DAGNode elem) {
307 return (sort != elem.sort || kind != elem.kind || name != elem.name ||
309 }
310
311 void
312 replace_children(const std::vector<std::shared_ptr<DAGNode>> &new_children) {
313 children = new_children;
314 }
315
316 void setName(const std::string &n) { name = n; }
317
318 bool isLeaf() const { return children.empty(); };
319 bool isInternal() const { return !children.empty(); };
320
321 // check null
322 bool isNull() const { return kind == NODE_KIND::NT_NULL; };
323
324 // check error
325 bool isErr() const { return (kind == NODE_KIND::NT_ERROR); };
326
327 // check unknown
328 bool isUnknown() const { return kind == NODE_KIND::NT_UNKNOWN; };
329
330 // check const
331 bool isCBool() const {
332 return (kind == NODE_KIND::NT_CONST_TRUE ||
334 sort->isBool();
335 };
336 bool isTrue() const {
337 return kind == NODE_KIND::NT_CONST_TRUE && sort->isBool();
338 };
339 bool isFalse() const {
340 return kind == NODE_KIND::NT_CONST_FALSE && sort->isBool();
341 };
352 bool isNumeral() const { return isCInt() || isCReal(); };
353 bool isCInt() const {
354 return isConst() && (sort->isInt() || sort->isIntOrReal());
355 };
356 bool isCReal() const {
357 return isConst() && (sort->isReal() || sort->isIntOrReal());
358 };
359 bool isCBV() const { return isConst() && sort->isBv(); };
360 bool isCFP() const { return isConst() && sort->isFp(); };
361 bool isCRoundingMode() const { return isConst() && sort->isRoundingMode(); };
362 bool isCStr() const { return isConst() && sort->isStr(); };
371
372 // check var
373 bool isVBool() const {
378 sort->isBool();
379 };
380 bool isLiteral() const {
381 return (isVBool() || (isNot() && getChild(0)->isVBool()) || isCBool());
382 };
383 bool isVInt() const {
388 sort->isInt();
389 };
390 bool isVReal() const {
395 sort->isReal();
396 };
397 bool isVBV() const {
402 sort->isBv();
403 };
404 bool isVFP() const {
409 sort->isFp();
410 };
411 bool isVRoundingMode() const {
416 sort->isRoundingMode();
417 };
418 bool isVStr() const {
423 sort->isStr();
424 };
425 bool isTempVar() const { return kind == NODE_KIND::NT_TEMP_VAR; };
426 bool isQuantVar() const { return kind == NODE_KIND::NT_QUANT_VAR; };
427 bool isLetBindVar() const { return kind == NODE_KIND::NT_LET_BIND_VAR; };
428 bool isPlaceholderVar() const {
430 };
431 bool isVReg() const {
436 sort->isReg();
437 };
438 // bool isVDT() const { return kind == NODE_KIND::NT_DT_TESTER || kind ==
439 // NODE_KIND::; };
440 bool isVar() const {
441 return (isVBool() || isVInt() || isVReal() || isVBV() || isVFP() ||
442 isVRoundingMode() || isVStr() || isTempVar() || isQuantVar() ||
444 };
445 bool isVUF() const {
446 return kind == NODE_KIND::NT_VAR && (sort->isDec() || sort->isDef());
447 };
448 bool isUFName() const { return kind == NODE_KIND::NT_UF_NAME; };
449
450 // interval
451 bool isMax() const { return kind == NODE_KIND::NT_MAX; };
452 bool isMin() const { return kind == NODE_KIND::NT_MIN; };
453
454 // check array
455 bool isArray() const {
456 return (kind == NODE_KIND::NT_VAR ||
459 sort->isArray();
460 };
461 bool isConstArray() const { return kind == NODE_KIND::NT_CONST_ARRAY; };
462
463 // check Boolean operations
464 bool isAnd() const { return (kind == NODE_KIND::NT_AND); };
465 bool isOr() const { return (kind == NODE_KIND::NT_OR); };
466 bool isNot() const { return (kind == NODE_KIND::NT_NOT); };
467 bool isImplies() const { return (kind == NODE_KIND::NT_IMPLIES); };
468 bool isXor() const { return (kind == NODE_KIND::NT_XOR); };
469
470 // check comparison
471 bool isEqBool() const { return (kind == NODE_KIND::NT_EQ_BOOL); };
472 bool isEqOther() const { return (kind == NODE_KIND::NT_EQ_OTHER); };
473 bool isEq() const {
474 return (kind == NODE_KIND::NT_EQ || isEqBool() || isEqOther());
475 };
476 bool isDistinctBool() const { return (kind == NODE_KIND::NT_DISTINCT_BOOL); };
477 bool isDistinctOther() const {
479 };
480 bool isDistinct() const {
483 };
484 bool isNeq() const { return isDistinct(); };
485
486 // check UF
487 bool isUFApplication() const { return (kind == NODE_KIND::NT_UF_APPLY); };
488
489 // check arithmetic operations
490 bool isAdd() const { return (kind == NODE_KIND::NT_ADD); };
491 bool isSub() const { return (kind == NODE_KIND::NT_SUB); };
492 bool isMul() const { return (kind == NODE_KIND::NT_MUL); };
493 bool isNeg() const { return (kind == NODE_KIND::NT_NEG); };
494 bool isDivInt() const { return (kind == NODE_KIND::NT_DIV_INT); };
495 bool isDivReal() const { return (kind == NODE_KIND::NT_DIV_REAL); };
496 bool isMod() const { return (kind == NODE_KIND::NT_MOD); };
497 bool isAbs() const { return (kind == NODE_KIND::NT_ABS); };
498 bool isCeil() const { return (kind == NODE_KIND::NT_CEIL); };
499 bool isFloor() const { return (kind == NODE_KIND::NT_FLOOR); };
500 bool isRound() const { return (kind == NODE_KIND::NT_ROUND); };
501 bool isArithOp() const {
502 return (isAdd() || isSub() || isMul() || isNeg() || isDivInt() ||
503 isDivReal() || isMod() || isAbs() || isCeil() || isFloor() ||
504 isRound());
505 };
506
507 // check transcendental operations
508 bool isIAnd() const { return (kind == NODE_KIND::NT_IAND); };
509 bool isPow2() const { return (kind == NODE_KIND::NT_POW2); };
510 bool isPow() const { return (kind == NODE_KIND::NT_POW); };
511 bool isSqrt() const { return (kind == NODE_KIND::NT_SQRT); };
512 bool isSafeSqrt() const { return (kind == NODE_KIND::NT_SAFESQRT); };
513 bool isRealNonlinearOp() const {
514 return (isIAnd() || isPow2() || isPow() || isSqrt() || isSafeSqrt());
515 };
516 bool isExp() const { return (kind == NODE_KIND::NT_EXP); };
517 bool isLog() const { return (kind == NODE_KIND::NT_LOG); };
518 bool isLn() const { return (kind == NODE_KIND::NT_LN); };
519 bool isLb() const { return (kind == NODE_KIND::NT_LB); };
520 bool isLg() const { return (kind == NODE_KIND::NT_LG); };
521 bool isSin() const { return (kind == NODE_KIND::NT_SIN); };
522 bool isCos() const { return (kind == NODE_KIND::NT_COS); };
523 bool isSec() const { return (kind == NODE_KIND::NT_SEC); };
524 bool isCsc() const { return (kind == NODE_KIND::NT_CSC); };
525 bool isTan() const { return (kind == NODE_KIND::NT_TAN); };
526 bool isCot() const { return (kind == NODE_KIND::NT_COT); };
527 bool isAsin() const { return (kind == NODE_KIND::NT_ASIN); };
528 bool isAcos() const { return (kind == NODE_KIND::NT_ACOS); };
529 bool isAsec() const { return (kind == NODE_KIND::NT_ASEC); };
530 bool isAcsc() const { return (kind == NODE_KIND::NT_ACSC); };
531 bool isAtan() const { return (kind == NODE_KIND::NT_ATAN); };
532 bool isAcot() const { return (kind == NODE_KIND::NT_ACOT); };
533 bool isSinh() const { return (kind == NODE_KIND::NT_SINH); };
534 bool isCosh() const { return (kind == NODE_KIND::NT_COSH); };
535 bool isTanh() const { return (kind == NODE_KIND::NT_TANH); };
536 bool isSech() const { return (kind == NODE_KIND::NT_SECH); };
537 bool isCsch() const { return (kind == NODE_KIND::NT_CSCH); };
538 bool isCoth() const { return (kind == NODE_KIND::NT_COTH); };
539 bool isAsinh() const { return (kind == NODE_KIND::NT_ASINH); };
540 bool isAcosh() const { return (kind == NODE_KIND::NT_ACOSH); };
541 bool isAtanh() const { return (kind == NODE_KIND::NT_ATANH); };
542 bool isAsech() const { return (kind == NODE_KIND::NT_ASECH); };
543 bool isAcsch() const { return (kind == NODE_KIND::NT_ACSCH); };
544 bool isAcoth() const { return (kind == NODE_KIND::NT_ACOTH); };
545 bool isAtan2() const { return (kind == NODE_KIND::NT_ATAN2); };
546 bool isTranscendentalOp() const {
547 return (isExp() || isLog() || isLn() || isLb() || isLg() || isSin() ||
548 isCos() || isSec() || isCsc() || isTan() || isCot() || isAsin() ||
549 isAcos() || isAsec() || isAcsc() || isAtan() || isAcot() ||
550 isSinh() || isCosh() || isTanh() || isSech() || isCsch() ||
551 isCoth() || isAsinh() || isAcosh() || isAtanh() || isAsech() ||
552 isAcsch() || isAcoth() || isAtan2());
553 };
554
555 // check arithmetic comparison
556 bool isLe() const { return (kind == NODE_KIND::NT_LE); };
557 bool isLt() const { return (kind == NODE_KIND::NT_LT); };
558 bool isGe() const { return (kind == NODE_KIND::NT_GE); };
559 bool isGt() const { return (kind == NODE_KIND::NT_GT); };
560 bool isArithTerm() const {
561 return (isArithOp() || isArithConv() || isRealNonlinearOp() ||
562 isTranscendentalOp() || (isVar() && (isVInt() || isVReal())) ||
563 (isConst() && (isCInt() || isCReal())) ||
564 ((isIte() || isMax() || isMin() || isUFApplication()) &&
565 (sort->isInt() || sort->isReal())));
566 };
567 bool isArithComp() const {
568 return ((isEq() && getChild(0)->isArithTerm()) ||
569 (isDistinct() && getChild(0)->isArithTerm()) || isLe() || isLt() ||
570 isGe() || isGt());
571 };
572
573 // check arithmetic covertion
574 bool isToReal() const { return (kind == NODE_KIND::NT_TO_REAL); };
575 bool isToInt() const { return (kind == NODE_KIND::NT_TO_INT); };
576 bool isArithConv() const { return (isToReal() || isToInt()); };
577
578 // check arithmetic properties
579 bool isInt() const { return (kind == NODE_KIND::NT_IS_INT); };
580 bool isDivisible() const { return (kind == NODE_KIND::NT_IS_DIVISIBLE); };
581 bool isPrime() const { return (kind == NODE_KIND::NT_IS_PRIME); };
582 bool isEven() const { return (kind == NODE_KIND::NT_IS_EVEN); };
583 bool isOdd() const { return (kind == NODE_KIND::NT_IS_ODD); };
584 bool isArithProp() const {
585 return (isInt() || isDivisible() || isPrime() || isEven() || isOdd());
586 };
587
588 // check arithmetic constants
589 bool isPi() const { return (kind == NODE_KIND::NT_CONST_PI); };
590 bool isE() const { return (kind == NODE_KIND::NT_CONST_E); };
591 bool isInfinity() const {
592 return (kind == NODE_KIND::NT_INFINITY ||
595 };
596 bool isPosInfinity() const { return (kind == NODE_KIND::NT_POS_INFINITY); };
597 bool isNegInfinity() const { return (kind == NODE_KIND::NT_NEG_INFINITY); };
598 bool isNaN() const { return (kind == NODE_KIND::NT_NAN); };
599 bool isEpsilon() const {
600 return (kind == NODE_KIND::NT_EPSILON ||
603 };
604 bool isPosEpsilon() const { return (kind == NODE_KIND::NT_POS_EPSILON); };
605 bool isNegEpsilon() const { return (kind == NODE_KIND::NT_NEG_EPSILON); };
606
607 // check arithmetic functions
608 // bool isSum() const { return (kind ==
609 // NODE_KIND::NT_SUM); }; bool isProd() const {
610 // return (kind == NODE_KIND::NT_PROD); };
611 bool isGcd() const { return (kind == NODE_KIND::NT_GCD); };
612 bool isLcm() const { return (kind == NODE_KIND::NT_LCM); };
613 bool isFact() const { return (kind == NODE_KIND::NT_FACT); };
614 // Bit-wise operations
615 bool isBVNot() const { return (kind == NODE_KIND::NT_BV_NOT); };
616 bool isBVAnd() const { return (kind == NODE_KIND::NT_BV_AND); };
617 bool isBVOr() const { return (kind == NODE_KIND::NT_BV_OR); };
618 bool isBVXor() const { return (kind == NODE_KIND::NT_BV_XOR); };
619 bool isBVNand() const { return (kind == NODE_KIND::NT_BV_NAND); };
620 bool isBVNor() const { return (kind == NODE_KIND::NT_BV_NOR); };
621 bool isBVXnor() const { return (kind == NODE_KIND::NT_BV_XNOR); };
622 bool isBVComp() const { return (kind == NODE_KIND::NT_BV_COMP); };
623 // Arithmetic operations
624 bool isBVNeg() const { return (kind == NODE_KIND::NT_BV_NEG); };
625 bool isBVAdd() const { return (kind == NODE_KIND::NT_BV_ADD); };
626 bool isBVSub() const { return (kind == NODE_KIND::NT_BV_SUB); };
627 bool isBVMul() const { return (kind == NODE_KIND::NT_BV_MUL); };
628 bool isBVUDiv() const { return (kind == NODE_KIND::NT_BV_UDIV); };
629 bool isBVURem() const { return (kind == NODE_KIND::NT_BV_UREM); };
630 bool isBVSDiv() const { return (kind == NODE_KIND::NT_BV_SDIV); };
631 bool isBVSRem() const { return (kind == NODE_KIND::NT_BV_SREM); };
632 bool isBVUMod() const { return (kind == NODE_KIND::NT_BV_UMOD); };
633 bool isBVSMod() const { return (kind == NODE_KIND::NT_BV_SMOD); };
634 // Arithmetic operations with overflow
635 bool isBVNegO() const { return (kind == NODE_KIND::NT_BV_NEGO); };
636 bool isBVUAddO() const { return (kind == NODE_KIND::NT_BV_UADDO); };
637 bool isBVSAddO() const { return (kind == NODE_KIND::NT_BV_SADDO); };
638 bool isBVUMulO() const { return (kind == NODE_KIND::NT_BV_UMULO); };
639 bool isBVSMulO() const { return (kind == NODE_KIND::NT_BV_SMULO); };
640 bool isBVUDivO() const { return (kind == NODE_KIND::NT_BV_UDIVO); };
641 bool isBVSDivO() const { return (kind == NODE_KIND::NT_BV_SDIVO); };
642 bool isBVURemO() const { return (kind == NODE_KIND::NT_BV_UREMO); };
643 bool isBVSRemO() const { return (kind == NODE_KIND::NT_BV_SREMO); };
644 bool isBVUModO() const { return (kind == NODE_KIND::NT_BV_UMODO); };
645 bool isBVSModO() const { return (kind == NODE_KIND::NT_BV_SMODO); };
646 // Shift operations
647 bool isBVShl() const { return (kind == NODE_KIND::NT_BV_SHL); };
648 bool isBVLSHR() const { return (kind == NODE_KIND::NT_BV_LSHR); };
649 bool isBVASHR() const { return (kind == NODE_KIND::NT_BV_ASHR); };
650 bool isBVConcat() const { return (kind == NODE_KIND::NT_BV_CONCAT); };
651 bool isBVExtract() const { return (kind == NODE_KIND::NT_BV_EXTRACT); };
652 bool isBVRepeat() const { return (kind == NODE_KIND::NT_BV_REPEAT); };
653 bool isBVZeroExt() const { return (kind == NODE_KIND::NT_BV_ZERO_EXT); };
654 bool isBVSignExt() const { return (kind == NODE_KIND::NT_BV_SIGN_EXT); };
655 bool isBVRotLeft() const { return (kind == NODE_KIND::NT_BV_ROTATE_LEFT); };
656 bool isBVRotRight() const { return (kind == NODE_KIND::NT_BV_ROTATE_RIGHT); };
657 bool isBVOp() const {
658 return (isBVNot() || isBVAnd() || isBVOr() || isBVXor() || isBVNand() ||
659 isBVNor() || isBVXnor() || isBVAdd() || isBVSub() || isBVMul() ||
660 isBVUDiv() || isBVURem() || isBVSDiv() || isBVSRem() ||
661 isBVSMod() || isBVShl() || isBVLSHR() || isBVASHR() ||
662 isBVConcat() || isBVExtract() || isBVRepeat() || isBVZeroExt() ||
664 };
665
666 // check bitvector comparison
667 bool isBVUlt() const { return (kind == NODE_KIND::NT_BV_ULT); };
668 bool isBVUle() const { return (kind == NODE_KIND::NT_BV_ULE); };
669 bool isBVUgt() const { return (kind == NODE_KIND::NT_BV_UGT); };
670 bool isBVUge() const { return (kind == NODE_KIND::NT_BV_UGE); };
671 bool isBVSlt() const { return (kind == NODE_KIND::NT_BV_SLT); };
672 bool isBVSle() const { return (kind == NODE_KIND::NT_BV_SLE); };
673 bool isBVSgt() const { return (kind == NODE_KIND::NT_BV_SGT); };
674 bool isBVSge() const { return (kind == NODE_KIND::NT_BV_SGE); };
675 bool isBVTerm() const {
676 return (isBVOp() || (isVar() && isVBV()) || (isConst() && isCBV()) ||
677 (isIte() && getChild(1)->isBVTerm() && getChild(2)->isBVTerm()) ||
678 (isMax() && getChild(0)->isBVTerm() && getChild(1)->isBVTerm()) ||
679 (isMin() && getChild(0)->isBVTerm() && getChild(1)->isBVTerm()) ||
680 (isUFApplication() && sort->isBv()));
681 };
682 bool isBVCompOp() const {
683 return ((isEq() && getChild(0)->isBVTerm()) ||
684 (isDistinct() && getChild(0)->isBVTerm()) || isBVUlt() ||
685 isBVUle() || isBVUgt() || isBVUge() || isBVSlt() || isBVSle() ||
686 isBVSgt() || isBVSge());
687 };
688 bool isBvAtom() const { return isBVCompOp(); };
689
690 // check bitvector conversion
691 bool isBVToNat() const { return (kind == NODE_KIND::NT_BV_TO_NAT); };
692 bool isNatToBV() const { return (kind == NODE_KIND::NT_NAT_TO_BV); };
693 bool isBVToInt() const { return (kind == NODE_KIND::NT_BV_TO_INT); };
694 bool isUBVToInt() const { return (kind == NODE_KIND::NT_UBV_TO_INT); };
695 bool isSBVToInt() const { return (kind == NODE_KIND::NT_SBV_TO_INT); };
696 bool isIntToBV() const { return (kind == NODE_KIND::NT_INT_TO_BV); };
697 bool isBVConv() const {
698 return (isBVToNat() || isNatToBV() || isBVToInt() || isIntToBV());
699 };
700
701 // check floating point common operators
702 bool isFPAdd() const { return (kind == NODE_KIND::NT_FP_ADD); };
703 bool isFPSub() const { return (kind == NODE_KIND::NT_FP_SUB); };
704 bool isFPMul() const { return (kind == NODE_KIND::NT_FP_MUL); };
705 bool isFPDiv() const { return (kind == NODE_KIND::NT_FP_DIV); };
706 bool isFPAbs() const { return (kind == NODE_KIND::NT_FP_ABS); };
707 bool isFPNeg() const { return (kind == NODE_KIND::NT_FP_NEG); };
708 bool isFPRem() const { return (kind == NODE_KIND::NT_FP_REM); };
709 bool isFPFMA() const { return (kind == NODE_KIND::NT_FP_FMA); };
710 bool isFPSqrt() const { return (kind == NODE_KIND::NT_FP_SQRT); };
711 bool isFPRoundToIntegral() const {
713 };
714 bool isFPRoToInt() const {
716 };
717 bool isFPMin() const { return (kind == NODE_KIND::NT_FP_MIN); };
718 bool isFPMax() const { return (kind == NODE_KIND::NT_FP_MAX); };
719 bool isFPOp() const {
720 return (isFPAdd() || isFPSub() || isFPMul() || isFPDiv() || isFPAbs() ||
721 isFPNeg() || isFPRem() || isFPFMA() || isFPSqrt() ||
722 isFPRoToInt() || isFPMin() || isFPMax() ||
723 (isUFApplication() && sort->isFp()));
724 };
725
726 // check floating point comparison
727 bool isFPLe() const { return (kind == NODE_KIND::NT_FP_LE); };
728 bool isFPLt() const { return (kind == NODE_KIND::NT_FP_LT); };
729 bool isFPGe() const { return (kind == NODE_KIND::NT_FP_GE); };
730 bool isFPGt() const { return (kind == NODE_KIND::NT_FP_GT); };
731 bool isFPEq() const { return (kind == NODE_KIND::NT_FP_EQ); };
732 bool isFPComp() const {
733 return (isFPLe() || isFPLt() || isFPGe() || isFPGt() || isFPEq());
734 };
735
736 // check floating point conversion
737 bool isFPToUBV() const { return (kind == NODE_KIND::NT_FP_TO_UBV); };
738 bool isFPToSBV() const { return (kind == NODE_KIND::NT_FP_TO_SBV); };
739 bool isFPToReal() const { return (kind == NODE_KIND::NT_FP_TO_REAL); };
740 bool isToFP() const { return (kind == NODE_KIND::NT_FP_TO_FP); };
741 bool isToFPUnsigned() const {
743 };
744
745 bool isFPConv() const {
746 return (isFPToUBV() || isFPToSBV() || isFPToReal() || isToFP() ||
748 };
749
750 // check floating point properties
751 bool isFPIsNormal() const { return (kind == NODE_KIND::NT_FP_IS_NORMAL); };
752 bool isFPIsSubnormal() const {
754 };
755 bool isFPIsZero() const { return (kind == NODE_KIND::NT_FP_IS_ZERO); };
756 bool isFPIsInf() const { return (kind == NODE_KIND::NT_FP_IS_INF); };
757 bool isFPIsNaN() const { return (kind == NODE_KIND::NT_FP_IS_NAN); };
758 bool isFPIsNeg() const { return (kind == NODE_KIND::NT_FP_IS_NEG); };
759 bool isFPIsPos() const { return (kind == NODE_KIND::NT_FP_IS_POS); };
760 bool isFPProp() const {
761 return isFPIsNormal() || isFPIsSubnormal() || isFPIsZero() || isFPIsInf() ||
762 isFPIsNaN() || isFPIsNeg() || isFPIsPos();
763 }
764
765 // check array
766 bool isSelect() const { return (kind == NODE_KIND::NT_SELECT); };
767 bool isStore() const { return (kind == NODE_KIND::NT_STORE); };
768 bool isArrayOp() const {
769 return (isSelect() || isStore() || (isUFApplication() && sort->isArray()));
770 };
771
772 // check strings common operators
773 bool isStrLen() const { return (kind == NODE_KIND::NT_STR_LEN); };
774 bool isStrConcat() const { return (kind == NODE_KIND::NT_STR_CONCAT); };
775 bool isStrSubstr() const { return (kind == NODE_KIND::NT_STR_SUBSTR); };
776 bool isStrPrefixof() const { return (kind == NODE_KIND::NT_STR_PREFIXOF); };
777 bool isStrSuffixof() const { return (kind == NODE_KIND::NT_STR_SUFFIXOF); };
778 bool isStrIndexof() const { return (kind == NODE_KIND::NT_STR_INDEXOF); };
779 bool isStrCharat() const { return (kind == NODE_KIND::NT_STR_CHARAT); };
780 bool isStrUpdate() const { return (kind == NODE_KIND::NT_STR_UPDATE); };
781 bool isStrReplace() const { return (kind == NODE_KIND::NT_STR_REPLACE); };
782 bool isStrReplaceAll() const {
784 };
785 bool isStrToLower() const { return (kind == NODE_KIND::NT_STR_TO_LOWER); };
786 bool isStrToUpper() const { return (kind == NODE_KIND::NT_STR_TO_UPPER); };
787 bool isStrRev() const { return (kind == NODE_KIND::NT_STR_REV); };
788 bool isStrSplit() const { return (kind == NODE_KIND::NT_STR_SPLIT); };
789 bool isStrSplitAt() const { return (kind == NODE_KIND::NT_STR_SPLIT_AT); };
790 bool isStrSplitRest() const {
792 };
793 bool isStrNumSplits() const {
795 };
796 bool isStrSplitAtRe() const {
798 };
799 bool isStrSplitRestRe() const {
801 };
802 bool isStrNumSplitsRe() const {
804 };
805 bool isStrOp() const {
806 return (isStrLen() || isStrConcat() || isStrSubstr() || isStrPrefixof() ||
809 isStrToLower() || isStrToUpper() || isStrRev() || isStrSplit() ||
812 (isUFApplication() && sort->isStr()));
813 };
814
815 // check strings comparison
816 bool isStrLt() const { return (kind == NODE_KIND::NT_STR_LT); };
817 bool isStrLe() const { return (kind == NODE_KIND::NT_STR_LE); };
818 bool isStrGt() const { return (kind == NODE_KIND::NT_STR_GT); };
819 bool isStrGe() const { return (kind == NODE_KIND::NT_STR_GE); };
820 bool isStrEq() const {
821 return (isEq() && getChildrenSize() >= 2 &&
822 (getChild(0)->isVStr() || getChild(0)->isCStr() ||
823 getChild(0)->isStrOp()));
824 };
825 bool isStrComp() const {
826 return (isStrLt() || isStrLe() || isStrGt() || isStrGe() || isStrEq());
827 };
828
829 // check strings properties
830 bool isStrInReg() const { return (kind == NODE_KIND::NT_STR_IN_REG); };
831 bool isStrContains() const { return (kind == NODE_KIND::NT_STR_CONTAINS); };
832 bool isStrIsDigit() const { return (kind == NODE_KIND::NT_STR_IS_DIGIT); };
833 bool isStrProp() const {
834 return (isStrInReg() || isStrContains() || isStrIsDigit());
835 };
836
837 // check strings conversion
838 bool isStrFromInt() const { return (kind == NODE_KIND::NT_STR_FROM_INT); };
839 bool isStrToInt() const { return (kind == NODE_KIND::NT_STR_TO_INT); };
840 bool isStrToReg() const { return (kind == NODE_KIND::NT_STR_TO_REG); };
841 bool isStrToCode() const { return (kind == NODE_KIND::NT_STR_TO_CODE); };
842 bool isStrFromCode() const { return (kind == NODE_KIND::NT_STR_FROM_CODE); };
843 bool isStrConv() const {
844 return (isStrFromInt() || isStrToInt() || isStrToReg() || isStrToCode() ||
845 isStrFromCode());
846 };
847
848 // reg
849 bool isRegNone() const { return (kind == NODE_KIND::NT_REG_NONE); };
850 bool isRegAll() const { return (kind == NODE_KIND::NT_REG_ALL); };
851 bool isRegAllChar() const { return (kind == NODE_KIND::NT_REG_ALLCHAR); };
852 bool isRegConcat() const { return (kind == NODE_KIND::NT_REG_CONCAT); };
853 bool isRegUnion() const { return (kind == NODE_KIND::NT_REG_UNION); };
854 bool isRegInter() const { return (kind == NODE_KIND::NT_REG_INTER); };
855 bool isRegDiff() const { return (kind == NODE_KIND::NT_REG_DIFF); };
856 bool isRegStar() const { return (kind == NODE_KIND::NT_REG_STAR); };
857 bool isRegPlus() const { return (kind == NODE_KIND::NT_REG_PLUS); };
858 bool isRegOpt() const { return (kind == NODE_KIND::NT_REG_OPT); };
859 bool isRegRange() const { return (kind == NODE_KIND::NT_REG_RANGE); };
860 bool isRegRepeat() const { return (kind == NODE_KIND::NT_REG_REPEAT); };
861 bool isRegLoop() const { return (kind == NODE_KIND::NT_REG_LOOP); };
862 bool isRegComplement() const {
864 };
865
866 bool isAtom() const {
867 return (isArithComp() || isArithProp() || isBVCompOp() || isFPComp() ||
868 isFPProp() || isStrComp() || isStrProp() ||
869 (isUFApplication() && sort->isBool()));
870 };
871 // check let
872 bool isLet() const { return kind == NODE_KIND::NT_LET; };
873 bool isLetChain() const { return kind == NODE_KIND::NT_LET_CHAIN; };
874 bool isLetBindVarList() const {
876 };
877
878 // check ite
879 bool isIte() const { return kind == NODE_KIND::NT_ITE; };
880
881 // check function
882 bool isFuncDec() const { return (kind == NODE_KIND::NT_FUNC_DEC); };
883 bool isFuncDef() const { return (kind == NODE_KIND::NT_FUNC_DEF); };
884 bool isFuncRec() const { return (kind == NODE_KIND::NT_FUNC_REC); };
885 bool isFuncParam() const { return (kind == NODE_KIND::NT_FUNC_PARAM); };
886 bool isFuncApplication() const { return (kind == NODE_KIND::NT_FUNC_APPLY); };
887 bool isDtFunApplication() const {
889 };
890 bool isFuncRecApplication() const {
892 };
893
894 // count the use of the node
895 size_t getUseCount() const { return _use_count; };
896 void incUseCount() { _use_count++; };
897 void decUseCount() { _use_count--; };
898
899 // get pure variable name for let bind var
900 std::string getPureName() const {
901 if (isLetBindVar()) {
902 return name.substr(0, name.find(PRESERVING_LET_BIND_VAR_SUFFIX));
903 }
904 return name;
905 }
906
907 std::string toString() const { return getPureName(); };
908
909 // other functions
915 std::shared_ptr<Sort> getSort() const { return sort; };
921 std::string getName() const { return name; };
922
928 std::string rename(const std::string &new_name) {
929 std::cerr << "Warning: rename " << name << " to " << new_name << std::endl;
930 name = new_name;
931 return new_name;
932 }
933
939 NODE_KIND getKind() const { return kind; };
940
946 std::shared_ptr<Value> getValue() const { return value; };
947
953 void setValue(std::shared_ptr<Value> v) { value = v; };
954
955 void setValue(const Integer &v) { value = newValue(v); };
956
957 void setValue(const Real &v) { value = newValue(v); };
958
959 void setValue(const double &v) { value = newValue(v); };
960
961 void setValue(const int &v) { value = newValue(v); };
962
963 void setValue(const Interval &v) { value = newValue(v); };
964
970 size_t getChildrenSize() const { return children.size(); };
971
977 std::vector<std::shared_ptr<DAGNode>> getChildren() const {
978 return children;
979 };
980
987 std::shared_ptr<DAGNode> getChild(int i) const { return children[i]; };
988 // NOTE: function body is the first child
989
995 std::shared_ptr<DAGNode> getFuncBody() const { return children[0]; };
996
1002 std::vector<std::shared_ptr<DAGNode>> getFuncParams() const {
1003 std::vector<std::shared_ptr<DAGNode>> res;
1004 for (size_t i = 1; i < getChildrenSize(); i++) {
1005 res.emplace_back(getChild(i));
1006 }
1007 return res;
1008 }
1009
1015 size_t getFuncParamsSize() const { return getChildrenSize() - 1; }
1016
1017 // get quant body
1023 std::shared_ptr<DAGNode> getQuantBody() const { return children[0]; };
1024
1030 std::vector<std::shared_ptr<DAGNode>> getQuantVars() const {
1031 std::vector<std::shared_ptr<DAGNode>> res;
1032 for (size_t i = 1; i < getChildrenSize(); i++) {
1033 res.emplace_back(getChild(i));
1034 }
1035 return res;
1036 }
1037
1038 // is really equal to another node
1045 bool isEquivalentTo(const std::shared_ptr<DAGNode> &other) const {
1046 return isEquivalentTo(*other);
1047 }
1048
1055 bool isEquivalentTo(const DAGNode &other) const {
1056 std::unordered_set<std::pair<const DAGNode *, const DAGNode *>,
1059 visited;
1060 return isEquivalentTo(other, visited);
1061 }
1062
1068 std::size_t hashCode() const {
1069 if (hash_computed) {
1070 return cached_hash_code;
1071 }
1072
1073 // high quality hash algorithm, reduce conflicts
1074 size_t h1 = std::hash<std::string>{}(sort->toString());
1075 size_t h2 = static_cast<size_t>(kind);
1076 size_t h3 = name.empty() ? 0 : std::hash<std::string>{}(name);
1077 size_t h4 = children.size();
1078 size_t h5 =
1079 children_hash.empty() ? 0 : std::hash<std::string>{}(children_hash);
1080
1081 // use better hash combination algorithm (based on boost::hash_combine)
1082 size_t seed = 0;
1083 seed ^= h1 + 0x9e3779b9 + (seed << 6) + (seed >> 2);
1084 seed ^= h2 + 0x9e3779b9 + (seed << 6) + (seed >> 2);
1085 seed ^= h3 + 0x9e3779b9 + (seed << 6) + (seed >> 2);
1086 seed ^= h4 + 0x9e3779b9 + (seed << 6) + (seed >> 2);
1087 seed ^= h5 + 0x9e3779b9 + (seed << 6) + (seed >> 2);
1088
1089 seed ^= 0x9e3779b9 + (seed << 6) + (seed >> 2);
1090
1091 cached_hash_code = seed;
1092 hash_computed = true;
1093 return cached_hash_code;
1094 }
1095
1106 void updateFuncDef(std::shared_ptr<Sort> out_sort,
1107 std::shared_ptr<DAGNode> body,
1108 const std::vector<std::shared_ptr<DAGNode>> &params,
1109 bool is_rec = false);
1110
1121 void updateApplyFunc(std::shared_ptr<Sort> out_sort,
1122 std::shared_ptr<DAGNode> body,
1123 const std::vector<std::shared_ptr<DAGNode>> &params,
1124 bool is_rec = false);
1125
1126 private:
1128 const DAGNode &other,
1129 std::unordered_set<std::pair<const DAGNode *, const DAGNode *>,
1131 PairNodePtrEqual> &visited) const {
1132 // fastest check: pointer same
1133 if (this == &other) {
1134 return true;
1135 }
1136
1137 // fast structure check (avoid the expensive subsequent comparison)
1138 if (kind != other.kind || children.size() != other.children.size() ||
1139 sort.get() != other.sort.get()) {
1140 return false;
1141 }
1142
1143 // name check
1144 if (name != other.name) {
1145 return false;
1146 }
1147
1148 // children_hash check (if both are calculated, this is the fastest deep
1149 // comparison)
1150 if (!children_hash.empty() && !other.children_hash.empty() &&
1151 children_hash != other.children_hash) {
1152 return false;
1153 }
1154
1155 auto p = std::make_pair(this, &other);
1156 if (visited.find(p) != visited.end()) {
1157 return true;
1158 }
1159 visited.insert(p);
1160
1161 // most expensive recursive comparison at the end
1162 for (size_t i = 0; i < children.size(); i++) {
1163 if (!children[i]->isEquivalentTo(*other.children[i], visited)) {
1164 return false;
1165 }
1166 }
1167 return true;
1168 }
1169};
1170
1171struct NodeHash {
1172 size_t operator()(const std::shared_ptr<DAGNode> &node) const {
1173 return node->hashCode(); // directly use the cached hash code
1174 }
1175};
1176
1178 bool operator()(const std::shared_ptr<DAGNode> &node1,
1179 const std::shared_ptr<DAGNode> &node2) const {
1180 // fast path: first compare hash code
1181 if (node1->hashCode() != node2->hashCode()) {
1182 return false;
1183 }
1184 // only check the expensive equivalence when the hash is the same
1185 return node1->isEquivalentTo(*node2);
1186 }
1187};
1188
1189std::string dumpSMTLIB2(const std::shared_ptr<DAGNode> &node);
1190std::string dumpFuncDef(const std::shared_ptr<DAGNode> &node);
1191std::string dumpFuncRec(const std::shared_ptr<DAGNode> &node);
1192std::string dumpFuncDec(const std::shared_ptr<DAGNode> &node);
1193
1194// smart pointer
1195typedef std::shared_ptr<DAGNode> NodePtr;
1196
1198 private:
1199 std::vector<std::shared_ptr<DAGNode>> nodes;
1200 // use secondary hash: Kind -> Hash -> NodeIndex
1201 std::array<
1202 std::unordered_map<
1203 size_t,
1204 std::vector<std::pair<std::shared_ptr<DAGNode>, size_t>>>,
1205 NUM_KINDS>
1207 // Track the number of static constant nodes to preserve them during clear()
1209
1210 public:
1211 NodeManager();
1212 ~NodeManager();
1213 std::shared_ptr<DAGNode> getNode(const size_t index) const;
1214 size_t getIndex(const std::shared_ptr<DAGNode> &node) const;
1215 size_t size() const;
1216
1217 // createNode methods corresponding to DAGNode constructors
1218 std::shared_ptr<DAGNode>
1219 createNode(std::shared_ptr<Sort> sort, NODE_KIND kind, std::string name, std::vector<std::shared_ptr<DAGNode>> children);
1220 std::shared_ptr<DAGNode> createNode(std::shared_ptr<Sort> sort,
1221 NODE_KIND kind,
1222 std::string name);
1223 std::shared_ptr<DAGNode> createNode(std::shared_ptr<Sort> sort,
1224 NODE_KIND kind);
1225 std::shared_ptr<DAGNode> createNode(std::shared_ptr<Sort> sort);
1226 std::shared_ptr<DAGNode> createNode();
1227 std::shared_ptr<DAGNode> createNode(NODE_KIND kind, std::string name);
1228 std::shared_ptr<DAGNode> createNode(NODE_KIND kind);
1229 std::shared_ptr<DAGNode> createNode(std::shared_ptr<Sort> sort,
1230 const Integer &v);
1231 std::shared_ptr<DAGNode> createNode(std::shared_ptr<Sort> sort,
1232 const Real &v);
1233 std::shared_ptr<DAGNode> createNode(std::shared_ptr<Sort> sort,
1234 const double &v);
1235 std::shared_ptr<DAGNode> createNode(std::shared_ptr<Sort> sort, const int &v);
1236 std::shared_ptr<DAGNode> createNode(std::shared_ptr<Sort> sort,
1237 const bool &v);
1238 std::shared_ptr<DAGNode> createNode(const std::string &n);
1239
1240 void clear();
1241
1242 // Getter functions for static constant nodes
1243 static std::shared_ptr<DAGNode> getNull() { return NULL_NODE; }
1244 static std::shared_ptr<DAGNode> getUnknown() { return UNKNOWN_NODE; }
1245 static std::shared_ptr<DAGNode> getTrue() { return TRUE_NODE; }
1246 static std::shared_ptr<DAGNode> getFalse() { return FALSE_NODE; }
1247 static std::shared_ptr<DAGNode> getE() { return E_NODE; }
1248 static std::shared_ptr<DAGNode> getPi() { return PI_NODE; }
1249 static std::shared_ptr<DAGNode> getNaN() { return NAN_NODE; }
1250 static std::shared_ptr<DAGNode> getEpsilon() { return EPSILON_NODE; }
1251 static std::shared_ptr<DAGNode> getPosEpsilon() { return POS_EPSILON_NODE; }
1252 static std::shared_ptr<DAGNode> getNegEpsilon() { return NEG_EPSILON_NODE; }
1253
1254 // Infinity getters
1255 static std::shared_ptr<DAGNode> getStrInf() { return STR_INF_NODE; }
1256 static std::shared_ptr<DAGNode> getStrPosInf() { return STR_POS_INF_NODE; }
1257 static std::shared_ptr<DAGNode> getStrNegInf() { return STR_NEG_INF_NODE; }
1258 static std::shared_ptr<DAGNode> getIntInf() { return INT_INF_NODE; }
1259 static std::shared_ptr<DAGNode> getIntPosInf() { return INT_POS_INF_NODE; }
1260 static std::shared_ptr<DAGNode> getIntNegInf() { return INT_NEG_INF_NODE; }
1261 static std::shared_ptr<DAGNode> getRealInf() { return REAL_INF_NODE; }
1262 static std::shared_ptr<DAGNode> getRealPosInf() { return REAL_POS_INF_NODE; }
1263 static std::shared_ptr<DAGNode> getRealNegInf() { return REAL_NEG_INF_NODE; }
1264
1265 public:
1266 // static constant nodes (inline for guaranteed initialization order)
1267 inline static const std::shared_ptr<DAGNode> NULL_NODE =
1268 std::make_shared<DAGNode>("NULL");
1269 inline static const std::shared_ptr<DAGNode> UNKNOWN_NODE =
1270 std::make_shared<DAGNode>(SortManager::UNKNOWN_SORT,
1272 "unknown");
1273 inline static const std::shared_ptr<DAGNode> ERROR_NODE =
1274 std::make_shared<DAGNode>(SortManager::NULL_SORT, NODE_KIND::NT_ERROR, "error");
1275 inline static const std::shared_ptr<DAGNode> TRUE_NODE =
1276 std::make_shared<DAGNode>("true");
1277 inline static const std::shared_ptr<DAGNode> FALSE_NODE =
1278 std::make_shared<DAGNode>("false");
1279 inline static const std::shared_ptr<DAGNode> E_NODE =
1280 std::make_shared<DAGNode>("e");
1281 inline static const std::shared_ptr<DAGNode> PI_NODE =
1282 std::make_shared<DAGNode>("pi");
1283 // inline static const std::shared_ptr<DAGNode> INF_NODE =
1284 // std::make_shared<DAGNode>(SortManager::EXT_SORT, NODE_KIND::NT_INFINITY,
1285 // "INF"); inline static const std::shared_ptr<DAGNode> POS_INF_NODE =
1286 // std::make_shared<DAGNode>(SortManager::EXT_SORT,
1287 // NODE_KIND::NT_POS_INFINITY, "+INF"); inline static const
1288 // std::shared_ptr<DAGNode> NEG_INF_NODE =
1289 // std::make_shared<DAGNode>(SortManager::EXT_SORT,
1290 // NODE_KIND::NT_NEG_INFINITY, "-INF");
1291 inline static const std::shared_ptr<DAGNode> NAN_NODE =
1292 std::make_shared<DAGNode>("NaN");
1293 inline static const std::shared_ptr<DAGNode> EPSILON_NODE =
1294 std::make_shared<DAGNode>("EPSILON");
1295 inline static const std::shared_ptr<DAGNode> POS_EPSILON_NODE =
1296 std::make_shared<DAGNode>(SortManager::EXT_SORT,
1298 "+EPSILON");
1299 inline static const std::shared_ptr<DAGNode> NEG_EPSILON_NODE =
1300 std::make_shared<DAGNode>(SortManager::EXT_SORT,
1302 "-EPSILON");
1303
1304 // infinity
1305 inline static const std::shared_ptr<DAGNode> STR_INF_NODE =
1306 std::make_shared<DAGNode>(SortManager::STR_SORT, NODE_KIND::NT_INFINITY, "INF");
1307 inline static const std::shared_ptr<DAGNode> STR_POS_INF_NODE =
1308 std::make_shared<DAGNode>(SortManager::STR_SORT,
1310 "+INF");
1311 inline static const std::shared_ptr<DAGNode> STR_NEG_INF_NODE =
1312 std::make_shared<DAGNode>(SortManager::STR_SORT,
1314 "-INF");
1315 inline static const std::shared_ptr<DAGNode> INT_INF_NODE =
1316 std::make_shared<DAGNode>(SortManager::INT_SORT, NODE_KIND::NT_INFINITY, "INF");
1317 inline static const std::shared_ptr<DAGNode> INT_POS_INF_NODE =
1318 std::make_shared<DAGNode>(SortManager::INT_SORT,
1320 "+INF");
1321 inline static const std::shared_ptr<DAGNode> INT_NEG_INF_NODE =
1322 std::make_shared<DAGNode>(SortManager::INT_SORT,
1324 "-INF");
1325 inline static const std::shared_ptr<DAGNode> REAL_INF_NODE =
1326 std::make_shared<DAGNode>(SortManager::REAL_SORT, NODE_KIND::NT_INFINITY, "INF");
1327 inline static const std::shared_ptr<DAGNode> REAL_POS_INF_NODE =
1328 std::make_shared<DAGNode>(SortManager::REAL_SORT,
1330 "+INF");
1331 inline static const std::shared_ptr<DAGNode> REAL_NEG_INF_NODE =
1332 std::make_shared<DAGNode>(SortManager::REAL_SORT,
1334 "-INF");
1335
1336 private:
1337 void initializeStaticNodes();
1338 std::shared_ptr<DAGNode>
1339 insertNodeToBucket(const std::shared_ptr<DAGNode> &node);
1340};
1341
1342} // namespace stabilizer::parser
1343#endif
bool isXor() const
Definition dag.h:468
bool isStrContains() const
Definition dag.h:831
bool isSech() const
Definition dag.h:536
bool isRegAllChar() const
Definition dag.h:851
bool isLetChain() const
Definition dag.h:873
bool isSec() const
Definition dag.h:523
std::vector< std::shared_ptr< DAGNode > > getChildren() const
Get the children of the node.
Definition dag.h:977
bool isBVXnor() const
Definition dag.h:621
bool isBVNand() const
Definition dag.h:619
bool isIntToBV() const
Definition dag.h:696
bool isAcosh() const
Definition dag.h:540
bool isStrEq() const
Definition dag.h:820
bool isLg() const
Definition dag.h:520
bool isInfinity() const
Definition dag.h:591
bool isStrProp() const
Definition dag.h:833
bool isInt() const
Definition dag.h:579
bool isBVUlt() const
Definition dag.h:667
bool isBVRotLeft() const
Definition dag.h:655
bool isBVSub() const
Definition dag.h:626
bool isFPAdd() const
Definition dag.h:702
bool isBVASHR() const
Definition dag.h:649
bool isCsc() const
Definition dag.h:524
bool isTan() const
Definition dag.h:525
bool isToFPUnsigned() const
Definition dag.h:741
bool isRegComplement() const
Definition dag.h:862
bool isArithOp() const
Definition dag.h:501
bool isStrPrefixof() const
Definition dag.h:776
bool isAcot() const
Definition dag.h:532
bool isDivInt() const
Definition dag.h:494
bool isCot() const
Definition dag.h:526
bool isRegInter() const
Definition dag.h:854
bool isCInt() const
Definition dag.h:353
bool isBVComp() const
Definition dag.h:622
bool isStrSplitRest() const
Definition dag.h:790
bool isImplies() const
Definition dag.h:467
bool isNaN() const
Definition dag.h:598
bool isStrCharat() const
Definition dag.h:779
bool isFPIsNormal() const
Definition dag.h:751
bool isStrSplitAtRe() const
Definition dag.h:796
void setValue(const Interval &v)
Definition dag.h:963
bool isLb() const
Definition dag.h:519
bool isStrInReg() const
Definition dag.h:830
bool isStrToInt() const
Definition dag.h:839
bool isFPToUBV() const
Definition dag.h:737
std::string toString() const
Definition dag.h:907
bool isBVTerm() const
Definition dag.h:675
bool isUnknown() const
Definition dag.h:328
bool isBVUDiv() const
Definition dag.h:628
bool isBVSDiv() const
Definition dag.h:630
bool isStrSplitRestRe() const
Definition dag.h:799
bool isBVToNat() const
Definition dag.h:691
std::string children_hash
Definition dag.h:83
bool isStrReplaceAll() const
Definition dag.h:782
bool isBVConv() const
Definition dag.h:697
std::size_t hashCode() const
Get the hash code of the node.
Definition dag.h:1068
bool isBVXor() const
Definition dag.h:618
bool isToReal() const
Definition dag.h:574
bool isDistinctBool() const
Definition dag.h:476
bool isBVConcat() const
Definition dag.h:650
bool isFPGe() const
Definition dag.h:729
bool isArithConv() const
Definition dag.h:576
bool isStore() const
Definition dag.h:767
bool isVReg() const
Definition dag.h:431
bool isNegInfinity() const
Definition dag.h:597
std::vector< std::shared_ptr< DAGNode > > getFuncParams() const
Get the parameters of the function.
Definition dag.h:1002
bool isRegAll() const
Definition dag.h:850
bool isFPIsInf() const
Definition dag.h:756
bool isFPNeg() const
Definition dag.h:707
bool isAsinh() const
Definition dag.h:539
std::shared_ptr< DAGNode > getFuncBody() const
Get the body of the function.
Definition dag.h:995
bool isSqrt() const
Definition dag.h:511
bool isFPIsNaN() const
Definition dag.h:757
bool isBVSgt() const
Definition dag.h:673
bool isSinh() const
Definition dag.h:533
bool isBVOp() const
Definition dag.h:657
bool isFuncDec() const
Definition dag.h:882
bool isVar() const
Definition dag.h:440
bool isAdd() const
Definition dag.h:490
bool isStrSubstr() const
Definition dag.h:775
size_t getFuncParamsSize() const
Get the number of parameters of the function.
Definition dag.h:1015
bool isInternal() const
Definition dag.h:319
std::vector< std::shared_ptr< DAGNode > > children
Definition dag.h:81
bool isStrConv() const
Definition dag.h:843
bool isGt() const
Definition dag.h:559
bool isFPMax() const
Definition dag.h:718
bool isAtan2() const
Definition dag.h:545
bool isFPIsPos() const
Definition dag.h:759
bool isStrFromInt() const
Definition dag.h:838
bool isBVCompOp() const
Definition dag.h:682
bool isRegUnion() const
Definition dag.h:853
bool isVBool() const
Definition dag.h:373
bool isBVUle() const
Definition dag.h:668
bool isMin() const
Definition dag.h:452
bool isDivReal() const
Definition dag.h:495
bool isStrOp() const
Definition dag.h:805
bool isRegStar() const
Definition dag.h:856
bool isStrToUpper() const
Definition dag.h:786
bool isLe() const
Definition dag.h:556
bool isLog() const
Definition dag.h:517
bool isCsch() const
Definition dag.h:537
bool isToFP() const
Definition dag.h:740
bool isRegDiff() const
Definition dag.h:855
bool isTrue() const
Definition dag.h:336
bool isBVRotRight() const
Definition dag.h:656
bool isCReal() const
Definition dag.h:356
bool isFPSub() const
Definition dag.h:703
bool isCBool() const
Definition dag.h:331
bool isGe() const
Definition dag.h:558
bool isStrIndexof() const
Definition dag.h:778
bool isRegNone() const
Definition dag.h:849
bool isAcsc() const
Definition dag.h:530
bool isFalse() const
Definition dag.h:339
bool isFPComp() const
Definition dag.h:732
bool isStrUpdate() const
Definition dag.h:780
bool isUFName() const
Definition dag.h:448
bool isBVSignExt() const
Definition dag.h:654
bool isBVSRem() const
Definition dag.h:631
bool isLn() const
Definition dag.h:518
bool isBVUDivO() const
Definition dag.h:640
bool isErr() const
Definition dag.h:325
bool isVUF() const
Definition dag.h:445
bool isBVSMulO() const
Definition dag.h:639
bool isFPDiv() const
Definition dag.h:705
bool isCBV() const
Definition dag.h:359
bool isFPRoToInt() const
Definition dag.h:714
bool isBVNeg() const
Definition dag.h:624
bool isFact() const
Definition dag.h:613
bool isBvAtom() const
Definition dag.h:688
bool isStrToLower() const
Definition dag.h:785
void updateFuncDef(std::shared_ptr< Sort > out_sort, std::shared_ptr< DAGNode > body, const std::vector< std::shared_ptr< DAGNode > > &params, bool is_rec=false)
Update the function definition.
Definition dag.cpp:43
bool isLet() const
Definition dag.h:872
bool isBVURem() const
Definition dag.h:629
bool isFPProp() const
Definition dag.h:760
bool isFPFMA() const
Definition dag.h:709
bool isLeaf() const
Definition dag.h:318
DAGNode(std::shared_ptr< Sort > sort, NODE_KIND kind, std::string name)
Definition dag.h:118
bool isFPConv() const
Definition dag.h:745
bool isAsech() const
Definition dag.h:542
std::shared_ptr< Value > value
Definition dag.h:80
bool isCoth() const
Definition dag.h:538
bool isCFP() const
Definition dag.h:360
bool isNegEpsilon() const
Definition dag.h:605
bool isMax() const
Definition dag.h:451
bool isVFP() const
Definition dag.h:404
bool isVStr() const
Definition dag.h:418
DAGNode(NODE_KIND kind, std::string name)
Definition dag.h:165
bool isBVAdd() const
Definition dag.h:625
bool isFuncRec() const
Definition dag.h:884
bool isBVOr() const
Definition dag.h:617
bool isEquivalentTo(const std::shared_ptr< DAGNode > &other) const
Check if the node is equivalent to another node.
Definition dag.h:1045
bool isStrToReg() const
Definition dag.h:840
bool isAcos() const
Definition dag.h:528
DAGNode(std::shared_ptr< Sort > sort, const bool &v)
Definition dag.h:224
bool isStrLt() const
Definition dag.h:816
void setName(const std::string &n)
Definition dag.h:316
bool isDtFunApplication() const
Definition dag.h:887
bool isRegPlus() const
Definition dag.h:857
bool isTempVar() const
Definition dag.h:425
bool isStrIsDigit() const
Definition dag.h:832
std::string getName() const
Get the name of the node.
Definition dag.h:921
bool isFPSqrt() const
Definition dag.h:710
bool isStrNumSplitsRe() const
Definition dag.h:802
bool isFPRoundToIntegral() const
Definition dag.h:711
size_t getChildrenSize() const
Get the number of children of the node.
Definition dag.h:970
bool isAtom() const
Definition dag.h:866
bool isFPIsZero() const
Definition dag.h:755
bool isBVSle() const
Definition dag.h:672
bool isRegRange() const
Definition dag.h:859
DAGNode(std::shared_ptr< Sort > sort)
Definition dag.h:146
bool isNull() const
Definition dag.h:322
bool isBVExtract() const
Definition dag.h:651
void updateApplyFunc(std::shared_ptr< Sort > out_sort, std::shared_ptr< DAGNode > body, const std::vector< std::shared_ptr< DAGNode > > &params, bool is_rec=false)
Update the function application.
Definition dag.cpp:57
bool isBVNegO() const
Definition dag.h:635
bool isAtan() const
Definition dag.h:531
bool isCeil() const
Definition dag.h:498
bool isArithProp() const
Definition dag.h:584
bool isDistinct() const
Definition dag.h:480
bool isFloor() const
Definition dag.h:499
bool isQuantVar() const
Definition dag.h:426
bool isEq() const
Definition dag.h:473
bool isLetBindVar() const
Definition dag.h:427
bool isBVSModO() const
Definition dag.h:645
bool isBVSlt() const
Definition dag.h:671
bool isArithTerm() const
Definition dag.h:560
std::shared_ptr< Sort > getSort() const
Get the sort of the node.
Definition dag.h:915
bool isVInt() const
Definition dag.h:383
bool isFPOp() const
Definition dag.h:719
bool isFPLe() const
Definition dag.h:727
bool isGcd() const
Definition dag.h:611
bool isArray() const
Definition dag.h:455
bool isStrLe() const
Definition dag.h:817
std::string getPureName() const
Definition dag.h:900
bool isStrLen() const
Definition dag.h:773
bool isAsec() const
Definition dag.h:529
bool isNot() const
Definition dag.h:466
bool isVBV() const
Definition dag.h:397
bool isNeg() const
Definition dag.h:493
bool isSBVToInt() const
Definition dag.h:695
bool isStrGe() const
Definition dag.h:819
bool isCStr() const
Definition dag.h:362
bool isEven() const
Definition dag.h:582
bool isEquivalentTo(const DAGNode &other, std::unordered_set< std::pair< const DAGNode *, const DAGNode * >, PairNodePtrHash, PairNodePtrEqual > &visited) const
Definition dag.h:1127
bool isCosh() const
Definition dag.h:534
bool isLetBindVarList() const
Definition dag.h:874
void setValue(const Integer &v)
Definition dag.h:955
bool isStrSuffixof() const
Definition dag.h:777
std::string rename(const std::string &new_name)
Get the re-named name of the node.
Definition dag.h:928
bool isFPLt() const
Definition dag.h:728
bool isAtanh() const
Definition dag.h:541
bool isBVUModO() const
Definition dag.h:644
bool isBVToInt() const
Definition dag.h:693
std::shared_ptr< Value > getValue() const
Get the value of the node.
Definition dag.h:946
bool isUFApplication() const
Definition dag.h:487
void setValue(const double &v)
Definition dag.h:959
NODE_KIND getKind() const
Get the kind of the node.
Definition dag.h:939
bool isRealNonlinearOp() const
Definition dag.h:513
bool isDistinctOther() const
Definition dag.h:477
bool isFPAbs() const
Definition dag.h:706
bool isStrConcat() const
Definition dag.h:774
bool isRegLoop() const
Definition dag.h:861
bool isVRoundingMode() const
Definition dag.h:411
bool isArrayOp() const
Definition dag.h:768
void replace_children(const std::vector< std::shared_ptr< DAGNode > > &new_children)
Definition dag.h:312
bool isStrComp() const
Definition dag.h:825
bool isBVSRemO() const
Definition dag.h:643
bool isRegOpt() const
Definition dag.h:858
bool isBVUMulO() const
Definition dag.h:638
bool isBVLSHR() const
Definition dag.h:648
bool isBVZeroExt() const
Definition dag.h:653
DAGNode(std::shared_ptr< Sort > sort, NODE_KIND kind, std::string name, std::vector< std::shared_ptr< DAGNode > > children)
Definition dag.h:89
std::shared_ptr< DAGNode > getQuantBody() const
Get the body of the quantifier.
Definition dag.h:1023
bool isNumeral() const
Definition dag.h:352
DAGNode(NODE_KIND kind)
Definition dag.h:181
bool isRegConcat() const
Definition dag.h:852
std::shared_ptr< DAGNode > getChild(int i) const
Get the child of the node.
Definition dag.h:987
bool isBVUge() const
Definition dag.h:670
bool isBVMul() const
Definition dag.h:627
bool isAttribute() const
Definition dag.h:363
bool isPow() const
Definition dag.h:510
bool isFPRem() const
Definition dag.h:708
bool isCRoundingMode() const
Definition dag.h:361
bool isFPMin() const
Definition dag.h:717
bool isArithComp() const
Definition dag.h:567
bool isPosEpsilon() const
Definition dag.h:604
bool isMul() const
Definition dag.h:492
size_t getUseCount() const
Definition dag.h:895
bool isSelect() const
Definition dag.h:766
bool isStrGt() const
Definition dag.h:818
std::vector< std::shared_ptr< DAGNode > > getQuantVars() const
Get the variables of the quantifier.
Definition dag.h:1030
bool isLiteral() const
Definition dag.h:380
DAGNode(std::shared_ptr< Sort > sort, const double &v)
Definition dag.h:208
bool isFuncParam() const
Definition dag.h:885
bool operator==(const DAGNode elem)
Definition dag.h:302
bool isEqOther() const
Definition dag.h:472
bool isBVSge() const
Definition dag.h:674
bool isEpsilon() const
Definition dag.h:599
bool isLcm() const
Definition dag.h:612
bool isConstArray() const
Definition dag.h:461
bool isBVSMod() const
Definition dag.h:633
bool isDivisible() const
Definition dag.h:580
bool isLt() const
Definition dag.h:557
bool isExp() const
Definition dag.h:516
bool isFuncApplication() const
Definition dag.h:886
bool isStrSplit() const
Definition dag.h:788
bool isIte() const
Definition dag.h:879
bool isAbs() const
Definition dag.h:497
bool isTranscendentalOp() const
Definition dag.h:546
bool isStrSplitAt() const
Definition dag.h:789
void setValue(const Real &v)
Definition dag.h:957
DAGNode(std::shared_ptr< Sort > sort, const int &v)
Definition dag.h:216
bool operator!=(const DAGNode elem)
Definition dag.h:306
bool isSafeSqrt() const
Definition dag.h:512
bool isBVNor() const
Definition dag.h:620
bool isStrReplace() const
Definition dag.h:781
DAGNode(const DAGNode &other)
Definition dag.h:161
bool isBVAnd() const
Definition dag.h:616
bool isFPIsNeg() const
Definition dag.h:758
bool isConst() const
Definition dag.h:342
bool isBVNot() const
Definition dag.h:615
bool isFPMul() const
Definition dag.h:704
bool isStrToCode() const
Definition dag.h:841
bool isBVUAddO() const
Definition dag.h:636
bool isNeq() const
Definition dag.h:484
bool isFPToReal() const
Definition dag.h:739
bool isTanh() const
Definition dag.h:535
bool isOdd() const
Definition dag.h:583
bool isStrNumSplits() const
Definition dag.h:793
bool isFPIsSubnormal() const
Definition dag.h:752
bool isEquivalentTo(const DAGNode &other) const
Check if the node is equivalent to another node.
Definition dag.h:1055
bool isVReal() const
Definition dag.h:390
bool isToInt() const
Definition dag.h:575
bool isPosInfinity() const
Definition dag.h:596
bool isAcoth() const
Definition dag.h:544
bool isBVUMod() const
Definition dag.h:632
bool isNatToBV() const
Definition dag.h:692
bool isFuncRecApplication() const
Definition dag.h:890
bool isPow2() const
Definition dag.h:509
bool isPrime() const
Definition dag.h:581
bool isBVUgt() const
Definition dag.h:669
bool isMod() const
Definition dag.h:496
DAGNode(std::shared_ptr< Sort > sort, const Real &v)
Definition dag.h:200
bool isCos() const
Definition dag.h:522
bool isAttributeParam() const
Definition dag.h:367
bool isStrFromCode() const
Definition dag.h:842
bool isBVSDivO() const
Definition dag.h:641
void setValue(const int &v)
Definition dag.h:961
bool isOr() const
Definition dag.h:465
bool isBVSAddO() const
Definition dag.h:637
bool isPlaceholderVar() const
Definition dag.h:428
bool isIAnd() const
Definition dag.h:508
bool isAnd() const
Definition dag.h:464
DAGNode(const std::string &n)
Definition dag.h:234
bool isFuncDef() const
Definition dag.h:883
bool isFPEq() const
Definition dag.h:731
bool isBVURemO() const
Definition dag.h:642
bool isBVRepeat() const
Definition dag.h:652
bool isUBVToInt() const
Definition dag.h:694
bool isSin() const
Definition dag.h:521
bool isRound() const
Definition dag.h:500
bool isAcsch() const
Definition dag.h:543
bool isEqBool() const
Definition dag.h:471
DAGNode(std::shared_ptr< Sort > sort, const Integer &v)
Definition dag.h:192
std::shared_ptr< Sort > sort
Definition dag.h:77
bool isFPToSBV() const
Definition dag.h:738
bool isBVShl() const
Definition dag.h:647
bool isPi() const
Definition dag.h:589
DAGNode(std::shared_ptr< Sort > sort, NODE_KIND kind)
Definition dag.h:135
bool isFPGt() const
Definition dag.h:730
bool isRegRepeat() const
Definition dag.h:860
bool isStrRev() const
Definition dag.h:787
bool isAsin() const
Definition dag.h:527
void setValue(std::shared_ptr< Value > v)
Set the value of the node.
Definition dag.h:953
bool isSub() const
Definition dag.h:491
std::string toString(int base=10) const
Definition number.cpp:1026
static std::shared_ptr< DAGNode > getNaN()
Definition dag.h:1249
static std::shared_ptr< DAGNode > getRealPosInf()
Definition dag.h:1262
static const std::shared_ptr< DAGNode > E_NODE
Definition dag.h:1279
static std::shared_ptr< DAGNode > getFalse()
Definition dag.h:1246
static const std::shared_ptr< DAGNode > INT_INF_NODE
Definition dag.h:1315
static const std::shared_ptr< DAGNode > STR_NEG_INF_NODE
Definition dag.h:1311
std::shared_ptr< DAGNode > createNode()
Definition dag.cpp:1233
size_t getIndex(const std::shared_ptr< DAGNode > &node) const
Definition dag.cpp:1083
static std::shared_ptr< DAGNode > getIntNegInf()
Definition dag.h:1260
static const std::shared_ptr< DAGNode > POS_EPSILON_NODE
Definition dag.h:1295
std::array< std::unordered_map< size_t, std::vector< std::pair< std::shared_ptr< DAGNode >, size_t > > >, NUM_KINDS > node_buckets
Definition dag.h:1206
static const std::shared_ptr< DAGNode > PI_NODE
Definition dag.h:1281
static const std::shared_ptr< DAGNode > UNKNOWN_NODE
Definition dag.h:1269
static const std::shared_ptr< DAGNode > NAN_NODE
Definition dag.h:1291
static const std::shared_ptr< DAGNode > REAL_INF_NODE
Definition dag.h:1325
static const std::shared_ptr< DAGNode > STR_POS_INF_NODE
Definition dag.h:1307
std::vector< std::shared_ptr< DAGNode > > nodes
Definition dag.h:1199
static const std::shared_ptr< DAGNode > ERROR_NODE
Definition dag.h:1273
static std::shared_ptr< DAGNode > getNegEpsilon()
Definition dag.h:1252
static std::shared_ptr< DAGNode > getUnknown()
Definition dag.h:1244
static std::shared_ptr< DAGNode > getEpsilon()
Definition dag.h:1250
std::shared_ptr< DAGNode > getNode(const size_t index) const
Definition dag.cpp:1080
static std::shared_ptr< DAGNode > getStrInf()
Definition dag.h:1255
static std::shared_ptr< DAGNode > getIntInf()
Definition dag.h:1258
static const std::shared_ptr< DAGNode > REAL_NEG_INF_NODE
Definition dag.h:1331
static const std::shared_ptr< DAGNode > NEG_EPSILON_NODE
Definition dag.h:1299
static const std::shared_ptr< DAGNode > REAL_POS_INF_NODE
Definition dag.h:1327
static std::shared_ptr< DAGNode > getRealInf()
Definition dag.h:1261
static const std::shared_ptr< DAGNode > TRUE_NODE
Definition dag.h:1275
static std::shared_ptr< DAGNode > getNull()
Definition dag.h:1243
static std::shared_ptr< DAGNode > getIntPosInf()
Definition dag.h:1259
static const std::shared_ptr< DAGNode > STR_INF_NODE
Definition dag.h:1305
static const std::shared_ptr< DAGNode > NULL_NODE
Definition dag.h:1267
static std::shared_ptr< DAGNode > getPi()
Definition dag.h:1248
static std::shared_ptr< DAGNode > getPosEpsilon()
Definition dag.h:1251
static const std::shared_ptr< DAGNode > INT_POS_INF_NODE
Definition dag.h:1317
static const std::shared_ptr< DAGNode > INT_NEG_INF_NODE
Definition dag.h:1321
static std::shared_ptr< DAGNode > getStrNegInf()
Definition dag.h:1257
static std::shared_ptr< DAGNode > getE()
Definition dag.h:1247
static const std::shared_ptr< DAGNode > EPSILON_NODE
Definition dag.h:1293
static const std::shared_ptr< DAGNode > FALSE_NODE
Definition dag.h:1277
std::shared_ptr< DAGNode > insertNodeToBucket(const std::shared_ptr< DAGNode > &node)
Definition dag.cpp:1114
static std::shared_ptr< DAGNode > getTrue()
Definition dag.h:1245
static std::shared_ptr< DAGNode > getRealNegInf()
Definition dag.h:1263
static std::shared_ptr< DAGNode > getStrPosInf()
Definition dag.h:1256
static const std::shared_ptr< Sort > STR_SORT
Definition sort.h:398
static const std::shared_ptr< Sort > INT_SORT
Definition sort.h:390
static const std::shared_ptr< Sort > BOOL_SORT
Definition sort.h:388
static const std::shared_ptr< Sort > REAL_SORT
Definition sort.h:392
static const std::shared_ptr< Sort > UNKNOWN_SORT
Definition sort.h:386
static const std::shared_ptr< Sort > EXT_SORT
Definition sort.h:402
static const std::shared_ptr< Sort > NULL_SORT
Definition sort.h:384
static bool isReal(const std::string &str)
Definition util.cpp:58
static bool isString(const std::string &str)
Definition util.cpp:259
static bool isInt(const std::string &str)
Definition util.cpp:47
const std::string PRESERVING_LET_BIND_VAR_SUFFIX
Definition kind.h:370
std::string dumpFuncDef(const std::shared_ptr< DAGNode > &node)
Definition dag.cpp:1009
std::string dumpSMTLIB2(const std::shared_ptr< DAGNode > &root)
Definition dag.cpp:1003
std::string dumpFuncDec(const std::shared_ptr< DAGNode > &node)
Definition dag.cpp:1043
constexpr size_t NUM_KINDS
Definition kind.h:366
std::string dumpFuncRec(const std::shared_ptr< DAGNode > &node)
Definition dag.cpp:1026
std::shared_ptr< DAGNode > NodePtr
Definition dag.h:1195
std::shared_ptr< Value > newValue(const std::string &string_value)
Definition value.cpp:168
bool operator()(const std::shared_ptr< DAGNode > &node1, const std::shared_ptr< DAGNode > &node2) const
Definition dag.h:1178
size_t operator()(const std::shared_ptr< DAGNode > &node) const
Definition dag.h:1172
bool operator()(const std::pair< const DAGNode *, const DAGNode * > &p1, const std::pair< const DAGNode *, const DAGNode * > &p2) const
Definition dag.h:68
size_t operator()(const std::pair< const DAGNode *, const DAGNode * > &p) const
Definition dag.h:61