Question: Problem #4 Consider the following program for computing exponents by repeated multiplica- tion. We refer to this program as Exp below. e = 1; i

 Problem #4 Consider the following program for computing exponents by repeated

Problem #4 Consider the following program for computing exponents by repeated multiplica- tion. We refer to this program as "Exp" below. e = 1; i = y ; while ( i > 0 ) do e = e * x ; i =i- 1 ; end Consider the following Hoare triple: (x 21Ay>1} Exp {e =my} Here, my means a raised to the yth power. Recall that any integer raised to the zeroth power is 1. That is, Vr . 20 = 1. Answer the following questions: 1. What is a loop invariant that would be useful in proving that "Exp" is partially correct, for the Hoare triple above. 2. Using the rules of axiomatic semantics show that the Hoare triple above is valid. You must also indicate which of the rules given above is used in each step of your proof. If you use abbreviations for code fragments or logical expressions you must provide a definition for them

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!