How do I retrieve the values of an enumerated variable v
? For example,
vTyp, (val1,val2,val3) = EnumSort('vTyp',['val1','val2','val3'])
v = Const('my variable',vTyp)
Now, given just the above variable v
, how would I retrieve a list of values [val1,val2,val3]
of v
(where val1,val3,val3
are expressions as above) ?
I have tried [v.sort().constructor(0), ...(1), ...(2)]
but the constructor method does not return an expression.
The expression v.sort().constructor(0)
returns a Z3 function declaration. In Z3, constants are functions with 0 arguments. To convert the declaration in a constant expression, we should use v.sort().constructor(0)()
.
BTW, the function is_func_decl
can be used to test whether an object is a Z3 function declaration or not. The function is_expr
is the equivalent for Z3 expressions.
print is_func_decl(v.sort().constructor(0))
print is_expr(v.sort().constructor(0))
print is_expr(v.sort().constructor(0)())
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.