Recursive datatypes with sequences in Python #6520
-
In guide there is an example of using recursive datatypes with sequences and arrays:
Is it possible to define Stmt using python bindings? Something like:
However, initializing SeqSort with incomplete Datatype is not possible:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
from z3 import *
SomeType = Datatype('SomeType')
SomeTypeS = DatatypeSort('SomeType')
SomeType.declare('nil')
SomeType.declare('some', ('someof', SeqSort(SomeTypeS), ))
SomeType = SomeType.create()
print(SomeType)
print(SomeTypeS)
print(SomeType.eq(SomeTypeS)) Background: the function "Datatype" creates a "builder" object where you can attach the constructors of a data-type. |
Beta Was this translation helpful? Give feedback.
-
Add example |
Beta Was this translation helpful? Give feedback.
Background: the function "Datatype" creates a "builder" object where you can attach the constructors of a data-type.
The function "DatatypeSort" accesses the sort object of name 'SomeType'. Z3 does not have information about the accessors/constructors until you called the "create()" method on the builder, but it is possible to use it as a sort as you like.
In fact the sort SomeType that is returned will be identical to SomeTypeS.