Docsity

List Induction Proofs in COSC 3015: Map Function and List Reversal - Prof. James L. Caldwe, Assignments of Computer Science

Toggle sidebar
bg1
HW 11 Prof. Caldwell
Due: 9 October 2008 COSC 3015
Recall the list induction principle.
[P([ ])∧
∀a:α. ∀m: [α]. P (m)⇒P(a:m)]
⇒ ∀m: [α].P (m)
Thus, for a property Pof lists, to show that ∀m: [α]. P (m) it is enough to show two things:
i.)P([ ])
ii.)∀a:α. ∀m: [α]. P (m)⇒P(a:m)
Here are some definitions.
head(h:t) = h
head[ ] = ⊥
last[x] = x
last(h:t) = last t
last[ ] = ⊥
reverse[ ] = [ ]
reverse(h:t) = (r everse t) + +[h]
map f [ ] = [ ]
map f (h:t) = (f h) : map f t
(f . g)x=f(g x)
Prove the following by list induction.
1.)∀m:[α]. map (f . g)m= ((map f ).(map g)) m
2.)∀m:[α]. head (reverse m) = last m
1

Partial preview of the text

Download List Induction Proofs in COSC 3015: Map Function and List Reversal - Prof. James L. Caldwe and more Assignments Computer Science in PDF only on Docsity!

HW 11 Prof. Caldwell Due: 9 October 2008 COSC 3015

Recall the list induction principle.

[P ([ ])∧ ∀a : α. ∀m : [α]. P (m) ⇒ P (a : m)] ⇒ ∀m : [α].P (m)

Thus, for a property P of lists, to show that ∀m : [α]. P (m) it is enough to show two things:

i.) P ([ ]) ii.) ∀a : α. ∀m : [α]. P (m) ⇒ P (a : m)

Here are some definitions. head(h : t) = h head[ ] = ⊥

last[x] = x last(h : t) = last t last[ ] = ⊥

reverse[ ] = [ ] reverse(h : t) = (reverse t) + +[h]

map f [ ] = [ ] map f (h : t) = (f h) : map f t

(f. g) x = f (g x)

Prove the following by list induction.

1 .) ∀m : [α]. map (f. g) m = ((map f ). (map g)) m 2 .) ∀m : [α]. head (reverse m) = last m