Skip to content

Commit 2b64933

Browse files
committed
tame exponential explosion in AndExpr
uncommon, but exists in some unit tests
1 parent 9d64ac0 commit 2b64933

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

smt/exprs.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,27 @@ using namespace std;
1111

1212
namespace smt {
1313

14-
void AndExpr::add(const expr &e) {
14+
void AndExpr::add(const expr &e, unsigned limit) {
1515
if (e.isTrue())
1616
return;
1717

1818
expr a, b;
19-
if (e.isAnd(a, b)) {
20-
add(move(a));
21-
add(move(b));
19+
if (limit > 0 && e.isAnd(a, b)) {
20+
add(move(a), limit-1);
21+
add(move(b), limit-1);
2222
return;
2323
}
2424
exprs.insert(e);
2525
}
2626

27-
void AndExpr::add(expr &&e) {
27+
void AndExpr::add(expr &&e, unsigned limit) {
2828
if (e.isTrue())
2929
return;
3030

3131
expr a, b;
32-
if (e.isAnd(a, b)) {
33-
add(move(a));
34-
add(move(b));
32+
if (limit > 0 && e.isAnd(a, b)) {
33+
add(move(a), limit-1);
34+
add(move(b), limit-1);
3535
return;
3636
}
3737
exprs.insert(move(e));

smt/exprs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ class AndExpr {
2424
template <typename T>
2525
AndExpr(T &&e) { add(std::forward<T>(e)); }
2626

27-
void add(const expr &e);
28-
void add(expr &&e);
27+
void add(const expr &e, unsigned limit = 16);
28+
void add(expr &&e, unsigned limit = 16);
2929
void add(const AndExpr &other);
3030
void del(const AndExpr &other);
3131
void reset();

0 commit comments

Comments
 (0)