繁体   English   中英

是否可以在 smtlib 中声明 function 排序?

[英]Is it possible to declare a function sort in smtlib?

例如,

$ z3 -in
(declare-fun f (Int Real) Int)
(assert (= f f))
(check-sat)
sat

还行吧。

但是,我想通过as来限定它?

$ z3 -in
(declare-fun f (Int Real) Int)
(assert (= (as f ???) (as f ???)))
(check-sat)
sat

我应该填写什么???

它必须是一种类型,但我应该使用哪种类型?

我试过((Int Real) Int)(-> (Int Real) Int)(_ (Int Real) Int) ,但都不正确。

是否可以在 smtlib 中声明 function 排序?

如果无法声明 function 排序,如何在以下程序中消除f的歧义:

$ z3 -in
(declare-fun f (Int Real) Real)
(declare-fun f (Int Bool) Real)
(assert (= f f))
(error "line 3 column 11: ambiguous constant reference, more than one constant with the same sort, use a qualified expression (as <symbol> <sort>) to disambigua
te f")

请注意,如果我不使用函数,那没问题:

$ z3 -in
(declare-fun f () Int)
(assert (= (as f Int) (as f Int)))
(check-sat)
sat

谢谢。

注释

(as f Int)

是正确的,即使(如您所见)非常混乱。 此注释并不一定意味着fInt 相反,它意味着f结果为Int ,因此它也可能是 function。

这确实非常令人困惑,但它遵循标准http://smtlib.cs.uiowa.edu/papers/smt-lib-reference-v2.6-r2021-05-12.pdf ,第 27 页:

回想一下,每个 function 符号 f 分别与一个或多个等级相关联,每个等级指定 f 的 arguments 和结果的种类。 为了简化排序检查,术语中的 function 符号可以用其结果排序 σ 之一进行注释。 这种带注释的 function 符号是形式的合格标识符(如 f σ)。

如上文(as f σ)所示,类型σf的结果排序

另请注意,求解器对这些注释的支持相当不一致。 有关先前对此的讨论,请参阅https://github.com/Z3Prover/z3/issues/2135

暂无
暂无

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

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