53
Module #3 - Sets Module #3 - Sets UC Davis, ECS20, Winter 2019 Discrete Mathematics for Computer Science Prof. Raissa D’Souza (slides adopted from Michael Frank and Haluk Bingöl) Lecture 4 The Theory of Sets Rosen, 2.1-2.2

The Theory of Sets Rosen, 2.1-2 - University of California, Davismae.engr.ucdavis.edu › dsouza › Classes › Lec4_ecs20.pdf · 2019-04-11 · The Theory of Sets Rosen, 2.1-2.2

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Mod

ule

#3

- Se

ts

Mod

ule

#3

- Se

ts

UCDavis,ECS20,Winter2019DiscreteMathematicsforComputerScienceProf.RaissaD’Souza(slidesadoptedfromMichaelFrankandHalukBingöl)

Lecture4

The Theory of Sets Rosen, 2.1-2.2

Mod

ule

#3

- Se

ts

IntroductiontoSetTheory•  Asetisanewtypeofstructure,represen2nganunorderedcollec2on(group,plurality)ofzeroormoredis+nct(different)objects.E.g,•  Thestudentsinthisclass•  Fruitsatthefarmersmarket•  Allthevideogamesonyourphone,etc.

•  Settheorydealswithopera2onsbetween,rela2onsamong,andstatementsaboutsets.

•  SetsareubiquitousincomputersoFwaresystems.

Mod

ule

#3

- Se

ts

Basicnotationsforsets• Forsets,wellusevariablesS,T,U,…• WecandenoteasetSinwri2ngbylis+ngallofitselementsincurlybraces:•  {a,b,c}isthesetofwhatever3objectsaredenotedbya,b,c.

• Setbuildernota+on:Foranyproposi2onP(x)overanyuniverseofdiscourse,{x|P(x)}isthesetofallxsuchthatP(x).

Mod

ule

#3

- Se

ts

Example• P(x)=xisastudentinECS20Spring2019

• Theuniverse/domainofdiscourseisallUCDavisstudents

• S={x|P(x)}

• WhatisSinstatedinEnglish?

Mod

ule

#3

- Se

ts

Basicpropertiesofsets•  Setsareinherentlyunordered:

• NomaZerwhatobjectsa,b,andcdenote,{a,b,c}={a,c,b}={b,a,c}={b,c,a}={c,a,b}={c,b,a}.

• Allelementsaredis+nct(repeatsdon’tcount);mul2plelis2ngsmakenodifference!•  Ifa=b,then{a,b,c}={a,c}={b,c}={a,a,b,a,b,c,c,c,c}.

•  Thissetcontains(atmost)2elements!

Mod

ule

#3

- Se

ts

Cardinality(i.e.,size)ofaset • Iftherearendis2nctelementsinthesetSwherenisanonnega2veinteger,wesaythatSisafiniteset.

•  n=|S|isthecardinalityofS.• Asetissaidtobeinfiniteifitisnotfinite.

• ExampleS={a,a,b,a,b,c,c,c,c},• |S|=3.

Mod

ule

#3

- Se

ts

BasicSetRelations:Memberof• Defini2on:x∈S (“xisinS”)istheproposi2onthatobjectxisan∈lementormemberofsetS.Examples:•  3∈{1,2,3,4}•  3∈{x|xisaninteger}• “a”∈{x|xisaleZerofthealphabet}

• Defini2on:x∉S:≡¬(x∈S)“xisnotinS”

Mod

ule

#3

- Se

ts

DeTinitionofSetEquality•  Twosetsaredeclaredtobeequalifandonlyiftheycontainexactlythesameelements.

•  Inpar2cular,itdoesnotmaZerhowthesetisdefinedordenoted.

•  Forexample:Theset{1,2,3,4}= {x|xisanintegerwherex>0andx<5}

= {x|xisaposi2veintegerwhosesquareis>0and<25}

Mod

ule

#3

- Se

ts

Setequalitywrittenmathematically

Twosets,AandB,areequal:A=B⇔∀x(x∈A↔x∈B).

Mod

ule

#3

- Se

ts

InTiniteSets• Conceptually,setsmaybeinfinite(i.e.,notfinite,withoutend,unending).

• Symbolsforsomespecialinfinitesets:N={0,1,2,…}TheNaturalnumbers.Z={…,-2,-1,0,1,2,…}TheIntegers.Z+={1,2,3,4,…}Theposi2veIntegers.R=The“Real”numbers,suchas374.1828471929498181917281943125…

• Double-struckfont(ℕ,ℤ, ℤ+,ℝ)isalsooFenusedforthesespecialnumbersets.

Mod

ule

#3

- Se

ts

InTinitesets• Infinitesetscancomeindifferentsizes!e.g.,S=ℤT={x|x=2n+1,wheren∈ℕ}(WhatareSandTinEnglish?)

Mod

ule

#3

- Se

ts

TheEmptySet• Defini2on:∅(“null”,“theemptyset” )istheuniquesetthatcontainsnoelementswhatsoever.• ∅={}Whatis|∅|?

• NomaZerthedomainofdiscourse,wehave:

Axiom.¬∃xsuchthatx∈∅.

Mod

ule

#3

- Se

ts

SubsetRelations• Defini2onS⊆T(“SisasubsetofT”)meansthateveryelementofSisalsoanelementofT.S⊆T⇔∀x(x∈S→x∈T)•  ∅⊆S(Theemptysetisasubsetofanyset)•  S⊆S(Anysetistechnicallyasubsetofitself)• NoteS=T⇔S⊆T∧T⊆S.

•  S⊈Tmeans¬(S⊆T),i.e.∃x(x∈S∧x∉T)

Mod

ule

#3

- Se

ts

John Venn 1834-1923

VennDiagramsGeometric representation of sets:

P1: 1

CH02-7T Rosen-2311T MHIA017-Rosen-v5.cls May 13, 2011 10:24

118 2 / Basic Structures: Sets, Functions, Sequences, Sums, and Matrices

THE EMPTY SET There is a special set that has no elements. This set is called the empty set,or null set, and is denoted by ∅. The empty set can also be denoted by { } (that is, we representthe empty set with a pair of braces that encloses all the elements in this set). Often, a set ofelements with certain properties turns out to be the null set. For instance, the set of all positiveintegers that are greater than their squares is the null set.

A set with one element is called a singleton set. A common error is to confuse the empty{∅} has one moreelement than ∅. set ∅ with the set {∅}, which is a singleton set. The single element of the set {∅} is the empty set

itself! A useful analogy for remembering this difference is to think of folders in a computer filesystem. The empty set can be thought of as an empty folder and the set consisting of just theempty set can be thought of as a folder with exactly one folder inside, namely, the empty folder.

NAIVE SET THEORY Note that the term object has been used in the definition of a set,Definition 1, without specifying what an object is. This description of a set as a collectionof objects, based on the intuitive notion of an object, was first stated in 1895 by the Germanmathematician Georg Cantor. The theory that results from this intuitive definition of a set, andthe use of the intuitive notion that for any property whatever, there is a set consisting of exactlythe objects with this property, leads to paradoxes, or logical inconsistencies. This was shownby the English philosopher Bertrand Russell in 1902 (see Exercise 46 for a description of one ofthese paradoxes). These logical inconsistencies can be avoided by building set theory beginningwith axioms. However, we will use Cantor’s original version of set theory, known as naive settheory, in this book because all sets considered in this book can be treated consistently usingCantor’s original theory. Students will find familiarity with naive set theory helpful if they go onto learn about axiomatic set theory. They will also find the development of axiomatic set theorymuch more abstract than the material in this text. We refer the interested reader to [Su72] tolearn more about axiomatic set theory.

Venn Diagrams

Sets can be represented graphically using Venn diagrams, named after the English mathemati-cian John Venn, who introduced their use in 1881. In Venn diagrams the universal set U, whichcontains all the objects under consideration, is represented by a rectangle. (Note that the uni-versal set varies depending on which objects are of interest.) Inside this rectangle, circles orother geometrical figures are used to represent sets. Sometimes points are used to represent theparticular elements of the set. Venn diagrams are often used to indicate the relationships betweensets. We show how a Venn diagram can be used in Example 7.

EXAMPLE 7 Draw a Venn diagram that represents V, the set of vowels in the English alphabet.

Solution: We draw a rectangle to indicate the universal set U , which is the set of the 26 lettersof the English alphabet. Inside this rectangle we draw a circle to represent V . Inside this circlewe indicate the elements of V with points (see Figure 1). ▲

U

V

a

eu

o i

FIGURE 1 Venn Diagram for the Set of Vowels.

•  Uistheuniverse/domainofdiscourse•  AcirclearoundelementsinthesetS

S=vowelsintheEnglishlanguage

Mod

ule

#3

- Se

ts

Mod

ule

#3

- Se

ts

Proper(Strict)Subsets

• Defini2on:S⊂T(“SisapropersubsetofT”)meansthatS⊆TbutT⊈S.Note⊂versus⊆

•  A⊂B⇔∀x(x∈A→x∈B)∧∃x(x∈B∧x∉A)

S T

Venn Diagram equivalent of S ⊂T

Example: {1, 2} ⊂ {1, 2, 3}

Mod

ule

#3

- Se

ts

SetsAreObjects,Too!

• CanmakeaSETOFSETS!!!

• Theobjectsthatareelementsofasetmaythemselvesbesets.

• E.g.letS={x|x⊆{1,2,3}}Soxisallsubsetsof{1,2,3}Whatarethey?

Mod

ule

#3

- Se

ts

Canmakesetsofsets!(cont)

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

• Notethat1≠{1}≠{{1}}

Mod

ule

#3

- Se

ts

Setsofsets•  Moreformally:S∉S,butS∈{S}

•  Theemptyset,∅={}•  ∅∉{}•  But∅∈{∅}•  {∅}={{}}•  {∅}∈{{∅}}

Mod

ule

#3

- Se

ts

ThePowerSetOperation• Def.ThepowersetP(S)ofasetSisthesetofallsubsetsofS.P(S):≡{x|x⊆S}.

•  E.g.P({a,b})={∅,{a},{b},{a,b}}.

• Remark.ForfiniteS,|P(S)|=2|S|.

•  Itturnsout∀S:|P(S)|>|S|,e.g.|P(ℕ)|>|ℕ|.Recall:therearedifferentsizesofinfinitesets!

Mod

ule

#3

- Se

ts

Thepowersetof∅

• Emptyset∅={}

• P(∅)={∅}

• So|∅|=0but|P(∅)|=1(Sorryfortheoverloadednota+onthatP(S)lookslikeapredicatefunc+on.ButwhenusedforpowersetPisnotitalized.AndIwilltrytoalwayssay“powerset”.)

Mod

ule

#3

- Se

ts

Review:Setnotationsofar• Variableobjectsx,y,z;setsS,T,U.•  Literalset{a,b,c}andset-builder{x|P(x)}.• ∈rela2onaloperator(“isanelementof”)

•  Theemptyset∅.

•  Setrela2ons=,⊆,⊂,⊄,etc.• Venndiagrams.

• Cardinality|S|andinfinitesetsℕ, ℤ, ℝ. • PowersetsP(S).•  Infiniteandfinitesets

Mod

ule

#3

- Se

ts

Orderedn-tuples• Thesearelikesets,exceptthatduplicatesmaZer,andtheordermakesadifference.

• Def.Nisanorderedn-tupleorasequenceorlistoflengthnandwriZen(a1,a2,…,an).Itsfirstelementisa1,etc.

• Notethat(1,2)≠(2,1)≠(2,1,1).• Emptysequence,singlets,pairs,triples,quadruples,quintuples,…,n-tuples. Contrast with

sets’ {}

Mod

ule

#3

- Se

ts

CartesianProductsofSets

• Def.ForsetsA,B,theirCartesianproductA×B:≡{(a,b)|a∈A∧b∈B}.

•  e.g.A={a,b},andB={1,2}AxB={(a,1),(a,2),(b,1),(b,2)}(asetofordered2-tuples)

•  e.g.,A=alldinnerentreesonamenuB=alldessertchoicesAxB=allpossibleentréeanddesertcombina2ons.

René Descartes (1596-1650)

Mod

ule

#3

- Se

ts

• Remarks.• ForfiniteA,B,|A×B|=|A||B|.• TheCartesianproductisnotcommuta2ve:i.e.,¬∀AB:A×B=B×A.(OfcourseifA=BorA=∅orB=∅theycommute.)

• Extendstomul2plesets• A1×A2×…×An ={(a1,a2,….,an)|ai∈Aifori∈{1,2,…n}}

CartesianProductsofSets

Mod

ule

#3

- Se

ts

SetnotationwithquantiTiers • Universalquan2fier:∀x∈S(P(x))

