简体   繁体   English

来自 Z3 的 Unsat 核心(版本 4)

[英]Unsat core from Z3 (version 4)

I have been using Ocaml API of Z3 version 4.0 for the last year or so, mainly the bitvector theory.我最近一年左右一直在使用Z3 4.0版本的Ocaml API,主要是bitvector理论。 Now I need to extract unsat cores after doing a Z3.solver_check and unfortunately version 4 doesn't have this ability.现在我需要在执行 Z3.solver_check 后提取 unsat 核心,不幸的是版本 4 没有这种能力。 I can do a rewrite to use assumptions to stand for each bitvector equation in the formula and then get the unsat core but this being critical part of the code, it might affect the overall performance.我可以重写以使用假设来代表公式中的每个位向量方程,然后获得 unsat 核心,但这是代码的关键部分,它可能会影响整体性能。

Is there a way of get unsat core without going through assumptions for version 4?有没有办法在不经过版本 4 的假设的情况下获得 unsat 核心? The long term solution is of course to move to latest version but if there is a less disruptive solution that would be nice.长期解决方案当然是迁移到最新版本,但如果有一个破坏性较小的解决方案,那就太好了。 For instance, is there a way to extract unsat core from the proof of unsat (returned by Z3.solver_get_proof)?例如,有没有办法从 unsat 的证明中提取 unsat 核心(由 Z3.solver_get_proof 返回)?

Thanks!谢谢!

If you use the assert_and_track function from the Solver module, then get_unsat_core, also in the Solver module, returns the set of tracking literals corresponding to the tracked assertions.如果您使用 Solver 模块中的 assert_and_track 函数,那么同样在 Solver 模块中的 get_unsat_core 将返回与跟踪断言相对应的跟踪文字集。 There is an example of using assert_and_track for the C# API in the method UnsatCoreAndProofExample2, and also in Java ( https://github.com/Z3Prover/z3/blob/master/examples/java/JavaExample.java ).有一个在方法 UnsatCoreAndProofExample2 和 Java ( https://github.com/Z3Prover/z3/blob/master/examples/java/JavaExample.java ) 中为 C# API 使用 assert_and_track 的示例。 There is no corresponding example in the ML sample, but translation to OCaml should not be too complicated. ML示例中没有对应的例子,但是翻译成OCaml应该不会太复杂。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM