ASSIGNMENT 5

ASSIGNMENT 5 - PRABHUVARMA SAGI A20259008 ASSIGNMENT 5 1)...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
PRABHUVARMA SAGI A20259008 ASSIGNMENT 5 1) { Vi :1<=I<k : A[max]>=a[i]} Select A[k]>=A[max] =>max:=k; k:=k+1; (Or) A[k]<=A[max] =>k:=k+1; End select {Vi :1<=i<k : A[max]>=A[i]} Sol: We know the proof rule for select is P=>Ei 1<=i<=n :Bi ^ Vi 1<=i<=n {p^ Bi} Si {Q} {p} select……. .endselect {Q} Part 1 : We have to show p=>BB Here P is {Vi :1<=i<k : A[max]>=A[i]} and Q is {Vi :1<=i<k : A[max]>=A[i]}
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
PRABHUVARMA SAGI A20259008 Proof: {Vi :1<=i<k : A[max]>=A[i]} => A[k]>=A[max] U A[k]<=A[max] True True. Part2: {Vi :1<=i<k : A[max]>=A[i] ^ A[k] >A[max]} => wp ( max:=k;k:=k+1, Vi :1<=i<k : A[max]>=A[i]} => ((Vi :1<=i<k : A[max]>=A[i])) first replace k with k+1 => (Vi :1<=i<k+1 : A[max]>=A[i]) now replace max with k. => (Vi :1<=i<k+1 : A[K]>=A[i]) We know the above one can also be written as => ( Vi :1<=i<k : A[max]>=A[i] ^ A[k+1] >A[max]) {Vi :1<=i<k : A[max]>=A[i] ^ A[k] >A[max]} => ( Vi :1<=i<k : A[max]>=A[i] ^ A[k+1] >A[max]). This is true. ^ Now we have to show {Vi :1<=i<k : A[max]>=A[i] ^ A[k] <A[max]} => wp (k:=k+1, Vi :1<=i<k : A[max]>=A[i]) => (Vi :1<=i<k : A[max]>=A[i]) replace K with K+1. => (Vi :1<=i<k+1 : A[max]>=A[i]) The above one can be written as.
Background image of page 2
PRABHUVARMA SAGI A20259008 => (Vi :1<=i<k : A[max]>=A[i] ^ A[k+1] <A[max] ). Hence {Vi :1<=i<k : A[max]>=A[i] ^ A[k] <A[max]} =>( Vi :1<=i<k : A[max]>=A[i] ^ A[k+1] <A[max] ). This is true. ^ {Vi :1<=i<k : A[max]>=A[i] ^ A[k] =A[max]} = > wp ( k:=k+1, Vi :1<=i<k : A[max]>=A[i]) => (Vi :1<=i<k+1 : A[max]>=A[i]) This can be written as => (Vi :1<=i<k : A[max]>=A[i] ^ A[k+1] =A[max] ). Hence {Vi :1<=i<k : A[max]>=A[i] ^ A[k] =A[max]} =>( Vi :1<=i<k : A[max]>=A[i] ^ A[k+1] =A[max] ). This is true. Hence T^T^T^T =T. hence proved. 2) Prove that the definition of the select statement satisfies the rule of excluded Miracle. Sol: law of excluded miracle is WP( select, false) = false. Now we take WP(select, false) By the definition of select .
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
PRABHUVARMA SAGI A20259008 WP(select, false) is Ei 1<=i<=n : Bi ^ Vi 1<=i<=n : Bi=>wp(Si, false) Ei 1<=i<=n : Bi ^ Vi 1<=i<=n: Bi=> false (assume Si satisfies law of excluded miracle) Ei : 1<=i<=n Bi can be written as !(Vi 1<=i<=n !Bi) ^ Vi 1<=i<=n !Bi True ^ false is false . 5. Prove following { even(x) ^ odd(y)} Select even (x+y) => (x,y) := (0,0) or odd(x+y) => (x,y) := (x-1,y+1) or odd(x) => (x,y) := (y,x)
Background image of page 4
PRABHUVARMA SAGI A20259008 or odd(y) => (x,y := x+1 , y-1) end select { odd(x) ^ even(y)} Sol : We know the proof rule for select is P=>Ei 1<=i<=n :Bi ^ Vi 1<=i<=n {p^ Bi} Si {Q} {p} select……. .endselect {Q} Here P is { even(x) ^ odd(y)} and Q is { odd(x) ^ even(y)}
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 16

ASSIGNMENT 5 - PRABHUVARMA SAGI A20259008 ASSIGNMENT 5 1)...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online