Sets Reading: EC 3.1-3.3 Peter J. Haas INFO 150 Fall Semester - - PowerPoint PPT Presentation

sets
SMART_READER_LITE
LIVE PREVIEW

Sets Reading: EC 3.1-3.3 Peter J. Haas INFO 150 Fall Semester - - PowerPoint PPT Presentation

Sets Reading: EC 3.1-3.3 Peter J. Haas INFO 150 Fall Semester 2019 Lecture 11 1/ 21 Sets Definitions Defining Sets Set Operations The Inclusion-Exclusion Principle Cartesian Products The Power Set Lecture 11 2/ 21 Some Common Sets


slide-1
SLIDE 1

Sets

Reading: EC 3.1-3.3 Peter J. Haas INFO 150 Fall Semester 2019 Lecture 11 1/ 21
slide-2
SLIDE 2 Sets Definitions Defining Sets Set Operations The Inclusion-Exclusion Principle Cartesian Products The Power Set Lecture 11 2/ 21
slide-3
SLIDE 3

Some Common Sets

Loose definition: A set is a collection of objects (called members or elements) I This loose general definition can lead to paradoxes (e.g., Russell’s Paradox) I To stay out of trouble, we will work with a small number of well-understood sets Basic Sets I N = {0, 1, 2, 3, . . .}: The set of natural numbers I Z = {. . . , 3, 2, 1, 0, 1, 2, 3, . . .}: The set of integers I Q: The set of rational numbers, e.g., ratios of integers such as 2 3 , 3 1 , 17 4 I R: The set of real numbers, i.e., decimal numbers with possibly infinite strings
  • f digits after the decimal point
Variations on Basic Sets I R+: The set of positive real numbers I R0: The set of nonnegative real numbers I Q+: The set of positive rationals I Q0: The set of nonnegative rationals I Z+: The set of positive integers I Z0: The same as N Lecture 11 3/ 21
slide-4
SLIDE 4

Subsets

Definitions for Subsets I x 2 A: The element x is a member of the set A I A ✓ B: A is a subset of B, i.e., every element in A is also in B I A = B: Set A and B contain exactly the same elements I ;: The empty set, i.e., the set that contains no elements I U: For any given discussion, all sets will be subsets of a larger set called the universal set or the universe Some Formal Definitions I A ✓ B: 8x 2 U, (x 2 A) ! (x 2 B) I A = B: A ✓ B and B ✓ A True or False? (If false, give a counterexample) I Z ✓ N I N ✓ Z I Q ✓ Z I Z ✓ Q I R ✓ Q I Q ✓ R Lecture 11 4/ 21 13 false L
  • 3)
True False I 3G ) 3 e

}

True False Ira ) True
slide-5
SLIDE 5

Digression: √ 2 is Irrational

Theorem p 2 is irrational Proof by Contradiction:
  • 1. Suppose the theorem is false
  • 2. Then we can write
p 2 = a b where a and b are relatively prime
  • 3. So 2 = a2
b2 , or a2 = 2b2
  • 4. Therefore a2 is even, which implies that a is even (see end of Lecture 7)
  • 5. Therefore a = 2k for some integer k
  • 6. So a2 = 4k2 = 2b2 and hence b2 = 2k2
  • 7. Therefore b2 is even, so that b is even
  • 8. Thus a and b are both even
  • 9. This contradicts the assumption that a and b are relatively prime
  • 10. Since assuming that the theorem is false leads to a contradiction, the theorem
must be true. Lecture 11 5/ 21 ( reduced form ) G
slide-6
SLIDE 6

More Examples

  • 1. {1, 2, 3, 4, 5} = {4, 2, 3, 1, 5} = {1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 5}
  • 2. {2, 4} ✓ {1, 2, 3, 4, 5} is true
  • 3. {1, 2, 3, 4, 5} ✓ {2, 4} is false
I E.g., 1 is a counterexample to “if x 2 {1, 2, 3, 4, 5}, then x 2 {2, 4}”
  • 4. ; ✓ {1, 2, 3, 4, 5} is true
I There is no counterexample to “if x 2 ;, then x 2 {1, 2, 3}” I The empty set is a subset of every set
  • 5. {John, Sue, Chen, Shankar} is a set containing 4 names
I U = the set of all first names of people
  • 6. {(1, 3), (2, 5), (3, 7)} is a set of ordered pairs
  • 7. {{3, 4}, {5, 6, 7}} is a set of sets
