Lecture 12
CS 1813 – Discrete Mathematics
The Principle of
Mathematical Induction
ok … now we’re cooking with gas …
CS 1813 Discrete Mathematics, Univ Oklahoma
Copyright © 2000 by Rex Page
1
A Little Theorem about Sequences
Algebraic laws of sequence construction
(x: []) = [x]
(xs [ ] ) = (x. ys. xs = (x: ys) )
-- :[]
-- (:)
( x : [x1, x2, …] ) = [x, x1, x2, …]
-- (: …)
(++) :: [a] -> [a] -> [a]
([ ] ++ ys) = ys
((x : xs) ++ ys) = (x : (xs ++ ys))
-- (++).[ ]
-- (++).:
Informally
Algebraic laws of concatenation
An equational argument
Assume x :: a and xs :: [a]
[x] ++ xs
= (x : [ ]) ++ xs
= x : ([ ] ++ xs)
= (x : xs)
:[]
(++).:
(++).[ ]
([x] ++ xs) = (x : xs)
()
What did this prove?
CS 1813 Discrete Mathematics, Univ Oklahoma
Copyright © 2000 by Rex Page
2
Software Equations = Algebraic Laws
Algebraic laws of foldr
foldr (the big picture)
foldr () z [x1, x2, …, xn] =
x1 (x2 … (xn-1 (xn z)) … )
foldr :: (a -> b -> b) -> b -> [a] -> b
foldr () z [ ] = z
foldr () z (x : xs) = x (foldr () z xs)
-- (foldr).[]
-- (foldr).:
The big or
(\/) :: Bool -> Bool -> Bool -- “little or” – satisfies Boolean laws for
or :: [Bool] -> Bool
-- “big or”
or = foldr (\/) False
-- (or)
Theorem (or1). or ([True] ++ xs) = True
or ([True] ++ xs)
= or (True : xs)
= foldr (\/) False (True : xs)
= True \/ (foldr (\/) False xs)
= (foldr (\/) False xs) \/ True
= True
CS 1813 Discrete Mathematics, Univ Oklahoma
Copyright © 2000 by Rex Page
()
(or)
(foldr).:
( comm)
( null)
qed
3
Theorem — or/singleton True
Corollary (or1c): or [True] = True
Proof
True
= or ( [True] ++ [ ] )
= or ( True : [ ] )
= or ( [True] )
(or1)
()
:[]
qed
CS 1813 Discrete Mathematics, Univ Oklahoma
Copyright © 2000 by Rex Page
4
Theorem — or[x,True, …] = True
Theorem (or2): or ([x] ++ ([True] ++ xs)) = True
Proof
or([x] ++ ([True] ++ xs))
= or((x:[]) ++ ([True] ++ xs))
= or(x:([] ++ ([True] ++ xs)))
= foldr (\/) False (x:([] ++ ([True] ++ xs)))
= x \/ (foldr (\/) False ([] ++ ([True] ++ xs)))
= x \/ (or([] ++ ([True] ++ xs)))
= x \/ (or([True] ++ xs))
= x \/ True
= True
Theorem (or1): or ([True] ++ xs) = True
CS 1813 Discrete Mathematics, Univ Oklahoma
Copyright © 2000 by Rex Page
(:)
(++).:
(or)
(foldr).:
(or)
(++).[]
(or1)
null
qed
5
Theorem — or[x, y,True, …] = True
Theorem (or3): or ([x, y] ++ ([True] ++ xs)) = True
Proof
or([x, y] ++ ([True] ++ xs))
= or((x:[y]) ++ ([True] ++ xs))
= or(x:([y] ++ ([True] ++ xs)))
= foldr (\/) False (x:([y] ++ ([True] ++ xs)))
= x \/(foldr (\/) False ([y] ++ ([True] ++ xs)))
= x \/ (or([y] ++ ([True] ++ xs)))
= x \/ True
= True
(:)
(++).:
(or)
(foldr).:
(or)
(or2)
null
qed
Theorem (or2): or ([x] ++ [True] ++ xs) = True
CS 1813 Discrete Mathematics, Univ Oklahoma
Copyright © 2000 by Rex Page
6
Theorem — or[x, y, z,True, …] = True
Theorem (or4): or ([x, y, z] ++ ([True] ++ xs)) = True
Proof
or([x, y, z] ++ ([True] ++ xs))
= or((x:[y, z]) ++ ([True] ++ xs))
= or(x:([y, z] ++ ([True] ++ xs)))
= foldr (\/) False (x:([y,z] ++ ([True] ++ xs)))
= x \/(foldr (\/) False ([y,z] ++ ([True] ++ xs)))
= x \/ (or([y,z] ++ ([True] ++ xs)))
= x \/ True
= True
Theorem (or3): or ([x, y] ++ [True] ++ xs) = True
CS 1813 Discrete Mathematics, Univ Oklahoma
Copyright © 2000 by Rex Page
(:)
(++).:
(or)
(foldr).:
(or)
(or3)
null
qed
7
Theorem — or[x, y, z, w,True, …] = True
Theorem (or5): or ([x, y, z, w] ++ ([True] ++ xs)) = True
Proof You can do this one, right?
or([x, y, z, w] ++ ([True] ++ xs))
= or((x:[y, z, w]) ++ ([True] ++ xs))
= or(x:([y, z, w] ++ ([True] ++ xs)))
= foldr (\/) False (x:([y,z,w] ++ ([True] ++ xs)))
= x \/(foldr (\/) False ([y,z,w] ++ ([True] ++ xs)))
= x \/ (or([y,z,w] ++ ([True] ++ xs)))
= x \/ True
= True
(:)
(++).:
(or)
(foldr).:
(or)
(or4)
null
The last three proofs are all the same, except that they each
cite a different theorem in the 5th line.
Theorem (or4): or ([x, y, z] ++ [True] ++ xs) = True
The proof of (orn+1) cites (orn)
CS 1813 Discrete Mathematics, Univ Oklahoma
Copyright © 2000 by Rex Page
8
Principle of Mathematical Induction
another way to skin a cat
{I} — an inference rule
with n. P(n) as it’s conclusion
One way to use {I}
Prove P(0)
Prove P(n +1) for arbitrary n
Takes care of P(1), P(2), P(3), …
Mathematical induction
P(n) {n arbitrary}
{I}
n. P(n)
Introduction
P(0) n.P(n)P(n+1)
{Ind}
n. P(n)
makes it easier Induction
Proof of P(n +1) can cite P(n) as a reason
If you cite P(n) as a reason in proof of P(n+1),
your proof relies on mathematical induction
If you don’t, your proof relies on {I}
CS 1813 Discrete Mathematics, Univ Oklahoma
Copyright © 2000 by Rex Page
9
Theorem — or[x, y, …,True, …] = True
Theorem (orn)
nN. length ys = n or (ys ++ ([True] ++ xs)) = True
Proof
P(n) length ys = n or (ys ++ ([True] ++ xs)) = True
Base case: P(0) length ys = 0 or(ys ++ ([True] ++ xs)) = True
length ys = 0
ys = [ ]
zero len theorem
or(ys ++ ([True] ++ xs)) = or([ ] ++ ([True] ++ xs)) substitution
= or ([True] ++ xs)
++.[]
= True
or1
Inductive case: P(n) P(n+1)
… next slide
CS 1813 Discrete Mathematics, Univ Oklahoma
Copyright © 2000 by Rex Page
10
Theorem — or[x, y, …,True, …] = True
Inductive Case
Predicate to prove for inductive case
P(n+1) length ys = n+1 or (ys ++ ([True] ++ xs)) = True
length ys = n+1
ys [ ]
zero len theorem
ys = y: zs length zs = n
:len corollary
or(ys ++ ([True] ++ xs)) = or((y:zs) ++ ([True] ++ xs))
subst
length zs = n
= or(y:(zs ++ ([True] ++ xs))) length zs = n
(++).:
= (y \/ (or(zs ++ ([True] ++ xs)))) length zs = n
(foldr).:
= (y \/ True) length zs = n
P(n)
induction hypothesis
= (y \/ True) True
subst
= True
id, null
Conclude: nN. P(n)
principle of induction
CS 1813 Discrete Mathematics, Univ Oklahoma
Copyright © 2000 by Rex Page
qed
11
End of Lecture
CS 1813 Discrete Mathematics, Univ Oklahoma
Copyright © 2000 by Rex Page
12
© Copyright 2026 Paperzz