{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

hw8Solutions

# hw8Solutions - Homework 8 Solutions Problem 1 Proof of...

This preview shows pages 1–2. Sign up to view the full content.

Homework 8 Solutions Problem 1) Proof of Thm{maxL}: Case 1: x >= y: max x y = x {max>} >= x {2 nd grade arith} Case2: x < y max x y = y {max<} > x {Case 2 assumption} >= x {2 nd grade arith} Proof of Thm{maxR}: similar to proof of maxL Proof of Thm{maxM} Cite the law of the excluded middle to prove the formula ((x >= y) \/ (not(x >= y))). Then use or elimination. In the middle and right-hand proofs in the or-eliminate, use your knowledge of arithmetic and or introduction to conclude the or-formula of {maxM}. Problem 2) maximum(x: xs) = foldr max x xs {maximum} Problem 3) P(n) (member(x, [x 1 , x 2 , … x n+1 ]) (maximum[x 1 , x 2 , … x n+1 ] x)) Base Case: P(0) (member(x, [x 1 ]) (maximum[x 1 ] x)) member(x, [x 1 ]) = member(x, x 1 :[ ]) (:) = (x == x 1 ) (member(x, [ ]) mem.: = (x == x 1 ) False mem.[ ] = (x == x 1 ) identity Therefore, maximum[x 1 ] = maximum[x] substitution = maximum(x: [ ]) (:) = foldr max x [ ] maximum = x foldr.[ ] x arithmetic Inductive Case: P(n+1) (member(x, [x 1 , x 2 , … x n+2 ]) (maximum[x 1 , x 2 , … x n+2 ] x)) member(x, [x 1 , x 2 , … x n+2 ]) = member(x, x 1 : [x 2 , … x n+2 ]) (:) = (x == x 1 ) member(x, [x 2 , … x n+2 ]) mem.:

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}