Download presentation
Presentation is loading. Please wait.
Published byAmbrose Booth Modified over 8 years ago
1
CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 1 Lecture 14 CS 1813 – Discrete Mathematics A Little Bit of Set Theory
2
CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 2 What Is a Set? Axiomatic approach Postulate the existence of Empty set — a set with no elements Infinite set — a set with an infinite number of elements Define some set operations Build all other sets from this starting point Naïve approach A set is a collection of elements There is some way to determine whether or not an element resides in a set Avoid contradictions by being specific about the universe of discourse path we’ll follow
3
CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 3 Notation for Sets — Explicit Enumeration {2, 3, 5, 7, 11} 2 {2, 3, 5, 7, 11} — stylized epsilon denotes “element of” 5 {2, 3, 5, 7, 11} 1 {2, 3, 5, 7, 11} — x A (x A) “Long Tall Sally” {2, 3, 5, 7, 11} {{“Wha’d I Say”, “Nadine”}, {“Peer Gynt”, “Moonlight Sonata”, “Finlandia”}} = A {“Wha’d I Say”, “Nadine”} A “Moonlight Sonata” A { }— the empty set, which has no elements none … nada … the number of elements in { } is zero 3 { } x { } — no matter what x stands for = { } — stylized Greek letter phi denotes empty set
4
CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 4 Notation for Sets — Set Comprehension { x | x {2, 3, 5, 7, 11} x 4} {5, 7, 11} { x + x | x {2, 3, 5, 7, 11} x 3 x 11} {6, 10, 14} {f x | x A, p x} Denotes set whose elements have the form (f x), where x comes from A and (p x) has the value True To avoid contradictions Predicate (or context) specifies universe of discourse Examples of invalid set comprehensions {X | X is a set} {X | X X} Universe of discourse is missing in these examples
5
CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 5 Set Operations — Subset, Equality A is a subset of B Definition: A B x. (x A x B) Examples {2, 3, 5, 7} {2, 3, 5, 7, 11} A — regardless of what set A stands for Set equality Definition: A = B (A B) (B A) A is a proper subset of B Definition: A B (A B) (A B)
6
CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 6 Set Operations — Union Union of A and B Definition: A B = {x | x A x B} Another way to say it: x. (x A B) (x A x B) Examples {2, 3, 5} {5, 7, 11} = {2, 3, 5, 7, 11} A = A — regardless of what set A stands for { , { }} { {{ }}, { , { }} } = { , { }, {{ }}, { , { }} } Big Union — of a set of sets Definition: S = {x | A S. x A} Another way to say it: x. (x S) ( A. A S x A) Examples { {2, 3, 5}, {5, 7, 11}, {2, 5, 13, 17} } = {2, 3, 5, 7, 11, 13, 17} { {c, c 2 } | c {1, 2, …} a {1, 2, …}. b {1, 2, …}. a 2 +b 2 =c 2 } = hypotenuses and their squares
7
CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 7 Set Operations — Intersection Intersection of A and B Definition: A B = {x | x A x B} Examples {2, 3, 5, 7} {2, 7, 11} = {2, 7} A = — regardless of what set A stands for {Crazy} {s | Patsy Cline sang s} {s | Willie Nelson wrote s} where the universe of discourse is songs Big Intersection — of a set of sets Definition: S = {x | A S. x A} Examples { {2, 3, 5, 11}, {5, 7, 11}, {2, 5, 7, 11, 13, 17} } = {5, 11} { {x n | x {1, 2, …}} | n {0, 1, 2, …} } = {1} Disjoint Definition: A and B are disjoint A B =
8
CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 8 Set Operations — Difference, Complement Difference of A and B Definition: A – B = {x | x A x B} Examples {2, 3, 5, 7} – {2, 7, 11} = {3, 5} A – = A — regardless of what set A stands for – A = — regardless of what set A stands for {Georgia} {s | Ray Charles sang s} – {s | Hank Wms wrote s} where the universe of discourse is songs Complement of A Definition: A’ = U – A where U is the universe of discourse Examples, universe of discourse = {0, 1, 2, …} {2, 3, 4, 5}’ = {0, 1} {6, 7, 8, …} {2x | x {0, 1, 2, …} }’ = {2x+1 | x {0, 1, 2, …} }
9
CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 9 Set Operations — Power Set Power set of A Definition: P(A) = {S | S A} Examples P({2, 3, 5}) = { , {2}, {3}, {5}, {2,3}, {2,5}, {3,5}, {2,3,5}} P( ) = { } Theorem: If A has n elements, P(A) has 2 n elements –This will be proved later, using mathematical induction How many elements in P(P( ))? –P(P( )) = { , { } } How many elements in P(P(P( )))? –P(P(P( ))) = { , { }, {{ }}, { , { }} } How many elements in P(P(P(P( ))))? –2 4 — that is, 16 How many elements in P(P(P(P(P( )))))? –2 16 — that is, quite a few (around 65,000)
10
CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 10 Set Operations — Cartesian Product Also Known as Cross Product Cartesian product of A and B Definition: A B = {(a, b) | a A b B} Note: This definition is problematic because it doesn’t say what the universe of discourse is for the pairs (a, b). –Problem can be solved by defining pairs in terms of subsets –Solution is tedious, and not especially enlightening A has n elements, B has m elements |– A B has n m elements Examples {2, 3} {3, 5, 7} = {(2,3), (2,5), (2,7), (3,3), (3,5), (3,7)} {0, 1, 2, …} {1, 2, 3, …} = pairs of non-negative natural numbers with second component non-zero A P(A) has how many elements? (assume A has n elements) - A P(A) has n 2 n elements if A has n elements
11
CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 11 Tools for Computing with Sets Domain of application Finite sets All elements have same type Type of elements is the class Eq and in the class Show Set operators defined in Stdm module Make set — normalizeSet :: Eq a => [a] -> Set a Subset — subset :: (Eq a, Show a) => Set a -> Set a -> Bool Equality — setEq :: (Eq a, Show a) => Set a -> Set a -> Bool Union — (+++) :: (Eq a, Show a) => Set a -> Set a -> Set a Intersection — ( ) :: (Eq a, Show a) => Set a -> Set a -> Set a Difference — (~~~) :: (Eq a, Show a) => Set a -> Set a -> Set a Cartesian Product crossproduct :: (Eq a, Show a, Eq b, Show b) => Set a -> Set b -> Set(a,b) Power Set — powerset :: (Eq a, Show a) => Set a -> Set(Set a)
12
CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 12 Subset Chain Rule (by natural deduction) Theorem (Subset Chain Rule) A B, B C |– A C Proof A B {def fwd } x. x A x B B C {def fwd } x. x B x C {Thm27} x. x A x C {def bkw } A C qed Corollary (Set Equality Chain Rule) A = B, B = C |– A = C Proof - recall that A = B means (A B) (B A)
13
CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 13 Union is Commutative (by equational reasoning) Definitions A B x. (x A x B) A = B (A B) (B A) Theorem {comm }: (A B) = (B A) A B = {x | x A x B} {def } = {x | x B x A} {comm } = B A {def } qed
14
CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 14 Pointwise Proofs of Set Equality Definitions A B x. (x A x B) A = B (A B) (B A) So, A = B can be proved point by point Prove ( x. (x A x B)) ( x. (x B x A)) That is, prove x. (x A x B) (x B x A) Predicate calculus law 3.11 That is, prove x. (x A x B) Equivalence law of propositional calculus That is, prove (x A x B), where x is arbitrary Proof does not depend on the value of x
15
CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 15 DeMorgan’s Law for Union a pointwise, equational proof Theorem (DeM ) (U – (A B)) = ((U – A) (U – B)) Proof x U – (A B) x U x A B{def –} x U (x A B) {def } x U ((x A) (x B)) {def } x U (x A) (x B) {DeM } x U x U (x A) (x B) { idem} x U (x A) x U (x B) { comm} x (U – A) x U (x B){def –} x (U – A) x (U – B) {def –} x (U – A) (U – B){def } qed Proofs skips a few steps Where?
16
CS 1813 Discrete Mathematics, Univ Oklahoma Copyright © 2000 by Rex Page 16 End of Lecture
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.