I'm trying to understand how to define an assertion in such a way that it proves certain mathematical qualities of an already defined function. As discussed in this post SMT solvers are not well-suited for induction, which is often needed to prove a mathematical quality.
In my case, I have a recursive function definition for the identity function f(x) = x
(just as a simple example):
(define-fun-rec identity-rec ((l String)) String
(ite (= 0 (str.len l))
""
(str.++ (str.at l 0) (identity-rec (str.substr l 1 (seq.len l))))))
(define-fun identity ((l String)) String
(ite (= 0 (str.len l))
""
(identity-rec l)))
The same post suggests that such characteristics cannot be proven out-of-the-box. However, I am interested to know how general mathematical properties are proven in z3
. I tried with all-quantifiers to prove the involution of the function but z3
does not terminate:
(assert
(forall ((a String))
(=
a
(indentity (identity a))
)
)
My Question:
What assertion can we use to prove that such a recursive function is an involution with z3
?