mirror of
https://github.com/Z3Prover/z3
synced 2025-04-28 03:15:50 +00:00
tseitin rule checking - wip
Unit test ``` (set-option :sat.euf true) (set-option :sat.smt.proof tseitinproof.smt2) (declare-const a1 Bool) (declare-const a2 Bool) (declare-const a3 Bool) (declare-const a4 Bool) (declare-const a5 Bool) (declare-const a6 Bool) (declare-const a7 Bool) (declare-const a8 Bool) (declare-const a9 Bool) (declare-const a10 Bool) (declare-const a11 Bool) (declare-const a12 Bool) (declare-const a13 Bool) (declare-const a14 Bool) (declare-const a15 Bool) (declare-const a16 Bool) (declare-const a17 Bool) (declare-const a18 Bool) (declare-const a19 Bool) (declare-const x1 Bool) (declare-const x2 Bool) (declare-const x3 Bool) (declare-const x4 Bool) (declare-const x5 Bool) (declare-const x6 Bool) (declare-const x7 Bool) (declare-const x8 Bool) (declare-const x9 Bool) (assert (= x1 (and a1 a2))) (assert (= x2 (or a3 a4))) (assert (= x3 (=> a5 a6))) (assert (= x4 (= a7 a8))) (assert (= x5 (if a9 a10 a11))) (assert (= x6 (=> a12 a13))) (check-sat) ``` Output proof ``` (declare-fun a1 () Bool) (declare-fun a2 () Bool) (define-const $26 Bool (and a1 a2)) (declare-fun tseitin (Bool Bool) Proof) (define-const $60 Bool (not $26)) (define-const $61 Proof (tseitin $60 a1)) (infer a1 (not $26) $61) (define-const $62 Proof (tseitin $60 a2)) (infer a2 (not $26) $62) (declare-fun tseitin (Bool Bool Bool) Proof) (define-const $64 Bool (not a2)) (define-const $63 Bool (not a1)) (define-const $65 Proof (tseitin $63 $64 $26)) (infer (not a1) (not a2) $26 $65) (declare-fun x1 () Bool) (assume (not x1) $26) (assume x1 (not $26)) (declare-fun a3 () Bool) (declare-fun a4 () Bool) (define-const $31 Bool (or a3 a4)) (define-const $66 Bool (not a3)) (define-const $67 Proof (tseitin $66 $31)) (infer (not a3) $31 $67) (define-const $68 Bool (not a4)) (define-const $69 Proof (tseitin $68 $31)) (infer (not a4) $31 $69) (define-const $70 Bool (not $31)) (define-const $71 Proof (tseitin a3 a4 $70)) (infer a3 a4 (not $31) $71) (declare-fun x2 () Bool) (assume (not x2) $31) (assume x2 (not $31)) (declare-fun a6 () Bool) (declare-fun a5 () Bool) (define-const $38 Bool (not a5)) (define-const $39 Bool (or a6 $38)) (define-const $72 Bool (not a6)) (define-const $73 Proof (tseitin $72 $39)) (infer (not a6) $39 $73) (define-const $74 Proof (tseitin a5 $39)) (infer a5 $39 $74) (define-const $75 Bool (not $39)) (define-const $76 Proof (tseitin a6 $38 $75)) (infer a6 (not a5) (not $39) $76) (declare-fun x3 () Bool) (assume (not x3) $39) (assume x3 (not $39)) (declare-fun a7 () Bool) (declare-fun a8 () Bool) (define-const $44 Bool (= a7 a8)) (define-const $78 Bool (not a7)) (define-const $77 Bool (not $44)) (define-const $79 Proof (tseitin $77 a8 $78)) (infer (not a7) a8 (not $44) $79) (define-const $80 Bool (not a8)) (define-const $81 Proof (tseitin $77 $80 a7)) (infer a7 (not a8) (not $44) $81) (define-const $82 Proof (tseitin $44 a8 a7)) (infer a7 a8 $44 $82) (define-const $83 Proof (tseitin $44 $80 $78)) (infer (not a7) (not a8) $44 $83) (declare-fun x4 () Bool) (assume (not x4) $44) (assume x4 (not $44)) (declare-fun a9 () Bool) (declare-fun a10 () Bool) (declare-fun a11 () Bool) (define-const $50 Bool (ite a9 a10 a11)) (define-const $85 Bool (not a9)) (define-const $84 Bool (not $50)) (define-const $86 Proof (tseitin $84 $85 a10)) (infer (not a9) a10 (not $50) $86) (define-const $87 Proof (tseitin $84 a9 a11)) (infer a9 a11 (not $50) $87) (define-const $88 Bool (not a10)) (define-const $89 Proof (tseitin $50 $85 $88)) (infer (not a9) (not a10) $50 $89) (define-const $90 Bool (not a11)) (define-const $91 Proof (tseitin $50 a9 $90)) (infer a9 (not a11) $50 $91) (define-const $92 Proof (tseitin $88 $90 $50)) (infer (not a10) (not a11) $50 $92) (define-const $93 Proof (tseitin a10 a11 $84)) (infer a10 a11 (not $50) $93) (declare-fun x5 () Bool) (assume (not x5) $50) (assume x5 (not $50)) (declare-fun a13 () Bool) (declare-fun a12 () Bool) (define-const $57 Bool (not a12)) (define-const $58 Bool (or a13 $57)) (define-const $94 Bool (not a13)) (define-const $95 Proof (tseitin $94 $58)) (infer (not a13) $58 $95) (define-const $96 Proof (tseitin a12 $58)) (infer a12 $58 $96) (define-const $97 Bool (not $58)) (define-const $98 Proof (tseitin a13 $57 $97)) (infer a13 (not a12) (not $58) $98) (declare-fun x6 () Bool) (assume (not x6) $58) (assume x6 (not $58)) ```
This commit is contained in:
parent
fceedf60dc
commit
cd8b8b603a
3 changed files with 131 additions and 28 deletions
|
@ -124,6 +124,14 @@ struct goal2sat::imp : public sat::sat_internalizer {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
euf::th_proof_hint* mk_tseitin(sat::literal a, sat::literal b, sat::literal c) {
|
||||
if (m_euf && ensure_euf()->use_drat()) {
|
||||
sat::literal lits[3] = { a, b, c };
|
||||
return ensure_euf()->mk_smt_hint(m_tseitin, 3, lits);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sat::status mk_status(euf::th_proof_hint* ph = nullptr) const {
|
||||
return sat::status::th(m_is_redundant, m.get_basic_family_id(), ph);
|
||||
}
|
||||
|
@ -522,13 +530,13 @@ struct goal2sat::imp : public sat::sat_internalizer {
|
|||
sat::bool_var k = add_var(false, n);
|
||||
sat::literal l(k, false);
|
||||
cache(n, l);
|
||||
mk_clause(~l, ~c, t);
|
||||
mk_clause(~l, c, e);
|
||||
mk_clause(l, ~c, ~t);
|
||||
mk_clause(l, c, ~e);
|
||||
mk_clause(~l, ~c, t, mk_tseitin(~l, ~c, t));
|
||||
mk_clause(~l, c, e, mk_tseitin(~l, c, e));
|
||||
mk_clause(l, ~c, ~t, mk_tseitin(l, ~c, ~t));
|
||||
mk_clause(l, c, ~e, mk_tseitin(l, c, ~e));
|
||||
if (m_ite_extra) {
|
||||
mk_clause(~t, ~e, l);
|
||||
mk_clause(t, e, ~l);
|
||||
mk_clause(~t, ~e, l, mk_tseitin(~t, ~e, l));
|
||||
mk_clause(t, e, ~l, mk_tseitin(t, e, ~l));
|
||||
}
|
||||
if (aig()) aig()->add_ite(l, c, t, e);
|
||||
if (sign)
|
||||
|
@ -555,8 +563,8 @@ struct goal2sat::imp : public sat::sat_internalizer {
|
|||
sat::literal l(k, false);
|
||||
cache(t, l);
|
||||
// l <=> ~lit
|
||||
mk_clause(lit, l);
|
||||
mk_clause(~lit, ~l);
|
||||
mk_clause(lit, l, mk_tseitin(lit, l));
|
||||
mk_clause(~lit, ~l, mk_tseitin(~lit, ~l));
|
||||
if (sign)
|
||||
l.neg();
|
||||
m_result_stack.push_back(l);
|
||||
|
@ -587,9 +595,9 @@ struct goal2sat::imp : public sat::sat_internalizer {
|
|||
sat::literal l(k, false);
|
||||
cache(t, l);
|
||||
// l <=> (l1 => l2)
|
||||
mk_clause(~l, ~l1, l2);
|
||||
mk_clause(l1, l);
|
||||
mk_clause(~l2, l);
|
||||
mk_clause(~l, ~l1, l2, mk_tseitin(~l, ~l1, l2));
|
||||
mk_clause(l1, l, mk_tseitin(l1, l));
|
||||
mk_clause(~l2, l, mk_tseitin(~l2, l));
|
||||
if (sign)
|
||||
l.neg();
|
||||
m_result_stack.push_back(l);
|
||||
|
@ -625,10 +633,10 @@ struct goal2sat::imp : public sat::sat_internalizer {
|
|||
sat::literal l(k, false);
|
||||
if (m.is_xor(t))
|
||||
l1.neg();
|
||||
mk_clause(~l, l1, ~l2);
|
||||
mk_clause(~l, ~l1, l2);
|
||||
mk_clause(l, l1, l2);
|
||||
mk_clause(l, ~l1, ~l2);
|
||||
mk_clause(~l, l1, ~l2, mk_tseitin(~l, l1, ~l2));
|
||||
mk_clause(~l, ~l1, l2, mk_tseitin(~l, ~l1, l2));
|
||||
mk_clause(l, l1, l2, mk_tseitin(l, l1, l2));
|
||||
mk_clause(l, ~l1, ~l2, mk_tseitin(l, ~l1, ~l2));
|
||||
if (aig()) aig()->add_iff(l, l1, l2);
|
||||
|
||||
cache(t, l);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue