0

I am starting to use Z3py, and I have so difficulties to understand how function it. I have to know if the array isEmpty or not, but I don't know how create a reference between "x" and "array"

def isEmpty():
    x = Int('x')
    y = Int('y')
    array = Array('array', IntSort(), IntSort())

    empty = Bool('isEmpty')
    s = Solver()
    #s.add(x==0)
    dato = Implies(x>0,empty == False),Or(Implies(x<=0,empty == True))
    s.add(dato)

    if s.check() == sat:
        #print("0")
        #print(s.model())
        return s.model()


if __name__ == '__main__':
     isEmpty()
Kokoro
  • 13
  • 3

1 Answers1

2

As Christoph answered in your previous question (how I can to know how many values have a array in z3?), an array in z3 is of unbounded size. They are more like functions in that sense. For every integer x, (select A x) is a meaningful expression.

Please review the array logic in the SMTLib document (http://smtlib.cs.uiowa.edu/theories-ArraysEx.shtml). So, asking if an array is empty is meaningless. If you want to associate a size with an array, you'll have to manage that separately, perhaps using the sequence logic (https://rise4fun.com/Z3/tutorial/sequences) where you can talk about lists of finite length; more similar to arrays as found in programming languages like C or Java.

alias
  • 28,120
  • 2
  • 23
  • 40