Download presentation
Presentation is loading. Please wait.
1
Lecture 12 CS 1813 – Discrete Mathematics
Lecture 15 - CS 1813 Discrete Math, University of Oklahoma 9/22/2018 Lecture 12 CS 1813 – Discrete Mathematics The Principle of Mathematical Induction ok … now we’re cooking with gas … CS Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page
2
A Little Theorem about Sequences
Lecture 15 - CS 1813 Discrete Math, University of Oklahoma 9/22/2018 A Little Theorem about Sequences Algebraic laws of sequence construction (x: []) = [x] :[] (xs [ ] ) = (x. ys. xs = (x: ys) ) -- (:) Informally ( x : [x1, x2, …] ) = [x, x1, x2, …] -- (: …) Algebraic laws of concatenation (++) :: [a] -> [a] -> [a] ([ ] ++ ys) = ys (++).[ ] ((x : xs) ++ ys) = (x : (xs ++ ys)) (++).: An equational argument Assume x :: a and xs :: [a] [x] ++ xs = (x : [ ]) ++ xs :[] = x : ([ ] ++ xs) (++).: = (x : xs) (++).[ ] What did this prove? ([x] ++ xs) = (x : xs) () CS Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page
3
Software Equations = Algebraic Laws
Lecture 15 - CS 1813 Discrete Math, University of Oklahoma 9/22/2018 Software Equations = Algebraic Laws foldr (the big picture) foldr () z [x1, x2, …, xn] = x1 (x2 … (xn-1 (xn z)) … ) Algebraic laws of foldr foldr :: (a -> b -> b) -> b -> [a] -> b foldr () z [ ] = z (foldr).[] foldr () z (x : xs) = x (foldr () z xs) (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) (or) = True \/ (foldr (\/) False xs) (foldr).: = (foldr (\/) False xs) \/ True ( comm) = True ( null) CS Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page qed
4
Theorem — or/singleton True
Lecture 15 - CS 1813 Discrete Math, University of Oklahoma 9/22/2018 Theorem — or/singleton True Corollary (or1c): or [True] = True Proof True = or ( [True] ++ [ ] ) (or1) = or ( True : [ ] ) () = or ( [True] ) :[] qed CS Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page
5
Theorem — or[x,True, …] = True
Lecture 15 - CS 1813 Discrete Math, University of Oklahoma 9/22/2018 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))) (or) = x \/ (foldr (\/) False ([] ++ ([True] ++ xs))) (foldr).: = x \/ (or([] ++ ([True] ++ xs))) (or) = x \/ (or([True] ++ xs)) (++).[] = x \/ True (or1) = True null qed Theorem (or1): or ([True] ++ xs) = True CS Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page
6
Theorem — or[x, y,True, …] = True
Lecture 15 - CS 1813 Discrete Math, University of Oklahoma 9/22/2018 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))) (or) = x \/(foldr (\/) False ([y] ++ ([True] ++ xs))) (foldr).: = x \/ (or([y] ++ ([True] ++ xs))) (or) = x \/ True (or2) = True null qed Theorem (or2): or ([x] ++ [True] ++ xs) = True CS Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page
7
Theorem — or[x, y, z,True, …] = True
Lecture 15 - CS 1813 Discrete Math, University of Oklahoma 9/22/2018 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))) (or) = x \/(foldr (\/) False ([y,z] ++ ([True] ++ xs))) (foldr).: = x \/ (or([y,z] ++ ([True] ++ xs))) (or) = x \/ True (or3) = True null qed Theorem (or3): or ([x, y] ++ [True] ++ xs) = True CS Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page
8
Theorem — or[x, y, z, w,True, …] = True
Lecture 15 - CS 1813 Discrete Math, University of Oklahoma 9/22/2018 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))) (or) = x \/(foldr (\/) False ([y,z,w] ++ ([True] ++ xs))) (foldr).: = x \/ (or([y,z,w] ++ ([True] ++ xs))) (or) = x \/ True (or4) = True 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 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page
9
Principle of Mathematical Induction another way to skin a cat
Lecture 15 - CS 1813 Discrete Math, University of Oklahoma 9/22/2018 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), … P(n) {n arbitrary} {I} n. P(n) Introduction P(0) n.P(n)P(n+1) {Ind} n. P(n) Induction Mathematical induction makes it easier 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 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page
10
Theorem — or[x, y, …,True, …] = True
Lecture 15 - CS 1813 Discrete Math, University of Oklahoma 9/22/2018 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 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page
11
Theorem — or[x, y, …,True, …] = True Inductive Case
Lecture 15 - CS 1813 Discrete Math, University of Oklahoma 9/22/2018 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 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page qed
12
Lecture 15 - CS 1813 Discrete Math, University of Oklahoma
9/22/2018 End of Lecture CS Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.