Shinichi72
New member
- Joined
- Apr 2, 2021
- Messages
- 13
Here is the problem, I have tried to compute it and provide a solution. But, my teacher told me that it is wrong. Maybe the final answer is not simplified or there is a miscomputation in my solution.
Consider the following expression: x = 2 * y + x - 1 {x > 11}
Applying the assignment axiom we have the weakest precondition to be
{2 * y + x - 1 > 11}
{2 * y + x > 12}
{2 * y > 12 - x}
{y > 6 - (x/2)}
The weakest precondition is {y > 6 – (x/2)}.(My answer is not correct)
For a better understanding, I will provide a meaning of finding the weakest precondition and an example that will definitely help you to understand my problem.
An axiom for assignment statements x =: E
{P} x =: E {Q}
➔
Given an assignment statement x =: E and a
postcondition Q, we can compute its weakest
precondition P by using Q with all instances of x
replaced by E, denoted by the assignment axiom
P = Q x → E
Example
{???} x =: x + y - 3 {x > 10}
➔Even if the LHS of the assignment (i e x appears in the
RHS does not affect the process of computing the precondition, as in
x + y - 3 > 10
y > 13 - x
∴{y > 13 x} x =: x + y - 3 {x > 10} is correct
Consider the following expression: x = 2 * y + x - 1 {x > 11}
Applying the assignment axiom we have the weakest precondition to be
{2 * y + x - 1 > 11}
{2 * y + x > 12}
{2 * y > 12 - x}
{y > 6 - (x/2)}
The weakest precondition is {y > 6 – (x/2)}.(My answer is not correct)
For a better understanding, I will provide a meaning of finding the weakest precondition and an example that will definitely help you to understand my problem.
An axiom for assignment statements x =: E
{P} x =: E {Q}
➔
Given an assignment statement x =: E and a
postcondition Q, we can compute its weakest
precondition P by using Q with all instances of x
replaced by E, denoted by the assignment axiom
P = Q x → E
Example
{???} x =: x + y - 3 {x > 10}
➔Even if the LHS of the assignment (i e x appears in the
RHS does not affect the process of computing the precondition, as in
x + y - 3 > 10
y > 13 - x
∴{y > 13 x} x =: x + y - 3 {x > 10} is correct