From 026065ff71fe809cd9eaa656cbe6094c1e9537ed Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sun, 28 Feb 2021 12:32:04 -0800 Subject: [PATCH] streamline pb solver interface and naming after removal of xor --- src/sat/sat_lookahead.h | 6 +- src/sat/sat_simplifier.h | 6 +- src/sat/sat_solver.h | 6 +- src/sat/smt/CMakeLists.txt | 10 +- src/sat/smt/euf_solver.cpp | 4 +- src/sat/smt/{ba_card.cpp => pb_card.cpp} | 31 +- src/sat/smt/{ba_card.h => pb_card.h} | 23 +- .../{ba_constraint.cpp => pb_constraint.cpp} | 17 +- .../smt/{ba_constraint.h => pb_constraint.h} | 40 +- ...{ba_internalize.cpp => pb_internalize.cpp} | 70 +- src/sat/smt/{ba_pb.cpp => pb_pb.cpp} | 53 +- src/sat/smt/{ba_pb.h => pb_pb.h} | 14 +- src/sat/smt/{ba_solver.cpp => pb_solver.cpp} | 874 ++++++++---------- src/sat/smt/{ba_solver.h => pb_solver.h} | 147 ++- ...lver_interface.h => pb_solver_interface.h} | 4 +- src/sat/tactic/goal2sat.cpp | 8 +- src/smt/arith_eq_adapter.cpp | 22 +- src/smt/mam.cpp | 32 +- src/smt/qi_queue.cpp | 6 +- src/smt/seq_eq_solver.cpp | 4 +- src/smt/seq_offset_eq.cpp | 16 +- src/smt/seq_regex.cpp | 2 +- src/smt/smt_almost_cg_table.cpp | 2 +- src/smt/smt_arith_value.cpp | 2 +- src/smt/smt_cg_table.cpp | 4 +- src/smt/smt_checker.cpp | 2 +- src/smt/smt_conflict_resolution.cpp | 26 +- src/smt/smt_consequences.cpp | 2 +- src/smt/smt_context.cpp | 44 +- src/smt/smt_context.h | 8 +- src/smt/smt_context_inv.cpp | 24 +- src/smt/smt_context_pp.cpp | 14 +- src/smt/smt_enode.cpp | 2 +- src/smt/smt_enode.h | 3 +- src/smt/smt_induction.cpp | 22 +- src/smt/smt_induction.h | 2 +- src/smt/smt_justification.cpp | 12 +- src/smt/smt_model_checker.cpp | 2 +- src/smt/smt_model_finder.cpp | 24 +- src/smt/smt_model_generator.cpp | 24 +- src/smt/smt_quantifier.cpp | 2 +- src/smt/smt_quick_checker.cpp | 8 +- src/smt/smt_relevancy.cpp | 4 +- src/smt/smt_theory.h | 6 +- src/smt/theory_arith.h | 4 +- src/smt/theory_arith_aux.h | 26 +- src/smt/theory_arith_core.h | 28 +- src/smt/theory_arith_eq.h | 6 +- src/smt/theory_arith_int.h | 10 +- src/smt/theory_arith_nl.h | 2 +- src/smt/theory_arith_pp.h | 6 +- src/smt/theory_array.cpp | 18 +- src/smt/theory_array_bapa.cpp | 6 +- src/smt/theory_array_base.cpp | 52 +- src/smt/theory_array_base.h | 22 +- src/smt/theory_array_full.cpp | 52 +- src/smt/theory_bv.cpp | 22 +- src/smt/theory_bv.h | 6 +- src/smt/theory_datatype.cpp | 44 +- src/smt/theory_datatype.h | 8 +- src/smt/theory_dense_diff_logic_def.h | 26 +- src/smt/theory_diff_logic_def.h | 36 +- src/smt/theory_dl.cpp | 6 +- src/smt/theory_fpa.cpp | 52 +- src/smt/theory_lra.cpp | 62 +- src/smt/theory_pb.cpp | 2 +- src/smt/theory_recfun.h | 4 +- src/smt/theory_seq.cpp | 54 +- src/smt/theory_special_relations.cpp | 8 +- src/smt/theory_str.cpp | 110 +-- src/smt/theory_utvpi.h | 2 +- src/smt/theory_utvpi_def.h | 22 +- src/smt/theory_wmaxsat.cpp | 2 +- 73 files changed, 1131 insertions(+), 1201 deletions(-) rename src/sat/smt/{ba_card.cpp => pb_card.cpp} (90%) rename src/sat/smt/{ba_card.h => pb_card.h} (71%) rename src/sat/smt/{ba_constraint.cpp => pb_constraint.cpp} (76%) rename src/sat/smt/{ba_constraint.h => pb_constraint.h} (85%) rename src/sat/smt/{ba_internalize.cpp => pb_internalize.cpp} (77%) rename src/sat/smt/{ba_pb.cpp => pb_pb.cpp} (85%) rename src/sat/smt/{ba_pb.h => pb_pb.h} (87%) rename src/sat/smt/{ba_solver.cpp => pb_solver.cpp} (81%) rename src/sat/smt/{ba_solver.h => pb_solver.h} (75%) rename src/sat/smt/{ba_solver_interface.h => pb_solver_interface.h} (97%) diff --git a/src/sat/sat_lookahead.h b/src/sat/sat_lookahead.h index 4b11b5917..a50d3ed37 100644 --- a/src/sat/sat_lookahead.h +++ b/src/sat/sat_lookahead.h @@ -23,6 +23,10 @@ Notes: #include "util/small_object_allocator.h" #include "sat/sat_elim_eqs.h" +namespace pb { + class solver; +}; + namespace sat { struct pp_prefix { @@ -66,7 +70,7 @@ namespace sat { reslimit m_rlimit; friend class ccc; - friend class ba_solver; + friend class pb::solver; struct config { double m_dl_success; diff --git a/src/sat/sat_simplifier.h b/src/sat/sat_simplifier.h index 8c847a658..0b512275e 100644 --- a/src/sat/sat_simplifier.h +++ b/src/sat/sat_simplifier.h @@ -31,6 +31,10 @@ Revision History: #include "util/statistics.h" #include "util/params.h" +namespace pb { + class solver; +} + namespace sat { class solver; @@ -50,7 +54,7 @@ namespace sat { }; class simplifier { - friend class ba_solver; + friend class pb::solver; friend class elim_vars; solver & s; unsigned m_num_calls; diff --git a/src/sat/sat_solver.h b/src/sat/sat_solver.h index bae4f0bfa..cc06ad1b3 100644 --- a/src/sat/sat_solver.h +++ b/src/sat/sat_solver.h @@ -47,6 +47,10 @@ Revision History: #include "util/scoped_ptr_vector.h" #include "util/scoped_limit_trail.h" +namespace pb { + class solver; +}; + namespace sat { /** @@ -210,7 +214,7 @@ namespace sat { friend class probing; friend class simplifier; friend class scc; - friend class ba_solver; + friend class pb::solver; friend class anf_simplifier; friend class cut_simplifier; friend class parallel; diff --git a/src/sat/smt/CMakeLists.txt b/src/sat/smt/CMakeLists.txt index 9284af431..a53d80cc4 100644 --- a/src/sat/smt/CMakeLists.txt +++ b/src/sat/smt/CMakeLists.txt @@ -9,11 +9,6 @@ z3_add_component(sat_smt array_model.cpp array_solver.cpp atom2bool_var.cpp - ba_card.cpp - ba_constraint.cpp - ba_internalize.cpp - ba_pb.cpp - ba_solver.cpp bv_ackerman.cpp bv_delay_internalize.cpp bv_internalize.cpp @@ -28,6 +23,11 @@ z3_add_component(sat_smt euf_relevancy.cpp euf_solver.cpp fpa_solver.cpp + pb_card.cpp + pb_constraint.cpp + pb_internalize.cpp + pb_pb.cpp + pb_solver.cpp q_clause.cpp q_ematch.cpp q_eval.cpp diff --git a/src/sat/smt/euf_solver.cpp b/src/sat/smt/euf_solver.cpp index 1f2531d20..9a3eedcb8 100644 --- a/src/sat/smt/euf_solver.cpp +++ b/src/sat/smt/euf_solver.cpp @@ -19,7 +19,7 @@ Author: #include "ast/ast_ll_pp.h" #include "sat/sat_solver.h" #include "sat/smt/sat_smt.h" -#include "sat/smt/ba_solver.h" +#include "sat/smt/pb_solver.h" #include "sat/smt/bv_solver.h" #include "sat/smt/euf_solver.h" #include "sat/smt/array_solver.h" @@ -112,7 +112,7 @@ namespace euf { datatype_util dt(m); recfun::util rf(m); if (pb.get_family_id() == fid) - ext = alloc(sat::ba_solver, *this, fid); + ext = alloc(pb::solver, *this, fid); else if (bvu.get_family_id() == fid) ext = alloc(bv::solver, *this, fid); else if (au.get_family_id() == fid) diff --git a/src/sat/smt/ba_card.cpp b/src/sat/smt/pb_card.cpp similarity index 90% rename from src/sat/smt/ba_card.cpp rename to src/sat/smt/pb_card.cpp index 277a53fe3..7356c3e84 100644 --- a/src/sat/smt/ba_card.cpp +++ b/src/sat/smt/pb_card.cpp @@ -15,33 +15,14 @@ Author: --*/ -#include "sat/smt/ba_card.h" -#include "sat/smt/ba_solver.h" +#include "sat/smt/pb_card.h" +#include "sat/smt/pb_solver.h" #include "sat/sat_simplifier.h" -namespace ba { - - // ----------------------- - // pb_base - - bool pb_base::well_formed() const { - uint_set vars; - if (lit() != sat::null_literal) vars.insert(lit().var()); - for (unsigned i = 0; i < size(); ++i) { - bool_var v = get_lit(i).var(); - if (vars.contains(v)) return false; - if (get_coeff(i) > k()) return false; - vars.insert(v); - } - return true; - } - - - // ---------------------- - // card +namespace pb { card::card(unsigned id, literal lit, literal_vector const& lits, unsigned k) : - pb_base(tag_t::card_t, id, lit, lits.size(), get_obj_size(lits.size()), k) { + constraint(tag_t::card_t, id, lit, lits.size(), get_obj_size(lits.size()), k) { for (unsigned i = 0; i < size(); ++i) { m_lits[i] = lits[i]; } @@ -64,7 +45,7 @@ namespace ba { return false; } - double card::get_reward(ba::solver_interface const& s, sat::literal_occs_fun& literal_occs) const { + double card::get_reward(solver_interface const& s, sat::literal_occs_fun& literal_occs) const { unsigned k = this->k(), slack = 0; bool do_add = s.get_config().m_lookahead_reward == sat::heule_schur_reward; double to_add = do_add ? 0 : 1; @@ -262,7 +243,7 @@ namespace ba { lbool card::eval(sat::model const& m) const { unsigned trues = 0, undefs = 0; for (literal l : *this) { - switch (ba::value(m, l)) { + switch (pb::value(m, l)) { case l_true: trues++; break; case l_undef: undefs++; break; default: break; diff --git a/src/sat/smt/ba_card.h b/src/sat/smt/pb_card.h similarity index 71% rename from src/sat/smt/ba_card.h rename to src/sat/smt/pb_card.h index 98d0456f9..6df50d81c 100644 --- a/src/sat/smt/ba_card.h +++ b/src/sat/smt/pb_card.h @@ -18,27 +18,12 @@ Author: #pragma once #include "sat/sat_types.h" -#include "sat/smt/ba_constraint.h" +#include "sat/smt/pb_constraint.h" -namespace ba { +namespace pb { - // base class for pb and cardinality constraints - class pb_base : public constraint { - protected: - unsigned m_k; - public: - pb_base(ba::tag_t t, unsigned id, literal l, unsigned sz, size_t osz, unsigned k) : - constraint(t, id, l, sz, osz), m_k(k) { - VERIFY(k < 4000000000); - } - virtual void set_k(unsigned k) { VERIFY(k < 4000000000); m_k = k; } - virtual unsigned get_coeff(unsigned i) const { UNREACHABLE(); return 0; } - unsigned k() const { return m_k; } - bool well_formed() const override; - }; - - class card : public pb_base { + class card : public constraint { literal m_lits[0]; public: static size_t get_obj_size(unsigned num_lits) { return sat::constraint_base::obj_size(sizeof(card) + num_lits * sizeof(literal)); } @@ -54,7 +39,7 @@ namespace ba { literal get_lit(unsigned i) const override { return m_lits[i]; } void set_lit(unsigned i, literal l) override { m_lits[i] = l; } unsigned get_coeff(unsigned i) const override { return 1; } - double get_reward(ba::solver_interface const& s, sat::literal_occs_fun& occs) const override; + double get_reward(solver_interface const& s, sat::literal_occs_fun& occs) const override; std::ostream& display(std::ostream& out) const override; std::ostream& display(std::ostream& out, solver_interface const& s, bool values) const override; void clear_watch(solver_interface& s) override; diff --git a/src/sat/smt/ba_constraint.cpp b/src/sat/smt/pb_constraint.cpp similarity index 76% rename from src/sat/smt/ba_constraint.cpp rename to src/sat/smt/pb_constraint.cpp index a15039e45..0b1b9f4f0 100644 --- a/src/sat/smt/ba_constraint.cpp +++ b/src/sat/smt/pb_constraint.cpp @@ -15,9 +15,9 @@ Author: --*/ -#include "sat/smt/ba_constraint.h" +#include "sat/smt/pb_constraint.h" -namespace ba { +namespace pb { unsigned constraint::fold_max_var(unsigned w) const { if (lit() != sat::null_literal) w = std::max(w, lit().var()); @@ -55,4 +55,17 @@ namespace ba { } } + bool constraint::well_formed() const { + uint_set vars; + if (lit() != sat::null_literal) vars.insert(lit().var()); + for (unsigned i = 0; i < size(); ++i) { + bool_var v = get_lit(i).var(); + if (vars.contains(v)) return false; + if (get_coeff(i) > k()) return false; + vars.insert(v); + } + return true; + } + + } diff --git a/src/sat/smt/ba_constraint.h b/src/sat/smt/pb_constraint.h similarity index 85% rename from src/sat/smt/ba_constraint.h rename to src/sat/smt/pb_constraint.h index cd132257b..6ab8fcf9d 100644 --- a/src/sat/smt/ba_constraint.h +++ b/src/sat/smt/pb_constraint.h @@ -3,7 +3,7 @@ Copyright (c) 2017 Microsoft Corporation Module Name: - ba_constraint.h + pb_constraint.h Abstract: @@ -18,9 +18,9 @@ Revision History: --*/ #pragma once -#include "sat/smt/ba_solver_interface.h" +#include "sat/smt/pb_solver_interface.h" -namespace ba { +namespace pb { enum class tag_t { card_t, @@ -28,29 +28,30 @@ namespace ba { }; class card; - class pb; - class pb_base; + class pbc; inline lbool value(sat::model const& m, literal l) { return l.sign() ? ~m[l.var()] : m[l.var()]; } class constraint { protected: tag_t m_tag; - bool m_removed; + bool m_removed { false }; literal m_lit; - literal m_watch; - unsigned m_glue; - unsigned m_psm; + literal m_watch { sat::null_literal }; + unsigned m_glue { 0 }; + unsigned m_psm { 0 }; unsigned m_size; size_t m_obj_size; - bool m_learned; + bool m_learned { false }; unsigned m_id; - bool m_pure; // is the constraint pure (only positive occurrences) + bool m_pure { false }; // is the constraint pure (only positive occurrences) + unsigned m_k; void display_lit(std::ostream& out, solver_interface const& s, literal lit, unsigned sz, bool values) const; public: - constraint(tag_t t, unsigned id, literal l, unsigned sz, size_t osz): - m_tag(t), m_removed(false), m_lit(l), m_watch(sat::null_literal), m_glue(0), m_psm(0), m_size(sz), m_obj_size(osz), m_learned(false), m_id(id), m_pure(false) { + constraint(tag_t t, unsigned id, literal l, unsigned sz, size_t osz, unsigned k): + m_tag(t), m_lit(l), m_size(sz), m_obj_size(osz), m_id(id), m_k(k) { + VERIFY(k < 400000000); } sat::ext_constraint_idx cindex() const { return sat::constraint_base::mem2base(this); } void deallocate(small_object_allocator& a) { a.deallocate(obj_size(), sat::constraint_base::mem2base_ptr(this)); } @@ -79,10 +80,9 @@ namespace ba { size_t obj_size() const { return m_obj_size; } card& to_card(); - pb& to_pb(); + pbc& to_pb(); card const& to_card() const; - pb const& to_pb() const; - pb_base const& to_pb_base() const; + pbc const& to_pb() const; bool is_card() const { return m_tag == tag_t::card_t; } bool is_pb() const { return m_tag == tag_t::pb_t; } @@ -103,7 +103,6 @@ namespace ba { virtual void swap(unsigned i, unsigned j) { UNREACHABLE(); } virtual literal get_lit(unsigned i) const { UNREACHABLE(); return sat::null_literal; } virtual void set_lit(unsigned i, literal l) { UNREACHABLE(); } - virtual bool well_formed() const { return true; } virtual void negate() { UNREACHABLE(); } virtual bool is_extended_binary(literal_vector& r) const { return false; } @@ -111,7 +110,12 @@ namespace ba { virtual std::ostream& display(std::ostream& out) const = 0; virtual std::ostream& display(std::ostream& out, solver_interface const& s, bool values) const = 0; virtual void init_use_list(sat::ext_use_list& ul) const = 0; - + + virtual void set_k(unsigned k) { VERIFY(k < 4000000000); m_k = k; } + virtual unsigned get_coeff(unsigned i) const { UNREACHABLE(); return 0; } + unsigned k() const { return m_k; } + bool well_formed() const; + class iterator { constraint const& c; unsigned idx; diff --git a/src/sat/smt/ba_internalize.cpp b/src/sat/smt/pb_internalize.cpp similarity index 77% rename from src/sat/smt/ba_internalize.cpp rename to src/sat/smt/pb_internalize.cpp index e44690534..5f7b04fd5 100644 --- a/src/sat/smt/ba_internalize.cpp +++ b/src/sat/smt/pb_internalize.cpp @@ -16,24 +16,24 @@ Author: --*/ -#include "sat/smt/ba_solver.h" +#include "sat/smt/pb_solver.h" #include "ast/pb_decl_plugin.h" -namespace sat { +namespace pb { - void ba_solver::internalize(expr* e, bool redundant) { + void solver::internalize(expr* e, bool redundant) { internalize(e, false, false, redundant); } - literal ba_solver::internalize(expr* e, bool sign, bool root, bool redundant) { + literal solver::internalize(expr* e, bool sign, bool root, bool redundant) { flet _redundant(m_is_redundant, redundant); if (m_pb.is_pb(e)) return internalize_pb(e, sign, root); UNREACHABLE(); - return null_literal; + return sat::null_literal; } - literal ba_solver::internalize_pb(expr* e, bool sign, bool root) { + literal solver::internalize_pb(expr* e, bool sign, bool root) { SASSERT(m_pb.is_pb(e)); app* t = to_app(e); rational k = m_pb.get_k(t); @@ -60,16 +60,16 @@ namespace sat { default: UNREACHABLE(); } - return null_literal; + return sat::null_literal; } - void ba_solver::check_unsigned(rational const& c) { + void solver::check_unsigned(rational const& c) { if (!c.is_unsigned()) { throw default_exception("unsigned coefficient expected"); } } - void ba_solver::convert_to_wlits(app* t, sat::literal_vector const& lits, svector& wlits) { + void solver::convert_to_wlits(app* t, sat::literal_vector const& lits, svector& wlits) { for (unsigned i = 0; i < lits.size(); ++i) { rational c = m_pb.get_coeff(t, i); check_unsigned(c); @@ -77,20 +77,20 @@ namespace sat { } } - void ba_solver::convert_pb_args(app* t, literal_vector& lits) { + void solver::convert_pb_args(app* t, literal_vector& lits) { for (expr* arg : *t) { lits.push_back(si.internalize(arg, m_is_redundant)); s().set_external(lits.back().var()); } } - void ba_solver::convert_pb_args(app* t, svector& wlits) { + void solver::convert_pb_args(app* t, svector& wlits) { sat::literal_vector lits; convert_pb_args(t, lits); convert_to_wlits(t, lits, wlits); } - literal ba_solver::convert_pb_le(app* t, bool root, bool sign) { + literal solver::convert_pb_le(app* t, bool root, bool sign) { rational k = m_pb.get_k(t); k.neg(); svector wlits; @@ -109,8 +109,8 @@ namespace sat { k1 += wl.first; } } - add_pb_ge(null_bool_var, wlits, k1); - return null_literal; + add_pb_ge(sat::null_bool_var, wlits, k1); + return sat::null_literal; } else { bool_var v = s().add_var(true); @@ -122,7 +122,7 @@ namespace sat { } - literal ba_solver::convert_pb_ge(app* t, bool root, bool sign) { + literal solver::convert_pb_ge(app* t, bool root, bool sign) { rational k = m_pb.get_k(t); check_unsigned(k); svector wlits; @@ -137,7 +137,7 @@ namespace sat { } } add_pb_ge(sat::null_bool_var, wlits, k1); - return null_literal; + return sat::null_literal; } else { sat::bool_var v = s().add_var(true); @@ -148,14 +148,14 @@ namespace sat { } } - literal ba_solver::convert_pb_eq(app* t, bool root, bool sign) { + literal solver::convert_pb_eq(app* t, bool root, bool sign) { rational k = m_pb.get_k(t); SASSERT(k.is_unsigned()); svector wlits; convert_pb_args(t, wlits); bool base_assert = (root && !sign && s().num_user_scopes() == 0); - bool_var v1 = base_assert ? null_bool_var : s().add_var(true); - bool_var v2 = base_assert ? null_bool_var : s().add_var(true); + bool_var v1 = base_assert ? sat::null_bool_var : s().add_var(true); + bool_var v2 = base_assert ? sat::null_bool_var : s().add_var(true); add_pb_ge(v1, wlits, k.get_unsigned()); k.neg(); for (wliteral& wl : wlits) { @@ -165,7 +165,7 @@ namespace sat { check_unsigned(k); add_pb_ge(v2, wlits, k.get_unsigned()); if (base_assert) { - return null_literal; + return sat::null_literal; } else { literal l1(v1, false), l2(v2, false); @@ -180,7 +180,7 @@ namespace sat { } } - literal ba_solver::convert_at_least_k(app* t, rational const& k, bool root, bool sign) { + literal solver::convert_at_least_k(app* t, rational const& k, bool root, bool sign) { SASSERT(k.is_unsigned()); literal_vector lits; convert_pb_args(t, lits); @@ -190,8 +190,8 @@ namespace sat { for (literal& l : lits) l.neg(); k2 = lits.size() + 1 - k2; } - add_at_least(null_bool_var, lits, k2); - return null_literal; + add_at_least(sat::null_bool_var, lits, k2); + return sat::null_literal; } else { bool_var v = s().add_var(true); @@ -204,7 +204,7 @@ namespace sat { } } - literal ba_solver::convert_at_most_k(app* t, rational const& k, bool root, bool sign) { + literal solver::convert_at_most_k(app* t, rational const& k, bool root, bool sign) { SASSERT(k.is_unsigned()); literal_vector lits; convert_pb_args(t, lits); @@ -217,8 +217,8 @@ namespace sat { for (literal& l : lits) l.neg(); k2 = lits.size() + 1 - k2; } - add_at_least(null_bool_var, lits, k2); - return null_literal; + add_at_least(sat::null_bool_var, lits, k2); + return sat::null_literal; } else { bool_var v = s().add_var(true); @@ -230,12 +230,12 @@ namespace sat { } } - literal ba_solver::convert_eq_k(app* t, rational const& k, bool root, bool sign) { + literal solver::convert_eq_k(app* t, rational const& k, bool root, bool sign) { SASSERT(k.is_unsigned()); literal_vector lits; convert_pb_args(t, lits); - bool_var v1 = (root && !sign) ? null_bool_var : s().add_var(true); - bool_var v2 = (root && !sign) ? null_bool_var : s().add_var(true); + bool_var v1 = (root && !sign) ? sat::null_bool_var : s().add_var(true); + bool_var v2 = (root && !sign) ? sat::null_bool_var : s().add_var(true); add_at_least(v1, lits, k.get_unsigned()); for (literal& l : lits) { l.neg(); @@ -254,11 +254,11 @@ namespace sat { return l; } else { - return null_literal; + return sat::null_literal; } } - expr_ref ba_solver::get_card(std::function& lit2expr, ba::card const& c) { + expr_ref solver::get_card(std::function& lit2expr, card const& c) { ptr_buffer lits; for (sat::literal l : c) { lits.push_back(lit2expr(l)); @@ -271,7 +271,7 @@ namespace sat { return fml; } - expr_ref ba_solver::get_pb(std::function& lit2expr, pb const& p) { + expr_ref solver::get_pb(std::function& lit2expr, pbc const& p) { ptr_buffer lits; vector coeffs; for (auto const& wl : p) { @@ -287,13 +287,13 @@ namespace sat { return fml; } - bool ba_solver::to_formulas(std::function& l2e, expr_ref_vector& fmls) { + bool solver::to_formulas(std::function& l2e, expr_ref_vector& fmls) { for (auto* c : constraints()) { switch (c->tag()) { - case ba::tag_t::card_t: + case pb::tag_t::card_t: fmls.push_back(get_card(l2e, c->to_card())); break; - case ba::tag_t::pb_t: + case pb::tag_t::pb_t: fmls.push_back(get_pb(l2e, c->to_pb())); break; } diff --git a/src/sat/smt/ba_pb.cpp b/src/sat/smt/pb_pb.cpp similarity index 85% rename from src/sat/smt/ba_pb.cpp rename to src/sat/smt/pb_pb.cpp index f7c0c10fb..1c016311e 100644 --- a/src/sat/smt/ba_pb.cpp +++ b/src/sat/smt/pb_pb.cpp @@ -3,7 +3,7 @@ Copyright (c) 2017 Microsoft Corporation Module Name: - ba_pb.cpp + pb_pb.cpp Abstract: @@ -15,30 +15,25 @@ Author: --*/ -#include "sat/smt/ba_pb.h" +#include "sat/smt/pb_pb.h" -namespace ba { +namespace pb { - pb& constraint::to_pb() { + pbc& constraint::to_pb() { SASSERT(is_pb()); - return static_cast(*this); + return static_cast(*this); } - pb const& constraint::to_pb() const { + pbc const& constraint::to_pb() const { SASSERT(is_pb()); - return static_cast(*this); - } - - pb_base const& constraint::to_pb_base() const { - SASSERT(is_pb() || is_card()); - return static_cast(*this); + return static_cast(*this); } // ----------------------------------- // pb - pb::pb(unsigned id, literal lit, svector const& wlits, unsigned k) : - pb_base(tag_t::pb_t, id, lit, wlits.size(), get_obj_size(wlits.size()), k), + pbc::pbc(unsigned id, literal lit, svector const& wlits, unsigned k) : + constraint(tag_t::pb_t, id, lit, wlits.size(), get_obj_size(wlits.size()), k), m_slack(0), m_num_watch(0), m_max_sum(0) { @@ -48,7 +43,7 @@ namespace ba { update_max_sum(); } - void pb::update_max_sum() { + void pbc::update_max_sum() { m_max_sum = 0; for (unsigned i = 0; i < size(); ++i) { m_wlits[i].first = std::min(k(), m_wlits[i].first); @@ -59,7 +54,7 @@ namespace ba { } } - void pb::negate() { + void pbc::negate() { m_lit.neg(); unsigned w = 0, m = 0; for (unsigned i = 0; i < m_size; ++i) { @@ -76,21 +71,21 @@ namespace ba { VERIFY(w >= m_k && m_k > 0); } - bool pb::is_watching(literal l) const { + bool pbc::is_watching(literal l) const { for (unsigned i = 0; i < m_num_watch; ++i) { if ((*this)[i].second == l) return true; } return false; } - bool pb::is_cardinality() const { + bool pbc::is_cardinality() const { if (size() == 0) return false; unsigned w = (*this)[0].first; for (wliteral wl : *this) if (w != wl.first) return false; return true; } - double pb::get_reward(ba::solver_interface const& s, sat::literal_occs_fun& occs) const { + double pbc::get_reward(solver_interface const& s, sat::literal_occs_fun& occs) const { unsigned k = this->k(), slack = 0; bool do_add = s.get_config().m_lookahead_reward == sat::heule_schur_reward; double to_add = do_add ? 0 : 1; @@ -114,7 +109,7 @@ namespace ba { } - void pb::clear_watch(solver_interface& s) { + void pbc::clear_watch(solver_interface& s) { reset_watch(); for (unsigned i = 0; i < num_watch(); ++i) { unwatch_literal(s, (*this)[i].second); @@ -125,7 +120,7 @@ namespace ba { // watch a prefix of literals, such that the slack of these is >= k - bool pb::init_watch(solver_interface& s) { + bool pbc::init_watch(solver_interface& s) { SASSERT(well_formed()); auto& p = *this; clear_watch(s); @@ -198,7 +193,7 @@ namespace ba { } - std::ostream& pb::display(std::ostream& out) const { + std::ostream& pbc::display(std::ostream& out) const { bool first = true; for (wliteral wl : *this) { if (!first) out << "+ "; @@ -209,7 +204,7 @@ namespace ba { return out << " >= " << k(); } - std::ostream& pb::display(std::ostream& out, solver_interface const& s, bool values) const { + std::ostream& pbc::display(std::ostream& out, solver_interface const& s, bool values) const { auto const& p = *this; if (p.lit() != sat::null_literal) out << p.lit() << " == "; if (values) { @@ -244,7 +239,7 @@ namespace ba { return out << ">= " << p.k() << "\n"; } - bool pb::validate_unit_propagation(solver_interface const& s, literal alit) const { + bool pbc::validate_unit_propagation(solver_interface const& s, literal alit) const { if (lit() != sat::null_literal && s.value(lit()) != l_true) return false; @@ -260,11 +255,11 @@ namespace ba { return sum < k(); } - lbool pb::eval(sat::model const& m) const { + lbool pbc::eval(sat::model const& m) const { auto const& p = *this; unsigned trues = 0, undefs = 0; for (wliteral wl : p) { - switch (ba::value(m, wl.second)) { + switch (pb::value(m, wl.second)) { case l_true: trues += wl.first; break; case l_undef: undefs += wl.first; break; default: break; @@ -275,7 +270,7 @@ namespace ba { return l_undef; } - lbool pb::eval(solver_interface const& s) const { + lbool pbc::eval(solver_interface const& s) const { auto const& p = *this; unsigned trues = 0, undefs = 0; for (wliteral wl : p) { @@ -290,13 +285,13 @@ namespace ba { return l_undef; } - void pb::init_use_list(sat::ext_use_list& ul) const { + void pbc::init_use_list(sat::ext_use_list& ul) const { auto idx = cindex(); for (auto l : *this) ul.insert(l.second, idx); } - bool pb::is_blocked(sat::simplifier& sim, literal lit) const { + bool pbc::is_blocked(sat::simplifier& sim, literal lit) const { unsigned weight = 0, offset = 0; for (wliteral l2 : *this) { if (~l2.second == lit) { diff --git a/src/sat/smt/ba_pb.h b/src/sat/smt/pb_pb.h similarity index 87% rename from src/sat/smt/ba_pb.h rename to src/sat/smt/pb_pb.h index 97b8c40dc..5db177d07 100644 --- a/src/sat/smt/ba_pb.h +++ b/src/sat/smt/pb_pb.h @@ -3,7 +3,7 @@ Copyright (c) 2017 Microsoft Corporation Module Name: - ba_pb.h + pb_pb.h Abstract: @@ -18,19 +18,19 @@ Author: #pragma once #include "sat/sat_types.h" -#include "sat/smt/ba_card.h" +#include "sat/smt/pb_card.h" -namespace ba { +namespace pb { - class pb : public pb_base { + class pbc : public constraint { unsigned m_slack; unsigned m_num_watch; unsigned m_max_sum; wliteral m_wlits[0]; public: - static size_t get_obj_size(unsigned num_lits) { return sat::constraint_base::obj_size(sizeof(pb) + num_lits * sizeof(wliteral)); } - pb(unsigned id, literal lit, svector const& wlits, unsigned k); + static size_t get_obj_size(unsigned num_lits) { return sat::constraint_base::obj_size(sizeof(pbc) + num_lits * sizeof(wliteral)); } + pbc(unsigned id, literal lit, svector const& wlits, unsigned k); literal lit() const { return m_lit; } wliteral operator[](unsigned i) const { return m_wlits[i]; } wliteral& operator[](unsigned i) { return m_wlits[i]; } @@ -52,7 +52,7 @@ namespace ba { literal get_lit(unsigned i) const override { return m_wlits[i].second; } void set_lit(unsigned i, literal l) override { m_wlits[i].second = l; } unsigned get_coeff(unsigned i) const override { return m_wlits[i].first; } - double get_reward(ba::solver_interface const& s, sat::literal_occs_fun& occs) const override; + double get_reward(solver_interface const& s, sat::literal_occs_fun& occs) const override; void clear_watch(solver_interface& s) override; std::ostream& display(std::ostream& out) const override; std::ostream& display(std::ostream& out, solver_interface const& s, bool values) const override; diff --git a/src/sat/smt/ba_solver.cpp b/src/sat/smt/pb_solver.cpp similarity index 81% rename from src/sat/smt/ba_solver.cpp rename to src/sat/smt/pb_solver.cpp index 882e5783d..973ba2a3b 100644 --- a/src/sat/smt/ba_solver.cpp +++ b/src/sat/smt/pb_solver.cpp @@ -3,7 +3,7 @@ Copyright (c) 2017 Microsoft Corporation Module Name: - ba_solver.cpp + pb_solver.cpp Abstract: @@ -18,11 +18,11 @@ Author: #include #include "util/mpz.h" #include "sat/sat_types.h" -#include "sat/smt/ba_solver.h" +#include "sat/smt/pb_solver.h" #include "sat/smt/euf_solver.h" #include "sat/sat_simplifier_params.hpp" -namespace sat { +namespace pb { static unsigned _bad_id = 11111111; // 2759; // #define BADLOG(_cmd_) if (p.id() == _bad_id) { _cmd_; } @@ -31,7 +31,7 @@ namespace sat { // ----------------------- // constraint - void ba_solver::set_conflict(constraint& c, literal lit) { + void solver::set_conflict(constraint& c, literal lit) { m_stats.m_num_conflicts++; TRACE("ba", display(tout, c, true); ); if (!validate_conflict(c)) { @@ -40,11 +40,11 @@ namespace sat { } SASSERT(validate_conflict(c)); SASSERT(value(lit) == l_false); - set_conflict(justification::mk_ext_justification(s().scope_lvl(), c.cindex()), ~lit); + set_conflict(sat::justification::mk_ext_justification(s().scope_lvl(), c.cindex()), ~lit); SASSERT(inconsistent()); } - void ba_solver::assign(constraint& c, literal lit) { + void solver::assign(constraint& c, literal lit) { if (inconsistent()) return; switch (value(lit)) { case l_true: @@ -57,7 +57,7 @@ namespace sat { m_num_propagations_since_pop++; //TRACE("ba", tout << "#prop: " << m_stats.m_num_propagations << " - " << c.lit() << " => " << lit << "\n";); SASSERT(validate_unit_propagation(c, lit)); - assign(lit, justification::mk_ext_justification(s().scope_lvl(), c.cindex())); + assign(lit, sat::justification::mk_ext_justification(s().scope_lvl(), c.cindex())); break; } } @@ -65,14 +65,14 @@ namespace sat { // ------------------- // pb_base - void ba_solver::simplify(pb_base& p) { + void solver::simplify(constraint& p) { SASSERT(s().at_base_lvl()); - if (p.lit() != null_literal && value(p.lit()) == l_false) { + if (p.lit() != sat::null_literal && value(p.lit()) == l_false) { TRACE("ba", tout << "pb: flip sign " << p << "\n";); IF_VERBOSE(1, verbose_stream() << "sign is flipped " << p << "\n";); return; } - bool nullify = p.lit() != null_literal && value(p.lit()) == l_true; + bool nullify = p.lit() != sat::null_literal && value(p.lit()) == l_true; if (nullify) { IF_VERBOSE(100, display(verbose_stream() << "nullify tracking literal\n", p, true);); SASSERT(lvl(p.lit()) == 0); @@ -80,7 +80,7 @@ namespace sat { init_watch(p); } - SASSERT(p.lit() == null_literal || value(p.lit()) != l_false); + SASSERT(p.lit() == sat::null_literal || value(p.lit()) != l_false); unsigned true_val = 0, slack = 0, num_false = 0; for (unsigned i = 0; i < p.size(); ++i) { @@ -97,32 +97,32 @@ namespace sat { default: slack += p.get_coeff(i); break; } } - if (p.k() == 1 && p.lit() == null_literal) { + if (p.k() == 1 && p.lit() == sat::null_literal) { literal_vector lits(p.literals()); - s().mk_clause(lits.size(), lits.c_ptr(), status::th(p.learned(), get_id())); + s().mk_clause(lits.size(), lits.c_ptr(), sat::status::th(p.learned(), get_id())); IF_VERBOSE(100, display(verbose_stream() << "add clause: " << lits << "\n", p, true);); remove_constraint(p, "implies clause"); } else if (true_val == 0 && num_false == 0) { - if (p.lit() == null_literal || value(p.lit()) == l_true) { + if (p.lit() == sat::null_literal || value(p.lit()) == l_true) { init_watch(p); } } else if (true_val >= p.k()) { - if (p.lit() != null_literal) { + if (p.lit() != sat::null_literal) { IF_VERBOSE(100, display(verbose_stream() << "assign true literal ", p, true);); s().assign_scoped(p.lit()); } remove_constraint(p, "is true"); } else if (slack + true_val < p.k()) { - if (p.lit() != null_literal) { + if (p.lit() != sat::null_literal) { IF_VERBOSE(100, display(verbose_stream() << "assign false literal ", p, true);); s().assign_scoped(~p.lit()); } else { IF_VERBOSE(1, verbose_stream() << "unsat during simplification\n";); - s().set_conflict(justification(0)); + s().set_conflict(sat::justification(0)); } remove_constraint(p, "is false"); } @@ -149,15 +149,15 @@ namespace sat { unsigned k = p.k() - true_val; - if (k == 1 && p.lit() == null_literal) { + if (k == 1 && p.lit() == sat::null_literal) { literal_vector lits(sz, p.literals().c_ptr()); - s().mk_clause(sz, lits.c_ptr(), status::th(p.learned(), get_id())); + s().mk_clause(sz, lits.c_ptr(), sat::status::th(p.learned(), get_id())); remove_constraint(p, "is clause"); return; } p.set_size(sz); p.set_k(k); - if (p.lit() == null_literal || value(p.lit()) == l_true) { + if (p.lit() == sat::null_literal || value(p.lit()) == l_true) { init_watch(p); } else { @@ -187,8 +187,8 @@ namespace sat { */ - void ba_solver::split_root(pb_base& p) { - SASSERT(p.lit() != null_literal); + void solver::split_root(constraint& p) { + SASSERT(p.lit() != sat::null_literal); SASSERT(!p.learned()); m_weights.resize(2*s().num_vars(), 0); unsigned k = p.k(); @@ -228,7 +228,7 @@ namespace sat { m_weights[l.index()] = 0; } - add_pb_ge(null_literal, m_wlits, k, false); + add_pb_ge(sat::null_literal, m_wlits, k, false); } @@ -258,7 +258,7 @@ namespace sat { a_max index: index of non-false literal with maximal weight. */ - void ba_solver::add_index(pb& p, unsigned index, literal lit) { + void solver::add_index(pbc& p, unsigned index, literal lit) { if (value(lit) == l_undef) { m_pb_undef.push_back(index); if (p[index].first > m_a_max) { @@ -276,7 +276,7 @@ namespace sat { Since 'true' literals may be unassigned (unless they are assigned at level 0) the cache has to be backtrack friendly (and the overhead of backtracking has to be taken into account). */ - lbool ba_solver::add_assign(pb& p, literal alit) { + lbool solver::add_assign(pbc& p, literal alit) { BADLOG(display(verbose_stream() << "assign: " << alit << " watch: " << p.num_watch() << " size: " << p.size(), p, true)); TRACE("ba", display(tout << "assign: " << alit << "\n", p, true);); SASSERT(!inconsistent()); @@ -285,7 +285,7 @@ namespace sat { unsigned num_watch = p.num_watch(); unsigned slack = p.slack(); SASSERT(value(alit) == l_false); - SASSERT(p.lit() == null_literal || value(p.lit()) == l_true); + SASSERT(p.lit() == sat::null_literal || value(p.lit()) == l_true); SASSERT(num_watch <= sz); SASSERT(num_watch > 0); unsigned index = 0; @@ -309,8 +309,8 @@ namespace sat { return l_undef; } - SASSERT(validate_watch(p, null_literal)); - // SASSERT(validate_watch(p, null_literal)); + SASSERT(validate_watch(p, sat::null_literal)); + // SASSERT(validate_watch(p, sat::null_literal)); SASSERT(index < num_watch); unsigned index1 = index + 1; @@ -344,7 +344,7 @@ namespace sat { slack += val; p.set_slack(slack); p.set_num_watch(num_watch); - SASSERT(validate_watch(p, null_literal)); + SASSERT(validate_watch(p, sat::null_literal)); BADLOG(display(verbose_stream() << "conflict: " << alit << " watch: " << p.num_watch() << " size: " << p.size(), p, true)); SASSERT(bound <= slack); TRACE("ba", tout << "conflict " << alit << "\n";); @@ -394,7 +394,7 @@ namespace sat { return l_undef; } - void ba_solver::recompile(pb& p) { + void solver::recompile(pbc& p) { // IF_VERBOSE(2, verbose_stream() << "re: " << p << "\n";); SASSERT(p.num_watch() == 0); m_weights.resize(2*s().num_vars(), 0); @@ -440,16 +440,16 @@ namespace sat { } if (k == 0) { - if (p.lit() != null_literal) { + if (p.lit() != sat::null_literal) { s().assign_scoped(p.lit()); } remove_constraint(p, "recompiled to true"); return; } - else if (k == 1 && p.lit() == null_literal) { + else if (k == 1 && p.lit() == sat::null_literal) { literal_vector lits(sz, p.literals().c_ptr()); - s().mk_clause(sz, lits.c_ptr(), status::th(p.learned(), get_id())); + s().mk_clause(sz, lits.c_ptr(), sat::status::th(p.learned(), get_id())); remove_constraint(p, "recompiled to clause"); return; } @@ -464,8 +464,8 @@ namespace sat { p.set_size(sz); p.update_max_sum(); if (p.max_sum() < k) { - if (p.lit() == null_literal) { - s().set_conflict(justification(0)); + if (p.lit() == sat::null_literal) { + s().set_conflict(sat::justification(0)); } else { s().assign_scoped(~p.lit()); @@ -479,7 +479,7 @@ namespace sat { if (clausify(p)) { return; } - if (p.lit() == null_literal || value(p.lit()) == l_true) { + if (p.lit() == sat::null_literal || value(p.lit()) == l_true) { init_watch(p); } } @@ -490,10 +490,10 @@ namespace sat { // conflict resolution - void ba_solver::inc_coeff(literal l, unsigned offset) { + void solver::inc_coeff(literal l, unsigned offset) { SASSERT(offset > 0); bool_var v = l.var(); - SASSERT(v != null_bool_var); + SASSERT(v != sat::null_bool_var); m_coeffs.reserve(v + 1, 0); TRACE("ba_verbose", tout << l << " " << offset << "\n";); @@ -528,11 +528,11 @@ namespace sat { } } - int64_t ba_solver::get_coeff(bool_var v) const { + int64_t solver::get_coeff(bool_var v) const { return m_coeffs.get(v, 0); } - uint64_t ba_solver::get_coeff(literal lit) const { + uint64_t solver::get_coeff(literal lit) const { int64_t c1 = get_coeff(lit.var()); SASSERT((c1 < 0) == lit.sign()); int64_t c = std::abs(c1); @@ -540,7 +540,7 @@ namespace sat { return static_cast(c); } - wliteral ba_solver::get_wliteral(bool_var v) { + wliteral solver::get_wliteral(bool_var v) { int64_t c1 = get_coeff(v); literal l = literal(v, c1 < 0); c1 = std::abs(c1); @@ -550,21 +550,21 @@ namespace sat { return wliteral(c, l); } - unsigned ba_solver::get_abs_coeff(bool_var v) const { + unsigned solver::get_abs_coeff(bool_var v) const { int64_t c1 = std::abs(get_coeff(v)); unsigned c = static_cast(c1); m_overflow |= c != c1; return c; } - int ba_solver::get_int_coeff(bool_var v) const { + int solver::get_int_coeff(bool_var v) const { int64_t c1 = m_coeffs.get(v, 0); int c = static_cast(c1); m_overflow |= c != c1; return c; } - void ba_solver::inc_bound(int64_t i) { + void solver::inc_bound(int64_t i) { int64_t new_bound = m_bound; new_bound += i; unsigned nb = static_cast(new_bound); @@ -572,7 +572,7 @@ namespace sat { m_bound = nb; } - void ba_solver::reset_coeffs() { + void solver::reset_coeffs() { for (unsigned i = m_active_vars.size(); i-- > 0; ) { m_coeffs[m_active_vars[i]] = 0; } @@ -581,12 +581,12 @@ namespace sat { static bool _debug_conflict = false; - static literal _debug_consequent = null_literal; + static literal _debug_consequent = sat::null_literal; static unsigned_vector _debug_var2position; // #define DEBUG_CODE(_x_) _x_ - void ba_solver::bail_resolve_conflict(unsigned idx) { + void solver::bail_resolve_conflict(unsigned idx) { literal_vector const& lits = s().m_trail; while (m_num_marks > 0) { bool_var v = lits[idx].var(); @@ -621,12 +621,12 @@ namespace sat { } } - lbool ba_solver::resolve_conflict() { + lbool solver::resolve_conflict() { if (0 == m_num_propagations_since_pop) { return l_undef; } - if (s().m_config.m_pb_resolve == PB_ROUNDING) { + if (s().m_config.m_pb_resolve == sat::PB_ROUNDING) { return resolve_conflict_rs(); } @@ -635,14 +635,14 @@ namespace sat { m_num_marks = 0; m_bound = 0; literal consequent = s().m_not_l; - justification js = s().m_conflict; + sat::justification js = s().m_conflict; TRACE("ba", tout << consequent << " " << js << "\n";); bool unique_max; m_conflict_lvl = s().get_max_lvl(consequent, js, unique_max); if (m_conflict_lvl == 0) { return l_undef; } - if (consequent != null_literal) { + if (consequent != sat::null_literal) { consequent.neg(); process_antecedent(consequent, 1); } @@ -678,28 +678,28 @@ namespace sat { _debug_consequent = consequent; } switch(js.get_kind()) { - case justification::NONE: - SASSERT (consequent != null_literal); + case sat::justification::NONE: + SASSERT (consequent != sat::null_literal); inc_bound(offset); break; - case justification::BINARY: + case sat::justification::BINARY: inc_bound(offset); - SASSERT (consequent != null_literal); + SASSERT (consequent != sat::null_literal); inc_coeff(consequent, offset); process_antecedent(js.get_literal(), offset); break; - case justification::TERNARY: + case sat::justification::TERNARY: inc_bound(offset); - SASSERT (consequent != null_literal); + SASSERT (consequent != sat::null_literal); inc_coeff(consequent, offset); process_antecedent(js.get_literal1(), offset); process_antecedent(js.get_literal2(), offset); break; - case justification::CLAUSE: { + case sat::justification::CLAUSE: { inc_bound(offset); - clause & c = s().get_clause(js); + sat::clause & c = s().get_clause(js); unsigned i = 0; - if (consequent != null_literal) { + if (consequent != sat::null_literal) { inc_coeff(consequent, offset); if (c[0] == consequent) { i = 1; @@ -715,7 +715,7 @@ namespace sat { process_antecedent(c[i], offset); break; } - case justification::EXT_JUSTIFICATION: { + case sat::justification::EXT_JUSTIFICATION: { auto cindex = js.get_ext_justification_idx(); auto* ext = sat::constraint_base::to_extension(cindex); if (ext != this) { @@ -727,14 +727,14 @@ namespace sat { constraint& cnstr = index2constraint(cindex); ++m_stats.m_num_resolves; switch (cnstr.tag()) { - case ba::tag_t::card_t: { + case pb::tag_t::card_t: { card& c = cnstr.to_card(); inc_bound(static_cast(offset) * c.k()); process_card(c, offset); break; } - case ba::tag_t::pb_t: { - pb& p = cnstr.to_pb(); + case pb::tag_t::pb_t: { + pbc& p = cnstr.to_pb(); m_lemma.reset(); inc_bound(offset); inc_coeff(consequent, offset); @@ -828,7 +828,7 @@ namespace sat { } - unsigned ba_solver::ineq::bv_coeff(bool_var v) const { + unsigned solver::ineq::bv_coeff(bool_var v) const { for (unsigned i = size(); i-- > 0; ) { if (lit(i).var() == v) return coeff(i); } @@ -836,7 +836,7 @@ namespace sat { return 0; } - void ba_solver::ineq::divide(unsigned c) { + void solver::ineq::divide(unsigned c) { if (c == 1) return; for (unsigned i = size(); i-- > 0; ) { m_wlits[i].first = (coeff(i) + c - 1) / c; @@ -847,7 +847,7 @@ namespace sat { /** * Remove literal at position i, subtract coefficient from bound. */ - void ba_solver::ineq::weaken(unsigned i) { + void solver::ineq::weaken(unsigned i) { unsigned ci = coeff(i); SASSERT(m_k >= ci); m_k -= ci; @@ -858,7 +858,7 @@ namespace sat { /** * Round coefficient of inequality to 1. */ - void ba_solver::round_to_one(ineq& ineq, bool_var v) { + void solver::round_to_one(ineq& ineq, bool_var v) { unsigned c = ineq.bv_coeff(v); if (c == 1) return; unsigned sz = ineq.size(); @@ -888,7 +888,7 @@ namespace sat { TRACE("ba", display(tout << "var: " << v << " " << c << ": ", ineq, true);); } - void ba_solver::round_to_one(bool_var w) { + void solver::round_to_one(bool_var w) { unsigned c = get_abs_coeff(w); if (c == 1 || c == 0) return; for (bool_var v : m_active_vars) { @@ -906,7 +906,7 @@ namespace sat { TRACE("ba", active2pb(m_B); display(tout, m_B, true);); } - void ba_solver::divide(unsigned c) { + void solver::divide(unsigned c) { SASSERT(c != 0); if (c == 1) return; reset_active_var_set(); @@ -927,12 +927,12 @@ namespace sat { m_bound = static_cast((m_bound + c - 1) / c); } - void ba_solver::resolve_on(literal consequent) { + void solver::resolve_on(literal consequent) { round_to_one(consequent.var()); m_coeffs[consequent.var()] = 0; } - void ba_solver::resolve_with(ineq const& ineq) { + void solver::resolve_with(ineq const& ineq) { TRACE("ba", display(tout, ineq, true);); inc_bound(ineq.m_k); TRACE("ba", tout << "bound: " << m_bound << "\n";); @@ -944,7 +944,7 @@ namespace sat { } } - void ba_solver::reset_marks(unsigned idx) { + void solver::reset_marks(unsigned idx) { while (m_num_marks > 0) { SASSERT(idx > 0); bool_var v = s().m_trail[idx].var(); @@ -960,7 +960,7 @@ namespace sat { * \brief mark variables that are on the assignment stack but * below the current processing level. */ - void ba_solver::mark_variables(ineq const& ineq) { + void solver::mark_variables(ineq const& ineq) { for (wliteral wl : ineq.m_wlits) { literal l = wl.second; if (!is_false(l)) continue; @@ -973,7 +973,7 @@ namespace sat { } } - lbool ba_solver::resolve_conflict_rs() { + lbool solver::resolve_conflict_rs() { if (0 == m_num_propagations_since_pop) { return l_undef; } @@ -983,13 +983,13 @@ namespace sat { m_num_marks = 0; m_bound = 0; literal consequent = s().m_not_l; - justification js = s().m_conflict; + sat::justification js = s().m_conflict; bool unique_max; m_conflict_lvl = s().get_max_lvl(consequent, js, unique_max); if (m_conflict_lvl == 0) { return l_undef; } - if (consequent != null_literal) { + if (consequent != sat::null_literal) { consequent.neg(); process_antecedent(consequent, 1); } @@ -998,35 +998,35 @@ namespace sat { do { TRACE("ba", s().display_justification(tout << "process consequent: " << consequent << " : ", js) << "\n"; - if (consequent != null_literal) { active2pb(m_A); display(tout, m_A, true); } + if (consequent != sat::null_literal) { active2pb(m_A); display(tout, m_A, true); } ); switch (js.get_kind()) { - case justification::NONE: - SASSERT(consequent != null_literal); + case sat::justification::NONE: + SASSERT(consequent != sat::null_literal); round_to_one(consequent.var()); inc_bound(1); inc_coeff(consequent, 1); break; - case justification::BINARY: - SASSERT(consequent != null_literal); + case sat::justification::BINARY: + SASSERT(consequent != sat::null_literal); round_to_one(consequent.var()); inc_bound(1); inc_coeff(consequent, 1); process_antecedent(js.get_literal()); break; - case justification::TERNARY: - SASSERT(consequent != null_literal); + case sat::justification::TERNARY: + SASSERT(consequent != sat::null_literal); round_to_one(consequent.var()); inc_bound(1); inc_coeff(consequent, 1); process_antecedent(js.get_literal1()); process_antecedent(js.get_literal2()); break; - case justification::CLAUSE: { - clause & c = s().get_clause(js); + case sat::justification::CLAUSE: { + sat::clause & c = s().get_clause(js); unsigned i = 0; - if (consequent != null_literal) { + if (consequent != sat::null_literal) { round_to_one(consequent.var()); inc_coeff(consequent, 1); if (c[0] == consequent) { @@ -1044,9 +1044,9 @@ namespace sat { process_antecedent(c[i]); break; } - case justification::EXT_JUSTIFICATION: { + case sat::justification::EXT_JUSTIFICATION: { ++m_stats.m_num_resolves; - ext_justification_idx index = js.get_ext_justification_idx(); + sat::ext_justification_idx index = js.get_ext_justification_idx(); auto* ext = sat::constraint_base::to_extension(index); if (ext != this) { m_lemma.reset(); @@ -1055,37 +1055,28 @@ namespace sat { process_antecedent(~l, 1); break; } - constraint& cnstr = index2constraint(index); - SASSERT(!cnstr.was_removed()); - switch (cnstr.tag()) { - case ba::tag_t::card_t: - case ba::tag_t::pb_t: { - pb_base const& p = cnstr.to_pb_base(); - unsigned k = p.k(), sz = p.size(); - m_A.reset(0); - for (unsigned i = 0; i < sz; ++i) { - literal l = p.get_lit(i); - unsigned c = p.get_coeff(i); - if (l == consequent || !is_visited(l.var())) { - m_A.push(l, c); - } - else { - SASSERT(k > c); - TRACE("ba", tout << "visited: " << l << "\n";); - k -= c; - } + constraint& p = index2constraint(index); + SASSERT(!p.was_removed()); + unsigned k = p.k(), sz = p.size(); + m_A.reset(0); + for (unsigned i = 0; i < sz; ++i) { + literal l = p.get_lit(i); + unsigned c = p.get_coeff(i); + if (l == consequent || !is_visited(l.var())) { + m_A.push(l, c); + } + else { + SASSERT(k > c); + TRACE("ba", tout << "visited: " << l << "\n";); + k -= c; } - SASSERT(k > 0); - if (p.lit() != null_literal) m_A.push(~p.lit(), k); - m_A.m_k = k; - break; - } - default: - constraint2pb(cnstr, consequent, 1, m_A); - break; } + SASSERT(k > 0); + if (p.lit() != sat::null_literal) m_A.push(~p.lit(), k); + m_A.m_k = k; + mark_variables(m_A); - if (consequent == null_literal) { + if (consequent == sat::null_literal) { SASSERT(validate_ineq(m_A)); m_bound = static_cast(m_A.m_k); for (wliteral wl : m_A.m_wlits) { @@ -1094,7 +1085,7 @@ namespace sat { } else { round_to_one(consequent.var()); - if (cnstr.is_pb()) round_to_one(m_A, consequent.var()); + if (p.is_pb()) round_to_one(m_A, consequent.var()); SASSERT(validate_ineq(m_A)); resolve_with(m_A); } @@ -1141,7 +1132,7 @@ namespace sat { TRACE("ba", active2pb(m_A); display(tout, m_A, true);); // TBD: check if this is useful - if (!m_overflow && consequent != null_literal) { + if (!m_overflow && consequent != sat::null_literal) { round_to_one(consequent.var()); } if (!m_overflow && create_asserting_lemma()) { @@ -1159,7 +1150,7 @@ namespace sat { } - bool ba_solver::create_asserting_lemma() { + bool solver::create_asserting_lemma() { int64_t bound64 = m_bound; int64_t slack = -bound64; reset_active_var_set(); @@ -1173,7 +1164,7 @@ namespace sat { } m_active_vars.shrink(j); m_lemma.reset(); - m_lemma.push_back(null_literal); + m_lemma.push_back(sat::null_literal); unsigned num_skipped = 0; int64_t asserting_coeff = 0; for (unsigned i = 0; 0 <= slack && i < m_active_vars.size(); ++i) { @@ -1185,7 +1176,7 @@ namespace sat { if (append) { literal lit(v, !is_true); if (lvl(lit) == m_conflict_lvl) { - if (m_lemma[0] == null_literal) { + if (m_lemma[0] == sat::null_literal) { asserting_coeff = std::abs(coeff); slack -= asserting_coeff; m_lemma[0] = ~lit; @@ -1214,9 +1205,9 @@ namespace sat { TRACE("ba", tout << "overflow\n";); return false; } - if (m_lemma[0] == null_literal) { + if (m_lemma[0] == sat::null_literal) { if (m_lemma.size() == 1) { - s().set_conflict(justification(0)); + s().set_conflict(sat::justification(0)); } TRACE("ba", tout << "no asserting literal\n";); return false; @@ -1241,7 +1232,7 @@ namespace sat { \brief compute a cut for current resolvent. */ - void ba_solver::cut() { + void solver::cut() { // bypass cut if there is a unit coefficient for (bool_var v : m_active_vars) { @@ -1291,10 +1282,10 @@ namespace sat { } } - void ba_solver::process_card(card& c, unsigned offset) { + void solver::process_card(card& c, unsigned offset) { literal lit = c.lit(); SASSERT(c.k() <= c.size()); - SASSERT(lit == null_literal || value(lit) != l_undef); + SASSERT(lit == sat::null_literal || value(lit) != l_undef); SASSERT(0 < offset); for (unsigned i = c.k(); i < c.size(); ++i) { process_antecedent(c[i], offset); @@ -1302,7 +1293,7 @@ namespace sat { for (unsigned i = 0; i < c.k(); ++i) { inc_coeff(c[i], offset); } - if (lit != null_literal) { + if (lit != sat::null_literal) { uint64_t offset1 = static_cast(offset) * c.k(); if (offset1 > UINT_MAX) { m_overflow = true; @@ -1316,7 +1307,7 @@ namespace sat { } } - void ba_solver::process_antecedent(literal l, unsigned offset) { + void solver::process_antecedent(literal l, unsigned offset) { SASSERT(value(l) == l_false); bool_var v = l.var(); unsigned level = lvl(v); @@ -1324,14 +1315,14 @@ namespace sat { if (!s().is_marked(v) && level == m_conflict_lvl) { s().mark(v); ++m_num_marks; - if (_debug_conflict && _debug_consequent != null_literal && _debug_var2position[_debug_consequent.var()] < _debug_var2position[l.var()]) { + if (_debug_conflict && _debug_consequent != sat::null_literal && _debug_var2position[_debug_consequent.var()] < _debug_var2position[l.var()]) { IF_VERBOSE(0, verbose_stream() << "antecedent " << l << " is above consequent in stack\n";); } } inc_coeff(l, offset); } - literal ba_solver::get_asserting_literal(literal p) { + literal solver::get_asserting_literal(literal p) { if (get_abs_coeff(p.var()) != 0) { return p; } @@ -1347,10 +1338,10 @@ namespace sat { return p; } - ba_solver::ba_solver(euf::solver& ctx, euf::theory_id id) : - ba_solver(ctx.get_manager(), ctx.get_si(), id) {} + solver::solver(euf::solver& ctx, euf::theory_id id) : + solver(ctx.get_manager(), ctx.get_si(), id) {} - ba_solver::ba_solver(ast_manager& m, sat::sat_internalizer& si, euf::theory_id id) + solver::solver(ast_manager& m, sat::sat_internalizer& si, euf::theory_id id) : euf::th_solver(m, symbol("ba"), id), si(si), m_pb(m), m_lookahead(nullptr), @@ -1359,7 +1350,7 @@ namespace sat { m_num_propagations_since_pop = 0; } - ba_solver::~ba_solver() { + solver::~solver() { m_stats.reset(); for (constraint* c : m_constraints) { c->deallocate(m_allocator); @@ -1369,29 +1360,29 @@ namespace sat { } } - void ba_solver::add_at_least(bool_var v, literal_vector const& lits, unsigned k) { - literal lit = v == null_bool_var ? null_literal : literal(v, false); + void solver::add_at_least(bool_var v, literal_vector const& lits, unsigned k) { + literal lit = v == sat::null_bool_var ? sat::null_literal : literal(v, false); add_at_least(lit, lits, k, m_is_redundant); } - constraint* ba_solver::add_at_least(literal lit, literal_vector const& lits, unsigned k, bool learned) { - if (k == 1 && lit == null_literal) { + constraint* solver::add_at_least(literal lit, literal_vector const& lits, unsigned k, bool learned) { + if (k == 1 && lit == sat::null_literal) { literal_vector _lits(lits); - s().mk_clause(_lits.size(), _lits.c_ptr(), status::th(learned, get_id())); + s().mk_clause(_lits.size(), _lits.c_ptr(), sat::status::th(learned, get_id())); return nullptr; } if (!learned && clausify(lit, lits.size(), lits.c_ptr(), k)) { return nullptr; } void * mem = m_allocator.allocate(card::get_obj_size(lits.size())); - constraint_base::initialize(mem, this); - card* c = new (constraint_base::ptr2mem(mem)) card(next_id(), lit, lits, k); + sat::constraint_base::initialize(mem, this); + card* c = new (sat::constraint_base::ptr2mem(mem)) card(next_id(), lit, lits, k); c->set_learned(learned); add_constraint(c); return c; } - void ba_solver::add_constraint(constraint* c) { + void solver::add_constraint(constraint* c) { literal_vector lits(c->literals()); if (c->learned()) { m_learned.push_back(c); @@ -1402,11 +1393,11 @@ namespace sat { } literal lit = c->lit(); if (c->learned() && m_solver && !s().at_base_lvl()) { - SASSERT(lit == null_literal); + SASSERT(lit == sat::null_literal); // gets initialized after backjump. m_constraint_to_reinit.push_back(c); } - else if (lit == null_literal) { + else if (lit == sat::null_literal) { init_watch(*c); } else { @@ -1424,23 +1415,23 @@ namespace sat { } - bool ba_solver::init_watch(constraint& c) { + bool solver::init_watch(constraint& c) { return !inconsistent() && c.init_watch(*this); } - lbool ba_solver::add_assign(constraint& c, literal l) { + lbool solver::add_assign(constraint& c, literal l) { switch (c.tag()) { - case ba::tag_t::card_t: return add_assign(c.to_card(), l); - case ba::tag_t::pb_t: return add_assign(c.to_pb(), l); + case pb::tag_t::card_t: return add_assign(c.to_card(), l); + case pb::tag_t::pb_t: return add_assign(c.to_pb(), l); } UNREACHABLE(); return l_undef; } - constraint* ba_solver::add_pb_ge(literal lit, svector const& wlits, unsigned k, bool learned) { + constraint* solver::add_pb_ge(literal lit, svector const& wlits, unsigned k, bool learned) { bool units = true; for (wliteral wl : wlits) units &= wl.first == 1; - if (k == 0 && lit == null_literal) { + if (k == 0 && lit == sat::null_literal) { return nullptr; } if (!learned) { @@ -1451,35 +1442,35 @@ namespace sat { for (wliteral wl : wlits) lits.push_back(wl.second); return add_at_least(lit, lits, k, learned); } - void * mem = m_allocator.allocate(pb::get_obj_size(wlits.size())); - constraint_base::initialize(mem, this); - pb* p = new (constraint_base::ptr2mem(mem)) pb(next_id(), lit, wlits, k); + void * mem = m_allocator.allocate(pbc::get_obj_size(wlits.size())); + sat::constraint_base::initialize(mem, this); + pbc* p = new (sat::constraint_base::ptr2mem(mem)) pbc(next_id(), lit, wlits, k); p->set_learned(learned); add_constraint(p); return p; } - void ba_solver::add_pb_ge(bool_var v, svector const& wlits, unsigned k) { - literal lit = v == null_bool_var ? null_literal : literal(v, false); + void solver::add_pb_ge(bool_var v, svector const& wlits, unsigned k) { + literal lit = v == sat::null_bool_var ? sat::null_literal : literal(v, false); add_pb_ge(lit, wlits, k, m_is_redundant); } - bool ba_solver::is_external(bool_var v) { + bool solver::is_external(bool_var v) { return false; } /* \brief return true to keep watching literal. */ - bool ba_solver::propagated(literal l, ext_constraint_idx idx) { + bool solver::propagated(literal l, sat::ext_constraint_idx idx) { SASSERT(value(l) == l_true); constraint& c = index2constraint(idx); - if (c.lit() != null_literal && l.var() == c.lit().var()) { + if (c.lit() != sat::null_literal && l.var() == c.lit().var()) { init_watch(c); return true; } - else if (c.lit() != null_literal && value(c.lit()) != l_true) { - // else if (c.lit() != null_literal && value(c.lit()) == l_false) { + else if (c.lit() != sat::null_literal && value(c.lit()) != l_true) { + // else if (c.lit() != sat::null_literal && value(c.lit()) == l_false) { return true; } else { @@ -1488,28 +1479,28 @@ namespace sat { } - double ba_solver::get_reward(literal l, ext_justification_idx idx, literal_occs_fun& occs) const { + double solver::get_reward(literal l, sat::ext_justification_idx idx, sat::literal_occs_fun& occs) const { constraint const& c = index2constraint(idx); return c.get_reward(*this, occs); } - void ba_solver::ensure_parity_size(bool_var v) { + void solver::ensure_parity_size(bool_var v) { if (m_parity_marks.size() <= static_cast(v)) { m_parity_marks.resize(static_cast(v) + 1, 0); } } - unsigned ba_solver::get_parity(bool_var v) { + unsigned solver::get_parity(bool_var v) { return m_parity_marks.get(v, 0); } - void ba_solver::inc_parity(bool_var v) { + void solver::inc_parity(bool_var v) { ensure_parity_size(v); m_parity_marks[v]++; } - void ba_solver::reset_parity(bool_var v) { + void solver::reset_parity(bool_var v) { ensure_parity_size(v); m_parity_marks[v] = 0; } @@ -1528,7 +1519,7 @@ namespace sat { */ - bool ba_solver::assigned_above(literal above, literal below) { + bool solver::assigned_above(literal above, literal below) { unsigned l = lvl(above); SASSERT(l == lvl(below)); if (l == 0) return false; @@ -1542,11 +1533,11 @@ namespace sat { return false; } - void ba_solver::get_antecedents(literal l, pb const& p, literal_vector& r) { + void solver::get_antecedents(literal l, pbc const& p, literal_vector& r) { TRACE("ba", display(tout << l << " level: " << s().scope_lvl() << " ", p, true);); - SASSERT(p.lit() == null_literal || value(p.lit()) == l_true); + SASSERT(p.lit() == sat::null_literal || value(p.lit()) == l_true); - if (p.lit() != null_literal) { + if (p.lit() != sat::null_literal) { r.push_back(p.lit()); } @@ -1628,12 +1619,12 @@ namespace sat { SASSERT(validate_unit_propagation(p, r, l)); } - bool ba_solver::is_extended_binary(ext_justification_idx idx, literal_vector & r) { + bool solver::is_extended_binary(sat::ext_justification_idx idx, literal_vector & r) { return index2constraint(idx).is_extended_binary(r); } - void ba_solver::get_antecedents(literal l, card const& c, literal_vector& r) { + void solver::get_antecedents(literal l, card const& c, literal_vector& r) { if (l == ~c.lit()) { for (unsigned i = c.k() - 1; i < c.size(); ++i) { VERIFY(value(c[i]) == l_false); @@ -1649,8 +1640,8 @@ namespace sat { CTRACE("ba",!found, s().display(tout << l << ":" << c << "\n");); SASSERT(found);); - VERIFY(c.lit() == null_literal || value(c.lit()) != l_false); - if (c.lit() != null_literal) r.push_back(value(c.lit()) == l_true ? c.lit() : ~c.lit()); + VERIFY(c.lit() == sat::null_literal || value(c.lit()) != l_false); + if (c.lit() != sat::null_literal) r.push_back(value(c.lit()) == l_true ? c.lit() : ~c.lit()); for (unsigned i = c.k(); i < c.size(); ++i) { SASSERT(value(c[i]) == l_false); r.push_back(~c[i]); @@ -1661,15 +1652,15 @@ namespace sat { // ---------------------------- // constraint generic methods - void ba_solver::get_antecedents(literal l, ext_justification_idx idx, literal_vector & r, bool probing) { + void solver::get_antecedents(literal l, sat::ext_justification_idx idx, literal_vector & r, bool probing) { get_antecedents(l, index2constraint(idx), r, probing); } - void ba_solver::get_antecedents(literal l, constraint const& c, literal_vector& r, bool probing) { + void solver::get_antecedents(literal l, constraint const& c, literal_vector& r, bool probing) { switch (c.tag()) { - case ba::tag_t::card_t: get_antecedents(l, c.to_card(), r); break; - case ba::tag_t::pb_t: get_antecedents(l, c.to_pb(), r); break; + case pb::tag_t::card_t: get_antecedents(l, c.to_card(), r); break; + case pb::tag_t::pb_t: get_antecedents(l, c.to_pb(), r); break; default: UNREACHABLE(); break; } if (get_config().m_drat && m_solver && !probing) { @@ -1681,11 +1672,11 @@ namespace sat { } } - void ba_solver::clear_watch(constraint& c) { + void solver::clear_watch(constraint& c) { c.clear_watch(*this); } - void ba_solver::remove_constraint(constraint& c, char const* reason) { + void solver::remove_constraint(constraint& c, char const* reason) { TRACE("ba", display(tout << "remove ", c, true) << " " << reason << "\n";); IF_VERBOSE(21, display(verbose_stream() << "remove " << reason << " ", c, true);); c.nullify_tracking_literal(*this); @@ -1697,31 +1688,31 @@ namespace sat { // -------------------------------- // validation - bool ba_solver::validate_unit_propagation(constraint const& c, literal l) const { + bool solver::validate_unit_propagation(constraint const& c, literal l) const { return true; return c.validate_unit_propagation(*this, l); } - bool ba_solver::validate_conflict(constraint const& c) const { + bool solver::validate_conflict(constraint const& c) const { return eval(c) == l_false; } - lbool ba_solver::eval(constraint const& c) const { - lbool v1 = c.lit() == null_literal ? l_true : value(c.lit()); + lbool solver::eval(constraint const& c) const { + lbool v1 = c.lit() == sat::null_literal ? l_true : value(c.lit()); return eval(v1, c.eval(*this)); } - lbool ba_solver::eval(model const& m, constraint const& c) const { - lbool v1 = c.lit() == null_literal ? l_true : ba::value(m, c.lit()); + lbool solver::eval(sat::model const& m, constraint const& c) const { + lbool v1 = c.lit() == sat::null_literal ? l_true : pb::value(m, c.lit()); return eval(v1, c.eval(m)); } - lbool ba_solver::eval(lbool a, lbool b) const { + lbool solver::eval(lbool a, lbool b) const { if (a == l_undef || b == l_undef) return l_undef; return (a == b) ? l_true : l_false; } - bool ba_solver::validate() { + bool solver::validate() { if (!validate_watch_literals()) { return false; } @@ -1736,7 +1727,7 @@ namespace sat { return true; } - bool ba_solver::validate_watch_literals() const { + bool solver::validate_watch_literals() const { for (unsigned v = 0; v < s().num_vars(); ++v) { literal lit(v, false); if (lvl(lit) == 0) continue; @@ -1746,10 +1737,10 @@ namespace sat { return true; } - bool ba_solver::validate_watch_literal(literal lit) const { + bool solver::validate_watch_literal(literal lit) const { if (lvl(lit) == 0) return true; for (auto const & w : get_wlist(lit)) { - if (w.get_kind() == watched::EXT_CONSTRAINT) { + if (w.get_kind() == sat::watched::EXT_CONSTRAINT) { constraint const& c = index2constraint(w.get_ext_constraint_idx()); if (!c.is_watching(~lit) && lit.var() != c.lit().var()) { IF_VERBOSE(0, display(verbose_stream() << lit << " " << lvl(lit) << " is not watched in " << c << "\n", c, true);); @@ -1761,12 +1752,12 @@ namespace sat { return true; } - bool ba_solver::validate_watched_constraint(constraint const& c) const { - if (c.is_pb() && !validate_watch(c.to_pb(), null_literal)) { + bool solver::validate_watched_constraint(constraint const& c) const { + if (c.is_pb() && !validate_watch(c.to_pb(), sat::null_literal)) { return false; } - if (c.lit() != null_literal && value(c.lit()) != l_true) return true; - SASSERT(c.lit() == null_literal || lvl(c.lit()) == 0 || (c.is_watched(*this, c.lit()) && c.is_watched(*this, ~c.lit()))); + if (c.lit() != sat::null_literal && value(c.lit()) != l_true) return true; + SASSERT(c.lit() == sat::null_literal || lvl(c.lit()) == 0 || (c.is_watched(*this, c.lit()) && c.is_watched(*this, ~c.lit()))); if (eval(c) == l_true) { return true; } @@ -1783,7 +1774,7 @@ namespace sat { s().display_watch_list(verbose_stream() << ~l << ": ", get_wlist(~l)) << "\n"; verbose_stream() << "value: " << value(l) << " level: " << lvl(l) << "\n"; display(verbose_stream(), c, true); - if (c.lit() != null_literal) verbose_stream() << value(c.lit()) << "\n";); + if (c.lit() != sat::null_literal) verbose_stream() << value(c.lit()) << "\n";); IF_VERBOSE(0, s().display_watches(verbose_stream())); @@ -1794,7 +1785,7 @@ namespace sat { return true; } - bool ba_solver::validate_watch(pb const& p, literal alit) const { + bool solver::validate_watch(pbc const& p, literal alit) const { for (unsigned i = 0; i < p.size(); ++i) { literal l = p[i].second; if (l != alit && lvl(l) != 0 && p.is_watched(*this, l) != (i < p.num_watch())) { @@ -1830,15 +1821,15 @@ namespace sat { } }; - void ba_solver::update_psm(constraint& c) const { + void solver::update_psm(constraint& c) const { unsigned r = 0; switch (c.tag()) { - case ba::tag_t::card_t: + case pb::tag_t::card_t: for (literal l : c.to_card()) { if (s().m_phase[l.var()] == !l.sign()) ++r; } break; - case ba::tag_t::pb_t: + case pb::tag_t::pb_t: for (wliteral l : c.to_pb()) { if (s().m_phase[l.second.var()] == !l.second.sign()) ++r; } @@ -1849,7 +1840,7 @@ namespace sat { c.set_psm(r); } - void ba_solver::gc() { + void solver::gc() { if (m_learned.size() >= 2 * m_constraints.size() && (s().at_search_lvl() || s().at_base_lvl())) { for (auto & c : m_learned) update_psm(*c); @@ -1859,7 +1850,7 @@ namespace sat { } } - void ba_solver::gc_half(char const* st_name) { + void solver::gc_half(char const* st_name) { TRACE("ba", tout << "gc\n";); unsigned sz = m_learned.size(); unsigned new_sz = sz/2; @@ -1881,12 +1872,12 @@ namespace sat { } - void ba_solver::gc_vars(unsigned num_vars) { + void solver::gc_vars(unsigned num_vars) { gc_vars(num_vars, m_constraints); gc_vars(num_vars, m_learned); } - void ba_solver::gc_vars(unsigned num_vars, ptr_vector& cs) { + void solver::gc_vars(unsigned num_vars, ptr_vector& cs) { unsigned j = 0; for (unsigned i = 0; i < cs.size(); ++i) { auto* c = cs[i]; @@ -1903,7 +1894,7 @@ namespace sat { } - lbool ba_solver::add_assign(card& c, literal alit) { + lbool solver::add_assign(card& c, literal alit) { // literal is assigned to false. unsigned sz = c.size(); unsigned bound = c.k(); @@ -1911,7 +1902,7 @@ namespace sat { SASSERT(0 < bound && bound <= sz); if (bound == sz) { - if (c.lit() != null_literal && value(c.lit()) == l_undef) { + if (c.lit() != sat::null_literal && value(c.lit()) == l_undef) { assign(c, ~c.lit()); return inconsistent() ? l_false : l_true; } @@ -1919,7 +1910,7 @@ namespace sat { return l_false; } SASSERT(value(alit) == l_false); - VERIFY(c.lit() == null_literal || value(c.lit()) != l_false); + VERIFY(c.lit() == sat::null_literal || value(c.lit()) != l_false); unsigned index = 0; for (index = 0; index <= bound; ++index) { if (c[index] == alit) { @@ -1946,7 +1937,7 @@ namespace sat { // conflict if (bound != index && value(c[bound]) == l_false) { TRACE("ba", tout << "conflict " << c[bound] << " " << alit << "\n";); - if (c.lit() != null_literal && value(c.lit()) == l_undef) { + if (c.lit() != sat::null_literal && value(c.lit()) == l_undef) { if (index + 1 < bound) c.swap(index, bound - 1); assign(c, ~c.lit()); return inconsistent() ? l_false : l_true; @@ -1965,7 +1956,7 @@ namespace sat { // position bound. Then literals in positions 0..bound-1 have to be // assigned l_true. - if (c.lit() != null_literal && value(c.lit()) == l_undef) { + if (c.lit() != sat::null_literal && value(c.lit()) == l_undef) { return l_true; } @@ -1983,17 +1974,17 @@ namespace sat { return inconsistent() ? l_false : l_true; } - void ba_solver::asserted(literal l) { + void solver::asserted(literal l) { } - check_result ba_solver::check() { return check_result::CR_DONE; } + sat::check_result solver::check() { return sat::check_result::CR_DONE; } - void ba_solver::push() { + void solver::push() { m_constraint_to_reinit_lim.push_back(m_constraint_to_reinit.size()); } - void ba_solver::pop(unsigned n) { + void solver::pop(unsigned n) { TRACE("sat_verbose", tout << "pop:" << n << "\n";); unsigned new_lim = m_constraint_to_reinit_lim.size() - n; m_constraint_to_reinit_last_sz = m_constraint_to_reinit_lim[new_lim]; @@ -2001,7 +1992,7 @@ namespace sat { m_num_propagations_since_pop = 0; } - void ba_solver::pop_reinit() { + void solver::pop_reinit() { unsigned sz = m_constraint_to_reinit_last_sz; for (unsigned i = sz; i < m_constraint_to_reinit.size(); ++i) { constraint* c = m_constraint_to_reinit[i]; @@ -2012,22 +2003,7 @@ namespace sat { m_constraint_to_reinit.shrink(sz); } - - void ba_solver::simplify(constraint& c) { - SASSERT(s().at_base_lvl()); - switch (c.tag()) { - case ba::tag_t::card_t: - simplify(c.to_card()); - break; - case ba::tag_t::pb_t: - simplify(c.to_pb()); - break; - default: - UNREACHABLE(); - } - } - - void ba_solver::simplify() { + void solver::simplify() { if (!s().at_base_lvl()) s().pop_to_base_level(); if (s().inconsistent()) @@ -2082,11 +2058,11 @@ namespace sat { * lit == C * -> negate: ~lit == ~C */ - void ba_solver::update_pure() { + void solver::update_pure() { //return; for (constraint* cp : m_constraints) { literal lit = cp->lit(); - if (lit != null_literal && + if (lit != sat::null_literal && !cp->is_pure() && value(lit) == l_undef && get_wlist(~lit).size() == 1 && @@ -2095,18 +2071,18 @@ namespace sat { cp->negate(); lit.neg(); } - if (lit != null_literal && + if (lit != sat::null_literal && !cp->is_pure() && m_cnstr_use_list[(~lit).index()].size() == 1 && get_wlist(lit).size() == 1 && m_clause_use_list.get(~lit).empty()) { cp->set_pure(); - get_wlist(~lit).erase(watched(cp->cindex())); // just ignore assignments to false + get_wlist(~lit).erase(sat::watched(cp->cindex())); // just ignore assignments to false } } } - void ba_solver::mutex_reduction() { + void solver::mutex_reduction() { literal_vector lits; for (unsigned v = 0; v < s().num_vars(); ++v) { lits.push_back(literal(v, false)); @@ -2118,38 +2094,38 @@ namespace sat { if (mux.size() > 2) { IF_VERBOSE(1, verbose_stream() << "mux: " << mux << "\n";); for (unsigned i = 0; i < mux.size(); ++i) mux[i].neg(); - add_at_least(null_literal, mux, mux.size() - 1, false); + add_at_least(sat::null_literal, mux, mux.size() - 1, false); } } } // ------------------------- // sorting networks - literal ba_solver::ba_sort::mk_false() { + literal solver::ba_sort::mk_false() { return ~mk_true(); } - literal ba_solver::ba_sort::mk_true() { - if (m_true == null_literal) { + literal solver::ba_sort::mk_true() { + if (m_true == sat::null_literal) { bool_var v = s.s().mk_var(false, false); m_true = literal(v, false); s.s().mk_clause(1,&m_true); } - VERIFY(m_true != null_literal); + VERIFY(m_true != sat::null_literal); return m_true; } - literal ba_solver::ba_sort::mk_not(literal l) { + literal solver::ba_sort::mk_not(literal l) { return ~l; } - literal ba_solver::ba_sort::fresh(char const*) { + literal solver::ba_sort::fresh(char const*) { bool_var v = s.s().mk_var(false, true); return literal(v, false); } - literal ba_solver::ba_sort::mk_max(unsigned n, literal const* lits) { + literal solver::ba_sort::mk_max(unsigned n, literal const* lits) { m_lits.reset(); for (unsigned i = 0; i < n; ++i) { if (lits[i] == m_true) return m_true; @@ -2173,7 +2149,7 @@ namespace sat { } } - literal ba_solver::ba_sort::mk_min(unsigned n, literal const* lits) { + literal solver::ba_sort::mk_min(unsigned n, literal const* lits) { m_lits.reset(); for (unsigned i = 0; i < n; ++i) { if (lits[i] == ~m_true) return ~m_true; @@ -2198,13 +2174,13 @@ namespace sat { } } - void ba_solver::ba_sort::mk_clause(unsigned n, literal const* lits) { + void solver::ba_sort::mk_clause(unsigned n, literal const* lits) { m_lits.reset(); m_lits.append(n, lits); s.s().mk_clause(n, m_lits.c_ptr()); } - std::ostream& ba_solver::ba_sort::pp(std::ostream& out, literal l) const { + std::ostream& solver::ba_sort::pp(std::ostream& out, literal l) const { return out << l; } @@ -2212,14 +2188,14 @@ namespace sat { // ------------------------------- // set literals equivalent - void ba_solver::reserve_roots() { + void solver::reserve_roots() { m_root_vars.reserve(s().num_vars(), false); for (unsigned i = m_roots.size(); i < 2 * s().num_vars(); ++i) { - m_roots.push_back(to_literal(i)); + m_roots.push_back(sat::to_literal(i)); } } - bool ba_solver::set_root(literal l, literal r) { + bool solver::set_root(literal l, literal r) { if (s().is_assumption(l.var())) { return false; } @@ -2230,7 +2206,7 @@ namespace sat { return true; } - void ba_solver::flush_roots() { + void solver::flush_roots() { if (m_roots.empty()) return; reserve_roots(); // validate(); @@ -2245,12 +2221,12 @@ namespace sat { // validate_eliminated(); } - void ba_solver::validate_eliminated() { + void solver::validate_eliminated() { validate_eliminated(m_constraints); validate_eliminated(m_learned); } - void ba_solver::validate_eliminated(ptr_vector const& cs) { + void solver::validate_eliminated(ptr_vector const& cs) { for (constraint const* c : cs) { if (c->learned()) continue; for (auto l : constraint::literal_iterator(*c)) @@ -2258,15 +2234,15 @@ namespace sat { } } - void ba_solver::recompile(constraint& c) { + void solver::recompile(constraint& c) { if (c.id() == _bad_id) { IF_VERBOSE(0, display(verbose_stream() << "recompile\n", c, true);); } switch (c.tag()) { - case ba::tag_t::card_t: + case pb::tag_t::card_t: recompile(c.to_card()); break; - case ba::tag_t::pb_t: + case pb::tag_t::pb_t: recompile(c.to_pb()); break; default: @@ -2274,8 +2250,8 @@ namespace sat { } } - void ba_solver::recompile(card& c) { - SASSERT(c.lit() == null_literal || c.is_watched(*this, c.lit())); + void solver::recompile(card& c) { + SASSERT(c.lit() == sat::null_literal || c.is_watched(*this, c.lit())); // pre-condition is that the literals, except c.lit(), in c are unwatched. if (c.id() == _bad_id) std::cout << "recompile: " << c << "\n"; @@ -2324,12 +2300,12 @@ namespace sat { m_weights[(~l).index()] = 0; } - if (k == 0 && c.lit() == null_literal) { + if (k == 0 && c.lit() == sat::null_literal) { remove_constraint(c, "recompiled to true"); return; } - if (k == 1 && c.lit() == null_literal) { + if (k == 1 && c.lit() == sat::null_literal) { literal_vector lits(sz, c.literals().c_ptr()); s().mk_clause(sz, lits.c_ptr(), sat::status::th(c.learned(), get_id())); remove_constraint(c, "recompiled to clause"); @@ -2337,29 +2313,29 @@ namespace sat { } if (sz == 0) { - if (c.lit() == null_literal) { + if (c.lit() == sat::null_literal) { if (k > 0) { - s().mk_clause(0, nullptr, status::th(false, get_id())); + s().mk_clause(0, nullptr, sat::status::th(false, get_id())); } } else if (k > 0) { literal lit = ~c.lit(); - s().mk_clause(1, &lit, status::th(c.learned(), get_id())); + s().mk_clause(1, &lit, sat::status::th(c.learned(), get_id())); } else { literal lit = c.lit(); - s().mk_clause(1, &lit, status::th(c.learned(), get_id())); + s().mk_clause(1, &lit, sat::status::th(c.learned(), get_id())); } remove_constraint(c, "recompiled to clause"); return; } if (all_units && sz < k) { - if (c.lit() == null_literal) { - s().mk_clause(0, nullptr, status::th(c.learned(), get_id())); + if (c.lit() == sat::null_literal) { + s().mk_clause(0, nullptr, sat::status::th(c.learned(), get_id())); } else { literal lit = ~c.lit(); - s().mk_clause(1, &lit, status::th(c.learned(), get_id())); + s().mk_clause(1, &lit, sat::status::th(c.learned(), get_id())); } remove_constraint(c, "recompiled to clause"); return; @@ -2383,17 +2359,17 @@ namespace sat { add_pb_ge(root, m_wlits, k, c.learned()); } else { - if (c.lit() == null_literal || value(c.lit()) == l_true) { + if (c.lit() == sat::null_literal || value(c.lit()) == l_true) { init_watch(c); } - SASSERT(c.lit() == null_literal || c.is_watched(*this, c.lit())); + SASSERT(c.lit() == sat::null_literal || c.is_watched(*this, c.lit())); SASSERT(c.well_formed()); } } - bool ba_solver::clausify(literal lit, unsigned n, literal const* lits, unsigned k) { + bool solver::clausify(literal lit, unsigned n, literal const* lits, unsigned k) { return false; - bool is_def = lit != null_literal; + bool is_def = lit != sat::null_literal; if ((!is_def || !s().was_eliminated(lit)) && !std::any_of(lits, lits + n, [&](literal l) { return s().was_eliminated(l); })) { literal def_lit = m_sort.ge(is_def, k, n, lits); @@ -2407,7 +2383,7 @@ namespace sat { } - bool ba_solver::clausify(card& c) { + bool solver::clausify(card& c) { return false; if (get_config().m_card_solver) return false; @@ -2424,13 +2400,13 @@ namespace sat { return true; } - bool ba_solver::clausify(pb& p) { + bool solver::clausify(pbc& p) { return false; if (get_config().m_card_solver) return false; bool ok = !p.learned(); - bool is_def = p.lit() != null_literal; + bool is_def = p.lit() != sat::null_literal; for (wliteral wl : p) { ok &= !s().was_eliminated(wl.second); } @@ -2452,7 +2428,7 @@ namespace sat { return false; } - bool ba_solver::is_cardinality(pb const& p, literal_vector& lits) { + bool solver::is_cardinality(pbc const& p, literal_vector& lits) { lits.reset(); p.size(); for (wliteral wl : p) { @@ -2466,20 +2442,13 @@ namespace sat { return true; } - void ba_solver::split_root(constraint& c) { - switch (c.tag()) { - case ba::tag_t::card_t: split_root(c.to_card()); break; - case ba::tag_t::pb_t: split_root(c.to_pb()); break; - } - } - - void ba_solver::flush_roots(constraint& c) { - if (c.lit() != null_literal && !c.is_watched(*this, c.lit())) { + void solver::flush_roots(constraint& c) { + if (c.lit() != sat::null_literal && !c.is_watched(*this, c.lit())) { c.watch_literal(*this, c.lit()); c.watch_literal(*this, ~c.lit()); } - SASSERT(c.lit() == null_literal || c.is_watched(*this, c.lit())); - bool found = c.lit() != null_literal && m_root_vars[c.lit().var()]; + SASSERT(c.lit() == sat::null_literal || c.is_watched(*this, c.lit())); + bool found = c.lit() != sat::null_literal && m_root_vars[c.lit().var()]; for (unsigned i = 0; !found && i < c.size(); ++i) { found = m_root_vars[c.get_lit(i).var()]; } @@ -2493,7 +2462,7 @@ namespace sat { } literal root = c.lit(); - if (root != null_literal && m_roots[root.index()] != root) { + if (root != sat::null_literal && m_roots[root.index()] != root) { root = m_roots[root.index()]; c.nullify_tracking_literal(*this); c.update_literal(root); @@ -2529,12 +2498,12 @@ namespace sat { recompile(c); } else { - if (c.lit() == null_literal || value(c.lit()) != l_undef) init_watch(c); + if (c.lit() == sat::null_literal || value(c.lit()) != l_undef) init_watch(c); SASSERT(c.well_formed()); } } - unsigned ba_solver::get_num_unblocked_bin(literal l) { + unsigned solver::get_num_unblocked_bin(literal l) { return s().m_simplifier.num_nonlearned_bin(l); } @@ -2547,65 +2516,52 @@ namespace sat { - resolution - blocked literals */ - void ba_solver::init_use_lists() { + void solver::init_use_lists() { m_clause_use_list.init(s().num_vars()); m_cnstr_use_list.reset(); m_cnstr_use_list.resize(2*s().num_vars()); - for (clause* c : s().m_clauses) { + for (sat::clause* c : s().m_clauses) { if (!c->frozen()) m_clause_use_list.insert(*c); } for (constraint* cp : m_constraints) { literal lit = cp->lit(); - if (lit != null_literal) { + if (lit != sat::null_literal) { m_cnstr_use_list[lit.index()].push_back(cp); m_cnstr_use_list[(~lit).index()].push_back(cp); } - switch (cp->tag()) { - case ba::tag_t::card_t: - case ba::tag_t::pb_t: - for (literal l : constraint::literal_iterator(*cp)) { - m_cnstr_use_list[l.index()].push_back(cp); - if (lit != null_literal) m_cnstr_use_list[(~l).index()].push_back(cp); - } - break; + for (literal l : constraint::literal_iterator(*cp)) { + m_cnstr_use_list[l.index()].push_back(cp); + if (lit != sat::null_literal) m_cnstr_use_list[(~l).index()].push_back(cp); } } } - void ba_solver::remove_unused_defs() { + void solver::remove_unused_defs() { if (incremental_mode()) return; // remove constraints where indicator literal isn't used. for (constraint* cp : m_constraints) { constraint& c = *cp; literal lit = c.lit(); - switch (c.tag()) { - case ba::tag_t::card_t: - case ba::tag_t::pb_t: { - if (lit != null_literal && - value(lit) == l_undef && - use_count(lit) == 1 && - use_count(~lit) == 1 && - get_num_unblocked_bin(lit) == 0 && - get_num_unblocked_bin(~lit) == 0) { - remove_constraint(c, "unused def"); - } - break; - } - default: - break; + if (lit != sat::null_literal && + value(lit) == l_undef && + use_count(lit) == 1 && + use_count(~lit) == 1 && + get_num_unblocked_bin(lit) == 0 && + get_num_unblocked_bin(~lit) == 0) { + remove_constraint(c, "unused def"); } } } - bool ba_solver::incremental_mode() const { + bool solver::incremental_mode() const { sat_simplifier_params p(s().m_params); bool incremental_mode = s().get_config().m_incremental && !p.override_incremental(); incremental_mode |= s().tracking_assumptions(); return incremental_mode; } - unsigned ba_solver::set_non_external() { + unsigned solver::set_non_external() { // set variables to be non-external if they are not used in theory constraints. unsigned ext = 0; if (!incremental_mode() && s().get_extension() == this) { @@ -2623,7 +2579,7 @@ namespace sat { for (constraint* cp : m_learned) { constraint& c = *cp; if (c.was_removed()) continue; - SASSERT(c.lit() == null_literal); + SASSERT(c.lit() == sat::null_literal); for (unsigned i = 0; i < c.size(); ++i) { bool_var v = c.get_lit(i).var(); if (s().was_eliminated(v)) { @@ -2635,7 +2591,7 @@ namespace sat { return ext; } - bool ba_solver::elim_pure(literal lit) { + bool solver::elim_pure(literal lit) { if (value(lit) == l_undef && !m_cnstr_use_list[lit.index()].empty() && use_count(~lit) == 0 && get_num_unblocked_bin(~lit) == 0) { IF_VERBOSE(100, verbose_stream() << "pure literal: " << lit << "\n";); @@ -2645,7 +2601,7 @@ namespace sat { return false; } - unsigned ba_solver::elim_pure() { + unsigned solver::elim_pure() { if (!get_config().m_elim_vars || incremental_mode()) { return 0; } @@ -2677,8 +2633,8 @@ namespace sat { * if slack < 0: * add ~root(~l) to c, k <- k + 1 */ - void ba_solver::unit_strengthen() { - big big(s().m_rand); + void solver::unit_strengthen() { + sat::big big(s().m_rand); big.init(s(), true); for (unsigned sz = m_constraints.size(), i = 0; i < sz; ++i) unit_strengthen(big, *m_constraints[i]); @@ -2686,22 +2642,8 @@ namespace sat { unit_strengthen(big, *m_learned[i]); } - void ba_solver::unit_strengthen(big& big, constraint& c) { - if (c.was_removed()) return; - switch (c.tag()) { - case ba::tag_t::card_t: - unit_strengthen(big, c.to_card()); - break; - case ba::tag_t::pb_t: - unit_strengthen(big, c.to_pb()); - break; - default: - break; - } - } - - void ba_solver::unit_strengthen(big& big, pb_base& p) { - if (p.lit() != null_literal) return; + void solver::unit_strengthen(sat::big& big, constraint& p) { + if (p.lit() != sat::null_literal) return; unsigned sz = p.size(); for (unsigned i = 0; i < sz; ++i) { literal u = p.get_lit(i); @@ -2750,44 +2692,44 @@ namespace sat { } ++m_stats.m_num_big_strengthenings; p.set_removed(); - add_pb_ge(null_literal, wlits, b, p.learned()); + add_pb_ge(sat::null_literal, wlits, b, p.learned()); return; } } } - void ba_solver::subsumption(constraint& cnstr) { - if (cnstr.was_removed()) return; + void solver::subsumption(constraint& cnstr) { + if (cnstr.was_removed()) + return; + if (cnstr.k() <= 1) + return; switch (cnstr.tag()) { - case ba::tag_t::card_t: { - card& c = cnstr.to_card(); - if (c.k() > 1) subsumption(c); + case pb::tag_t::card_t: + subsumption(cnstr.to_card()); break; - } - case ba::tag_t::pb_t: { - pb& p = cnstr.to_pb(); - if (p.k() > 1) subsumption(p); + case pb::tag_t::pb_t: + subsumption(cnstr.to_pb()); break; } - default: - break; - } } - void ba_solver::init_visited() { s().init_visited(); } - void ba_solver::mark_visited(literal l) { s().mark_visited(l); } - void ba_solver::mark_visited(bool_var v) { s().mark_visited(v); } - bool ba_solver::is_visited(bool_var v) const { return s().is_visited(v); } - bool ba_solver::is_visited(literal l) const { return s().is_visited(l); } + void solver::init_visited() { s().init_visited(); } + void solver::mark_visited(literal l) { s().mark_visited(l); } + void solver::mark_visited(bool_var v) { s().mark_visited(v); } + bool solver::is_visited(bool_var v) const { return s().is_visited(v); } + bool solver::is_visited(literal l) const { return s().is_visited(l); } - void ba_solver::cleanup_clauses() { + void solver::cleanup_clauses() { if (m_clause_removed) { cleanup_clauses(s().m_clauses); cleanup_clauses(s().m_learned); } } - void ba_solver::cleanup_clauses(clause_vector& clauses) { + typedef sat::clause_vector clause_vector; + typedef sat::clause clause; + + void solver::cleanup_clauses(clause_vector& clauses) { // version in simplify first clears // all watch literals, then reinserts them. // this ensures linear time cleanup. @@ -2810,7 +2752,7 @@ namespace sat { clauses.set_end(it2); } - void ba_solver::cleanup_constraints() { + void solver::cleanup_constraints() { if (m_constraint_removed) { cleanup_constraints(m_constraints, false); cleanup_constraints(m_learned, true); @@ -2818,7 +2760,7 @@ namespace sat { } } - void ba_solver::cleanup_constraints(ptr_vector& cs, bool learned) { + void solver::cleanup_constraints(ptr_vector& cs, bool learned) { ptr_vector::iterator it = cs.begin(); ptr_vector::iterator it2 = it; ptr_vector::iterator end = cs.end(); @@ -2851,8 +2793,8 @@ namespace sat { - version that generalizes self-subsumption to more than one literal A + ~L + B >= k' => A + B >= k' if A + A' + L >= k and k' + |L| + |A'| <= k */ - bool ba_solver::subsumes(card& c1, card& c2, literal_vector & comp) { - if (c2.lit() != null_literal) return false; + bool solver::subsumes(card& c1, card& c2, literal_vector & comp) { + if (c2.lit() != sat::null_literal) return false; unsigned c2_exclusive = 0; unsigned common = 0; @@ -2878,7 +2820,7 @@ namespace sat { A + L + B >= k self-subsumes A + ~L + C >= 1 if k + 1 - |B| - |C| - |L| > 0 */ - bool ba_solver::subsumes(card& c1, clause& c2, bool& self) { + bool solver::subsumes(card& c1, sat::clause& c2, bool& self) { unsigned common = 0, complement = 0, c2_exclusive = 0; self = false; @@ -2905,7 +2847,7 @@ namespace sat { \brief Ax >= k subsumes By >= k' if all coefficients in A are <= B and k >= k' */ - bool ba_solver::subsumes(pb const& p1, pb_base const& p2) { + bool solver::subsumes(pbc const& p1, constraint const& p2) { if (p1.k() < p2.k() || p1.size() > p2.size()) return false; unsigned num_sub = 0; for (unsigned i = 0; i < p2.size(); ++i) { @@ -2918,15 +2860,15 @@ namespace sat { return num_sub == p1.size(); } - void ba_solver::subsumes(pb& p1, literal lit) { + void solver::subsumes(pbc& p1, literal lit) { for (constraint* c : m_cnstr_use_list[lit.index()]) { if (c == &p1 || c->was_removed()) continue; bool s = false; switch (c->tag()) { - case ba::tag_t::card_t: + case pb::tag_t::card_t: s = subsumes(p1, c->to_card()); break; - case ba::tag_t::pb_t: + case pb::tag_t::pb_t: s = subsumes(p1, c->to_pb()); break; default: @@ -2940,9 +2882,9 @@ namespace sat { } } - literal ba_solver::get_min_occurrence_literal(card const& c) { + literal solver::get_min_occurrence_literal(card const& c) { unsigned occ_count = UINT_MAX; - literal lit = null_literal; + literal lit = sat::null_literal; for (literal l : c) { unsigned occ_count1 = m_cnstr_use_list[l.index()].size(); if (occ_count1 < occ_count) { @@ -2953,7 +2895,7 @@ namespace sat { return lit; } - void ba_solver::card_subsumption(card& c1, literal lit) { + void solver::card_subsumption(card& c1, literal lit) { literal_vector slit; for (constraint* c : m_cnstr_use_list[lit.index()]) { if (!c->is_card() || c == &c1 || c->was_removed()) { @@ -2990,12 +2932,12 @@ namespace sat { } } - void ba_solver::clause_subsumption(card& c1, literal lit, clause_vector& removed_clauses) { + void solver::clause_subsumption(card& c1, literal lit, sat::clause_vector& removed_clauses) { SASSERT(!c1.was_removed()); - clause_use_list& occurs = m_clause_use_list.get(lit); - clause_use_list::iterator it = occurs.mk_iterator(); + sat::clause_use_list& occurs = m_clause_use_list.get(lit); + sat::clause_use_list::iterator it = occurs.mk_iterator(); while (!it.at_end()) { - clause& c2 = it.curr(); + sat::clause& c2 = it.curr(); bool self; if (!c2.was_removed() && subsumes(c1, c2, self)) { if (self) { @@ -3012,9 +2954,9 @@ namespace sat { } } - void ba_solver::set_non_learned(constraint& c) { + void solver::set_non_learned(constraint& c) { literal lit = c.lit(); - if (lit != null_literal) { + if (lit != sat::null_literal) { s().set_external(lit.var()); } for (literal lit : constraint::literal_iterator(c)) { @@ -3024,7 +2966,9 @@ namespace sat { c.set_learned(false); } - void ba_solver::binary_subsumption(card& c1, literal lit) { + typedef sat::watch_list watch_list; + + void solver::binary_subsumption(card& c1, literal lit) { if (c1.k() + 1 != c1.size()) return; SASSERT(is_visited(lit)); SASSERT(!c1.was_removed()); @@ -3033,7 +2977,7 @@ namespace sat { watch_list::iterator it2 = it; watch_list::iterator end = wlist.end(); for (; it != end; ++it) { - watched w = *it; + sat::watched w = *it; if (w.is_binary_clause() && is_visited(w.get_literal())) { ++m_stats.m_num_bin_subsumes; IF_VERBOSE(20, verbose_stream() << c1 << " subsumes (" << lit << " " << w.get_literal() << ")\n";); @@ -3051,11 +2995,11 @@ namespace sat { wlist.set_end(it2); } - void ba_solver::subsumption(card& c1) { - if (c1.was_removed() || c1.lit() != null_literal) { + void solver::subsumption(card& c1) { + if (c1.was_removed() || c1.lit() != sat::null_literal) { return; } - clause_vector removed_clauses; + sat::clause_vector removed_clauses; init_visited(); for (literal l : c1) mark_visited(l); for (unsigned i = 0; i < std::min(c1.size(), c1.k() + 1); ++i) { @@ -3071,8 +3015,8 @@ namespace sat { } } - void ba_solver::subsumption(pb& p1) { - if (p1.was_removed() || p1.lit() != null_literal) { + void solver::subsumption(pbc& p1) { + if (p1.was_removed() || p1.lit() != sat::null_literal) { return; } init_visited(); @@ -3090,15 +3034,15 @@ namespace sat { } } - void ba_solver::clauses_modifed() {} + void solver::clauses_modifed() {} - lbool ba_solver::get_phase(bool_var v) { return l_undef; } + lbool solver::get_phase(bool_var v) { return l_undef; } /* \brief lit <=> conjunction of unconstrained lits */ - void ba_solver::assert_unconstrained(literal lit, literal_vector const& lits) { - if (lit == null_literal) { + void solver::assert_unconstrained(literal lit, literal_vector const& lits) { + if (lit == sat::null_literal) { for (literal l : lits) { if (value(l) == l_undef) { s().assign_scoped(l); @@ -3120,35 +3064,35 @@ namespace sat { } } - extension* ba_solver::copy(solver* s) { + sat::extension* solver::copy(sat::solver* s) { return clone_aux(m, *s, si, m_id); } - euf::th_solver* ba_solver::clone(euf::solver& new_ctx) { + euf::th_solver* solver::clone(euf::solver& new_ctx) { return clone_aux(new_ctx.get_manager(), new_ctx.s(), new_ctx.get_si(), get_id()); } - euf::th_solver* ba_solver::clone_aux(ast_manager& m, sat::solver& s, sat::sat_internalizer& si, euf::theory_id id) { - ba_solver* result = alloc(ba_solver, m, si, id); + euf::th_solver* solver::clone_aux(ast_manager& m, sat::solver& s, sat::sat_internalizer& si, euf::theory_id id) { + solver* result = alloc(solver, m, si, id); result->set_solver(&s); copy_constraints(result, m_constraints); return result; } - void ba_solver::copy_constraints(ba_solver* result, ptr_vector const& constraints) { + void solver::copy_constraints(solver* result, ptr_vector const& constraints) { literal_vector lits; svector wlits; for (constraint* cp : constraints) { switch (cp->tag()) { - case ba::tag_t::card_t: { + case pb::tag_t::card_t: { card const& c = cp->to_card(); lits.reset(); for (literal l : c) lits.push_back(l); result->add_at_least(c.lit(), lits, c.k(), c.learned()); break; } - case ba::tag_t::pb_t: { - pb const& p = cp->to_pb(); + case pb::tag_t::pb_t: { + pbc const& p = cp->to_pb(); wlits.reset(); for (wliteral w : p) { wlits.push_back(w); @@ -3162,11 +3106,11 @@ namespace sat { } } - void ba_solver::init_use_list(sat::ext_use_list& ul) { + void solver::init_use_list(sat::ext_use_list& ul) { ul.init(s().num_vars()); for (constraint const* cp : m_constraints) { - ext_constraint_idx idx = cp->cindex(); - if (cp->lit() != null_literal) { + sat::ext_constraint_idx idx = cp->cindex(); + if (cp->lit() != sat::null_literal) { ul.insert(cp->lit(), idx); ul.insert(~cp->lit(), idx); } @@ -3179,16 +3123,16 @@ namespace sat { // it occurs negatively in constraint c. // all literals in C are marked // - bool ba_solver::is_blocked(literal l, ext_constraint_idx idx) { + bool solver::is_blocked(literal l, sat::ext_constraint_idx idx) { constraint const& c = index2constraint(idx); - simplifier& sim = s().m_simplifier; - if (c.lit() != null_literal) return false; + sat::simplifier& sim = s().m_simplifier; + if (c.lit() != sat::null_literal) return false; return c.is_blocked(sim, l); } - void ba_solver::find_mutexes(literal_vector& lits, vector & mutexes) { - literal_set slits(lits); + void solver::find_mutexes(literal_vector& lits, vector & mutexes) { + sat::literal_set slits(lits); bool change = false; for (constraint* cp : m_constraints) { if (!cp->is_card()) continue; @@ -3218,7 +3162,7 @@ namespace sat { } } - void ba_solver::display(std::ostream& out, ineq const& ineq, bool values) const { + void solver::display(std::ostream& out, ineq const& ineq, bool values) const { for (unsigned i = 0; i < ineq.size(); ++i) { if (ineq.coeff(i) != 1) out << ineq.coeff(i) << "*"; out << ineq.lit(i) << " "; @@ -3228,7 +3172,7 @@ namespace sat { } - std::ostream& ba_solver::display(std::ostream& out) const { + std::ostream& solver::display(std::ostream& out) const { for (constraint const* c : m_constraints) { out << (*c) << "\n"; } @@ -3241,19 +3185,19 @@ namespace sat { return out; } - std::ostream& ba_solver::display_justification(std::ostream& out, ext_justification_idx idx) const { + std::ostream& solver::display_justification(std::ostream& out, sat::ext_justification_idx idx) const { return out << index2constraint(idx); } - std::ostream& ba_solver::display_constraint(std::ostream& out, ext_constraint_idx idx) const { + std::ostream& solver::display_constraint(std::ostream& out, sat::ext_constraint_idx idx) const { return out << index2constraint(idx); } - std::ostream& ba_solver::display(std::ostream& out, constraint const& c, bool values) const { + std::ostream& solver::display(std::ostream& out, constraint const& c, bool values) const { return c.display(out, *this, values); } - void ba_solver::collect_statistics(statistics& st) const { + void solver::collect_statistics(statistics& st) const { st.update("ba propagations", m_stats.m_num_propagations); st.update("ba conflicts", m_stats.m_num_conflicts); st.update("ba resolves", m_stats.m_num_resolves); @@ -3266,7 +3210,7 @@ namespace sat { } - bool ba_solver::validate_unit_propagation(pb const& p, literal_vector const& r, literal alit) const { + bool solver::validate_unit_propagation(pbc const& p, literal_vector const& r, literal alit) const { // all elements of r are true, for (literal l : r) { if (value(l) != l_true) { @@ -3320,7 +3264,7 @@ namespace sat { } - bool ba_solver::validate_lemma() { + bool solver::validate_lemma() { int64_t bound64 = m_bound; int64_t val = -bound64; reset_active_var_set(); @@ -3339,7 +3283,7 @@ namespace sat { /** * the slack of inequalities on the stack should be non-positive. */ - bool ba_solver::validate_ineq(ineq const& ineq) const { + bool solver::validate_ineq(ineq const& ineq) const { int64_t k = -static_cast(ineq.m_k); for (wliteral wl : ineq.m_wlits) { if (!is_false(wl.second)) @@ -3349,11 +3293,11 @@ namespace sat { return k <= 0; } - void ba_solver::reset_active_var_set() { + void solver::reset_active_var_set() { while (!m_active_var_set.empty()) m_active_var_set.erase(); } - bool ba_solver::test_and_set_active(bool_var v) { + bool solver::test_and_set_active(bool_var v) { if (m_active_var_set.contains(v)) { return false; } @@ -3363,17 +3307,17 @@ namespace sat { } } - void ba_solver::active2pb(ineq& p) { + void solver::active2pb(ineq& p) { p.reset(m_bound); active2wlits(p.m_wlits); } - void ba_solver::active2wlits() { + void solver::active2wlits() { m_wlits.reset(); active2wlits(m_wlits); } - void ba_solver::active2wlits(svector& wlits) { + void solver::active2wlits(svector& wlits) { uint64_t sum = 0; reset_active_var_set(); for (bool_var v : m_active_vars) { @@ -3386,11 +3330,11 @@ namespace sat { m_overflow |= sum >= UINT_MAX/2; } - constraint* ba_solver::active2lemma() { + constraint* solver::active2lemma() { switch (s().m_config.m_pb_lemma_format) { - case PB_LEMMA_CARDINALITY: + case sat::PB_LEMMA_CARDINALITY: return active2card(); - case PB_LEMMA_PB: + case sat::PB_LEMMA_PB: return active2constraint(); default: UNREACHABLE(); @@ -3398,12 +3342,12 @@ namespace sat { } } - constraint* ba_solver::active2constraint() { + constraint* solver::active2constraint() { active2wlits(); if (m_overflow) { return nullptr; } - constraint* c = add_pb_ge(null_literal, m_wlits, m_bound, true); + constraint* c = add_pb_ge(sat::null_literal, m_wlits, m_bound, true); TRACE("ba", if (c) display(tout, *c, true);); ++m_stats.m_num_lemmas; return c; @@ -3440,7 +3384,7 @@ namespace sat { }; - constraint* ba_solver::active2card() { + constraint* solver::active2card() { active2wlits(); if (m_overflow) { return nullptr; @@ -3497,7 +3441,7 @@ namespace sat { for (wliteral wl : m_wlits) { lits.push_back(wl.second); } - constraint* c = add_at_least(null_literal, lits, k, true); + constraint* c = add_at_least(sat::null_literal, lits, k, true); ++m_stats.m_num_lemmas; @@ -3513,34 +3457,34 @@ namespace sat { } - void ba_solver::justification2pb(justification const& js, literal lit, unsigned offset, ineq& ineq) { + void solver::justification2pb(sat::justification const& js, literal lit, unsigned offset, ineq& ineq) { switch (js.get_kind()) { - case justification::NONE: - SASSERT(lit != null_literal); + case sat::justification::NONE: + SASSERT(lit != sat::null_literal); ineq.reset(offset); ineq.push(lit, offset); break; - case justification::BINARY: - SASSERT(lit != null_literal); + case sat::justification::BINARY: + SASSERT(lit != sat::null_literal); ineq.reset(offset); ineq.push(lit, offset); ineq.push(js.get_literal(), offset); break; - case justification::TERNARY: - SASSERT(lit != null_literal); + case sat::justification::TERNARY: + SASSERT(lit != sat::null_literal); ineq.reset(offset); ineq.push(lit, offset); ineq.push(js.get_literal1(), offset); ineq.push(js.get_literal2(), offset); break; - case justification::CLAUSE: { + case sat::justification::CLAUSE: { ineq.reset(offset); - clause & c = s().get_clause(js); + sat::clause & c = s().get_clause(js); for (literal l : c) ineq.push(l, offset); break; } - case justification::EXT_JUSTIFICATION: { - ext_justification_idx index = js.get_ext_justification_idx(); + case sat::justification::EXT_JUSTIFICATION: { + sat::ext_justification_idx index = js.get_ext_justification_idx(); VERIFY(this == sat::constraint_base::to_extension(index)); constraint& cnstr = index2constraint(index); constraint2pb(cnstr, lit, offset, ineq); @@ -3552,20 +3496,20 @@ namespace sat { } } - void ba_solver::constraint2pb(constraint& cnstr, literal lit, unsigned offset, ineq& ineq) { + void solver::constraint2pb(constraint& cnstr, literal lit, unsigned offset, ineq& ineq) { switch (cnstr.tag()) { - case ba::tag_t::card_t: { + case pb::tag_t::card_t: { card& c = cnstr.to_card(); ineq.reset(static_cast(offset)*c.k()); for (literal l : c) ineq.push(l, offset); - if (c.lit() != null_literal) ineq.push(~c.lit(), offset*c.k()); + if (c.lit() != sat::null_literal) ineq.push(~c.lit(), offset*c.k()); break; } - case ba::tag_t::pb_t: { - pb& p = cnstr.to_pb(); + case pb::tag_t::pb_t: { + pbc& p = cnstr.to_pb(); ineq.reset(static_cast(offset) * p.k()); for (wliteral wl : p) ineq.push(wl.second, offset * wl.first); - if (p.lit() != null_literal) ineq.push(~p.lit(), offset * p.k()); + if (p.lit() != sat::null_literal) ineq.push(~p.lit(), offset * p.k()); break; } default: @@ -3576,7 +3520,7 @@ namespace sat { // validate that m_A & m_B implies m_C - bool ba_solver::validate_resolvent() { + bool solver::validate_resolvent() { return true; u_map coeffs; uint64_t k = m_A.m_k + m_B.m_k; @@ -3630,15 +3574,15 @@ namespace sat { violated: // last ditch effort by translating to SAT. - solver s0(s().m_params, s().rlimit()); + sat::solver s0(s().m_params, s().rlimit()); u_map translation; literal l1 = translate_to_sat(s0, translation, m_A); - if (l1 == null_literal) return true; + if (l1 == sat::null_literal) return true; literal l2 = translate_to_sat(s0, translation, m_B); - if (l2 == null_literal) return true; + if (l2 == sat::null_literal) return true; ineq notC = negate(m_B); literal l3 = translate_to_sat(s0, translation, notC); - if (l3 == null_literal) return true; + if (l3 == sat::null_literal) return true; s0.assign_scoped(l1); s0.assign_scoped(l2); s0.assign_scoped(l3); @@ -3651,7 +3595,7 @@ namespace sat { display(verbose_stream(), m_B); display(verbose_stream(), m_C); for (auto& e : coeffs) { - verbose_stream() << to_literal(e.m_key) << ": " << e.m_value << "\n"; + verbose_stream() << sat::to_literal(e.m_key) << ": " << e.m_value << "\n"; }); UNREACHABLE(); @@ -3661,7 +3605,7 @@ namespace sat { /** \brief translate PB inequality to SAT formula. */ - literal ba_solver::translate_to_sat(solver& s, u_map& translation, ineq const& pb) { + literal solver::translate_to_sat(sat::solver& s, u_map& translation, ineq const& pb) { SASSERT(pb.m_k > 0); if (pb.size() > 1) { ineq a, b; @@ -3687,21 +3631,21 @@ namespace sat { return translate_to_sat(s, translation, pb.lit(0)); } else { - return null_literal; + return sat::null_literal; } } /* \brief encode the case where Sum(a) >= k-1 & Sum(b) >= 1 \/ ... \/ Sum(a) >= 1 & Sum(b) >= k-1 */ - literal ba_solver::translate_to_sat(solver& s, u_map& translation, ineq& a, ineq& b) { + literal solver::translate_to_sat(sat::solver& s, u_map& translation, ineq& a, ineq& b) { uint64_t k0 = a.m_k; literal_vector lits; for (unsigned k = 1; k < a.m_k - 1; ++k) { a.m_k = k; b.m_k = k0 - k; literal lit1 = translate_to_sat(s, translation, a); literal lit2 = translate_to_sat(s, translation, b); - if (lit1 != null_literal && lit2 != null_literal) { + if (lit1 != sat::null_literal && lit2 != sat::null_literal) { bool_var v = s.mk_var(); literal lit(v, false); s.mk_clause(~lit, lit1); @@ -3712,7 +3656,7 @@ namespace sat { a.m_k = k0; b.m_k = k0; switch (lits.size()) { - case 0: return null_literal; + case 0: return sat::null_literal; case 1: return lits[0]; default: { bool_var v = s.mk_var(); @@ -3724,7 +3668,7 @@ namespace sat { } } - literal ba_solver::translate_to_sat(solver& s, u_map& translation, literal lit) { + literal solver::translate_to_sat(sat::solver& s, u_map& translation, literal lit) { bool_var v; if (!translation.find(lit.var(), v)) { v = s.mk_var(); @@ -3733,7 +3677,7 @@ namespace sat { return literal(v, lit.sign()); } - ba_solver::ineq ba_solver::negate(ineq const& a) const { + solver::ineq solver::negate(ineq const& a) const { ineq result; uint64_t sum = 0; for (unsigned i = 0; i < a.size(); ++i) { @@ -3745,13 +3689,13 @@ namespace sat { return result; } - void ba_solver::push_lit(literal_vector& lits, literal lit) { - if (lit != null_literal) { + void solver::push_lit(literal_vector& lits, literal lit) { + if (lit != sat::null_literal) { lits.push_back(lit); } } - bool ba_solver::validate_conflict(literal_vector const& lits, ineq& p) { + bool solver::validate_conflict(literal_vector const& lits, ineq& p) { for (literal l : lits) { if (value(l) != l_false) { TRACE("ba", tout << "literal " << l << " is not false\n";); @@ -3775,13 +3719,13 @@ namespace sat { return value < p.m_k; } - bool ba_solver::check_model(model const& m) const { + bool solver::check_model(sat::model const& m) const { bool ok = true; for (constraint const* c : m_constraints) { if (c->was_removed()) { continue; } - if (c->is_pure() && c->lit() != null_literal && m[c->lit().var()] == (c->lit().sign() ? l_true : l_false)) { + if (c->is_pure() && c->lit() != sat::null_literal && m[c->lit().var()] == (c->lit().sign() ? l_true : l_false)) { continue; } switch (eval(m, *c)) { @@ -3799,19 +3743,19 @@ namespace sat { return ok; } - bool ba_solver::extract_pb(std::function& add_cardinality, + bool solver::extract_pb(std::function& add_cardinality, std::function& add_pb) { unsigned_vector coeffs; literal_vector lits; for (constraint* cp : m_constraints) { switch (cp->tag()) { - case ba::tag_t::card_t: { + case pb::tag_t::card_t: { card const& c = cp->to_card(); unsigned n = c.size(); unsigned k = c.k(); - if (c.lit() == null_literal) { + if (c.lit() == sat::null_literal) { // c.lits() >= k // <=> // ~c.lits() <= n - k @@ -3844,14 +3788,14 @@ namespace sat { } break; } - case ba::tag_t::pb_t: { - pb const& p = cp->to_pb(); + case pb::tag_t::pb_t: { + pbc const& p = cp->to_pb(); lits.reset(); coeffs.reset(); unsigned sum = 0; for (wliteral wl : p) sum += wl.first; - if (p.lit() == null_literal) { + if (p.lit() == sat::null_literal) { // w1 + .. + w_n >= k // <=> // ~wl + ... + ~w_n <= sum_of_weights - k diff --git a/src/sat/smt/ba_solver.h b/src/sat/smt/pb_solver.h similarity index 75% rename from src/sat/smt/ba_solver.h rename to src/sat/smt/pb_solver.h index 103136189..a3b75300a 100644 --- a/src/sat/smt/ba_solver.h +++ b/src/sat/smt/pb_solver.h @@ -25,23 +25,22 @@ Revision History: #include "sat/sat_big.h" #include "sat/smt/sat_smt.h" #include "sat/smt/sat_th.h" -#include "sat/smt/ba_constraint.h" -#include "sat/smt/ba_card.h" -#include "sat/smt/ba_pb.h" +#include "sat/smt/pb_constraint.h" +#include "sat/smt/pb_card.h" +#include "sat/smt/pb_pb.h" #include "util/small_object_allocator.h" #include "util/scoped_ptr_vector.h" #include "util/sorting_network.h" #include "ast/pb_decl_plugin.h" -namespace sat { +namespace pb { - typedef ba::constraint constraint; - typedef ba::wliteral wliteral; - typedef ba::card card; - typedef ba::pb_base pb_base; - typedef ba::pb pb; + typedef pb::constraint constraint; + typedef pb::wliteral wliteral; + typedef pb::card card; + typedef pb::pbc pbc; - class ba_solver : public euf::th_solver, public ba::solver_interface { + class solver : public euf::th_solver, public pb::solver_interface { friend class local_search; @@ -78,16 +77,16 @@ namespace sat { bool contains(literal l) const { for (auto wl : m_wlits) if (wl.second == l) return true; return false; } }; - sat_internalizer& si; + sat::sat_internalizer& si; pb_util m_pb; - lookahead* m_lookahead{ nullptr }; + sat::lookahead* m_lookahead{ nullptr }; stats m_stats; small_object_allocator m_allocator; - ptr_vector m_constraints; - ptr_vector m_learned; - ptr_vector m_constraint_to_reinit; + ptr_vector m_constraints; + ptr_vector m_learned; + ptr_vector m_constraint_to_reinit; unsigned_vector m_constraint_to_reinit_lim; unsigned m_constraint_to_reinit_last_sz{ 0 }; unsigned m_constraint_id{ 0 }; @@ -111,12 +110,12 @@ namespace sat { typedef sat::literal pliteral; typedef sat::literal_vector pliteral_vector; - ba_solver& s; + solver& s; pliteral m_true; pliteral_vector m_lits; - ba_sort(ba_solver& s): s(s), m_true(null_literal) {} + ba_sort(solver& s): s(s), m_true(sat::null_literal) {} pliteral mk_false(); pliteral mk_true(); pliteral mk_not(pliteral l); @@ -137,7 +136,7 @@ namespace sat { // simplification routines vector> m_cnstr_use_list; - use_list m_clause_use_list; + sat::use_list m_clause_use_list; bool m_simplify_change{ false }; bool m_clause_removed{ false }; bool m_constraint_removed{ false }; @@ -149,13 +148,13 @@ namespace sat { euf::th_solver* clone_aux(ast_manager& m, sat::solver& s, sat::sat_internalizer& si, euf::theory_id id); bool subsumes(card& c1, card& c2, literal_vector& comp); - bool subsumes(card& c1, clause& c2, bool& self); + bool subsumes(card& c1, sat::clause& c2, bool& self); bool subsumed(card& c1, literal l1, literal l2); - bool subsumes(pb const& p1, pb_base const& p2); - void subsumes(pb& p1, literal lit); - void subsumption(pb& p1); + bool subsumes(pbc const& p1, constraint const& p2); + void subsumes(pbc& p1, literal lit); + void subsumption(pbc& p1); void binary_subsumption(card& c1, literal lit); - void clause_subsumption(card& c1, literal lit, clause_vector& removed_clauses); + void clause_subsumption(card& c1, literal lit, sat::clause_vector& removed_clauses); void card_subsumption(card& c1, literal lit); unsigned get_num_unblocked_bin(literal l); literal get_min_occurrence_literal(card const& c); @@ -165,9 +164,8 @@ namespace sat { unsigned elim_pure(); bool elim_pure(literal lit); void unit_strengthen(); - void unit_strengthen(big& big, ba::constraint& cs); - void unit_strengthen(big& big, pb_base& p); - void subsumption(ba::constraint& c1); + void unit_strengthen(sat::big& big, constraint& cs); + void subsumption(pb::constraint& c1); void subsumption(card& c1); void gc_half(char const* _method); void update_psm(constraint& c) const; @@ -178,23 +176,21 @@ namespace sat { unsigned use_count(literal lit) const { return m_cnstr_use_list[lit.index()].size() + m_clause_use_list.get(lit).size(); } void cleanup_clauses(); - void cleanup_clauses(clause_vector& clauses); + void cleanup_clauses(sat::clause_vector& clauses); void cleanup_constraints(); void cleanup_constraints(ptr_vector& cs, bool learned); void remove_constraint(constraint& c, char const* reason); void gc_vars(unsigned num_vars, ptr_vector& cs); // constraints - constraint& index2constraint(size_t idx) const { return *reinterpret_cast(constraint_base::from_index(idx)->mem()); } + constraint& index2constraint(size_t idx) const { return *reinterpret_cast(sat::constraint_base::from_index(idx)->mem()); } void pop_constraint(); - // void watch_literal(wliteral w, pb& p); void add_constraint(constraint* c); bool init_watch(constraint& c); void init_watch(bool_var v); void clear_watch(constraint& c); lbool add_assign(constraint& c, literal l); bool incremental_mode() const; - void simplify(constraint& c); void set_conflict(constraint& c, literal lit) override; void assign(constraint& c, literal lit) override; bool assigned_above(literal above, literal below); @@ -206,7 +202,7 @@ namespace sat { void attach_constraint(constraint const& c); void detach_constraint(constraint const& c); lbool eval(constraint const& c) const; - lbool eval(model const& m, constraint const& c) const; + lbool eval(sat::model const& m, constraint const& c) const; lbool eval(lbool a, lbool b) const; void assert_unconstrained(literal lit, literal_vector const& lits); void flush_roots(constraint& c); @@ -214,7 +210,7 @@ namespace sat { void split_root(constraint& c); unsigned next_id() { return m_constraint_id++; } void set_non_learned(constraint& c); - double get_reward(literal l, ext_justification_idx idx, literal_occs_fun& occs) const override; + double get_reward(literal l, sat::ext_justification_idx idx, sat::literal_occs_fun& occs) const override; // cardinality lbool add_assign(card& c, literal lit); @@ -225,25 +221,24 @@ namespace sat { void recompile(card& c); bool clausify(card& c); bool clausify(literal lit, unsigned n, literal const* lits, unsigned k); + lbool eval(card const& c) const; - lbool eval(model const& m, card const& c) const; // pb functionality unsigned m_a_max{ 0 }; - lbool add_assign(pb& p, literal alit); - void add_index(pb& p, unsigned index, literal lit); - void get_antecedents(literal l, pb const& p, literal_vector & r); - void split_root(pb_base& p); - void simplify(pb_base& p); - void simplify2(pb& p); - bool is_cardinality(pb const& p); - void flush_roots(pb& p); - void recompile(pb& p); - bool clausify(pb& p); - bool is_cardinality(pb const& p, literal_vector& lits); - lbool eval(pb const& p) const; - lbool eval(model const& m, pb const& p) const; + lbool add_assign(pbc& p, literal alit); + void add_index(pbc& p, unsigned index, literal lit); + void get_antecedents(literal l, pbc const& p, literal_vector & r); + void simplify(constraint& p); + void simplify2(pbc& p); + bool is_cardinality(pbc const& p); + void flush_roots(pbc& p); + void recompile(pbc& p); + bool clausify(pbc& p); + bool is_cardinality(pbc const& p, literal_vector& lits); + lbool eval(pbc const& p) const; + lbool eval(model const& m, constraint const& p) const; // RoundingPb conflict resolution lbool resolve_conflict_rs(); @@ -275,17 +270,17 @@ namespace sat { if (m_lookahead) return m_lookahead->inconsistent(); return m_solver->inconsistent(); } - inline watch_list& get_wlist(literal l) override { return m_lookahead ? m_lookahead->get_wlist(l) : m_solver->get_wlist(l); } - inline watch_list const& get_wlist(literal l) const override { return m_lookahead ? m_lookahead->get_wlist(l) : m_solver->get_wlist(l); } - inline void assign(literal l, justification j) override { + inline sat::watch_list& get_wlist(literal l) override { return m_lookahead ? m_lookahead->get_wlist(l) : m_solver->get_wlist(l); } + inline sat:: watch_list const& get_wlist(literal l) const override { return m_lookahead ? m_lookahead->get_wlist(l) : m_solver->get_wlist(l); } + inline void assign(literal l, sat::justification j) override { if (m_lookahead) m_lookahead->assign(l); else m_solver->assign(l, j); } - inline void set_conflict(justification j, literal l) override { + inline void set_conflict(sat::justification j, literal l) override { if (m_lookahead) m_lookahead->set_conflict(); else m_solver->set_conflict(j, l); } - inline config const& get_config() const override { + inline sat::config const& get_config() const override { return m_lookahead ? m_lookahead->get_config() : m_solver->get_config(); } @@ -311,20 +306,20 @@ namespace sat { // validation utilities bool validate_conflict(card const& c) const; - bool validate_conflict(pb const& p) const; + bool validate_conflict(pbc const& p) const; bool validate_assign(literal_vector const& lits, literal lit); bool validate_lemma(); bool validate_ineq(ineq const& ineq) const; - bool validate_unit_propagation(pb const& p, literal_vector const& r, literal alit) const; + bool validate_unit_propagation(pbc const& p, literal_vector const& r, literal alit) const; bool validate_conflict(literal_vector const& lits, ineq& p); bool validate_watch_literals() const; bool validate_watch_literal(literal lit) const; bool validate_watched_constraint(constraint const& c) const; - bool validate_watch(pb const& p, literal alit) const; + bool validate_watch(pbc const& p, literal alit) const; bool is_watching(literal lit, constraint const& c) const; - literal translate_to_sat(solver& s, u_map& translation, ineq const& pb); - literal translate_to_sat(solver& s, u_map& translation, ineq& a, ineq& b); - literal translate_to_sat(solver& s, u_map& translation, literal lit); + literal translate_to_sat(sat::solver& s, u_map& translation, ineq const& pb); + literal translate_to_sat(sat::solver& s, u_map& translation, ineq& a, ineq& b); + literal translate_to_sat(sat::solver& s, u_map& translation, literal lit); ineq negate(ineq const& a) const; void push_lit(literal_vector& lits, literal lit); @@ -335,7 +330,7 @@ namespace sat { constraint* active2card(); void active2wlits(); void active2wlits(svector& wlits); - void justification2pb(justification const& j, literal lit, unsigned offset, ineq& p); + void justification2pb(sat::justification const& j, literal lit, unsigned offset, ineq& p); void constraint2pb(constraint& cnstr, literal lit, unsigned offset, ineq& p); bool validate_resolvent(); unsigned get_coeff(ineq const& pb, literal lit); @@ -346,10 +341,10 @@ namespace sat { constraint* add_at_least(literal l, literal_vector const& lits, unsigned k, bool learned); constraint* add_pb_ge(literal l, svector const& wlits, unsigned k, bool learned); bool all_distinct(literal_vector const& lits); - bool all_distinct(clause const& c); + bool all_distinct(sat::clause const& c); - void copy_core(ba_solver* result, bool learned); - void copy_constraints(ba_solver* result, ptr_vector const& constraints); + void copy_core(solver* result, bool learned); + void copy_constraints(solver* result, ptr_vector const& constraints); // Internalize literal convert_eq_k(app* t, rational const& k, bool root, bool sign); @@ -366,23 +361,23 @@ namespace sat { literal internalize_pb(expr* e, bool sign, bool root); // Decompile expr_ref get_card(std::function& l2e, card const& c); - expr_ref get_pb(std::function& l2e, pb const& p); + expr_ref get_pb(std::function& l2e, pbc const& p); public: - ba_solver(euf::solver& ctx, euf::theory_id id); - ba_solver(ast_manager& m, sat::sat_internalizer& si, euf::theory_id id); - ~ba_solver() override; - void set_lookahead(lookahead* l) override { m_lookahead = l; } + solver(euf::solver& ctx, euf::theory_id id); + solver(ast_manager& m, sat::sat_internalizer& si, euf::theory_id id); + ~solver() override; + void set_lookahead(sat::lookahead* l) override { m_lookahead = l; } void add_at_least(bool_var v, literal_vector const& lits, unsigned k); void add_pb_ge(bool_var v, svector const& wlits, unsigned k); bool is_external(bool_var v) override; - bool propagated(literal l, ext_constraint_idx idx) override; + bool propagated(literal l, sat::ext_constraint_idx idx) override; bool unit_propagate() override { return false; } lbool resolve_conflict() override; - void get_antecedents(literal l, ext_justification_idx idx, literal_vector & r, bool probing) override; + void get_antecedents(literal l, sat::ext_justification_idx idx, literal_vector & r, bool probing) override; void asserted(literal l) override; - check_result check() override; + sat::check_result check() override; void push() override; void pop(unsigned n) override; void pre_simplify() override {} @@ -392,18 +387,18 @@ namespace sat { bool set_root(literal l, literal r) override; void flush_roots() override; std::ostream& display(std::ostream& out) const override; - std::ostream& display_justification(std::ostream& out, ext_justification_idx idx) const override; - std::ostream& display_constraint(std::ostream& out, ext_constraint_idx idx) const override; + std::ostream& display_justification(std::ostream& out, sat::ext_justification_idx idx) const override; + std::ostream& display_constraint(std::ostream& out, sat::ext_constraint_idx idx) const override; void collect_statistics(statistics& st) const override; - extension* copy(solver* s) override; + extension* copy(sat::solver* s) override; void find_mutexes(literal_vector& lits, vector & mutexes) override; void pop_reinit() override; void gc() override; void gc_vars(unsigned num_vars) override; - bool is_extended_binary(ext_justification_idx idx, literal_vector & r) override; - void init_use_list(ext_use_list& ul) override; - bool is_blocked(literal l, ext_constraint_idx idx) override; - bool check_model(model const& m) const override; + bool is_extended_binary(sat::ext_justification_idx idx, literal_vector & r) override; + void init_use_list(sat::ext_use_list& ul) override; + bool is_blocked(literal l, sat::ext_constraint_idx idx) override; + bool check_model(sat::model const& m) const override; literal internalize(expr* e, bool sign, bool root, bool redundant) override; void internalize(expr* e, bool redundant) override; diff --git a/src/sat/smt/ba_solver_interface.h b/src/sat/smt/pb_solver_interface.h similarity index 97% rename from src/sat/smt/ba_solver_interface.h rename to src/sat/smt/pb_solver_interface.h index 5c6da6d31..30914fc3f 100644 --- a/src/sat/smt/ba_solver_interface.h +++ b/src/sat/smt/pb_solver_interface.h @@ -3,7 +3,7 @@ Copyright (c) 2017 Microsoft Corporation Module Name: - ba_solver_interface.h + pb_solver_interface.h Abstract: @@ -25,7 +25,7 @@ Revision History: #include "sat/smt/sat_smt.h" -namespace ba { +namespace pb { typedef sat::literal literal; typedef sat::bool_var bool_var; diff --git a/src/sat/tactic/goal2sat.cpp b/src/sat/tactic/goal2sat.cpp index bd99336c0..b626b3460 100644 --- a/src/sat/tactic/goal2sat.cpp +++ b/src/sat/tactic/goal2sat.cpp @@ -41,7 +41,7 @@ Notes: #include "sat/sat_cut_simplifier.h" #include "sat/sat_drat.h" #include "sat/tactic/goal2sat.h" -#include "sat/smt/ba_solver.h" +#include "sat/smt/pb_solver.h" #include "sat/smt/euf_solver.h" #include "sat/smt/sat_th.h" #include "sat/sat_params.hpp" @@ -635,10 +635,10 @@ struct goal2sat::imp : public sat::sat_internalizer { void convert_ba(app* t, bool root, bool sign) { SASSERT(!m_euf); - sat::extension* ext = dynamic_cast(m_solver.get_extension()); + sat::extension* ext = dynamic_cast(m_solver.get_extension()); euf::th_solver* th = nullptr; if (!ext) { - th = alloc(sat::ba_solver, m, *this, pb.get_family_id()); + th = alloc(pb::solver, m, *this, pb.get_family_id()); m_solver.set_extension(th); th->push_scopes(m_solver.num_scopes()); } @@ -1227,7 +1227,7 @@ struct sat2goal::imp { return expr_ref(lit2expr(mc, lit), m); }; expr_ref_vector fmls(m); - sat::ba_solver* ba = dynamic_cast(ext); + pb::solver* ba = dynamic_cast(ext); if (ba) { ba->to_formulas(l2e, fmls); } diff --git a/src/smt/arith_eq_adapter.cpp b/src/smt/arith_eq_adapter.cpp index de328a242..6f3828bd5 100644 --- a/src/smt/arith_eq_adapter.cpp +++ b/src/smt/arith_eq_adapter.cpp @@ -86,11 +86,11 @@ namespace smt { return; ast_manager & m = get_manager(); TRACE("arith_eq_adapter_mk_axioms", tout << "#" << n1->get_owner_id() << " #" << n2->get_owner_id() << "\n"; - tout << mk_ismt2_pp(n1->get_owner(), m) << "\n" << mk_ismt2_pp(n2->get_owner(), m) << "\n";); + tout << mk_ismt2_pp(n1->get_expr(), m) << "\n" << mk_ismt2_pp(n2->get_expr(), m) << "\n";); if (n1->get_owner_id() > n2->get_owner_id()) std::swap(n1, n2); - app * t1 = n1->get_owner(); - app * t2 = n2->get_owner(); + app * t1 = n1->get_expr(); + app * t2 = n2->get_expr(); if (m.are_distinct(t1, t2)) { expr_ref eq(m.mk_eq(t1, t2), m); ctx.internalize(eq, true); @@ -110,8 +110,8 @@ namespace smt { CTRACE("arith_eq_adapter_relevancy", !(ctx.is_relevant(n1) && ctx.is_relevant(n2)), tout << "is_relevant(n1): #" << n1->get_owner_id() << " " << ctx.is_relevant(n1) << "\n"; tout << "is_relevant(n2): #" << n2->get_owner_id() << " " << ctx.is_relevant(n2) << "\n"; - tout << mk_pp(n1->get_owner(), get_manager()) << "\n"; - tout << mk_pp(n2->get_owner(), get_manager()) << "\n"; + tout << pp(n1, get_manager()) << "\n"; + tout << pp(n2, get_manager()) << "\n"; ctx.display(tout);); // // The atoms d.m_t1_eq_t2, d.m_le, and d.m_ge should only be marked as relevant @@ -127,8 +127,8 @@ namespace smt { m_stats.m_num_eq_axioms++; TRACE("arith_eq_adapter_profile_detail", - tout << "mk_detail " << mk_bounded_pp(n1->get_owner(), m, 5) << " " << - mk_bounded_pp(n2->get_owner(), m, 5) << "\n";); + tout << "mk_detail " << mk_bounded_pp(n1->get_expr(), m, 5) << " " << + mk_bounded_pp(n2->get_expr(), m, 5) << "\n";); app_ref t1_eq_t2(m); t1_eq_t2 = ctx.mk_eq_atom(t1, t2); @@ -222,9 +222,9 @@ namespace smt { ctx.mk_th_axiom(tid, le_lit, ge_lit, m_proof_hint.size(), m_proof_hint.c_ptr()); } if (ctx.relevancy()) { - relevancy_eh * eh = ctx.mk_relevancy_eh(arith_eq_relevancy_eh(n1->get_owner(), n2->get_owner(), t1_eq_t2, le, ge)); - ctx.add_relevancy_eh(n1->get_owner(), eh); - ctx.add_relevancy_eh(n2->get_owner(), eh); + relevancy_eh * eh = ctx.mk_relevancy_eh(arith_eq_relevancy_eh(n1->get_expr(), n2->get_expr(), t1_eq_t2, le, ge)); + ctx.add_relevancy_eh(n1->get_expr(), eh); + ctx.add_relevancy_eh(n2->get_expr(), eh); } if (!m_owner.get_fparams().m_arith_lazy_adapter && !ctx.at_base_level() && n1->get_iscope_lvl() <= ctx.get_base_level() && n2->get_iscope_lvl() <= ctx.get_base_level()) { @@ -235,7 +235,7 @@ namespace smt { void arith_eq_adapter::new_eq_eh(theory_var v1, theory_var v2) { TRACE("arith_eq_adapter", tout << "v" << v1 << " = v" << v2 << " #" << get_enode(v1)->get_owner_id() << " = #" << get_enode(v2)->get_owner_id() << "\n";); - TRACE("arith_eq_adapter_bug", tout << mk_bounded_pp(get_enode(v1)->get_owner(), get_manager()) << "\n" << mk_bounded_pp(get_enode(v2)->get_owner(), get_manager()) << "\n";); + TRACE("arith_eq_adapter_bug", tout << mk_bounded_pp(get_enode(v1)->get_expr(), get_manager()) << "\n" << mk_bounded_pp(get_enode(v2)->get_expr(), get_manager()) << "\n";); mk_axioms(get_enode(v1), get_enode(v2)); } diff --git a/src/smt/mam.cpp b/src/smt/mam.cpp index 30b3fcee4..14c7e048f 100644 --- a/src/smt/mam.cpp +++ b/src/smt/mam.cpp @@ -2027,7 +2027,7 @@ namespace { init(t); if (t->filter_candidates()) { for (enode* app : t->get_candidates()) { - TRACE("trigger_bug", tout << "candidate\n" << mk_ismt2_pp(app->get_owner(), m) << "\n";); + TRACE("trigger_bug", tout << "candidate\n" << mk_ismt2_pp(app->get_expr(), m) << "\n";); if (!app->is_marked() && app->is_cgr()) { if (m_context.resource_limits_exceeded() || !execute_core(t, app)) return; @@ -2041,7 +2041,7 @@ namespace { } else { for (enode* app : t->get_candidates()) { - TRACE("trigger_bug", tout << "candidate\n" << mk_ismt2_pp(app->get_owner(), m) << "\n";); + TRACE("trigger_bug", tout << "candidate\n" << mk_ismt2_pp(app->get_expr(), m) << "\n";); if (app->is_cgr()) { TRACE("trigger_bug", tout << "is_cgr\n";); if (m_context.resource_limits_exceeded() || !execute_core(t, app)) @@ -2244,7 +2244,7 @@ namespace { if (m_use_filters) out << ", lbls: " << n->get_root()->get_lbls() << " "; out << "\n"; - out << mk_pp(n->get_owner(), m) << "\n"; + out << mk_pp(n->get_expr(), m) << "\n"; } } @@ -2287,7 +2287,7 @@ namespace { #endif bool interpreter::execute_core(code_tree * t, enode * n) { - TRACE("trigger_bug", tout << "interpreter::execute_core\n"; t->display(tout); tout << "\nenode\n" << mk_ismt2_pp(n->get_owner(), m) << "\n";); + TRACE("trigger_bug", tout << "interpreter::execute_core\n"; t->display(tout); tout << "\nenode\n" << mk_ismt2_pp(n->get_expr(), m) << "\n";); unsigned since_last_check = 0; #ifdef _PROFILE_MAM @@ -2473,7 +2473,7 @@ namespace { m_app = get_first_f_app(static_cast(m_pc)->m_label, static_cast(m_pc)->m_num_args, m_n1); \ if (!m_app) \ goto backtrack; \ - TRACE("mam_int", tout << "bind candidate: " << mk_pp(m_app->get_owner(), m) << "\n";); \ + TRACE("mam_int", tout << "bind candidate: " << mk_pp(m_app->get_expr(), m) << "\n";); \ m_backtrack_stack[m_top].m_instr = m_pc; \ m_backtrack_stack[m_top].m_old_max_generation = m_curr_max_generation; \ m_backtrack_stack[m_top].m_old_used_enodes_size = m_curr_used_enodes_size; \ @@ -2623,7 +2623,7 @@ namespace { #define SET_VAR(IDX) \ m_args[IDX] = m_registers[static_cast(m_pc)->m_iregs[IDX]]; \ if (m_use_filters && static_cast(m_pc)->m_lbl_set.empty_intersection(m_args[IDX]->get_root()->get_plbls())) { \ - TRACE("trigger_bug", tout << "m_args[IDX]->get_root():\n" << mk_ismt2_pp(m_args[IDX]->get_root()->get_owner(), m) << "\n"; \ + TRACE("trigger_bug", tout << "m_args[IDX]->get_root():\n" << mk_ismt2_pp(m_args[IDX]->get_root()->get_expr(), m) << "\n"; \ tout << "cgr set: "; static_cast(m_pc)->m_lbl_set.display(tout); tout << "\n"; \ tout << "node set: "; m_args[IDX]->get_root()->get_plbls().display(tout); tout << "\n";); \ goto backtrack; \ @@ -2687,7 +2687,7 @@ namespace { if (m_app == nullptr) goto backtrack; m_pattern_instances.push_back(m_app); - TRACE("mam_int", tout << "continue candidate:\n" << mk_ll_pp(m_app->get_owner(), m);); + TRACE("mam_int", tout << "continue candidate:\n" << mk_ll_pp(m_app->get_expr(), m);); for (unsigned i = 0; i < m_num_args; i++) m_registers[m_oreg+i] = m_app->get_arg(i); m_pc = m_pc->m_next; @@ -2750,7 +2750,7 @@ namespace { goto backtrack; \ } \ bp.m_curr = m_app; \ - TRACE("mam_int", tout << "bind next candidate:\n" << mk_ll_pp(m_app->get_owner(), m);); \ + TRACE("mam_int", tout << "bind next candidate:\n" << mk_ll_pp(m_app->get_expr(), m);); \ m_oreg = m_b->m_oreg BBIND_COMMON(); @@ -2830,7 +2830,7 @@ namespace { m_pattern_instances.push_back(m_app); // continue succeeded update_max_generation(m_app, nullptr); // null indicates a top-level match - TRACE("mam_int", tout << "continue next candidate:\n" << mk_ll_pp(m_app->get_owner(), m);); + TRACE("mam_int", tout << "continue next candidate:\n" << mk_ll_pp(m_app->get_expr(), m);); m_num_args = c->m_num_args; m_oreg = c->m_oreg; for (unsigned i = 0; i < m_num_args; i++) @@ -3163,7 +3163,7 @@ namespace { void add_candidate(code_tree * t, enode * app) { if (t != nullptr) { - TRACE("mam_candidate", tout << "adding candidate:\n" << mk_ll_pp(app->get_owner(), m);); + TRACE("mam_candidate", tout << "adding candidate:\n" << mk_ll_pp(app->get_expr(), m);); if (!t->has_candidates()) m_to_match.push_back(t); t->add_candidate(app); @@ -3221,7 +3221,7 @@ namespace { if (!r_plbls.may_contain(elem)) { m_trail_stack.push(mam_value_trail(r_plbls)); r_plbls.insert(elem); - TRACE("trigger_bug", tout << "updating plabels of:\n" << mk_ismt2_pp(c->get_root()->get_owner(), m) << "\n"; + TRACE("trigger_bug", tout << "updating plabels of:\n" << mk_ismt2_pp(c->get_root()->get_expr(), m) << "\n"; tout << "new_elem: " << static_cast(elem) << "\n"; tout << "plbls: " << c->get_root()->get_plbls() << "\n";); TRACE("mam_bug", tout << "updating plabels of: #" << c->get_root()->get_owner_id() << "\n"; @@ -3610,7 +3610,7 @@ namespace { bool is_flat_assoc = lbl->is_flat_associative(); enode * curr_parent_root = curr_parent->get_root(); enode * curr_parent_cg = curr_parent->get_cg(); - TRACE("mam_path_tree", tout << "processing parent:\n" << mk_pp(curr_parent->get_owner(), m) << "\n";); + TRACE("mam_path_tree", tout << "processing parent:\n" << mk_pp(curr_parent->get_expr(), m) << "\n";); TRACE("mam_path_tree", tout << "parent is marked: " << curr_parent->is_marked() << "\n";); if (filter.may_contain(m_lbl_hasher(lbl)) && !curr_parent->is_marked() && @@ -3639,7 +3639,7 @@ namespace { is_eq(curr_tree->m_ground_arg, curr_parent->get_arg(curr_tree->m_ground_arg_idx)) )) { if (curr_tree->m_code) { - TRACE("mam_path_tree", tout << "found candidate " << expr_ref(curr_parent->get_owner(), m) << "\n";); + TRACE("mam_path_tree", tout << "found candidate " << expr_ref(curr_parent->get_expr(), m) << "\n";); add_candidate(curr_tree->m_code, curr_parent); } if (curr_tree->m_first_child) { @@ -3941,7 +3941,7 @@ namespace { TRACE("missing_instance", tout << "qa:\n" << mk_ll_pp(qa, m) << "\npat:\n" << mk_ll_pp(pat, m); for (unsigned i = 0; i < num_bindings; i++) - tout << "#" << bindings[i]->get_expr_id() << "\n" << mk_ll_pp(bindings[i]->get_owner(), m) << "\n"; + tout << "#" << bindings[i]->get_expr_id() << "\n" << mk_ll_pp(bindings[i]->get_expr(), m) << "\n"; ); UNREACHABLE(); } @@ -3963,7 +3963,7 @@ namespace { // This method is invoked when n becomes relevant. // If lazy == true, then n is not added to the list of candidate enodes for matching. That is, the method just updates the lbls. void relevant_eh(enode * n, bool lazy) override { - TRACE("trigger_bug", tout << "relevant_eh:\n" << mk_ismt2_pp(n->get_owner(), m) << "\n"; + TRACE("trigger_bug", tout << "relevant_eh:\n" << mk_ismt2_pp(n->get_expr(), m) << "\n"; tout << "mam: " << this << "\n";); TRACE("mam", tout << "relevant_eh: #" << n->get_owner_id() << "\n";); if (n->has_lbl_hash()) @@ -3979,7 +3979,7 @@ namespace { update_lbls(n, h); if (is_plbl(lbl)) update_children_plbls(n, h); - TRACE("mam_bug", tout << "adding relevant candidate:\n" << mk_ll_pp(n->get_owner(), m) << "\n";); + TRACE("mam_bug", tout << "adding relevant candidate:\n" << mk_ll_pp(n->get_expr(), m) << "\n";); if (!lazy) add_candidate(n); } diff --git a/src/smt/qi_queue.cpp b/src/smt/qi_queue.cpp index a7b03dc3e..cce8a6339 100644 --- a/src/smt/qi_queue.cpp +++ b/src/smt/qi_queue.cpp @@ -140,7 +140,7 @@ namespace smt { tout << "new instance of " << q->get_qid() << ", weight " << q->get_weight() << ", generation: " << generation << ", scope_level: " << m_context.get_scope_level() << ", cost: " << cost << "\n"; for (unsigned i = 0; i < f->get_num_args(); i++) { - tout << "#" << f->get_arg(i)->get_owner_id() << " d:" << f->get_arg(i)->get_owner()->get_depth() << " "; + tout << "#" << f->get_arg(i)->get_expr_id() << " d:" << f->get_arg(i)->get_expr()->get_depth() << " "; } tout << "\n";); TRACE("new_entries_bug", tout << "[qi:insert]\n";); @@ -223,7 +223,7 @@ namespace smt { auto* ebindings = m_subst(q, num_bindings); for (unsigned i = 0; i < num_bindings; ++i) - ebindings[i] = bindings[i]->get_owner(); + ebindings[i] = bindings[i]->get_expr(); expr_ref instance = m_subst(); TRACE("qi_queue", tout << "new instance:\n" << mk_pp(instance, m) << "\n";); @@ -271,7 +271,7 @@ namespace smt { if (m.proofs_enabled()) { expr_ref_vector bindings_e(m); for (unsigned i = 0; i < num_bindings; ++i) { - bindings_e.push_back(bindings[i]->get_owner()); + bindings_e.push_back(bindings[i]->get_expr()); } app * bare_lemma = m.mk_or(m.mk_not(q), instance); proof * qi_pr = m.mk_quant_inst(bare_lemma, num_bindings, bindings_e.c_ptr()); diff --git a/src/smt/seq_eq_solver.cpp b/src/smt/seq_eq_solver.cpp index a549305e4..735306d04 100644 --- a/src/smt/seq_eq_solver.cpp +++ b/src/smt/seq_eq_solver.cpp @@ -1110,7 +1110,7 @@ int theory_seq::find_fst_non_empty_idx(expr_ref_vector const& xs) { if (ctx.e_internalized(e)) { enode* root = ctx.get_enode(e)->get_root(); rational val; - if (m_autil.is_numeral(root->get_owner(), val) && val.is_zero()) { + if (m_autil.is_numeral(root->get_expr(), val) && val.is_zero()) { continue; } } @@ -1414,7 +1414,7 @@ bool theory_seq::check_length_coherence() { } enode* n = ensure_enode(e); enode* r = n->get_root(); - if (r != n && has_length(r->get_owner())) { + if (r != n && has_length(r->get_expr())) { continue; } if (add_length_to_eqc(e)) { diff --git a/src/smt/seq_offset_eq.cpp b/src/smt/seq_offset_eq.cpp index 275856d4f..a1f3426b8 100644 --- a/src/smt/seq_offset_eq.cpp +++ b/src/smt/seq_offset_eq.cpp @@ -59,10 +59,10 @@ void seq_offset_eq::len_offset(expr* e, int val) { enode* r1 = th.get_root(x); enode* r2 = th.get_root(y); for (enode* n1 : *r1) { - if (!seq.str.is_length(n1->get_owner(), e1)) + if (!seq.str.is_length(n1->get_expr(), e1)) continue; for (enode* n2 : *r2) { - if (!seq.str.is_length(n2->get_owner(), e2)) + if (!seq.str.is_length(n2->get_expr(), e2)) continue; if (r1->get_owner_id() > r2->get_owner_id()) { std::swap(r1, r2); @@ -83,11 +83,11 @@ void seq_offset_eq::len_offset(expr* e, int val) { void seq_offset_eq::prop_arith_to_len_offset() { rational val; for (enode* n : th.get_context().enodes()) { - if (a.is_numeral(n->get_owner(), val) && val.is_int32() && INT_MIN < val.get_int32()) { - TRACE("seq", tout << "offset: " << mk_pp(n->get_owner(), m) << "\n";); + if (a.is_numeral(n->get_expr(), val) && val.is_int32() && INT_MIN < val.get_int32()) { + TRACE("seq", tout << "offset: " << mk_pp(n->get_expr(), m) << "\n";); enode *next = n->get_next(); while (next != n) { - len_offset(next->get_owner(), val.get_int32()); + len_offset(next->get_expr(), val.get_int32()); next = next->get_next(); } } @@ -100,14 +100,14 @@ bool seq_offset_eq::find(enode* n1, enode* n2, int& offset) const { if (n1->get_owner_id() > n2->get_owner_id()) std::swap(n1, n2); return - !a.is_numeral(n1->get_owner()) && - !a.is_numeral(n2->get_owner()) && + !a.is_numeral(n1->get_expr()) && + !a.is_numeral(n2->get_expr()) && m_offset_equalities.find(n1, n2, offset); } bool seq_offset_eq::contains(enode* r) { r = r->get_root(); - return !a.is_numeral(r->get_owner()) && m_has_offset_equality.contains(r); + return !a.is_numeral(r->get_expr()) && m_has_offset_equality.contains(r); } bool seq_offset_eq::propagate() { diff --git a/src/smt/seq_regex.cpp b/src/smt/seq_regex.cpp index 0613e584d..c35e413ba 100644 --- a/src/smt/seq_regex.cpp +++ b/src/smt/seq_regex.cpp @@ -387,7 +387,7 @@ namespace smt { rewrite(regex); lits.push_back(~entry.m_lit); if (n1 != n2) - lits.push_back(~th.mk_eq(n1->get_owner(), n2->get_owner(), false)); + lits.push_back(~th.mk_eq(n1->get_expr(), n2->get_expr(), false)); } m_s_in_re.push_back(s_in_re(lit, s, regex)); th.get_trail_stack().push(push_back_vector>(m_s_in_re)); diff --git a/src/smt/smt_almost_cg_table.cpp b/src/smt/smt_almost_cg_table.cpp index b891c002d..0a0157446 100644 --- a/src/smt/smt_almost_cg_table.cpp +++ b/src/smt/smt_almost_cg_table.cpp @@ -77,7 +77,7 @@ namespace smt { } bool almost_cg_table::cg_eq::operator()(enode * n1, enode * n2) const { - if (n1->get_owner()->get_decl() != n2->get_owner()->get_decl()) + if (n1->get_expr()->get_decl() != n2->get_expr()->get_decl()) return false; unsigned num_args = n1->get_num_args(); if (num_args != n2->get_num_args()) diff --git a/src/smt/smt_arith_value.cpp b/src/smt/smt_arith_value.cpp index 8984fe981..a05c05bbf 100644 --- a/src/smt/smt_arith_value.cpp +++ b/src/smt/smt_arith_value.cpp @@ -119,7 +119,7 @@ namespace smt { expr_ref _val(m); enode* next = m_ctx->get_enode(e), *n = next; do { - e = next->get_owner(); + e = next->get_expr(); if (m_tha && m_tha->get_value(next, _val) && a.is_numeral(_val, val)) return true; if (m_thi && m_thi->get_value(next, _val) && a.is_numeral(_val, val)) return true; if (m_thr && m_thr->get_value(next, val)) return true; diff --git a/src/smt/smt_cg_table.cpp b/src/smt/smt_cg_table.cpp index c969cc559..774ca6b87 100644 --- a/src/smt/smt_cg_table.cpp +++ b/src/smt/smt_cg_table.cpp @@ -207,8 +207,8 @@ namespace smt { enode_bool_pair cg_table::insert(enode * n) { // it doesn't make sense to insert a constant. SASSERT(n->get_num_args() > 0); - SASSERT(!m_manager.is_and(n->get_owner())); - SASSERT(!m_manager.is_or(n->get_owner())); + SASSERT(!m_manager.is_and(n->get_expr())); + SASSERT(!m_manager.is_or(n->get_expr())); enode * n_prime; void * t = get_table(n); switch (static_cast(GET_TAG(t))) { diff --git a/src/smt/smt_checker.cpp b/src/smt/smt_checker.cpp index b124f3118..7e4627c41 100644 --- a/src/smt/smt_checker.cpp +++ b/src/smt/smt_checker.cpp @@ -102,7 +102,7 @@ namespace smt { } enode * e = get_enode_eq_to(a); if (e && e->is_bool() && m_context.is_relevant(e)) { - lbool val = m_context.get_assignment(e->get_owner()); + lbool val = m_context.get_assignment(e->get_expr()); return val != l_undef && is_true == (val == l_true); } return false; diff --git a/src/smt/smt_conflict_resolution.cpp b/src/smt/smt_conflict_resolution.cpp index d581ed4e5..1359fe3bd 100644 --- a/src/smt/smt_conflict_resolution.cpp +++ b/src/smt/smt_conflict_resolution.cpp @@ -107,7 +107,7 @@ namespace smt { SASSERT(m_antecedents); TRACE("conflict_", ast_manager& m = get_manager(); - tout << mk_pp(lhs->get_owner(), m) << " = " << mk_pp(rhs->get_owner(), m); + tout << mk_pp(lhs->get_expr(), m) << " = " << mk_pp(rhs->get_expr(), m); switch (js.get_kind()) { case eq_justification::AXIOM: tout << " axiom\n"; break; case eq_justification::EQUATION: @@ -129,7 +129,7 @@ namespace smt { break; case eq_justification::CONGRUENCE: { CTRACE("dyn_ack_target", !lhs->is_eq(), tout << "dyn_ack_target2: " << lhs->get_owner_id() << " " << rhs->get_owner_id() << "\n";); - m_dyn_ack_manager.used_cg_eh(lhs->get_owner(), rhs->get_owner()); + m_dyn_ack_manager.used_cg_eh(lhs->get_expr(), rhs->get_expr()); unsigned num_args = lhs->get_num_args(); SASSERT(num_args == rhs->get_num_args()); if (js.used_commutativity()) { @@ -177,7 +177,7 @@ namespace smt { enode * c = find_common_ancestor(n1, n2); eq_branch2literals(n1, c); eq_branch2literals(n2, c); - m_dyn_ack_manager.used_eq_eh(n1->get_owner(), n2->get_owner(), c->get_owner()); + m_dyn_ack_manager.used_eq_eh(n1->get_expr(), n2->get_expr(), c->get_expr()); } /** @@ -785,14 +785,14 @@ namespace smt { SASSERT(m.has_fact(pr)); expr* f1 = nullptr, *f2 = nullptr; app * fact = to_app(m.get_fact(pr)); - app * n1_owner = n1->get_owner(); - app * n2_owner = n2->get_owner(); + app * n1_owner = n1->get_expr(); + app * n2_owner = n2->get_expr(); bool is_eq = m.is_eq(fact, f1, f2); if (is_eq && is_quantifier(f1)) { - f1 = m_ctx.get_enode(f1)->get_owner(); + f1 = m_ctx.get_enode(f1)->get_expr(); } if (is_eq && is_quantifier(f2)) { - f2 = m_ctx.get_enode(f2)->get_owner(); + f2 = m_ctx.get_enode(f2)->get_expr(); } if (m.is_false(fact) && !m_ctx.is_true(n2) && !m_ctx.is_false(n2)) { pr = m.mk_hypothesis(m.mk_eq(n1_owner, n2_owner)); @@ -853,7 +853,7 @@ namespace smt { case eq_justification::CONGRUENCE: num_args = n1->get_num_args(); SASSERT(num_args == n2->get_num_args()); - SASSERT(n1->get_owner()->get_decl() == n2->get_owner()->get_decl()); + SASSERT(n1->get_expr()->get_decl() == n2->get_expr()->get_decl()); if (js.used_commutativity()) { bool visited = true; SASSERT(num_args == 2); @@ -876,8 +876,8 @@ namespace smt { } if (!visited) return nullptr; - app * e1 = n1->get_owner(); - app * e2 = n2->get_owner(); + app * e1 = n1->get_expr(); + app * e2 = n2->get_expr(); app * e2_prime = m.mk_app(e2->get_decl(), e2->get_arg(1), e2->get_arg(0)); proof * pr1 = nullptr; if (!prs.empty()) { @@ -908,7 +908,7 @@ namespace smt { } if (!visited) return nullptr; - proof * pr = m.mk_congruence(n1->get_owner(), n2->get_owner(), prs.size(), prs.c_ptr()); + proof * pr = m.mk_congruence(n1->get_expr(), n2->get_expr(), prs.size(), prs.c_ptr()); m_new_proofs.push_back(pr); return pr; } @@ -1218,7 +1218,7 @@ namespace smt { void conflict_resolution::mk_proof(enode * lhs, enode * rhs) { SASSERT(!m_eq2proof.contains(lhs, rhs)); if (lhs == rhs) { - proof* pr = m.mk_reflexivity(lhs->get_owner()); + proof* pr = m.mk_reflexivity(lhs->get_expr()); m_new_proofs.push_back(pr); m_eq2proof.insert(lhs, rhs, pr); return; @@ -1250,7 +1250,7 @@ namespace smt { for (unsigned i = 0; i < sz; i++) { tout << mk_ll_pp(prs1[i], m) << "\n"; }); - pr = m.mk_transitivity(prs1.size(), prs1.c_ptr(), lhs->get_owner(), rhs->get_owner()); + pr = m.mk_transitivity(prs1.size(), prs1.c_ptr(), lhs->get_expr(), rhs->get_expr()); } m_new_proofs.push_back(pr); TRACE("proof_gen_bug", tout << "eq2pr_saved: #" << lhs->get_owner_id() << " #" << rhs->get_owner_id() << "\n";); diff --git a/src/smt/smt_consequences.cpp b/src/smt/smt_consequences.cpp index 8760b1c8f..632b780dd 100644 --- a/src/smt/smt_consequences.cpp +++ b/src/smt/smt_consequences.cpp @@ -194,7 +194,7 @@ namespace smt { break; } } - else if (e_internalized(k) && m.are_distinct(v, get_enode(k)->get_root()->get_owner())) { + else if (e_internalized(k) && m.are_distinct(v, get_enode(k)->get_root()->get_expr())) { to_delete.push_back(k); } else if (get_assignment(mk_diseq(k, v)) == l_true) { diff --git a/src/smt/smt_context.cpp b/src/smt/smt_context.cpp index d97234515..ea5655fa2 100644 --- a/src/smt/smt_context.cpp +++ b/src/smt/smt_context.cpp @@ -469,7 +469,7 @@ namespace smt { TRACE("add_eq", tout << "redundant constraint.\n";); return; } - IF_VERBOSE(20, verbose_stream() << "merge " << mk_bounded_pp(n1->get_owner(), m) << " " << mk_bounded_pp(n2->get_owner(), m) << "\n"); + IF_VERBOSE(20, verbose_stream() << "merge " << mk_bounded_pp(n1->get_expr(), m) << " " << mk_bounded_pp(n2->get_expr(), m) << "\n"); if (r1->is_interpreted() && r2->is_interpreted()) { TRACE("add_eq", tout << "interpreted roots conflict.\n";); @@ -627,7 +627,7 @@ namespace smt { lbool val = get_assignment(v); if (val != l_true) { if (val == l_false && js.get_kind() == eq_justification::CONGRUENCE) - m_dyn_ack_manager.cg_conflict_eh(n1->get_owner(), n2->get_owner()); + m_dyn_ack_manager.cg_conflict_eh(n1->get_expr(), n2->get_expr()); assign(literal(v), mk_justification(eq_propagation_justification(lhs, rhs))); } @@ -755,7 +755,7 @@ namespace smt { enode * r2 = n2->get_root(); enode * r1 = n1->get_root(); if (!r1->has_th_vars() && !r2->has_th_vars()) { - TRACE("merge_theory_vars", tout << "Neither have theory vars #" << n1->get_owner()->get_id() << " #" << n2->get_owner()->get_id() << "\n";); + TRACE("merge_theory_vars", tout << "Neither have theory vars #" << n1->get_expr()->get_id() << " #" << n2->get_expr()->get_id() << "\n";); return; } @@ -891,7 +891,7 @@ namespace smt { lbool val2 = get_assignment(v2); if (val2 != val) { if (val2 != l_undef && congruent(source, target) && source->get_num_args() > 0) - m_dyn_ack_manager.cg_conflict_eh(source->get_owner(), target->get_owner()); + m_dyn_ack_manager.cg_conflict_eh(source->get_expr(), target->get_expr()); assign(literal(v2, sign), mk_justification(mp_iff_justification(source, target))); } target = target->get_next(); @@ -1041,10 +1041,10 @@ namespace smt { enode * r1 = n1->get_root(); enode * r2 = n2->get_root(); TRACE("add_diseq", tout << "assigning: #" << n1->get_owner_id() << " != #" << n2->get_owner_id() << "\n"; - tout << mk_ll_pp(n1->get_owner(), m) << " != "; - tout << mk_ll_pp(n2->get_owner(), m) << "\n"; - tout << mk_ll_pp(r1->get_owner(), m) << " != "; - tout << mk_ll_pp(r2->get_owner(), m) << "\n"; + tout << mk_ll_pp(n1->get_expr(), m) << " != "; + tout << mk_ll_pp(n2->get_expr(), m) << "\n"; + tout << mk_ll_pp(r1->get_expr(), m) << " != "; + tout << mk_ll_pp(r2->get_expr(), m) << "\n"; ); DEBUG_CODE( @@ -1102,13 +1102,13 @@ namespace smt { SASSERT(n1->get_sort() == n2->get_sort()); context * _this = const_cast(this); if (!m_is_diseq_tmp) { - app * eq = m.mk_eq(n1->get_owner(), n2->get_owner()); + app * eq = m.mk_eq(n1->get_expr(), n2->get_expr()); m.inc_ref(eq); _this->m_is_diseq_tmp = enode::mk_dummy(m, m_app2enode, eq); } - else if (m_is_diseq_tmp->get_owner()->get_arg(0)->get_sort() != n1->get_sort()) { - m.dec_ref(m_is_diseq_tmp->get_owner()); - app * eq = m.mk_eq(n1->get_owner(), n2->get_owner()); + else if (m_is_diseq_tmp->get_expr()->get_arg(0)->get_sort() != n1->get_sort()) { + m.dec_ref(m_is_diseq_tmp->get_expr()); + app * eq = m.mk_eq(n1->get_expr(), n2->get_expr()); m.inc_ref(eq); m_is_diseq_tmp->m_func_decl_id = UINT_MAX; m_is_diseq_tmp->m_owner = eq; @@ -1136,7 +1136,7 @@ namespace smt { if (n1->get_num_parents() > n2->get_num_parents()) std::swap(n1, n2); for (enode * parent : enode::parents(n1)) { - if (parent->is_eq() && is_relevant(parent->get_owner()) && get_assignment(enode2bool_var(parent)) == l_false && + if (parent->is_eq() && is_relevant(parent->get_expr()) && get_assignment(enode2bool_var(parent)) == l_false && ((parent->get_arg(0)->get_root() == n1->get_root() && parent->get_arg(1)->get_root() == n2->get_root()) || (parent->get_arg(1)->get_root() == n1->get_root() && parent->get_arg(0)->get_root() == n2->get_root()))) { TRACE("is_diseq_bug", tout << "parent: #" << parent->get_owner_id() << ", parent->root: #" << @@ -1253,14 +1253,14 @@ namespace smt { enode * r = m_cg_table.find(tmp); #ifdef Z3DEBUG if (r != nullptr) { - SASSERT(r->get_owner()->get_decl() == f); + SASSERT(r->get_expr()->get_decl() == f); SASSERT(r->get_num_args() == num_args); if (r->is_commutative()) { // TODO } else { for (unsigned i = 0; i < num_args; i++) { - expr * arg = r->get_owner()->get_arg(i); + expr * arg = r->get_expr()->get_arg(i); SASSERT(e_internalized(arg)); enode * _arg = get_enode(arg); CTRACE("eq_to_bug", args[i]->get_root() != _arg->get_root(), @@ -1434,7 +1434,7 @@ namespace smt { return; } theory_id th_id = th->get_id(); - TRACE("push_new_th_diseqs", tout << "#" << r->get_owner_id() << " " << mk_bounded_pp(r->get_owner(), m) << " v" << v << " th: " << th_id << "\n";); + TRACE("push_new_th_diseqs", tout << "#" << r->get_owner_id() << " " << mk_bounded_pp(r->get_expr(), m) << " v" << v << " th: " << th_id << "\n";); for (enode * parent : r->get_parents()) { CTRACE("parent_bug", parent == 0, tout << "#" << r->get_owner_id() << ", num_parents: " << r->get_num_parents() << "\n"; display(tout);); if (parent->is_eq()) { @@ -1518,7 +1518,7 @@ namespace smt { If the enode is not boolean, then return l_undef. */ lbool context::get_assignment(enode * n) const { - expr * owner = n->get_owner(); + expr * owner = n->get_expr(); if (!m.is_bool(owner)) return l_undef; if (n == m_false_enode) @@ -2953,7 +2953,7 @@ namespace smt { m_qmanager = nullptr; if (m_is_diseq_tmp) { m_is_diseq_tmp->del_eh(m, false); - m.dec_ref(m_is_diseq_tmp->get_owner()); + m.dec_ref(m_is_diseq_tmp->get_expr()); enode::del_dummy(m_is_diseq_tmp); m_is_diseq_tmp = nullptr; } @@ -4354,8 +4354,8 @@ namespace smt { bool context::assume_eq(enode * lhs, enode * rhs) { if (lhs->get_root() == rhs->get_root()) return false; // it is not necessary to assume the eq. - expr * _lhs = lhs->get_owner(); - expr * _rhs = rhs->get_owner(); + expr * _lhs = lhs->get_expr(); + expr * _rhs = rhs->get_expr(); expr * eq = mk_eq_atom(_lhs, _rhs); TRACE("assume_eq", tout << "creating interface eq:\n" << mk_pp(eq, m) << "\n";); if (m.is_false(eq)) { @@ -4412,7 +4412,7 @@ namespace smt { bool context::is_shared(enode * n) const { n = n->get_root(); unsigned num_th_vars = n->get_num_th_vars(); - if (m.is_ite(n->get_owner())) { + if (m.is_ite(n->get_expr())) { return true; } switch (num_th_vars) { @@ -4431,7 +4431,7 @@ namespace smt { theory_id th_id = l->get_id(); for (enode * parent : enode::parents(n)) { - app* p = parent->get_owner(); + app* p = parent->get_expr(); family_id fid = p->get_family_id(); if (fid != th_id && fid != m.get_basic_family_id()) { TRACE("is_shared", tout << enode_pp(n, *this) diff --git a/src/smt/smt_context.h b/src/smt/smt_context.h index 16d6f41cc..43718f229 100644 --- a/src/smt/smt_context.h +++ b/src/smt/smt_context.h @@ -297,7 +297,7 @@ namespace smt { } bool_var get_bool_var(enode const * n) const { - return get_bool_var(n->get_owner()); + return get_bool_var(n->get_expr()); } bool_var get_bool_var_of_id(unsigned id) const { @@ -1084,7 +1084,7 @@ namespace smt { void push_eq(enode * lhs, enode * rhs, eq_justification const & js) { if (lhs->get_root() != rhs->get_root()) { - SASSERT(lhs->get_owner()->get_sort() == rhs->get_owner()->get_sort()); + SASSERT(lhs->get_expr()->get_sort() == rhs->get_expr()->get_sort()); m_eq_propagation_queue.push_back(new_eq(lhs, rhs, js)); } } @@ -1269,7 +1269,7 @@ namespace smt { } bool is_relevant(enode * n) const { - return is_relevant(n->get_owner()); + return is_relevant(n->get_expr()); } bool is_relevant(bool_var v) const { @@ -1287,7 +1287,7 @@ namespace smt { void mark_as_relevant(expr * n) { m_relevancy_propagator->mark_as_relevant(n); m_relevancy_propagator->propagate(); } - void mark_as_relevant(enode * n) { mark_as_relevant(n->get_owner()); } + void mark_as_relevant(enode * n) { mark_as_relevant(n->get_expr()); } void mark_as_relevant(bool_var v) { mark_as_relevant(bool_var2expr(v)); } diff --git a/src/smt/smt_context_inv.cpp b/src/smt/smt_context_inv.cpp index 63a45d0d5..49ec0cbe8 100644 --- a/src/smt/smt_context_inv.cpp +++ b/src/smt/smt_context_inv.cpp @@ -160,7 +160,7 @@ namespace smt { if (n->is_true_eq() && n2->is_true_eq()) continue; CTRACE("missing_propagation", congruent(n, n2), - tout << mk_pp(n->get_owner(), m) << "\n" << mk_pp(n2->get_owner(), m) << "\n"; + tout << mk_pp(n->get_expr(), m) << "\n" << mk_pp(n2->get_expr(), m) << "\n"; display(tout);); SASSERT(!congruent(n, n2)); } @@ -171,12 +171,12 @@ namespace smt { bool context::check_missing_bool_enode_propagation() const { for (enode* n : m_enodes) { - if (m.is_bool(n->get_owner()) && get_assignment(n) == l_undef) { + if (m.is_bool(n->get_expr()) && get_assignment(n) == l_undef) { enode * first = n; do { CTRACE("missing_propagation", get_assignment(n) != l_undef, - tout << mk_pp(first->get_owner(), m) << "\nassignment: " << get_assignment(first) << "\n" - << mk_pp(n->get_owner(), m) << "\nassignment: " << get_assignment(n) << "\n";); + tout << mk_pp(first->get_expr(), m) << "\nassignment: " << get_assignment(first) << "\n" + << mk_pp(n->get_expr(), m) << "\nassignment: " << get_assignment(n) << "\n";); SASSERT(get_assignment(n) == l_undef); n = n->get_next(); } @@ -232,11 +232,11 @@ namespace smt { */ bool context::check_eqc_bool_assignment() const { for (enode* e : m_enodes) { - if (m.is_bool(e->get_owner())) { + if (m.is_bool(e->get_expr())) { enode * r = e->get_root(); CTRACE("eqc_bool", get_assignment(e) != get_assignment(r), - tout << "#" << e->get_expr_id() << "\n" << mk_pp(e->get_owner(), m) << "\n"; - tout << "#" << r->get_expr_id() << "\n" << mk_pp(r->get_owner(), m) << "\n"; + tout << "#" << e->get_expr_id() << "\n" << mk_pp(e->get_expr(), m) << "\n"; + tout << "#" << r->get_expr_id() << "\n" << mk_pp(r->get_expr(), m) << "\n"; tout << "assignments: " << get_assignment(e) << " " << get_assignment(r) << "\n"; display(tout);); SASSERT(get_assignment(e) == get_assignment(r)); @@ -270,8 +270,8 @@ namespace smt { for (bool_var v = 0; v < num; v++) { if (has_enode(v)) { enode * n = bool_var2enode(v); - if (n->is_eq() && is_relevant(n) && get_assignment(v) == l_false && !m.is_iff(n->get_owner())) { - TRACE("check_th_diseq_propagation", tout << "checking: #" << n->get_expr_id() << " " << mk_bounded_pp(n->get_owner(), m) << "\n";); + if (n->is_eq() && is_relevant(n) && get_assignment(v) == l_false && !m.is_iff(n->get_expr())) { + TRACE("check_th_diseq_propagation", tout << "checking: #" << n->get_expr_id() << " " << mk_bounded_pp(n->get_expr(), m) << "\n";); enode * lhs = n->get_arg(0)->get_root(); enode * rhs = n->get_arg(1)->get_root(); if (rhs->is_interpreted() && lhs->is_interpreted()) @@ -279,7 +279,7 @@ namespace smt { if (lhs == rhs) continue; TRACE("check_th_diseq_propagation", tout << "num. theory_vars: " << lhs->get_num_th_vars() << " " - << mk_pp(lhs->get_owner()->get_sort(), m) << "\n";); + << mk_pp(lhs->get_expr()->get_sort(), m) << "\n";); theory_var_list * l = lhs->get_th_var_list(); while (l) { theory_id th_id = l->get_id(); @@ -306,9 +306,9 @@ namespace smt { tout << "checking theory: " << m.get_family_name(th_id) << "\n" << "root: #" << n->get_root()->get_expr_id() << " node: #" << n->get_expr_id() << "\n" - << mk_pp(n->get_owner(), m) << "\n" + << mk_pp(n->get_expr(), m) << "\n" << "lhs: #" << lhs->get_expr_id() << ", rhs: #" << rhs->get_expr_id() << "\n" - << mk_bounded_pp(lhs->get_owner(), m) << " " << mk_bounded_pp(rhs->get_owner(), m) << "\n";); + << mk_bounded_pp(lhs->get_expr(), m) << " " << mk_bounded_pp(rhs->get_expr(), m) << "\n";); VERIFY(found); } l = l->get_next(); diff --git a/src/smt/smt_context_pp.cpp b/src/smt/smt_context_pp.cpp index 2f0c93fcf..e87d1122c 100644 --- a/src/smt/smt_context_pp.cpp +++ b/src/smt/smt_context_pp.cpp @@ -146,7 +146,7 @@ namespace smt { void context::display_enode_defs(std::ostream & out) const { for (enode * x : m_enodes) { - expr * n = x->get_owner(); + expr * n = x->get_expr(); ast_def_ll_pp(out, m, n, get_pp_visited(), true, false); } } @@ -246,8 +246,8 @@ namespace smt { void context::display_eqc(std::ostream & out) const { bool first = true; for (enode * x : m_enodes) { - expr * n = x->get_owner(); - expr * r = x->get_root()->get_owner(); + expr * n = x->get_expr(); + expr * r = x->get_root()->get_expr(); if (n != r) { if (first) { out << "equivalence classes:\n"; @@ -457,7 +457,7 @@ namespace smt { } for (unsigned i = 0; i < num_eq_antecedents; i++) { enode_pair const & p = eq_antecedents[i]; - n = m.mk_eq(p.first->get_owner(), p.second->get_owner()); + n = m.mk_eq(p.first->get_expr(), p.second->get_expr()); fmls.push_back(n); } if (consequent != false_literal) { @@ -509,14 +509,14 @@ namespace smt { out << std::left << n->get_owner_id() << " #"; out.width(5); out << n->get_root()->get_owner_id() << " := " << std::right; - unsigned num = n->get_owner()->get_num_args(); + unsigned num = n->get_expr()->get_num_args(); if (num > 0) out << "("; out << n->get_decl()->get_name(); if (!n->get_decl()->private_parameters()) display_parameters(out, n->get_decl()->get_num_parameters(), n->get_decl()->get_parameters()); for (unsigned i = 0; i < num; i++) { - expr * arg = n->get_owner()->get_arg(i); + expr * arg = n->get_expr()->get_arg(i); if (e_internalized(arg)) { enode * n = get_enode(arg)->get_root(); out << " #" << n->get_owner_id(); @@ -658,7 +658,7 @@ namespace smt { std::ostream& operator<<(std::ostream& out, enode_pp const& p) { ast_manager& m = p.ctx.get_manager(); enode* n = p.n; - return out << "[#" << n->get_owner_id() << " " << mk_bounded_pp(n->get_owner(), m) << "]"; + return out << "[#" << n->get_owner_id() << " " << mk_bounded_pp(n->get_expr(), m) << "]"; } std::ostream& operator<<(std::ostream& out, enode_eq_pp const& p) { diff --git a/src/smt/smt_enode.cpp b/src/smt/smt_enode.cpp index 7eeab6388..a54a287ec 100644 --- a/src/smt/smt_enode.cpp +++ b/src/smt/smt_enode.cpp @@ -277,7 +277,7 @@ namespace smt { bool congruent(enode * n1, enode * n2, bool & comm) { comm = false; - if (n1->get_owner()->get_decl() != n2->get_owner()->get_decl()) + if (n1->get_expr()->get_decl() != n2->get_expr()->get_decl()) return false; unsigned num_args = n1->get_num_args(); if (num_args != n2->get_num_args()) diff --git a/src/smt/smt_enode.h b/src/smt/smt_enode.h index 59dd75bc5..6e739a499 100644 --- a/src/smt/smt_enode.h +++ b/src/smt/smt_enode.h @@ -21,6 +21,7 @@ Revision History: #include "util/id_var_list.h" #include "util/approx_set.h" #include "ast/ast.h" +#include "ast/ast_pp.h" #include "smt/smt_types.h" #include "smt/smt_eq_justification.h" @@ -165,7 +166,6 @@ namespace smt { void del_eh(ast_manager & m, bool update_children_parent = true); - app * get_owner() const { return m_owner; } app * get_expr() const { return m_owner; } unsigned get_owner_id() const { return m_owner->get_id(); } @@ -453,6 +453,7 @@ namespace smt { void reset(); }; + inline mk_pp pp(enode* n, ast_manager& m) { return mk_pp(n->get_expr(), m); } }; diff --git a/src/smt/smt_induction.cpp b/src/smt/smt_induction.cpp index d5375b87e..895e8ae76 100644 --- a/src/smt/smt_induction.cpp +++ b/src/smt/smt_induction.cpp @@ -113,14 +113,14 @@ bool induction_lemmas::viable_induction_sort(sort* s) { } bool induction_lemmas::viable_induction_parent(enode* p, enode* n) { - app* o = p->get_owner(); + app* o = p->get_expr(); return m_rec.is_defined(o) || m_dt.is_constructor(o); } bool induction_lemmas::viable_induction_children(enode* n) { - app* e = n->get_owner(); + app* e = n->get_expr(); if (m.is_value(e)) return false; if (e->get_decl()->is_skolem()) @@ -136,7 +136,7 @@ bool induction_lemmas::viable_induction_children(enode* n) { bool induction_lemmas::viable_induction_term(enode* p, enode* n) { return - viable_induction_sort(n->get_owner()->get_sort()) && + viable_induction_sort(n->get_expr()->get_sort()) && viable_induction_parent(p, n) && viable_induction_children(n); } @@ -201,7 +201,7 @@ induction_lemmas::induction_positions_t induction_lemmas::induction_positions2(e } void induction_lemmas::initialize_levels(enode* n) { - expr_ref tmp(n->get_owner(), m); + expr_ref tmp(n->get_expr(), m); m_depth2terms.reset(); m_depth2terms.resize(get_depth(tmp) + 1); m_ts++; @@ -221,7 +221,7 @@ induction_lemmas::induction_combinations_t induction_lemmas::induction_combinati if (pos.size() > 6) { induction_positions_t r; for (auto const& p : pos) { - if (is_uninterp_const(p.first->get_owner())) + if (is_uninterp_const(p.first->get_expr())) r.push_back(p); } result.push_back(r); @@ -239,7 +239,7 @@ induction_lemmas::induction_combinations_t induction_lemmas::induction_combinati for (auto const& pos : result) { std::cout << "position\n"; for (auto const& p : pos) { - std::cout << mk_pp(p.first->get_owner(), m) << ":" << p.second << "\n"; + std::cout << mk_pp(p.first->get_expr(), m) << ":" << p.second << "\n"; } } return result; @@ -252,7 +252,7 @@ bool induction_lemmas::positions_dont_overlap(induction_positions_t const& posit auto mark = [&](expr* n) { m_marks[n->get_id()] = m_ts; }; auto is_marked = [&](expr* n) { return m_marks[n->get_id()] == m_ts; }; for (auto p : positions) - mark(p.first->get_owner()); + mark(p.first->get_expr()); // no term used for induction contains a subterm also used for induction. for (auto const& terms : m_depth2terms) { for (app* t : terms) { @@ -456,7 +456,7 @@ void induction_lemmas::apply_induction(literal lit, induction_positions_t const unsigned i = 0; for (auto const& p : positions) { - expr* t = p.first->get_owner()->get_arg(p.second); + expr* t = p.first->get_expr()->get_arg(p.second); if (term2skolem.contains(t)) continue; if (i == sks.size()) { @@ -500,7 +500,7 @@ void induction_lemmas::apply_induction(literal lit, induction_positions_t const expr* arg = to_app(t)->get_arg(i); found = false; for (auto const& p : positions) { - if (p.first->get_owner() == t && p.second == i) { + if (p.first->get_expr() == t && p.second == i) { args.push_back(term2skolem[arg]); found = true; break; @@ -558,10 +558,10 @@ induction::induction(context& ctx, ast_manager& m): // TBD: use smt_arith_value to also include state from arithmetic solver void induction::init_values() { for (enode* n : ctx.enodes()) - if (m.is_value(n->get_owner())) + if (m.is_value(n->get_expr())) for (enode* r : *n) if (r != n) { - vs.set_value(r->get_owner(), n->get_owner()); + vs.set_value(r->get_expr(), n->get_expr()); } } diff --git a/src/smt/smt_induction.h b/src/smt/smt_induction.h index 8db1a99ab..308b23dba 100644 --- a/src/smt/smt_induction.h +++ b/src/smt/smt_induction.h @@ -69,7 +69,7 @@ namespace smt { unsigned operator()(induction_term_and_position_t const& t) const { unsigned a = get_node_hash(t.m_term); for (auto const& p : t.m_positions) { - a = mk_mix(a, p.second, get_node_hash(p.first->get_owner())); + a = mk_mix(a, p.second, get_node_hash(p.first->get_expr())); } return a; } diff --git a/src/smt/smt_justification.cpp b/src/smt/smt_justification.cpp index 34fe21e77..573db1a78 100644 --- a/src/smt/smt_justification.cpp +++ b/src/smt/smt_justification.cpp @@ -139,8 +139,8 @@ namespace smt { if (!visited) return nullptr; - expr * lhs = m_node1->get_root()->get_owner(); - expr * rhs = m_node2->get_root()->get_owner(); + expr * lhs = m_node1->get_root()->get_expr(); + expr * rhs = m_node2->get_root()->get_expr(); proof * pr1 = m.mk_transitivity(prs.size(), prs.c_ptr(), lhs, rhs); proof * pr2 = m.mk_rewrite(m.mk_eq(lhs, rhs), m.mk_false()); return m.mk_modus_ponens(pr1, pr2); @@ -152,8 +152,8 @@ namespace smt { proof * eq_root_propagation_justification::mk_proof(conflict_resolution & cr) { ast_manager & m = cr.get_manager(); - expr * var = m_node->get_owner(); - expr * val = m_node->get_root()->get_owner(); + expr * var = m_node->get_expr(); + expr * val = m_node->get_root()->get_expr(); SASSERT(m.is_true(val) || m.is_false(val)); proof * pr1 = cr.get_proof(m_node, m_node->get_root()); if (pr1) { @@ -191,7 +191,7 @@ namespace smt { proof * mp_iff_justification::mk_proof(conflict_resolution & cr) { ast_manager& m = cr.get_manager(); if (m_node1 == m_node2) - return m.mk_reflexivity(m_node1->get_owner()); + return m.mk_reflexivity(m_node1->get_expr()); proof * pr1 = cr.get_proof(m_node1, m_node2); context & ctx = cr.get_context(); bool_var v = ctx.enode2bool_var(m_node1); @@ -357,7 +357,7 @@ namespace smt { return nullptr; ast_manager & m = cr.get_manager(); context & ctx = cr.get_context(); - expr * fact = ctx.mk_eq_atom(m_lhs->get_owner(), m_rhs->get_owner()); + expr * fact = ctx.mk_eq_atom(m_lhs->get_expr(), m_rhs->get_expr()); return m.mk_th_lemma(m_th_id, fact, prs.size(), prs.c_ptr(), m_params.size(), m_params.c_ptr()); } diff --git a/src/smt/smt_model_checker.cpp b/src/smt/smt_model_checker.cpp index e82d0c791..447cbded2 100644 --- a/src/smt/smt_model_checker.cpp +++ b/src/smt/smt_model_checker.cpp @@ -112,7 +112,7 @@ namespace smt { enode * n = kv.m_key; expr * val = kv.m_value; n = n->get_eq_enode_with_min_gen(); - m_value2expr.insert(val, n->get_owner()); + m_value2expr.insert(val, n->get_expr()); } } } diff --git a/src/smt/smt_model_finder.cpp b/src/smt/smt_model_finder.cpp index b67187c89..ef1c66ab7 100644 --- a/src/smt/smt_model_finder.cpp +++ b/src/smt/smt_model_finder.cpp @@ -1177,7 +1177,7 @@ namespace smt { // So, using n->get_arg(m_arg_i)->get_root(), we may miss // a necessary instantiation. enode* e_arg = n->get_arg(m_arg_i); - expr* arg = e_arg->get_owner(); + expr* arg = e_arg->get_expr(); A_f_i->insert(arg, e_arg->get_generation()); } } @@ -1195,7 +1195,7 @@ namespace smt { for (enode* n : ctx->enodes_of(m_f)) { if (ctx->is_relevant(n)) { enode* e_arg = n->get_arg(m_arg_i); - expr* arg = e_arg->get_owner(); + expr* arg = e_arg->get_expr(); s->insert(arg, e_arg->get_generation()); } } @@ -1247,7 +1247,7 @@ namespace smt { bv_util bv(m); bv_rewriter bv_rw(m); enode* e_arg = n->get_arg(m_arg_i); - expr* arg = e_arg->get_owner(); + expr* arg = e_arg->get_expr(); expr_ref arg_minus_k(m); if (bv.is_bv(arg)) bv_rw.mk_sub(arg, m_offset, arg_minus_k); @@ -1348,7 +1348,7 @@ namespace smt { enode_vector::iterator end2 = curr->end_parents(); for (; it2 != end2; ++it2) { enode* p = *it2; - if (ctx->is_relevant(p) && p->get_owner()->get_decl() == auf_arr->get_decl()) { + if (ctx->is_relevant(p) && p->get_expr()->get_decl() == auf_arr->get_decl()) { arrays.push_back(p); } } @@ -1398,11 +1398,11 @@ namespace smt { TRACE("select_var", tout << "enodes matching: "; display(tout); tout << "\n"; for (enode* n : arrays) { - tout << "#" << n->get_owner()->get_id() << "\n" << mk_pp(n->get_owner(), m) << "\n"; + tout << "#" << n->get_expr_id() << "\n" << mk_pp(n->get_expr(), m) << "\n"; }); node* n1 = s.get_uvar(q, m_var_j); for (enode* n : arrays) { - app* ground_array = n->get_owner(); + app* ground_array = n->get_expr(); func_decl* f = get_array_func_decl(ground_array, s); if (f) { SASSERT(m_arg_i >= 1); @@ -1416,7 +1416,7 @@ namespace smt { ptr_buffer arrays; get_auf_arrays(get_array(), ctx, arrays); for (enode* curr : arrays) { - app* ground_array = curr->get_owner(); + app* ground_array = curr->get_expr(); func_decl* f = get_array_func_decl(ground_array, s); if (f) { node* A_f_i = s.get_A_f_i(f, m_arg_i - 1); @@ -1424,10 +1424,10 @@ namespace smt { enode_vector::iterator end2 = curr->end_parents(); for (; it2 != end2; ++it2) { enode* p = *it2; - if (ctx->is_relevant(p) && p->get_owner()->get_decl() == m_select->get_decl()) { - SASSERT(m_arg_i < p->get_owner()->get_num_args()); + if (ctx->is_relevant(p) && p->get_expr()->get_decl() == m_select->get_decl()) { + SASSERT(m_arg_i < p->get_expr()->get_num_args()); enode* e_arg = p->get_arg(m_arg_i); - A_f_i->insert(e_arg->get_owner(), e_arg->get_generation()); + A_f_i->insert(e_arg->get_expr(), e_arg->get_generation()); } } } @@ -1558,8 +1558,8 @@ namespace smt { // See Section 4.1 in the paper "Complete Quantifier Instantiation" node* S_q_i = slv.get_uvar(q, m_var_i); for (enode* n : ctx->enodes()) { - if (ctx->is_relevant(n) && n->get_owner()->get_sort() == s) { - S_q_i->insert(n->get_owner(), n->get_generation()); + if (ctx->is_relevant(n) && n->get_expr()->get_sort() == s) { + S_q_i->insert(n->get_expr(), n->get_generation()); } } } diff --git a/src/smt/smt_model_generator.cpp b/src/smt/smt_model_generator.cpp index d502f7599..5af14cbd6 100644 --- a/src/smt/smt_model_generator.cpp +++ b/src/smt/smt_model_generator.cpp @@ -98,7 +98,7 @@ namespace smt { model_value_proc * proc = nullptr; if (m.is_bool(s)) { CTRACE("model", m_context->get_assignment(r) == l_undef, - tout << mk_pp(r->get_owner(), m) << "\n";); + tout << mk_pp(r->get_expr(), m) << "\n";); SASSERT(m_context->get_assignment(r) != l_undef); if (m_context->get_assignment(r) == l_true) proc = alloc(expr_wrapper_proc, m.mk_true()); @@ -134,12 +134,12 @@ namespace smt { model_value_proc* model_generator::mk_model_value(enode* r) { SASSERT(r == r->get_root()); - expr * n = r->get_owner(); + expr * n = r->get_expr(); if (!m.is_model_value(n)) { sort * s = r->get_sort(); n = m_model->get_fresh_value(s); CTRACE("model", n == 0, - tout << mk_pp(r->get_owner(), m) << "\nsort:\n" << mk_pp(s, m) << "\n"; + tout << mk_pp(r->get_expr(), m) << "\nsort:\n" << mk_pp(s, m) << "\n"; tout << "is_finite: " << m_model->is_finite(s) << "\n";); } return alloc(expr_wrapper_proc, to_app(n)); @@ -209,7 +209,7 @@ namespace smt { } TRACE("mg_top_sort", tout << "src: " << src << " "; - tout << mk_pp(n->get_owner(), m) << "\n"; + tout << mk_pp(n->get_expr(), m) << "\n"; for (model_value_dependency const& dep : dependencies) { tout << "#" << n->get_owner_id() << " -> " << dep << " already visited: " << visited << "\n"; } @@ -306,7 +306,7 @@ namespace smt { else { enode * n = curr.get_enode(); SASSERT(n->get_root() == n); - tout << mk_pp(n->get_owner(), m) << "\n"; + tout << mk_pp(n->get_expr(), m) << "\n"; sort * s = n->get_sort(); tout << curr << " " << mk_pp(s, m); tout << " is_fresh: " << root2proc[n]->is_fresh() << "\n"; @@ -338,14 +338,14 @@ namespace smt { for (model_value_dependency const& d : dependencies) { if (d.is_fresh_value()) { CTRACE("mg_top_sort", !d.get_value()->get_value(), - tout << "#" << n->get_owner_id() << " " << mk_pp(n->get_owner(), m) << " -> " << d << "\n";); + tout << "#" << n->get_owner_id() << " " << mk_pp(n->get_expr(), m) << " -> " << d << "\n";); SASSERT(d.get_value()->get_value()); dependency_values.push_back(d.get_value()->get_value()); } else { enode * child = d.get_enode(); - TRACE("mg_top_sort", tout << "#" << n->get_owner_id() << " (" << mk_pp(n->get_owner(), m) << "): " - << mk_pp(child->get_owner(), m) << " " << mk_pp(child->get_root()->get_owner(), m) << "\n";); + TRACE("mg_top_sort", tout << "#" << n->get_owner_id() << " (" << mk_pp(n->get_expr(), m) << "): " + << mk_pp(child->get_expr(), m) << " " << mk_pp(child->get_root()->get_expr(), m) << "\n";); child = child->get_root(); dependency_values.push_back(m_root2value[child]); } @@ -358,8 +358,8 @@ namespace smt { } // send model for (enode * n : m_context->enodes()) { - if (is_uninterp_const(n->get_owner()) && m_context->is_relevant(n)) { - func_decl * d = n->get_owner()->get_decl(); + if (is_uninterp_const(n->get_expr()) && m_context->is_relevant(n)) { + func_decl * d = n->get_expr()->get_decl(); TRACE("mg_top_sort", tout << d->get_name() << " " << (m_hidden_ufs.contains(d)?"hidden":"visible") << "\n";); if (m_hidden_ufs.contains(d)) continue; expr * val = get_value(n); @@ -427,7 +427,7 @@ namespace smt { SASSERT(m_model->get_func_interp(f) == fi); // The entry must be new because n->get_cg() == n TRACE("model", - tout << "insert new entry for:\n" << mk_ismt2_pp(n->get_owner(), m) << "\nargs: "; + tout << "insert new entry for:\n" << mk_ismt2_pp(n->get_expr(), m) << "\nargs: "; for (unsigned i = 0; i < num_args; i++) { tout << "#" << n->get_arg(i)->get_owner_id() << " "; } @@ -468,7 +468,7 @@ namespace smt { void model_generator::register_existing_model_values() { for (enode * r : m_context->enodes()) { if (r == r->get_root() && m_context->is_relevant(r)) { - expr * n = r->get_owner(); + expr * n = r->get_expr(); if (m.is_model_value(n)) { register_value(n); } diff --git a/src/smt/smt_quantifier.cpp b/src/smt/smt_quantifier.cpp index b59e34454..b67599a99 100644 --- a/src/smt/smt_quantifier.cpp +++ b/src/smt/smt_quantifier.cpp @@ -316,7 +316,7 @@ namespace smt { CTRACE("bindings", f != nullptr, tout << expr_ref(q, m()) << "\n"; for (unsigned i = 0; i < num_bindings; ++i) { - tout << expr_ref(bindings[i]->get_owner(), m()) << " [r " << bindings[i]->get_root()->get_owner_id() << "] "; + tout << expr_ref(bindings[i]->get_expr(), m()) << " [r " << bindings[i]->get_root()->get_owner_id() << "] "; } tout << "\n"; ); diff --git a/src/smt/smt_quick_checker.cpp b/src/smt/smt_quick_checker.cpp index 5dcd1f265..a8ba15a82 100644 --- a/src/smt/smt_quick_checker.cpp +++ b/src/smt/smt_quick_checker.cpp @@ -358,10 +358,10 @@ namespace smt { if (idx >= m_num_bindings) return n; // VAR 0 is stored in the last position of m_bindings - return m_bindings[m_num_bindings - idx - 1]->get_root()->get_owner(); + return m_bindings[m_num_bindings - idx - 1]->get_root()->get_expr(); } if (m_context.e_internalized(n)) - return m_context.get_enode(n)->get_root()->get_owner(); + return m_context.get_enode(n)->get_root()->get_expr(); if (!is_app(n) || to_app(n)->get_num_args() == 0) return n; expr * r; @@ -382,8 +382,8 @@ namespace smt { if (has_arg_enodes) { enode * e = m_context.get_enode_eq_to(to_app(n)->get_decl(), num_args, new_arg_enodes.c_ptr()); if (e) { - m_canonize_cache.insert(n, e->get_root()->get_owner()); - return e->get_root()->get_owner(); + m_canonize_cache.insert(n, e->get_root()->get_expr()); + return e->get_root()->get_expr(); } } // substitute by values in the model diff --git a/src/smt/smt_relevancy.cpp b/src/smt/smt_relevancy.cpp index 75c82fa89..5bc7bf9d2 100644 --- a/src/smt/smt_relevancy.cpp +++ b/src/smt/smt_relevancy.cpp @@ -333,7 +333,7 @@ namespace smt { if (e != nullptr) { enode * curr = e; do { - set_relevant(curr->get_owner()); + set_relevant(curr->get_expr()); curr = curr->get_next(); } while (curr != e); @@ -625,7 +625,7 @@ namespace smt { if (n0 != 0) { enode * n = n0->get_next(); while (n0 != n) { - SASSERT(is_relevant(n->get_owner())); + SASSERT(is_relevant(n->get_expr())); n = n->get_next(); } } diff --git a/src/smt/smt_theory.h b/src/smt/smt_theory.h index a7182f996..a77b4168c 100644 --- a/src/smt/smt_theory.h +++ b/src/smt/smt_theory.h @@ -404,7 +404,7 @@ namespace smt { } app * get_expr(theory_var v) const { - return get_enode(v)->get_owner(); + return get_enode(v)->get_expr(); } /** @@ -447,9 +447,9 @@ namespace smt { std::ostream& display_flat_app(std::ostream & out, app * n) const; - std::ostream& display_var_def(std::ostream & out, theory_var v) const { return display_app(out, get_enode(v)->get_owner()); } + std::ostream& display_var_def(std::ostream & out, theory_var v) const { return display_app(out, get_enode(v)->get_expr()); } - std::ostream& display_var_flat_def(std::ostream & out, theory_var v) const { return display_flat_app(out, get_enode(v)->get_owner()); } + std::ostream& display_var_flat_def(std::ostream & out, theory_var v) const { return display_flat_app(out, get_enode(v)->get_expr()); } protected: void log_axiom_instantiation(app * r, unsigned axiom_id = UINT_MAX, unsigned num_bindings = 0, diff --git a/src/smt/theory_arith.h b/src/smt/theory_arith.h index 1bdd2ff15..dac417c02 100644 --- a/src/smt/theory_arith.h +++ b/src/smt/theory_arith.h @@ -531,7 +531,7 @@ namespace smt { bool has_var(expr * v) const { return get_context().e_internalized(v) && get_context().get_enode(v)->get_th_var(get_id()) != null_theory_var; } theory_var expr2var(expr * v) const { SASSERT(get_context().e_internalized(v)); return get_context().get_enode(v)->get_th_var(get_id()); } - expr * var2expr(theory_var v) const { return get_enode(v)->get_owner(); } + expr * var2expr(theory_var v) const { return get_enode(v)->get_expr(); } bool reflection_enabled() const; bool reflect(app * n) const; unsigned lazy_pivoting_lvl() const { return m_params.m_arith_lazy_pivoting_lvl; } @@ -973,7 +973,7 @@ namespace smt { \brief A monomial is 'pure' if does not have a numeric coefficient. */ bool is_pure_monomial(expr * m) const { return m_util.is_mul(m) && (to_app(m)->get_num_args() > 2 || !m_util.is_numeral(to_app(m)->get_arg(0))); } - bool is_pure_monomial(theory_var v) const { return is_pure_monomial(get_enode(v)->get_owner()); } + bool is_pure_monomial(theory_var v) const { return is_pure_monomial(get_enode(v)->get_expr()); } void mark_var(theory_var v, svector & vars, var_set & already_found); void mark_dependents(theory_var v, svector & vars, var_set & already_found, row_set & already_visited_rows); void get_non_linear_cluster(svector & vars); diff --git a/src/smt/theory_arith_aux.h b/src/smt/theory_arith_aux.h index 1e52e0cbc..507969469 100644 --- a/src/smt/theory_arith_aux.h +++ b/src/smt/theory_arith_aux.h @@ -430,8 +430,8 @@ namespace smt { template void theory_arith::eq_bound::display(theory_arith const& th, std::ostream& out) const { ast_manager& m = th.get_manager(); - out << "#" << m_lhs->get_owner_id() << " " << mk_pp(m_lhs->get_owner(), m) << " = " - << "#" << m_rhs->get_owner_id() << " " << mk_pp(m_rhs->get_owner(), m); + out << "#" << m_lhs->get_owner_id() << " " << mk_pp(m_lhs->get_expr(), m) << " = " + << "#" << m_rhs->get_owner_id() << " " << mk_pp(m_rhs->get_expr(), m); } // ----------------------------------- @@ -761,8 +761,8 @@ namespace smt { enode* a = e.first; enode* b = e.second; out << " "; - out << "#" << a->get_owner_id() << " " << mk_pp(a->get_owner(), m) << " = " - << "#" << b->get_owner_id() << " " << mk_pp(b->get_owner(), m) << "\n"; + out << "#" << a->get_owner_id() << " " << mk_pp(a->get_expr(), m) << " = " + << "#" << b->get_owner_id() << " " << mk_pp(b->get_expr(), m) << "\n"; } for (literal l : m_lits) { out << l << ":"; th.ctx.display_detailed_literal(out, l) << "\n"; @@ -1086,7 +1086,7 @@ namespace smt { expr_ref theory_arith::mk_gt(theory_var v) { ast_manager& m = get_manager(); inf_numeral const& val = get_value(v); - expr* obj = get_enode(v)->get_owner(); + expr* obj = get_enode(v)->get_expr(); expr_ref e(m); rational r = val.get_rational(); if (m_util.is_int(obj->get_sort())) { @@ -1124,7 +1124,7 @@ namespace smt { expr_ref theory_arith::mk_ge(generic_model_converter& fm, theory_var v, inf_numeral const& val) { ast_manager& m = get_manager(); std::ostringstream strm; - strm << val << " <= " << mk_pp(get_enode(v)->get_owner(), get_manager()); + strm << val << " <= " << mk_pp(get_enode(v)->get_expr(), get_manager()); app* b = m.mk_const(symbol(strm.str()), m.mk_bool_sort()); expr_ref result(b, m); TRACE("opt", tout << result << "\n";); @@ -1205,8 +1205,8 @@ namespace smt { } for (unsigned i = 0; i < num_eqs; ++i) { enode_pair const& p = eqs[i]; - x = p.first->get_owner(); - y = p.second->get_owner(); + x = p.first->get_expr(); + y = p.second->get_expr(); tmp = m.mk_eq(x,y); } @@ -1228,8 +1228,8 @@ namespace smt { } for (unsigned i = 0; i < num_eqs; ++i) { enode_pair const& p = eqs[i]; - x = p.first->get_owner(); - y = p.second->get_owner(); + x = p.first->get_expr(); + y = p.second->get_expr(); tmp = m.mk_eq(x,y); parameter const& pa = params[1 + num_lits + i]; SASSERT(pa.is_rational()); @@ -1798,7 +1798,7 @@ namespace smt { */ template typename theory_arith::max_min_t theory_arith::max_min(theory_var v, bool max, bool maintain_integrality, bool& has_shared) { - expr* e = get_enode(v)->get_owner(); + expr* e = get_enode(v)->get_expr(); (void)e; SASSERT(!maintain_integrality || valid_assignment()); SASSERT(satisfy_bounds()); @@ -2179,7 +2179,7 @@ namespace smt { TRACE("shared", tout << ctx.get_scope_level() << " " << v << " " << r->get_num_parents() << "\n";); for (; it != end; ++it) { enode * parent = *it; - app * o = parent->get_owner(); + app * o = parent->get_expr(); if (o->get_family_id() == get_id()) { switch (o->get_decl_kind()) { case OP_DIV: @@ -2209,7 +2209,7 @@ namespace smt { int num = get_num_vars(); for (theory_var v = 0; v < num; v++) { enode * n = get_enode(v); - TRACE("func_interp_bug", tout << mk_pp(n->get_owner(), get_manager()) << " -> " << m_value[v] << " root #" << n->get_root()->get_owner_id() << " " << is_relevant_and_shared(n) << "\n";); + TRACE("func_interp_bug", tout << mk_pp(n->get_expr(), get_manager()) << " -> " << m_value[v] << " root #" << n->get_root()->get_owner_id() << " " << is_relevant_and_shared(n) << "\n";); if (!is_relevant_and_shared(n)) { continue; } diff --git a/src/smt/theory_arith_core.h b/src/smt/theory_arith_core.h index d8bb38d55..e31f0c1f4 100644 --- a/src/smt/theory_arith_core.h +++ b/src/smt/theory_arith_core.h @@ -103,8 +103,8 @@ namespace smt { theory_var r = theory::mk_var(n); SASSERT(r == static_cast(m_columns.size())); SASSERT(check_vector_sizes()); - bool is_int = is_int_expr(n->get_owner()); - TRACE("mk_arith_var", tout << mk_pp(n->get_owner(), m) << " is_int: " << is_int << "\n";); + bool is_int = is_int_expr(n->get_expr()); + TRACE("mk_arith_var", tout << mk_pp(n->get_expr(), m) << " is_int: " << is_int << "\n";); m_columns .push_back(column()); m_data .push_back(var_data(is_int)); if (random_initial_value()) { @@ -127,12 +127,12 @@ namespace smt { m_in_update_trail_stack.assure_domain(r); m_left_basis.assure_domain(r); m_in_to_check.assure_domain(r); - if (is_pure_monomial(n->get_owner())) + if (is_pure_monomial(n->get_expr())) m_nl_monomials.push_back(r); SASSERT(check_vector_sizes()); SASSERT(m_var_occs[r].empty()); TRACE("mk_arith_var", - tout << "#" << n->get_owner_id() << " :=\n" << mk_ll_pp(n->get_owner(), m) << "\n"; + tout << "#" << n->get_owner_id() << " :=\n" << mk_ll_pp(n->get_expr(), m) << "\n"; tout << "is_attached_to_var: " << is_attached_to_var(n) << ", var: " << n->get_th_var(get_id()) << "\n";); ctx.attach_th_var(n, this, r); SASSERT(m_var_occs.back().empty()); @@ -1349,26 +1349,26 @@ namespace smt { template void theory_arith::new_eq_eh(theory_var v1, theory_var v2) { TRACE("arith_new_eq_eh", tout << "#" << get_enode(v1)->get_owner_id() << " = #" << get_enode(v2)->get_owner_id() << "\n";); - TRACE("arith_new_eq_eh_detail", tout << mk_pp(get_enode(v1)->get_owner(), m) << "\n" << - mk_pp(get_enode(v2)->get_owner(), m) << "\n";); + TRACE("arith_new_eq_eh_detail", tout << mk_pp(get_enode(v1)->get_expr(), m) << "\n" << + mk_pp(get_enode(v2)->get_expr(), m) << "\n";); enode * n1 = get_enode(v1); - if (!m_util.is_int(n1->get_owner()) && - !m_util.is_real(n1->get_owner())) { + if (!m_util.is_int(n1->get_expr()) && + !m_util.is_real(n1->get_expr())) { return; } if (m_params.m_arith_eq_bounds) { enode * n2 = get_enode(v2); SASSERT(n1->get_root() == n2->get_root()); - if (m_util.is_numeral(n1->get_owner())) { + if (m_util.is_numeral(n1->get_expr())) { std::swap(v1, v2); std::swap(n1, n2); } rational k; bound * b1 = nullptr; bound * b2 = nullptr; - if (m_util.is_numeral(n2->get_owner(), k)) { + if (m_util.is_numeral(n2->get_expr(), k)) { inf_numeral val(k); b1 = alloc(eq_bound, v1, val, B_LOWER, n1, n2); b2 = alloc(eq_bound, v1, val, B_UPPER, n1, n2); @@ -1376,9 +1376,9 @@ namespace smt { else { if (n1->get_owner_id() > n2->get_owner_id()) std::swap(n1, n2); - sort * st = n1->get_owner()->get_sort(); + sort * st = n1->get_expr()->get_sort(); app * minus_one = m_util.mk_numeral(rational::minus_one(), st); - app * s = m_util.mk_add(n1->get_owner(), m_util.mk_mul(minus_one, n2->get_owner())); + app * s = m_util.mk_add(n1->get_expr(), m_util.mk_mul(minus_one, n2->get_expr())); ctx.internalize(s, false); enode * e_s = ctx.get_enode(s); ctx.mark_as_relevant(e_s); @@ -1404,8 +1404,8 @@ namespace smt { template void theory_arith::new_diseq_eh(theory_var v1, theory_var v2) { - TRACE("arith_new_diseq_eh", tout << mk_bounded_pp(get_enode(v1)->get_owner(), m) << "\n" << - mk_bounded_pp(get_enode(v2)->get_owner(), m) << "\n";); + TRACE("arith_new_diseq_eh", tout << mk_bounded_pp(get_enode(v1)->get_expr(), m) << "\n" << + mk_bounded_pp(get_enode(v2)->get_expr(), m) << "\n";); m_stats.m_assert_diseq++; m_arith_eq_adapter.new_diseq_eh(v1, v2); } diff --git a/src/smt/theory_arith_eq.h b/src/smt/theory_arith_eq.h index d167a5c57..0620742d4 100644 --- a/src/smt/theory_arith_eq.h +++ b/src/smt/theory_arith_eq.h @@ -43,7 +43,7 @@ namespace smt { return; numeral const & val = lower_bound(v).get_rational(); value_sort_pair key(val, is_int_src(v)); - TRACE("arith_eq", tout << mk_pp(get_enode(v)->get_owner(), get_manager()) << " = " << val << "\n";); + TRACE("arith_eq", tout << mk_pp(get_enode(v)->get_expr(), get_manager()) << " = " << val << "\n";); theory_var v2; if (m_fixed_var_table.find(key, v2)) { if (v2 < static_cast(get_num_vars()) && is_fixed(v2) && lower_bound(v2).get_rational() == val) { @@ -349,10 +349,10 @@ namespace smt { tout << "\n"; } for (auto const& p : eqs) { - tout << mk_pp(p.first->get_owner(), m) << " = " << mk_pp(p.second->get_owner(), m) << "\n"; + tout << mk_pp(p.first->get_expr(), m) << " = " << mk_pp(p.second->get_expr(), m) << "\n"; } tout << " ==> "; - tout << mk_pp(_x->get_owner(), m) << " = " << mk_pp(_y->get_owner(), m) << "\n"; + tout << mk_pp(_x->get_expr(), m) << " = " << mk_pp(_y->get_expr(), m) << "\n"; ); ctx.assign_eq(_x, _y, eq_justification(js)); } diff --git a/src/smt/theory_arith_int.h b/src/smt/theory_arith_int.h index b561ff287..7eaf57276 100644 --- a/src/smt/theory_arith_int.h +++ b/src/smt/theory_arith_int.h @@ -213,7 +213,7 @@ namespace smt { tout << "k = " << k << ", _k = "<< _k << std::endl; ); expr_ref bound(m); - expr* e = get_enode(v)->get_owner(); + expr* e = get_enode(v)->get_expr(); bound = m_util.mk_ge(e, m_util.mk_numeral(_k, m_util.is_int(e))); context & ctx = get_context(); { @@ -411,7 +411,7 @@ namespace smt { for (; it != end; ++it) { if (!it->is_dead() && it->m_var != b && is_free(it->m_var)) { theory_var v = it->m_var; - expr* e = get_enode(v)->get_owner(); + expr* e = get_enode(v)->get_expr(); bool _is_int = m_util.is_int(e); expr_ref bound(m_util.mk_ge(e, m_util.mk_numeral(rational::zero(), _is_int)), get_manager()); context & ctx = get_context(); @@ -465,7 +465,7 @@ namespace smt { for (unsigned i = 0; i < num_args; i++) { rational _k = args[i].m_coeff.to_rational(); - expr * x = get_enode(args[i].m_var)->get_owner(); + expr * x = get_enode(args[i].m_var)->get_expr(); if (m_util.is_int(x) && !all_int) x = m_util.mk_to_real(x); if (_k.is_one()) @@ -635,9 +635,9 @@ namespace smt { } rational _k = k.to_rational(); if (is_lower) - bound = m_util.mk_ge(get_enode(v)->get_owner(), m_util.mk_numeral(_k, is_int(v))); + bound = m_util.mk_ge(get_enode(v)->get_expr(), m_util.mk_numeral(_k, is_int(v))); else - bound = m_util.mk_le(get_enode(v)->get_owner(), m_util.mk_numeral(_k, is_int(v))); + bound = m_util.mk_le(get_enode(v)->get_expr(), m_util.mk_numeral(_k, is_int(v))); } else { if (num_ints > 0) { diff --git a/src/smt/theory_arith_nl.h b/src/smt/theory_arith_nl.h index 243bcc2c4..dea5a4ad6 100644 --- a/src/smt/theory_arith_nl.h +++ b/src/smt/theory_arith_nl.h @@ -660,7 +660,7 @@ theory_var theory_arith::find_nl_var_for_branching() { bool computed_epsilon = false; bool r = check_monomial_assignment(v, computed_epsilon); if (!r) { - expr * m = get_enode(v)->get_owner(); + expr * m = get_enode(v)->get_expr(); SASSERT(is_pure_monomial(m)); for (expr * arg : *to_app(m)) { theory_var curr = ctx.get_enode(arg)->get_th_var(get_id()); diff --git a/src/smt/theory_arith_pp.h b/src/smt/theory_arith_pp.h index 222321e65..9dce32979 100644 --- a/src/smt/theory_arith_pp.h +++ b/src/smt/theory_arith_pp.h @@ -422,8 +422,8 @@ namespace smt { if (!lits().empty()) out << "\n"; ast_manager& m = th.get_manager(); for (auto const& e : m_eqs) { - out << mk_pp(e.first->get_owner(), m) << " "; - out << mk_pp(e.second->get_owner(), m) << "\n"; + out << mk_pp(e.first->get_expr(), m) << " "; + out << mk_pp(e.second->get_expr(), m) << "\n"; } return out; } @@ -508,7 +508,7 @@ namespace smt { pp.set_benchmark_name("lemma"); int n = get_num_vars(); for (theory_var v = 0; v < n; v++) { - expr * n = get_enode(v)->get_owner(); + expr * n = get_enode(v)->get_expr(); if (is_fixed(v)) { inf_numeral k_inf = lower_bound(v); rational k = k_inf.get_rational().to_rational(); diff --git a/src/smt/theory_array.cpp b/src/smt/theory_array.cpp index 9a17f6e6a..7c9b792ef 100644 --- a/src/smt/theory_array.cpp +++ b/src/smt/theory_array.cpp @@ -43,7 +43,7 @@ namespace smt { // v1 is the new root TRACE("array", tout << "merging v" << v1 << " v" << v2 << "\n"; display_var(tout, v1); - tout << mk_pp(get_enode(v1)->get_owner(), m) << " <- " << mk_pp(get_enode(v2)->get_owner(), m) << "\n";); + tout << mk_pp(get_enode(v1)->get_expr(), m) << " <- " << mk_pp(get_enode(v2)->get_expr(), m) << "\n";); SASSERT(v1 == find(v1)); var_data * d1 = m_var_data[v1]; var_data * d2 = m_var_data[v2]; @@ -68,11 +68,11 @@ namespace smt { SASSERT(r == static_cast(m_var_data.size())); m_var_data.push_back(alloc(var_data)); var_data * d = m_var_data[r]; - TRACE("array", tout << mk_bounded_pp(n->get_owner(), m) << "\nis_array: " << is_array_sort(n) << ", is_select: " << is_select(n) << + TRACE("array", tout << mk_bounded_pp(n->get_expr(), m) << "\nis_array: " << is_array_sort(n) << ", is_select: " << is_select(n) << ", is_store: " << is_store(n) << "\n";); d->m_is_array = is_array_sort(n); if (d->m_is_array) - register_sort(n->get_owner()->get_sort()); + register_sort(n->get_expr()->get_sort()); d->m_is_select = is_select(n); if (is_store(n)) d->m_stores.push_back(n); @@ -89,7 +89,7 @@ namespace smt { v = find(v); var_data * d = m_var_data[v]; d->m_parent_selects.push_back(s); - TRACE("array", tout << v << " " << mk_pp(s->get_owner(), m) << " " << mk_pp(get_enode(v)->get_owner(), m) << "\n";); + TRACE("array", tout << v << " " << mk_pp(s->get_expr(), m) << " " << mk_pp(get_enode(v)->get_expr(), m) << "\n";); m_trail_stack.push(push_back_trail(d->m_parent_selects)); for (enode* n : d->m_stores) { instantiate_axiom2a(s, n); @@ -196,7 +196,7 @@ namespace smt { } void theory_array::instantiate_axiom1(enode * store) { - TRACE("array", tout << "axiom 1:\n" << mk_bounded_pp(store->get_owner(), m) << "\n";); + TRACE("array", tout << "axiom 1:\n" << mk_bounded_pp(store->get_expr(), m) << "\n";); SASSERT(is_store(store)); m_stats.m_num_axiom1++; assert_store_axiom1(store); @@ -296,8 +296,8 @@ namespace smt { void theory_array::new_eq_eh(theory_var v1, theory_var v2) { m_find.merge(v1, v2); enode* n1 = get_enode(v1), *n2 = get_enode(v2); - if (n1->get_owner()->get_decl()->is_lambda() || - n2->get_owner()->get_decl()->is_lambda()) { + if (n1->get_expr()->get_decl()->is_lambda() || + n2->get_expr()->get_decl()->is_lambda()) { assert_congruent(n1, n2); } } @@ -307,8 +307,8 @@ namespace smt { v2 = find(v2); var_data * d1 = m_var_data[v1]; TRACE("ext", tout << "extensionality: " << d1->m_is_array << "\n" - << mk_bounded_pp(get_enode(v1)->get_owner(), m, 5) << "\n" - << mk_bounded_pp(get_enode(v2)->get_owner(), m, 5) << "\n";); + << mk_bounded_pp(get_enode(v1)->get_expr(), m, 5) << "\n" + << mk_bounded_pp(get_enode(v2)->get_expr(), m, 5) << "\n";); if (d1->m_is_array) { SASSERT(m_var_data[v2]->m_is_array); diff --git a/src/smt/theory_array_bapa.cpp b/src/smt/theory_array_bapa.cpp index 13867364d..5a20d588b 100644 --- a/src/smt/theory_array_bapa.cpp +++ b/src/smt/theory_array_bapa.cpp @@ -128,7 +128,7 @@ namespace smt { } bool is_true(expr* e) { return is_true(ctx().get_literal(e)); } - bool is_true(enode* e) { return is_true(e->get_owner()); } + bool is_true(enode* e) { return is_true(e->get_expr()); } bool is_true(literal l) { return ctx().is_relevant(l) && ctx().get_assignment(l) == l_true; } bool is_leaf(sz_info& i) const { return i.m_is_leaf; } bool is_leaf(sz_info* i) const { return is_leaf(*i); } @@ -167,7 +167,7 @@ namespace smt { for (enode* parent : enode::parents(set)) { if (is_select(parent) && parent->get_arg(0)->get_root() == set) { if (is_true(parent)) { - v.m_selects.insert(parent->get_arg(1)->get_root(), parent->get_owner()); + v.m_selects.insert(parent->get_arg(1)->get_root(), parent->get_expr()); } } } @@ -424,7 +424,7 @@ namespace smt { if (info.m_selects.size() > 1) { ptr_vector args; for (auto const& kv : info.m_selects) { - args.push_back(kv.m_key->get_owner()); + args.push_back(kv.m_key->get_expr()); } if (info.m_selects.size() == 2) { lits.push_back(mk_eq(args[0], args[1])); diff --git a/src/smt/theory_array_base.cpp b/src/smt/theory_array_base.cpp index 683e0aa51..d32b29606 100644 --- a/src/smt/theory_array_base.cpp +++ b/src/smt/theory_array_base.cpp @@ -94,7 +94,7 @@ namespace smt { } void theory_array_base::assert_store_axiom1_core(enode * e) { - app * n = e->get_owner(); + app * n = e->get_expr(); SASSERT(is_store(n)); ptr_buffer sel_args; unsigned num_args = n->get_num_args(); @@ -134,7 +134,7 @@ namespace smt { */ void theory_array_base::assert_store_axiom2_core(enode * store, enode * select) { TRACE("array", tout << "generating axiom2: #" << store->get_owner_id() << " #" << select->get_owner_id() << "\n"; - tout << mk_bounded_pp(store->get_owner(), m) << "\n" << mk_bounded_pp(select->get_owner(), m) << "\n";); + tout << mk_bounded_pp(store->get_expr(), m) << "\n" << mk_bounded_pp(select->get_expr(), m) << "\n";); SASSERT(is_store(store)); SASSERT(is_select(select)); SASSERT(store->get_num_args() == 1 + select->get_num_args()); @@ -144,12 +144,12 @@ namespace smt { enode * const * is = select->get_args() + 1; enode * const * js = store->get_args() + 1; unsigned num_args = select->get_num_args() - 1; - sel1_args.push_back(store->get_owner()); - sel2_args.push_back(a->get_owner()); + sel1_args.push_back(store->get_expr()); + sel2_args.push_back(a->get_expr()); for (unsigned i = 0; i < num_args; i++) { - sel1_args.push_back(is[i]->get_owner()); - sel2_args.push_back(is[i]->get_owner()); + sel1_args.push_back(is[i]->get_expr()); + sel2_args.push_back(is[i]->get_expr()); } expr_ref sel1(m), sel2(m); @@ -179,14 +179,14 @@ namespace smt { conseq_expr = ctx.bool_var2expr(conseq.var()); } - literal ante = mk_eq(idx1->get_owner(), idx2->get_owner(), true); + literal ante = mk_eq(idx1->get_expr(), idx2->get_expr(), true); ctx.mark_as_relevant(ante); // ctx.force_phase(ante); ctx.add_rel_watch(~ante, conseq_expr); // ctx.mark_as_relevant(conseq_expr); TRACE("array", tout << "asserting axiom2: " << ante << "\n";); TRACE("array_map_bug", tout << "axiom2:\n"; - tout << mk_ismt2_pp(idx1->get_owner(), m) << "\n=\n" << mk_ismt2_pp(idx2->get_owner(), m); + tout << mk_ismt2_pp(idx1->get_expr(), m) << "\n=\n" << mk_ismt2_pp(idx2->get_expr(), m); tout << "\nimplies\n" << mk_ismt2_pp(conseq_expr, m) << "\n";); if (m.has_trace_stream()) { app_ref body(m); @@ -264,7 +264,7 @@ namespace smt { for (enode* parent : r1->get_const_parents()) { if (parent->is_cgr() && ctx.is_relevant(parent) && - is_select(parent->get_owner()) && + is_select(parent->get_expr()) && parent->get_arg(0)->get_root() == r1) { m_array_value.insert(parent); } @@ -274,7 +274,7 @@ namespace smt { enode * other; if (parent->is_cgr() && ctx.is_relevant(parent) && - is_select(parent->get_owner()) && + is_select(parent->get_expr()) && parent->get_arg(0)->get_root() == r2 && m_array_value.find(parent, other)) { @@ -313,8 +313,8 @@ namespace smt { void theory_array_base::assert_extensionality_core(enode * n1, enode * n2) { - app * e1 = n1->get_owner(); - app * e2 = n2->get_owner(); + app * e1 = n1->get_expr(); + app * e2 = n2->get_expr(); func_decl_ref_vector * funcs = nullptr; sort * s = e1->get_sort(); @@ -351,8 +351,8 @@ namespace smt { \brief assert n1 = n2 => forall vars . (n1 vars) = (n2 vars) */ void theory_array_base::assert_congruent_core(enode * n1, enode * n2) { - app * e1 = n1->get_owner(); - app * e2 = n2->get_owner(); + app * e1 = n1->get_expr(); + app * e2 = n2->get_expr(); sort* s = e1->get_sort(); unsigned dimension = get_array_arity(s); literal n1_eq_n2 = mk_eq(e1, e2, true); @@ -564,15 +564,15 @@ namespace smt { TRACE("array_bug", tout << "mk_interface_eqs: processing: v" << *it1 << "\n";); theory_var v1 = *it1; enode * n1 = get_enode(v1); - sort * s1 = n1->get_owner()->get_sort(); + sort * s1 = n1->get_expr()->get_sort(); sbuffer::iterator it2 = it1; ++it2; for (; it2 != end1; ++it2) { theory_var v2 = *it2; enode * n2 = get_enode(v2); - sort * s2 = n2->get_owner()->get_sort(); + sort * s2 = n2->get_expr()->get_sort(); if (s1 == s2 && !ctx.is_diseq(n1, n2)) { - app * eq = mk_eq_atom(n1->get_owner(), n2->get_owner()); + app * eq = mk_eq_atom(n1->get_expr(), n2->get_expr()); if (!ctx.b_internalized(eq) || !ctx.is_relevant(eq)) { result++; ctx.internalize(eq, true); @@ -624,7 +624,7 @@ namespace smt { void theory_array_base::set_default(theory_var v, enode* n) { - TRACE("array", tout << "set default: " << v << " " << mk_pp(n->get_owner(), m) << "\n";); + TRACE("array", tout << "set default: " << v << " " << pp(n, m) << "\n";); v = mg_find(v); if (m_defaults[v] == 0) { m_defaults[v] = n; @@ -672,8 +672,8 @@ namespace smt { m_defaults[u] = m_defaults[v]; } CTRACE("array", m_defaults[v], - tout << mk_pp(m_defaults[v]->get_root()->get_owner(), m) << "\n"; - tout << mk_pp(m_defaults[u]->get_root()->get_owner(), m) << "\n"; + tout << pp(m_defaults[v]->get_root(), m) << "\n"; + tout << pp(m_defaults[u]->get_root(), m) << "\n"; ); // NB. it may be the case that m_defaults[u] != m_defaults[v] @@ -748,7 +748,7 @@ namespace smt { mg_merge(v, get_representative(w)); - TRACE("array", tout << "merge: " << mk_pp(n->get_owner(), m) << " " << v << " " << w << "\n";); + TRACE("array", tout << "merge: " << pp(n, m) << " " << v << " " << w << "\n";); } else if (is_const(n)) { set_default(v, n->get_arg(0)); @@ -983,7 +983,7 @@ namespace smt { SASSERT(ctx.is_relevant(n)); theory_var v = n->get_th_var(get_id()); SASSERT(v != null_theory_var); - sort * s = n->get_owner()->get_sort(); + sort * s = n->get_expr()->get_sort(); enode * else_val_n = get_default(v); array_value_proc * result = nullptr; @@ -1008,7 +1008,7 @@ namespace smt { // The implementation should not assume a fresh value is created for // the else_val if the range is finite - TRACE("array", tout << mk_pp(n->get_owner(), m) << " " << mk_pp(range, m) << " " << range->is_infinite() << "\n";); + TRACE("array", tout << pp(n, m) << " " << mk_pp(range, m) << " " << range->is_infinite() << "\n";); if (range->is_infinite()) else_val = TAG(void*, mg.mk_extra_fresh_value(range), 1); else @@ -1038,14 +1038,14 @@ namespace smt { } } TRACE("array", - tout << mk_pp(n->get_root()->get_owner(), m) << "\n"; + tout << pp(n->get_root(), m) << "\n"; if (sel_set) { for (enode* s : *sel_set) { - tout << "#" << s->get_root()->get_owner()->get_id() << " " << mk_pp(s->get_owner(), m) << "\n"; + tout << "#" << s->get_root()->get_expr_id() << " " << pp(s, m) << "\n"; } } if (else_val_n) { - tout << "else: " << mk_pp(else_val_n->get_owner(), m) << "\n"; + tout << "else: " << pp(else_val_n, m) << "\n"; }); return result; } diff --git a/src/smt/theory_array_base.h b/src/smt/theory_array_base.h index 4763c2d9e..b73805be8 100644 --- a/src/smt/theory_array_base.h +++ b/src/smt/theory_array_base.h @@ -35,8 +35,8 @@ namespace smt { void add_weak_var(theory_var v); virtual void set_prop_upward(theory_var v) {} void found_unsupported_op(expr * n); - void found_unsupported_op(enode* n) { found_unsupported_op(n->get_owner()); } - void found_unsupported_op(theory_var v) { found_unsupported_op(get_enode(v)->get_owner()); } + void found_unsupported_op(enode* n) { found_unsupported_op(n->get_expr()); } + void found_unsupported_op(theory_var v) { found_unsupported_op(get_enode(v)->get_expr()); } bool is_store(app const* n) const { return n->is_app_of(get_id(), OP_STORE); } bool is_map(app const* n) const { return n->is_app_of(get_id(), OP_ARRAY_MAP); } @@ -50,15 +50,15 @@ namespace smt { bool is_set_has_size(app const* n) const { return n->is_app_of(get_id(), OP_SET_HAS_SIZE); } bool is_set_card(app const* n) const { return n->is_app_of(get_id(), OP_SET_CARD); } - bool is_store(enode const * n) const { return is_store(n->get_owner()); } - bool is_map(enode const* n) const { return is_map(n->get_owner()); } - bool is_select(enode const* n) const { return is_select(n->get_owner()); } - bool is_const(enode const* n) const { return is_const(n->get_owner()); } - bool is_as_array(enode const * n) const { return is_as_array(n->get_owner()); } - bool is_default(enode const* n) const { return is_default(n->get_owner()); } - bool is_array_sort(enode const* n) const { return is_array_sort(n->get_owner()); } - bool is_set_has_size(enode const* n) const { return is_set_has_size(n->get_owner()); } - bool is_set_carde(enode const* n) const { return is_set_card(n->get_owner()); } + bool is_store(enode const * n) const { return is_store(n->get_expr()); } + bool is_map(enode const* n) const { return is_map(n->get_expr()); } + bool is_select(enode const* n) const { return is_select(n->get_expr()); } + bool is_const(enode const* n) const { return is_const(n->get_expr()); } + bool is_as_array(enode const * n) const { return is_as_array(n->get_expr()); } + bool is_default(enode const* n) const { return is_default(n->get_expr()); } + bool is_array_sort(enode const* n) const { return is_array_sort(n->get_expr()); } + bool is_set_has_size(enode const* n) const { return is_set_has_size(n->get_expr()); } + bool is_set_carde(enode const* n) const { return is_set_card(n->get_expr()); } bool is_select_arg(enode* r); app * mk_select(unsigned num_args, expr * const * args); diff --git a/src/smt/theory_array_full.cpp b/src/smt/theory_array_full.cpp index a4772c578..ca6240d94 100644 --- a/src/smt/theory_array_full.cpp +++ b/src/smt/theory_array_full.cpp @@ -134,7 +134,7 @@ namespace smt { // call set_prop_upward on array arguments. // void theory_array_full::set_prop_upward(enode * n) { - TRACE("array", tout << mk_pp(n->get_owner(), m) << "\n";); + TRACE("array", tout << pp(n, m) << "\n";); if (is_store(n)) { set_prop_upward(n->get_arg(0)->get_th_var(get_id())); } @@ -344,8 +344,8 @@ namespace smt { add_as_array(v1, n); } TRACE("array", - tout << mk_pp(get_enode(v1)->get_owner(), m) << "\n"; - tout << mk_pp(get_enode(v2)->get_owner(), m) << "\n"; + tout << pp(get_enode(v1), m) << "\n"; + tout << pp(get_enode(v2), m) << "\n"; tout << "merge in\n"; display_var(tout, v2); tout << "after merge\n"; display_var(tout, v1);); } @@ -354,7 +354,7 @@ namespace smt { SASSERT(v != null_theory_var); v = find(v); var_data* d = m_var_data[v]; - TRACE("array", tout << "v" << v << " " << mk_pp(get_enode(v)->get_owner(), m) << " " + TRACE("array", tout << "v" << v << " " << pp(get_enode(v), m) << " " << d->m_prop_upward << " " << m_params.m_array_delay_exp_axiom << "\n";); for (enode * store : d->m_stores) { SASSERT(is_store(store)); @@ -368,7 +368,7 @@ namespace smt { void theory_array_full::add_parent_select(theory_var v, enode * s) { TRACE("array", - tout << v << " select parent: " << mk_pp(s->get_owner(), m) << "\n"; + tout << v << " select parent: " << pp(s, m) << "\n"; display_var(tout, v); ); theory_array::add_parent_select(v,s); @@ -446,8 +446,8 @@ namespace smt { // select(map[f](a, ... d), i) = f(select(a,i),...,select(d,i)) // bool theory_array_full::instantiate_select_map_axiom(enode* sl, enode* mp) { - app* map = mp->get_owner(); - app* select = sl->get_owner(); + app* map = mp->get_expr(); + app* select = sl->get_expr(); SASSERT(is_map(map)); SASSERT(is_select(select)); SASSERT(map->get_num_args() > 0); @@ -456,7 +456,7 @@ namespace smt { TRACE("array_map_bug", tout << "invoked instantiate_select_map_axiom\n"; tout << sl->get_owner_id() << " " << mp->get_owner_id() << "\n"; - tout << mk_ismt2_pp(sl->get_owner(), m) << "\n" << mk_ismt2_pp(mp->get_owner(), m) << "\n";); + tout << mk_ismt2_pp(sl->get_expr(), m) << "\n" << mk_ismt2_pp(mp->get_expr(), m) << "\n";); if (!ctx.add_fingerprint(mp, mp->get_owner_id(), sl->get_num_args() - 1, sl->get_args() + 1)) { return false; @@ -466,8 +466,8 @@ namespace smt { m_stats.m_num_map_axiom++; TRACE("array", - tout << mk_bounded_pp(mp->get_owner(), m) << "\n"; - tout << mk_bounded_pp(sl->get_owner(), m) << "\n";); + tout << mk_bounded_pp(mp->get_expr(), m) << "\n"; + tout << mk_bounded_pp(sl->get_expr(), m) << "\n";); unsigned num_args = select->get_num_args(); unsigned num_arrays = map->get_num_args(); ptr_buffer args1, args2; @@ -513,7 +513,7 @@ namespace smt { bool theory_array_full::instantiate_default_map_axiom(enode* mp) { SASSERT(is_map(mp)); - app* map = mp->get_owner(); + app* map = mp->get_expr(); if (!ctx.add_fingerprint(this, m_default_map_fingerprint, 1, &mp)) { return false; } @@ -543,9 +543,9 @@ namespace smt { } m_stats.m_num_default_const_axiom++; SASSERT(is_const(cnst)); - TRACE("array", tout << mk_bounded_pp(cnst->get_owner(), m) << "\n";); - expr* val = cnst->get_arg(0)->get_owner(); - expr* def = mk_default(cnst->get_owner()); + TRACE("array", tout << mk_bounded_pp(cnst->get_expr(), m) << "\n";); + expr* val = cnst->get_arg(0)->get_expr(); + expr* def = mk_default(cnst->get_expr()); ctx.internalize(def, false); return try_assign_eq(val, def); } @@ -626,15 +626,15 @@ namespace smt { m_stats.m_num_select_const_axiom++; ptr_buffer sel_args; - sel_args.push_back(cnst->get_owner()); + sel_args.push_back(cnst->get_expr()); for (unsigned short i = 1; i < num_args; ++i) { - sel_args.push_back(select->get_owner()->get_arg(i)); + sel_args.push_back(select->get_expr()->get_arg(i)); } expr * sel = mk_select(sel_args.size(), sel_args.c_ptr()); - expr * val = cnst->get_owner()->get_arg(0); + expr * val = cnst->get_expr()->get_arg(0); TRACE("array", tout << "new select-const axiom...\n"; - tout << "const: " << mk_bounded_pp(cnst->get_owner(), m) << "\n"; - tout << "select: " << mk_bounded_pp(select->get_owner(), m) << "\n"; + tout << "const: " << mk_bounded_pp(cnst->get_expr(), m) << "\n"; + tout << "select: " << mk_bounded_pp(select->get_expr(), m) << "\n"; tout << " sel/const: " << mk_bounded_pp(sel, m) << "\n"; tout << "value: " << mk_bounded_pp(val, m) << "\n"; tout << "#" << sel->get_id() << " = #" << val->get_id() << "\n"; @@ -650,7 +650,7 @@ namespace smt { // select(as-array f, i_1, ..., i_n) = (f i_1 ... i_n) // bool theory_array_full::instantiate_select_as_array_axiom(enode* select, enode* arr) { - SASSERT(is_as_array(arr->get_owner())); + SASSERT(is_as_array(arr->get_expr())); SASSERT(is_select(select)); SASSERT(arr->get_num_args() == 0); unsigned num_args = select->get_num_args(); @@ -660,16 +660,16 @@ namespace smt { m_stats.m_num_select_as_array_axiom++; ptr_buffer sel_args; - sel_args.push_back(arr->get_owner()); + sel_args.push_back(arr->get_expr()); for (unsigned short i = 1; i < num_args; ++i) { - sel_args.push_back(select->get_owner()->get_arg(i)); + sel_args.push_back(select->get_expr()->get_arg(i)); } expr * sel = mk_select(sel_args.size(), sel_args.c_ptr()); - func_decl * f = array_util(m).get_as_array_func_decl(arr->get_owner()); + func_decl * f = array_util(m).get_as_array_func_decl(arr->get_expr()); expr_ref val(m.mk_app(f, sel_args.size()-1, sel_args.c_ptr()+1), m); TRACE("array", tout << "new select-as-array axiom...\n"; - tout << "as-array: " << mk_bounded_pp(arr->get_owner(), m) << "\n"; - tout << "select: " << mk_bounded_pp(select->get_owner(), m) << "\n"; + tout << "as-array: " << mk_bounded_pp(arr->get_expr(), m) << "\n"; + tout << "select: " << mk_bounded_pp(select->get_expr(), m) << "\n"; tout << " sel/as-array: " << mk_bounded_pp(sel, m) << "\n"; tout << "value: " << mk_bounded_pp(val.get(), m) << "\n"; tout << "#" << sel->get_id() << " = #" << val->get_id() << "\n"; @@ -684,7 +684,7 @@ namespace smt { bool theory_array_full::instantiate_default_store_axiom(enode* store) { SASSERT(is_store(store)); SASSERT(store->get_num_args() >= 3); - app* store_app = store->get_owner(); + app* store_app = store->get_expr(); if (!ctx.add_fingerprint(this, m_default_store_fingerprint, store->get_num_args(), store->get_args())) { return false; } diff --git a/src/smt/theory_bv.cpp b/src/smt/theory_bv.cpp index 19cdd7034..468277cb3 100644 --- a/src/smt/theory_bv.cpp +++ b/src/smt/theory_bv.cpp @@ -45,7 +45,7 @@ namespace smt { void theory_bv::mk_bits(theory_var v) { enode * n = get_enode(v); - app * owner = n->get_owner(); + app * owner = n->get_expr(); unsigned bv_size = get_bv_size(n); bool is_relevant = ctx.is_relevant(n); literal_vector & bits = m_bits[v]; @@ -180,7 +180,7 @@ namespace smt { return n->get_arg(idx); } else { - app * arg = to_app(n->get_owner()->get_arg(idx)); + app * arg = to_app(n->get_expr()->get_arg(idx)); SASSERT(ctx.e_internalized(arg)); return ctx.get_enode(arg); } @@ -418,7 +418,7 @@ namespace smt { } if (!visited) return nullptr; - expr * fact = ctx.mk_eq_atom(m_th.get_enode(m_var1)->get_owner(), m_th.get_enode(m_var2)->get_owner()); + expr * fact = ctx.mk_eq_atom(m_th.get_enode(m_var1)->get_expr(), m_th.get_enode(m_var2)->get_expr()); ast_manager & m = ctx.get_manager(); return m.mk_th_lemma(get_from_theory(), fact, prs.size(), prs.c_ptr()); } @@ -444,8 +444,8 @@ namespace smt { return; } ++m_stats.m_num_eq_dynamic; - app* o1 = get_enode(v1)->get_owner(); - app* o2 = get_enode(v2)->get_owner(); + app* o1 = get_enode(v1)->get_expr(); + app* o2 = get_enode(v2)->get_expr(); literal oeq = mk_eq(o1, o2, true); unsigned sz = get_bv_size(v1); TRACE("bv", @@ -479,7 +479,7 @@ namespace smt { VERIFY(get_fixed_value(v, val)); enode* n = get_enode(v); if (ctx.watches_fixed(n)) { - expr_ref num(m_util.mk_numeral(val, n->get_owner()->get_sort()), m); + expr_ref num(m_util.mk_numeral(val, n->get_expr()->get_sort()), m); literal_vector& lits = m_tmp_literals; lits.reset(); for (literal b : m_bits[v]) { @@ -1101,16 +1101,16 @@ namespace smt { } void theory_bv::apply_sort_cnstr(enode * n, sort * s) { - if (!is_attached_to_var(n) && !approximate_term(n->get_owner())) { + if (!is_attached_to_var(n) && !approximate_term(n->get_expr())) { mk_bits(mk_var(n)); if (ctx.is_relevant(n)) { - relevant_eh(n->get_owner()); + relevant_eh(n->get_expr()); } } } void theory_bv::new_eq_eh(theory_var v1, theory_var v2) { - TRACE("bv_eq", tout << "new_eq: " << mk_pp(get_enode(v1)->get_owner(), m) << " = " << mk_pp(get_enode(v2)->get_owner(), m) << "\n";); + TRACE("bv_eq", tout << "new_eq: " << mk_pp(get_enode(v1)->get_expr(), m) << " = " << mk_pp(get_enode(v2)->get_expr(), m) << "\n";); TRACE("bv", tout << "new_eq_eh v" << v1 << " = v" << v2 << " @ " << ctx.get_scope_level() << " relevant1: " << ctx.is_relevant(get_enode(v1)) << " relevant2: " << ctx.is_relevant(get_enode(v2)) << "\n";); @@ -1176,7 +1176,7 @@ namespace smt { literal_vector & lits = m_tmp_literals; lits.reset(); - literal eq = mk_eq(get_enode(v1)->get_owner(), get_enode(v2)->get_owner(), true); + literal eq = mk_eq(get_enode(v1)->get_expr(), get_enode(v2)->get_expr(), true); lits.push_back(eq); it1 = bits1.begin(); it2 = bits2.begin(); @@ -1190,7 +1190,7 @@ namespace smt { lits.push_back(arg); } TRACE("bv", - tout << mk_pp(get_enode(v1)->get_owner(), m) << " = " << mk_pp(get_enode(v2)->get_owner(), m) << " " + tout << mk_pp(get_enode(v1)->get_expr(), m) << " = " << mk_pp(get_enode(v2)->get_expr(), m) << " " << ctx.get_scope_level() << "\n"; ctx.display_literals_smt2(tout, lits);); diff --git a/src/smt/theory_bv.h b/src/smt/theory_bv.h index 1b1f16603..d01a9b1d4 100644 --- a/src/smt/theory_bv.h +++ b/src/smt/theory_bv.h @@ -145,14 +145,14 @@ namespace smt { theory_var next(theory_var v) const { return m_find.next(v); } bool is_root(theory_var v) const { return m_find.is_root(v); } unsigned get_bv_size(app const * n) const { return m_util.get_bv_size(n); } - unsigned get_bv_size(enode const * n) const { return m_util.get_bv_size(n->get_owner()); } + unsigned get_bv_size(enode const * n) const { return m_util.get_bv_size(n->get_expr()); } unsigned get_bv_size(theory_var v) const { return get_bv_size(get_enode(v)); } bool is_bv(app const* n) const { return m_util.is_bv_sort(n->get_sort()); } - bool is_bv(enode const* n) const { return is_bv(n->get_owner()); } + bool is_bv(enode const* n) const { return is_bv(n->get_expr()); } bool is_bv(theory_var v) const { return is_bv(get_enode(v)); } region & get_region() { return m_trail_stack.get_region(); } - bool is_numeral(theory_var v) const { return m_util.is_numeral(get_enode(v)->get_owner()); } + bool is_numeral(theory_var v) const { return m_util.is_numeral(get_enode(v)->get_expr()); } app * mk_bit2bool(app * bv, unsigned idx); void mk_bits(theory_var v); friend class mk_atom_trail; diff --git a/src/smt/theory_datatype.cpp b/src/smt/theory_datatype.cpp index a88d4b734..26eb4bc6e 100644 --- a/src/smt/theory_datatype.cpp +++ b/src/smt/theory_datatype.cpp @@ -87,7 +87,7 @@ namespace smt { if (antecedent != null_literal) { std::function fn = [&]() { app_ref body(m); - body = m.mk_eq(lhs->get_owner(), rhs); + body = m.mk_eq(lhs->get_expr(), rhs); body = m.mk_implies(ctx.bool_var2expr(antecedent.var()), body); log_axiom_instantiation(body, 1, &lhs); }; @@ -95,7 +95,7 @@ namespace smt { } if (m.proofs_enabled()) { - literal l(mk_eq(lhs->get_owner(), rhs, true)); + literal l(mk_eq(lhs->get_expr(), rhs, true)); ctx.mark_as_relevant(l); if (antecedent != null_literal) { literal lits[2] = {l, ~antecedent}; @@ -108,12 +108,12 @@ namespace smt { } else { ctx.internalize(rhs, false); - TRACE("datatype", tout << "adding axiom:\n" << mk_pp(lhs->get_owner(), m) << "\n=\n" << mk_pp(rhs, m) << "\n";); + TRACE("datatype", tout << "adding axiom:\n" << pp(lhs, m) << "\n=\n" << mk_pp(rhs, m) << "\n";); if (antecedent == null_literal) { ctx.assign_eq(lhs, ctx.get_enode(rhs), eq_justification::mk_axiom()); } else if (ctx.get_assignment(antecedent) != l_true) { - literal l(mk_eq(lhs->get_owner(), rhs, true)); + literal l(mk_eq(lhs->get_expr(), rhs, true)); ctx.mark_as_relevant(l); ctx.mark_as_relevant(antecedent); literal lits[2] = {l, ~antecedent}; @@ -137,7 +137,7 @@ namespace smt { where acc_i are the accessors of constructor c. */ void theory_datatype::assert_is_constructor_axiom(enode * n, func_decl * c, literal antecedent) { - app* e = n->get_owner(); + app* e = n->get_expr(); TRACE("datatype_bug", tout << "creating axiom (= n (c (acc_1 n) ... (acc_m n))) for\n" << mk_pp(c, m) << " " << mk_pp(e, m) << "\n";); m_stats.m_assert_cnstr++; @@ -174,17 +174,17 @@ namespace smt { vector> used_enodes; used_enodes.push_back(std::make_tuple(nullptr, n)); for (unsigned i = 0; i < n->get_num_args(); ++i) { - bindings.push_back(n->get_arg(i)->get_owner()); + bindings.push_back(n->get_arg(i)->get_expr()); } unsigned base_id = m.has_trace_stream() && accessors.size() > 0 ? m_util.plugin().get_axiom_base_id(d->get_name()) : 0; unsigned i = 0; for (func_decl * acc : accessors) { - app_ref acc_app(m.mk_app(acc, n->get_owner()), m); + app_ref acc_app(m.mk_app(acc, n->get_expr()), m); enode * arg = n->get_arg(i); std::function fn = [&]() { app_ref body(m); - body = m.mk_eq(arg->get_owner(), acc_app); + body = m.mk_eq(arg->get_expr(), acc_app); log_axiom_instantiation(body, base_id + 3*i, bindings.size(), bindings.c_ptr(), base_id - 3, used_enodes); }; scoped_trace_stream _st(m, fn); @@ -202,7 +202,7 @@ namespace smt { SASSERT(m_util.get_recognizer_constructor(r->get_decl()) == c->get_decl()); SASSERT(c->get_root() == r->get_arg(0)->get_root()); TRACE("recognizer_conflict", - tout << mk_ismt2_pp(c->get_owner(), m) << "\n" << mk_ismt2_pp(r->get_owner(), m) << "\n";); + tout << mk_ismt2_pp(c->get_expr(), m) << "\n" << mk_ismt2_pp(r->get_expr(), m) << "\n";); literal l(ctx.enode2bool_var(r)); SASSERT(ctx.get_assignment(l) == l_false); l.neg(); @@ -223,7 +223,7 @@ namespace smt { void theory_datatype::assert_update_field_axioms(enode * n) { m_stats.m_assert_update_field++; SASSERT(is_update_field(n)); - app* own = n->get_owner(); + app* own = n->get_expr(); expr* arg1 = own->get_arg(0); func_decl * upd = n->get_decl(); func_decl * acc = to_func_decl(upd->get_parameter(0).get_ast()); @@ -248,7 +248,7 @@ namespace smt { assert_eq_axiom(arg, acc_own, is_con); } // update_field is identity if 'n' is not created by a matching constructor. - app_ref imp(m.mk_implies(m.mk_not(rec_app), m.mk_eq(n->get_owner(), arg1)), m); + app_ref imp(m.mk_implies(m.mk_not(rec_app), m.mk_eq(n->get_expr(), arg1)), m); assert_eq_axiom(n, arg1, ~is_con); app_ref n_is_con(m.mk_app(rec, own), m); @@ -335,7 +335,7 @@ namespace smt { enode * arg = e->get_arg(i); sort * s = arg->get_sort(); if (m_autil.is_array(s) && m_util.is_datatype(get_array_range(s))) { - app_ref def(m_autil.mk_default(arg->get_owner()), m); + app_ref def(m_autil.mk_default(arg->get_expr()), m); if (!ctx.e_internalized(def)) { ctx.internalize(def, false); } @@ -381,9 +381,9 @@ namespace smt { // (assert (> (len a) 1) // // If the theory variable is not created for 'a', then a wrong model will be generated. - TRACE("datatype", tout << "apply_sort_cnstr: #" << n->get_owner_id() << " " << mk_pp(n->get_owner(), m) << "\n";); + TRACE("datatype", tout << "apply_sort_cnstr: #" << n->get_owner_id() << " " << pp(n, m) << "\n";); TRACE("datatype_bug", - tout << "apply_sort_cnstr:\n" << mk_pp(n->get_owner(), m) << " "; + tout << "apply_sort_cnstr:\n" << pp(n, m) << " "; tout << m_util.is_datatype(s) << " "; if (m_util.is_datatype(s)) tout << "is-infinite: " << s->is_infinite() << " "; if (m_util.is_datatype(s)) tout << "attached: " << is_attached_to_var(n) << " "; @@ -545,7 +545,7 @@ namespace smt { // explain the cycle root -> ... -> app -> root void theory_datatype::occurs_check_explain(enode * app, enode * root) { - TRACE("datatype", tout << "occurs_check_explain " << mk_bounded_pp(app->get_owner(), m) << " <-> " << mk_bounded_pp(root->get_owner(), m) << "\n";); + TRACE("datatype", tout << "occurs_check_explain " << mk_bounded_pp(app->get_expr(), m) << " <-> " << mk_bounded_pp(root->get_expr(), m) << "\n";); // first: explain that root=v, given that app=cstor(...,v,...) @@ -595,7 +595,7 @@ namespace smt { return true; } // explore `arg` (with parent) - expr* earg = arg->get_owner(); + expr* earg = arg->get_expr(); sort* s = earg->get_sort(); if (m_util.is_datatype(s)) { m_parent.insert(arg->get_root(), parent); @@ -626,7 +626,7 @@ namespace smt { for (enode* p : th->parent_selects(n)) { m_array_args.push_back(p); } - app_ref def(m_autil.mk_default(n->get_owner()), m); + app_ref def(m_autil.mk_default(n->get_expr()), m); m_array_args.push_back(ctx.get_enode(def)); return m_array_args; } @@ -780,10 +780,10 @@ namespace smt { result->add_dependency(arg); } TRACE("datatype", - tout << mk_pp(n->get_owner(), m) << "\n"; + tout << pp(n, m) << "\n"; tout << "depends on\n"; for (enode* arg : enode::args(d->m_constructor)) { - tout << " " << mk_pp(arg->get_owner(), m) << "\n"; + tout << " " << pp(arg, m) << "\n"; }); return result; } @@ -910,7 +910,7 @@ namespace smt { // conflict SASSERT(!lits.empty()); region & reg = ctx.get_region(); - TRACE("datatype_conflict", tout << mk_ismt2_pp(recognizer->get_owner(), m) << "\n"; + TRACE("datatype_conflict", tout << mk_ismt2_pp(recognizer->get_expr(), m) << "\n"; for (literal l : lits) { ctx.display_detailed_literal(tout, l) << "\n"; } @@ -927,7 +927,7 @@ namespace smt { if (!r) { ptr_vector const & constructors = *m_util.get_datatype_constructors(dt); func_decl * rec = m_util.get_constructor_is(constructors[unassigned_idx]); - app_ref rec_app(m.mk_app(rec, n->get_owner()), m); + app_ref rec_app(m.mk_app(rec, n->get_expr()), m); ctx.internalize(rec_app, false); consequent = literal(ctx.get_bool_var(rec_app)); } @@ -1007,7 +1007,7 @@ namespace smt { } } SASSERT(r != nullptr); - app_ref r_app(m.mk_app(r, n->get_owner()), m); + app_ref r_app(m.mk_app(r, n->get_expr()), m); TRACE("datatype", tout << "creating split: " << mk_pp(r_app, m) << "\n";); ctx.internalize(r_app, false); bool_var bv = ctx.get_bool_var(r_app); diff --git a/src/smt/theory_datatype.h b/src/smt/theory_datatype.h index 9e93b3b37..155a18a63 100644 --- a/src/smt/theory_datatype.h +++ b/src/smt/theory_datatype.h @@ -58,10 +58,10 @@ namespace smt { bool is_accessor(app * f) const { return m_util.is_accessor(f); } bool is_update_field(app * f) const { return m_util.is_update_field(f); } - bool is_constructor(enode * n) const { return is_constructor(n->get_owner()); } - bool is_recognizer(enode * n) const { return is_recognizer(n->get_owner()); } - bool is_accessor(enode * n) const { return is_accessor(n->get_owner()); } - bool is_update_field(enode * n) const { return m_util.is_update_field(n->get_owner()); } + bool is_constructor(enode * n) const { return is_constructor(n->get_expr()); } + bool is_recognizer(enode * n) const { return is_recognizer(n->get_expr()); } + bool is_accessor(enode * n) const { return is_accessor(n->get_expr()); } + bool is_update_field(enode * n) const { return m_util.is_update_field(n->get_expr()); } void assert_eq_axiom(enode * lhs, expr * rhs, literal antecedent); void assert_is_constructor_axiom(enode * n, func_decl * c, literal antecedent); diff --git a/src/smt/theory_dense_diff_logic_def.h b/src/smt/theory_dense_diff_logic_def.h index 5baf6ccc1..717d67f3c 100644 --- a/src/smt/theory_dense_diff_logic_def.h +++ b/src/smt/theory_dense_diff_logic_def.h @@ -51,7 +51,7 @@ namespace smt { template theory_var theory_dense_diff_logic::mk_var(enode * n) { theory_var v = theory::mk_var(n); - bool is_int = m_autil.is_int(n->get_owner()); + bool is_int = m_autil.is_int(n->get_expr()); m_is_int.push_back(is_int); m_f_targets.push_back(f_target()); for (auto& rows : m_matrix) { @@ -726,7 +726,7 @@ namespace smt { TRACE("ddl_model", tout << "ddl model\n"; for (theory_var v = 0; v < num_vars; v++) { - tout << "#" << mk_pp(get_enode(v)->get_owner(), m) << " = " << m_assignment[v] << "\n"; + tout << "#" << mk_pp(get_enode(v)->get_expr(), m) << " = " << m_assignment[v] << "\n"; }); } @@ -802,13 +802,13 @@ namespace smt { int num_vars = get_num_vars(); for (int v = 0; v < num_vars && v < (int)m_assignment.size(); ++v) { enode * n = get_enode(v); - if (m_autil.is_zero(n->get_owner()) && !m_assignment[v].is_zero()) { + if (m_autil.is_zero(n->get_expr()) && !m_assignment[v].is_zero()) { numeral val = m_assignment[v]; - sort * s = n->get_owner()->get_sort(); + sort * s = n->get_expr()->get_sort(); // adjust the value of all variables that have the same sort. for (int v2 = 0; v2 < num_vars; ++v2) { enode * n2 = get_enode(v2); - if (n2->get_owner()->get_sort() == s) { + if (n2->get_expr()->get_sort() == s) { m_assignment[v2] -= val; } } @@ -818,7 +818,7 @@ namespace smt { TRACE("ddl_model", tout << "ddl model\n"; for (theory_var v = 0; v < num_vars; v++) { - tout << "#" << mk_pp(get_enode(v)->get_owner(), m) << " = " << m_assignment[v] << "\n"; + tout << "#" << mk_pp(get_enode(v)->get_expr(), m) << " = " << m_assignment[v] << "\n"; }); } @@ -941,7 +941,7 @@ namespace smt { } for (unsigned i = 0; i < num_nodes; ++i) { enode * n = get_enode(i); - if (m_autil.is_zero(n->get_owner())) { + if (m_autil.is_zero(n->get_expr())) { S.set_lower(i, mpq_inf(mpq(0), mpq(0))); S.set_upper(i, mpq_inf(mpq(0), mpq(0))); break; @@ -1080,19 +1080,19 @@ namespace smt { expr_ref e(m), f(m), f2(m); TRACE("opt", tout << "mk_ineq " << v << " " << val << "\n";); if (t.size() == 1 && t[0].second.is_one()) { - f = get_enode(t[0].first)->get_owner(); + f = get_enode(t[0].first)->get_expr(); } else if (t.size() == 1 && t[0].second.is_minus_one()) { - f = m_autil.mk_uminus(get_enode(t[0].first)->get_owner()); + f = m_autil.mk_uminus(get_enode(t[0].first)->get_expr()); } else if (t.size() == 2 && t[0].second.is_one() && t[1].second.is_minus_one()) { - f = get_enode(t[0].first)->get_owner(); - f2 = get_enode(t[1].first)->get_owner(); + f = get_enode(t[0].first)->get_expr(); + f2 = get_enode(t[1].first)->get_expr(); f = m_autil.mk_sub(f, f2); } else if (t.size() == 2 && t[1].second.is_one() && t[0].second.is_minus_one()) { - f = get_enode(t[1].first)->get_owner(); - f2 = get_enode(t[0].first)->get_owner(); + f = get_enode(t[1].first)->get_expr(); + f2 = get_enode(t[0].first)->get_expr(); f = m_autil.mk_sub(f, f2); } else { diff --git a/src/smt/theory_diff_logic_def.h b/src/smt/theory_diff_logic_def.h index 54c3188b0..4c2c2ba88 100644 --- a/src/smt/theory_diff_logic_def.h +++ b/src/smt/theory_diff_logic_def.h @@ -384,11 +384,11 @@ final_check_status theory_diff_logic::final_check_eh() { } for (enode* n : ctx.enodes()) { - family_id fid = n->get_owner()->get_family_id(); + family_id fid = n->get_expr()->get_family_id(); if (fid != get_family_id() && fid != m.get_basic_family_id() && - !is_uninterp_const(n->get_owner())) { - TRACE("arith", tout << mk_pp(n->get_owner(), m) << "\n";); + !is_uninterp_const(n->get_expr())) { + TRACE("arith", tout << mk_pp(n->get_expr(), m) << "\n";); return FC_GIVEUP; } } @@ -607,8 +607,8 @@ void theory_diff_logic::new_edge(dl_var src, dl_var dst, unsigned num_edges } enode* e1 = get_enode(src); enode* e2 = get_enode(dst); - expr* n1 = e1->get_owner(); - expr* n2 = e2->get_owner(); + expr* n1 = e1->get_expr(); + expr* n2 = e2->get_expr(); bool is_int = m_util.is_int(n1); rational num = w.get_rational().to_rational(); @@ -821,7 +821,7 @@ theory_var theory_diff_logic::mk_var(enode* n) { TRACE("diff_logic_vars", tout << "mk_var: " << v << "\n";); m_graph.init_var(v); ctx.attach_th_var(n, this, v); - set_sort(n->get_owner()); + set_sort(n->get_expr()); return v; } @@ -938,12 +938,12 @@ model_value_proc * theory_diff_logic::mk_value(enode * n, model_generator & theory_var v = n->get_th_var(get_id()); SASSERT(v != null_theory_var); rational num; - if (!m_util.is_numeral(n->get_owner(), num)) { + if (!m_util.is_numeral(n->get_expr(), num)) { numeral val = m_graph.get_assignment(v); num = val.get_rational().to_rational() + m_delta * val.get_infinitesimal().to_rational(); } - TRACE("arith", tout << mk_pp(n->get_owner(), m) << " |-> " << num << "\n";); - bool is_int = m_util.is_int(n->get_owner()); + TRACE("arith", tout << mk_pp(n->get_expr(), m) << " |-> " << num << "\n";); + bool is_int = m_util.is_int(n->get_expr()); if (is_int && !num.is_int()) throw default_exception("difference logic solver was used on mixed int/real problem"); return alloc(expr_wrapper_proc, m_factory->mk_num_value(num, is_int)); @@ -983,7 +983,7 @@ theory_var theory_diff_logic::expand(bool pos, theory_var v, rational & k) enode* e = get_enode(v); rational r; for (;;) { - app* n = e->get_owner(); + app* n = e->get_expr(); if (m_util.is_add(n) && n->get_num_args() == 2) { app* x = to_app(n->get_arg(0)); app* y = to_app(n->get_arg(1)); @@ -1033,8 +1033,8 @@ void theory_diff_logic::new_eq_or_diseq(bool is_eq, theory_var v1, theory_v app_ref eq(m), s2(m), t2(m); - app* s1 = get_enode(s)->get_owner(); - app* t1 = get_enode(t)->get_owner(); + app* s1 = get_enode(s)->get_expr(); + app* t1 = get_enode(t)->get_expr(); s2 = m_util.mk_sub(t1, s1); t2 = m_util.mk_numeral(k, s2->get_sort()); // t1 - s1 = k @@ -1344,19 +1344,19 @@ expr_ref theory_diff_logic::mk_ineq(theory_var v, inf_eps const& val, bool objective_term const& t = m_objectives[v]; expr_ref e(m), f(m), f2(m); if (t.size() == 1 && t[0].second.is_one()) { - f = get_enode(t[0].first)->get_owner(); + f = get_enode(t[0].first)->get_expr(); } else if (t.size() == 1 && t[0].second.is_minus_one()) { - f = m_util.mk_uminus(get_enode(t[0].first)->get_owner()); + f = m_util.mk_uminus(get_enode(t[0].first)->get_expr()); } else if (t.size() == 2 && t[0].second.is_one() && t[1].second.is_minus_one()) { - f = get_enode(t[0].first)->get_owner(); - f2 = get_enode(t[1].first)->get_owner(); + f = get_enode(t[0].first)->get_expr(); + f2 = get_enode(t[1].first)->get_expr(); f = m_util.mk_sub(f, f2); } else if (t.size() == 2 && t[1].second.is_one() && t[0].second.is_minus_one()) { - f = get_enode(t[1].first)->get_owner(); - f2 = get_enode(t[0].first)->get_owner(); + f = get_enode(t[1].first)->get_expr(); + f2 = get_enode(t[0].first)->get_expr(); f = m_util.mk_sub(f, f2); } else { diff --git a/src/smt/theory_dl.cpp b/src/smt/theory_dl.cpp index 60e0b8c03..794874927 100644 --- a/src/smt/theory_dl.cpp +++ b/src/smt/theory_dl.cpp @@ -79,12 +79,12 @@ namespace smt { app * mk_value(smt::model_generator & mg, expr_ref_vector const & ) override { smt::context& ctx = m_th.get_context(); app* result = nullptr; - expr* n = m_node->get_owner(); + expr* n = m_node->get_expr(); sort* s = n->get_sort(); func_decl* r, *v; m_th.get_rep(s, r, v); app_ref rep_of(m_th.m()); - rep_of = m_th.m().mk_app(r, m_node->get_owner()); + rep_of = m_th.m().mk_app(r, m_node->get_expr()); theory_id bv_id = m_th.m().mk_family_id("bv"); theory_bv* th_bv = dynamic_cast(ctx.get_theory(bv_id)); SASSERT(th_bv); @@ -166,7 +166,7 @@ namespace smt { } void apply_sort_cnstr(enode * n, sort * s) override { - app* term = n->get_owner(); + app* term = n->get_expr(); if (u().is_finite_sort(term)) { mk_rep(term); } diff --git a/src/smt/theory_fpa.cpp b/src/smt/theory_fpa.cpp index 75289ddf8..cd5d2ad1e 100644 --- a/src/smt/theory_fpa.cpp +++ b/src/smt/theory_fpa.cpp @@ -228,7 +228,7 @@ namespace smt { void theory_fpa::attach_new_th_var(enode * n) { theory_var v = mk_var(n); ctx.attach_th_var(n, this, v); - TRACE("t_fpa", tout << "new theory var: " << mk_ismt2_pp(n->get_owner(), m) << " := " << v << "\n";); + TRACE("t_fpa", tout << "new theory var: " << mk_ismt2_pp(n->get_expr(), m) << " := " << v << "\n";); } bool theory_fpa::internalize_atom(app * atom, bool gate_ctx) { @@ -290,13 +290,13 @@ namespace smt { } void theory_fpa::apply_sort_cnstr(enode * n, sort * s) { - TRACE("t_fpa", tout << "apply sort cnstr for: " << mk_ismt2_pp(n->get_owner(), m) << "\n";); + TRACE("t_fpa", tout << "apply sort cnstr for: " << mk_ismt2_pp(n->get_expr(), m) << "\n";); SASSERT(s->get_family_id() == get_family_id()); SASSERT(m_fpa_util.is_float(s) || m_fpa_util.is_rm(s)); - SASSERT(m_fpa_util.is_float(n->get_owner()) || m_fpa_util.is_rm(n->get_owner())); - SASSERT(n->get_owner()->get_decl()->get_range() == s); + SASSERT(m_fpa_util.is_float(n->get_expr()) || m_fpa_util.is_rm(n->get_expr())); + SASSERT(n->get_expr()->get_decl()->get_range() == s); - app * owner = n->get_owner(); + app * owner = n->get_expr(); if (!is_attached_to_var(n)) { attach_new_th_var(n); @@ -322,13 +322,13 @@ namespace smt { enode * e_y = get_enode(y); TRACE("t_fpa", tout << "new eq: " << x << " = " << y << std::endl; - tout << mk_ismt2_pp(e_x->get_owner(), m) << std::endl << " = " << std::endl << - mk_ismt2_pp(e_y->get_owner(), m) << std::endl;); + tout << mk_ismt2_pp(e_x->get_expr(), m) << std::endl << " = " << std::endl << + mk_ismt2_pp(e_y->get_expr(), m) << std::endl;); fpa_util & fu = m_fpa_util; - expr * xe = e_x->get_owner(); - expr * ye = e_y->get_owner(); + expr * xe = e_x->get_expr(); + expr * ye = e_y->get_expr(); if (m_fpa_util.is_bvwrap(xe) || m_fpa_util.is_bvwrap(ye)) return; @@ -361,13 +361,13 @@ namespace smt { enode * e_y = get_enode(y); TRACE("t_fpa", tout << "new diseq: " << x << " != " << y << std::endl; - tout << mk_ismt2_pp(e_x->get_owner(), m) << std::endl << " != " << std::endl << - mk_ismt2_pp(e_y->get_owner(), m) << std::endl;); + tout << mk_ismt2_pp(e_x->get_expr(), m) << std::endl << " != " << std::endl << + mk_ismt2_pp(e_y->get_expr(), m) << std::endl;); fpa_util & fu = m_fpa_util; - expr * xe = e_x->get_owner(); - expr * ye = e_y->get_owner(); + expr * xe = e_x->get_expr(); + expr * ye = e_y->get_expr(); if (m_fpa_util.is_bvwrap(xe) || m_fpa_util.is_bvwrap(ye)) return; @@ -532,11 +532,11 @@ namespace smt { } model_value_proc * theory_fpa::mk_value(enode * n, model_generator & mg) { - TRACE("t_fpa", tout << "mk_value for: " << mk_ismt2_pp(n->get_owner(), m) << - " (sort " << mk_ismt2_pp(n->get_owner()->get_sort(), m) << ")\n";); + TRACE("t_fpa", tout << "mk_value for: " << mk_ismt2_pp(n->get_expr(), m) << + " (sort " << mk_ismt2_pp(n->get_expr()->get_sort(), m) << ")\n";); app_ref owner(m); - owner = get_ite_value(n->get_owner()); + owner = get_ite_value(n->get_expr()); // If the owner is not internalized, it doesn't have an enode associated. SASSERT(ctx.e_internalized(owner)); @@ -571,9 +571,9 @@ namespace smt { vp->add_dependency(ctx.get_enode(a1)); vp->add_dependency(ctx.get_enode(a2)); TRACE("t_fpa_detail", tout << "Depends on: " << - mk_ismt2_pp(a0, m) << " eq. cls. #" << get_enode(a0)->get_root()->get_owner()->get_id() << std::endl << - mk_ismt2_pp(a1, m) << " eq. cls. #" << get_enode(a1)->get_root()->get_owner()->get_id() << std::endl << - mk_ismt2_pp(a2, m) << " eq. cls. #" << get_enode(a2)->get_root()->get_owner()->get_id() << std::endl;); + mk_ismt2_pp(a0, m) << " eq. cls. #" << get_enode(a0)->get_root()->get_expr()->get_id() << std::endl << + mk_ismt2_pp(a1, m) << " eq. cls. #" << get_enode(a1)->get_root()->get_expr()->get_id() << std::endl << + mk_ismt2_pp(a2, m) << " eq. cls. #" << get_enode(a2)->get_root()->get_expr()->get_id() << std::endl;); res = vp; } else if (m_fpa_util.is_bv2rm(owner)) { @@ -583,7 +583,7 @@ namespace smt { fpa_rm_value_proc * vp = alloc(fpa_rm_value_proc, this); vp->add_dependency(ctx.get_enode(a0)); TRACE("t_fpa_detail", tout << "Depends on: " << - mk_ismt2_pp(a0, m) << " eq. cls. #" << get_enode(a0)->get_root()->get_owner()->get_id() << std::endl;); + mk_ismt2_pp(a0, m) << " eq. cls. #" << get_enode(a0)->get_root()->get_expr()->get_id() << std::endl;); res = vp; } else if (ctx.e_internalized(wrapped)) { @@ -598,7 +598,7 @@ namespace smt { fpa_value_proc * vp = alloc(fpa_value_proc, this, ebits, sbits); enode * en = ctx.get_enode(wrapped); vp->add_dependency(en); - TRACE("t_fpa_detail", tout << "Depends on: " << mk_ismt2_pp(wrapped, m) << " eq. cls. #" << en->get_root()->get_owner()->get_id() << std::endl;); + TRACE("t_fpa_detail", tout << "Depends on: " << mk_ismt2_pp(wrapped, m) << " eq. cls. #" << en->get_root()->get_expr()->get_id() << std::endl;); res = vp; } } @@ -646,7 +646,7 @@ namespace smt { if (v != -1) { if (first) out << "fpa theory variables:" << std::endl; out << v << " -> " << - mk_ismt2_pp(n->get_owner(), m) << std::endl; + mk_ismt2_pp(n->get_expr(), m) << std::endl; first = false; } } @@ -657,20 +657,20 @@ namespace smt { for (enode * n : ctx.enodes()) { theory_var v = n->get_th_var(m_bv_util.get_family_id()); if (v != -1) out << v << " -> " << - mk_ismt2_pp(n->get_owner(), m) << std::endl; + mk_ismt2_pp(n->get_expr(), m) << std::endl; } out << "arith theory variables:" << std::endl; for (enode* n : ctx.enodes()) { theory_var v = n->get_th_var(m_arith_util.get_family_id()); if (v != -1) out << v << " -> " << - mk_ismt2_pp(n->get_owner(), m) << std::endl; + mk_ismt2_pp(n->get_expr(), m) << std::endl; } out << "equivalence classes:\n"; for (enode * n : ctx.enodes()) { - expr * e = n->get_owner(); - expr * r = n->get_root()->get_owner(); + expr * e = n->get_expr(); + expr * r = n->get_root()->get_expr(); out << r->get_id() << " --> " << mk_ismt2_pp(e, m) << std::endl; } } diff --git a/src/smt/theory_lra.cpp b/src/smt/theory_lra.cpp index bf1ec9cb2..6ec1e5deb 100644 --- a/src/smt/theory_lra.cpp +++ b/src/smt/theory_lra.cpp @@ -239,12 +239,12 @@ class theory_lra::imp { theory_id get_id() const { return th.get_id(); } theory_arith_params const& params() const { return ctx().get_fparams(); } bool is_int(theory_var v) const { return is_int(get_enode(v)); } - bool is_int(enode* n) const { return a.is_int(n->get_owner()); } + bool is_int(enode* n) const { return a.is_int(n->get_expr()); } bool is_real(theory_var v) const { return is_real(get_enode(v)); } - bool is_real(enode* n) const { return a.is_real(n->get_owner()); } + bool is_real(enode* n) const { return a.is_real(n->get_expr()); } enode* get_enode(theory_var v) const { return th.get_enode(v); } enode* get_enode(expr* e) const { return ctx().get_enode(e); } - expr* get_owner(theory_var v) const { return get_enode(v)->get_owner(); } + expr* get_owner(theory_var v) const { return get_enode(v)->get_expr(); } lpvar add_const(int c, lpvar& var, bool is_int) { if (var != UINT_MAX) { @@ -717,8 +717,8 @@ class theory_lra::imp { } TRACE("arith", { - expr* o1 = get_enode(v1)->get_owner(); - expr* o2 = get_enode(v2)->get_owner(); + expr* o1 = get_enode(v1)->get_expr(); + expr* o2 = get_enode(v2)->get_expr(); tout << "v" << v1 << " = " << "v" << v2 << ": " << mk_pp(o1, m) << " = " << mk_pp(o2, m) << "\n"; }); @@ -1046,7 +1046,7 @@ public: } void apply_sort_cnstr(enode* n, sort*) { - TRACE("arith", tout << "sort constraint: " << mk_pp(n->get_owner(), m) << "\n";); + TRACE("arith", tout << "sort constraint: " << pp(n, m) << "\n";); #if 0 if (!th.is_attached_to_var(n)) { mk_var(n->get_owner()); @@ -1201,9 +1201,9 @@ public: /// abs(r) > r >= 0 void assert_idiv_mod_axioms(theory_var u, theory_var v, theory_var w, rational const& r) { app_ref term(m); - term = a.mk_mul(a.mk_numeral(r, true), get_enode(w)->get_owner()); - term = a.mk_add(get_enode(v)->get_owner(), term); - term = a.mk_sub(get_enode(u)->get_owner(), term); + term = a.mk_mul(a.mk_numeral(r, true), get_enode(w)->get_expr()); + term = a.mk_add(get_enode(v)->get_expr(), term); + term = a.mk_sub(get_enode(u)->get_expr(), term); theory_var z = internalize_def(term); lpvar zi = register_theory_var_in_lar_solver(z); lpvar vi = register_theory_var_in_lar_solver(v); @@ -1502,8 +1502,8 @@ public: } enode* n2 = get_enode(other); if (n1->get_root() != n2->get_root()) { - TRACE("arith", tout << mk_pp(n1->get_owner(), m) << " = " << mk_pp(n2->get_owner(), m) << "\n"; - tout << mk_pp(n1->get_owner(), m) << " = " << mk_pp(n2->get_owner(), m) << "\n"; + TRACE("arith", tout << pp(n1, m) << " = " << pp(n2, m) << "\n"; + tout << pp(n1, m) << " = " << pp(n2, m) << "\n"; tout << "v" << v << " = " << "v" << other << "\n";); m_assume_eq_candidates.push_back(std::make_pair(v, other)); num_candidates++; @@ -1650,7 +1650,7 @@ public: rational lc = denominator(k); for (auto const& kv : coeffs) { theory_var w = kv.m_key; - expr* o = get_enode(w)->get_owner(); + expr* o = get_enode(w)->get_expr(); is_int = a.is_int(o); if (!is_int) break; lc = lcm(lc, denominator(kv.m_value)); @@ -2076,7 +2076,7 @@ public: } else { for (enode * parent : r->get_const_parents()) { - if (a.is_underspecified(parent->get_owner())) { + if (a.is_underspecified(parent->get_expr())) { return true; } } @@ -2253,7 +2253,7 @@ public: lpvar vi = be.m_j; if (lp::tv::is_term(vi)) return; - expr_ref w(get_enode(v)->get_owner(), m); + expr_ref w(get_enode(v)->get_expr(), m); if (a.is_add(w) || a.is_numeral(w) || m.is_ite(w)) return; literal bound = null_literal; @@ -2297,8 +2297,8 @@ public: return; if (!ctx().is_shared(n1) || !ctx().is_shared(n2)) return; - expr* e1 = n1->get_owner(); - expr* e2 = n2->get_owner(); + expr* e1 = n1->get_expr(); + expr* e2 = n2->get_expr(); if (e1->get_sort() != e2->get_sort()) return; if (m.is_ite(e1) || m.is_ite(e2)) @@ -3077,9 +3077,9 @@ public: for (auto c : m_core) ctx().display_detailed_literal(tout, c) << "\n"; for (auto e : m_eqs) - tout << mk_pp(e.first->get_owner(), m) << " = " << mk_pp(e.second->get_owner(), m) << "\n"; + tout << pp(e.first, m) << " = " << pp(e.second, m) << "\n"; tout << " ==> "; - tout << mk_pp(x->get_owner(), m) << " = " << mk_pp(y->get_owner(), m) << "\n"; + tout << pp(x, m) << " = " << pp(y, m) << "\n"; ); // parameters are TBD. @@ -3189,7 +3189,7 @@ public: } else { for (auto const& eq : m_eqs) { - m_core.push_back(th.mk_eq(eq.first->get_owner(), eq.second->get_owner(), false)); + m_core.push_back(th.mk_eq(eq.first->get_expr(), eq.second->get_expr(), false)); } for (literal & c : m_core) { c.neg(); @@ -3287,7 +3287,7 @@ public: model_value_proc * mk_value(enode * n, model_generator & mg) { theory_var v = n->get_th_var(get_id()); - expr* o = n->get_owner(); + expr* o = n->get_expr(); if (use_nra_model() && lp().external_to_local(v) != lp::null_lpvar) { anum const& an = nl_value(v, *m_a1); if (a.is_int(o) && !m_nla->am().is_int(an)) { @@ -3309,7 +3309,7 @@ public: if (!is_registered_var(v)) return false; lpvar vi = get_lpvar(v); if (lp().has_value(vi, val)) { - TRACE("arith", tout << expr_ref(n->get_owner(), m) << " := " << val << "\n";); + TRACE("arith", tout << expr_ref(n->get_expr(), m) << " := " << val << "\n";); if (is_int(n) && !val.is_int()) return false; return true; } @@ -3433,7 +3433,7 @@ public: if (params().m_arith_mode == arith_solver_id::AS_NEW_ARITH) return true; context nctx(m, ctx().get_fparams(), ctx().get_params()); add_background(nctx); - nctx.assert_expr(m.mk_not(m.mk_eq(x->get_owner(), y->get_owner()))); + nctx.assert_expr(m.mk_not(m.mk_eq(x->get_expr(), y->get_expr()))); cancel_eh eh(m.limit()); scoped_timer timer(1000, &eh); return l_true != nctx.check(); @@ -3446,7 +3446,7 @@ public: nctx.assert_expr(tmp); } for (auto const& eq : m_eqs) { - nctx.assert_expr(m.mk_eq(eq.first->get_owner(), eq.second->get_owner())); + nctx.assert_expr(m.mk_eq(eq.first->get_expr(), eq.second->get_expr())); } } @@ -3508,7 +3508,7 @@ public: expr_ref mk_gt(theory_var v) { lp::impq val = get_ivalue(v); - expr* obj = get_enode(v)->get_owner(); + expr* obj = get_enode(v)->get_expr(); rational r = val.x; expr_ref e(m); if (a.is_int(obj->get_sort())) { @@ -3571,7 +3571,7 @@ public: expr_ref_vector args(m); for (auto const& kv : coeffs) { theory_var w = kv.m_key; - expr* o = get_enode(w)->get_owner(); + expr* o = get_enode(w)->get_expr(); if (kv.m_value.is_zero()) { // continue } @@ -3618,13 +3618,13 @@ public: app_ref mk_obj(theory_var v) { auto t = get_tv(v); - bool is_int = a.is_int(get_enode(v)->get_owner()); + bool is_int = a.is_int(get_enode(v)->get_expr()); if (t.is_term()) { return mk_term(lp().get_term(t), is_int); } else { // theory_var w = lp().external_to_local(vi); - return app_ref(get_enode(v)->get_owner(), m); + return app_ref(get_enode(v)->get_expr(), m); } } @@ -3632,7 +3632,7 @@ public: rational r = val.get_rational(); bool is_strict = val.get_infinitesimal().is_pos(); app_ref b(m); - bool is_int = a.is_int(get_enode(v)->get_owner()); + bool is_int = a.is_int(get_enode(v)->get_expr()); TRACE("arith", display(tout << "v" << v << "\n");); if (is_strict) { b = a.mk_le(mk_obj(v), a.mk_numeral(r, is_int)); @@ -3708,13 +3708,13 @@ public: break; } case equality_source: - out << mk_pp(m_equalities[idx].first->get_owner(), m) << " = " - << mk_pp(m_equalities[idx].second->get_owner(), m) << "\n"; + out << pp(m_equalities[idx].first, m) << " = " + << pp(m_equalities[idx].second, m) << "\n"; break; case definition_source: { theory_var v = m_definitions[idx]; if (v != null_theory_var) - out << "def: v" << v << " := " << mk_pp(th.get_enode(v)->get_owner(), m) << "\n"; + out << "def: v" << v << " := " << pp(th.get_enode(v), m) << "\n"; break; } case null_source: diff --git a/src/smt/theory_pb.cpp b/src/smt/theory_pb.cpp index 2c6474c6c..19f7e0677 100644 --- a/src/smt/theory_pb.cpp +++ b/src/smt/theory_pb.cpp @@ -2355,7 +2355,7 @@ namespace smt { } model_value_proc * theory_pb::mk_value(enode * n, model_generator & mg) { - app* a = n->get_owner(); + app* a = n->get_expr(); pb_model_value_proc* p = alloc(pb_model_value_proc, a); for (unsigned i = 0; i < a->get_num_args(); ++i) { p->add(ctx.get_enode(a->get_arg(i))); diff --git a/src/smt/theory_recfun.h b/src/smt/theory_recfun.h index a60b4c9ea..c6dead6c4 100644 --- a/src/smt/theory_recfun.h +++ b/src/smt/theory_recfun.h @@ -63,8 +63,8 @@ namespace smt { bool is_defined(app * f) const { return u().is_defined(f); } bool is_case_pred(app * f) const { return u().is_case_pred(f); } - bool is_defined(enode * e) const { return is_defined(e->get_owner()); } - bool is_case_pred(enode * e) const { return is_case_pred(e->get_owner()); } + bool is_defined(enode * e) const { return is_defined(e->get_expr()); } + bool is_case_pred(enode * e) const { return is_case_pred(e->get_expr()); } void activate_guard(expr* guard, expr_ref_vector const& guards); diff --git a/src/smt/theory_seq.cpp b/src/smt/theory_seq.cpp index c93666282..80f7cf0e5 100644 --- a/src/smt/theory_seq.cpp +++ b/src/smt/theory_seq.cpp @@ -555,7 +555,7 @@ bool theory_seq::check_extensionality() { unsigned_vector seqs; for (unsigned v = 0; v < sz; ++v) { enode* n1 = get_enode(v); - expr* o1 = n1->get_owner(); + expr* o1 = n1->get_expr(); if (n1 != n1->get_root()) { continue; } @@ -567,7 +567,7 @@ bool theory_seq::check_extensionality() { } for (theory_var v : seqs) { enode* n2 = get_enode(v); - expr* o2 = n2->get_owner(); + expr* o2 = n2->get_expr(); if (o1->get_sort() != o2->get_sort()) { continue; } @@ -575,7 +575,7 @@ bool theory_seq::check_extensionality() { continue; } expr_ref e2(m); - if (!canonize(n2->get_owner(), dep, e2)) { + if (!canonize(n2->get_expr(), dep, e2)) { return false; } m_new_eqs.reset(); @@ -783,13 +783,13 @@ bool theory_seq::propagate_eq(dependency* dep, enode* n1, enode* n2) { enode_pair_vector eqs; linearize(dep, eqs, lits); TRACE("seq_verbose", - tout << "assert: " << mk_bounded_pp(n1->get_owner(), m) << " = " << mk_bounded_pp(n2->get_owner(), m) << " <-\n"; + tout << "assert: " << mk_bounded_pp(n1->get_expr(), m) << " = " << mk_bounded_pp(n2->get_expr(), m) << " <-\n"; display_deps(tout, dep); ); TRACE("seq", tout << "assert: " - << mk_bounded_pp(n1->get_owner(), m) << " = " << mk_bounded_pp(n2->get_owner(), m) << " <-\n" + << mk_bounded_pp(n1->get_expr(), m) << " = " << mk_bounded_pp(n2->get_expr(), m) << " <-\n" << lits << "\n"; ); @@ -799,7 +799,7 @@ bool theory_seq::propagate_eq(dependency* dep, enode* n1, enode* n2) { get_id(), ctx.get_region(), lits.size(), lits.c_ptr(), eqs.size(), eqs.c_ptr(), n1, n2)); { - std::function fn = [&]() { return m.mk_eq(n1->get_owner(), n2->get_owner()); }; + std::function fn = [&]() { return m.mk_eq(n1->get_expr(), n2->get_expr()); }; scoped_trace_stream _sts(*this, fn); ctx.assign_eq(n1, n2, eq_justification(js)); } @@ -823,8 +823,8 @@ bool theory_seq::propagate_eq(dependency* dep, literal lit, expr* e1, expr* e2, } void theory_seq::enforce_length_coherence(enode* n1, enode* n2) { - expr* o1 = n1->get_owner(); - expr* o2 = n2->get_owner(); + expr* o1 = n1->get_expr(); + expr* o2 = n2->get_expr(); if (m_util.str.is_concat(o1) && m_util.str.is_concat(o2)) { return; } @@ -1555,7 +1555,7 @@ bool theory_seq::add_length_to_eqc(expr* e) { enode* n1 = n; bool change = false; do { - expr* o = n->get_owner(); + expr* o = n->get_expr(); if (!has_length(o)) { expr_ref len(m_util.str.mk_length(o), m); enque_axiom(len); @@ -1701,8 +1701,8 @@ std::ostream& theory_seq::display_deps(std::ostream& out, literal_vector const& for (auto const& eq : eqs) { if (eq.first->get_root() != eq.second->get_root()) out << "invalid: "; - out << " (= " << mk_bounded_pp(eq.first->get_owner(), m, 2) - << "\n " << mk_bounded_pp(eq.second->get_owner(), m, 2) + out << " (= " << mk_bounded_pp(eq.first->get_expr(), m, 2) + << "\n " << mk_bounded_pp(eq.second->get_expr(), m, 2) << ")\n"; } for (literal l : lits) { @@ -1714,8 +1714,8 @@ std::ostream& theory_seq::display_deps(std::ostream& out, literal_vector const& std::ostream& theory_seq::display_deps_smt2(std::ostream& out, literal_vector const& lits, enode_pair_vector const& eqs) const { params_ref p; for (auto const& eq : eqs) { - out << " (= " << mk_pp(eq.first->get_owner(), m) - << "\n " << mk_pp(eq.second->get_owner(), m) + out << " (= " << pp(eq.first, m) + << "\n " << pp(eq.second, m) << ")\n"; } for (literal l : lits) { @@ -1911,7 +1911,7 @@ public: th.m_str_rewrite(result); } th.m_factory->add_trail(result); - TRACE("seq", tout << mk_pp(m_node->get_owner(), th.m) << " -> " << result << "\n";); + TRACE("seq", tout << pp(m_node, th.m) << " -> " << result << "\n";); return to_app(result); } }; @@ -1933,7 +1933,7 @@ app* theory_seq::get_ite_value(expr* e) { } model_value_proc * theory_seq::mk_value(enode * n, model_generator & mg) { - app* e = n->get_owner(); + app* e = n->get_expr(); TRACE("seq", tout << mk_pp(e, m) << "\n";); // Shortcut for well-founded values to avoid some quadratic overhead @@ -2241,11 +2241,11 @@ void theory_seq::validate_assign(literal lit, enode_pair_vector const& eqs, lite void theory_seq::validate_assign_eq(enode* a, enode* b, enode_pair_vector const& eqs, literal_vector const& lits) { IF_VERBOSE(10, display_deps(verbose_stream() << "; assign-eq\n", lits, eqs); - verbose_stream() << "(not (= " << mk_bounded_pp(a->get_owner(), m) - << " " << mk_bounded_pp(b->get_owner(), m) << "))\n"); + verbose_stream() << "(not (= " << mk_bounded_pp(a->get_expr(), m) + << " " << mk_bounded_pp(b->get_expr(), m) << "))\n"); if (get_fparams().m_seq_validate) { expr_ref_vector fmls(m); - fmls.push_back(m.mk_not(m.mk_eq(a->get_owner(), b->get_owner()))); + fmls.push_back(m.mk_not(m.mk_eq(a->get_expr(), b->get_expr()))); validate_fmls(eqs, lits, fmls); } } @@ -2261,7 +2261,7 @@ void theory_seq::validate_fmls(enode_pair_vector const& eqs, literal_vector cons fmls.push_back(fml); } for (auto const& p : eqs) { - fmls.push_back(m.mk_eq(p.first->get_owner(), p.second->get_owner())); + fmls.push_back(m.mk_eq(p.first->get_expr(), p.second->get_expr())); } TRACE("seq", tout << fmls << "\n";); @@ -2287,7 +2287,7 @@ void theory_seq::validate_fmls(enode_pair_vector const& eqs, literal_vector cons } theory_var theory_seq::mk_var(enode* n) { - expr* o = n->get_owner(); + expr* o = n->get_expr(); if (!m_util.is_seq(o) && !m_util.is_re(o)) return null_theory_var; @@ -2962,8 +2962,8 @@ void theory_seq::assign_eh(bool_var v, bool is_true) { void theory_seq::new_eq_eh(theory_var v1, theory_var v2) { enode* n1 = get_enode(v1); enode* n2 = get_enode(v2); - expr* o1 = n1->get_owner(); - expr* o2 = n2->get_owner(); + expr* o1 = n1->get_expr(); + expr* o2 = n2->get_expr(); if (!m_util.is_seq(o1) && !m_util.is_re(o1)) return; if (m_util.is_re(o1)) { @@ -2976,8 +2976,8 @@ void theory_seq::new_eq_eh(theory_var v1, theory_var v2) { } void theory_seq::new_eq_eh(dependency* deps, enode* n1, enode* n2) { - expr* e1 = n1->get_owner(); - expr* e2 = n2->get_owner(); + expr* e1 = n1->get_expr(); + expr* e2 = n2->get_expr(); TRACE("seq", tout << mk_bounded_pp(e1, m) << " = " << mk_bounded_pp(e2, m) << "\n";); if (n1 != n2 && m_util.is_seq(e1)) { theory_var v1 = n1->get_th_var(get_id()); @@ -3003,11 +3003,11 @@ void theory_seq::new_eq_eh(dependency* deps, enode* n1, enode* n2) { void theory_seq::new_diseq_eh(theory_var v1, theory_var v2) { enode* n1 = get_enode(v1); enode* n2 = get_enode(v2); - expr_ref e1(n1->get_owner(), m); - expr_ref e2(n2->get_owner(), m); + expr_ref e1(n1->get_expr(), m); + expr_ref e2(n2->get_expr(), m); if (n1->get_root() == n2->get_root()) return; - if (m_util.is_re(n1->get_owner())) { + if (m_util.is_re(n1->get_expr())) { m_regex.propagate_ne(e1, e2); return; } diff --git a/src/smt/theory_special_relations.cpp b/src/smt/theory_special_relations.cpp index 0cc6f9c4d..7b4fed92d 100644 --- a/src/smt/theory_special_relations.cpp +++ b/src/smt/theory_special_relations.cpp @@ -532,8 +532,8 @@ namespace smt { r.m_graph.find_shortest_zero_edge_path(i, j, timestamp, r); r.m_graph.find_shortest_zero_edge_path(j, i, timestamp, r); literal_vector const& lits = r.m_explanation; - TRACE("special_relations", ctx.display_literals_verbose(tout << mk_pp(x->get_owner(), m) << " = " << mk_pp(y->get_owner(), m) << "\n", lits) << "\n";); - IF_VERBOSE(20, ctx.display_literals_verbose(verbose_stream() << mk_pp(x->get_owner(), m) << " = " << mk_pp(y->get_owner(), m) << "\n", lits) << "\n";); + TRACE("special_relations", ctx.display_literals_verbose(tout << mk_pp(x->get_expr(), m) << " = " << mk_pp(y->get_expr(), m) << "\n", lits) << "\n";); + IF_VERBOSE(20, ctx.display_literals_verbose(verbose_stream() << mk_pp(x->get_expr(), m) << " = " << mk_pp(y->get_expr(), m) << "\n", lits) << "\n";); eq_justification js(ctx.mk_justification(ext_theory_eq_propagation_justification(get_id(), ctx.get_region(), lits.size(), lits.c_ptr(), 0, nullptr, x, y))); ctx.assign_eq(x, y, js); @@ -945,8 +945,8 @@ namespace smt { atom& a = *ap; if (!a.phase()) continue; SASSERT(ctx.get_assignment(a.var()) == l_true); - expr* x = get_enode(a.v1())->get_root()->get_owner(); - expr* y = get_enode(a.v2())->get_root()->get_owner(); + expr* x = get_enode(a.v1())->get_root()->get_expr(); + expr* y = get_enode(a.v2())->get_root()->get_expr(); expr* cb = connected_body; expr* args[5] = { x, y, A, S, cb }; connected_body = m.mk_app(nextf, 5, args); diff --git a/src/smt/theory_str.cpp b/src/smt/theory_str.cpp index f09041114..6f7f53a73 100644 --- a/src/smt/theory_str.cpp +++ b/src/smt/theory_str.cpp @@ -315,8 +315,8 @@ namespace smt { } theory_var theory_str::mk_var(enode* n) { - TRACE("str", tout << "mk_var for " << mk_pp(n->get_owner(), get_manager()) << std::endl;); - if (!(n->get_owner()->get_sort() == u.str.mk_string_sort())) { + TRACE("str", tout << "mk_var for " << mk_pp(n->get_expr(), get_manager()) << std::endl;); + if (!(n->get_expr()->get_sort() == u.str.mk_string_sort())) { return null_theory_var; } if (is_attached_to_var(n)) { @@ -809,7 +809,7 @@ namespace smt { unsigned start_count = m_library_aware_axiom_todo.size(); ptr_vector axioms_tmp(m_library_aware_axiom_todo); for (auto const& e : axioms_tmp) { - app * a = e->get_owner(); + app * a = e->get_expr(); if (u.str.is_stoi(a)) { instantiate_axiom_str_to_int(e); } else if (u.str.is_itos(a)) { @@ -837,7 +837,7 @@ namespace smt { } else if (u.str.is_to_code(a)) { instantiate_axiom_str_to_code(e); } else { - TRACE("str", tout << "BUG: unhandled library-aware term " << mk_pp(e->get_owner(), get_manager()) << std::endl;); + TRACE("str", tout << "BUG: unhandled library-aware term " << mk_pp(e->get_expr(), get_manager()) << std::endl;); NOT_IMPLEMENTED_YET(); } } @@ -884,7 +884,7 @@ namespace smt { */ void theory_str::try_eval_concat(enode * cat) { - app * a_cat = cat->get_owner(); + app * a_cat = cat->get_expr(); SASSERT(u.str.is_concat(a_cat)); ast_manager & m = get_manager(); @@ -934,7 +934,7 @@ namespace smt { */ void theory_str::instantiate_concat_axiom(enode * cat) { ast_manager & m = get_manager(); - app * a_cat = cat->get_owner(); + app * a_cat = cat->get_expr(); TRACE("str", tout << "instantiating concat axiom for " << mk_ismt2_pp(a_cat, m) << std::endl;); if (!u.str.is_concat(a_cat)) { return; @@ -979,13 +979,13 @@ namespace smt { void theory_str::instantiate_basic_string_axioms(enode * str) { ast_manager & m = get_manager(); - TRACE("str", tout << "set up basic string axioms on " << mk_pp(str->get_owner(), m) << std::endl;); + TRACE("str", tout << "set up basic string axioms on " << mk_pp(str->get_expr(), m) << std::endl;); { - sort * a_sort = str->get_owner()->get_sort(); + sort * a_sort = str->get_expr()->get_sort(); sort * str_sort = u.str.mk_string_sort(); if (a_sort != str_sort) { - TRACE("str", tout << "WARNING: not setting up string axioms on non-string term " << mk_pp(str->get_owner(), m) << std::endl;); + TRACE("str", tout << "WARNING: not setting up string axioms on non-string term " << mk_pp(str->get_expr(), m) << std::endl;); return; } } @@ -997,7 +997,7 @@ namespace smt { } // generate a stronger axiom for constant strings - app * a_str = str->get_owner(); + app * a_str = str->get_expr(); if (u.str.is_string(a_str)) { expr_ref len_str(m); @@ -1005,7 +1005,7 @@ namespace smt { SASSERT(len_str); zstring strconst; - u.str.is_string(str->get_owner(), strconst); + u.str.is_string(str->get_expr(), strconst); TRACE("str", tout << "instantiating constant string axioms for \"" << strconst.encode() << '"' << std::endl;); unsigned int l = strconst.length(); expr_ref len(m_autil.mk_numeral(rational(l), true), m); @@ -1071,8 +1071,8 @@ namespace smt { void theory_str::instantiate_str_eq_length_axiom(enode * lhs, enode * rhs) { ast_manager & m = get_manager(); - app * a_lhs = lhs->get_owner(); - app * a_rhs = rhs->get_owner(); + app * a_lhs = lhs->get_expr(); + app * a_rhs = rhs->get_expr(); // build premise: (lhs == rhs) expr_ref premise(ctx.mk_eq_atom(a_lhs, a_rhs), m); @@ -1092,7 +1092,7 @@ namespace smt { void theory_str::instantiate_axiom_CharAt(enode * e) { ast_manager & m = get_manager(); expr* arg0, *arg1; - app * expr = e->get_owner(); + app * expr = e->get_expr(); if (axiomatized_terms.contains(expr)) { TRACE("str", tout << "already set up CharAt axiom for " << mk_pp(expr, m) << std::endl;); return; @@ -1127,7 +1127,7 @@ namespace smt { void theory_str::instantiate_axiom_prefixof(enode * e) { ast_manager & m = get_manager(); - app * expr = e->get_owner(); + app * expr = e->get_expr(); if (axiomatized_terms.contains(expr)) { TRACE("str", tout << "already set up prefixof axiom for " << mk_pp(expr, m) << std::endl;); return; @@ -1163,7 +1163,7 @@ namespace smt { void theory_str::instantiate_axiom_suffixof(enode * e) { ast_manager & m = get_manager(); - app * expr = e->get_owner(); + app * expr = e->get_expr(); if (axiomatized_terms.contains(expr)) { TRACE("str", tout << "already set up suffixof axiom for " << mk_pp(expr, m) << std::endl;); return; @@ -1199,7 +1199,7 @@ namespace smt { void theory_str::instantiate_axiom_Contains(enode * e) { ast_manager & m = get_manager(); - app * ex = e->get_owner(); + app * ex = e->get_expr(); if (axiomatized_terms.contains(ex)) { TRACE("str", tout << "already set up Contains axiom for " << mk_pp(ex, m) << std::endl;); return; @@ -1249,7 +1249,7 @@ namespace smt { th_rewriter & rw = ctx.get_rewriter(); ast_manager & m = get_manager(); - app * ex = e->get_owner(); + app * ex = e->get_expr(); if (axiomatized_terms.contains(ex)) { TRACE("str", tout << "already set up str.indexof axiom for " << mk_pp(ex, m) << std::endl;); return; @@ -1350,7 +1350,7 @@ namespace smt { th_rewriter & rw = ctx.get_rewriter(); ast_manager & m = get_manager(); - app * e = _e->get_owner(); + app * e = _e->get_expr(); if (axiomatized_terms.contains(e)) { TRACE("str", tout << "already set up extended str.indexof axiom for " << mk_pp(e, m) << std::endl;); return; @@ -1494,7 +1494,7 @@ namespace smt { void theory_str::instantiate_axiom_LastIndexof(enode * e) { ast_manager & m = get_manager(); - app * expr = e->get_owner(); + app * expr = e->get_expr(); if (axiomatized_terms.contains(expr)) { TRACE("str", tout << "already set up LastIndexof axiom for " << mk_pp(expr, m) << std::endl;); return; @@ -1565,7 +1565,7 @@ namespace smt { expr* substrPos = nullptr; expr* substrLen = nullptr; - app * expr = e->get_owner(); + app * expr = e->get_expr(); if (axiomatized_terms.contains(expr)) { TRACE("str", tout << "already set up Substr axiom for " << mk_pp(expr, m) << std::endl;); return; @@ -1667,7 +1667,7 @@ namespace smt { void theory_str::instantiate_axiom_Replace(enode * e) { ast_manager & m = get_manager(); - app * ex = e->get_owner(); + app * ex = e->get_expr(); if (axiomatized_terms.contains(ex)) { TRACE("str", tout << "already set up Replace axiom for " << mk_pp(ex, m) << std::endl;); return; @@ -1724,7 +1724,7 @@ namespace smt { void theory_str::instantiate_axiom_str_to_int(enode * e) { ast_manager & m = get_manager(); - app * ex = e->get_owner(); + app * ex = e->get_expr(); if (axiomatized_terms.contains(ex)) { TRACE("str", tout << "already set up str.to-int axiom for " << mk_pp(ex, m) << std::endl;); return; @@ -1774,7 +1774,7 @@ namespace smt { void theory_str::instantiate_axiom_int_to_str(enode * e) { ast_manager & m = get_manager(); - app * ex = e->get_owner(); + app * ex = e->get_expr(); if (axiomatized_terms.contains(ex)) { TRACE("str", tout << "already set up str.from-int axiom for " << mk_pp(ex, m) << std::endl;); return; @@ -1809,7 +1809,7 @@ namespace smt { void theory_str::instantiate_axiom_is_digit(enode * e) { ast_manager & m = get_manager(); - app * ex = e->get_owner(); + app * ex = e->get_expr(); if (axiomatized_terms.contains(ex)) { TRACE("str", tout << "already set up str.is_digit axiom for " << mk_pp(ex, m) << std::endl;); return; @@ -1837,7 +1837,7 @@ namespace smt { void theory_str::instantiate_axiom_str_from_code(enode * e) { ast_manager & m = get_manager(); - app * ex = e->get_owner(); + app * ex = e->get_expr(); if (axiomatized_terms.contains(ex)) { TRACE("str", tout << "already set up str.from_code axiom for " << mk_pp(ex, m) << std::endl;); return; @@ -1873,7 +1873,7 @@ namespace smt { void theory_str::instantiate_axiom_str_to_code(enode * e) { ast_manager & m = get_manager(); - app * ex = e->get_owner(); + app * ex = e->get_expr(); if (axiomatized_terms.contains(ex)) { TRACE("str", tout << "already set up str.to_code axiom for " << mk_pp(ex, m) << std::endl;); return; @@ -1910,7 +1910,7 @@ namespace smt { void theory_str::instantiate_axiom_RegexIn(enode * e) { ast_manager & m = get_manager(); - app * ex = e->get_owner(); + app * ex = e->get_expr(); if (axiomatized_terms.contains(ex)) { TRACE("str", tout << "already set up RegexIn axiom for " << mk_pp(ex, m) << std::endl;); return; @@ -1931,7 +1931,7 @@ namespace smt { void theory_str::attach_new_th_var(enode * n) { theory_var v = mk_var(n); ctx.attach_th_var(n, this, v); - TRACE("str", tout << "new theory var: " << mk_ismt2_pp(n->get_owner(), get_manager()) << " := v#" << v << std::endl;); + TRACE("str", tout << "new theory var: " << mk_ismt2_pp(n->get_expr(), get_manager()) << " := v#" << v << std::endl;); } void theory_str::reset_eh() { @@ -2006,7 +2006,7 @@ namespace smt { // support for user_smt_theory-style EQC handling app * theory_str::get_ast(theory_var v) { - return get_enode(v)->get_owner(); + return get_enode(v)->get_expr(); } theory_var theory_str::get_var(expr * n) const { @@ -2150,7 +2150,7 @@ namespace smt { for (auto &e_parent : current_parents) { SASSERT(e_parent != nullptr); - app * a_parent = e_parent->get_owner(); + app * a_parent = e_parent->get_expr(); TRACE("str", tout << "considering parent " << mk_ismt2_pp(a_parent, m) << std::endl;); if (u.str.is_concat(a_parent)) { @@ -2160,7 +2160,7 @@ namespace smt { rational parentLen; bool parentLen_exists = get_len_value(a_parent, parentLen); - if (arg0 == n_eq_enode->get_owner()) { + if (arg0 == n_eq_enode->get_expr()) { rational arg0Len, arg1Len; bool arg0Len_exists = get_len_value(eq_str, arg0Len); bool arg1Len_exists = get_len_value(arg1, arg1Len); @@ -2229,9 +2229,9 @@ namespace smt { assert_implication(implyL, implyR); } } - } // if (arg0 == n_eq_enode->get_owner()) + } // if (arg0 == n_eq_enode->get_expr()) - if (arg1 == n_eq_enode->get_owner()) { + if (arg1 == n_eq_enode->get_expr()) { rational arg0Len, arg1Len; bool arg0Len_exists = get_len_value(arg0, arg0Len); bool arg1Len_exists = get_len_value(eq_str, arg1Len); @@ -2355,7 +2355,7 @@ namespace smt { if (arg1 == n_eqNode) { expr_ref_vector concat_parents(m); for (auto& e_concat_parent : e_parent->get_parents()) { - concat_parents.push_back(e_concat_parent->get_owner()); + concat_parents.push_back(e_concat_parent->get_expr()); } for (auto& _concat_parent : concat_parents) { app* concat_parent = to_app(_concat_parent); @@ -2383,7 +2383,7 @@ namespace smt { if (arg0 == n_eqNode) { expr_ref_vector concat_parents(m); for (auto& e_concat_parent : e_parent->get_parents()) { - concat_parents.push_back(e_concat_parent->get_owner()); + concat_parents.push_back(e_concat_parent->get_expr()); } for (auto& _concat_parent : concat_parents) { app* concat_parent = to_app(_concat_parent); @@ -4607,8 +4607,8 @@ namespace smt { // if an integer constant exists in the eqc, it should be the root enode * en_e = ctx.get_enode(e); enode * root_e = en_e->get_root(); - if (m_autil.is_numeral(root_e->get_owner(), val) && val.is_int()) { - TRACE("str", tout << mk_pp(e, get_manager()) << " ~= " << mk_pp(root_e->get_owner(), get_manager()) << std::endl;); + if (m_autil.is_numeral(root_e->get_expr(), val) && val.is_int()) { + TRACE("str", tout << mk_pp(e, get_manager()) << " ~= " << mk_pp(root_e->get_expr(), get_manager()) << std::endl;); return true; } else { TRACE("str", tout << "root of eqc of " << mk_pp(e, get_manager()) << " is not a numeral" << std::endl;); @@ -4691,7 +4691,7 @@ namespace smt { enode * nNode = ctx.get_enode(len); enode * eqcNode = nNode; do { - app * ast = eqcNode->get_owner(); + app * ast = eqcNode->get_expr(); tout << mk_pp(ast, get_manager()) << std::endl; eqcNode = eqcNode->get_next(); } while (eqcNode != nNode); @@ -7052,8 +7052,8 @@ namespace smt { void theory_str::new_eq_eh(theory_var x, theory_var y) { //TRACE("str", tout << "new eq: v#" << x << " = v#" << y << std::endl;); - TRACE("str", tout << "new eq: " << mk_ismt2_pp(get_enode(x)->get_owner(), get_manager()) << " = " << - mk_ismt2_pp(get_enode(y)->get_owner(), get_manager()) << std::endl;); + TRACE("str", tout << "new eq: " << mk_ismt2_pp(get_enode(x)->get_expr(), get_manager()) << " = " << + mk_ismt2_pp(get_enode(y)->get_expr(), get_manager()) << std::endl;); candidate_model.reset(); /* @@ -7061,7 +7061,7 @@ namespace smt { return; } */ - handle_equality(get_enode(x)->get_owner(), get_enode(y)->get_owner()); + handle_equality(get_enode(x)->get_expr(), get_enode(y)->get_expr()); // replicate Z3str2 behaviour: merge eqc **AFTER** handle_equality m_find.merge(x, y); @@ -7069,8 +7069,8 @@ namespace smt { void theory_str::new_diseq_eh(theory_var x, theory_var y) { //TRACE("str", tout << "new diseq: v#" << x << " != v#" << y << std::endl;); - TRACE("str", tout << "new diseq: " << mk_ismt2_pp(get_enode(x)->get_owner(), get_manager()) << " != " << - mk_ismt2_pp(get_enode(y)->get_owner(), get_manager()) << std::endl;); + TRACE("str", tout << "new diseq: " << mk_ismt2_pp(get_enode(x)->get_expr(), get_manager()) << " != " << + mk_ismt2_pp(get_enode(y)->get_expr(), get_manager()) << std::endl;); candidate_model.reset(); } @@ -7294,7 +7294,7 @@ namespace smt { ptr_vector new_m_basicstr; for (ptr_vector::iterator it = m_basicstr_axiom_todo.begin(); it != m_basicstr_axiom_todo.end(); ++it) { enode * e = *it; - TRACE("str", tout << "consider deleting " << mk_pp(e->get_owner(), get_manager()) + TRACE("str", tout << "consider deleting " << mk_pp(e->get_expr(), get_manager()) << ", enode scope level is " << e->get_iscope_lvl() << std::endl;); if (e->get_iscope_lvl() <= (unsigned)sLevel) { @@ -7587,7 +7587,7 @@ namespace smt { enode * e_curr = ctx.get_enode(unroll); enode * e_curr_end = e_curr; do { - app * curr = e_curr->get_owner(); + app * curr = e_curr->get_expr(); if (u.str.is_concat(curr)) { tout << " >>> " << mk_pp(curr, mgr) << std::endl; } @@ -8531,7 +8531,7 @@ namespace smt { for (std::set::iterator it = eqc_roots.begin(); it != eqc_roots.end(); ++it) { enode * e = *it; - app * a = e->get_owner(); + app * a = e->get_expr(); if (!(a->get_sort() == u.str.mk_string_sort())) { TRACE("str", tout << "EQC root " << mk_pp(a, m) << " not a string term; skipping" << std::endl;); } else { @@ -8540,9 +8540,9 @@ namespace smt { enode * e_it = e; enode * e_root = e_it; do { - bool status = check_concat_len_in_eqc(e_it->get_owner()); + bool status = check_concat_len_in_eqc(e_it->get_expr()); if (!status) { - TRACE("str", tout << "concat-len check asserted an axiom on " << mk_pp(e_it->get_owner(), m) << std::endl;); + TRACE("str", tout << "concat-len check asserted an axiom on " << mk_pp(e_it->get_expr(), m) << std::endl;); found_inconsistency = true; } e_it = e_it->get_next(); @@ -8552,8 +8552,8 @@ namespace smt { enode * e1 = e; enode * e2 = e1->get_next(); if (e1 != e2) { - TRACE("str", tout << "deferred new_eq_check() over EQC of " << mk_pp(e1->get_owner(), m) << " and " << mk_pp(e2->get_owner(), m) << std::endl;); - bool result = new_eq_check(e1->get_owner(), e2->get_owner()); + TRACE("str", tout << "deferred new_eq_check() over EQC of " << mk_pp(e1->get_expr(), m) << " and " << mk_pp(e2->get_expr(), m) << std::endl;); + bool result = new_eq_check(e1->get_expr(), e2->get_expr()); if (!result) { TRACE("str", tout << "new_eq_check found inconsistencies" << std::endl;); found_inconsistency = true; @@ -8813,7 +8813,7 @@ namespace smt { concatEqUnrollsMap[curr].insert(unrollGroup_map[unroll].begin(), unrollGroup_map[unroll].end()); } enode * e_curr = ctx.get_enode(curr); - curr = e_curr->get_next()->get_owner(); + curr = e_curr->get_next()->get_expr(); // curr = get_eqc_next(curr); } while (curr != unroll); } @@ -9025,11 +9025,11 @@ namespace smt { } model_value_proc * theory_str::mk_value(enode * n, model_generator & mg) { - TRACE("str", tout << "mk_value for: " << mk_ismt2_pp(n->get_owner(), get_manager()) << - " (sort " << mk_ismt2_pp(n->get_owner()->get_sort(), get_manager()) << ")" << std::endl;); + TRACE("str", tout << "mk_value for: " << mk_ismt2_pp(n->get_expr(), get_manager()) << + " (sort " << mk_ismt2_pp(n->get_expr()->get_sort(), get_manager()) << ")" << std::endl;); ast_manager & m = get_manager(); app_ref owner(m); - owner = n->get_owner(); + owner = n->get_expr(); // If the owner is not internalized, it doesn't have an enode associated. SASSERT(ctx.e_internalized(owner)); diff --git a/src/smt/theory_utvpi.h b/src/smt/theory_utvpi.h index 1985ed23a..2006e013b 100644 --- a/src/smt/theory_utvpi.h +++ b/src/smt/theory_utvpi.h @@ -324,7 +324,7 @@ namespace smt { void new_eq_or_diseq(bool is_eq, th_var v1, th_var v2, justification& eq_just); - bool is_int(theory_var v) const { return a.is_int(get_enode(v)->get_owner()); } + bool is_int(theory_var v) const { return a.is_int(get_enode(v)->get_expr()); } th_var get_zero(sort* s) { return a.is_int(s) ? m_izero : m_rzero; } diff --git a/src/smt/theory_utvpi_def.h b/src/smt/theory_utvpi_def.h index 1188d8192..340346018 100644 --- a/src/smt/theory_utvpi_def.h +++ b/src/smt/theory_utvpi_def.h @@ -98,7 +98,7 @@ namespace smt { template theory_var theory_utvpi::mk_var(enode* n) { th_var v = theory::mk_var(n); - TRACE("utvpi", tout << v << " " << mk_pp(n->get_owner(), m) << "\n";); + TRACE("utvpi", tout << v << " " << mk_pp(n->get_expr(), m) << "\n";); m_graph.init_var(to_var(v)); m_graph.init_var(neg(to_var(v))); ctx.attach_th_var(n, this, v); @@ -170,8 +170,8 @@ namespace smt { // app_ref eq(m), s2(m), t2(m); - app* s1 = get_enode(s)->get_owner(); - app* t1 = get_enode(t)->get_owner(); + app* s1 = get_enode(s)->get_expr(); + app* t1 = get_enode(t)->get_expr(); s2 = a.mk_sub(t1, s1); t2 = a.mk_numeral(k, s2->get_sort()); eq = m.mk_eq(s2.get(), t2.get()); @@ -438,7 +438,7 @@ namespace smt { unsigned sz = get_num_vars(); for (unsigned i = 0; i < sz; ++i) { enode* e = get_enode(i); - if (!a.is_int(e->get_owner())) { + if (!a.is_int(e->get_expr())) { continue; } th_var v1 = to_var(i); @@ -460,7 +460,7 @@ namespace smt { m_nc_functor.reset(); VERIFY(m_graph.find_shortest_zero_edge_path(v1, v2, UINT_MAX, m_nc_functor)); VERIFY(m_graph.find_shortest_zero_edge_path(v2, v1, UINT_MAX, m_nc_functor)); - IF_VERBOSE(1, verbose_stream() << "parity conflict " << mk_pp(e->get_owner(), m) << "\n";); + IF_VERBOSE(1, verbose_stream() << "parity conflict " << mk_pp(e->get_expr(), m) << "\n";); set_conflict(); return false; @@ -593,7 +593,7 @@ namespace smt { expr* x, *y; rational r; for (;;) { - app* n = e->get_owner(); + app* n = e->get_expr(); if (a.is_add(n, x, y)) { if (a.is_numeral(x, r)) { e = ctx.get_enode(y); @@ -736,7 +736,7 @@ namespace smt { unsigned sz = get_num_vars(); for (unsigned i = 0; i < sz; ++i) { enode* e = get_enode(i); - if (a.is_int(e->get_owner()) && !is_parity_ok(i)) { + if (a.is_int(e->get_expr()) && !is_parity_ok(i)) { todo.push_back(i); } } @@ -781,7 +781,7 @@ namespace smt { DEBUG_CODE( for (unsigned i = 0; i < sz; ++i) { enode* e = get_enode(i); - if (a.is_int(e->get_owner()) && !is_parity_ok(i)) { + if (a.is_int(e->get_expr()) && !is_parity_ok(i)) { IF_VERBOSE(0, verbose_stream() << "disparities not fixed\n";); UNREACHABLE(); } @@ -911,7 +911,7 @@ namespace smt { num = num/rational(2); SASSERT(!is_int || num.is_int()); TRACE("utvpi", - expr* n = get_enode(v)->get_owner(); + expr* n = get_enode(v)->get_expr(); tout << mk_pp(n, m) << " |-> (" << val1 << " - " << val2 << ")/2 = " << num << "\n";); return num; @@ -920,9 +920,9 @@ namespace smt { template model_value_proc * theory_utvpi::mk_value(enode * n, model_generator & mg) { theory_var v = n->get_th_var(get_id()); - bool is_int = a.is_int(n->get_owner()); + bool is_int = a.is_int(n->get_expr()); rational num = mk_value(v, is_int); - TRACE("utvpi", tout << mk_pp(n->get_owner(), m) << " |-> " << num << "\n";); + TRACE("utvpi", tout << mk_pp(n->get_expr(), m) << " |-> " << num << "\n";); return alloc(expr_wrapper_proc, m_factory->mk_num_value(num, is_int)); } diff --git a/src/smt/theory_wmaxsat.cpp b/src/smt/theory_wmaxsat.cpp index 9113f76d6..c93dacdf5 100644 --- a/src/smt/theory_wmaxsat.cpp +++ b/src/smt/theory_wmaxsat.cpp @@ -248,7 +248,7 @@ namespace smt { TRACE("opt", tout << "costs: "; for (unsigned i = 0; i < m_costs.size(); ++i) { - tout << mk_pp(get_enode(m_costs[i])->get_owner(), get_manager()) << " "; + tout << pp(get_enode(m_costs[i]), get_manager()) << " "; } tout << "\n"; //ctx.display(tout);