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?
$ 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.
Is it possible to declare a function sort in smtlib?
If there is impossible to declare a function sort, how to disambiguate f in the following program:
$ 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
is correct, even though (as you noticed) is very confusing. This annotation does not necessarily mean
fisInt. Rather, it meansfresults in anInt, so it could also be a 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:
As indicated above in
(as f σ), the typeσis the result sort off.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