I was reading this research paper: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.365.9467&rep=rep1&type=pdf
So, in summary, they are transforming the quantified horn clauses to quantifier-free horn clauses by instantiation (via E-matching), and the resulting Verification Conditions (VCs) are given in Fig. 6 of the paper.
As per my understanding, the paper suggests to pass the resulting VCs in Fig. 6 to any SMT solver, since the VCs are now quantifier-free and can be solved by any SMT solver. (Please correct me, if I'm wrong in this.)
So, going ahead with this understanding, I tried coding Fig. 6 VCs with z3py.
Edit: My goal is to find the solution to the VCs in Fig. 6. What should I add as the return type of invariant P that is to be inferred by z3? Is there a better way to do this using z3? Thank you for your time!
Here's the code:
from z3 import *
Z = IntSort()
B = BoolSort()
k0, k1, k2, N1, N2 = Ints('k0, k1, k2, N1, N2')
i0, i1, i2 = Ints('i0, i1, i2')
P = Function('P', B, Z)
a0 = Array('a0', Z, B)
a1 = Array('a1', Z, B)
a2 = Array('a2', Z, B)
prove(And(Implies(i0 == 0, P( Select(a0,k0), i0) ),
Implies(And(P(Select(a1, k1),i1), i1<N1), P(Select(Store(a1, i1, 0)), i1+1) ),
Implies(And(P(Select(a2,k2), i2), not(i2<N2)), Implies(0<=k2<=N2, a2[k2]) )))
Function('P', B, Z)
is a function from B to Z; the declaration is missing the second argument or the return type. – Christoph Wintersteiger