簡體   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