From d3805bbdf6da7c9c9ec5b07ca086c01e56d1a6ca Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Mon, 15 Feb 2016 17:29:46 -0800 Subject: [PATCH 1/3] fix location of level retrieval Signed-off-by: Nikolaj Bjorner --- src/tactic/bv/bv_bounds_tactic.cpp | 3 +++ src/tactic/core/ctx_simplify_tactic.cpp | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/tactic/bv/bv_bounds_tactic.cpp b/src/tactic/bv/bv_bounds_tactic.cpp index 73a856cb9..10f050166 100644 --- a/src/tactic/bv/bv_bounds_tactic.cpp +++ b/src/tactic/bv/bv_bounds_tactic.cpp @@ -110,6 +110,9 @@ public: bool lo, s; expr* t1; rational n; + if (!shared(t)) { + return; + } if (is_bound(t, t1, lo, s, n)) { if (sign) { // !(n <= t1) <=> t1 <= n - 1 diff --git a/src/tactic/core/ctx_simplify_tactic.cpp b/src/tactic/core/ctx_simplify_tactic.cpp index c61f2d3af..739c0d19e 100644 --- a/src/tactic/core/ctx_simplify_tactic.cpp +++ b/src/tactic/core/ctx_simplify_tactic.cpp @@ -202,8 +202,8 @@ struct ctx_simplify_tactic::imp { } void cache_core(expr * from, expr * to) { - TRACE("ctx_simplify_tactic_cache", tout << "caching\n" << mk_ismt2_pp(from, m) << "\n--->\n" << mk_ismt2_pp(to, m) << "\n";); unsigned id = from->get_id(); + TRACE("ctx_simplify_tactic_cache", tout << "caching " << id << " @ " << scope_level() << "\n" << mk_ismt2_pp(from, m) << "\n--->\n" << mk_ismt2_pp(to, m) << "\n";); m_cache.reserve(id+1); cache_cell & cell = m_cache[id]; void * mem = m_allocator.allocate(sizeof(cached_result)); @@ -270,11 +270,11 @@ struct ctx_simplify_tactic::imp { if (num_scopes == 0) return; SASSERT(num_scopes <= scope_level()); - + + unsigned lvl = scope_level(); m_simp->pop(num_scopes); // restore cache - unsigned lvl = scope_level(); for (unsigned i = 0; i < num_scopes; i++) { restore_cache(lvl); lvl--; From 98c5a5c86c0f137a02afbce2399583a84d3cb3d0 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Tue, 16 Feb 2016 09:34:45 +0000 Subject: [PATCH 2/3] move ctx_propagate_assertions class to .cpp file --- src/tactic/core/ctx_simplify_tactic.cpp | 25 +++++++++++++++++++++++++ src/tactic/core/ctx_simplify_tactic.h | 25 +------------------------ 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/tactic/core/ctx_simplify_tactic.cpp b/src/tactic/core/ctx_simplify_tactic.cpp index efaae3c40..95be200a8 100644 --- a/src/tactic/core/ctx_simplify_tactic.cpp +++ b/src/tactic/core/ctx_simplify_tactic.cpp @@ -22,6 +22,27 @@ Notes: #include"ast_ll_pp.h" #include"ast_pp.h" + +class ctx_propagate_assertions : public ctx_simplify_tactic::simplifier { + ast_manager& m; + obj_map m_assertions; + expr_ref_vector m_trail; + unsigned_vector m_scopes; + + void assert_eq_val(expr * t, app * val, bool mk_scope); + void assert_eq_core(expr * t, app * val); +public: + ctx_propagate_assertions(ast_manager& m); + virtual ~ctx_propagate_assertions() {} + virtual void assert_expr(expr * t, bool sign); + virtual bool simplify(expr* t, expr_ref& result); + virtual void push(); + virtual void pop(unsigned num_scopes); + virtual unsigned scope_level() const { return m_scopes.size(); } + virtual simplifier * translate(ast_manager & m); +}; + + ctx_propagate_assertions::ctx_propagate_assertions(ast_manager& m): m(m), m_trail(m) {} void ctx_propagate_assertions::assert_expr(expr * t, bool sign) { @@ -106,6 +127,10 @@ ctx_simplify_tactic::simplifier * ctx_propagate_assertions::translate(ast_manage return alloc(ctx_propagate_assertions, m); } +tactic * mk_ctx_simplify_tactic(ast_manager & m, params_ref const & p) { + return clean(alloc(ctx_simplify_tactic, m, alloc(ctx_propagate_assertions, m), p)); +} + struct ctx_simplify_tactic::imp { struct cached_result { diff --git a/src/tactic/core/ctx_simplify_tactic.h b/src/tactic/core/ctx_simplify_tactic.h index d72f54a83..fccb25d3b 100644 --- a/src/tactic/core/ctx_simplify_tactic.h +++ b/src/tactic/core/ctx_simplify_tactic.h @@ -65,30 +65,7 @@ public: virtual void cleanup(); }; - -class ctx_propagate_assertions : public ctx_simplify_tactic::simplifier { - ast_manager& m; - obj_map m_assertions; - expr_ref_vector m_trail; - unsigned_vector m_scopes; - - void assert_eq_val(expr * t, app * val, bool mk_scope); - void assert_eq_core(expr * t, app * val); -public: - ctx_propagate_assertions(ast_manager& m); - virtual ~ctx_propagate_assertions() {} - virtual void assert_expr(expr * t, bool sign); - virtual bool simplify(expr* t, expr_ref& result); - virtual void push(); - virtual void pop(unsigned num_scopes); - virtual unsigned scope_level() const { return m_scopes.size(); } - virtual simplifier * translate(ast_manager & m); -}; - - -inline tactic * mk_ctx_simplify_tactic(ast_manager & m, params_ref const & p = params_ref()) { - return clean(alloc(ctx_simplify_tactic, m, alloc(ctx_propagate_assertions, m), p)); -} +tactic * mk_ctx_simplify_tactic(ast_manager & m, params_ref const & p = params_ref()); /* ADD_TACTIC("ctx-simplify", "apply contextual simplification rules.", "mk_ctx_simplify_tactic(m, p)") From 293566d464f3d39edccbe0a13b9d013c7f0e4251 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Tue, 16 Feb 2016 09:53:04 +0000 Subject: [PATCH 3/3] ctx-simplify: simplify destructor --- src/tactic/core/ctx_simplify_tactic.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/tactic/core/ctx_simplify_tactic.cpp b/src/tactic/core/ctx_simplify_tactic.cpp index 95be200a8..894aea117 100644 --- a/src/tactic/core/ctx_simplify_tactic.cpp +++ b/src/tactic/core/ctx_simplify_tactic.cpp @@ -177,8 +177,7 @@ struct ctx_simplify_tactic::imp { ~imp() { pop(scope_level()); - SASSERT(scope_level() == 0); - restore_cache(0); + SASSERT(scope_level() == 0 && m_cache_undo.empty()); DEBUG_CODE({ for (unsigned i = 0; i < m_cache.size(); i++) { CTRACE("ctx_simplify_tactic_bug", m_cache[i].m_from,