34
Discrete Mathematics 1-3. Set Operations

1-3. Set Operations - SNUcglab.snu.ac.kr/lectures/09-1/discrete_math/dm09_slide1-3.pdf · Discrete Mathematics 1-3. Set Operations. Introduction to Set Theory ... Discrete Mathematics,

  • Upload
    ngokiet

  • View
    234

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 1-3. Set Operations - SNUcglab.snu.ac.kr/lectures/09-1/discrete_math/dm09_slide1-3.pdf · Discrete Mathematics 1-3. Set Operations. Introduction to Set Theory ... Discrete Mathematics,

Discrete Mathematics1-3. Set Operations

Page 2: 1-3. Set Operations - SNUcglab.snu.ac.kr/lectures/09-1/discrete_math/dm09_slide1-3.pdf · Discrete Mathematics 1-3. Set Operations. Introduction to Set Theory ... Discrete Mathematics,

Introduction to Set Theory

• A set is a new type of structure, representing an unordered collection (group, plurality) of zero or more distinct (different) objects.

• Set theory deals with operations between, relations among, and statements about sets.

Discrete Mathematics, Spring 2009 2

• Set theory deals with operations between, relations among, and statements about sets.

• Sets are ubiquitous in computer software systems.

• All of mathematics can be defined in terms of some form of set theory (using predicate logic).

Page 3: 1-3. Set Operations - SNUcglab.snu.ac.kr/lectures/09-1/discrete_math/dm09_slide1-3.pdf · Discrete Mathematics 1-3. Set Operations. Introduction to Set Theory ... Discrete Mathematics,

Basic notations for sets

• For sets, we’ll use variables S, T, U, …

• We can denote a set S in writing by listing all of its elements in curly braces:

− {a, b, c} is the set of whatever 3 objects are

Discrete Mathematics, Spring 2009 3

− {a, b, c} is the set of whatever 3 objects are denoted by a, b, c.

• Set builder notation: For any proposition P(x) over any universe of discourse, {x|P(x)} is the set of all x such that P(x).

Page 4: 1-3. Set Operations - SNUcglab.snu.ac.kr/lectures/09-1/discrete_math/dm09_slide1-3.pdf · Discrete Mathematics 1-3. Set Operations. Introduction to Set Theory ... Discrete Mathematics,

Basic properties of sets

• Sets are inherently unordered:

− No matter what objects a, b, and c denote, {a, b, c} = {a, c, b} = {b, a, c} ={b, c, a} = {c, a, b} = {c, b, a}.

Discrete Mathematics, Spring 2009 4

{b, c, a} = {c, a, b} = {c, b, a}.

• All elements are distinct (unequal);multiple listings make no difference!

− If a=b, then {a, b, c} = {a, c} = {b, c} = {a, a, b, a, b, c, c, c, c}.

− This set contains at most 2 elements!

Page 5: 1-3. Set Operations - SNUcglab.snu.ac.kr/lectures/09-1/discrete_math/dm09_slide1-3.pdf · Discrete Mathematics 1-3. Set Operations. Introduction to Set Theory ... Discrete Mathematics,

Infinite Sets

• Conceptually, sets may be infinite (i.e., not finite, without end, unending).

• Symbols for some special infinite sets:N = {0, 1, 2, …} The Natural numbers.

Discrete Mathematics, Spring 2009 5

N = {0, 1, 2, …} The Natural numbers.Z = {…, -2, -1, 0, 1, 2, …} The Zntegers.

R = The “Real” numbers, such as 374.1828471929498181917281943125…

• Infinite sets come in different sizes!

Page 6: 1-3. Set Operations - SNUcglab.snu.ac.kr/lectures/09-1/discrete_math/dm09_slide1-3.pdf · Discrete Mathematics 1-3. Set Operations. Introduction to Set Theory ... Discrete Mathematics,

Empty Set

• Definition:

A set which does not contain any elements is an empty set, denoted by ∅ or {} or {x|false}

Discrete Mathematics, Spring 2009 6

• Example: ¬∃x: x∈∅

Page 7: 1-3. Set Operations - SNUcglab.snu.ac.kr/lectures/09-1/discrete_math/dm09_slide1-3.pdf · Discrete Mathematics 1-3. Set Operations. Introduction to Set Theory ... Discrete Mathematics,

Subset and Superset

• Definition:

Let S and T be any two sets. S is a subset of T and T is a superset of S, denoted by S⊆T, if and only if every element of S is an element of T,

Discrete Mathematics, Spring 2009 7

every element of S is an element of T,

i.e., (∀x) ((x∈S) → (x∈T)).

