Skip to content

Commit c424165

Browse files
block deep based on condition for internalization #4192
Signed-off-by: Nikolaj Bjorner <[email protected]>
1 parent 7d4c9e6 commit c424165

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/smt/smt_context.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,8 @@ namespace smt {
739739
char_vector tcolors;
740740
char_vector fcolors;
741741

742+
bool should_internalize_rec(expr* e) const;
743+
742744
void top_sort_expr(expr * n, svector<expr_bool_pair> & sorted_exprs);
743745

744746
void assert_default(expr * n, proof * pr);

src/smt/smt_internalizer.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ namespace smt {
109109
bool context::ts_visit_children(expr * n, bool gate_ctx, svector<expr_bool_pair> & todo) {
110110
if (is_quantifier(n))
111111
return true;
112+
if (!should_internalize_rec(n))
113+
return true;
112114
SASSERT(is_app(n));
113115
if (m.is_bool(n)) {
114116
if (b_internalized(n))
@@ -181,8 +183,15 @@ namespace smt {
181183

182184
#define DEEP_EXPR_THRESHOLD 1024
183185

186+
bool context::should_internalize_rec(expr* e) const {
187+
return !is_app(e) ||
188+
!m.is_bool(e) ||
189+
to_app(e)->get_family_id() == null_family_id ||
190+
to_app(e)->get_family_id() == m.get_basic_family_id();
191+
}
192+
184193
void context::internalize_deep(expr* n) {
185-
if (!e_internalized(n) && ::get_depth(n) > DEEP_EXPR_THRESHOLD) {
194+
if (!e_internalized(n) && ::get_depth(n) > DEEP_EXPR_THRESHOLD && should_internalize_rec(n)) {
186195
// if the expression is deep, then execute topological sort to avoid
187196
// stack overflow.
188197
// a caveat is that theory internalizers do rely on recursive descent so
@@ -193,10 +202,7 @@ namespace smt {
193202
TRACE("deep_internalize", for (auto & kv : sorted_exprs) tout << "#" << kv.first->get_id() << " " << kv.second << "\n"; );
194203
for (auto & kv : sorted_exprs) {
195204
expr* e = kv.first;
196-
if (!is_app(e) ||
197-
!m.is_bool(e) ||
198-
to_app(e)->get_family_id() == null_family_id ||
199-
to_app(e)->get_family_id() == m.get_basic_family_id())
205+
if (should_internalize_rec(e))
200206
internalize_rec(e, kv.second);
201207
}
202208
}

0 commit comments

Comments
 (0)