I need to reinitialized a real variable based on some some Boolean flag as follows.
Alongside changing the truth value of location_next I want to reinitialize x_next with another value. How can I do that?
location, location_next = Bools('location location_next')
x, x_next = Reals('x x_next')
...
location_next == If(And(Not(location), x_next >= 12),
True,
If(And(location, x_next <= 0), False, location))
The function
If(in the Z3 API) can be also used to create non-Boolean expressions.We must have that for every
If(c, t1, t2),chas sort Boolean, andt1andt2have the same sort (type)S. In this case,If(c, t1, t2)is will produce a Z3 expression of sortS. Here is a small example:Here is a link with the example above: http://rise4fun.com/Z3Py/V4e
In the following example, we have a formula such that
x_nextis equal tox+1whenlocationisFalseandx >= 12, is equal tox-1whenlocationisTrueandx <= 0, and is equal toxotherwise.