Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Compute the weakest precondition for each of the following problems: (1). Comput

ID: 3749977 • Letter: C

Question

Compute the weakest precondition for each of the following problems:
(1). Compute the weakest precondition for each of the following assignment statements and
postconditions:
x = 2 * y + x - 1 {x > 11}
(2). Compute the weakest precondition for each of the following sequences of assignment
statements and their postconditions:
a= 2*b+1;
b=a-3
(b<0)
(3). Compute the weakest precondition for each of the following sequences of assignment
statements and their postconditions:
a = 3 * (2 * b + a);
b = 2 * a - 1
{b > 5}

Explanation / Answer

Solution:-

(1). x = 2 * y + x - 1

{x > 11}

putting x > 11 in above expression

2 * y + x – 1 > 11

2 * y + x > 12

(2). a= 2*b+1   (i)

b=a-3    (ii)

(b<0)

putting b<0 in above expression (ii)

a-3 < 0

a < 3

putting  a < 3   in above expression (i)

2*b+1 < 3

2b < 2

b < 1

(3).

a= 3*(2*b+a) (i)

b= 2*a-1   (ii)

{b>5}

putting b>5 in above expression (ii)

2*a-1>5

2*a>6

a>3

putting a>3 in above expression (i)

a= 3*(2*b+a) {a>3}

3*(2*b+a)>3

6*b+3*a>3

2*b+a>1

b>(1-a)/2

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote