I'm learning Z3 solver. I have a question about Arrays and related conditions. In particular, I have to create Z3py code to solve the if condition below:
totalAccounts = [ 1, 2, 3, 4, 5 ]
def (myAccounts):
cnt = len(myAccounts)
if (cnt > 10) doSomething()
myAccounts
is a list of Integers, subset of the list totalAccounts
.
The condition to pass is cnt > 10
which depends on the length of myAccounts
list.
I think I need to represent myAccounts
as a Z3's Array and copy the values in totalAccounts
on it using the function Store
.
MYACCOUNTS = Array ('MYACCOUNTS', IntSort(), IntSort())
I = Int('I')
i = 0
for elem in totalAccounts:
MYACCOUNTS = Store(MYACCOUNTS, i, elem)
i = i + 1
But I don't know how to represent the length of such array in creating the condition to add to the solver:
solver = Solver()
solver.add( ??? > 10 )
Am I doing it right?