Skip to content

Commit decd69a

Browse files
move to util
Signed-off-by: Nikolaj Bjorner <[email protected]>
1 parent 6d4bd37 commit decd69a

File tree

3 files changed

+32
-34
lines changed

3 files changed

+32
-34
lines changed

src/ast/ast_util.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Revision History:
1717
1818
--*/
1919
#include "ast/ast_util.h"
20+
#include "ast/ast_pp.h"
21+
#include "ast/for_each_expr.h"
2022
#include "ast/arith_decl_plugin.h"
2123

2224
app * mk_list_assoc_app(ast_manager & m, func_decl * f, unsigned num_args, expr * const * args) {
@@ -372,3 +374,22 @@ static app_ref plus(ast_manager& m, expr* a, expr* b) {
372374
app_ref operator+(expr_ref& a, expr_ref& b) {
373375
return plus(a.m(), a.get(), b.get());
374376
}
377+
378+
bool has_uninterpreted(ast_manager& m, expr* _e) {
379+
expr_ref e(_e, m);
380+
arith_util au(m);
381+
func_decl_ref f_out(m);
382+
for (expr* arg : subterms(e)) {
383+
if (!is_app(arg))
384+
continue;
385+
app* a = to_app(arg);
386+
func_decl* f = a->get_decl();
387+
if (a->get_num_args() == 0)
388+
continue;
389+
if (m.is_considered_uninterpreted(f))
390+
return true;
391+
if (au.is_considered_uninterpreted(f, a->get_num_args(), a->get_args(), f_out))
392+
return true;
393+
}
394+
return false;
395+
}

src/ast/ast_util.h

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,14 @@ inline bool depth_leq_one(app * n) {
6767

6868
template<typename AST>
6969
void dec_ref(ast_manager & m, obj_hashtable<AST> & s) {
70-
typename obj_hashtable<AST>::iterator it = s.begin();
71-
typename obj_hashtable<AST>::iterator end = s.end();
72-
for (;it != end; ++it) {
73-
m.dec_ref(*it);
74-
}
70+
for (auto a : s)
71+
m.dec_ref(a);
7572
}
7673

7774
template<typename AST>
7875
void inc_ref(ast_manager & m, obj_hashtable<AST> & s) {
79-
typename obj_hashtable<AST>::iterator it = s.begin();
80-
typename obj_hashtable<AST>::iterator end = s.end();
81-
for (;it != end; ++it) {
82-
m.inc_ref(*it);
83-
}
76+
for (auto a : s)
77+
m.inc_ref(a);
8478
}
8579

8680
// -----------------------------------
@@ -174,5 +168,6 @@ void flatten_or(expr_ref_vector& result);
174168

175169
void flatten_or(expr* fml, expr_ref_vector& result);
176170

171+
bool has_uninterpreted(ast_manager& m, expr* e);
177172

178173
#endif /* AST_UTIL_H_ */

src/qe/qe.cpp

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -929,10 +929,9 @@ namespace qe {
929929
CHECK_COND(m_children.empty() || fml());
930930
CHECK_COND(!is_root() || fml());
931931
CHECK_COND(!fml() || has_var() || m_num_branches.is_zero() || is_unit());
932-
branch_map::iterator it = m_branch_index.begin(), end = m_branch_index.end();
933-
for (; it != end; ++it) {
934-
CHECK_COND(it->m_value < m_children.size());
935-
CHECK_COND(it->m_key < get_num_branches());
932+
for (auto const & kv : m_branch_index) {
933+
CHECK_COND(kv.m_value < m_children.size());
934+
CHECK_COND(kv.m_key < get_num_branches());
936935
}
937936
for (unsigned i = 0; i < m_children.size(); ++i) {
938937
CHECK_COND(m_children[i]);
@@ -1388,9 +1387,8 @@ namespace qe {
13881387
void reset() {
13891388
m_free_vars.reset();
13901389
m_trail.reset();
1391-
obj_map<app, contains_app*>::iterator it = m_var2contains.begin(), end = m_var2contains.end();
1392-
for (; it != end; ++it) {
1393-
dealloc(it->m_value);
1390+
for (auto & kv : m_var2contains) {
1391+
dealloc(kv.m_value);
13941392
}
13951393
m_var2contains.reset();
13961394
m_var2branch.reset();
@@ -1406,22 +1404,6 @@ namespace qe {
14061404
m_conjs.add_plugin(p);
14071405
}
14081406

1409-
bool has_uninterpreted(expr* _e) {
1410-
expr_ref e(_e, m);
1411-
arith_util au(m);
1412-
func_decl_ref f_out(m);
1413-
for (expr* arg : subterms(e)) {
1414-
if (!is_app(arg)) continue;
1415-
app* a = to_app(arg);
1416-
func_decl* f = a->get_decl();
1417-
if (m.is_considered_uninterpreted(f))
1418-
return true;
1419-
if (au.is_considered_uninterpreted(f, a->get_num_args(), a->get_args(), f_out))
1420-
return true;
1421-
}
1422-
return false;
1423-
}
1424-
14251407
void check(unsigned num_vars, app* const* vars,
14261408
expr* assumption, expr_ref& fml, bool get_first,
14271409
app_ref_vector& free_vars, guarded_defs* defs) {
@@ -1462,7 +1444,7 @@ namespace qe {
14621444
lbool res = l_true;
14631445
while (res == l_true) {
14641446
res = m_solver.check();
1465-
if (res == l_true && has_uninterpreted(m_fml))
1447+
if (res == l_true && has_uninterpreted(m, m_fml))
14661448
res = l_undef;
14671449
if (res == l_true) {
14681450
is_sat = true;

0 commit comments

Comments
 (0)