Lecture 11 6/ 21 a " bag " contain duplicates set considers
  • nly unique
elements
slide-7
SLIDE 7

Set-Builder Notation

Even natural numbers I {x : x 2 N and x is even} or I {x 2 N : x is even} or I {x 2 N : x = 2k for some k 2 N} (a property description) I {2k : k 2 N} (a form description) Intervals I {x 2 R : 2.1  x  2.6} or [2.1, 2.6] I {x 2 R : 2.1 < x < 2.6} or (2.1, 2.6) I {x 2 R : 2.1 < x  2.6} or (2.1, 2.6] I {x 2 R : 2.1  x < 2.6} or [2.1, 2.6) I {x 2 N : 3  x < 6} or [3, 6) = {3, 4, 5} Other examples: give an alternate description I {n 2 N : n has exactly two positive divisors} I {x 2 R : x2 + 1 = 0} Lecture 11 7/ 21 ° closed interval
  • pen
interval } semi

.

closed intervals Form description

¢

Sa . b : a , bane prime }
slide-8
SLIDE 8

Examples of Form Notation

  • 1. The set of integers that are multiples of 3: {3k : k 2 Z}
  • 2. The set of perfect square integers: {m2 : m 2 N} or {m2 : m 2 Z}
  • 3. The set of natural numbers that end in a 1: {10k + 1 : k 2 N}
  • 4. The set Q: { a
b : a 2 Z and b 2 Z+} Lecture 11 8/ 21 0,3 , 6 , u
  • O
, I , 4,9,
  • v
. 41121 ,
slide-9
SLIDE 9

Operations on Sets

Operations on Sets A and B
  • 1. Intersection A \ B: A \ B = {x 2 U : x 2 A and x 2 B}
  • 2. Union A [ B: A [ B = {x 2 U : x 2 A or x 2 B}
  • 3. Difference A B: A B = {x 2 U : x 2 A and x 62 B}
  • 4. Complement A0: A0 = {x 2 U : x 62 A} or A0 = U A
Definition Set A and B are disjoint if A \ B = ;. Example: Suppose U = {1, 2, . . . , 12}, A = {1, 2, 3, 4, 5}, B = {2, 4, 6, 8, 10} I A0 = I A \ B = I A [ B = I A B = I B A = I A \ {8, 10, 12} = I U0 = Lecture 11 9/ 21 {6,7 , . . . , 14 5443 { I , 43,4 , 3,6 , 8,10) I I , 3,53 I 6 , 8,10 } to
slide-10
SLIDE 10

BHT for Sets

Theorem For sets A, B, and C, the empty set ;, and the universal set U, the following properties hold: (a) Commutative A \ B = B \ A A [ B = B [ A (b) Associative (A \ B) \ C = A \ (B \ C) (A [ B) [ C = A [ (B [ C) (c) Distributive A \ (B [ C) = (A \ B) [ (A \ C) A [ (B \ C) = (A [ B) \ (A [ C) (d) Identity A \ U = A A [ ; = A (e) Negation A [ A0 = U A \ A0 = ; (f) Double negative (A0)0 = A (g) Idempotent A \ A = A A [ A = A (h) DeMorgan’s laws (A \ B)0 = A0 [ B0 (A [ B)0 = A0 \ B0 (i) Universal bound A [ U = U A \ ; = ; (j) Absorption A \ (A [ B) = A A [ (A \ B) = A (k) Complements U0 = ; ;0 = U (l) Compl. & neg. A B = A \ B0 Lecture 11 10/ 21 close

Relation

to

logic

U v
  • f
→ false n n u true

Duality principle

: u n ¢ s u n u u →
  • f
slide-11
SLIDE 11

Verification via Venn Diagrams

Example: U = {1, 2, . . . , 15, 16}, A = {1, 2, 5, 7, 9, 11, 13, 15}, B = {2, 3, 5, 7, 11, 13}, C = {1, 4, 9, 16} Example: Show that A \ (B [ C) = (A \ B) [ (A \ C) A B C U A B C U A B C U A B C U A B C U Lecture 11 11/ 21 1 2 4 6 5 7 8 9 10 11 12 13 14 15 16 3 A B C U Also: A \ (B [ C) ✓ B [ C
slide-12
SLIDE 12

Elementwise Proofs 1

Example 1: Prove that A ∩ B ⊆ A
  • 1. Let x ∈ A ∩ B
  • 2. Then x ∈ A and x ∈ B
  • 3. In particular, x ∈ A
  • 4. So (x ∈ A ∩ B) → (x ∈ A), and hence A ∩ B ⊆ A
Lecture 11 12/ 21

Definition

tlxeu :@

e A) → HEB)
slide-13
SLIDE 13

Elementwise Proofs 2

Example 2: Prove that A ∩ (B ∪ C) ⊆ (A ∩ B) ∪ (A ∩ C)
  • 1. Let x ∈ A ∩ (B ∪ C)
  • 2. Then x ∈ A and x ∈ B ∪ C
  • 3. Case 1: x ∈ B
3.1 Then x ∈ A ∩ B since x ∈ A and x ∈ B 3.2 Hence in (A ∩ B) ∪ (A ∩ C) by argument similar to Example 1
  • 4. Case 2: x ∈ C
4.1 Then x ∈ A ∩ C 4.2 Hence in (A ∩ B) ∪ (A ∩ C) by argument similar to Example 1
  • 5. In either case, x ∈ A ∩ (B ∪ C) implies that
x ∈ (A ∩ B) ∪ (A ∩ C) Lecture 11 13/ 21 formal Version : thou , # An LB uld )

get

B)YAK)

)

I
slide-14
SLIDE 14

Elementwise Proofs 3

Example 3: Prove that A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C) I By above result, it suffices to show that (A ∩ B) ∪ (A ∩ C) ⊆ A ∩ (B ∪ C) Lecture 11 14/ 21

Let

x a CAN B) U

@

not

  • i. show

that

NEA and case I :X a An B . then xe A exo B hence HEA Case 2 : exe Anc . Then xeA and C ' hence HEA so in both cases . XEA ' a . Show that XO BVC case I : xe An B , hence XEB > Xe BUC Laser : Xo Arc , hence X GC 3
  • X EA
and XE Bvc , hence 46 An L BUD
slide-15
SLIDE 15

Elementwise Proofs 4

Example 4: Prove that (A ⊆ B) ∧ (B ⊆ C) → (A ⊆ C)
  • 1. Let x ∈ A
  • 2. Then x ∈ B since A ⊆ B
  • 3. Hence x ∈ C since B ⊆ C
  • 4. So (x ∈ A) → (x ∈ C), and hence A ⊆ C
Lecture 11 15/ 21
slide-16
SLIDE 16

The Inclusion-Exclusion Principle

Definition n(A) = the number of elements in the set A Example I A = {2k : k 2 Z+ and k  15} and B = {3k : k 2 Z+ and k  10} I n(A) = n(B) = I A \ B = I n(A \ B) = I A [ B = I n(A [ B) = Theorem (The Inclusion-Exclusion Principle) Let sets A, B, and C be given. Then I n(A [ B) = n(A) + n(B) n(A \ B) I n(A[B[C) = n(A)+n(B)+n(C)n(A\B)n(A\C)n(B\C)+n(A\B\C) n(A) + n(B) + n(C) = n1 + n2 + n3 + 2n4 + 2n5 + 2n6 + 3n7 Lecture 11 16/ 21 2 4 6 8 9 10 12 16 3 A B U 15 21 27 18 24 30 14 20 22 26 28 A B C U F 3 } 2,416,410,13143^936,9 ) I since Any
  • 163
I 2,346,8 , 9,1914143 71-3
  • I
slide-17
SLIDE 17

Cartesian Products

Ordered pairs: Definition The Cartesian product A ⇥ B of sets A and B is defined as {(a, b) : a 2 A and b 2 B}. When both coordinates are taken from the same set A, we write A2 instead of A ⇥ A. Example: For second graph, the set of plotted points are {(x, y) 2 R2 : y = 3x 1} Example: Succinctly describe the sequence a1 = 2, a2 = 4, a3 = 8, . . . using ordered pairs (1, 2), (2, 4), (3, 8), etc.: Example: Describe all possible (sandwich, drink) orders where sandwiches are of type 1, 2, or 3 and drinks are A, B, C, or D: Example: Describe all possible pairs (type of A, type of B) of people you might encounter on the island of Liars and Truthtellers: Lecture 11 17/ 21 scn.sn ) : nett

I

Gbh ,3)xSA,B,4D3 49,13A } .
  • ( 417USD
,

:{

Liar , Truth teller }t=E4TlxE4T3
slide-18
SLIDE 18

Size of Cartesian Products

Example: A = {2, 4, 6, 8} and B = {1, 2, 3, 4, 5} A ⇥ B Elements of A Elements of B ! # 1 2 3 4 5 2 (2,1) (2,2) (2,3) (2,4) (2,5) 4 (4,1) (4,2) (4,3) (4,4) (4,5) 6 (6,1) (6,2) (6,3) (6,4) (6,5) 8 (8,1) (8,2) (8,3) (8,4) (8,5) B ⇥ A Elements of B Elements of A ! # 2 4 6 8 1 (1,2) (1,4) (1,6) (1,8) 2 (2,2) (2,4) (2,6) (2,8) 3 (3,2) (3,4) (3,6) (3,8) 4 (4,2) (4,4) (4,6) (4,8) 5 (5,2) (5,4) (5,6) (5,8) Theorem For all finite sets A and B, n(A ⇥ B) = n(A) · n(B). Lecture 11 18/ 21 n lAxB)=nlBxA )
slide-19
SLIDE 19

Cartesian Products Gone Wild!

Definition For any integer n 3, the structure (x1, x2, . . . , xn) is called an n-tuple. Definition Given sets S1, S2, . . . , Sn, the Cartesian product S1 ⇥ S2 ⇥ · · · ⇥ Sn is the set of all n-tuples (x1, x2, . . . , xn) such that x1 2 S1, x2 2 S2, . . . , xn 2 Sn. When S1, . . . , Sn are all equal to the same set S, we write Sn = S ⇥ S ⇥ · · · ⇥ S | {z } n terms . Theorem A For any finite sets S1, S2, . . . , Sk, n(S1 ⇥ S2 ⇥ · · · ⇥ Sk) = n(S1) · n(S2) · · · · n(Sk) Lecture 11 19/ 21

ex

:

slide-20
SLIDE 20

Examples: Cartesian Products and Sets of Sets

Example 1: Truth-table values for p, q, r, s: Example 2: 12 ⇥ 12 multiplication table, e.g., (2, 3, 6), (5, 1, 5), and so on: Example 3: List 4 elements of I {T, F}3: I S = {s 2 {0, 1}5 : s consists of three 0’s and two 1’s in some order} I {1, 2, 3, 4, 5} ⇥ {x, y, z} ⇥ {A, B, C, D}: Example 4: Sets of sets I Is {1, 2} ✓ {{1, 2}, {1, 3, 4}}? I Is {1, 2} 2 {{1, 2}, {1, 3, 4}}? I What is n
  • {{1, 2}, {3, 4}, {1, 3, 4}}
  • ?
I What element of S = {1, 2, 3, {1, 2}, {1, 3, 4}} is also a subset of S? I What are the elements of S? I What is n(S)? Lecture 11 20/ 21

5=17,03

IT

,f34=

5×5×5×5=24

5=514,12)

{ La

,b,4els1xfs3xlN

: ax 5- c) ka,b,axD :@ Des } '

I

first

.tk/T,f3e:lIIf).CT.f,f),lF,fDco,o,o,lil.Ct9QQDu,x.s),L5,7D

)

NO ! e. 9. lisnelanelementotheroght
  • hand
304 yes ~ 3 s g

4435123,9%43

" " 4
slide-21
SLIDE 21

The Power Set

Definition The power set of A is P(A) = {S : S ✓ A}. Example: For A = {1, 2, 3, 4}, list the elements of P(A) in an orderly manner P({1}) ; {1} P({1, 2}) ; {1} {2} {1, 2} P({1, 2, 3}) ; {1} {2} {1, 2} {3} {1, 3} {2, 3} {1, 2, 3} P({1, 2, 3, 4}) ; {1} {2} {1, 2} {3} {1, 3} {2, 3} {1, 2, 3} {4} {1, 4} {2, 4} {1, 2, 4} {3, 4} {1, 3, 4} {2, 3, 4} {1, 2, 3, 4} Some questions: I How large is P(A)? I If B = {2, 4, 6, 8}, how large is P(B)? I If C = {1, 2, 3, 4, 5}, how large is P(C)? Theorem B For any finite set A, if k = n(A), then n(P(A)) = 2k. Lecture 11 21/ 21 16 16 32