mirror of
https://github.com/Z3Prover/z3
synced 2025-08-15 15:25:26 +00:00
add stubs for converting assertions, consolidate filter_model_converter
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
53e36c9cf9
commit
0d15b6abb7
76 changed files with 244 additions and 356 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue