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
)
∨
F
a
l
s
e
m
e
m
.
[
]
= (x == x
1
)
∨
identity
Therefore,
maximum[x
1
]
= maximum[x]
substitution
= maximum(x: [ ])
(:)
= foldr max x [ ]
maximum
= x
foldr.[ ]
≥
x
a
r
i
t
h
m
e
t
i
c
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.: