Skip to content

Temporary Variables in forall scope #5088

Answered by aytey
SunandanAdhikary asked this question in Q&A
Discussion options

You must be logged in to vote

You don't have to write the constraint for ForAll "inline"; you can totally do something like:

from z3 import *


def my_fun(y, z):
    return Implies(And(y > -5, y < 5), y + z > 10)


s = Solver()

z = Int("z")
y = Int("y")

s.add(ForAll([y], my_fun(y, z)))

print(s.sexpr())

I think in Z3 parlance, my_fun is called a "generator expression" -- that is, it a function that generates further Z3 expressions.

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by nunoplopes
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #5084 on March 08, 2021 17:38.