sets - cse.unl.educse.unl.edu/~choueiry/s17-235h/files/sets.pdf · sets sec’ons 2.1 and 2.2 of...

46
Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page: cse.unl.edu/~cse235h Ques7ons: Piazza

Upload: others

Post on 14-Oct-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

Sets

Sec'ons2.1and2.2ofRosenSpring2017

CSCE235HIntroduc7ontoDiscreteStructures(Honors)Courseweb-page:cse.unl.edu/~cse235h

Ques7ons:Piazza

Page 2: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 2

Nota7onandLaTeX•  Asetisacollec7onofobjects.•  Forexample:

–  S={s1,s2,s3,…,sn}isafinitesetofnelements–  S={s1,s2,s3,…}isainfinitesetofelements.

•  s1∈Sdenotesthattheobjects1isanelementofthesetS•  s1∉Sdenotesthattheobjects1isnotanelementofthesetS•  LaTex

–  $S=\{s_1,s_2,s_3,\ldots,s_n\}$–  $s_i\inS$–  $si\no7nS$

•  Usingthepackage:\usepackage{amssymb}–  Setofnaturalnumbers:$\mathbb{N}$–  Setofintegernumbers:$\mathbb{Z}$–  Setofra7onalnumbers:$\mathbb{Q}$–  Setofrealnumbers:$\mathbb{R}$–  Setofcomplexnumbers:$\mathbb{C}$

Page 3: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 3

Outline•  Defini7ons:set,element•  Terminologyandnota7on

•  Setequal,mul7-set,bag,setbuilder,intension,extension,VennDiagram(representa7on),emptyset,singletonset,subset,propersubset,finite/infiniteset,cardinality

•  Provingequivalences•  Powerset•  Tuples(orderedpair)•  CartesianProduct(a.k.a.Crossproduct),rela7on•  Quan7fiers•  SetOpera7ons(union,intersec7on,complement,difference),Disjointsets•  Setequivalences(cheatsheetorTable1,page130)

•  Inclusioninbothdirec7ons•  Usingmembershiptables

•  GeneralizedUnionsandIntersec7on•  ComputerRepresenta7onofSets

Page 4: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 4

Introduc7on(1)

•  Wehavealreadyimplicitlydealtwithsets–  Integers(Z),ra7onals(Q),naturals(N),reals(R),etc.

•  Wewilldevelopmorefully–  Thedefini7onsofsets–  Theproper7esofsets–  Theopera7onsonsets

•  Defini'on:Asetisanunorderedcollec7onof(unique)objects

•  Setsarefundamentaldiscretestructuresandforthebasisofmorecomplexdiscretestructureslikegraphs

Page 5: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 5

Introduc7on(2)

•  Defini'on:Theobjectsinasetarecalledelementsormembersofaset.Asetissaidtocontainitselements

•  Nota7on,forasetA:– x∈A:xisanelementofA$\in$– x∉A:xisnotanelementofA$\no7n$

Page 6: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 6

Terminology(1)

•  Defini'on:Twosets,AandB,areequalistheycontainthesameelements.WewriteA=B.

•  Example:–  {2,3,5,7}={3,2,7,5},becauseasetisunordered– Also,{2,3,5,7}={2,2,3,5,3,7}becauseasetcontainsuniqueelements

– However,{2,3,5,7}≠{2,3}$\neq$

Page 7: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 7

Terminology(2)

•  Amul7-setisasetwhereyouspecifythenumberofoccurrencesofeachelement:{m1⋅a1,m2⋅a2,…,mr⋅ar}isasetwhere–  m1occursa17mes–  m2occursa27mes– …–  mroccursar7mes

•  InDatabases,wedis7nguish–  Aset:elementscannotberepeated–  Abag:elementscanberepeated

Page 8: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 8

Terminology(3)

•  Theset-buildernota7onS={x|(x∈Z)∧(x=2k)forsomek∈Z}

reads:Sisthesetthatcontainsallxsuchthatxisanintegerandxiseven

•  Asetisdefinedinintensionwhenyougiveitsset-buildernota7on

S={x|(x∈Z)∧(0≤x≤8)∧(x=2k)forsomek∈Z}

•  Asetisdefinedinextensionwhenyouenumeratealltheelements:

S={0,2,4,6,8}

Page 9: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 9

VennDiagram:Example

•  AsetcanberepresentedgraphicallyusingaVennDiagram

U

a

x y

zA

C

B

Page 10: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 10

MoreTerminologyandNota7on(1)

•  Asetthathasnoelementsiscalledtheemptysetornullsetandisdenoted∅$\emptyset$

•  Asetthathasoneelementiscalledasingletonset.–  Forexample:{a},withbrackets,isasingletonset–  a,withoutbrackets,isanelementoftheset{a}

•  Notethesubtletyin∅≠{∅}–  Thelep-handsideistheemptyset–  Therighthand-sideisasingletonset,andasetcontainingaset

Page 11: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 11

MoreTerminologyandNota7on(2)

•  Defini'on:AissaidtobeasubsetofB,andwewriteA⊆B,ifandonlyifeveryelementofAisalsoanelementofB$\subseteq$

•  Thatis,wehavetheequivalence:A⊆B⇔∀x(x∈A⇒x∈B)

Page 12: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 12

MoreTerminologyandNota7on(3)

•  Theorem:ForanysetSTheorem1,page120– ∅⊆Sand– S⊆S

•  Theproofisinthebook,anexcellentexampleofavacuousproof

Page 13: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 13

MoreTerminologyandNota7on(4)

•  Defini'on:AsetAthatisasubsetofasetBiscalledapropersubsetifA≠B.

•  Thatisthereisanelementx∈Bsuchthatx∉A•  Wewrite:A⊂B,A⊂B•  InLaTex:$\subset$,$\subsetneq$

Page 14: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 14

MoreTerminologyandNota7on(5)

•  Setscanbeelementsofothersets•  Examples

– S1={∅,{a},{b},{a,b},c}– S2={{1},{2,4,8},{3},{6},4,5,6}

Page 15: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 15

MoreTerminologyandNota7on(6)

•  Defini'on:Ifthereareexactlyndis7nctelementsinasetS,withnanonnega7veinteger,wesaythat:– Sisafiniteset,and– ThecardinalityofSisn.Nota7on:|S|=n.

•  Defini'on:Asetthatisnotfiniteissaidtobeinfinite

Page 16: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 16

MoreTerminologyandNota7on(7)

•  Examples– LetB={x|(x≤100)∧(xisprime)},thecardinalityofBis|B|=25becausethereare25primeslessthanorequalto100.

– Thecardinalityoftheemptysetis|∅|=0– ThesetsN,Z,Q,Rareallinfinite

Page 17: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 17

ProvingEquivalence(1)•  Youmaybeaskedtoshowthatasetis

–  asubsetof,–  propersubsetof,or–  equaltoanotherset.

•  ToprovethatAisasubsetofB,usetheequivalencediscussedearlierA⊆B⇔∀x(x∈A⇒x∈B)–  ToprovethatA⊆Bitisenoughtoshowthatforanarbitrary

(nonspecific)elementx,x∈AimpliesthatxisalsoinB.–  Anyproofmethodcanbeused.

•  ToprovethatAisapropersubsetofB,youmustprove–  AisasubsetofBand–  ∃x(x∈B)∧(x∉A)

Page 18: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 18

ProvingEquivalence(2)

•  Finallytoshowthattwosetsareequal,itissufficienttoshowindependently(muchlikeabicondi7onal)that–  A⊆Band–  B⊆A

•  Logicallyspeaking,youmustshowthefollowingquan7fiedstatements:

(∀x(x∈A⇒x∈B))∧(∀x(x∈B⇒x∈A))wewillseeanexamplelater..

Page 19: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 19

PowerSet(1)

