Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 9 CS 1813 – Discrete Mathematics

Similar presentations


Presentation on theme: "Lecture 9 CS 1813 – Discrete Mathematics"— Presentation transcript:

1 Lecture 9 CS 1813 – Discrete Mathematics
Lecture 9 - CS 1813 Discrete Math, University of Oklahoma 12/10/2018 Lecture 9 CS 1813 – Discrete Mathematics Predicate Calculus Propositions Plus Plus CS Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page

2 Lecture 9 - CS 1813 Discrete Math, University of Oklahoma
12/10/2018 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 Must be specified Otherwise, all bets off — muchas contradicciónes Non-empty Empty universe calls for special handling Default assumption: non-empty universe CS Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page

3 Predicate on a Program for Sums
Lecture 9 - CS 1813 Discrete Math, University of Oklahoma 12/10/2018 Predicate on a Program for Sums sum::[Rational] -> Rational function-type arrow, not implication Input (argument) Sequence of Rational values (ratios of whole numbers) Type: [Rational] — square brackets indicate sequence-type Output (value delivered): Rational — not a sequence (so, no brackets) Predicate S(n)  sum[x1, x2, …, xn] = x1 + x2 + … + xn S is a predicate — each equation S(n) is a different proposition Each S(n) is either True or False S(3) is the (atomic) proposition sum[x1, x2, x3] = x1 + x2 + x3 Universe of discourse (collection of values that parameterize S) Natural numbers N = {0, 1, 2, … } — a collection of infinite size Why not T([x1, x2, … xn]) instead of S(n)? Nothing wrong with T([x1, x2, … xn]) Universe of discourse for T: finite sequences of numbers Universe of discourse for S: counting numbers {0, 1, 2, …} CS Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page

4 Predicate on a Program for Maximums
Lecture 9 - CS 1813 Discrete Math, University of Oklahoma Predicate on a Program for Maximums 12/10/2018 maximum :: [String] -> String Argument Sequence of strings (String means sequence of characters) Type: [String] — square brackets indicate sequence-type Value: String — not a sequence of strings (so, no brackets) Predicate B(n, k)  maximum[s1, s2, …, sn]  sk B is a predicate — each B(n, k) is a proposition (True or False) B(4,2) is the (atomic) proposition maximum[s1, s2, s3 , s4]  s2 Universe of discourse (collection of values that parameterize B) Pairs of non-zero natural numbers {(1,1), (2,1), (2,2), (3,1), … } where second number in pair does not exceed first Why not C([s1, s2, … sn], sk) instead of B(n, k)? C is ok, but depends on the strings si — not just on n and k Proofs involving B must take care to encompass arbitrary si’s Note: Proofs will work for any type of class Ord, not just String What is the universe of discourse for C([s1, s2, … sn], sk)? CS Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page

5 Another Predicate about Maximums
Lecture 9 - CS 1813 Discrete Math, University of Oklahoma Another Predicate about Maximums 12/10/2018 maximum :: [String] -> String Argument Sequence of strings (String means sequence of characters) Type: [String] — square brackets indicate sequence-type Value: String — not a sequence of strings (so, no brackets) Predicate E(n, k)  maximum[s1, s2, …, sn] = sk E is a predicate —each equation E(n, k) is an atomic proposition Each E(n, k) is either True or False E(4,1) is the proposition maximum[s1, s2, s3 , s4] = s1 Universe of discourse (collection of values that parameterize E) Pairs of non-zero natural numbers {(1,1), (2,1), (2,2), (3,1), … } where second number in pair does not exceed first Is E(n, k) usually True or usually False? Would you expect E(n, k) to be True for some pairs (n, k)? Given a sequence of strings [s1, s2, … sn], would you expect to be able to find any values of k for which E(n, k) is true? CS Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page

6 Predicates about a Sorting Program
Lecture 9 - CS 1813 Discrete Math, University of Oklahoma 12/10/2018 Predicates about a Sorting Program qsort :: Ord a => [a] -> [a] Argument Sequence of type [a] — where a is a type of class Ord Value — Also a sequence of type [a] Predicates L(n)  length(qsort[a1, a2, …, an] ) = n L is a predicate — each equation L(n) is a proposition Universe of discourse: Natural numbers N = {0, 1, 2, … } What does [a1, a2, …, an] mean when n = 0 Would you expect L(n) to be True, regardless of the ai’s? I(n, k)  (qsort[a1, a2, …, an] = [b1, b2, …, bn] )  (bk  bk+1 ) I is a predicate — each I(n, k) is a proposition (non-atomic, btw) Universe of discourse: Pairs of non-zero natural numbers where first number exceeds second {(2,1), (3,1), (3,2), (4,1), … } For what pairs would you expect I(n, k) to be True? R(n, j, k)  (qsort[a1, a2, …, an] = [b1, b2, …, bn] )  (aj = bk) Universe of discourse? Places in universe where R(n, j, k) is True? CS Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page

7 Predicates about Concatenation
Lecture 9 - CS 1813 Discrete Math, University of Oklahoma 12/10/2018 Predicates about Concatenation (++) :: [a] -> [a] -> [a] Two arguments Sequences of type [a] — where a can be any type Value — Also a sequence of type [a] Predicates C(n, m)  length( [a1, a2, …, an] ++ [b1, b2, …, bm] ) = n + m C is a predicate — each equation C(n, m) is a proposition Universe of discourse: Pairs of natural numbers {(0,0), (1,0), … } Would you expect C(n, m) to be True? A(xs, ys, zs)  xs ++ (ys ++ zs) = (xs ++ ys) ++ zs A is a predicate — each equation A(xs, ys, zs) is a proposition Universe of discourse: Triples of sequences of type [a] For what sequences would you expect A(xs, ys, zs) to be True? CS Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page

8  — the Universal Quantifier, Forall
Lecture 9 - CS 1813 Discrete Math, University of Oklahoma 12/10/2018  — 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 every value of x in the universe of discourse False if there is some value 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[x1, x2, …, xn] = x1 + x2 + … + xn 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 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page

9 Another Example with Forall  — the Universal Quantifier
Lecture 9 - CS 1813 Discrete Math, University of Oklahoma 12/10/2018 Another Example with Forall  — the Universal Quantifier B — predicate about maximum B(n, k)  maximum[s1, s2, …, sn]  sk Universe of discourse Pairs of non-zero natural numbers where second number in pair does not exceed first U = {(n, k)  N N | 0  k  n} = {(1,1), (2,1), (2,2), (3,1), … } OK, so we haven’t gotten to set theory yet — Sabe, verdad? (n, k).B(n, k) A predicate calculus formula because each B(n, k) is a proposition, which is a portion of predicate calculus Do you expect (n, k).B(n, k) to be True? Other ways to write (n, k).B(n, k) nN . kN . (0  k)  (k  n)  B(n, k) nN, n  0 . kN, 0  k  n . B(n, k) Note nesting and direct specification of universe of discourse Technically, U = N N in this case, but values of B(n, k) outside the old U are immaterial. CS Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page

10 Lecture 9 - CS 1813 Discrete Math, University of Oklahoma
12/10/2018 End of Lecture 9 CS Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page


Download ppt "Lecture 9 CS 1813 – Discrete Mathematics"

Similar presentations


Ads by Google