如何在Z3&#x27的SMT2语法中使用策略?

发布于 2025-02-06 23:24:06 字数 363 浏览 1 评论 0 原文

我通过其SMT2接口与Z3进行交互。假设,我写下了以下命令:

(declare-fun p () Int)
(declare-fun q () Int)
(declare-fun r () Int)

(assert (and (<= (+ (* 4 p) (* 3 q)) (- r 10)) (<= (+ (* 4 p) (* 3 q)) (- r 12))))

(apply simplify)

现在,我在形式中获得了一个目标列表,

(goals
(goal …)
(goal …)
…
)

该怎么办?

另一个问题,有什么文件吗?我应该在哪里寻找它?

I am interacting with z3 through its smt2 interface. Suppose, I write the following commands:

(declare-fun p () Int)
(declare-fun q () Int)
(declare-fun r () Int)

(assert (and (<= (+ (* 4 p) (* 3 q)) (- r 10)) (<= (+ (* 4 p) (* 3 q)) (- r 12))))

(apply simplify)

Now, I get a list of goals in the form

(goals
(goal …)
(goal …)
…
)

What do I do with it?

Another question, is there any documentation on this? Where should I look for it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光礼记 2025-02-13 23:24:06

战术是Z3发明;因此,您将找不到有关如何从Smtlib角度使用它们的任何正式文档。

通常,您不仅使用应用。相反,您使用方法 check-sat-using ,将战术作为参数。通常, check-sat 使用(使用smt),即使用 smt tactic。

就您的示例而言,您可以说:

(check-sat-using (then simplify smt))

这将使问题降低到 SAT 。这个想法是,您可以使用这些“策略”来指导求解器找到解决方案(或更快)。

策略通常旨在从C/C ++/Java等高级接口中使用,不幸的是,它们的记录并不那么充分。通过

策略也记录在,尽管它再次使用python接口而不是smtlib。

Tactics are a z3 invention; so you will not find any official documentation on how they should be used from an SMTLib perspective.

In general, you don't just use apply. Instead, you use the method check-sat-using, that takes a tactic as an argument. In general, check-sat is equivalent to (check-sat-using smt), i.e., using the smt tactic.

For your example, you can say:

(check-sat-using (then simplify smt))

this would reduce the problem to sat. The idea is that you can use these "tactics" to guide the solver to find a solution (or go faster).

Tactics are usually intended to be used from higher-level interfaces, such as C/C++/Java etc., and unfortunately they aren't all that well documented. Read through http://www.cs.tau.ac.il/~msagiv/courses/asv/z3py/strategies-examples.htm, which is using the Python interface, but you can use the same ideas directly from smtLib as well.

Tactics are also documented at https://theory.stanford.edu/~nikolaj/programmingz3.html#sec-tactics, though again it uses the Python interface not SMTLib.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文