•  Defini'on:ThepowersetofasetS,denotedP(S),isthesetofallsubsetsofS.

•  Examples–  LetA={a,b,c},P(A)={∅,{a},{b},{c},{a,b},{b,c},{a,c},{a,b,c}}–  LetA={{a,b},c},P(A)={∅,{{a,b}},{c},{{a,b},c}}

•  Note:theemptyset∅andthesetitselfarealwayselementsofthepowerset.ThisfactfollowsfromTheorem1(Rosen,page120).

Page 20: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 20

PowerSet(2)

•  Thepowersetisafundamentalcombinatorialobjectusefulwhenconsideringallpossiblecombina7onsofelementsofaset

•  Fact:LetSbeasetsuchthat|S|=n,then|P(S)|=2n

Page 21: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 21

Outline•  Defini7ons:set,element•  Terminologyandnota7on

•  Setequal,mul7-set,bag,setbuilder,intension,extension,VennDiagram(representa7on),emptyset,singletonset,subset,propersubset,finite/infiniteset,cardinality

•  Provingequivalences•  Powerset•  Tuples(orderedpair)•  CartesianProduct(a.k.a.Crossproduct),rela'on•  Quan'fiers•  SetOpera7ons(union,intersec7on,complement,difference),Disjointsets•  Setequivalences(cheatsheetorTable1,page130)

•  Inclusioninbothdirec7ons•  Usingmembershiptables

•  GeneralizedUnionsandIntersec7on•  ComputerRepresenta7onofSets

Page 22: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 22

Tuples(1)

•  Some7mesweneedtoconsiderorderedcollec7onsofobjects

•  Defini'on:Theorderedn-tuple(a1,a2,…,an)istheorderedcollec7onwiththeelementaibeingthei-thelementfori=1,2,…,n

•  Twoorderedn-tuples(a1,a2,…,an)and(b1,b2,…,bn)areequaliffforeveryi=1,2,…,nwehaveai=bi(a1,a2,…,an)

•  A2-tuple(n=2)iscalledanorderedpair

Page 23: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 23

CartesianProduct(1)•  Defini'on:LetAandBbetwosets.TheCartesianproductof

AandB,denotedAxB,isthesetofallorderedpairs(a,b)wherea∈Aandb∈B

AxB={(a,b)|(a∈A)∧(b∈B)}•  TheCartesianproductisalsoknownasthecrossproduct•  Defini'on:AsubsetofaCartesianproduct,R⊆AxBiscalleda

rela7on.Wewilltalkmoreaboutrela7onsinthenextsetofslides

•  Note:AxB≠BxAunlessA=∅orB=∅orA=B.Findacounterexampletoprovethis.

Page 24: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 24

CartesianProduct(2)

•  CartesianProductscanbegeneralizedforanyn-tuple

•  Defini'on:TheCartesianproductofnsets,A1,A2,…,An,denotedA1×A2×…×An,isA1×A2×…×An={(a1,a2,…,an)|ai∈Aifori=1,2,…,n}

\prod\limits_{i=1}^nA_i=A_1\7mesA_2\7mes\ldots\7mesA_n

nY

i=1

Ai = A1 ⇥A2 ⇥ . . .⇥An

Page 25: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 25

Nota7onwithQuan7fiers

•  Wheneverwewrote∃xP(x)or∀xP(x),wespecifiedtheuniverseofdiscourseusingexplicitEnglishlanguage

•  Nowwecansimplifythingsusingsetnota7on!•  Example

–  ∀x∈R(x2≥0)–  ∃x∈Z (x2=1)–  Alsomixingquan7fiers:

∀a,b,c∈R∃x∈C (ax2+bx+c=0)

Page 26: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 26

Outline•  Defini7ons:set,element•  Terminologyandnota7on

•  Setequal,mul7-set,bag,setbuilder,intension,extension,VennDiagram(representa7on),emptyset,singletonset,subset,propersubset,finite/infiniteset,cardinality

