python - ForAll in Z3.py -


i have question using of forall in z3.py. want create local variable in forall declaration follows:

a = declaresort('a') a0,a1,a2,a3 = consts('a0 a1 a2 a3', a)  s = solver() f = function('f', a, a, boolsort()) s.add(forall ([a0],(f(a0, a0))))  print (s.check()) print (s.model()) 

the result should applied consts except a0 local variable in forall model shows solution apply consts including a0.

creating local variable possible in smt not in python.

can help?

here model provides:

sat [elem!0 = a!val!0, f = [else -> true]] 

it introduces single element called "elem!0" having unique value "a!val!0" (this z3's way generate fresh values"). interpretation of f given such f true.

if want quantify on variables not listed in list, should walk formula being quantified on , collect variables not included in set. there 3 cases consider when walking expression: can satisfy 1 of following properties:

 is_quantifier(e), is_app(e), is_var(e) 

an expression 'e' uninterpreted constant if is_app(e) true, number of children 0 (len(e.children()) == 0), , furthermore when accessing e.decl().kind() obtain uninterpreted kind.

you can use "e.get_id()" retrieve unique identifier corresponding expression. can used in python maps (you can't use expressions keys in python maps because equality overloaded construct new expressions checking semantic equality of expressions, rather checking syntactic equality of expressions).


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -