Can I replay a proof in Z3?

社会主义新天地 提交于 2021-01-28 01:39:12

问题


Is it possible to have Z3 serialise a proof for some assertion, and replay the proof on later invocations instead of running a proof-search again? I know Z3 can output counter-examples for unsat, but can it provide proofs for models that are sat?


回答1:


Terminology note: Z3 (and SAT/SMT solvers in general) output models for sat, and proofs for unsat.

Proof generation is actually an SMT-Lib feature. See page 56 of http://smtlib.cs.uiowa.edu/papers/smt-lib-reference-v2.6-r2017-07-18.pdf

And Z3 indeed supports it, here's the simplest example:

(set-option :produce-proofs true)
(declare-fun a () Bool)
(assert (= a (not a)))
(check-sat)
(get-proof)

Z3 says:

unsat
((proof
(mp (asserted (= a (not a))) (rewrite (= (= a (not a)) false)) false)))

The format is solver-specific. The SMTLib document says:

(get-proof) asks the solver for a proof of unsatisfiability for the set of all formulas in the current context. The command can be issued only if the most recent check command had an empty set of assumptions. The solver responds by printing a refutation proof on its regular output channel. The format of the proof is solver-specific. The only requirement is that, like all responses, it be a member of s_expr.

So far as I know there's no "public" switch to tell Z3 to read this proof back and do anything with it. It wouldn't surprise me, however, that they might have internal tools to consume this output.

Replaying in a theorem prover

Isabelle theorem prover can read Z3's proofs back and replay them internally to construct the corresponding proof. This is probably closer to what you are looking for. Here's a paper that describes this work: http://www21.in.tum.de/~boehmes/proofrec.pdf Of course, precisely which logics are supported and whether the connection is actively maintained is a different question! You might find the "related work" section of that paper quite helpful.



来源:https://stackoverflow.com/questions/49874498/can-i-replay-a-proof-in-z3

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!