Question: In questions 1 and 2 , we will create program that calculates the factorial of natural number n . We want x = fac (
In questions and we will create program that calculates the factorial of natural number We want fac
to be the postcondition of the program, and to be the precondition of this program.
Create a loop invariant by replacing by variable in the postcondition. Consider: what is the range of
Create the corresponding loop condition and bound expression Show your work.
Create a full proof outline under the total correctness for this program. Don't forget to initialize variable and
before the loop starts, find reasonable values for them. Use the fact that facfac while
creating the loop body.
For each of the following statements, decide whether it is true or false. Justify your answer.
a A good loop invariant should be stronger than the expected postcondition of the loop.
b A good loop invariant should be true before, after and within each iteration of the loop.
c There is no algorithm to find a loop invariant, but there are algorithms to find bound expressions.
d If we know that then if then else :
eif then else :
Finish the following syntax substitution, where are all named constants. Optimize your result into a chain
if else fi expression.
Find an optimized precondition which contains no conditional expressions and create a full proof outline for
the following minimal proof outline. You may assume that :;::;:::::;:::::
:
you don't need worry about the arrayindexoutbounds error.
:;:
Draw evaluation graph for the configuration :: where ::;:
Draw evaluation graph for the configuration :: where while :
: you don't need
worry about the arrayindexoutbounds error.
:;:
Find optimized precondition which contains conditional expressions and create a full proof outline for
the following minimal proof outline. You may assume that
you don't need worry about the arrayindexoutbounds error.
:;:
Draw evaluation graph for the configuration :: where ::;:
Draw evaluation graph for the configuration :: where while :
:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
