[英]Is it possible to declare a function sort in smtlib?
For example,例如,
$ z3 -in
(declare-fun f (Int Real) Int)
(assert (= f f))
(check-sat)
sat
This is OK.还行吧。
However, I'd like to qualify it by as
?但是,我想通过
as
来限定它?
$ z3 -in
(declare-fun f (Int Real) Int)
(assert (= (as f ???) (as f ???)))
(check-sat)
sat
What should I fill in ???
我应该填写什么
???
? ?
It must be a sort, but what sort should I use?它必须是一种类型,但我应该使用哪种类型?
I have tried ((Int Real) Int)
or (-> (Int Real) Int)
or (_ (Int Real) Int)
, but none of them are correct.我试过
((Int Real) Int)
或(-> (Int Real) Int)
或(_ (Int Real) Int)
,但都不正确。
Is it possible to declare a function sort in smtlib?是否可以在 smtlib 中声明 function 排序?
If there is impossible to declare a function sort, how to disambiguate f
in the following program:如果无法声明 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")
Note that if I don't use functions, it's no problem:请注意,如果我不使用函数,那没问题:
$ z3 -in
(declare-fun f () Int)
(assert (= (as f Int) (as f Int)))
(check-sat)
sat
Thanks.谢谢。
The annotation注释
(as f Int)
is correct, even though (as you noticed) is very confusing.是正确的,即使(如您所见)非常混乱。 This annotation does not necessarily mean
f
is Int
.此注释并不一定意味着
f
是Int
。 Rather, it means f
results in an Int
, so it could also be a function.相反,它意味着
f
结果为Int
,因此它也可能是 function。
This is very confusing indeed, but it follows the standard http://smtlib.cs.uiowa.edu/papers/smt-lib-reference-v2.6-r2021-05-12.pdf , page 27:这确实非常令人困惑,但它遵循标准http://smtlib.cs.uiowa.edu/papers/smt-lib-reference-v2.6-r2021-05-12.pdf ,第 27 页:
Recall that every function symbol f is separately associated with one or more ranks, each specifying the sorts of f 's arguments and result.
回想一下,每个 function 符号 f 分别与一个或多个等级相关联,每个等级指定 f 的 arguments 和结果的种类。 To simplify sort checking, a function symbol in a term can be annotated with one of its result sorts σ.
为了简化排序检查,术语中的 function 符号可以用其结果排序 σ 之一进行注释。 Such an annotated function symbol is a qualified identifier of the form (as f σ).
这种带注释的 function 符号是形式的合格标识符(如 f σ)。
As indicated above in (as f σ)
, the type σ
is the result sort of f
.如上文
(as f σ)
所示,类型σ
是f
的结果排序。
Note also that solver support for these annotations is rather inconsistent.另请注意,求解器对这些注释的支持相当不一致。 For a previous discussion on this, see https://github.com/Z3Prover/z3/issues/2135
有关先前对此的讨论,请参阅https://github.com/Z3Prover/z3/issues/2135
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.