I am new to z3py and SMT and I haven't found a good tutorial about z3py.
Here is my problem setting:
Given an input integer array I=[1,2,3,4,5], and an output integer array O=[1,2,4,5].
I want to infer k for the operator Delete, which deletes the element at position k in an array, where
Delete(I,O) = (ForAll 0<=x<k, O[x] = I[x] ) and (ForAll k<=x<length(I)-1, O[x] = I[x+1]) is true
Should I use Array or IntVector, or anything else to represent the input/output array?
Edit:
My code is as follows:
from z3 import *
k=Int('k')
s=Solver()
x = Int('x')
y = Int('y')
s.add(k >= 0)
s.add(k < 4)
s.add(x >= 0)
s.add(x < k)
s.add(y >= k)
s.add(y < 4)
I = Array('I',IntSort(),IntSort())
O = Array('O',IntSort(),IntSort())
Store(I, 0, 1)
Store(I, 1, 2)
Store(I, 2, 3)
Store(I, 3, 4)
Store(I, 4, 5)
Store(O, 0, 1)
Store(O, 1, 2)
Store(O, 2, 4)
Store(O, 3, 5)
s.add(And(ForAll(x,Select(O,x) == Select(I,x)),ForAll(y,Select(O,y) == Select(I,y+1))))
print s.check()
print s.model()
It returns
sat
[I = [2 -> 2, else -> 2],
O = [2 -> 2, else -> 2],
y = 1,
k = 1,
x = 0,
elem!0 = 2,
elem!1 = 2,
k!4 = [2 -> 2, else -> 2]]
I don't understand what I, O, elem!0, elem!1 and k!4 mean and this is clearly not what I expected.