• Example

∅⊆S, S⊆S.

Page 8: 1-3. Set Operations - SNUcglab.snu.ac.kr/lectures/09-1/discrete_math/dm09_slide1-3.pdf · Discrete Mathematics 1-3. Set Operations. Introduction to Set Theory ... Discrete Mathematics,

Set Equality

• Definition:

Let S and T be any two sets. S and T are declared to be equal if and only if they contain exactly the same elements, i.e. S=Tiff (S⊆ T) ∧ (S⊆ T)

Discrete Mathematics, Spring 2009 8

• Note that it does not matter how the set is defined or denoted.Example:

The set {1, 2, 3, 4} = {x | x is an integer where x>0 and x<5 } = {x | x is a positive integer whose square is >0 and <25}

Page 9: 1-3. Set Operations - SNUcglab.snu.ac.kr/lectures/09-1/discrete_math/dm09_slide1-3.pdf · Discrete Mathematics 1-3. Set Operations. Introduction to Set Theory ... Discrete Mathematics,

Proper Subsets & Supersets

• Definition:

Let S and T be any two sets. S is a proper subset of T (T is a proper superset of S), denoted by S⊂T iff S⊆T and S ≠T.

Discrete Mathematics, Spring 2009 9

iff S⊆T and S ≠T.

S

TVenn Diagram equivalent of S⊂T

Example:

{1,2} ⊂{1,2,3}

Page 10: 1-3. Set Operations - SNUcglab.snu.ac.kr/lectures/09-1/discrete_math/dm09_slide1-3.pdf · Discrete Mathematics 1-3. Set Operations. Introduction to Set Theory ... Discrete Mathematics,

Sets Are Objects, Too!

• The objects that are elements of a set may themselves be sets.

• Example:

Let S={x | x ⊆ {1,2,3}}

Discrete Mathematics, Spring 2009 10

Let S={x | x ⊆ {1,2,3}}then S={∅,

{1}, {2}, {3},{1,2}, {1,3}, {2,3},{1,2,3}}

• Note that 1 ≠ {1} ≠ {{1}} !!!!

Page 11: 1-3. Set Operations - SNUcglab.snu.ac.kr/lectures/09-1/discrete_math/dm09_slide1-3.pdf · Discrete Mathematics 1-3. Set Operations. Introduction to Set Theory ... Discrete Mathematics,

Basic Set Relations: Member of

• Definition:

− x∈S (“x is in S”) is the proposition that object x is an ∈lement or member of set S.

• e.g. 3∈N, “a”∈{x | x is a letter of the alphabet}

Discrete Mathematics, Spring 2009 11

• e.g. 3∈N, “a”∈{x | x is a letter of the alphabet}

− Can define set equality in terms of ∈ relation:∀S,T: S=T ↔ (∀x: x∈S ↔ x∈T)“Two sets are equal iff they have all the same members.”

• x∉S :≡ ¬(x∈S) “x is not in S”

Page 12: 1-3. Set Operations - SNUcglab.snu.ac.kr/lectures/09-1/discrete_math/dm09_slide1-3.pdf · Discrete Mathematics 1-3. Set Operations. Introduction to Set Theory ... Discrete Mathematics,

Cardinality and Finiteness

• |S| (read “the cardinality of S”) is a measure of how many different elements S has.

• E.g., |∅|=0, |{1,2,3}| = 3, |{a,b}| = 2,|{{1,2,3},{4,5}}| = 2

Discrete Mathematics, Spring 2009 12

|{{1,2,3},{4,5}}| = 2

• If |S|∈N, then we say S is finite.Otherwise, we say S is infinite.

• What are some infinite sets we’ve seen?

Page 13: 1-3. Set Operations - SNUcglab.snu.ac.kr/lectures/09-1/discrete_math/dm09_slide1-3.pdf · Discrete Mathematics 1-3. Set Operations. Introduction to Set Theory ... Discrete Mathematics,

Power Set

• Definition:

Let S be a set. The power set ℘(S) of a set S is the set of all subsets of S. ℘(S) = {x | x⊆S}.

Example:

Discrete Mathematics, Spring 2009 13

• Example:

℘({a,b}) = {∅, {a}, {b}, {a,b}}.

• Sometimes ℘(S) is written 2S.Note that for finite S, |℘(S)| = 2|S|.

• It turns out that |P(N)| > |N|.There are different sizes of infinite sets!

Page 14: 1-3. Set Operations - SNUcglab.snu.ac.kr/lectures/09-1/discrete_math/dm09_slide1-3.pdf · Discrete Mathematics 1-3. Set Operations. Introduction to Set Theory ... Discrete Mathematics,

