一起使用浮点数和实数时 z3 返回未知?
由于我在同一个 .smt2 文件中使用浮点数和实数,我注意到这通常会导致结果“未知”。我在此处看到了这一点,但自这个答案以来已经过去了一段时间,我想询问我是否可能根本没有使用正确的设置(例如,我是否应该在 check-sat 行中传递策略作为参数?或者缩小设置逻辑范围?)
这是一个展示该行为的示例:
(set-logic ALL)
(set-option :produce-models true)
(set-info :smt-lib-version 2.6)
(set-info :status unknown)
(define-sort FPN () (_ FloatingPoint 8 24))
(declare-fun a () Real)
(declare-fun b () Real)
(declare-fun c () Real)
(declare-fun x0 () FPN)
(declare-fun y0 () FPN)
(declare-fun z0 () FPN)
(declare-fun x1 () FPN)
(declare-fun y1 () FPN)
(declare-fun z1 () FPN)
(define-fun fun ( (x FPN) (y FPN) (z FPN) (arg0 Real) (arg1 Real) (arg2 Real)) FPN (fp.add RNE
(fp.add RNE (fp.mul RNE ((_ to_fp 8 24) RNE arg0) x)
(fp.mul RNE ((_ to_fp 8 24) RNE arg1) y))
(fp.mul RNE ((_ to_fp 8 24) RNE arg2) z)) )
(assert (fp.eq x0 ((_ to_fp 8 24) RNE 1)))
(assert (fp.eq y0 ((_ to_fp 8 24) RNE 0)))
(assert (fp.eq z0 ((_ to_fp 8 24) RNE 0)))
(assert (fp.eq x1 ((_ to_fp 8 24) RNE 0)))
(assert (fp.eq y1 ((_ to_fp 8 24) RNE 0)))
(assert (fp.eq z1 ((_ to_fp 8 24) RNE 0)))
(assert
(fp.gt (fun x0 y0 z0 a b c) (fun x1 y1 z1 a b c))
)
(check-sat)
(get-info :reason-unknown)
(get-model)
(exit)
非常感谢非常适合任何回应!
As I was using Floats and Reals in the same .smt2 file, I noticed that this would often lead to the result being "unknown". I have seen this mentioned here but as some time has passed since this answer I wanted to ask if maybe I'm simply not using the correct settings (e.g. Should I maybe be passing a tactic as parameter in the check-sat line? Or narrowing down set-logic?)
Here is an example that exhibits the behavior:
(set-logic ALL)
(set-option :produce-models true)
(set-info :smt-lib-version 2.6)
(set-info :status unknown)
(define-sort FPN () (_ FloatingPoint 8 24))
(declare-fun a () Real)
(declare-fun b () Real)
(declare-fun c () Real)
(declare-fun x0 () FPN)
(declare-fun y0 () FPN)
(declare-fun z0 () FPN)
(declare-fun x1 () FPN)
(declare-fun y1 () FPN)
(declare-fun z1 () FPN)
(define-fun fun ( (x FPN) (y FPN) (z FPN) (arg0 Real) (arg1 Real) (arg2 Real)) FPN (fp.add RNE
(fp.add RNE (fp.mul RNE ((_ to_fp 8 24) RNE arg0) x)
(fp.mul RNE ((_ to_fp 8 24) RNE arg1) y))
(fp.mul RNE ((_ to_fp 8 24) RNE arg2) z)) )
(assert (fp.eq x0 ((_ to_fp 8 24) RNE 1)))
(assert (fp.eq y0 ((_ to_fp 8 24) RNE 0)))
(assert (fp.eq z0 ((_ to_fp 8 24) RNE 0)))
(assert (fp.eq x1 ((_ to_fp 8 24) RNE 0)))
(assert (fp.eq y1 ((_ to_fp 8 24) RNE 0)))
(assert (fp.eq z1 ((_ to_fp 8 24) RNE 0)))
(assert
(fp.gt (fun x0 y0 z0 a b c) (fun x1 y1 z1 a b c))
)
(check-sat)
(get-info :reason-unknown)
(get-model)
(exit)
Thank you so much for any responses!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
恐怕从那时起并没有太大变化。像这样混合浮点数和实数会给 SMT 求解器带来非常棘手的问题。您可以在 z3 问题跟踪器 (https://github.com/Z3Prover/z3/issues )提醒开发人员,可惜我怀疑很快就会有很大的改进。
请注意,尝试其他求解器总是一个好主意。 CVC5 和 MathSAT 都支持浮点数和实数。不幸的是,当我在你的问题上调用 mathsat 时,它因语法错误而出错(我认为这是 mathsat 本身的错误),但 CVC5 确实找到了以下模型:
我还没有检查该模型是否实际上有效,但它是好消息是 CVC5 可以开箱即用(而且速度也很快)处理这个问题。
I'm afraid not much has changed since then. Mixing floats and reals like this creates really difficult problems for SMT solvers to deal with. You can file specific cases at the z3 issue tracker (https://github.com/Z3Prover/z3/issues) to alert the developers, alas I doubt there'll be much of an improvement any time soon.
Note that it's always a good idea to try other solvers as well. CVC5 and MathSAT both support floats and reals together. Unfortunately, when I call mathsat on your problem it errors out with a syntax error (I think it's a bug in mathsat itself), but CVC5 does indeed find the following model:
I haven't checked if the model is actually valid, but it's good news that CVC5 can handle this problem out-of-the-box (and quickly too.)