Are functions in z3 realized by inlining? Eg would this
(define-fun f ((parameter Int)) Int (* parameter parameter))
(assert (= (f x) y))
automatically be replaced by this?:
(assert (= (* x x) y))
I know that in https://smtlib.github.io/jSMTLIB/SMTLIBTutorial.pdf#subsection.3.9.4 (page 38) it is mentioned that they are "equivalent"/"an abbreviation", but I just wanted to make sure whether this means that the function calls themselves are replaced.
Thanks so much!
Yes, the SMT-LIB standard indeed defines define-fun
to be a C-style macro that is syntactically expanded to its defining expression.
However, while this defines its semantics, the definition does not necessarily require SMT-LIB tools, most notably SMT solvers, to actually implement define-fun
like this. Hence, it could be that an SMT solver behaved differently, eg in terms of performance, if you ran it on two versions of a program: one with define-fun
s, and a second where you manually replaced all define-fun
s with their corresponding expressions.
The last bit is pure speculation from my side, though; you'd have to look at, eg Z3's sources (or maybe just its verbose debug output) to find out what a particular tool actually does.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.