mirror of
https://github.com/Z3Prover/z3
synced 2025-04-05 17:14:07 +00:00
streamlining proof generation (initial step of removing ast-manager dependency). Detect error in model creation when declaring constant with non-zero arity. See #1223
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
77bbae65f5
commit
f63439603d
|
@ -2843,6 +2843,8 @@ void fpa_example() {
|
|||
/*@}*/
|
||||
/*@}*/
|
||||
|
||||
|
||||
|
||||
int main() {
|
||||
#ifdef LOG_Z3_CALLS
|
||||
Z3_open_log("z3.log");
|
||||
|
|
|
@ -249,7 +249,7 @@ extern "C" {
|
|||
params_ref _p;
|
||||
_p.set_bool("proof", true); // this is currently useless
|
||||
|
||||
scoped_proof_mode spm(mk_c(c)->m(), PGM_FINE);
|
||||
scoped_proof_mode spm(mk_c(c)->m(), PGM_ENABLED);
|
||||
scoped_ptr<solver_factory> sf = mk_smt_solver_factory();
|
||||
scoped_ptr<solver> m_solver((*sf)(mk_c(c)->m(), _p, true, true, true, ::symbol::null));
|
||||
m_solver.get()->updt_params(_p); // why do we have to do this?
|
||||
|
|
|
@ -255,8 +255,13 @@ extern "C" {
|
|||
LOG_Z3_add_const_interp(c, m, f, a);
|
||||
RESET_ERROR_CODE();
|
||||
func_decl* d = to_func_decl(f);
|
||||
model* mdl = to_model_ref(m);
|
||||
mdl->register_decl(d, to_expr(a));
|
||||
if (d->get_arity() != 0) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
}
|
||||
else {
|
||||
model* mdl = to_model_ref(m);
|
||||
mdl->register_decl(d, to_expr(a));
|
||||
}
|
||||
Z3_CATCH;
|
||||
}
|
||||
|
||||
|
|
|
@ -2626,7 +2626,7 @@ bool ast_manager::is_fully_interp(sort * s) const {
|
|||
// -----------------------------------
|
||||
|
||||
proof * ast_manager::mk_proof(family_id fid, decl_kind k, unsigned num_args, expr * const * args) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
if (proofs_disabled())
|
||||
return m_undef_proof;
|
||||
return mk_app(fid, k, num_args, args);
|
||||
}
|
||||
|
@ -2662,8 +2662,7 @@ proof * ast_manager::mk_goal(expr * f) {
|
|||
}
|
||||
|
||||
proof * ast_manager::mk_modus_ponens(proof * p1, proof * p2) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
return m_undef_proof;
|
||||
if (!p1 || !p2) return nullptr;
|
||||
SASSERT(has_fact(p1));
|
||||
SASSERT(has_fact(p2));
|
||||
CTRACE("mk_modus_ponens", !(is_implies(get_fact(p2)) || is_iff(get_fact(p2)) || is_oeq(get_fact(p2))),
|
||||
|
@ -2684,13 +2683,13 @@ proof * ast_manager::mk_modus_ponens(proof * p1, proof * p2) {
|
|||
}
|
||||
|
||||
proof * ast_manager::mk_reflexivity(expr * e) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
if (proofs_disabled())
|
||||
return m_undef_proof;
|
||||
return mk_app(m_basic_family_id, PR_REFLEXIVITY, mk_eq(e, e));
|
||||
}
|
||||
|
||||
proof * ast_manager::mk_oeq_reflexivity(expr * e) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
if (proofs_disabled())
|
||||
return m_undef_proof;
|
||||
return mk_app(m_basic_family_id, PR_REFLEXIVITY, mk_oeq(e, e));
|
||||
}
|
||||
|
@ -2705,8 +2704,7 @@ proof * ast_manager::mk_commutativity(app * f) {
|
|||
\brief Given a proof of p, return a proof of (p <=> true)
|
||||
*/
|
||||
proof * ast_manager::mk_iff_true(proof * pr) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
return m_undef_proof;
|
||||
if (!pr) return pr;
|
||||
SASSERT(has_fact(pr));
|
||||
SASSERT(is_bool(get_fact(pr)));
|
||||
return mk_app(m_basic_family_id, PR_IFF_TRUE, pr, mk_iff(get_fact(pr), mk_true()));
|
||||
|
@ -2716,8 +2714,7 @@ proof * ast_manager::mk_iff_true(proof * pr) {
|
|||
\brief Given a proof of (not p), return a proof of (p <=> false)
|
||||
*/
|
||||
proof * ast_manager::mk_iff_false(proof * pr) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
return m_undef_proof;
|
||||
if (!pr) return pr;
|
||||
SASSERT(has_fact(pr));
|
||||
SASSERT(is_not(get_fact(pr)));
|
||||
expr * p = to_app(get_fact(pr))->get_arg(0);
|
||||
|
@ -2725,10 +2722,7 @@ proof * ast_manager::mk_iff_false(proof * pr) {
|
|||
}
|
||||
|
||||
proof * ast_manager::mk_symmetry(proof * p) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
return m_undef_proof;
|
||||
if (!p)
|
||||
return p;
|
||||
if (!p) return p;
|
||||
if (is_reflexivity(p))
|
||||
return p;
|
||||
if (is_symmetry(p))
|
||||
|
@ -2741,8 +2735,6 @@ proof * ast_manager::mk_symmetry(proof * p) {
|
|||
}
|
||||
|
||||
proof * ast_manager::mk_transitivity(proof * p1, proof * p2) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
return m_undef_proof;
|
||||
if (!p1)
|
||||
return p2;
|
||||
if (!p2)
|
||||
|
@ -2787,7 +2779,7 @@ proof * ast_manager::mk_transitivity(proof * p1, proof * p2, proof * p3, proof *
|
|||
}
|
||||
|
||||
proof * ast_manager::mk_transitivity(unsigned num_proofs, proof * const * proofs) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
if (proofs_disabled())
|
||||
return m_undef_proof;
|
||||
SASSERT(num_proofs > 0);
|
||||
proof * r = proofs[0];
|
||||
|
@ -2797,9 +2789,9 @@ proof * ast_manager::mk_transitivity(unsigned num_proofs, proof * const * proofs
|
|||
}
|
||||
|
||||
proof * ast_manager::mk_transitivity(unsigned num_proofs, proof * const * proofs, expr * n1, expr * n2) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
if (proofs_disabled())
|
||||
return m_undef_proof;
|
||||
if (fine_grain_proofs())
|
||||
if (proofs_enabled())
|
||||
return mk_transitivity(num_proofs, proofs);
|
||||
SASSERT(num_proofs > 0);
|
||||
if (num_proofs == 1)
|
||||
|
@ -2817,7 +2809,7 @@ proof * ast_manager::mk_transitivity(unsigned num_proofs, proof * const * proofs
|
|||
}
|
||||
|
||||
proof * ast_manager::mk_monotonicity(func_decl * R, app * f1, app * f2, unsigned num_proofs, proof * const * proofs) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
if (proofs_disabled())
|
||||
return m_undef_proof;
|
||||
SASSERT(f1->get_num_args() == f2->get_num_args());
|
||||
SASSERT(f1->get_decl() == f2->get_decl());
|
||||
|
@ -2828,7 +2820,7 @@ proof * ast_manager::mk_monotonicity(func_decl * R, app * f1, app * f2, unsigned
|
|||
}
|
||||
|
||||
proof * ast_manager::mk_congruence(app * f1, app * f2, unsigned num_proofs, proof * const * proofs) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
if (proofs_disabled())
|
||||
return m_undef_proof;
|
||||
SASSERT(get_sort(f1) == get_sort(f2));
|
||||
sort * s = get_sort(f1);
|
||||
|
@ -2837,7 +2829,7 @@ proof * ast_manager::mk_congruence(app * f1, app * f2, unsigned num_proofs, proo
|
|||
}
|
||||
|
||||
proof * ast_manager::mk_oeq_congruence(app * f1, app * f2, unsigned num_proofs, proof * const * proofs) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
if (proofs_disabled())
|
||||
return m_undef_proof;
|
||||
SASSERT(get_sort(f1) == get_sort(f2));
|
||||
sort * s = get_sort(f1);
|
||||
|
@ -2846,7 +2838,7 @@ proof * ast_manager::mk_oeq_congruence(app * f1, app * f2, unsigned num_proofs,
|
|||
}
|
||||
|
||||
proof * ast_manager::mk_quant_intro(quantifier * q1, quantifier * q2, proof * p) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
if (proofs_disabled())
|
||||
return m_undef_proof;
|
||||
if (!p) {
|
||||
return 0;
|
||||
|
@ -2858,7 +2850,7 @@ proof * ast_manager::mk_quant_intro(quantifier * q1, quantifier * q2, proof * p)
|
|||
}
|
||||
|
||||
proof * ast_manager::mk_oeq_quant_intro(quantifier * q1, quantifier * q2, proof * p) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
if (proofs_disabled())
|
||||
return m_undef_proof;
|
||||
SASSERT(q1->get_num_decls() == q2->get_num_decls());
|
||||
SASSERT(has_fact(p));
|
||||
|
@ -2867,25 +2859,25 @@ proof * ast_manager::mk_oeq_quant_intro(quantifier * q1, quantifier * q2, proof
|
|||
}
|
||||
|
||||
proof * ast_manager::mk_distributivity(expr * s, expr * r) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
if (proofs_disabled())
|
||||
return m_undef_proof;
|
||||
return mk_app(m_basic_family_id, PR_DISTRIBUTIVITY, mk_eq(s, r));
|
||||
}
|
||||
|
||||
proof * ast_manager::mk_rewrite(expr * s, expr * t) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
if (proofs_disabled())
|
||||
return m_undef_proof;
|
||||
return mk_app(m_basic_family_id, PR_REWRITE, mk_eq(s, t));
|
||||
}
|
||||
|
||||
proof * ast_manager::mk_oeq_rewrite(expr * s, expr * t) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
if (proofs_disabled())
|
||||
return m_undef_proof;
|
||||
return mk_app(m_basic_family_id, PR_REWRITE, mk_oeq(s, t));
|
||||
}
|
||||
|
||||
proof * ast_manager::mk_rewrite_star(expr * s, expr * t, unsigned num_proofs, proof * const * proofs) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
if (proofs_disabled())
|
||||
return m_undef_proof;
|
||||
ptr_buffer<expr> args;
|
||||
args.append(num_proofs, (expr**) proofs);
|
||||
|
@ -2894,37 +2886,37 @@ proof * ast_manager::mk_rewrite_star(expr * s, expr * t, unsigned num_proofs, pr
|
|||
}
|
||||
|
||||
proof * ast_manager::mk_pull_quant(expr * e, quantifier * q) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
if (proofs_disabled())
|
||||
return m_undef_proof;
|
||||
return mk_app(m_basic_family_id, PR_PULL_QUANT, mk_iff(e, q));
|
||||
}
|
||||
|
||||
proof * ast_manager::mk_pull_quant_star(expr * e, quantifier * q) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
if (proofs_disabled())
|
||||
return m_undef_proof;
|
||||
return mk_app(m_basic_family_id, PR_PULL_QUANT_STAR, mk_iff(e, q));
|
||||
}
|
||||
|
||||
proof * ast_manager::mk_push_quant(quantifier * q, expr * e) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
if (proofs_disabled())
|
||||
return m_undef_proof;
|
||||
return mk_app(m_basic_family_id, PR_PUSH_QUANT, mk_iff(q, e));
|
||||
}
|
||||
|
||||
proof * ast_manager::mk_elim_unused_vars(quantifier * q, expr * e) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
if (proofs_disabled())
|
||||
return m_undef_proof;
|
||||
return mk_app(m_basic_family_id, PR_ELIM_UNUSED_VARS, mk_iff(q, e));
|
||||
}
|
||||
|
||||
proof * ast_manager::mk_der(quantifier * q, expr * e) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
if (proofs_disabled())
|
||||
return m_undef_proof;
|
||||
return mk_app(m_basic_family_id, PR_DER, mk_iff(q, e));
|
||||
}
|
||||
|
||||
proof * ast_manager::mk_quant_inst(expr * not_q_or_i, unsigned num_bind, expr* const* binding) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
if (proofs_disabled())
|
||||
return m_undef_proof;
|
||||
vector<parameter> params;
|
||||
for (unsigned i = 0; i < num_bind; ++i) {
|
||||
|
@ -2959,7 +2951,7 @@ bool ast_manager::is_rewrite(expr const* e, expr*& r1, expr*& r2) const {
|
|||
}
|
||||
|
||||
proof * ast_manager::mk_def_axiom(expr * ax) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
if (proofs_disabled())
|
||||
return m_undef_proof;
|
||||
return mk_app(m_basic_family_id, PR_DEF_AXIOM, ax);
|
||||
}
|
||||
|
@ -3001,7 +2993,7 @@ proof * ast_manager::mk_unit_resolution(unsigned num_proofs, proof * const * pro
|
|||
new_lits.push_back(lit);
|
||||
}
|
||||
DEBUG_CODE({
|
||||
for (unsigned i = 1; m_proof_mode == PGM_FINE && i < num_proofs; i++) {
|
||||
for (unsigned i = 1; proofs_enabled() && i < num_proofs; i++) {
|
||||
CTRACE("mk_unit_resolution_bug", !found.get(i, false),
|
||||
for (unsigned j = 0; j < num_proofs; j++) {
|
||||
if (j == i) tout << "Index " << i << " was not found:\n";
|
||||
|
@ -3080,14 +3072,11 @@ proof * ast_manager::mk_unit_resolution(unsigned num_proofs, proof * const * pro
|
|||
}
|
||||
|
||||
proof * ast_manager::mk_hypothesis(expr * h) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
return m_undef_proof;
|
||||
return mk_app(m_basic_family_id, PR_HYPOTHESIS, h);
|
||||
}
|
||||
|
||||
proof * ast_manager::mk_lemma(proof * p, expr * lemma) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
return m_undef_proof;
|
||||
if (!p) return p;
|
||||
SASSERT(has_fact(p));
|
||||
CTRACE("mk_lemma", !is_false(get_fact(p)), tout << mk_ll_pp(p, *this) << "\n";);
|
||||
SASSERT(is_false(get_fact(p)));
|
||||
|
@ -3100,7 +3089,7 @@ proof * ast_manager::mk_def_intro(expr * new_def) {
|
|||
}
|
||||
|
||||
proof * ast_manager::mk_apply_defs(expr * n, expr * def, unsigned num_proofs, proof * const * proofs) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
if (proofs_disabled())
|
||||
return m_undef_proof;
|
||||
ptr_buffer<expr> args;
|
||||
args.append(num_proofs, (expr**) proofs);
|
||||
|
@ -3109,10 +3098,7 @@ proof * ast_manager::mk_apply_defs(expr * n, expr * def, unsigned num_proofs, pr
|
|||
}
|
||||
|
||||
proof * ast_manager::mk_iff_oeq(proof * p) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
return m_undef_proof;
|
||||
if (!p)
|
||||
return p;
|
||||
if (!p) return p;
|
||||
|
||||
SASSERT(has_fact(p));
|
||||
SASSERT(is_iff(get_fact(p)) || is_oeq(get_fact(p)));
|
||||
|
@ -3136,7 +3122,7 @@ bool ast_manager::check_nnf_proof_parents(unsigned num_proofs, proof * const * p
|
|||
}
|
||||
|
||||
proof * ast_manager::mk_nnf_pos(expr * s, expr * t, unsigned num_proofs, proof * const * proofs) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
if (proofs_disabled())
|
||||
return m_undef_proof;
|
||||
check_nnf_proof_parents(num_proofs, proofs);
|
||||
ptr_buffer<expr> args;
|
||||
|
@ -3146,7 +3132,7 @@ proof * ast_manager::mk_nnf_pos(expr * s, expr * t, unsigned num_proofs, proof *
|
|||
}
|
||||
|
||||
proof * ast_manager::mk_nnf_neg(expr * s, expr * t, unsigned num_proofs, proof * const * proofs) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
if (proofs_disabled())
|
||||
return m_undef_proof;
|
||||
check_nnf_proof_parents(num_proofs, proofs);
|
||||
ptr_buffer<expr> args;
|
||||
|
@ -3156,7 +3142,7 @@ proof * ast_manager::mk_nnf_neg(expr * s, expr * t, unsigned num_proofs, proof *
|
|||
}
|
||||
|
||||
proof * ast_manager::mk_nnf_star(expr * s, expr * t, unsigned num_proofs, proof * const * proofs) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
if (proofs_disabled())
|
||||
return m_undef_proof;
|
||||
ptr_buffer<expr> args;
|
||||
args.append(num_proofs, (expr**) proofs);
|
||||
|
@ -3165,7 +3151,7 @@ proof * ast_manager::mk_nnf_star(expr * s, expr * t, unsigned num_proofs, proof
|
|||
}
|
||||
|
||||
proof * ast_manager::mk_skolemization(expr * q, expr * e) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
if (proofs_disabled())
|
||||
return m_undef_proof;
|
||||
SASSERT(is_bool(q));
|
||||
SASSERT(is_bool(e));
|
||||
|
@ -3173,7 +3159,7 @@ proof * ast_manager::mk_skolemization(expr * q, expr * e) {
|
|||
}
|
||||
|
||||
proof * ast_manager::mk_cnf_star(expr * s, expr * t, unsigned num_proofs, proof * const * proofs) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
if (proofs_disabled())
|
||||
return m_undef_proof;
|
||||
ptr_buffer<expr> args;
|
||||
args.append(num_proofs, (expr**) proofs);
|
||||
|
@ -3182,7 +3168,7 @@ proof * ast_manager::mk_cnf_star(expr * s, expr * t, unsigned num_proofs, proof
|
|||
}
|
||||
|
||||
proof * ast_manager::mk_and_elim(proof * p, unsigned i) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
if (proofs_disabled())
|
||||
return m_undef_proof;
|
||||
SASSERT(has_fact(p));
|
||||
SASSERT(is_and(get_fact(p)));
|
||||
|
@ -3193,7 +3179,7 @@ proof * ast_manager::mk_and_elim(proof * p, unsigned i) {
|
|||
}
|
||||
|
||||
proof * ast_manager::mk_not_or_elim(proof * p, unsigned i) {
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
if (proofs_disabled())
|
||||
return m_undef_proof;
|
||||
SASSERT(has_fact(p));
|
||||
SASSERT(is_not(get_fact(p)));
|
||||
|
@ -3216,7 +3202,7 @@ proof * ast_manager::mk_th_lemma(
|
|||
unsigned num_params, parameter const* params
|
||||
)
|
||||
{
|
||||
if (m_proof_mode == PGM_DISABLED)
|
||||
if (proofs_disabled())
|
||||
return m_undef_proof;
|
||||
|
||||
ptr_buffer<expr> args;
|
||||
|
|
|
@ -1396,8 +1396,7 @@ public:
|
|||
|
||||
enum proof_gen_mode {
|
||||
PGM_DISABLED,
|
||||
PGM_COARSE,
|
||||
PGM_FINE
|
||||
PGM_ENABLED
|
||||
};
|
||||
|
||||
// -----------------------------------
|
||||
|
@ -2088,15 +2087,14 @@ protected:
|
|||
proof * mk_proof(family_id fid, decl_kind k, expr * arg1, expr * arg2);
|
||||
proof * mk_proof(family_id fid, decl_kind k, expr * arg1, expr * arg2, expr * arg3);
|
||||
|
||||
proof * mk_undef_proof() const { return m_undef_proof; }
|
||||
|
||||
public:
|
||||
bool proofs_enabled() const { return m_proof_mode != PGM_DISABLED; }
|
||||
bool proofs_disabled() const { return m_proof_mode == PGM_DISABLED; }
|
||||
bool coarse_grain_proofs() const { return m_proof_mode == PGM_COARSE; }
|
||||
bool fine_grain_proofs() const { return m_proof_mode == PGM_FINE; }
|
||||
proof_gen_mode proof_mode() const { return m_proof_mode; }
|
||||
void toggle_proof_mode(proof_gen_mode m) { m_proof_mode = m; } // APIs for creating proof objects return [undef]
|
||||
|
||||
proof * mk_undef_proof() const { return m_undef_proof; }
|
||||
|
||||
bool is_proof(expr const * n) const { return is_app(n) && to_app(n)->get_decl()->get_range() == m_proof_sort; }
|
||||
|
||||
|
|
|
@ -229,7 +229,7 @@ struct pull_quant::imp {
|
|||
proofs.push_back(m_manager.mk_pull_quant(arg, to_quantifier(new_arg)));
|
||||
}
|
||||
pull_quant1(to_app(n)->get_decl(), new_args.size(), new_args.c_ptr(), r);
|
||||
if (m_manager.fine_grain_proofs()) {
|
||||
if (m_manager.proofs_enabled()) {
|
||||
app * r1 = m_manager.mk_app(to_app(n)->get_decl(), new_args.size(), new_args.c_ptr());
|
||||
proof * p1 = proofs.empty() ? 0 : m_manager.mk_congruence(to_app(n), r1, proofs.size(), proofs.c_ptr());
|
||||
proof * p2 = r1 == r ? 0 : m_manager.mk_pull_quant(r1, to_quantifier(r));
|
||||
|
@ -240,7 +240,7 @@ struct pull_quant::imp {
|
|||
expr_ref new_expr(m_manager);
|
||||
pull_quant1(to_quantifier(n)->get_expr(), new_expr);
|
||||
pull_quant1(to_quantifier(n), new_expr, r);
|
||||
if (m_manager.fine_grain_proofs()) {
|
||||
if (m_manager.proofs_enabled()) {
|
||||
quantifier * q1 = m_manager.update_quantifier(to_quantifier(n), new_expr);
|
||||
proof * p1 = 0;
|
||||
if (n != q1) {
|
||||
|
|
|
@ -606,7 +606,7 @@ bool pattern_inference_cfg::reduce_quantifier(
|
|||
result = m.update_quantifier_weight(tmp, new_weight);
|
||||
TRACE("pattern_inference", tout << "found patterns in database, weight: " << new_weight << "\n" << mk_pp(new_q, m) << "\n";);
|
||||
}
|
||||
if (m.fine_grain_proofs())
|
||||
if (m.proofs_enabled())
|
||||
result_pr = m.mk_rewrite(q, new_q);
|
||||
return true;
|
||||
}
|
||||
|
@ -671,7 +671,7 @@ bool pattern_inference_cfg::reduce_quantifier(
|
|||
quantifier_ref new_q(m.update_quantifier(q, new_patterns.size(), (expr**) new_patterns.c_ptr(), new_body), m);
|
||||
if (weight != q->get_weight())
|
||||
new_q = m.update_quantifier_weight(new_q, weight);
|
||||
if (m.fine_grain_proofs()) {
|
||||
if (m.proofs_enabled()) {
|
||||
proof* new_body_pr = m.mk_reflexivity(new_body);
|
||||
result_pr = m.mk_quant_intro(q, new_q, new_body_pr);
|
||||
}
|
||||
|
@ -689,7 +689,7 @@ bool pattern_inference_cfg::reduce_quantifier(
|
|||
warning_msg("pulled nested quantifier to be able to find an useable pattern (quantifier id: %s)", q->get_qid().str().c_str());
|
||||
}
|
||||
new_q = m.update_quantifier(result2, new_patterns.size(), (expr**) new_patterns.c_ptr(), result2->get_expr());
|
||||
if (m.fine_grain_proofs()) {
|
||||
if (m.proofs_enabled()) {
|
||||
result_pr = m.mk_transitivity(new_pr, m.mk_quant_intro(result2, new_q, m.mk_reflexivity(new_q->get_expr())));
|
||||
}
|
||||
TRACE("pattern_inference", tout << "pulled quantifier:\n" << mk_pp(new_q, m) << "\n";);
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
|
||||
class scoped_proof : public scoped_proof_mode {
|
||||
public:
|
||||
scoped_proof(ast_manager& m): scoped_proof_mode(m, PGM_FINE) {}
|
||||
scoped_proof(ast_manager& m): scoped_proof_mode(m, PGM_ENABLED) {}
|
||||
};
|
||||
|
||||
class scoped_no_proof : public scoped_proof_mode {
|
||||
|
|
|
@ -192,7 +192,7 @@ void context_params::get_solver_params(ast_manager const & m, params_ref & p, bo
|
|||
|
||||
ast_manager * context_params::mk_ast_manager() {
|
||||
ast_manager * r = alloc(ast_manager,
|
||||
m_proof ? PGM_FINE : PGM_DISABLED,
|
||||
m_proof ? PGM_ENABLED : PGM_DISABLED,
|
||||
m_trace ? m_trace_file_name.c_str() : 0);
|
||||
if (m_smtlib2_compliant)
|
||||
r->enable_int_real_coercions(false);
|
||||
|
|
|
@ -147,7 +147,7 @@ static void compute_interpolant_and_maybe_check(cmd_context & ctx, expr * t, par
|
|||
ast_manager &_m = ctx.m();
|
||||
// TODO: the following is a HACK to enable proofs in the old smt solver
|
||||
// When we stop using that solver, this hack can be removed
|
||||
scoped_proof_mode spm(_m,PGM_FINE);
|
||||
scoped_proof_mode spm(_m,PGM_ENABLED);
|
||||
ctx.params().get_solver_params(_m, p, proofs_enabled, models_enabled, unsat_core_enabled);
|
||||
p.set_bool("proof", true);
|
||||
scoped_ptr<solver> sp = (ctx.get_interpolating_solver_factory())(_m, p, true, models_enabled, false, ctx.get_logic());
|
||||
|
|
|
@ -462,7 +462,7 @@ namespace datalog {
|
|||
|
||||
void context::flush_add_rules() {
|
||||
datalog::rule_manager& rm = get_rule_manager();
|
||||
scoped_proof_mode _scp(m, generate_proof_trace()?PGM_FINE:PGM_DISABLED);
|
||||
scoped_proof_mode _scp(m, generate_proof_trace()?PGM_ENABLED:PGM_DISABLED);
|
||||
while (m_rule_fmls_head < m_rule_fmls.size()) {
|
||||
expr* fml = m_rule_fmls[m_rule_fmls_head].get();
|
||||
proof* p = generate_proof_trace()?m.mk_asserted(fml):0;
|
||||
|
|
|
@ -141,7 +141,7 @@ namespace datalog {
|
|||
|
||||
|
||||
void rule_manager::mk_rule(expr* fml, proof* p, rule_set& rules, symbol const& name) {
|
||||
scoped_proof_mode _sc(m, m_ctx.generate_proof_trace()?PGM_FINE:PGM_DISABLED);
|
||||
scoped_proof_mode _sc(m, m_ctx.generate_proof_trace()?PGM_ENABLED:PGM_DISABLED);
|
||||
proof_ref pr(p, m);
|
||||
expr_ref fml1(m);
|
||||
bind_variables(fml, true, fml1);
|
||||
|
@ -343,7 +343,7 @@ namespace datalog {
|
|||
}
|
||||
TRACE("dl", tout << rule_expr << "\n";);
|
||||
|
||||
scoped_proof_mode _sc(m, m_ctx.generate_proof_trace()?PGM_FINE:PGM_DISABLED);
|
||||
scoped_proof_mode _sc(m, m_ctx.generate_proof_trace()?PGM_ENABLED:PGM_DISABLED);
|
||||
proof_ref pr(m);
|
||||
if (m_ctx.generate_proof_trace()) {
|
||||
pr = m.mk_asserted(rule_expr);
|
||||
|
|
|
@ -1825,7 +1825,7 @@ namespace pdr {
|
|||
m_core_generalizers.push_back(alloc(core_multi_generalizer, *this, 0));
|
||||
}
|
||||
if (!classify.is_bool()) {
|
||||
m.toggle_proof_mode(PGM_FINE);
|
||||
m.toggle_proof_mode(PGM_ENABLED);
|
||||
m_fparams.m_arith_bound_prop = BP_NONE;
|
||||
m_fparams.m_arith_auto_config_simplex = true;
|
||||
m_fparams.m_arith_propagate_eqs = false;
|
||||
|
|
|
@ -372,7 +372,7 @@ namespace pdr {
|
|||
|
||||
farkas_learner::farkas_learner(smt_params& params, ast_manager& outer_mgr)
|
||||
: m_proof_params(get_proof_params(params)),
|
||||
m_pr(PGM_FINE),
|
||||
m_pr(PGM_ENABLED),
|
||||
m_constr(0),
|
||||
m_combine_farkas_coefficients(true),
|
||||
p2o(m_pr, outer_mgr),
|
||||
|
|
|
@ -2139,7 +2139,7 @@ void context::reset_lemma_generalizers()
|
|||
void context::init_lemma_generalizers(datalog::rule_set& rules)
|
||||
{
|
||||
reset_lemma_generalizers();
|
||||
m.toggle_proof_mode(PGM_FINE);
|
||||
m.toggle_proof_mode(PGM_ENABLED);
|
||||
smt_params &fparams = m_pm.fparams ();
|
||||
if (!m_params.spacer_eq_prop ()) {
|
||||
fparams.m_arith_bound_prop = BP_NONE;
|
||||
|
|
|
@ -135,7 +135,7 @@ public:
|
|||
virtual expr * get_assumption(unsigned idx) const
|
||||
{return m_solver.get_assumption(idx);}
|
||||
virtual std::ostream &display(std::ostream &out) const
|
||||
{m_solver.display(out); return out;}
|
||||
{ return m_solver.display(out); }
|
||||
|
||||
/* check_sat_result interface */
|
||||
|
||||
|
@ -170,7 +170,7 @@ public:
|
|||
public:
|
||||
scoped_bg(itp_solver &s) : m_s(s), m_bg_sz(m_s.get_num_bg()) {}
|
||||
~scoped_bg()
|
||||
{if(m_s.get_num_bg() > m_bg_sz) { m_s.pop_bg(m_s.get_num_bg() - m_bg_sz); }}
|
||||
{if (m_s.get_num_bg() > m_bg_sz) { m_s.pop_bg(m_s.get_num_bg() - m_bg_sz); }}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -72,73 +72,67 @@ namespace spacer {
|
|||
//
|
||||
|
||||
model_evaluator_util::model_evaluator_util(ast_manager& m) :
|
||||
m(m), m_mev(NULL)
|
||||
{ reset (NULL); }
|
||||
m(m), m_mev(nullptr) {
|
||||
reset (nullptr);
|
||||
}
|
||||
|
||||
model_evaluator_util::~model_evaluator_util() {reset (NULL);}
|
||||
|
||||
|
||||
void model_evaluator_util::reset(model* model)
|
||||
{
|
||||
void model_evaluator_util::reset(model* model) {
|
||||
if (m_mev) {
|
||||
dealloc(m_mev);
|
||||
m_mev = NULL;
|
||||
}
|
||||
m_model = model;
|
||||
if (!m_model) { return; }
|
||||
if (!m_model) { return; }
|
||||
m_mev = alloc(model_evaluator, *m_model);
|
||||
}
|
||||
|
||||
bool model_evaluator_util::eval(expr *e, expr_ref &result, bool model_completion)
|
||||
{
|
||||
|
||||
bool model_evaluator_util::eval(expr *e, expr_ref &result, bool model_completion) {
|
||||
m_mev->set_model_completion (model_completion);
|
||||
try {
|
||||
m_mev->operator() (e, result);
|
||||
return true;
|
||||
} catch (model_evaluator_exception &ex) {
|
||||
}
|
||||
catch (model_evaluator_exception &ex) {
|
||||
(void)ex;
|
||||
TRACE("spacer_model_evaluator", tout << ex.msg () << "\n";);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool model_evaluator_util::eval(const expr_ref_vector &v,
|
||||
expr_ref& res, bool model_completion)
|
||||
{
|
||||
expr_ref& res, bool model_completion) {
|
||||
expr_ref e(m);
|
||||
e = mk_and (v);
|
||||
return eval(e, res, model_completion);
|
||||
}
|
||||
|
||||
|
||||
bool model_evaluator_util::is_true(const expr_ref_vector &v)
|
||||
{
|
||||
|
||||
|
||||
bool model_evaluator_util::is_true(const expr_ref_vector &v) {
|
||||
expr_ref res(m);
|
||||
return eval (v, res, false) && m.is_true (res);
|
||||
}
|
||||
|
||||
bool model_evaluator_util::is_false(expr *x)
|
||||
{
|
||||
|
||||
bool model_evaluator_util::is_false(expr *x) {
|
||||
expr_ref res(m);
|
||||
return eval(x, res, false) && m.is_false (res);
|
||||
}
|
||||
bool model_evaluator_util::is_true(expr *x)
|
||||
{
|
||||
|
||||
bool model_evaluator_util::is_true(expr *x) {
|
||||
expr_ref res(m);
|
||||
return eval(x, res, false) && m.is_true (res);
|
||||
}
|
||||
|
||||
|
||||
void reduce_disequalities(model& model, unsigned threshold, expr_ref& fml)
|
||||
{
|
||||
|
||||
void reduce_disequalities(model& model, unsigned threshold, expr_ref& fml) {
|
||||
ast_manager& m = fml.get_manager();
|
||||
expr_ref_vector conjs(m);
|
||||
flatten_and(fml, conjs);
|
||||
obj_map<expr, unsigned> diseqs;
|
||||
expr* n, *lhs, *rhs;
|
||||
for (unsigned i = 0; i < conjs.size(); ++i) {
|
||||
if (m.is_not(conjs[i].get(), n) &&
|
||||
m.is_eq(n, lhs, rhs)) {
|
||||
if (m.is_not(conjs[i].get(), n) && m.is_eq(n, lhs, rhs)) {
|
||||
if (!m.is_value(rhs)) {
|
||||
std::swap(lhs, rhs);
|
||||
}
|
||||
|
@ -157,12 +151,12 @@ void reduce_disequalities(model& model, unsigned threshold, expr_ref& fml)
|
|||
pr = m.mk_asserted(m.mk_true());
|
||||
obj_map<expr, unsigned>::iterator it = diseqs.begin();
|
||||
obj_map<expr, unsigned>::iterator end = diseqs.end();
|
||||
for (; it != end; ++it) {
|
||||
if (it->m_value >= threshold) {
|
||||
model.eval(it->m_key, val);
|
||||
sub.insert(it->m_key, val, pr);
|
||||
conjs.push_back(m.mk_eq(it->m_key, val));
|
||||
num_deleted += it->m_value;
|
||||
for (auto const& kv : diseqs) {
|
||||
if (kv.m_value >= threshold) {
|
||||
model.eval(kv.m_key, val);
|
||||
sub.insert(kv.m_key, val, pr);
|
||||
conjs.push_back(m.mk_eq(kv.m_key, val));
|
||||
num_deleted += kv.m_value;
|
||||
}
|
||||
}
|
||||
if (orig_size < conjs.size()) {
|
||||
|
@ -178,14 +172,17 @@ void reduce_disequalities(model& model, unsigned threshold, expr_ref& fml)
|
|||
SASSERT(orig_size <= 1 + conjs.size());
|
||||
if (i + 1 == orig_size) {
|
||||
// no-op.
|
||||
} else if (orig_size <= conjs.size()) {
|
||||
}
|
||||
else if (orig_size <= conjs.size()) {
|
||||
// no-op
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
SASSERT(orig_size == 1 + conjs.size());
|
||||
--orig_size;
|
||||
--i;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
conjs[i] = tmp;
|
||||
}
|
||||
}
|
||||
|
@ -202,9 +199,8 @@ void reduce_disequalities(model& model, unsigned threshold, expr_ref& fml)
|
|||
ast_manager& m;
|
||||
public:
|
||||
ite_hoister(ast_manager& m): m(m) {}
|
||||
|
||||
br_status mk_app_core(func_decl* f, unsigned num_args, expr* const* args, expr_ref& result)
|
||||
{
|
||||
|
||||
br_status mk_app_core(func_decl* f, unsigned num_args, expr* const* args, expr_ref& result) {
|
||||
if (m.is_ite(f)) {
|
||||
return BR_FAILED;
|
||||
}
|
||||
|
@ -233,13 +229,12 @@ void reduce_disequalities(model& model, unsigned threshold, expr_ref& fml)
|
|||
struct ite_hoister_cfg: public default_rewriter_cfg {
|
||||
ite_hoister m_r;
|
||||
bool rewrite_patterns() const { return false; }
|
||||
br_status reduce_app(func_decl * f, unsigned num, expr * const * args, expr_ref & result, proof_ref & result_pr)
|
||||
{
|
||||
br_status reduce_app(func_decl * f, unsigned num, expr * const * args, expr_ref & result, proof_ref & result_pr) {
|
||||
return m_r.mk_app_core(f, num, args, result);
|
||||
}
|
||||
ite_hoister_cfg(ast_manager & m, params_ref const & p):m_r(m) {}
|
||||
};
|
||||
|
||||
|
||||
class ite_hoister_star : public rewriter_tpl<ite_hoister_cfg> {
|
||||
ite_hoister_cfg m_cfg;
|
||||
public:
|
||||
|
@ -247,9 +242,8 @@ void reduce_disequalities(model& model, unsigned threshold, expr_ref& fml)
|
|||
rewriter_tpl<ite_hoister_cfg>(m, false, m_cfg),
|
||||
m_cfg(m, p) {}
|
||||
};
|
||||
|
||||
void hoist_non_bool_if(expr_ref& fml)
|
||||
{
|
||||
|
||||
void hoist_non_bool_if(expr_ref& fml) {
|
||||
ast_manager& m = fml.get_manager();
|
||||
scoped_no_proof _sp(m);
|
||||
params_ref p;
|
||||
|
@ -266,8 +260,7 @@ void hoist_non_bool_if(expr_ref& fml)
|
|||
bool m_is_dl;
|
||||
bool m_test_for_utvpi;
|
||||
|
||||
bool is_numeric(expr* e) const
|
||||
{
|
||||
bool is_numeric(expr* e) const {
|
||||
if (a.is_numeral(e)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -278,13 +271,11 @@ void hoist_non_bool_if(expr_ref& fml)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool is_arith_expr(expr *e) const
|
||||
{
|
||||
bool is_arith_expr(expr *e) const {
|
||||
return is_app(e) && a.get_family_id() == to_app(e)->get_family_id();
|
||||
}
|
||||
|
||||
bool is_offset(expr* e) const
|
||||
{
|
||||
|
||||
bool is_offset(expr* e) const {
|
||||
if (a.is_numeral(e)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -315,47 +306,44 @@ void hoist_non_bool_if(expr_ref& fml)
|
|||
return !is_arith_expr(e);
|
||||
}
|
||||
|
||||
bool is_minus_one(expr const * e) const
|
||||
{
|
||||
rational r;
|
||||
return a.is_numeral(e, r) && r.is_minus_one();
|
||||
bool is_minus_one(expr const * e) const {
|
||||
rational r;
|
||||
return a.is_numeral(e, r) && r.is_minus_one();
|
||||
}
|
||||
|
||||
bool test_ineq(expr* e) const
|
||||
{
|
||||
bool test_ineq(expr* e) const {
|
||||
SASSERT(a.is_le(e) || a.is_ge(e) || m.is_eq(e));
|
||||
SASSERT(to_app(e)->get_num_args() == 2);
|
||||
expr * lhs = to_app(e)->get_arg(0);
|
||||
expr * rhs = to_app(e)->get_arg(1);
|
||||
if (is_offset(lhs) && is_offset(rhs))
|
||||
{ return true; }
|
||||
{ return true; }
|
||||
if (!is_numeric(rhs))
|
||||
{ std::swap(lhs, rhs); }
|
||||
{ std::swap(lhs, rhs); }
|
||||
if (!is_numeric(rhs))
|
||||
{ return false; }
|
||||
{ return false; }
|
||||
// lhs can be 'x' or '(+ x (* -1 y))'
|
||||
if (is_offset(lhs))
|
||||
{ return true; }
|
||||
{ return true; }
|
||||
expr* arg1, *arg2;
|
||||
if (!a.is_add(lhs, arg1, arg2))
|
||||
{ return false; }
|
||||
{ return false; }
|
||||
// x
|
||||
if (m_test_for_utvpi) {
|
||||
return is_offset(arg1) && is_offset(arg2);
|
||||
}
|
||||
if (is_arith_expr(arg1))
|
||||
{ std::swap(arg1, arg2); }
|
||||
{ std::swap(arg1, arg2); }
|
||||
if (is_arith_expr(arg1))
|
||||
{ return false; }
|
||||
{ return false; }
|
||||
// arg2: (* -1 y)
|
||||
expr* m1, *m2;
|
||||
if (!a.is_mul(arg2, m1, m2))
|
||||
{ return false; }
|
||||
{ return false; }
|
||||
return is_minus_one(m1) && is_offset(m2);
|
||||
}
|
||||
|
||||
bool test_eq(expr* e) const
|
||||
{
|
||||
bool test_eq(expr* e) const {
|
||||
expr* lhs, *rhs;
|
||||
VERIFY(m.is_eq(e, lhs, rhs));
|
||||
if (!a.is_int_real(lhs)) {
|
||||
|
@ -370,9 +358,8 @@ void hoist_non_bool_if(expr_ref& fml)
|
|||
!a.is_mul(lhs) &&
|
||||
!a.is_mul(rhs);
|
||||
}
|
||||
|
||||
bool test_term(expr* e) const
|
||||
{
|
||||
|
||||
bool test_term(expr* e) const {
|
||||
if (m.is_bool(e)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -490,7 +477,7 @@ bool is_utvpi_logic(ast_manager& m, unsigned num_fmls, expr* const* fmls)
|
|||
* eliminate simple equalities using qe_lite
|
||||
* then, MBP for Booleans (substitute), reals (based on LW), ints (based on Cooper), and arrays
|
||||
*/
|
||||
void qe_project (ast_manager& m, app_ref_vector& vars, expr_ref& fml,
|
||||
void qe_project (ast_manager& m, app_ref_vector& vars, expr_ref& fml,
|
||||
const model_ref& M, bool reduce_all_selects, bool use_native_mbp,
|
||||
bool dont_sub)
|
||||
{
|
||||
|
|
|
@ -34,7 +34,7 @@ Revision History:
|
|||
namespace smtlib {
|
||||
|
||||
solver::solver():
|
||||
m_ast_manager(m_params.m_proof ? PGM_FINE : PGM_DISABLED,
|
||||
m_ast_manager(m_params.m_proof ? PGM_ENABLED : PGM_DISABLED,
|
||||
m_params.m_trace ? m_params.m_trace_file_name.c_str() : 0),
|
||||
m_ctx(0),
|
||||
m_error_code(0) {
|
||||
|
|
|
@ -810,8 +810,6 @@ namespace smt {
|
|||
m_new_proofs.push_back(pr);
|
||||
return pr;
|
||||
}
|
||||
if (m_manager.coarse_grain_proofs())
|
||||
return pr;
|
||||
TRACE("norm_eq_proof",
|
||||
tout << "#" << n1->get_owner_id() << " = #" << n2->get_owner_id() << "\n";
|
||||
tout << mk_ll_pp(pr, m_manager, true, false););
|
||||
|
@ -1217,7 +1215,7 @@ namespace smt {
|
|||
mk_proof(rhs, c, prs2);
|
||||
while (!prs2.empty()) {
|
||||
proof * pr = prs2.back();
|
||||
if (m_manager.fine_grain_proofs()) {
|
||||
if (m_manager.proofs_enabled()) {
|
||||
pr = m_manager.mk_symmetry(pr);
|
||||
m_new_proofs.push_back(pr);
|
||||
prs1.push_back(pr);
|
||||
|
|
|
@ -129,7 +129,7 @@ namespace smt {
|
|||
|
||||
if (m_node1 != m_node1->get_root()) {
|
||||
proof * pr = cr.get_proof(m_node1, m_node1->get_root());
|
||||
if (pr && m.fine_grain_proofs())
|
||||
if (pr && m.proofs_enabled())
|
||||
pr = m.mk_symmetry(pr);
|
||||
prs.push_back(pr);
|
||||
if (!pr)
|
||||
|
|
Loading…
Reference in a new issue