CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 1 CS 1813 – Discrete Mathematics Review of Predicate Calculus Set Theory Inductive.

Slides:



Advertisements
Similar presentations
– Alfred North Whitehead,
Advertisements

CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 1 Lecture 3 CS 1813 – Discrete Mathematics Truth Inference and the Logical Way.
CS 454 Theory of Computation Sonoma State University, Fall 2011 Instructor: B. (Ravi) Ravikumar Office: 116 I Darwin Hall Original slides by Vahid and.
Discrete Mathematics Lecture 4 Harper Langston New York University.
1 Section 3.3 Mathematical Induction. 2 Technique used extensively to prove results about large variety of discrete objects Can only be used to prove.
Mathematical Induction
Methods of Proof & Proof Strategies
Induction and recursion
A Brief Summary for Exam 1 Subject Topics Propositional Logic (sections 1.1, 1.2) –Propositions Statement, Truth value, Proposition, Propositional symbol,
Discrete Mathematics, Part II CSE 2353 Fall 2007 Margaret H. Dunham Department of Computer Science and Engineering Southern Methodist University Some slides.
1 Introduction to Abstract Mathematics Chapter 4: Sequences and Mathematical Induction Instructor: Hayk Melikya 4.1- Sequences. 4.2,
CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 1 Lecture 18 CS 1813 – Discrete Mathematics Loops Without Invariants Are Like.
CSE 311 Foundations of Computing I Lecture 8 Proofs and Set Theory Spring
Mathematical Preliminaries (Hein 1.1 and 1.2) Sets are collections in which order of elements and duplication of elements do not matter. – {1,a,1,1} =
CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 1 Lecture 10 CS 1813 – Discrete Mathematics Quantify What? Reasoning with Predicates.
Induction Proof. Well-ordering A set S is well ordered if every subset has a least element. [0, 1] is not well ordered since (0,1] has no least element.
DISCRETE COMPUTATIONAL STRUCTURES
ICS 253: Discrete Structures I Induction and Recursion King Fahd University of Petroleum & Minerals Information & Computer Science Department.
Methods of Proof Dr. Yasir Ali. Proof A (logical) proof of a statement is a finite sequence of statements (called the steps of the proof) leading from.
CSE 311 Foundations of Computing I Lecture 9 Proofs and Set Theory Autumn 2012 CSE
1 Introduction to Abstract Mathematics Predicate Logic Instructor: Hayk Melikya Purpose of Section: To introduce predicate logic (or.
CS 103 Discrete Structures Lecture 13 Induction and Recursion (1)
Discrete Mathematics CS 2610 August 22, Agenda Last class Propositional logic Logical equivalences This week Predicate logic & rules of inference.
CS 285- Discrete Mathematics Lecture 4. Section 1.3 Predicate logic Predicate logic is an extension of propositional logic that permits concisely reasoning.
Basic Definitions of Set Theory Lecture 23 Section 5.1 Wed, Mar 8, 2006.
Basic Definitions of Set Theory Lecture 24 Section 5.1 Fri, Mar 2, 2007.
CSE 311: Foundations of Computing Fall 2013 Lecture 8: Proofs and Set theory.
CompSci 102 Discrete Math for Computer Science March 13, 2012 Prof. Rodger Slides modified from Rosen.
CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 1 Lecture 14 CS 1813 – Discrete Mathematics A Little Bit of Set Theory.
Discrete Mathematical Structures: Theory and Applications 1 Logic: Learning Objectives  Learn about statements (propositions)  Learn how to use logical.
Week 15 - Wednesday.  What did we talk about last time?  Review first third of course.
CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 1 Lecture 17 CS 1813 – Discrete Mathematics How Does It Work in the Real World?
Chapter 2 1. Chapter Summary Sets (This Slide) The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions.
DISCRETE COMPUTATIONAL STRUCTURES CSE 2353 Fall 2010 Most slides modified from Discrete Mathematical Structures: Theory and Applications by D.S. Malik.
Chapter 5 1. Chapter Summary  Mathematical Induction  Strong Induction  Recursive Definitions  Structural Induction  Recursive Algorithms.
CS151: Mathematical Foundations of Computing Mathematical Induction.
Lecture 04 Set Theory Profs. Koike and Yukita
Advanced Algorithms Analysis and Design
PROGRAMMING IN HASKELL
Induction and recursion
PROGRAMMING IN HASKELL
PROGRAMMING IN HASKELL
PROGRAMMING IN HASKELL
Chapter 5 Induction and Recursion
Lecture 15 CS 1813 – Discrete Mathematics
CS 1813 – Discrete Mathematics
Lecture 12 CS 1813 – Discrete Mathematics
Lecture 13 CS 1813 – Discrete Mathematics
CS201: Data Structures and Discrete Mathematics I
PROGRAMMING IN HASKELL
CS 1813 – Discrete Mathematics
The Foundations: Logic and Proofs
CS201: Data Structures and Discrete Mathematics I
Lecture 16 CS 1813 – Discrete Mathematics
Quizzes CS 1813 – Discrete Mathematics
Induction and recursion
Lecture 9 CS 1813 – Discrete Mathematics
Lecture 11 CS 1813 – Discrete Mathematics
A Brief Summary for Exam 1
First Order Logic Rosen Lecture 3: Sept 11, 12.
CSCE 314: Programming Languages Dr. Dylan Shell
MA/CSSE 474 More Math Review Theory of Computation
Computer Security: Art and Science, 2nd Edition
Lecture 8 CS 1813 – Discrete Mathematics
CSCE 314: Programming Languages Dr. Dylan Shell
Advanced Analysis of Algorithms
CS201: Data Structures and Discrete Mathematics I
Logic Logic is a discipline that studies the principles and methods used to construct valid arguments. An argument is a related sequence of statements.
Mathematical Induction
Agenda Proofs (Konsep Pembuktian) Direct Proofs & Counterexamples
Presentation transcript:

CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 1 CS 1813 – Discrete Mathematics Review of Predicate Calculus Set Theory Inductive Definition Proof by Mathematical Induction

CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 2 What is a Predicate?  Predicate  Parameterized collection of propositions  P(x) Typically a different proposition for each x Universe of discourse –Values that x may take  Universe of discourse  Must be specified Otherwise, all bets off — muchas contradicciónes  Non-empty Empty universe calls for special handling Default assumption: non-empty universe

CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 3  — the Universal Quantifier, Forall   x.P(x)  This formula is a WFF of predicate calculus whenever P(x) is a WFF of predicate calculus  True if the proposition P(x) is True for all x’s in the universe of discourse  False if there is some x in the universe of discourse for which P(x) is False  Equivalent to forming the Logical And of all P(x)’s  Example – S predicate about sum  S(n)  sum[x 1, x 2, …, x n ] = x 1 + x 2 + … + x n   n.S(n) Universe of discourse: natural numbers N = {0, 1, 2, … }  n.S(n) means S(0)  S(1)  S(2)  … So, “  ” provides a way to write formulas that would contain an infinite number of symbols if written in propositional calculus notation (but infinitely long formulas aren’t WFFs)

CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 4  —the Existential Quantifier, There Exists   x.P(x)  This formula is a WFF of predicate calculus whenever P(x) is a WFF of predicate calculus  True if there is at least one x in the universe of discourse for which the proposition P(x) is True  False if  x.  P(x) is True  Equivalent to forming the Logical Or of all P(x)’s  Example – E predicate about maximum  E(n, k)  maximum[s 1, s 2, …, s n ] = s k   k.E(23, k) Universe of discourse: U = {1, 2, …, 23}  k.E(23, k) means E(23,1)  E(23,2)  …  E(23,23) Note: When U is finite, quantifiers not required –Clumsy to write big formulas without quantifiers, though –Without quantifiers, reasoning can be more complex, too

CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 5 Free Variables and Bound Variables  Variables in WFFs of predicate calculus  Denoted by lower-case letters  Examples of predicate calculus WFFs with variables F(p, q)  G(q, r)variables: p, q, r (  x.F(x))  (G(y)  H(y))variables: x, y (  x.F(x, y)  G(y))  (H(z)  K(x))variables: x, y, z  Free variables and bound variables  Let e stand for a WFF of predicate calculus  Bound variable  x. ex is bound in the formula  x. e  x. ex is bound in the formula  x. e  Free variables are variables that are not bound Which variables are free?

CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 6 Arbitrary Variables  A variable is arbitrary in a proof if it does not occur free in any undischarged assumption of that proof  Examples  x. F(x)  {  E} F(x) G(x, y)  {  I}  y. G(x, y) x arbitrary? P(x)  Q  {  E L } P(x)  {  I} P(x)  Q  P(x)  {  I}  x. P(x)  Q  P(x) x arbitrary? discharged Yes No Yes

CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 7  x. F(x) F(x) |– A {x not free in A}  {  E} A Inference Rules of Predicate Calculus...plus the inference rules of propositional calculus  x. F(x) {universe is not empty}  {  E} F(x) F(x) {x arbitrary}  {  I}  x. F(x) F(x)  {  I}  x. F(x) {  E} rule triggers discharge  x. F(x) {y not in F(x)}  {  R}  y. F(y)  x. F(x) {y not in F(x)}  {  R}  y. F(y) F(x) {x, y arbitrary, y not in F(x)}  {R} F(y) Renaming Variables Introducing/Eliminating Quantifiers

CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 8  x. F(x) F(x) |– A {x not free in A}  {  E} A  x. P(x)  Q(x)  {  E} P(x)  Q(x) Existential Elimination something like {  E} Theorem 31  x. P(x),  x. P(x)  Q(x) |–  x. Q(x) proof  {  E} Q(x)  {  E}  x. Q(x) {x not free in  x.Q(x)}  x. P(x) discharge  P(x)  x. Q(x)  x  U. Q(x) plays role of A in {  E} rule P plays role of F in {  E} rule {  I}

CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 9 Existential Incrimination it’s not legal, really Theorem 9 from Planet X:  x. P(x),  x. P(x)  Q(x) |–  x. Q(x) Proof Why not?  Suppose   U, where U is the domain of discourse for x  Is P(  )  Q(  ) True?  Maybe so, maybe not  “  x. P(x)  Q(x)” means P(  )  Q(  ) is True for at least one value   U  There may be many values   U where P(  )  Q(  ) is False  Counter-example that disproves the theorem  Universe of discourse = {0, 1}  P(0) = True, P(1) = True Note: (  x. P(x)) = True  Q(0) = True, Q(1) = FalseNote: (  x. P(x)  Q(x)) = True  But, (  x.  (P(x)  Q(x))) is also True Because P(1)  Q(1) is False  (  x. Q(x)) = False, because Q(1) = False QED

CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 10 ( ) x not free in q Algebraic Laws of Predicate Calculus (  x. P(x))  (  y. Q(y)) (  x. f(x))  (  y. f(y)){  R} (  x. f(x))  (  y. f(y)){  R} y not in f(x)

CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 11 Equational Reasoning with Predicates  Theorem ( (  x. P(x))  (  x. Q(x)) ) = (  x.  y. P(x)  Q(y) )  Proof of Theorem (  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 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 12 Equational Reasoning about Software  Algebraic law of sequence construction x : [x 1, x 2, …, x n ] = [x, x 1, x 2, …, x n ]-- (:)  Algebraic laws of concatenation (++) :: [a] -> [a] -> [a] [ ] ++ ys = ys -- (++).[] (x : xs) ++ ys = x : (xs ++ ys) -- (++).:  An equational argument [x] ++ xs = (x : [ ]) ++ xs (:) = x : ([ ] ++ xs) (++).: = x : xs (++).[]  What did this prove? Theorem (++ 1 ) [x] ++ xs = x : xs ( )

CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 13 More Software Equations  The big or (\/) :: Bool -> Bool -> Bool -- “little or” – satisfies Boolean laws for  or :: [Bool] -> Bool -- “big or” or = foldr (\/) False -- (or)  Theorem (or null 1 ) — or null/first element or ([True] ++ xs) = True or ([True] ++ xs) = or (True : xs) (++ 1 ) = foldr (\/) False (True : xs) (or) = True \/ (foldr (\/) False xs) (foldr).: = True (  null) qed foldr (the big picture) foldr (  ) z [x 1, x 2, …, x n ] = x 1  (x 2  …  (x n-1  (x n  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).:

CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 14 principleofinduction  Universe of discourse: N = {0, 1, 2, …}  Predicate P  P(n) is a proposition whenever n  N  Want to prove:  n  N. 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:  n  N. (P(n)  P(n+1))  Conclude:  n  N. P(n) The Principle of Mathematical Induction A way to prove P(n) for all values of n, without proving any P(n) directly except P(0)

CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 15 Theorem — or[x, y, …,True, …] = True  Theorem (or T )  n  N. 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 or 1 T  Inductive case: P(n)  P(n+1) … next slide

CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 16 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)  (y \/ True) (conj imp) = True  null  Conclude:  n  N. P(n) principle of induction induction hypothesis qed

CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 17 Strong Induction Basic Principle of Induction  Prove P(0) is true  Prove P(n+1) is true, n  N arbitrary Proof of P(n+1) may assume P(n) is true  Conclude  n  N. P(n)  What if proof of P(n+1) does not make use of P(n)? Conclusion  n  N. P(n) is still valid This would be a direct proof using the {  I} inference rule The principle of induction is a lever that makes the proof easier  Principle of Strong Induction  Prove P(n) for arbitrary n  N Twist: Can assume  k  D n. P(k), where D n = {k  N | k  n}  Conclude  n  N. P(n)  Getting Started: D 0 = { }  So, must prove P(0) from scratch (as with old principle of induction) Pretty good deal, eh? Strong Induction  n.(  m  n.P(m))  P(n)  {StrInd}  n.P(n)

CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 18 msort Termination Proof — inductive case  P(n)  (length xs) = n  (msort xs) terminates  length(msort xs) = n  Proof of P(n) for arbitrary n  {2, 3, 4, …} msort xs = msort(x1: x2: ws) (pattern matching) (length xs)  2 = merge (msort ys) (msort zs) (no operation) (msort).: where (ys, zs) = deal(x1: x2: ws) merge (msort ys) (msort zs) (msort).: msort (x1: x2: xs) = where (ys, zs) = deal(x1: x2: xs) Each step (matching, deal, msort twice, merge) takes a finite amount of time, so (msort xs) terminates length xs = length ys + length zs(dS) = length(msort ys) + length(msort zs) P(length ys), P(length zs) = length(merge (msort ys) (msort zs))(mT) = length(msort xs)(msort).:: – as in above proof length ys  length xs (dR) (msort ys) terminates – Why? (msort zs) terminates (similar argument) merge terminates (mT) qed (strong induction) Ind Hyp implies P(length ys) is True strong induction deal terminates (dS)

CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 19 Haskell Type Specifications  x, y, z :: Integer -- x, y, and z have type Integer  xs, ys :: [Integer]-- sequences with Integer elements  or :: [Bool] -> Bool -- function with one argument argument is sequence with Bool elems delivers value of type Bool  (++) :: [e] -> [e] -> [e] -- generic function with two arguments args are sequences with elems of same type type is not constrained (can be any type) delivers sequence with elements of same type as those in arguments  sum :: Num n => [n] -> n -- generic function with one argument argument is a sequence with elems of type n n must a type of class Num Num is a set of types with +, , … operations  powerSet :: (Eq e, Show e) => Set e -> Set(Set e) -- generic function with one argument argument is a set with elements of type e delivers set with elements of type (Set e) type e must be both class Eq and class Show Class Eq has == operator, Show displayable

CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 20 Inductive Definitions aka Recursive Equations sum :: Num n => [n] -> n sum(x: xs) = x + sum xs(sum).: sum[ ] = 0 (sum).[] Theorem: sum = foldr (+) 0 length :: [a] -> Int length(x: xs) = 1 + length xs (length).: length[ ] = 0(length).[] Theorem: length = foldr oneMore 0 where oneMore x n = 1 + n (++) :: [a] -> [a] -> [a] (x: xs) ++ ys = x: (xs ++ ys) (++).: [ ] ++ ys = ys(++).[] Theorem: xs ++ ys = foldr (:) ys xs concat :: [[a]] -> [a] concat(xs: xss) = xs ++ concat xss (concat).: concat[ ] = [ ](concat).[] Theorem: concat = foldr (++) [ ]

CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 21 Patterns of Computation Pattern: foldr (  ) z [x 1, x 2, …, x n-1, x n ] = x 1  ( x 2  … (x n-1  ( x n  z)) … ) foldr :: (a -> b -> b) -> b -> [a] -> b foldr (  ) z (x: xs) = x  foldr (  ) z xs(foldr).: foldr (  ) z [ ] = z(foldr).[] Pattern: map f [x 1, x 2, … x n ] = [f x 1, f x 2, … f x n ] map :: (a -> b) -> [a] -> [b] map f (x : xs) = (f x) : map f xs(map).: map f [ ] = [ ](map).[] Pattern: zipWith b [x 1, x 2, … x n ] [y 1, y 2, … y n ] = [b x 1 y 1, b x 2 y 2, … b x n y n ] Note: extra elements in either sequence are dropped zipWith :: (a -> b -> c) -> [a] -> [b] -> [c] zipWith b (x:xs) (y:ys) = (b x y): (zipWith b xs ys)(zipW).: zipWith b [ ] ys = [ ](zipW).[]-1 zipWith b xs [ ] = [ ] (zipW).[]-2

CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 22 Sets  {2, 3, 5, 7, 11} — explicit enumeration  2  {2, 3, 5, 7, 11} — stylized epsilon means “element of”   = { } — stylized Greek letter phi denotes empty set  {x | p x} — set comprehension  Denotes set with elements x, where (p x) is True  {f x | p x} — set comprehension  Denotes set with elements of form (f x), where (p x) is True  A  B   x. (x  A  x  B) — subset  A = B  (A  B)  (B  A) — set equality  A  B = {x | x  A  x  B} — union   S = {x |  A  S. x  A} — big union  A  B = {x | x  A  x  B} — intersection   S = {x |  A  S. x  A} — big intersection  A – B = {x | x  A  x  B} — set difference  A’ = U – A — complement (U = universe)  P(A) = {S | S  A} — power set  A  B = {(a, b) | a  A  b  B} — Cartesian product

CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 23 End of Lecture