了解Z3在量化的LIA公式上的低性能

发布于 2025-02-04 02:59:54 字数 415 浏览 2 评论 0 原文

我遇到了以下公式,该公式需要Z3几分钟才能解决:

(set-logic LIA)
(assert
    (forall ((f Int))
        (exists ((a Int) (b Int))
            (= (+ (* 17 a) (* 19 b)) f)
        )
    )
)

(check-sat)
(exit)

我已经阅读了记录Z3用来决定LIA的方法,但是,我看不出Z3为何在给定公式中挣扎。你能解释一下吗?

I have come across the following formula that takes Z3 several minutes to solve:

(set-logic LIA)
(assert
    (forall ((f Int))
        (exists ((a Int) (b Int))
            (= (+ (* 17 a) (* 19 b)) f)
        )
    )
)

(check-sat)
(exit)

I have read the paper documenting the approach Z3 uses to decide LIA, however, I fail to see why does Z3 struggles with the given formula. Could you please explain?

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

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

发布评论

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

评论(1

南巷近海 2025-02-11 02:59:54

量词很难,嵌套的量词更难。在任何给定的SMT溶剂中,内部发生了什么,真的很难猜测。很遗憾。除非您投资研究其内部设备,否则它们是或多或少的黑盒子。关于所使用技术的一本好书是Kroening和Strichman的决策程序 。您可能需要阅读该书,其中还包含进一步的参考。

请注意,当SMT求解器“试图找到模型”而不是试图证明事物时,他们会做得更好,因此通常会要求否定定理要满足。然后取消结果表明理论。将此翻译成您的问题,一个人会得到:

(set-logic LIA)
(declare-fun f () Int)
(assert
  (forall ((a Int) (b Int))
      (distinct (+ (* 17 a) (* 19 b)) f)
  )
)

(check-sat)
(exit)

不幸的是,Z3在此形式上花费更长的时间;这让我感到惊讶。 (我已经期望至少相同的性能。)但是 yices 立即解决! (为了进行比较,CVC5似乎也永远在上面运行,谁知道原因。)因此,如果您遇到这种问题,您可能想尝试YICES。

Yices在此方面表现良好的事实,而Z3并不意味着Z3可能缺少某些启发式,或者是Yices拥有的重写。您可能需要在。不是作为错误,而是作为好奇心,为什么YICES表现更好。我敢肯定,即使开发人员选择不做任何使Z3在此问题上更快的事情,他们也会很高兴听到有关此问题的消息。

Quantifiers are hard, nested quantifiers are harder. It's really hard to guess what's going on internally in any given SMT-solver; unfortunately. They are more-or-less black-boxes, unless you invest in studying their internals. A good book on the techniques used is Kroening and Strichman's Decision Procedures, which has an entire chapter on linear arithmetic. You might want to read through that book, which also contains further references.

Note that SMT solvers do better when they "try to find a model" instead of trying to prove things, so one usually asks the negation of a theorem to be satisfied instead. An unsat result then indicates theoremhood. Doing this translation to your problem, one gets:

(set-logic LIA)
(declare-fun f () Int)
(assert
  (forall ((a Int) (b Int))
      (distinct (+ (* 17 a) (* 19 b)) f)
  )
)

(check-sat)
(exit)

Unfortunately, z3 takes even longer on this form; which surprised me. (I'd have expected at least the same performance.) But yices solves it instantly! (For comparison, CVC5 seems to run forever on it as well, who knows why.) So, you might want to try yices instead if you have problems of this sort.

The fact that yices does well on this while z3 doesn't suggests perhaps z3 is missing some heuristic, or a rewrite that yices has. You might want to report this discrepancy at https://github.com/Z3Prover/z3/issues. Not as a bug, but rather as a curiosity why yices performs much better. I'm sure the developers would appreciate hearing about it, even if they choose not to do anything to make z3 go faster on this problem.

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