• P(x)holdsforallx∈S• ∀x(x∈S→P(x))

•  Existen2alquan2fier:∃x∈S(P(x))• P(x)holdsforatleastonex∈S• ∃x(x∈S∧P(x))

•  TruthsetofpredicateP:theelementsofthesetforwhichPistrue.If∀x∈S(P(x)),thenthewholeuniverseofdiscourseUisthetruthset.

Mod

ule

#3

- Se

ts

SetOperators,Sec2.2

Mod

ule

#3

- Se

ts

TheUnionOperator

• Def.ForsetsA,B,their∪nionA∪BisthesetcontainingallelementsthatareeitherinA,or(“∨”)inB(or,ofcourse,inboth).

• Formally,∀A,B:A∪B={x|x∈A∨x∈B}

• Remark.A∪BisasupersetofbothAandB(infact,itisthesmallestsuchsuperset):∀A,B:(A⊆A∪B)∧(B⊆A∪B)

Mod

ule

#3

- Se

ts

UnionVennDiagram

P1: 1

CH02-7T Rosen-2311T MHIA017-Rosen-v5.cls May 13, 2011 10:24

2.2 Set Operations 127

2.2 Set Operations

Introduction

Two, or more, sets can be combined in many different ways. For instance, starting with the setof mathematics majors at your school and the set of computer science majors at your school, wecan form the set of students who are mathematics majors or computer science majors, the set ofstudents who are joint majors in mathematics and computer science, the set of all students notmajoring in mathematics, and so on.

DEFINITION 1 Let A and B be sets. The union of the sets A and B, denoted by A ∪ B, is the set that containsthose elements that are either in A or in B, or in both.

An element x belongs to the union of the sets A and B if and only if x belongs to A or x belongsto B. This tells us that

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

The Venn diagram shown in Figure 1 represents the union of two sets A and B. The areathat represents A ∪ B is the shaded area within either the circle representing A or the circlerepresenting B.

We will give some examples of the union of sets.

EXAMPLE 1 The union of the sets {1, 3, 5} and {1, 2, 3} is the set {1, 2, 3, 5}; that is,{1, 3, 5} ∪ {1, 2, 3} = {1, 2, 3, 5}. ▲

EXAMPLE 2 The union of the set of all computer science majors at your school and the set of all mathe-matics majors at your school is the set of students at your school who are majoring either inmathematics or in computer science (or in both). ▲

DEFINITION 2 Let A and B be sets. The intersection of the sets A and B, denoted by A ∩ B, is the setcontaining those elements in both A and B.

An element x belongs to the intersection of the sets A and B if and only if x belongs to A andx belongs to B. This tells us that

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

U

BA

A ! B is shaded.

FIGURE 1 Venn Diagram of theUnion of A and B.

U

BA

A " B is shaded.

FIGURE 2 Venn Diagram of theIntersection of A and B.

Mod

ule

#3

- Se

ts

UnionExamples•  {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}

Think “The United States of America includes every person who worked in any U.S. state last year.” (This is how the IRS sees it...)

Mod

ule

#3

- Se

ts

TheIntersectionOperator• Def.ForsetsA,B,theirintersec+onA∩BisthesetcontainingallelementsthataresimultaneouslyinAand(“∧”)inB.

• Formally,∀A,B:A∩B={x|x∈A∧x∈B}

• Remark.A∩BisasubsetofbothAandB(infactitisthelargestsuchsubset):∀A,B:(A∩B⊆A)∧(A∩B⊆B)

Mod

ule

#3

- Se

ts

IntersectionVenndiagram

P1: 1

CH02-7T Rosen-2311T MHIA017-Rosen-v5.cls May 13, 2011 10:24

2.2 Set Operations 127

2.2 Set Operations

Introduction

Two, or more, sets can be combined in many different ways. For instance, starting with the setof mathematics majors at your school and the set of computer science majors at your school, wecan form the set of students who are mathematics majors or computer science majors, the set ofstudents who are joint majors in mathematics and computer science, the set of all students notmajoring in mathematics, and so on.

DEFINITION 1 Let A and B be sets. The union of the sets A and B, denoted by A ∪ B, is the set that containsthose elements that are either in A or in B, or in both.

An element x belongs to the union of the sets A and B if and only if x belongs to A or x belongsto B. This tells us that

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

The Venn diagram shown in Figure 1 represents the union of two sets A and B. The areathat represents A ∪ B is the shaded area within either the circle representing A or the circlerepresenting B.

We will give some examples of the union of sets.

EXAMPLE 1 The union of the sets {1, 3, 5} and {1, 2, 3} is the set {1, 2, 3, 5}; that is,{1, 3, 5} ∪ {1, 2, 3} = {1, 2, 3, 5}. ▲

EXAMPLE 2 The union of the set of all computer science majors at your school and the set of all mathe-matics majors at your school is the set of students at your school who are majoring either inmathematics or in computer science (or in both). ▲

DEFINITION 2 Let A and B be sets. The intersection of the sets A and B, denoted by A ∩ B, is the setcontaining those elements in both A and B.

An element x belongs to the intersection of the sets A and B if and only if x belongs to A andx belongs to B. This tells us that

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

U

BA

A ! B is shaded.

FIGURE 1 Venn Diagram of theUnion of A and B.

U

BA

A " B is shaded.

FIGURE 2 Venn Diagram of theIntersection of A and B.

Mod

ule

#3

- Se

ts

IntersectionExamples•  {a,b,c}∩{2,3}=?•  {2,4,6}∩{3,4,5}=?

Think “The intersection of 2nd Ave. and 3rd St. is just that part of the road surface that lies on both streets.”

Mod

ule

#3

- Se

ts

Disjointedness• Def.TwosetsA,Barecalleddisjoint(i.e.,unjoined)ifftheirintersec2onisempty.(A∩B=∅)

• Example:thesetofevenintegersisdisjointwiththesetofoddintegers.

Help, I’ve been

disjointed!

Mod

ule

#3

- Se

ts

Inclusion-ExclusionPrinciple• HowmanyelementsareinA∪B?|A∪B|=|A|+|B|-|A∩B|

•  Example:HowmanystudentsaremathorCSmajors?ConsidersetS=A∪B,

A={s|sisaCSmajor} B={s|sisaMathmajor}

•  Somestudentsdoublemajor!(Weonlywanttocounteachonce)

•  |S|=|A∪B|=|A|+|B|-|A∩B|

Subtract out items in intersection, to compensate for

double-counting them!

P1: 1

CH02-7T Rosen-2311T MHIA017-Rosen-v5.cls May 13, 2011 10:24

2.2 Set Operations 127

2.2 Set Operations

Introduction

Two, or more, sets can be combined in many different ways. For instance, starting with the setof mathematics majors at your school and the set of computer science majors at your school, wecan form the set of students who are mathematics majors or computer science majors, the set ofstudents who are joint majors in mathematics and computer science, the set of all students notmajoring in mathematics, and so on.

DEFINITION 1 Let A and B be sets. The union of the sets A and B, denoted by A ∪ B, is the set that containsthose elements that are either in A or in B, or in both.

An element x belongs to the union of the sets A and B if and only if x belongs to A or x belongsto B. This tells us that

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

The Venn diagram shown in Figure 1 represents the union of two sets A and B. The areathat represents A ∪ B is the shaded area within either the circle representing A or the circlerepresenting B.

We will give some examples of the union of sets.

EXAMPLE 1 The union of the sets {1, 3, 5} and {1, 2, 3} is the set {1, 2, 3, 5}; that is,{1, 3, 5} ∪ {1, 2, 3} = {1, 2, 3, 5}. ▲

EXAMPLE 2 The union of the set of all computer science majors at your school and the set of all mathe-matics majors at your school is the set of students at your school who are majoring either inmathematics or in computer science (or in both). ▲

DEFINITION 2 Let A and B be sets. The intersection of the sets A and B, denoted by A ∩ B, is the setcontaining those elements in both A and B.

An element x belongs to the intersection of the sets A and B if and only if x belongs to A andx belongs to B. This tells us that

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

U

BA

A ! B is shaded.

FIGURE 1 Venn Diagram of theUnion of A and B.

U

BA

A " B is shaded.

FIGURE 2 Venn Diagram of theIntersection of A and B.

Mod

ule

#3

- Se

ts

SetDifference

• Def.ForsetsA,B,thedifferenceofAandB,wriZenA-B,isthesetofallelementsthatareinAbutnotB.

• Formally:A-B:≡{x|x∈A∧x∉B}

• Alsocalled:ThecomplementofBwithrespecttoA.

• Note,|A-B|≤|A|(regardlessofthesizeofB)

Mod

ule

#3

- Se

ts

SetDifferenceExamples

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

• ℤ-ℕ={…,−1,0,1,2,…}-{0,1,…}={x|xisanintegerbutnotanat.#}={x|xisanega2veinteger}={…,−3,−2,−1}

Mod

ule

#3

- Se

ts

SetDifference-VennDiagram• A−Biswhat’sleFaFerB“takesabiteoutofA”

Set A Set B

Set A-B

Chomp!

Mod

ule

#3

- Se

ts

SetComplements• Def.Theuniverseofdiscoursecanitselfbeconsideredaset,callitU.

• WhenthecontextclearlydefinesU,wesaythatforanysetA⊆U,thecomplementofA,wriZenisthecomplementofAw.r.t.U,i.e.,itisU-A.

• E.g.,IfU=N,,...}7,6,4,2,1,0{}5,3{ =

A

Mod

ule

#3

- Se

ts

MoreonSetComplements• Anequivalentdefini2on,whenUisgiven: }|{ AxxA ∉=

P1: 1

CH02-7T Rosen-2311T MHIA017-Rosen-v5.cls May 13, 2011 10:24

2.2 Set Operations 129

U

BA

A – B is shaded.

FIGURE 3 Venn Diagram forthe Difference of A and B.

U

A

A is shaded.

FIGURE 4 Venn Diagram forthe Complement of the Set A.

Once the universal set U has been specified, the complement of a set can be defined.

DEFINITION 5 Let U be the universal set. The complement of the set A, denoted by A, is the complementof A with respect to U . Therefore, the complement of the set A is U − A.

An element belongs to A if and only if x /∈ A. This tells us that

A = {x ∈ U | x /∈ A}.

In Figure 4 the shaded area outside the circle representing A is the area representing A.We give some examples of the complement of a set.

EXAMPLE 8 Let A = {a, e, i, o, u} (where the universal set is the set of letters of the English alphabet). ThenA = {b, c, d, f, g, h, j, k, l, m, n, p, q, r, s, t, v, w, x, y, z}. ▲

EXAMPLE 9 Let A be the set of positive integers greater than 10 (with universal set the set of all positiveintegers). Then A = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}. ▲

It is left to the reader (Exercise 19) to show that we can express the difference of A and Bas the intersection of A and the complement of B. That is,

A− B = A ∩ B.

Set Identities

Table 1 lists the most important set identities. We will prove several of these identities here,using three different methods. These methods are presented to illustrate that there are often manydifferent approaches to the solution of a problem. The proofs of the remaining identities will

Set identities andpropositionalequivalences are justspecial cases of identitiesfor Boolean algebra.

be left as exercises. The reader should note the similarity between these set identities and thelogical equivalences discussed in Section 1.3. (Compare Table 6 of Section 1.6 and Table 1.) Infact, the set identities given can be proved directly from the corresponding logical equivalences.Furthermore, both are special cases of identities that hold for Boolean algebra (discussed inChapter 12).

One way to show that two sets are equal is to show that each is a subset of the other. Recallthat to show that one set is a subset of a second set, we can show that if an element belongs tothe first set, then it must also belong to the second set. We generally use a direct proof to do this.We illustrate this type of proof by establishing the first of De Morgan’s laws.

Mod

ule

#3

- Se

ts

SetIdentities• Iden2ty:A∪∅=A=A∩U• Domina2on:A∪U=U,A∩∅=∅• Idempotent:A∪A=A=A∩A• Doublecomplement:• Commuta2ve:A∪B=B∪A,A∩B=B∩A• Associa2ve:A∪(B∪C)=(A∪B)∪C,A∩(B∩C)=(A∩B)∩C

AA =)(

Mod

ule

#3

- Se

ts

DeMorgan’sLawforSets• Exactlyanalogousto(andprovablefrom)DeMorgan’sLawforproposi2ons.

A∪B = A∩B

A∩B = A∪B

Mod

ule

#3

- Se

ts

P1: 1

CH02-7T Rosen-2311T MHIA017-Rosen-v5.cls May 13, 2011 10:24

2.2 Set Operations 127

2.2 Set Operations

Introduction

Two, or more, sets can be combined in many different ways. For instance, starting with the setof mathematics majors at your school and the set of computer science majors at your school, wecan form the set of students who are mathematics majors or computer science majors, the set ofstudents who are joint majors in mathematics and computer science, the set of all students notmajoring in mathematics, and so on.

DEFINITION 1 Let A and B be sets. The union of the sets A and B, denoted by A ∪ B, is the set that containsthose elements that are either in A or in B, or in both.

An element x belongs to the union of the sets A and B if and only if x belongs to A or x belongsto B. This tells us that

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

The Venn diagram shown in Figure 1 represents the union of two sets A and B. The areathat represents A ∪ B is the shaded area within either the circle representing A or the circlerepresenting B.

We will give some examples of the union of sets.

EXAMPLE 1 The union of the sets {1, 3, 5} and {1, 2, 3} is the set {1, 2, 3, 5}; that is,{1, 3, 5} ∪ {1, 2, 3} = {1, 2, 3, 5}. ▲

EXAMPLE 2 The union of the set of all computer science majors at your school and the set of all mathe-matics majors at your school is the set of students at your school who are majoring either inmathematics or in computer science (or in both). ▲

DEFINITION 2 Let A and B be sets. The intersection of the sets A and B, denoted by A ∩ B, is the setcontaining those elements in both A and B.

An element x belongs to the intersection of the sets A and B if and only if x belongs to A andx belongs to B. This tells us that

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

U

BA

A ! B is shaded.

FIGURE 1 Venn Diagram of theUnion of A and B.

U

BA

A " B is shaded.

FIGURE 2 Venn Diagram of theIntersection of A and B.

A∪B = A∩B

Mod

ule

#3

- Se

ts

ProvingSetIdentities

• Toprovestatementsaboutsets,oftheformE1=E2(wheretheEsaresetexpressions),herearethreedifferentandusefulmethods:

1.ProveE1⊆E2andE2⊆E1separately.

2.Usesetbuildernota2on&logicalequivalences.

3.Useamembershiptable.

Mod

ule

#3

- Se

ts

Method1:Mutualsubsets•  Example:•  ShowA∩(B∪C)=(A∩B)∪(A∩C).

•  Part1:ShowA∩(B∪C)⊆(A∩B)∪(A∩C).•  Assumex∈A∩(B∪C),&showx∈(A∩B)∪(A∩C).• Weknowthatx∈A,andeitherx∈Borx∈C.

•  Case1:x∈B.Thenx∈A∩B,sox∈(A∩B)∪(A∩C).•  Case2:x∈C.Thenx∈A∩C,sox∈(A∩B)∪(A∩C).

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

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

Mod

ule

#3

- Se

ts

Method2:Directproof

P1: 1

CH02-7T Rosen-2311T MHIA017-Rosen-v5.cls May 13, 2011 10:24

2.2 Set Operations 131

EXAMPLE 11 Use set builder notation and logical equivalences to establish the first De Morgan law A ∩ B =A ∪ B.

Solution: We can prove this identity with the following steps.

A ∩ B = {x | x /∈ A ∩ B} by definition of complement

= {x | ¬(x ∈ (A ∩ B))} by definition of does not belong symbol

= {x | ¬(x ∈ A ∧ x ∈ B)} by definition of intersection

= {x | ¬(x ∈ A) ∨ ¬(x ∈ B)} by the first De Morgan law for logical equivalences

= {x | x /∈ A ∨ x /∈ B} by definition of does not belong symbol

= {x | x ∈ A ∨ x ∈ B} by definition of complement

= {x | x ∈ A ∪ B} by definition of union

= A ∪ B by meaning of set builder notation

Note that besides the definitions of complement, union, set membership, and set buildernotation, this proof uses the second De Morgan law for logical equivalences. ▲

Proving a set identity involving more than two sets by showing each side of the identity isa subset of the other often requires that we keep track of different cases, as illustrated by theproof in Example 12 of one of the distributive laws for sets.

EXAMPLE 12 Prove the second distributive law from Table 1, which states that A ∩ (B ∪ C) = (A ∩ B) ∪(A ∩ C) for all sets A, B, and C.

Solution: We will prove this identity by showing that each side is a subset of the other side.Suppose that x ∈ A ∩ (B ∪ C). Then x ∈ A and x ∈ B ∪ C. By the definition of union, it

follows that x ∈ A, and x ∈ B or x ∈ C (or both). In other words, we know that the compoundproposition (x ∈ A) ∧ ((x ∈ B) ∨ (x ∈ C)) is true. By the distributive law for conjunction overdisjunction, it follows that ((x ∈ A) ∧ (x ∈ B)) ∨ ((x ∈ A) ∧ (x ∈ C)).We conclude that eitherx ∈ A and x ∈ B, or x ∈ A and x ∈ C. By the definition of intersection, it follows that x ∈ A ∩ Bor x ∈ A ∩ C. Using the definition of union, we conclude that x ∈ (A ∩ B) ∪ (A ∩ C). Weconclude that A ∩ (B ∪ C) ⊆ (A ∩ B) ∪ (A ∩ C).

Now suppose that x ∈ (A ∩ B) ∪ (A ∩ C). Then, by the definition of union, x ∈ A ∩ B orx ∈ A ∩ C. By the definition of intersection, it follows that x ∈ A and x ∈ B or that x ∈ A andx ∈ C. From this we see that x ∈ A, and x ∈ B or x ∈ C. Consequently, by the definition ofunion we see that x ∈ A and x ∈ B ∪ C. Furthermore, by the definition of intersection, it followsthat x ∈ A ∩ (B ∪ C). We conclude that (A ∩ B) ∪ (A ∩ C) ⊆ A ∩ (B ∪ C). This completesthe proof of the identity. ▲

Set identities can also be proved using membership tables. We consider each combinationof sets that an element can belong to and verify that elements in the same combinations of setsbelong to both the sets in the identity. To indicate that an element is in a set, a 1 is used; toindicate that an element is not in a set, a 0 is used. (The reader should note the similarity betweenmembership tables and truth tables.)

EXAMPLE 13 Use a membership table to show that A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C).

Solution: The membership table for these combinations of sets is shown in Table 2. This tablehas eight rows. Because the columns for A ∩ (B ∪ C) and (A ∩ B) ∪ (A ∩ C) are the same, theidentity is valid. ▲

Additional set identities can be established using those that we have already proved. ConsiderExample 14.

Mod

ule

#3

- Se

ts

Method3:MembershipTables• Justliketruthtablesforproposi2onallogic.• Columnsfordifferentsetexpressions.• Rowsforallcombina2onsofmembershipsincons2tuentsets.

• Use“1”toindicateelementisamemberofthespecifiedset,and“0”fornon-membership.

• Proveequivalencewithiden2calcolumns.

Mod

ule

#3

- Se

ts

MembershipTableExample• Prove(A∪B)-B=A-B.

AA BB AA∪∪BB ((AA∪∪BB))−−BB AA−−BB0 0 0 0 00 1 1 0 01 0 1 1 11 1 1 0 0

Mod

ule

#3

- Se

ts

MembershipTableExercise•  Prove(A∪B)-C=(A-C)∪(B-C).

A B C AA∪∪BB ((AA∪∪BB))−−CC AA−−CC BB−−CC ((AA−−CC))∪∪((BB−−CC))0 0 00 0 10 1 00 1 11 0 01 0 11 1 01 1 1

Mod

ule

#3

- Se

ts

GeneralizedUnions&Intersections

• Sinceunion&intersec2onarecommuta2veandassocia2ve,wecanextendthemfromopera2ngonorderedpairsofsets(A,B)toopera2ngonsequencesofsets(A1,…,An),orevenonunorderedsetsofsets,X={A|P(A)}.

Mod

ule

#3

- Se

ts

GeneralizedUnion• Binaryunionoperator:A∪B

• n-aryunion:A∪A2∪…∪An:≡((…((A1∪A2)∪…)∪An)(grouping&orderisirrelevant)

• “BigU”nota2on:

• orforinfinitesetsofsets:

∪n

iiA

1=

AA∈X∪

Mod

ule

#3

- Se

ts

GeneralizedIntersection• Binaryintersec2onoperator:A∩B

• n-aryintersec2on:A1∩A2∩…∩An≡((…((A1∩A2)∩…)∩An)(grouping&orderisirrelevant)

• “BigArch”nota2on:

• orforinfinitesetsofsets:

∩n

iiA

1=

∩XA

A∈

Mod

ule

#3

- Se

ts

Table 1, Sec 2.2,

Rosen text