mirror of
https://github.com/Z3Prover/z3
synced 2025-04-22 16:45:31 +00:00
add examples with proof replay
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
88d10f7fe4
commit
f6595c161f
9 changed files with 166 additions and 5 deletions
|
@ -931,6 +931,14 @@ extern "C" {
|
|||
on_clause_eh(user_ctx, of_expr(pr.get()), of_ast_vector(literals));
|
||||
};
|
||||
to_solver_ref(s)->register_on_clause(user_context, _on_clause);
|
||||
auto& solver = *to_solver(s);
|
||||
|
||||
if (!solver.m_cmd_context) {
|
||||
solver.m_cmd_context = alloc(cmd_context, false, &(mk_c(c)->m()));
|
||||
install_proof_cmds(*solver.m_cmd_context);
|
||||
init_proof_cmds(*solver.m_cmd_context);
|
||||
}
|
||||
solver.m_cmd_context->get_proof_cmds()->register_on_clause(user_context, _on_clause);
|
||||
Z3_CATCH;
|
||||
}
|
||||
|
||||
|
|
|
@ -99,6 +99,7 @@ public:
|
|||
virtual void end_infer() = 0;
|
||||
virtual void end_deleted() = 0;
|
||||
virtual void updt_params(params_ref const& p) = 0;
|
||||
virtual void register_on_clause(void* ctx, user_propagator::on_clause_eh_t& on_clause) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -227,13 +227,34 @@ class proof_cmds_imp : public proof_cmds {
|
|||
scoped_ptr<euf::smt_proof_checker> m_checker;
|
||||
scoped_ptr<proof_saver> m_saver;
|
||||
scoped_ptr<proof_trim> m_trimmer;
|
||||
user_propagator::on_clause_eh_t m_on_clause_eh;
|
||||
void* m_on_clause_ctx = nullptr;
|
||||
expr_ref m_assumption, m_del;
|
||||
|
||||
euf::smt_proof_checker& checker() { params_ref p; if (!m_checker) m_checker = alloc(euf::smt_proof_checker, m, p); return *m_checker; }
|
||||
proof_saver& saver() { if (!m_saver) m_saver = alloc(proof_saver, ctx); return *m_saver; }
|
||||
proof_trim& trim() { if (!m_trimmer) m_trimmer = alloc(proof_trim, ctx); return *m_trimmer; }
|
||||
|
||||
expr_ref assumption() {
|
||||
if (!m_assumption)
|
||||
m_assumption = m.mk_app(symbol("assumption"), 0, nullptr, m.mk_proof_sort());
|
||||
return m_assumption;
|
||||
}
|
||||
|
||||
expr_ref del() {
|
||||
if (!m_del)
|
||||
m_del = m.mk_app(symbol("del"), 0, nullptr, m.mk_proof_sort());
|
||||
return m_del;
|
||||
}
|
||||
|
||||
public:
|
||||
proof_cmds_imp(cmd_context& ctx): ctx(ctx), m(ctx.m()), m_lits(m), m_proof_hint(m) {
|
||||
proof_cmds_imp(cmd_context& ctx):
|
||||
ctx(ctx),
|
||||
m(ctx.m()),
|
||||
m_lits(m),
|
||||
m_proof_hint(m),
|
||||
m_assumption(m),
|
||||
m_del(m) {
|
||||
updt_params(gparams::get_module("solver"));
|
||||
}
|
||||
|
||||
|
@ -251,6 +272,8 @@ public:
|
|||
saver().assume(m_lits);
|
||||
if (m_trim)
|
||||
trim().assume(m_lits);
|
||||
if (m_on_clause_eh)
|
||||
m_on_clause_eh(m_on_clause_ctx, assumption(), m_lits.size(), m_lits.data());
|
||||
m_lits.reset();
|
||||
m_proof_hint.reset();
|
||||
}
|
||||
|
@ -262,6 +285,8 @@ public:
|
|||
saver().infer(m_lits, m_proof_hint);
|
||||
if (m_trim)
|
||||
trim().infer(m_lits, m_proof_hint);
|
||||
if (m_on_clause_eh)
|
||||
m_on_clause_eh(m_on_clause_ctx, m_proof_hint, m_lits.size(), m_lits.data());
|
||||
m_lits.reset();
|
||||
m_proof_hint.reset();
|
||||
}
|
||||
|
@ -273,6 +298,8 @@ public:
|
|||
saver().del(m_lits);
|
||||
if (m_trim)
|
||||
trim().del(m_lits);
|
||||
if (m_on_clause_eh)
|
||||
m_on_clause_eh(m_on_clause_ctx, del(), m_lits.size(), m_lits.data());
|
||||
m_lits.reset();
|
||||
m_proof_hint.reset();
|
||||
}
|
||||
|
@ -285,6 +312,12 @@ public:
|
|||
if (m_trim)
|
||||
trim().updt_params(p);
|
||||
}
|
||||
|
||||
void register_on_clause(void* ctx, user_propagator::on_clause_eh_t& on_clause_eh) override {
|
||||
m_on_clause_ctx = ctx;
|
||||
m_on_clause_eh = on_clause_eh;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -344,3 +377,7 @@ void install_proof_cmds(cmd_context & ctx) {
|
|||
ctx.insert(alloc(infer_cmd));
|
||||
ctx.insert(alloc(assume_cmd));
|
||||
}
|
||||
|
||||
void init_proof_cmds(cmd_context& ctx) {
|
||||
get(ctx);
|
||||
}
|
||||
|
|
|
@ -33,4 +33,4 @@ Notes:
|
|||
|
||||
class cmd_context;
|
||||
void install_proof_cmds(cmd_context & ctx);
|
||||
|
||||
void init_proof_cmds(cmd_context& ctx);
|
||||
|
|
|
@ -200,8 +200,9 @@ namespace sat {
|
|||
m_smt_proof = p.smt_proof();
|
||||
m_smt_proof_check = p.smt_proof_check();
|
||||
m_smt_proof_check_rup = p.smt_proof_check_rup();
|
||||
m_drat_disable = p.drat_disable();
|
||||
m_drat =
|
||||
!p.drat_disable() && p.threads() == 1 &&
|
||||
!m_drat_disable && p.threads() == 1 &&
|
||||
(sp.lemmas2console() ||
|
||||
m_drat_check_unsat ||
|
||||
m_drat_file.is_non_empty_string() ||
|
||||
|
|
|
@ -175,6 +175,7 @@ namespace sat {
|
|||
|
||||
// drat proofs
|
||||
bool m_drat;
|
||||
bool m_drat_disable;
|
||||
bool m_drat_binary;
|
||||
symbol m_drat_file;
|
||||
symbol m_smt_proof;
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace euf {
|
|||
if (m_proof_initialized)
|
||||
return;
|
||||
|
||||
if (m_on_clause)
|
||||
if (m_on_clause && !s().get_config().m_drat_disable)
|
||||
s().set_drat(true);
|
||||
|
||||
if (!s().get_config().m_drat)
|
||||
|
@ -39,7 +39,6 @@ namespace euf {
|
|||
|
||||
get_drat().add_theory(get_id(), symbol("euf"));
|
||||
get_drat().add_theory(m.get_basic_family_id(), symbol("bool"));
|
||||
|
||||
if (s().get_config().m_smt_proof.is_non_empty_string())
|
||||
m_proof_out = alloc(std::ofstream, s().get_config().m_smt_proof.str(), std::ios_base::out);
|
||||
get_drat().set_clause_eh(*this);
|
||||
|
|
|
@ -372,6 +372,7 @@ namespace euf {
|
|||
void smt_theory_checker_plugin::register_plugins(theory_checker& pc) {
|
||||
pc.register_plugin(symbol("datatype"), this);
|
||||
pc.register_plugin(symbol("array"), this);
|
||||
pc.register_plugin(symbol("quant"), this);
|
||||
pc.register_plugin(symbol("fpa"), this);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue