Download presentation
Presentation is loading. Please wait.
1
Lecture 11 CS 1813 – Discrete Mathematics
Lecture 12 - CS 1813 Discrete Math, University of Oklahoma 1/2/2019 Lecture 11 CS 1813 – Discrete Mathematics Algebra Every Which Way Boolean Algebra Predicate Algebra Software Algebra CS Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page
2
Algebraic Laws of Predicate Calculus
Lecture 12 - CS 1813 Discrete Math, University of Oklahoma 1/2/2019 Algebraic Laws of Predicate Calculus x not free in q (x. P(x)) (y. Q(y)) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) y not in f(x) (x. f(x)) = (y. f(y)) {R} (x. f(x)) = (y. f(y)) {R} CS Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page
3
Equational Reasoning with Predicates
Lecture 12 - CS 1813 Discrete Math, University of Oklahoma 1/2/2019 Equational Reasoning with Predicates Theorem IX ( (x. P(x)) (y. Q(y)) ) = (x. y. P(x) Q(y) ) Proof of Theorem IX (x. P(x)) (x. Q(x)) = ((x. P(x))) (x. Q(x)) {implication} = (x. P(x)) (x. Q(x)) {3.6} = x. ( (P(x)) (x. Q(x)) ) {3.10} = x. ( (x. Q(x)) (P(x)) ) { comm} = x. ( (y. Q(y)) (P(x)) ) {R} = x. y. ( Q(y) (P(x)) ) {3.10} = x. y. ( (P(x)) Q(y) ) { comm} = x. y. ( P(x) Q(y) ) {implication} qed CS Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page
4
Equational Reasoning about Software
Lecture 12 - CS 1813 Discrete Math, University of Oklahoma 1/2/2019 Equational Reasoning about Software Algebraic laws of sequence construction (x: []) = [x] :[] (xs [ ] ) = (x. ys. xs = (x: ys) ) -- (:) Informally ( x : [x1, x2, …] ) = [x, x1, x2, …] -- (: …) Sequence length – an inductive definition length(x: xs) = 1 + length xs (length).: length[ ] = (length).[] Theorem (len0). xs::[a]. length xs 0 We are going to accept this theorem without proof Think of it as axiomatic CS Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page
5
Zero Length Means Empty
Lecture 12 - CS 1813 Discrete Math, University of Oklahoma Zero Length Means Empty 1/2/2019 length :: [a] -> Int length(x: xs) = 1 + length xs (length).: length[ ] = (length).[] Theorem (len 0 [ ]). length xs = 0 xs = [ ] Proof, part 1 (): xs = [ ] length xs = 0 length xs = length [ ] assumption: xs = [ ] = (length).[] Proof, part 2 (): xs [ ] length xs 0 (contrapositive) = length(x: ys) (:) - (x. ys. xs = (x: ys)) = 1 + length ys (length).: (len0) = nd grade arith nd grade arith Corollary (:len). length xs 0 xs [ ] x. ys. (xs = (x: ys)) ((length xs) = ((length ys) + 1)) We’ll use this theorem many, many times CS Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page
6
Reasoning about Inductive Equations
Lecture 12 - CS 1813 Discrete Math, University of Oklahoma 1/2/2019 Reasoning about Inductive Equations sum :: Num a => [a] -> a Two equations any good sum function should satisfy sum(x: xs) = x + sum xs (sum).: sum[ ] = (sum).[] Pleasant surprise These two equations are enough to completely define sum Just use equational reasoning sum[7, 19, -12] = sum(7: [19, -12]) (:) = 7 + sum([19, -12]) (sum).: = 7 + sum(19: [-12]) (:) = 7 + (19 + sum([-12])) (sum).: = 7 + (19 + sum(-12: [ ])) (:) = 7 + (19 +((-12) + sum[ ])) (sum).: = 7 + (19 + ((-12) + 0)) (sum).[] = nd-grade arithmetic CS Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page
7
But What About sum[x1, x2, … xn]?
Lecture 12 - CS 1813 Discrete Math, University of Oklahoma 1/2/2019 But What About sum[x1, x2, … xn]? Theorem proved sum[7, 19, -12] = 14 Theorem that could have been proved with essentially the same argument Universe of discourse for addends: a is a type of class Num x1, x2, x3 :: a . sum[x1, x2, x3] = x1 + (x2 + (x3 + 0)) Theorem that should be proved nN Note: N = {0, 1, 2 …} xk :: a . sum[x1, x2, … xn] = x1+ (x2 + (x3 + … (xn-1 + (xn + 0)) …)) For any fixed value of n, reason as before Proof will have 2n+1 steps But, we want to prove it for all possible values of n, not just those for which we have time to do a proofs with 2n+1 steps Conclusion Relying on a new proof for each n is not good enough Must find a better way CS Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page
8
The Principle of Mathematical Induction
Lecture 12 - CS 1813 Discrete Math, University of Oklahoma 1/2/2019 The Principle of Mathematical Induction Universe of discourse: N = {0, 1, 2, …} Predicate P P(n) is a proposition whenever nN Want to prove: nN. P(n) That is, to prove that the proposition P(n) is True for all natural numbers n Principle of Induction Prove: P(0) Prove: nN. P(n) P(n+1) Conclude: nN. P(n) THE SINGLE MOST IMPORTANT CONCEPT YOU WILL LEARN THIS YEAR, NEXT YEAR, OR THE YEAR AFTER THAT principle of induction This is a subtle idea. Only P(0) is proven directly. The rest gives a template for constructing a proof of P(1) or P(1000) CS Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page
9
Lecture 12 - CS 1813 Discrete Math, University of Oklahoma
1/2/2019 sum works! P(0) n.P(n)P(n+1) {Ind} n. P(n) Induction Principle of Induction Prove: P(0) Prove: P(n) P(n+1), n arbitrary Conclude: nN. P(n) Define P(n) to be the following proposition sum[x1, x2, … xn] = x1+ (x2 + (x3 + … (xn-1 + (xn + 0)) …)) What about P(0)? P(0) says this: sum[ ] = 0 True because that is what the equation (sum).0 says Now prove the implication P(n) P(n+1) The implication is always True when P(n) is False So, we only need to prove that P(n+1) is True when P(n) is True CS Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page
10
Lecture 12 - CS 1813 Discrete Math, University of Oklahoma
1/2/2019 Coup de Grâce P(n +1) is the proposition sum[x1, x2, … xn+1] = x1+ (x2 + (x3 + … (xn + (xn+1 + 0)) …)) sum[x1, x2, … xn+1] = sum(x1 : [x2, … xn+1]) (: …) = x1 + (sum[x2, … xn+1]) (sum).: = x1 + (x2 + (x3 + … (xn + (xn+1 + 0)) …)) P(n) That is sum[x1, x2, … xn+1] = x1 + (x2 + (x3 + … (xn + (xn+1 + 0)) …)) But, that is exactly what P(n+1) says This proves the implication P(n) P(n+1) Conclude nN. P(n) — by the Principle of Induction That is: nN. sum[x1, x2, … xn] = x1+ (x2 + (x3 + … (xn-1 + (xn + 0)) …)) qed CS Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page
11
Lecture 12 - CS 1813 Discrete Math, University of Oklahoma
1/2/2019 End of Lecture CS Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.