Ordered n-tuples

• Definition:

For n∈N, an ordered n-tuple or a sequence of length n is written (a1, a2, …, an). The first element is a1, etc.

Discrete Mathematics, Spring 2009 14

• These are like sets, except that duplicates matter, and the order makes a difference.

• Note (1, 2) ≠ (2, 1) ≠ (2, 1, 1).

• Empty sequence, singlets, pairs, triples, quadruples, quintuples, …, n-tuples.

Page 15: 1-3. Set Operations - SNUcglab.snu.ac.kr/lectures/09-1/discrete_math/dm09_slide1-3.pdf · Discrete Mathematics 1-3. Set Operations. Introduction to Set Theory ... Discrete Mathematics,

Cartesian Products of Sets

• Definition:

Let A and B be any two sets.

The Cartesian product A×B is defined to be A×B = {(a, b) | a∈A ∧ b∈B }.

Discrete Mathematics, Spring 2009 15

A×B = {(a, b) | a∈A ∧ b∈B }.

• Example: {a,b}×{1,2} = {(a,1),(a,2),(b,1),(b,2)}

• Note that for finite A, B, |A×B|=|A||B|.

• Note that the Cartesian product is not commutative: A×B≠B×A.

• Extends to A1 × A2 × … × An...

Page 16: 1-3. Set Operations - SNUcglab.snu.ac.kr/lectures/09-1/discrete_math/dm09_slide1-3.pdf · Discrete Mathematics 1-3. Set Operations. Introduction to Set Theory ... Discrete Mathematics,

Union Operator

• Definition:

Let A and B be any two sets. The ∪ nion A∪B of Aand B is the set containing all elements that are either in A or (“∨∨∨∨”) in B (or, of course, in both), i.e.,

Discrete Mathematics, Spring 2009 16

in A or (“∨∨∨∨”) in B (or, of course, in both), i.e.,

A∪B = {x | x∈A ∨∨∨∨ x∈B}.

• Note that A∪B contains all the elements of A and it contains all the elements of B: (A∪B ⊇ A) ∧∧∧∧ (A∪B ⊇ B)

Page 17: 1-3. Set Operations - SNUcglab.snu.ac.kr/lectures/09-1/discrete_math/dm09_slide1-3.pdf · Discrete Mathematics 1-3. Set Operations. Introduction to Set Theory ... Discrete Mathematics,

• {a,b,c}∪{2,3} = {a,b,c,2,3}

• {2,3,5}∪{3,5,7} = {2,3,5,3,5,7} ={2,3,5,7}

Example of Union

Discrete Mathematics, Spring 2009 17

Page 18: 1-3. Set Operations - SNUcglab.snu.ac.kr/lectures/09-1/discrete_math/dm09_slide1-3.pdf · Discrete Mathematics 1-3. Set Operations. Introduction to Set Theory ... Discrete Mathematics,

Intersection Operator

• Definition:

Let A and B be any two sets. The intersection A∩B of Aand B is the set containing all elements that are simultaneously in A and (“∧”) in B, i.e.,

Discrete Mathematics, Spring 2009 18

simultaneously in A and (“∧”) in B, i.e.,

A∩B≡{x | x∈A ∧∧∧∧ x∈B}.

• Note that A∩B is a subset of A and it is a subset of B:(A∩B ⊆ A) ∧∧∧∧ (A∩B ⊆ B)

Page 19: 1-3. Set Operations - SNUcglab.snu.ac.kr/lectures/09-1/discrete_math/dm09_slide1-3.pdf · Discrete Mathematics 1-3. Set Operations. Introduction to Set Theory ... Discrete Mathematics,

• {a,b,c}∩{2,3} = ∅

• {2,4,6}∩{3,4,5} = {4}

Example of Intersection

Discrete Mathematics, Spring 2009 19

Page 20: 1-3. Set Operations - SNUcglab.snu.ac.kr/lectures/09-1/discrete_math/dm09_slide1-3.pdf · Discrete Mathematics 1-3. Set Operations. Introduction to Set Theory ... Discrete Mathematics,

Disjointedness

• Definition:

Let A and B be any two sets. A and B are called disjoint (i.e., unjoined)iff their intersection is empty (A∩B=∅).

Discrete Mathematics, Spring 2009 20

iff their intersection is empty (A∩B=∅).

• Example:

The set of even integers is disjoint with the set of odd integers.

