mirror of
https://github.com/Z3Prover/z3
synced 2025-04-24 01:25:31 +00:00
fix bug in new core not detecting conflict, fix #6525, add tactic doc
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
feda706d0d
commit
4f7f4376b8
14 changed files with 175 additions and 26 deletions
|
@ -124,6 +124,19 @@ namespace arith {
|
|||
return m_arith_hint.mk(ctx);
|
||||
}
|
||||
|
||||
arith_proof_hint const* solver::explain_conflict(sat::literal_vector const& core, euf::enode_pair_vector const& eqs) {
|
||||
arith_proof_hint* hint = nullptr;
|
||||
if (ctx.use_drat()) {
|
||||
m_arith_hint.set_type(ctx, hint_type::farkas_h);
|
||||
for (auto lit : core)
|
||||
m_arith_hint.add_lit(rational::one(), lit);
|
||||
for (auto const& [a,b] : eqs)
|
||||
m_arith_hint.add_eq(a, b);
|
||||
hint = m_arith_hint.mk(ctx);
|
||||
}
|
||||
return hint;
|
||||
}
|
||||
|
||||
arith_proof_hint const* solver::explain_implied_eq(lp::explanation const& e, euf::enode* a, euf::enode* b) {
|
||||
if (!ctx.use_drat())
|
||||
return nullptr;
|
||||
|
|
|
@ -1196,26 +1196,31 @@ namespace arith {
|
|||
void solver::set_conflict_or_lemma(literal_vector const& core, bool is_conflict) {
|
||||
reset_evidence();
|
||||
m_core.append(core);
|
||||
|
||||
++m_num_conflicts;
|
||||
++m_stats.m_conflicts;
|
||||
for (auto ev : m_explanation)
|
||||
set_evidence(ev.ci());
|
||||
|
||||
TRACE("arith",
|
||||
tout << "Lemma - " << (is_conflict ? "conflict" : "propagation") << "\n";
|
||||
for (literal c : m_core) tout << literal2expr(c) << "\n";
|
||||
for (auto p : m_eqs) tout << ctx.bpp(p.first) << " == " << ctx.bpp(p.second) << "\n";);
|
||||
DEBUG_CODE(
|
||||
if (is_conflict) {
|
||||
for (literal c : m_core) VERIFY(s().value(c) == l_true);
|
||||
for (auto p : m_eqs) VERIFY(p.first->get_root() == p.second->get_root());
|
||||
});
|
||||
for (auto const& eq : m_eqs)
|
||||
m_core.push_back(ctx.mk_literal(m.mk_eq(eq.first->get_expr(), eq.second->get_expr())));
|
||||
for (literal& c : m_core)
|
||||
c.neg();
|
||||
|
||||
add_redundant(m_core, explain(hint_type::farkas_h));
|
||||
if (is_conflict) {
|
||||
DEBUG_CODE(
|
||||
for (literal c : m_core) VERIFY(s().value(c) == l_true);
|
||||
for (auto p : m_eqs) VERIFY(p.first->get_root() == p.second->get_root()));
|
||||
++m_num_conflicts;
|
||||
++m_stats.m_conflicts;
|
||||
auto* hint = explain_conflict(m_core, m_eqs);
|
||||
ctx.set_conflict(euf::th_explain::conflict(*this, m_core, m_eqs, hint));
|
||||
}
|
||||
else {
|
||||
for (auto const& eq : m_eqs)
|
||||
m_core.push_back(ctx.mk_literal(m.mk_eq(eq.first->get_expr(), eq.second->get_expr())));
|
||||
for (literal& c : m_core)
|
||||
c.neg();
|
||||
|
||||
add_redundant(m_core, explain(hint_type::farkas_h));
|
||||
}
|
||||
}
|
||||
|
||||
bool solver::is_infeasible() const {
|
||||
|
|
|
@ -478,6 +478,7 @@ namespace arith {
|
|||
arith_proof_hint const* explain(hint_type ty, sat::literal lit = sat::null_literal);
|
||||
arith_proof_hint const* explain_implied_eq(lp::explanation const& e, euf::enode* a, euf::enode* b);
|
||||
arith_proof_hint const* explain_trichotomy(sat::literal le, sat::literal ge, sat::literal eq);
|
||||
arith_proof_hint const* explain_conflict(sat::literal_vector const& core, euf::enode_pair_vector const& eqs);
|
||||
void explain_assumptions(lp::explanation const& e);
|
||||
|
||||
|
||||
|
|
|
@ -13,7 +13,36 @@ Author:
|
|||
|
||||
Leonardo (leonardo) 2011-10-26
|
||||
|
||||
Notes:
|
||||
Tactic Documentation:
|
||||
|
||||
## Tactic sat
|
||||
|
||||
### Short Description
|
||||
|
||||
Try to solve goal using a SAT solver
|
||||
|
||||
## Tactic sat-preprocess
|
||||
|
||||
### Short Description
|
||||
|
||||
Apply SAT solver preprocessing procedures (bounded resolution, Boolean constant propagation, 2-SAT, subsumption, subsumption resolution).
|
||||
|
||||
### Example
|
||||
|
||||
```z3
|
||||
(declare-const a Bool)
|
||||
(declare-const b Bool)
|
||||
(declare-const c Bool)
|
||||
(declare-const d Bool)
|
||||
(declare-const e Bool)
|
||||
(declare-const f Bool)
|
||||
(declare-fun p (Bool) Bool)
|
||||
(assert (=> a b))
|
||||
(assert (=> b c))
|
||||
(assert a)
|
||||
(assert (not c))
|
||||
(apply sat-preprocess)
|
||||
```
|
||||
|
||||
--*/
|
||||
#pragma once
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue