3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-24 17:45:32 +00:00

add stubs for converting assertions, consolidate filter_model_converter

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2017-11-17 14:51:13 -08:00
parent 53e36c9cf9
commit 0d15b6abb7
76 changed files with 244 additions and 356 deletions

View file

@ -1883,7 +1883,7 @@ namespace z3 {
bool is_uint(unsigned i) const { Z3_bool r = Z3_stats_is_uint(ctx(), m_stats, i); check_error(); return r != 0; }
bool is_double(unsigned i) const { Z3_bool r = Z3_stats_is_double(ctx(), m_stats, i); check_error(); return r != 0; }
unsigned uint_value(unsigned i) const { unsigned r = Z3_stats_get_uint_value(ctx(), m_stats, i); check_error(); return r; }
double double_value(unsigned i) const { double r = Z3_stats_get_double_value(ctx(), m_stats, i); check_error(); return r; }
double double_value(unsigned i) const { double r = Z3_stats_get_double_value(ctx(), m_stats, i); check_error(); return r; }
friend std::ostream & operator<<(std::ostream & out, stats const & s);
};
inline std::ostream & operator<<(std::ostream & out, stats const & s) { out << Z3_stats_to_string(s.ctx(), s); return out; }

View file

@ -41,7 +41,7 @@ Revision History:
#include "ast/rewriter/expr_replacer.h"
#include "ast/rewriter/bool_rewriter.h"
#include "ast/rewriter/expr_safe_replace.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
#include "ast/scoped_proof.h"
#include "ast/datatype_decl_plugin.h"
#include "ast/ast_util.h"
@ -326,8 +326,8 @@ namespace datalog {
rules.set_output_predicate(qpred);
if (m_ctx.get_model_converter()) {
filter_model_converter* mc = alloc(filter_model_converter, m);
mc->insert(qpred);
generic_model_converter* mc = alloc(generic_model_converter, m);
mc->hide(qpred);
m_ctx.add_model_converter(mc);
}

View file

@ -25,7 +25,7 @@ Revision History:
#include "ast/rewriter/expr_replacer.h"
#include "muz/base/dl_rule_transformer.h"
#include "muz/transforms/dl_mk_slice.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
#include "muz/transforms/dl_transforms.h"
#include "muz/base/fixedpoint_params.hpp"
#include "ast/ast_util.h"
@ -229,8 +229,8 @@ class horn_tactic : public tactic {
}
queries.reset();
queries.push_back(q);
filter_model_converter* mc1 = alloc(filter_model_converter, m);
mc1->insert(to_app(q)->get_decl());
generic_model_converter* mc1 = alloc(generic_model_converter, m);
mc1->hide(q);
mc = mc1;
}
SASSERT(queries.size() == 1);

View file

@ -112,10 +112,10 @@ public:
{m_solver.collect_param_descrs(r);}
virtual void set_produce_models(bool f)
{m_solver.set_produce_models(f);}
virtual void assert_expr(expr *t)
virtual void assert_expr_core(expr *t)
{m_solver.assert_expr(t);}
virtual void assert_expr(expr *t, expr *a)
virtual void assert_expr_core(expr *t, expr *a)
{NOT_IMPLEMENTED_YET();}
virtual void assert_lemma(expr* e) { NOT_IMPLEMENTED_YET(); }
virtual expr_ref lookahead(const expr_ref_vector &,const expr_ref_vector &) { return expr_ref(m.mk_true(), m); }

View file

@ -50,7 +50,7 @@ virtual_solver::virtual_solver(virtual_solver_factory &factory,
// -- change m_context, but will add m_pred to
// -- the private field solver_na2as::m_assumptions
if (m_virtual)
{ solver_na2as::assert_expr(m.mk_true(), m_pred); }
{ solver_na2as::assert_expr_core(m.mk_true(), m_pred); }
}
virtual_solver::~virtual_solver()
@ -210,7 +210,7 @@ void virtual_solver::get_unsat_core(ptr_vector<expr> &r)
}
}
void virtual_solver::assert_expr(expr *e)
void virtual_solver::assert_expr_core(expr *e)
{
SASSERT(!m_pushed || get_scope_level() > 0);
if (m.is_true(e)) { return; }

View file

@ -78,7 +78,7 @@ public:
}
virtual void get_unsat_core(ptr_vector<expr> &r);
virtual void assert_expr(expr *e);
virtual void assert_expr_core(expr *e);
virtual void collect_statistics(statistics &st) const {}
virtual void get_model_core(model_ref &m) {m_context.get_model(m);}
virtual proof* get_proof();

View file

@ -22,7 +22,7 @@ Revision History:
#include "ast/rewriter/rewriter_def.h"
#include "ast/ast_pp.h"
#include "ast/rewriter/expr_safe_replace.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
#include "muz/transforms/dl_mk_interp_tail_simplifier.h"
#include "muz/base/fixedpoint_params.hpp"
#include "ast/scoped_proof.h"
@ -299,12 +299,12 @@ namespace datalog {
}
if (m_context.get_model_converter()) {
filter_model_converter* fmc = alloc(filter_model_converter, m);
generic_model_converter* fmc = alloc(generic_model_converter, m);
bit_blast_model_converter* bvmc = alloc(bit_blast_model_converter, m);
func_decl_ref_vector const& old_funcs = m_rewriter.m_cfg.old_funcs();
func_decl_ref_vector const& new_funcs = m_rewriter.m_cfg.new_funcs();
for (unsigned i = 0; i < old_funcs.size(); ++i) {
fmc->insert(new_funcs[i]);
fmc->hide(new_funcs[i]);
bvmc->insert(old_funcs[i], new_funcs[i]);
}
m_context.add_model_converter(concat(bvmc, fmc));

View file

@ -105,7 +105,7 @@ namespace opt {
app* maxsmt_solver_base::mk_fresh_bool(char const* name) {
app* result = m.mk_fresh_const(name, m.mk_bool_sort());
m_c.fm().insert(result->get_decl());
m_c.fm().hide(result);
return result;
}

View file

@ -22,7 +22,6 @@ Notes:
#include "ast/ast.h"
#include "util/params.h"
#include "solver/solver.h"
#include "tactic/filter_model_converter.h"
#include "util/statistics.h"
#include "smt/smt_context.h"
#include "smt/smt_theory.h"

View file

@ -40,7 +40,7 @@ Notes:
#include "ast/bv_decl_plugin.h"
#include "ast/pb_decl_plugin.h"
#include "ast/ast_smt_pp.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
#include "ast/ast_pp_util.h"
#include "qe/qsat.h"
@ -1021,7 +1021,7 @@ namespace opt {
}
void context::purify(app_ref& term) {
filter_model_converter_ref fm;
generic_model_converter_ref fm;
if (m_arith.is_add(term)) {
expr_ref_vector args(m);
unsigned sz = term->get_num_args();
@ -1058,13 +1058,13 @@ namespace opt {
(m_arith.is_mul(e, e2, e1) && m_arith.is_numeral(e1) && is_uninterp_const(e2));
}
app* context::purify(filter_model_converter_ref& fm, expr* term) {
app* context::purify(generic_model_converter_ref& fm, expr* term) {
std::ostringstream out;
out << mk_pp(term, m);
app* q = m.mk_fresh_const(out.str().c_str(), m.get_sort(term));
if (!fm) fm = alloc(filter_model_converter, m);
if (!fm) fm = alloc(generic_model_converter, m);
m_hard_constraints.push_back(m.mk_eq(q, term));
fm->insert(q->get_decl());
fm->hide(q);
return q;
}
@ -1075,7 +1075,7 @@ namespace opt {
- filter "obj" from generated model.
*/
void context::mk_atomic(expr_ref_vector& terms) {
filter_model_converter_ref fm;
generic_model_converter_ref fm;
for (unsigned i = 0; i < terms.size(); ++i) {
expr_ref p(terms[i].get(), m);
app_ref q(m);

View file

@ -45,7 +45,7 @@ namespace opt {
class maxsat_context {
public:
virtual filter_model_converter& fm() = 0; // converter that removes fresh names introduced by simplification.
virtual generic_model_converter& fm() = 0; // converter that removes fresh names introduced by simplification.
virtual bool sat_enabled() const = 0; // is using th SAT solver core enabled?
virtual solver& get_solver() = 0; // retrieve solver object (SAT or SMT solver)
virtual ast_manager& get_manager() const = 0;
@ -155,7 +155,7 @@ namespace opt {
vector<objective> m_objectives;
model_ref m_model;
model_converter_ref m_model_converter;
filter_model_converter m_fm;
generic_model_converter m_fm;
obj_map<func_decl, unsigned> m_objective_fns;
obj_map<func_decl, expr*> m_objective_orig;
func_decl_ref_vector m_objective_refs;
@ -219,7 +219,7 @@ namespace opt {
virtual expr_ref mk_le(unsigned i, model_ref& model);
virtual smt::context& smt_context() { return m_opt_solver->get_context(); }
virtual filter_model_converter& fm() { return m_fm; }
virtual generic_model_converter& fm() { return m_fm; }
virtual bool sat_enabled() const { return 0 != m_sat_solver.get(); }
virtual solver& get_solver();
virtual ast_manager& get_manager() const { return this->m; }
@ -253,7 +253,7 @@ namespace opt {
vector<rational>& weights, rational& offset, bool& neg,
symbol& id, expr_ref& orig_term, unsigned& index);
void purify(app_ref& term);
app* purify(filter_model_converter_ref& fm, expr* e);
app* purify(generic_model_converter_ref& fm, expr* e);
bool is_mul_const(expr* e);
expr* mk_maximize(unsigned index, app* t);
expr* mk_minimize(unsigned index, app* t);

View file

@ -37,7 +37,7 @@ Notes:
namespace opt {
opt_solver::opt_solver(ast_manager & mgr, params_ref const & p,
filter_model_converter& fm):
generic_model_converter& fm):
solver_na2as(mgr),
m_params(p),
m_context(mgr, m_params),
@ -80,7 +80,7 @@ namespace opt {
m_context.collect_statistics(st);
}
void opt_solver::assert_expr(expr * t) {
void opt_solver::assert_expr_core(expr * t) {
if (has_quantifiers(t)) {
m_params.m_relevancy_lvl = 2;
}

View file

@ -30,7 +30,7 @@ Notes:
#include "smt/params/smt_params.h"
#include "smt/smt_types.h"
#include "smt/theory_opt.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
namespace opt {
@ -70,7 +70,7 @@ namespace opt {
smt_params m_params;
smt::kernel m_context;
ast_manager& m;
filter_model_converter& m_fm;
generic_model_converter& m_fm;
progress_callback * m_callback;
symbol m_logic;
svector<smt::theory_var> m_objective_vars;
@ -84,14 +84,14 @@ namespace opt {
bool m_first;
bool m_was_unknown;
public:
opt_solver(ast_manager & m, params_ref const & p, filter_model_converter& fm);
opt_solver(ast_manager & m, params_ref const & p, generic_model_converter& fm);
virtual ~opt_solver();
virtual solver* translate(ast_manager& m, params_ref const& p);
virtual void updt_params(params_ref const& p);
virtual void collect_param_descrs(param_descrs & r);
virtual void collect_statistics(statistics & st) const;
virtual void assert_expr(expr * t);
virtual void assert_expr_core(expr * t);
virtual void assert_lemma(expr* t) {}
virtual void push_core();
virtual void pop_core(unsigned n);

View file

@ -24,7 +24,7 @@ Notes:
#include "smt/smt_context.h"
#include "opt/opt_context.h"
#include "util/sorting_network.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
namespace opt {
@ -35,7 +35,7 @@ namespace opt {
psort_nw<sortmax> m_sort;
expr_ref_vector m_trail;
func_decl_ref_vector m_fresh;
ref<filter_model_converter> m_filter;
ref<generic_model_converter> m_filter;
sortmax(maxsat_context& c, weights_t& ws, expr_ref_vector const& soft):
maxsmt_solver_base(c, ws, soft), m_sort(*this), m_trail(m), m_fresh(m) {}
@ -50,7 +50,7 @@ namespace opt {
if (is_sat != l_true) {
return is_sat;
}
m_filter = alloc(filter_model_converter, m);
m_filter = alloc(generic_model_converter, m);
rational offset = m_lower;
m_upper = offset;
expr_ref_vector in(m);
@ -142,7 +142,7 @@ namespace opt {
expr_ref fr(m.mk_fresh_const(n, m.mk_bool_sort()), m);
func_decl* f = to_app(fr)->get_decl();
m_fresh.push_back(f);
m_filter->insert(f);
m_filter->hide(f);
return trail(fr);
}

View file

@ -17,7 +17,6 @@ Revision History:
--*/
#include "tactic/tactical.h"
#include "tactic/filter_model_converter.h"
#include "util/cooperate.h"
#include "qe/qe.h"

View file

@ -44,11 +44,11 @@ namespace qe {
m(m),
m_asms(m),
m_trail(m),
m_fmc(alloc(filter_model_converter, m))
m_fmc(alloc(generic_model_converter, m))
{
}
filter_model_converter* pred_abs::fmc() {
generic_model_converter* pred_abs::fmc() {
return m_fmc.get();
}
@ -282,7 +282,7 @@ namespace qe {
app_ref pred_abs::fresh_bool(char const* name) {
app_ref r(m.mk_fresh_const(name, m.mk_bool_sort()), m);
m_fmc->insert(r->get_decl());
m_fmc->hide(r);
return r;
}
@ -747,9 +747,7 @@ namespace qe {
}
void filter_vars(app_ref_vector const& vars) {
for (unsigned i = 0; i < vars.size(); ++i) {
m_pred_abs.fmc()->insert(vars[i]->get_decl());
}
for (app* v : vars) m_pred_abs.fmc()->hide(v);
}
void initialize_levels() {

View file

@ -22,7 +22,7 @@ Revision History:
#define QE_QSAT_H__
#include "tactic/tactic.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
#include "qe/qe_mbp.h"
namespace qe {
@ -72,7 +72,7 @@ namespace qe {
obj_map<expr, app*> m_asm2pred; // maintain map from assumptions to predicates
obj_map<expr, expr*> m_pred2asm; // predicates |-> assumptions
expr_ref_vector m_trail;
filter_model_converter_ref m_fmc;
generic_model_converter_ref m_fmc;
ptr_vector<expr> todo;
obj_map<expr, max_level> m_elevel;
obj_map<func_decl, max_level> m_flevel;
@ -91,7 +91,7 @@ namespace qe {
public:
pred_abs(ast_manager& m);
filter_model_converter* fmc();
generic_model_converter* fmc();
void reset();
max_level compute_level(app* e);
void push();

View file

@ -31,7 +31,6 @@ Notes:
#include "sat/tactic/goal2sat.h"
#include "ast/ast_pp.h"
#include "model/model_smt2_pp.h"
#include "tactic/filter_model_converter.h"
#include "tactic/bv/bit_blaster_model_converter.h"
#include "ast/ast_translation.h"
#include "ast/ast_util.h"
@ -241,13 +240,13 @@ public:
virtual unsigned get_scope_level() const {
return m_num_scopes;
}
virtual void assert_expr(expr * t, expr * a) {
virtual void assert_expr_core(expr * t, expr * a) {
if (a) {
m_asmsf.push_back(a);
assert_expr(m.mk_implies(a, t));
assert_expr_core(m.mk_implies(a, t));
}
else {
assert_expr(t);
assert_expr_core(t);
}
}
@ -261,7 +260,7 @@ public:
}
virtual ast_manager& get_manager() const { return m; }
virtual void assert_expr(expr * t) {
virtual void assert_expr_core(expr * t) {
m_internalized = false;
TRACE("goal2sat", tout << mk_pp(t, m) << "\n";);
m_fmls.push_back(t);

View file

@ -38,7 +38,7 @@ Notes:
#include "model/model_evaluator.h"
#include "model/model_v2_pp.h"
#include "tactic/tactic.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
#include<sstream>
struct goal2sat::imp {
@ -883,7 +883,7 @@ struct sat2goal::imp {
class sat_model_converter : public model_converter {
sat::model_converter m_mc;
expr_ref_vector m_var2expr;
filter_model_converter_ref m_fmc; // filter for eliminating fresh variables introduced in the assertion-set --> sat conversion
generic_model_converter_ref m_fmc; // filter for eliminating fresh variables introduced in the assertion-set --> sat conversion
sat_model_converter(ast_manager & m):
m_var2expr(m) {
@ -892,7 +892,7 @@ struct sat2goal::imp {
public:
sat_model_converter(ast_manager & m, sat::solver const & s):m_var2expr(m) {
m_mc.copy(s.get_model_converter());
m_fmc = alloc(filter_model_converter, m);
m_fmc = alloc(generic_model_converter, m);
}
ast_manager & m() { return m_var2expr.get_manager(); }
@ -907,7 +907,7 @@ struct sat2goal::imp {
if (aux) {
SASSERT(is_uninterp_const(atom));
SASSERT(m().is_bool(atom));
m_fmc->insert(to_app(atom)->get_decl());
m_fmc->hide(to_app(atom)->get_decl());
}
}
@ -976,7 +976,7 @@ struct sat2goal::imp {
virtual model_converter * translate(ast_translation & translator) {
sat_model_converter * res = alloc(sat_model_converter, translator.to());
res->m_fmc = static_cast<filter_model_converter*>(m_fmc->translate(translator));
res->m_fmc = static_cast<generic_model_converter*>(m_fmc->translate(translator));
for (expr* e : m_var2expr)
res->m_var2expr.push_back(e ? translator(e) : nullptr);
return res;

View file

@ -18,7 +18,6 @@ Notes:
--*/
#include "ast/ast_pp.h"
#include "tactic/tactical.h"
#include "tactic/filter_model_converter.h"
#include "sat/tactic/goal2sat.h"
#include "sat/sat_solver.h"
#include "model/model_v2_pp.h"

View file

@ -101,11 +101,11 @@ namespace smt {
return m_context.find_mutexes(vars, mutexes);
}
virtual void assert_expr(expr * t) {
virtual void assert_expr_core(expr * t) {
m_context.assert_expr(t);
}
virtual void assert_expr(expr * t, expr * a) {
virtual void assert_expr_core(expr * t, expr * a) {
if (m_name2assertion.contains(a)) {
throw default_exception("named assertion defined twice");
}

View file

@ -23,7 +23,7 @@ Notes:
#include "smt/params/smt_params_helper.hpp"
#include "util/lp/lp_params.hpp"
#include "ast/rewriter/rewriter_types.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
#include "ast/ast_util.h"
#include "solver/solver2tactic.h"
#include "smt/smt_solver.h"
@ -169,7 +169,7 @@ public:
expr_ref_vector clauses(m);
expr2expr_map bool2dep;
ptr_vector<expr> assumptions;
ref<filter_model_converter> fmc;
ref<generic_model_converter> fmc;
if (in->unsat_core_enabled()) {
extract_clauses_and_dependencies(in, clauses, assumptions, bool2dep, fmc);
TRACE("mus", in->display_with_dependencies(tout);

View file

@ -1081,7 +1081,7 @@ namespace smt {
virtual inf_eps_rational<inf_rational> maximize(theory_var v, expr_ref& blocker, bool& has_shared);
virtual inf_eps_rational<inf_rational> value(theory_var v);
virtual theory_var add_objective(app* term);
expr_ref mk_ge(filter_model_converter& fm, theory_var v, inf_numeral const& val);
expr_ref mk_ge(generic_model_converter& fm, theory_var v, inf_numeral const& val);
void enable_record_conflict(expr* bound);
void record_conflict(unsigned num_lits, literal const * lits,
unsigned num_eqs, enode_pair const * eqs,

View file

@ -23,7 +23,7 @@ Revision History:
#include "smt/theory_arith.h"
#include "smt/smt_farkas_util.h"
#include "ast/rewriter/th_rewriter.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
namespace smt {
@ -1117,14 +1117,14 @@ namespace smt {
This allows to handle inequalities with non-standard numbers.
*/
template<typename Ext>
expr_ref theory_arith<Ext>::mk_ge(filter_model_converter& fm, theory_var v, inf_numeral const& val) {
expr_ref theory_arith<Ext>::mk_ge(generic_model_converter& fm, theory_var v, inf_numeral const& val) {
ast_manager& m = get_manager();
context& ctx = get_context();
std::ostringstream strm;
strm << val << " <= " << mk_pp(get_enode(v)->get_owner(), get_manager());
app* b = m.mk_const(symbol(strm.str().c_str()), m.mk_bool_sort());
if (!ctx.b_internalized(b)) {
fm.insert(b->get_decl());
fm.hide(b->get_decl());
bool_var bv = ctx.mk_bool_var(b);
ctx.set_var_theory(bv, get_id());
// ctx.set_enode_flag(bv, true);

View file

@ -271,7 +271,7 @@ namespace smt {
virtual inf_eps_rational<inf_rational> value(theory_var v);
virtual theory_var add_objective(app* term);
virtual expr_ref mk_gt(theory_var v, inf_eps const& val);
expr_ref mk_ge(filter_model_converter& fm, theory_var v, inf_eps const& val);
expr_ref mk_ge(generic_model_converter& fm, theory_var v, inf_eps const& val);
// -----------------------------------
//

View file

@ -1055,7 +1055,7 @@ namespace smt {
template<typename Ext>
expr_ref theory_dense_diff_logic<Ext>::mk_ge(
filter_model_converter& fm, theory_var v, inf_eps const& val) {
generic_model_converter& fm, theory_var v, inf_eps const& val) {
return mk_ineq(v, val, false);
}

View file

@ -324,7 +324,7 @@ namespace smt {
virtual inf_eps maximize(theory_var v, expr_ref& blocker, bool& has_shared);
virtual inf_eps value(theory_var v);
virtual theory_var add_objective(app* term);
expr_ref mk_ge(filter_model_converter& fm, theory_var v, inf_eps const& val);
expr_ref mk_ge(generic_model_converter& fm, theory_var v, inf_eps const& val);
bool internalize_objective(expr * n, rational const& m, rational& r, objective_term & objective);

View file

@ -1336,7 +1336,7 @@ expr_ref theory_diff_logic<Ext>::mk_gt(theory_var v, inf_eps const& val) {
}
template<typename Ext>
expr_ref theory_diff_logic<Ext>::mk_ge(filter_model_converter& fm, theory_var v, inf_eps const& val) {
expr_ref theory_diff_logic<Ext>::mk_ge(generic_model_converter& fm, theory_var v, inf_eps const& val) {
return mk_ineq(v, val, false);
}

View file

@ -36,7 +36,7 @@ Revision History:
#include "smt/smt_model_generator.h"
#include "smt/arith_eq_adapter.h"
#include "util/nat_set.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
namespace lra_lp {
enum bound_kind { lower_t, upper_t };
@ -2417,7 +2417,7 @@ namespace smt {
}
}
expr_ref mk_ge(filter_model_converter& fm, theory_var v, inf_rational const& val) {
expr_ref mk_ge(generic_model_converter& fm, theory_var v, inf_rational const& val) {
rational r = val.get_rational();
bool is_strict = val.get_infinitesimal().is_pos();
app_ref b(m);
@ -2429,7 +2429,7 @@ namespace smt {
b = a.mk_ge(mk_obj(v), a.mk_numeral(r, is_int));
}
if (!ctx().b_internalized(b)) {
fm.insert(b->get_decl());
fm.hide(b);
bool_var bv = ctx().mk_bool_var(b);
ctx().set_var_theory(bv, get_id());
// ctx().set_enode_flag(bv, true);
@ -2620,7 +2620,7 @@ namespace smt {
theory_var theory_lra::add_objective(app* term) {
return m_imp->add_objective(term);
}
expr_ref theory_lra::mk_ge(filter_model_converter& fm, theory_var v, inf_rational const& val) {
expr_ref theory_lra::mk_ge(generic_model_converter& fm, theory_var v, inf_rational const& val) {
return m_imp->mk_ge(fm, v, val);
}

View file

@ -89,7 +89,7 @@ namespace smt {
virtual inf_eps value(theory_var);
virtual inf_eps maximize(theory_var v, expr_ref& blocker, bool& has_shared);
virtual theory_var add_objective(app* term);
virtual expr_ref mk_ge(filter_model_converter& fm, theory_var v, inf_rational const& val);
virtual expr_ref mk_ge(generic_model_converter& fm, theory_var v, inf_rational const& val);
};

View file

@ -25,7 +25,7 @@ Notes:
#ifndef THEORY_OPT_H_
#define THEORY_OPT_H_
class filter_model_converter;
class generic_model_converter;
namespace smt {
class theory_opt {
public:

View file

@ -25,7 +25,7 @@ Notes:
namespace smt {
theory_wmaxsat::theory_wmaxsat(ast_manager& m, filter_model_converter& mc):
theory_wmaxsat::theory_wmaxsat(ast_manager& m, generic_model_converter& mc):
theory(m.mk_family_id("weighted_maxsat")),
m_mc(mc),
m_vars(m),
@ -92,7 +92,7 @@ namespace smt {
ast_manager& m = get_manager();
app_ref var(m), wfml(m);
var = m.mk_fresh_const("w", m.mk_bool_sort());
m_mc.insert(var->get_decl());
m_mc.hide(var);
wfml = m.mk_or(var, fml);
ctx.assert_expr(wfml);
m_rweights.push_back(w);

View file

@ -22,7 +22,7 @@ Notes:
#include "smt/smt_theory.h"
#include "smt/smt_clause.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
namespace smt {
class theory_wmaxsat : public theory {
@ -32,7 +32,7 @@ namespace smt {
void reset() { memset(this, 0, sizeof(*this)); }
stats() { reset(); }
};
filter_model_converter& m_mc;
generic_model_converter& m_mc;
mutable unsynch_mpz_manager m_mpz;
app_ref_vector m_vars; // Auxiliary variables per soft clause
expr_ref_vector m_fmls; // Formulas per soft clause
@ -56,7 +56,7 @@ namespace smt {
svector<bool> m_assigned, m_enabled;
stats m_stats;
public:
theory_wmaxsat(ast_manager& m, filter_model_converter& mc);
theory_wmaxsat(ast_manager& m, generic_model_converter& mc);
virtual ~theory_wmaxsat();
void get_assignment(svector<bool>& result);
expr* assert_weighted(expr* fml, rational const& w);

View file

@ -164,7 +164,7 @@ public:
m_solver2->set_produce_models(f);
}
virtual void assert_expr(expr * t) {
virtual void assert_expr_core(expr * t) {
if (m_check_sat_executed)
switch_inc_mode();
m_solver1->assert_expr(t);
@ -172,7 +172,7 @@ public:
m_solver2->assert_expr(t);
}
virtual void assert_expr(expr * t, expr * a) {
virtual void assert_expr_core(expr * t, expr * a) {
if (m_check_sat_executed)
switch_inc_mode();
m_solver1->assert_expr(t, a);

View file

@ -182,13 +182,26 @@ bool solver::is_literal(ast_manager& m, expr* e) {
return is_uninterp_const(e) || (m.is_not(e, e) && is_uninterp_const(e));
}
#if 0
expr_ref solver::lookahead(expr_ref_vector const& candidates) {
std::cout << "lookahead: " << candidates.size() << "\n";
INVOKE_DEBUGGER();
ast_manager& m = candidates.get_manager();
return expr_ref(m.mk_true(), m);
void solver::assert_expr(expr* f) {
expr_ref fml(f, get_manager());
if (mc0()) {
(*mc0())(fml);
}
assert_expr_core(fml);
}
#endif
void solver::assert_expr(expr* f, expr* t) {
// let mc0 be the model converter associated with the solver
// that converts models to their "real state".
ast_manager& m = get_manager();
expr_ref fml(f, m);
expr_ref a(t, m);
if (mc0()) {
(*mc0())(fml);
// (*mc0())(a);
}
assert_expr_core(fml, a);
}

View file

@ -80,14 +80,16 @@ public:
/**
\brief Add a new formula to the assertion stack.
*/
virtual void assert_expr(expr * t) = 0;
void assert_expr(expr* f);
virtual void assert_expr_core(expr * t) = 0;
void assert_expr(expr_ref_vector const& ts) {
for (unsigned i = 0; i < ts.size(); ++i) assert_expr(ts[i]);
for (expr* e : ts) assert_expr(e);
}
void assert_expr(ptr_vector<expr> const& ts) {
for (unsigned i = 0; i < ts.size(); ++i) assert_expr(ts[i]);
for (expr* e : ts) assert_expr(e);
}
/**
@ -95,7 +97,10 @@ public:
The propositional variable \c a is used to track the use of \c t in a proof
of unsatisfiability.
*/
virtual void assert_expr(expr * t, expr * a) = 0;
void assert_expr(expr * t, expr* a);
virtual void assert_expr_core(expr * t, expr * a) = 0;
/**
\brief Add a lemma to the assertion stack. A lemma is assumed to be a consequence of already
@ -210,11 +215,13 @@ public:
~scoped_push() { if (!m_nopop) s.pop(1); }
void disable_pop() { m_nopop = true; }
};
protected:
virtual lbool get_consequences_core(expr_ref_vector const& asms, expr_ref_vector const& vars, expr_ref_vector& consequences);
bool is_literal(ast_manager& m, expr* e);
};

View file

@ -19,13 +19,13 @@ Notes:
#include "solver/solver.h"
#include "tactic/tactic.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
#include "solver/solver2tactic.h"
#include "ast/ast_util.h"
typedef obj_map<expr, expr *> expr2expr_map;
void extract_clauses_and_dependencies(goal_ref const& g, expr_ref_vector& clauses, ptr_vector<expr>& assumptions, expr2expr_map& bool2dep, ref<filter_model_converter>& fmc) {
void extract_clauses_and_dependencies(goal_ref const& g, expr_ref_vector& clauses, ptr_vector<expr>& assumptions, expr2expr_map& bool2dep, ref<generic_model_converter>& fmc) {
expr2expr_map dep2bool;
ptr_vector<expr> deps;
ast_manager& m = g->m();
@ -65,9 +65,9 @@ void extract_clauses_and_dependencies(goal_ref const& g, expr_ref_vector& clause
bool2dep.insert(b, d);
assumptions.push_back(b);
if (!fmc) {
fmc = alloc(filter_model_converter, m);
fmc = alloc(generic_model_converter, m);
}
fmc->insert(to_app(b)->get_decl());
fmc->hide(to_app(b)->get_decl());
}
clause.push_back(m.mk_not(b));
}
@ -110,7 +110,7 @@ public:
expr_ref_vector clauses(m);
expr2expr_map bool2dep;
ptr_vector<expr> assumptions;
ref<filter_model_converter> fmc;
ref<generic_model_converter> fmc;
extract_clauses_and_dependencies(in, clauses, assumptions, bool2dep, fmc);
ref<solver> local_solver = m_solver->translate(m, m_params);
local_solver->assert_expr(clauses);

View file

@ -20,11 +20,11 @@ Notes:
#define SOLVER2TACTIC_H_
#include "tactic/tactic.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
class solver;
tactic * mk_solver2tactic(solver* s);
void extract_clauses_and_dependencies(goal_ref const& g, expr_ref_vector& clauses, ptr_vector<expr>& assumptions, obj_map<expr, expr*>& bool2dep, ref<filter_model_converter>& fmc);
void extract_clauses_and_dependencies(goal_ref const& g, expr_ref_vector& clauses, ptr_vector<expr>& assumptions, obj_map<expr, expr*>& bool2dep, ref<generic_model_converter>& fmc);
#endif

View file

@ -30,9 +30,9 @@ solver_na2as::solver_na2as(ast_manager & m):
solver_na2as::~solver_na2as() {}
void solver_na2as::assert_expr(expr * t, expr * a) {
void solver_na2as::assert_expr_core(expr * t, expr * a) {
if (a == 0) {
assert_expr(t);
assert_expr_core(t);
}
else {
SASSERT(is_uninterp_const(a));
@ -41,7 +41,7 @@ void solver_na2as::assert_expr(expr * t, expr * a) {
m_assumptions.push_back(a);
expr_ref new_t(m);
new_t = m.mk_implies(a, t);
assert_expr(new_t);
assert_expr_core(new_t);
}
}

View file

@ -34,8 +34,8 @@ public:
solver_na2as(ast_manager & m);
virtual ~solver_na2as();
virtual void assert_expr(expr * t, expr * a);
virtual void assert_expr(expr * t) = 0;
void assert_expr_core(expr * t, expr * a) override;
virtual void assert_expr_core(expr * t) = 0;
// Subclasses of solver_na2as should redefine the following *_core methods instead of these ones.
virtual lbool check_sat(unsigned num_assumptions, expr * const * assumptions);

View file

@ -49,7 +49,7 @@ public:
m_in_delayed_scope(false),
m_dump_counter(0) {
if (is_virtual()) {
solver_na2as::assert_expr(m.mk_true(), pred);
solver_na2as::assert_expr_core(m.mk_true(), pred);
}
}
@ -191,7 +191,7 @@ public:
}
}
virtual void assert_expr(expr * e) {
virtual void assert_expr_core(expr * e) {
SASSERT(!m_pushed || get_scope_level() > 0);
if (m.is_true(e)) return;
if (m_in_delayed_scope) {

View file

@ -54,7 +54,7 @@ public:
virtual void set_produce_models(bool f) { m_produce_models = f; }
virtual void assert_expr(expr * t);
virtual void assert_expr_core(expr * t);
virtual void assert_lemma(expr * t);
virtual void push_core();
@ -112,7 +112,7 @@ void tactic2solver::collect_param_descrs(param_descrs & r) {
m_tactic->collect_param_descrs(r);
}
void tactic2solver::assert_expr(expr * t) {
void tactic2solver::assert_expr_core(expr * t) {
m_assertions.push_back(t);
m_result = 0;
}

View file

@ -2,7 +2,6 @@ z3_add_component(tactic
SOURCES
equiv_proof_converter.cpp
extension_model_converter.cpp
filter_model_converter.cpp
generic_model_converter.cpp
goal.cpp
goal_num_occurs.cpp

View file

@ -23,7 +23,7 @@ Notes:
#include "ast/rewriter/pb2bv_rewriter.h"
#include "ast/ast_util.h"
#include "ast/ast_pp.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
class card2bv_tactic : public tactic {
ast_manager & m;
@ -89,9 +89,9 @@ public:
func_decl_ref_vector const& fns = rw2.fresh_constants();
if (!fns.empty()) {
filter_model_converter* filter = alloc(filter_model_converter, m);
generic_model_converter* filter = alloc(generic_model_converter, m);
for (unsigned i = 0; i < fns.size(); ++i) {
filter->insert(fns[i]);
filter->hide(fns[i]);
}
mc = filter;
}

View file

@ -20,7 +20,6 @@ Revision History:
--*/
#include "tactic/tactical.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
#include "util/cooperate.h"
#include "ast/arith_decl_plugin.h"
@ -197,12 +196,10 @@ class degree_shift_tactic : public tactic {
void prepare_substitution(model_converter_ref & mc) {
SASSERT(!m_var2degree.empty());
filter_model_converter * fmc = 0;
generic_model_converter * xmc = 0;
if (m_produce_models) {
fmc = alloc(filter_model_converter, m);
xmc = alloc(generic_model_converter, m);
mc = concat(fmc, xmc);
mc = xmc;
}
for (auto const& kv : m_var2degree) {
SASSERT(kv.m_value.is_int());
@ -211,7 +208,7 @@ class degree_shift_tactic : public tactic {
m_pinned.push_back(fresh);
m_var2var.insert(kv.m_key, fresh);
if (m_produce_models) {
fmc->insert(fresh->get_decl());
xmc->hide(fresh->get_decl());
xmc->add(kv.m_key->get_decl(), mk_power(fresh, rational(1)/kv.m_value));
}
if (m_produce_proofs) {

View file

@ -21,7 +21,7 @@ Revision History:
#include "ast/rewriter/th_rewriter.h"
#include "ast/for_each_expr.h"
#include "tactic/extension_model_converter.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
#include "ast/arith_decl_plugin.h"
#include "ast/expr_substitution.h"
#include "ast/ast_smt2_pp.h"
@ -225,10 +225,10 @@ class lia2pb_tactic : public tactic {
throw tactic_exception("lia2pb failed, number of necessary bits exceeds specified threshold (use option :lia2pb-total-bits to increase threshold)");
extension_model_converter * mc1 = 0;
filter_model_converter * mc2 = 0;
generic_model_converter * mc2 = 0;
if (m_produce_models) {
mc1 = alloc(extension_model_converter, m);
mc2 = alloc(filter_model_converter, m);
mc2 = alloc(generic_model_converter, m);
mc = concat(mc2, mc1);
}
@ -259,7 +259,7 @@ class lia2pb_tactic : public tactic {
else
def_args.push_back(m_util.mk_mul(m_util.mk_numeral(a, true), x_prime));
if (m_produce_models)
mc2->insert(x_prime->get_decl());
mc2->hide(x_prime->get_decl());
a *= rational(2);
}
SASSERT(def_args.size() > 1);

View file

@ -27,7 +27,7 @@ Notes:
#include "tactic/arith/bv2int_rewriter.h"
#include "tactic/arith/bv2real_rewriter.h"
#include "tactic/extension_model_converter.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
#include "tactic/arith/bound_manager.h"
#include "util/obj_pair_hashtable.h"
#include "ast/ast_smt2_pp.h"
@ -60,7 +60,7 @@ class nla2bv_tactic : public tactic {
expr_ref_vector m_trail;
unsigned m_num_bits;
unsigned m_default_bv_size;
filter_model_converter_ref m_fmc;
generic_model_converter_ref m_fmc;
public:
imp(ast_manager & m, params_ref const& p):
@ -86,7 +86,7 @@ class nla2bv_tactic : public tactic {
TRACE("nla2bv", g.display(tout);
tout << "Muls: " << count_mul(g) << "\n";
);
m_fmc = alloc(filter_model_converter, m_manager);
m_fmc = alloc(generic_model_converter, m_manager);
m_bounds(g);
collect_power2(g);
if(!collect_vars(g)) {
@ -104,7 +104,7 @@ class nla2bv_tactic : public tactic {
evc->insert(m_vars[i].get(), m_defs[i].get());
}
for (unsigned i = 0; i < m_bv2real.num_aux_decls(); ++i) {
m_fmc->insert(m_bv2real.get_aux_decl(i));
m_fmc->hide(m_bv2real.get_aux_decl(i));
}
IF_VERBOSE(TACTIC_VERBOSITY_LVL, verbose_stream() << "(nla->bv :sat-preserving " << m_is_sat_preserving << ")\n";);
TRACE("nla2bv_verbose", g.display(tout););
@ -233,7 +233,7 @@ class nla2bv_tactic : public tactic {
bv_sort = m_bv.mk_sort(num_bits);
std::string name = n->get_decl()->get_name().str();
s_bv = m_manager.mk_fresh_const(name.c_str(), bv_sort);
m_fmc->insert(to_app(s_bv)->get_decl());
m_fmc->hide(s_bv);
s_bv = m_bv.mk_bv2int(s_bv);
if (low) {
if (!(*low).is_zero()) {
@ -271,8 +271,8 @@ class nla2bv_tactic : public tactic {
s = m_manager.mk_fresh_const(name.c_str(), bv_sort);
name += "_r";
t = m_manager.mk_fresh_const(name.c_str(), bv_sort);
m_fmc->insert(to_app(s)->get_decl());
m_fmc->insert(to_app(t)->get_decl());
m_fmc->hide(s);
m_fmc->hide(t);
s_bv = m_bv2real.mk_bv2real(s, t);
m_trail.push_back(s_bv);
m_subst.insert(n, s_bv);

View file

@ -22,7 +22,7 @@ Revision History:
#include "tactic/arith/bound_manager.h"
#include "ast/rewriter/th_rewriter.h"
#include "tactic/extension_model_converter.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
#include "ast/arith_decl_plugin.h"
#include "ast/expr_substitution.h"
#include "ast/ast_smt2_pp.h"
@ -99,10 +99,10 @@ class normalize_bounds_tactic : public tactic {
}
extension_model_converter * mc1 = 0;
filter_model_converter * mc2 = 0;
generic_model_converter * mc2 = 0;
if (produce_models) {
mc1 = alloc(extension_model_converter, m);
mc2 = alloc(filter_model_converter, m);
mc2 = alloc(generic_model_converter, m);
mc = concat(mc2, mc1);
}
@ -121,7 +121,7 @@ class normalize_bounds_tactic : public tactic {
subst.insert(x, def);
if (produce_models) {
mc1->insert(to_app(x)->get_decl(), def);
mc2->insert(x_prime->get_decl());
mc2->hide(x_prime->get_decl());
}
}
}

View file

@ -26,7 +26,7 @@ Notes:
#include "util/trace.h"
#include "ast/ast_smt2_pp.h"
#include "ast/expr_substitution.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
#include "tactic/arith/pb2bv_model_converter.h"
#include "tactic/arith/pb2bv_tactic.h"
#include "ast/ast_pp.h"
@ -949,15 +949,13 @@ private:
g->update(idx, new_exprs[idx].get(), 0, (m_produce_unsat_cores) ? new_deps[idx].get() : g->dep(idx));
if (m_produce_models) {
filter_model_converter * mc1 = alloc(filter_model_converter, m);
obj_map<func_decl, expr*>::iterator it = m_const2bit.begin();
obj_map<func_decl, expr*>::iterator end = m_const2bit.end();
for (; it != end; ++it)
mc1->insert(to_app(it->m_value)->get_decl());
generic_model_converter * mc1 = alloc(generic_model_converter, m);
for (auto const& kv : m_const2bit)
mc1->hide(kv.m_value);
// store temp int constants in the filter
unsigned num_temps = m_temporary_ints.size();
for (unsigned i = 0; i < num_temps; i++)
mc1->insert(to_app(m_temporary_ints.get(i))->get_decl());
mc1->hide(m_temporary_ints.get(i));
pb2bv_model_converter * mc2 = alloc(pb2bv_model_converter, m, m_const2bit, m_bm);
mc = concat(mc1, mc2);
}

View file

@ -27,7 +27,7 @@ Revision History:
#include "tactic/core/nnf_tactic.h"
#include "tactic/core/simplify_tactic.h"
#include "ast/rewriter/th_rewriter.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
#include "tactic/extension_model_converter.h"
#include "ast/ast_smt2_pp.h"
#include "ast/rewriter/expr_replacer.h"
@ -764,17 +764,15 @@ struct purify_arith_proc {
m_goal.assert_expr(r.cfg().m_new_cnstrs.get(i), m_produce_proofs ? r.cfg().m_new_cnstr_prs.get(i) : 0, 0);
}
// add filter_model_converter to eliminate auxiliary variables from model
// add generic_model_converter to eliminate auxiliary variables from model
if (produce_models) {
filter_model_converter * fmc = alloc(filter_model_converter, m());
generic_model_converter * fmc = alloc(generic_model_converter, m());
mc = fmc;
obj_map<app, expr*> & f2v = r.cfg().m_app2fresh;
obj_map<app, expr*>::iterator it = f2v.begin();
obj_map<app, expr*>::iterator end = f2v.end();
for (; it != end; ++it) {
app * v = to_app(it->m_value);
for (auto const& kv : f2v) {
app * v = to_app(kv.m_value);
SASSERT(is_uninterp_const(v));
fmc->insert(v->get_decl());
fmc->hide(v->get_decl());
}
}
if (produce_models && !m_sin_cos.empty()) {

View file

@ -33,7 +33,7 @@ Revision History:
#include "tactic/tactical.h"
#include "ast/rewriter/th_rewriter.h"
#include "tactic/extension_model_converter.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
#include "ast/arith_decl_plugin.h"
#include "ast/expr_substitution.h"
#include "util/dec_ref_util.h"
@ -113,7 +113,7 @@ class recover_01_tactic : public tactic {
// temporary fields used by operator() and process
extension_model_converter * mc1;
filter_model_converter * mc2;
generic_model_converter * mc2;
expr_substitution * subst;
goal_ref new_goal;
obj_map<expr, expr *> bool2int;
@ -205,7 +205,7 @@ class recover_01_tactic : public tactic {
expr * bool_def = m.mk_eq(var, m_util.mk_numeral(rational(1), true));
subst->insert(atom, bool_def);
if (m_produce_models) {
mc2->insert(to_app(var)->get_decl());
mc2->hide(to_app(var)->get_decl());
mc1->insert(to_app(atom)->get_decl(), bool_def);
}
m.inc_ref(atom);
@ -329,7 +329,7 @@ class recover_01_tactic : public tactic {
if (m_produce_models) {
mc1 = alloc(extension_model_converter, m);
mc2 = alloc(filter_model_converter, m);
mc2 = alloc(generic_model_converter, m);
mc = concat(mc2, mc1);
}

View file

@ -25,7 +25,7 @@ Notes:
#include "ast/bv_decl_plugin.h"
#include "ast/rewriter/expr_replacer.h"
#include "tactic/extension_model_converter.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
#include "ast/ast_smt2_pp.h"
class bv_size_reduction_tactic : public tactic {
@ -60,7 +60,7 @@ struct bv_size_reduction_tactic::imp {
obj_map<app, numeral> m_unsigned_lowers;
obj_map<app, numeral> m_unsigned_uppers;
ref<bv_size_reduction_mc> m_mc;
filter_model_converter_ref m_fmc;
generic_model_converter_ref m_fmc;
scoped_ptr<expr_replacer> m_replacer;
bool m_produce_models;
@ -269,9 +269,9 @@ struct bv_size_reduction_tactic::imp {
m_mc = alloc(bv_size_reduction_mc, m);
m_mc->insert(v->get_decl(), new_def);
if (!m_fmc && new_const)
m_fmc = alloc(filter_model_converter, m);
m_fmc = alloc(generic_model_converter, m);
if (new_const)
m_fmc->insert(new_const->get_decl());
m_fmc->hide(new_const);
}
num_reduced++;
}
@ -335,9 +335,9 @@ struct bv_size_reduction_tactic::imp {
m_mc = alloc(bv_size_reduction_mc, m);
m_mc->insert(v->get_decl(), new_def);
if (!m_fmc && new_const)
m_fmc = alloc(filter_model_converter, m);
m_fmc = alloc(generic_model_converter, m);
if (new_const)
m_fmc->insert(new_const->get_decl());
m_fmc->hide(new_const);
}
num_reduced++;
TRACE("bv_size_reduction", tout << "New definition = " << mk_ismt2_pp(new_def, m) << "\n";);

View file

@ -120,7 +120,7 @@ func_decl_ref bvarray2uf_rewriter_cfg::mk_uf_for_array(expr * e) {
m_array_util.mk_as_array(bv_f));
}
else if (m_fmc)
m_fmc->insert(bv_f);
m_fmc->hide(bv_f);
m_arrays_fs.insert(e, bv_f);
m_manager.inc_ref(e);
m_manager.inc_ref(bv_f);
@ -193,10 +193,10 @@ br_status bvarray2uf_rewriter_cfg::reduce_app(func_decl * f, unsigned num, expr
if (is_uninterp_const(e)) {
if (m_emc)
m_emc->insert(e->get_decl(),
m_array_util.mk_as_array(bv_f));
m_array_util.mk_as_array(bv_f));
}
else if (m_fmc)
m_fmc->insert(bv_f);
m_fmc->hide(bv_f);
m_arrays_fs.insert(e, bv_f);
m_manager.inc_ref(e);
m_manager.inc_ref(bv_f);

View file

@ -22,7 +22,7 @@ Notes:
#include "ast/rewriter/rewriter.h"
#include "tactic/extension_model_converter.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
class bvarray2uf_rewriter_cfg : public default_rewriter_cfg {
ast_manager & m_manager;
@ -31,7 +31,7 @@ class bvarray2uf_rewriter_cfg : public default_rewriter_cfg {
bv_util m_bv_util;
array_util m_array_util;
extension_model_converter * m_emc;
filter_model_converter * m_fmc;
generic_model_converter * m_fmc;
obj_map<expr, func_decl*> m_arrays_fs;
@ -59,7 +59,7 @@ public:
expr_ref_vector extra_assertions;
void set_mcs(extension_model_converter * emc, filter_model_converter * fmc) { m_emc = emc; m_fmc = fmc; }
void set_mcs(extension_model_converter * emc, generic_model_converter * fmc) { m_emc = emc; m_fmc = fmc; }
protected:
sort * get_index_sort(expr * e);
@ -79,7 +79,7 @@ struct bvarray2uf_rewriter : public rewriter_tpl<bvarray2uf_rewriter_cfg> {
m_cfg(m, p) {
}
void set_mcs(extension_model_converter * emc, filter_model_converter * fmc) { m_cfg.set_mcs(emc, fmc); }
void set_mcs(extension_model_converter * emc, generic_model_converter * fmc) { m_cfg.set_mcs(emc, fmc); }
};
#endif

View file

@ -21,7 +21,7 @@ Notes:
#include "ast/bv_decl_plugin.h"
#include "ast/rewriter/expr_replacer.h"
#include "tactic/extension_model_converter.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
#include "ast/ast_smt2_pp.h"
#include "tactic/bv/bvarray2uf_tactic.h"
@ -69,7 +69,7 @@ class bvarray2uf_tactic : public tactic {
if (m_produce_models) {
extension_model_converter * emc = alloc(extension_model_converter, m_manager);
filter_model_converter * fmc = alloc(filter_model_converter, m_manager);
generic_model_converter * fmc = alloc(generic_model_converter, m_manager);
mc = concat(emc, fmc);
m_rw.set_mcs(emc, fmc);
}

View file

@ -21,11 +21,11 @@ Revision History:
#include "tactic/bv/dt2bv_tactic.h"
#include "tactic/tactical.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
#include "ast/datatype_decl_plugin.h"
#include "ast/bv_decl_plugin.h"
#include "ast/rewriter/rewriter_def.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
#include "tactic/extension_model_converter.h"
#include "ast/rewriter/var_subst.h"
#include "ast/ast_util.h"
@ -135,7 +135,7 @@ public:
m_fd_sorts.remove(s);
if (!m_fd_sorts.empty()) {
ref<extension_model_converter> ext = alloc(extension_model_converter, m);
ref<filter_model_converter> filter = alloc(filter_model_converter, m);
ref<generic_model_converter> filter = alloc(generic_model_converter, m);
enum2bv_rewriter rw(m, m_params);
rw.set_is_fd(&m_is_fd);
expr_ref new_curr(m);
@ -153,7 +153,7 @@ public:
for (expr* b : bounds)
g->assert_expr(b);
for (auto const& kv : rw.enum2bv())
filter->insert(kv.m_value);
filter->hide(kv.m_value);
for (auto const& kv : rw.enum2def())
ext->insert(kv.m_key, kv.m_value);

View file

@ -18,7 +18,7 @@ Revision History:
--*/
#include "tactic/tactical.h"
#include "ast/rewriter/rewriter_def.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
#include "util/cooperate.h"
#include "ast/bv_decl_plugin.h"
#include "ast/used_vars.h"
@ -35,7 +35,7 @@ class elim_small_bv_tactic : public tactic {
params_ref m_params;
bv_util m_util;
th_rewriter m_simp;
ref<filter_model_converter> m_mc;
ref<generic_model_converter> m_mc;
goal * m_goal;
unsigned m_max_bits;
unsigned long long m_max_steps;

View file

@ -19,7 +19,6 @@ Notes:
#include "tactic/tactical.h"
#include "ast/normal_forms/defined_names.h"
#include "ast/rewriter/rewriter_def.h"
#include "tactic/filter_model_converter.h"
#include "util/cooperate.h"
#include "ast/scoped_proof.h"

View file

@ -20,7 +20,7 @@ Notes:
#include "tactic/tactical.h"
#include "ast/normal_forms/defined_names.h"
#include "ast/rewriter/rewriter_def.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
#include "util/cooperate.h"
class elim_term_ite_tactic : public tactic {
@ -28,7 +28,7 @@ class elim_term_ite_tactic : public tactic {
struct rw_cfg : public default_rewriter_cfg {
ast_manager & m;
defined_names m_defined_names;
ref<filter_model_converter> m_mc;
ref<generic_model_converter> m_mc;
goal * m_goal;
unsigned long long m_max_memory; // in bytes
bool m_produce_models;
@ -55,8 +55,8 @@ class elim_term_ite_tactic : public tactic {
m_num_fresh++;
if (m_produce_models) {
if (!m_mc)
m_mc = alloc(filter_model_converter, m);
m_mc->insert(_result->get_decl());
m_mc = alloc(generic_model_converter, m);
m_mc->hide(_result->get_decl());
}
}
result = _result.get();

View file

@ -18,7 +18,6 @@ Notes:
--*/
#include "tactic/tactical.h"
#include "tactic/generic_model_converter.h"
#include "tactic/filter_model_converter.h"
#include "ast/rewriter/rewriter_def.h"
#include "ast/arith_decl_plugin.h"
#include "ast/bv_decl_plugin.h"
@ -873,9 +872,9 @@ class elim_uncnstr_tactic : public tactic {
app_ref_vector & fresh_vars = m_rw->cfg().m_fresh_vars;
m_num_elim_apps = fresh_vars.size();
if (produce_models && !fresh_vars.empty()) {
filter_model_converter * fmc = alloc(filter_model_converter, m());
for (unsigned i = 0; i < fresh_vars.size(); i++)
fmc->insert(fresh_vars.get(i)->get_decl());
generic_model_converter * fmc = alloc(generic_model_converter, m());
for (app * f : fresh_vars)
fmc->hide(f);
mc = concat(fmc, m_mc.get());
}
else {
@ -910,7 +909,7 @@ class elim_uncnstr_tactic : public tactic {
imp * m_imp;
params_ref m_params;
public:
elim_uncnstr_tactic(ast_manager & m, params_ref const & p):
elim_uncnstr_tactic(ast_manager & m, params_ref const & p):
m_params(p) {
m_imp = alloc(imp, m, p);
}

View file

@ -18,7 +18,7 @@ Revision History:
--*/
#include "ast/normal_forms/nnf.h"
#include "tactic/tactical.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
class nnf_tactic : public tactic {
params_ref m_params;
@ -97,10 +97,10 @@ public:
result.push_back(g.get());
unsigned num_extra_names = dnames.get_num_names();
if (num_extra_names > 0) {
filter_model_converter * fmc = alloc(filter_model_converter, m);
generic_model_converter * fmc = alloc(generic_model_converter, m);
mc = fmc;
for (unsigned i = 0; i < num_extra_names; i++)
fmc->insert(dnames.get_name_decl(i));
fmc->hide(dnames.get_name_decl(i));
}
TRACE("nnf", g->display(tout););
SASSERT(g->is_well_sorted());

View file

@ -23,13 +23,13 @@ Revision History:
--*/
#include "tactic/tactical.h"
#include "tactic/core/occf_tactic.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
#include "util/cooperate.h"
class occf_tactic : public tactic {
struct imp {
ast_manager & m;
filter_model_converter * m_mc;
generic_model_converter * m_mc;
imp(ast_manager & _m):
m(_m) {
@ -115,7 +115,7 @@ class occf_tactic : public tactic {
SASSERT(!c2b.contains(cnstr));
expr * bvar = m.mk_fresh_const(0, m.mk_bool_sort());
if (produce_models)
m_mc->insert(to_app(bvar)->get_decl());
m_mc->hide(to_app(bvar)->get_decl());
c2b.insert(cnstr, bvar_info(bvar, sign));
if (sign) {
g->assert_expr(m.mk_or(bvar, m.mk_not(cnstr)), 0, 0);
@ -157,7 +157,7 @@ class occf_tactic : public tactic {
if (!is_target(cls))
continue;
if (produce_models && !m_mc) {
m_mc = alloc(filter_model_converter, m);
m_mc = alloc(generic_model_converter, m);
mc = m_mc;
}
expr * keep = 0;

View file

@ -23,7 +23,7 @@ Notes:
#include "util/map.h"
#include "ast/rewriter/rewriter_def.h"
#include "tactic/extension_model_converter.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
/**
\brief Reduce the number of arguments in function applications.
@ -395,7 +395,7 @@ struct reduce_args_tactic::imp {
var_ref_vector new_vars(m_manager);
ptr_buffer<expr> new_eqs;
extension_model_converter * e_mc = alloc(extension_model_converter, m_manager);
filter_model_converter * f_mc = alloc(filter_model_converter, m_manager);
generic_model_converter * f_mc = alloc(generic_model_converter, m_manager);
decl2arg2func_map::iterator it = decl2arg2funcs.begin();
decl2arg2func_map::iterator end = decl2arg2funcs.end();
for (; it != end; ++it) {
@ -416,7 +416,7 @@ struct reduce_args_tactic::imp {
for (; it2 != end2; ++it2) {
app * t = it2->m_key;
func_decl * new_def = it2->m_value;
f_mc->insert(new_def);
f_mc->hide(new_def);
SASSERT(new_def->get_arity() == new_args.size());
app * new_t = m_manager.mk_app(new_def, new_args.size(), new_args.c_ptr());
if (def == 0) {

View file

@ -51,7 +51,7 @@ Notes:
--*/
#include "tactic/tactical.h"
#include "tactic/goal_shared_occs.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
#include "ast/rewriter/bool_rewriter.h"
#include "tactic/core/simplify_tactic.h"
#include "util/cooperate.h"
@ -80,7 +80,7 @@ class tseitin_cnf_tactic : public tactic {
frame(app * n):m_t(n), m_first(true) {}
};
typedef filter_model_converter mc;
typedef generic_model_converter mc;
ast_manager & m;
svector<frame> m_frame_stack;
@ -344,7 +344,7 @@ class tseitin_cnf_tactic : public tactic {
app * v = m.mk_fresh_const(0, m.mk_bool_sort());
m_fresh_vars.push_back(v);
if (m_mc)
m_mc->insert(v->get_decl());
m_mc->hide(v->get_decl());
return v;
}
@ -817,7 +817,7 @@ class tseitin_cnf_tactic : public tactic {
m_frame_stack.reset();
m_clauses.reset();
if (m_produce_models)
m_mc = alloc(filter_model_converter, m);
m_mc = alloc(generic_model_converter, m);
else
m_mc = 0;

View file

@ -10,6 +10,8 @@ Abstract:
Model converter that introduces new interpretations into a model.
It used to be called elim_var_model_converter
TBD: special case of generic_model_converter
Author:
Leonardo (leonardo) 2011-10-21

View file

@ -1,74 +0,0 @@
/*++
Copyright (c) 2011 Microsoft Corporation
Module Name:
filter_model_converter.cpp
Abstract:
Filter decls from a model
Author:
Leonardo (leonardo) 2011-05-06
Notes:
--*/
#include "tactic/filter_model_converter.h"
#include "model/model_v2_pp.h"
filter_model_converter::~filter_model_converter() {
}
void filter_model_converter::operator()(model_ref & old_model, unsigned goal_idx) {
TRACE("filter_mc", tout << "before filter_model_converter\n"; model_v2_pp(tout, *old_model); display(tout););
ast_fast_mark1 fs;
unsigned num = m_decls.size();
for (unsigned i = 0; i < num; i++)
fs.mark(m_decls.get(i));
model * new_model = alloc(model, m());
num = old_model->get_num_constants();
for (unsigned i = 0; i < num; i++) {
func_decl * f = old_model->get_constant(i);
if (fs.is_marked(f))
continue;
expr * fi = old_model->get_const_interp(f);
new_model->register_decl(f, fi);
}
num = old_model->get_num_functions();
for (unsigned i = 0; i < num; i++) {
func_decl * f = old_model->get_function(i);
if (fs.is_marked(f))
continue;
func_interp * fi = old_model->get_func_interp(f);
SASSERT(fi);
new_model->register_decl(f, fi->copy());
}
new_model->copy_usort_interps(*old_model);
old_model = new_model;
TRACE("filter_mc", tout << "after filter_model_converter\n"; model_v2_pp(tout, *old_model););
}
void filter_model_converter::operator()(svector<symbol> & labels, unsigned goal_idx) {
}
void filter_model_converter::display(std::ostream & out) {
for (func_decl* f : m_decls) {
display_del(out, f);
}
}
model_converter * filter_model_converter::translate(ast_translation & translator) {
filter_model_converter * res = alloc(filter_model_converter, translator.to());
for (func_decl* f : m_decls)
res->m_decls.push_back(translator(f));
return res;
}
void filter_model_converter::collect(ast_pp_util& visitor) {
m_env = &visitor.env();
for (func_decl* f : m_decls) visitor.coll.visit_func(f);
}

View file

@ -1,56 +0,0 @@
/*++
Copyright (c) 2011 Microsoft Corporation
Module Name:
filter_model_converter.h
Abstract:
Filter decls from a model
Author:
Leonardo (leonardo) 2011-05-06
Notes:
--*/
#ifndef FILTER_MODEL_CONVERTER_H_
#define FILTER_MODEL_CONVERTER_H_
#include "tactic/model_converter.h"
#include "ast/ast_pp_util.h"
class filter_model_converter : public model_converter {
func_decl_ref_vector m_decls;
public:
filter_model_converter(ast_manager & m): m_decls(m) {}
virtual ~filter_model_converter();
ast_manager & m() const { return m_decls.get_manager(); }
virtual void operator()(model_ref & md, unsigned goal_idx);
virtual void operator()(svector<symbol> & labels, unsigned goal_idx);
virtual void operator()(model_ref & md) { operator()(md, 0); } // TODO: delete
virtual void cancel() {}
virtual void display(std::ostream & out);
void insert(func_decl * d) {
m_decls.push_back(d);
}
virtual model_converter * translate(ast_translation & translator);
virtual void collect(ast_pp_util& visitor);
};
typedef ref<filter_model_converter> filter_model_converter_ref;
#endif

View file

@ -85,3 +85,7 @@ void generic_model_converter::collect(ast_pp_util& visitor) {
if (e.m_def) visitor.coll.visit(e.m_def);
}
}
void generic_model_converter::operator()(expr_ref& fml) {
NOT_IMPLEMENTED_YET();
}

View file

@ -38,6 +38,8 @@ public:
virtual ~generic_model_converter() { }
void hide(expr* e) { SASSERT(is_app(e) && to_app(e)->get_num_args() == 0); hide(to_app(e)->get_decl()); }
void hide(func_decl * f) { m_entries.push_back(entry(f, 0, m, HIDE)); }
void add(func_decl * d, expr* e) { m_entries.push_back(entry(d, e, m, ADD)); }
@ -55,6 +57,8 @@ public:
virtual model_converter * translate(ast_translation & translator);
virtual void collect(ast_pp_util& visitor);
void operator()(expr_ref& fml) override;
};
typedef ref<generic_model_converter> generic_model_converter_ref;

View file

@ -45,12 +45,19 @@ public:
SASSERT(goal_idx == 0);
operator()(m);
}
virtual void operator()(labels_vec & r, unsigned goal_idx) {}
virtual void operator()(labels_vec & r, unsigned goal_idx) {}
virtual model_converter * translate(ast_translation & translator) = 0;
virtual void collect(ast_pp_util& visitor) { m_env = &visitor.env(); }
/**
\brief we are adding a formula to the context of the model converter.
The operator has as side effect of adding definitions as assertions to the
formula and removing these definitions from the model converter.
*/
virtual void operator()(expr_ref& formula) { UNREACHABLE(); }
};
typedef ref<model_converter> model_converter_ref;

View file

@ -49,7 +49,7 @@ Revision History:
#include "smt/tactic/smt_tactic.h"
#include "ast/rewriter/rewriter.h"
#include "nlsat/tactic/nlsat_tactic.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
#include "util/obj_pair_hashtable.h"
#include "ast/rewriter/rewriter_def.h"
#include "ast/ast_pp.h"
@ -73,7 +73,7 @@ class nl_purify_tactic : public tactic {
arith_util m_util;
params_ref m_params;
bool m_produce_proofs;
ref<filter_model_converter> m_fmc;
ref<generic_model_converter> m_fmc;
tactic_ref m_nl_tac; // nlsat tactic
goal_ref m_nl_g; // nlsat goal
ref<solver> m_solver; // SMT solver
@ -133,7 +133,7 @@ public:
}
r = m.mk_fresh_const(0, u().mk_real());
m_new_reals.push_back(to_app(r));
m_owner.m_fmc->insert(to_app(r)->get_decl());
m_owner.m_fmc->hide(r);
m_interface_cache.insert(arg, r);
expr_ref eq(m);
eq = m.mk_eq(r, arg);
@ -159,7 +159,7 @@ public:
result = m.mk_fresh_const(0, m.mk_bool_sort());
m_polarities.insert(result, pol);
m_new_preds.push_back(to_app(result));
m_owner.m_fmc->insert(to_app(result)->get_decl());
m_owner.m_fmc->hide(result);
if (pol != pol_neg) {
m_owner.m_nl_g->assert_expr(m.mk_or(m.mk_not(result), old_pred));
}
@ -491,7 +491,7 @@ private:
pred = m.mk_fresh_const(0, m.mk_bool_sort());
m_eq_preds.push_back(pred);
m_eq_values.push_back(l_true);
m_fmc->insert(to_app(pred)->get_decl());
m_fmc->hide(pred);
nl_g->assert_expr(m.mk_or(m.mk_not(pred), m.mk_eq(w, v)));
nl_g->assert_expr(m.mk_or(pred, m.mk_not(m.mk_eq(w, v))));
m_solver->assert_expr(m.mk_iff(pred, m.mk_eq(w, v)));
@ -761,7 +761,7 @@ public:
rw r(*this);
expr_ref_vector clauses(m);
m_nl_g = alloc(goal, m, true, false);
m_fmc = alloc(filter_model_converter, m);
m_fmc = alloc(generic_model_converter, m);
// first hoist interface variables,
// then annotate subformulas by polarities,

View file

@ -21,7 +21,7 @@ Notes:
#include "solver/solver_na2as.h"
#include "tactic/tactic.h"
#include "ast/rewriter/pb2bv_rewriter.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
#include "tactic/extension_model_converter.h"
#include "ast/ast_pp.h"
#include "model/model_smt2_pp.h"
@ -86,7 +86,7 @@ public:
return result;
}
virtual void assert_expr(expr * t) {
virtual void assert_expr_core(expr * t) {
unsigned i = m_assertions.size();
m_assertions.push_back(t);
while (i < m_assertions.size()) {
@ -209,10 +209,8 @@ private:
if (m_bv_fns.empty()) {
return;
}
filter_model_converter filter(m);
for (unsigned i = 0; i < m_bv_fns.size(); ++i) {
filter.insert(m_bv_fns[i].get());
}
generic_model_converter filter(m);
for (func_decl* f : m_bv_fns) filter.hide(f);
filter(mdl, 0);
}

View file

@ -26,7 +26,7 @@ Notes:
#include "model/model_smt2_pp.h"
#include "tactic/tactic.h"
#include "tactic/extension_model_converter.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
#include "tactic/portfolio/enum2bv_solver.h"
#include "solver/solver_na2as.h"
#include "ast/rewriter/enum2bv_rewriter.h"
@ -58,7 +58,7 @@ public:
return result;
}
virtual void assert_expr(expr * t) {
virtual void assert_expr_core(expr * t) {
expr_ref tmp(t, m);
expr_ref_vector bounds(m);
proof_ref tmp_proof(m);
@ -164,9 +164,9 @@ public:
}
void filter_model(model_ref& mdl) {
filter_model_converter filter(m);
generic_model_converter filter(m);
for (auto const& kv : m_rewriter.enum2bv()) {
filter.insert(kv.m_value);
filter.hide(kv.m_value);
}
filter(mdl, 0);
}

View file

@ -549,7 +549,7 @@ public:
expr_ref_vector clauses(m);
ptr_vector<expr> assumptions;
obj_map<expr, expr*> bool2dep;
ref<filter_model_converter> fmc;
ref<generic_model_converter> fmc;
extract_clauses_and_dependencies(g, clauses, assumptions, bool2dep, fmc);
for (expr * clause : clauses) {
s->assert_expr(clause);

View file

@ -21,7 +21,7 @@ Notes:
#include "tactic/tactic.h"
#include "ast/rewriter/pb2bv_rewriter.h"
#include "ast/rewriter/th_rewriter.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
#include "ast/ast_pp.h"
#include "model/model_smt2_pp.h"
@ -57,7 +57,7 @@ public:
return result;
}
virtual void assert_expr(expr * t) {
virtual void assert_expr_core(expr * t) {
m_assertions.push_back(t);
}
@ -113,10 +113,10 @@ public:
if (m_rewriter.fresh_constants().empty()) {
return;
}
filter_model_converter filter(m);
generic_model_converter filter(m);
func_decl_ref_vector const& fns = m_rewriter.fresh_constants();
for (unsigned i = 0; i < fns.size(); ++i) {
filter.insert(fns[i]);
for (func_decl* f : fns) {
filter.hide(f);
}
filter(mdl, 0);
}
@ -138,8 +138,8 @@ private:
proof_ref proof(m);
expr_ref fml1(m), fml(m);
expr_ref_vector fmls(m);
for (unsigned i = 0; i < m_assertions.size(); ++i) {
m_th_rewriter(m_assertions[i].get(), fml1, proof);
for (expr* a : m_assertions) {
m_th_rewriter(a, fml1, proof);
m_rewriter(fml1, fml, proof);
m_solver->assert_expr(fml);
}

View file

@ -18,10 +18,9 @@ Revision History:
#include "tactic/sine_filter.h"
#include "tactic/tactical.h"
#include "tactic/filter_model_converter.h"
#include "tactic/generic_model_converter.h"
#include "ast/datatype_decl_plugin.h"
#include "ast/rewriter/rewriter_def.h"
#include "tactic/filter_model_converter.h"
#include "tactic/extension_model_converter.h"
#include "ast/rewriter/var_subst.h"
#include "ast/ast_util.h"
@ -69,7 +68,7 @@ public:
result.push_back(g.get());
TRACE("sine", result[0]->display(tout););
SASSERT(g->is_well_sorted());
filter_model_converter * fmc = alloc(filter_model_converter, m);
generic_model_converter * fmc = alloc(generic_model_converter, m);
mc = fmc;
}