NEXT ·
UP ·
PREVIOUS ·
CONTENTS ·
INDEX
Next:Proof:
Up:Induction for lists
Previous:Induction for lists
Proof:
The proof is by induction on l
.The initial step is to show that this proposition holds when
l
is the empty list, []. Using properties of
the append operator, we conclude
rev() =
revl
=
=
as required.
Now assume rev () =
and
consider h
:: t.
LHS |
= |
rev() |
|
|
= |
rev() |
[defn of @] |
|
= |
|
[defn of rev] |
|
= |
|
[induction hypothesis] |
|
= |
|
[defn of rev] |
|
= |
RHS |
|

Exercise
Prove by structural induction that for all 'a lists
l
and l
length ()
=
length l + length l . |
Proposition (Involution)
The rev function is an involution, i.e.
it always undoes its own work, since
rev(revl) = l.
NEXT ·
UP ·
PREVIOUS ·
CONTENTS ·
INDEX
Next:Proof:
Up:Induction for lists
Previous:Induction for lists