•  Provingequivalences•  Powerset•  Tuples(orderedpair)•  CartesianProduct(a.k.a.Crossproduct),rela7on•  Quan7fiers•  SetOpera7ons(union,intersec7on,complement,difference),Disjointsets•  Setequivalences(cheatsheetorTable1,page130)

•  Inclusioninbothdirec7ons•  Usingmembershiptables

•  GeneralizedUnionsandIntersec7on•  ComputerRepresenta7onofSets

Page 27: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 27

SetOpera7ons•  Arithme7coperators(+,-,×,÷)canbeusedonpairsofnumberstogiveusnewnumbers

•  Similarly,setoperatorsexistandactontwosetstogiveusnewsets–  Union$\cup$–  Intersec7on$\cap$–  Setdifference$\setminus$–  Setcomplement$\overline{S}$–  Generalizedunion$\bigcup$–  Generalizedintersec7on$\bigcap$

Page 28: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 28

SetOperators:Union

•  Defini'on:TheunionoftwosetsAandBisthesetthatcontainsallelementsinA,B,orboth.Wewrite:

A∪B={x|(x∈A)∨(x∈B)}

U A B

Page 29: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 29

SetOperators:Intersec7on

•  Defini'on:Theintersec7onoftwosetsAandBisthesetthatcontainsallelementsthatareelementofbothAandB.Wewrite:

A∩B={x|(x∈A)∧(x∈B)}U

A B

Page 30: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 30

DisjointSets

•  Defini'on:Twosetsaresaidtobedisjointiftheirintersec7onistheemptyset:A∩B=∅

UA B

Page 31: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 31

SetDifference

•  Defini'on:ThedifferenceoftwosetsAandB,denotedA\B($\setminus$)orA−B,isthesetcontainingthoseelementsthatareinAbutnotinB

UA B

Page 32: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 32

SetComplement

•  Defini'on:ThecomplementofasetA,denotedA($\bar$),consistsofallelementsnotinA.ThatisthedifferenceoftheuniversalsetandU:U\A

A=AC={x|x∉A}

U A A

Page 33: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 33

SetComplement:Absolute&Rela7ve

•  GiventheUniverseU,andA,B⊂U.•  The(absolute)complementofAisA=U\A•  The(rela7ve)complementofAinBisB\A

UAA

UBA

Page 34: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 34

SetIdendi7esLet’stakeaquicklookatthisCheatSheetoratTable1onpage130inyourtextbook

Page 35: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 35

ProvingSetEquivalences

•  Recallthattoprovesuchiden7ty,wemustshowthat:1.  Thelep-handsideisasubsetoftheright-handside2.  Theright-handsideisasubsetofthelep-handside3.  Thenconcludethatthetwosidesarethusequal

•  Thebookprovesseveralofthestandardsetiden77es

•  Wewillgiveacoupleofdifferentexampleshere

Page 36: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 36

ProvingSetEquivalences:ExampleA(1)

•  Let– A={x|xiseven}– B={x|xisamul7pleof3}– C={x|xisamul7pleof6}

•  ShowthatA∩B=C

Page 37: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 37

ProvingSetEquivalences:ExampleA(2)

•  A∩B⊆C:∀x∈A∩B⇒ xisamul7pleof2andxisamul7pleof3⇒ wecanwritex=2.3.kforsomeintegerk⇒ x=6kforsomeintegerk⇒xisamul7pleof6⇒ x∈C

•  C⊆A∩B:∀x∈C⇒ xisamul7pleof6⇒x=6kforsomeintegerk⇒ x=2(3k)=3(2k)⇒xisamul7pleof2andof3⇒ x∈A∩B

Page 38: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 38

ProvingSetEquivalences:ExampleB(1)

•  Analterna7veproveistousemembershiptableswhereanentryis– 1ifachosen(butfixed)elementisintheset– 0otherwise

•  Example:ShowthatA∩B∩C=A∪B∪C

Page 39: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 39

ProvingSetEquivalences:ExampleB(2)AB C A∩B∩C A∩B∩C A B C A∪B∪C

0 0 0 0 1 1 1 1 1

0 0 1 0 1 1 1 0 1

0 1 0 0 1 1 0 1 1

0 1 1 0 1 1 0 0 1

1 0 0 0 1 0 1 1 1

1 0 1 0 1 0 1 0 1

1 1 0 0 1 0 0 1 1

1 1 1 1 0 0 0 0 0

•  1underasetindicatesthat“anelementisintheset”•  Ifthecolumnsareequivalent,wecanconcludethatindeed

thetwosetsareequal

Page 40: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 40

GeneralizingSetOpera7ons:UnionandIntersec7on

•  Inthepreviousexample,weshowedDeMorgan’sLawgeneralizedtounionsinvolving3sets

•  Infact,DeMorgan’sLawsholdforanyfinitesetofsets

•  Moreover,wecangeneralizesetopera7onsunionandintersec7oninastraighyorwardmannertoanyfinitenumberofsets

Page 41: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 41

GeneralizedUnion

•  Defini'on:Theunionofacollec7onofsetsisthesetthatcontainsthoseelementsthataremembersofatleastonesetinthecollec7on

$\bigcup_{i=1}^{n}A_i=A_1\cupA_2\cup\ldots\cupA_n$

n[

i=1

Ai = A1 [A2 [ . . . [An

Page 42: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 42

GeneralizedIntersec7on

•  Defini'on:Theintersec7onofacollec7onofsetsisthesetthatcontainsthoseelementsthataremembersofeverysetinthecollec7on

LaTex:$\bigcap_{i=1}^{n}A_i=A_1\capA_2\cap\ldots\capA_n$

n\

i=1

Ai = A1 \A2 \ . . . \An

Page 43: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 43

ComputerRepresenta7onofSets(1)

•  Therereallyaren’twaystorepresentinfinitesetsbyacomputersinceacomputerhasafiniteamountofmemory

•  IfweassumethattheuniversalsetUisfinite,thenwecaneasilyandeffec7velyrepresentsetsbybitvectors

•  Specifically,weforceanorderingontheobjects,say:U={a1,a2,…,an}

•  ForasetA⊆U,abitvectorcanbedefinedas,fori=1,2,…,n–  bi=0ifai∉A–  bi=1ifai∈A

Page 44: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 44

ComputerRepresenta7onofSets(2)

•  Examples–  LetU={0,1,2,3,4,5,6,7}andA={0,1,6,7}–  Thebitvectorrepresen7ngAis:11000011–  Howistheemptysetrepresented?–  HowisUrepresented?

•  Setopera7onsbecometrivialwhensetsarerepresentedbybitvectors–  Unionisobtainedbymakingthebit-wiseOR–  Intersec7onisobtainedbymakingthebit-wiseAND

Page 45: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 45

ComputerRepresenta7onofSets(3)

•  LetU={0,1,2,3,4,5,6,7},A={0,1,6,7},B={0,4,5}•  Whatisthebit-vectorrepresenta7onofB?•  Compute,bit-wise,thebit-vectorrepresenta7onofA∩B

•  Compute,bit-wise,thebit-vectorrepresenta7onofA∪B

•  Whatsetsdothesebitvectorsrepresent?

Page 46: Sets - cse.unl.educse.unl.edu/~choueiry/S17-235H/files/Sets.pdf · Sets Sec’ons 2.1 and 2.2 of Rosen Spring 2017 CSCE 235H Introduc7on to Discrete Structures (Honors) Course web-page:

SetsCSCE235 46

ProgrammingQues7on

•  Usingbitvector,wecanrepresentsetsofcardinalityequaltothesizeofthevector

•  Whatifwewanttorepresentanarbitrarysizedsetinacomputer(i.e.,thatwedonotknowapriorithesizeoftheset)?

•  Whatdatastructurecouldweuse?