Page 21: 1-3. Set Operations - SNUcglab.snu.ac.kr/lectures/09-1/discrete_math/dm09_slide1-3.pdf · Discrete Mathematics 1-3. Set Operations. Introduction to Set Theory ... Discrete Mathematics,

Inclusion-Exclusion Principle

• How many elements are in A∪B?|A∪B| = |A| + |B| − |A∩B|

• Example:

How many students are on our class email list?

Discrete Mathematics, Spring 2009 21

How many students are on our class email list? Consider set E = I ∪ M, I = {s | s turned in an information sheet}M = {s | s sent the TAs their email address}

• Some students did both!|E| = |I∪M| = |I| + |M| − |I∩M|

Page 22: 1-3. Set Operations - SNUcglab.snu.ac.kr/lectures/09-1/discrete_math/dm09_slide1-3.pdf · Discrete Mathematics 1-3. Set Operations. Introduction to Set Theory ... Discrete Mathematics,

Set Difference

• Definition:

Let A and B be any two sets. The set difference of A and B, A−B is the set of all elements that are in A but not B.

Discrete Mathematics, Spring 2009 22

A but not B.

A − B = {x | x∈A ∧ x∉B}

= {x | ¬( x∈A → x∈B ) }

A − B is also called the complement of B with respect to A.

Page 23: 1-3. Set Operations - SNUcglab.snu.ac.kr/lectures/09-1/discrete_math/dm09_slide1-3.pdf · Discrete Mathematics 1-3. Set Operations. Introduction to Set Theory ... Discrete Mathematics,

Example of Set Difference

• {1,2,3,4,5,6} − {2,3,5,7,9,11} = {1,4,6}

