Question: Q 4 [ 2 0 ] Consider the following specification where a and b are arrays of inte - gers of length n f =

Q4[20]
Consider the following specification where a and b are arrays of inte-
gers of length n
f=(:AAiin{0,..n}*b'(i)=(??jin{0,..,i}*(-1)ja(j)):)
E.g.a=[7,2,6,8],b'=[7,5,11,3].
Read the whole question before beginning to answer. The idea is to
develop a command of the form
fm0; while Adoh0
The command should run in (n) time.
(a)[5] Propose a loop invariant I
Let g=((:I:)=>f). Let m=(:I'???a'=a:) so that fm;g.
(b)[2] Give a command that refines m.
(c)[5] Give an expression A and such that
I??notA=>AAiin{0,..n}*b(i)=(??jin{0,..i}*(-1)ja(j))
is true for all states, i.e., so that (:notA:)=>g skip.
A is
(d)[3] Propose a bound expression for the loop.
Let h=(:A??I=>I'???a'=a:) so that
g if A then (h;g) else skip
(e)[5] Give a command that refines h and that makes the bound
expression smaller.
h
 Q4[20] Consider the following specification where a and b are arrays

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 Databases Questions!