I want to find the weakest precondition given an action and post condition using z3py.
Given the action N = N + 1 and the post condition N == 5 the weakest precondition would be N == 4.
Using the Tactic solve-eqs this approach works for some post conditions but not others.
When using the post condition N < 5 I get [[Not(4 <= N)]].
But when using N == 5 I get [[]], when I would like N == 4.
N2 = Int('N2') # N after the action
N = Int('N') # N before the action
weakestPreconditionGoal = Goal()
# 'N2 == n + 1' action
# 'N2 == 5' post condition.
weakestPreconditionGoal.add(N2 == N + 1, N2 == 5)
t = Tactic('solve-eqs')
wp = t(weakestPreconditionGoal)
print(wp)
Is this the best approach find the weakest precondition?
I have tried a several methods but am new to Z3 and can not figure out what approach to take or how to implement it.