• Z − N = {… , -1, 0, 1, 2, … } − {0, 1, … }= {x | x is an integer but not a nat. #}= {x | x is a negative integer}

Discrete Mathematics, Spring 2009 23

= {x | x is a negative integer}= {… , -3, -2, -1}

Page 24: 1-3. Set Operations - SNUcglab.snu.ac.kr/lectures/09-1/discrete_math/dm09_slide1-3.pdf · Discrete Mathematics 1-3. Set Operations. Introduction to Set Theory ... Discrete Mathematics,

Universal Set & Complement of a Set

• Definition (Universal Set):

A set is a universal set or a universe of discourse, denoted by U, if it includes every set under discussion.

• Definition (Complement of a Set):

Discrete Mathematics, Spring 2009 24

• Definition (Complement of a Set):

Let A be a set. The complement of A in U, denoted by , is the set of all elements of U which are not elements of A, i.e.,

= U−A.

U−A = {x | x∈U ∧ x∉A}

• Example:

If U=N,

A

,...}7,6,4,2,1{}5,3{ =

A

Page 25: 1-3. Set Operations - SNUcglab.snu.ac.kr/lectures/09-1/discrete_math/dm09_slide1-3.pdf · Discrete Mathematics 1-3. Set Operations. Introduction to Set Theory ... Discrete Mathematics,

More on Set Complements

• An equivalent definition, when U is clear:

}|{ AxxA ∉=

Discrete Mathematics, Spring 2009 25

A

U

A

Page 26: 1-3. Set Operations - SNUcglab.snu.ac.kr/lectures/09-1/discrete_math/dm09_slide1-3.pdf · Discrete Mathematics 1-3. Set Operations. Introduction to Set Theory ... Discrete Mathematics,

Set Identities (Theorem)

• Theorem:

− Identity: A∪∅=A A∩U=A

− Domination: A∪U=U A∩∅=∅

Discrete Mathematics, Spring 2009 26

− Idempotent: A∪A = A = A∩A

− Double complement:

− Commutative: A∪B=B∪A A∩B=B∩A

− Associative: A∪(B∪C)=(A∪B)∪CA∩(B∩C)=(A∩B)∩C

AA =)(

Page 27: 1-3. Set Operations - SNUcglab.snu.ac.kr/lectures/09-1/discrete_math/dm09_slide1-3.pdf · Discrete Mathematics 1-3. Set Operations. Introduction to Set Theory ... Discrete Mathematics,

DeMorgan’s Law for Sets

• Theorem:

− Exactly analogous to (and derivable from) DeMorgan’s Law for propositions.

Discrete Mathematics, Spring 2009 27

BABA

BABA

∪=∩

∩=∪

Page 28: 1-3. Set Operations - SNUcglab.snu.ac.kr/lectures/09-1/discrete_math/dm09_slide1-3.pdf · Discrete Mathematics 1-3. Set Operations. Introduction to Set Theory ... Discrete Mathematics,

Proving Set Equality

To prove statements about the form E1 = E2

where E1 and E2 are sets, prove E1 ⊆ E2 and E2

⊆ E1 separately.

Discrete Mathematics, Spring 2009 28

Page 29: 1-3. Set Operations - SNUcglab.snu.ac.kr/lectures/09-1/discrete_math/dm09_slide1-3.pdf · Discrete Mathematics 1-3. Set Operations. Introduction to Set Theory ... Discrete Mathematics,

Example: Show A∩∩∩∩(B∪∪∪∪C)=(A∩∩∩∩B)∪∪∪∪(A∩∩∩∩C)

• Show A∩(B∪C)⊆(A∩B)∪(A∩C).

− Assume x∈A∩(B∪C), & show x∈(A∩B)∪(A∩C).

− We know that x∈A, and either x∈B or x∈C.

• Case 1: x∈B. Then x∈A∩B, so x∈(A∩B)∪(A∩C).

Discrete Mathematics, Spring 2009 29

• Case 1: x∈B. Then x∈A∩B, so x∈(A∩B)∪(A∩C).

• Case 2: x∈C. Then x∈A∩C , so x∈(A∩B)∪(A∩C).

− Therefore, x∈(A∩B)∪(A∩C).

− Therefore, A∩(B∪C)⊆(A∩B)∪(A∩C).

• Show (A∩B)∪(A∩C) ⊆ A∩(B∪C). …

Page 30: 1-3. Set Operations - SNUcglab.snu.ac.kr/lectures/09-1/discrete_math/dm09_slide1-3.pdf · Discrete Mathematics 1-3. Set Operations. Introduction to Set Theory ... Discrete Mathematics,

Theorem:

• If A and B are two sets, the following statements are equivalent.

(1) A⊆B

Discrete Mathematics, Spring 2009 30

(1) A⊆B

(2) A ∩ B = A

(3) A ∪ B = B

Page 31: 1-3. Set Operations - SNUcglab.snu.ac.kr/lectures/09-1/discrete_math/dm09_slide1-3.pdf · Discrete Mathematics 1-3. Set Operations. Introduction to Set Theory ... Discrete Mathematics,

Generalized Unions & Intersections

• Since union & intersection are commutative and associative, we can extend them from operating on ordered pairs of sets (A,B) to operating on sequences of sets (A ,…,A ), or

Discrete Mathematics, Spring 2009 31

operating on sequences of sets (A1,…,An), or even unordered sets of sets,X={A | Q(A)}.

Page 32: 1-3. Set Operations - SNUcglab.snu.ac.kr/lectures/09-1/discrete_math/dm09_slide1-3.pdf · Discrete Mathematics 1-3. Set Operations. Introduction to Set Theory ... Discrete Mathematics,

Generalized Union

• Binary union operator: A∪B

• n-ary union:A1∪A2∪…∪An :≡ ((…((A1∪ A2) ∪…)∪ An)(grouping & order is irrelevant)

Discrete Mathematics, Spring 2009 32

1 2 n 1 2 n

(grouping & order is irrelevant)

• “Big U” notation:

• Or for infinite sets of sets:

Un

i

iA

1=

UXA

A

Page 33: 1-3. Set Operations - SNUcglab.snu.ac.kr/lectures/09-1/discrete_math/dm09_slide1-3.pdf · Discrete Mathematics 1-3. Set Operations. Introduction to Set Theory ... Discrete Mathematics,

Generalized Intersection

• Binary intersection operator: A∩B

• n-ary intersection:A∩A2∩…∩An≡((…((A1∩A2)∩…)∩An)(grouping & order is irrelevant)

Discrete Mathematics, Spring 2009 33

2 n 1 2 n

(grouping & order is irrelevant)

• “Big Arch” notation:

• Or for infinite sets of sets:

In

i

iA

1=

IXA

A

Page 34: 1-3. Set Operations - SNUcglab.snu.ac.kr/lectures/09-1/discrete_math/dm09_slide1-3.pdf · Discrete Mathematics 1-3. Set Operations. Introduction to Set Theory ... Discrete Mathematics,

Exercise1.Let A and B be sets. Show that

(a) (A ∩B) ⊆A

(b)A ∪(B-A) = A ∪B

2.Let A, B and C be sets. Show that

Discrete Mathematics, Spring 2009 34

2.Let A, B and C be sets. Show that

(A-B)-C= (A-C)-(B-C).

3.Let A and B be two sets. Prove or disprove each of the followings

(a) P(A) ∪P(B) ⊆P(A ∪B) where P(A) is the power set of the set A.

(b) P(A ∪B) ⊆P(A) ∪P(B)