Docsity

Mathematical Induction Proofs for Natural Numbers Addition - Prof. James L. Caldwell, Assignments of Computer Science

Toggle sidebar
bg1
HW 7 Prof. Caldwell
Due: 18 September 2008 COSC 3015
1
Problem 1.1. Read chapter 3 of Bird.
Problem 1.2. Do exercises 3.2.1 1and 3.2.4 (for finite natural numbers) using the principle of
mathematical induction given on page 63. Hint for 3.2.4: Choose arbitrary m, n โˆˆNat and do
induction on p.
2 Induction Examples from Class
In class we gave the following definitions.
date Nat = Zero | Succ Nat deriving (Eq,Ord,Show)
(+) :: Nat -> Nat -> Nat
m + Zero = m
m + (Succ n) = Succ (m + n)
We can prove properties of our addition function, verifying that it really behaves like the addition
we know an love, by using mathematical induction.
Lemma 2.1. โˆ€m:Nat. Z ero +m=m
Proof: By induction on m. The property Pis given as:
P(m)def
=Zero +m=m
Case[P(Zero)] We must show Zero +Z ero =Z ero, which holds by the definition of + so the base
case holds.
Case[P(Succ k)] Assume P(k) and show P(S ucc k).
P(k) : Zero +k=k
P(Succ k) : Z ero + (Succ k) = (S ucc k)
Starting on the left side of the equality P(Succ k):
Zero + (Succ k)hhdef.of (+)ii
=Succ (Z ero +k)hhP(k)ii
=Succ k
๎˜ƒ
1i.e. prove โˆ€m:Nat. Succ Z ero ร—m=m
1
pf2

Partial preview of the text

Download Mathematical Induction Proofs for Natural Numbers Addition - Prof. James L. Caldwell and more Assignments Computer Science in PDF only on Docsity!

HW 7 Prof. Caldwell Due: 18 September 2008 COSC 3015

Problem 1.1. Read chapter 3 of Bird.

Problem 1.2. Do exercises 3.2.1 1 and 3.2.4 (for finite natural numbers) using the principle of mathematical induction given on page 63. Hint for 3.2.4: Choose arbitrary m, n โˆˆ N at and do induction on p.

2 Induction Examples from Class

In class we gave the following definitions.

date Nat = Zero | Succ Nat deriving (Eq,Ord,Show)

(+) :: Nat -> Nat -> Nat m + Zero = m m + (Succ n) = Succ (m + n)

We can prove properties of our addition function, verifying that it really behaves like the addition we know an love, by using mathematical induction.

Lemma 2.1. โˆ€m : N at. Zero + m = m Proof: By induction on m. The property P is given as:

P (m) def = Zero + m = m

Case[P (Zero)] We must show Zero + Zero = Zero, which holds by the definition of + so the base case holds.

Case[P (Succ k)] Assume P (k) and show P (Succ k).

P (k) : Zero + k = k P (Succ k) : Zero + (Succ k) = (Succ k)

Starting on the left side of the equality P (Succ k):

Zero + (Succ k)

ใ€ˆใ€ˆdef. of (+)ใ€‰ใ€‰ = Succ (Zero + k)

ใ€ˆใ€ˆP (k)ใ€‰ใ€‰ = Succ k



(^1) i.e. prove โˆ€m : N at. Succ Zero ร— m = m

Lemma 2.2. โˆ€n : N at. โˆ€k : N at. Succ k + n = k + Succ n Proof: By induction on n. Then

P (n)

def = โˆ€k : N at. Succ k + n = k + Succ n

Case[P (Zero)] We must show โˆ€k : N at. Succ k + Zero = k + Succ Zero. Choose arbitrary k and show Succ k + Zero = k + Succ Zero. But, consider the following sequences of equalities:

Succ k + Zero

ใ€ˆใ€ˆdef. of (+)ใ€‰ใ€‰ = Succ k k + Succ Zero

ใ€ˆใ€ˆdef. of (+)ใ€‰ใ€‰ = Succ (k + Zero)

ใ€ˆใ€ˆdef. of (+)ใ€‰ใ€‰ = Succ k

so the base case holds. Case[P (Succ m)] Assume P (m) and show P (Succ m).

P (m) : โˆ€k : N at. Succ k + m = k + Succ m P (Succ m) : โˆ€k : N at. Succ k + Succ m = k + Succ (Succ m) Notice that in the second equation, substituting Succ m for n in the term Succ n on the right side gives Succ (Succ m), this could would be an easy place to make an error. To prove p(Succ m) holds, choose arbitrary k โˆˆ N at and show Succ k + Succ m = k + Succ (Succ m) Consider the following sequences of equalities:

Succ k + Succ m

ใ€ˆใ€ˆdef. of (+)ใ€‰ใ€‰ = Succ (Succ k + m)

ใ€ˆใ€ˆP (m)ใ€‰ใ€‰ = Succ (k + Succ m) k + Succ (Succ m)

ใ€ˆใ€ˆdef. of (+)ใ€‰ใ€‰ = Succ (k + Succ m)



Now, we prove the commutativity of addition:

Theorem 2.1. โˆ€n : N at. โˆ€m : N at. m + n = n + m Proof: By induction on m. Then

P (n) def = โˆ€m : N at. m + n = n + m

Case[P (Zero)] We must show โˆ€m : N at. m + Zero = Zero + m. Choose arbitrary m and notice that by definition of (+) m + Zero = m and by Lemma 2.1 Zero + m = m. Thus, the base case holds. Case[P (Succ m)] Assume P (m) and show P (Succ m).

P (k) : โˆ€m : N at. m + k = k + m P (Succ k) : โˆ€m : N at. m + Succ k = Succ k + m To show P (Succ k) choose arbitrary m and show m + Succ k = Succ k + m. m + Succ k ใ€ˆใ€ˆdef. of (+)ใ€‰ใ€‰ = Succ (m + k) ใ€ˆใ€ˆP (k)ใ€‰ใ€‰ = Succ (k + m) ใ€ˆใ€ˆdef. of (+)[backwards]ใ€‰ใ€‰ = k + Succ m ใ€ˆใ€ˆ(Lemma 2 .1)ใ€‰ใ€‰ = Succ k + m

Note: In the second to last step, we use the equality k + Succ m

ใ€ˆใ€ˆdef. of (+)ใ€‰ใ€‰ = Succ (k + m) in the right to left direction. This can be seen as a step in which we fold up the definition of (+).