Homework # 6  - due Tuesday October 4th

 

  1. Read the section on pre and post conditions and do problems 19 a and b  and 20 a  from Chapter 3 found  on pages 172 & 173 (also shown below)

 

19.     Compute the weakest precondition for each of the following statements and postconditions

 

a.          a = 2 * (b – 1) – 1   {a > 0}

                       2*(b-1)-1 > 0

                        2b – 2 -1 > 0

                         2b – 3 > 0

                          2b > 3

                             b > 3/2    Ü  required answer  (derivation is optional)

 

b.       b = (c + 10) / 3   { b > 6}

      

            (c+10)/3 > 6

              (c+10) > 18

                 c > 8  Ü  required answer  (derivation is optional)

 

20.     Compute the weakest precondition for each of the following sequences of assignment statements and their postconditions

 

a.          a = 2 * b + 1;

   b = a – 3

   { b < 0}

 

        a – 3 < 0

        a < 3   Ü  required answer  (derivation is optional)

 

  1.  Answer the Pascal questions found here