YangJuanyangjuan@bupt.edu.cnCollegeofComputerScience&TechnologyBeijingUniversityofPosts&TelecommunicationsSetOperations(集合的运算)22020/1/5CollegeofComputerScience&Technology,BUPTSetOperationsPropositionalcalculus(命题演算)andsettheory(集合论)arebothinstancesofanalgebraicsystem(代数系统)calledaBooleanAlgebra(布尔代数)TheoperatorsinsettheoryaredefinedintermsofthecorrespondingoperatorinpropositionalcalculusAsalwaystheremustbeauniverseU.AllsetsareassumedtobesubsetsofU32020/1/5CollegeofComputerScience&Technology,BUPTEqual(相等)Definition:TwosetsAandBareequal,denotedA=B,iffx[xAxB].Note:ByapreviouslogicalequivalencewehaveA=Biffx[(xAxB)(xBxA)]orA=BiffABandBA42020/1/5CollegeofComputerScience&Technology,BUPTDefinitionsTheunion(并集)ofAandB,denotedAB,istheset{x|xAxB}Theintersection(交集)ofAandB,denotedAB,istheset{x|xAxB}Note:Iftheintersectionisvoid,AandBaresaidtobedisjoint(不相交).Thecomplement(补集)ofA,denotedA,istheset{x|(xA)}Note:AlternativenotationisAc,and{x|xA}.52020/1/5CollegeofComputerScience&Technology,BUPTTheAdditionprinciple(加法原理)TheoremIfAandBarefinitesets,then|AB|=|A|+|B|-|AB|Italsocalledtheinclusion-exclusionprinciple(容斥原理)62020/1/5CollegeofComputerScience&Technology,BUPTExampleLetA={a,b,c,d,e}andB={c,e,f,h,k,m}.Verifyinclusion-exclusionprinciple.Solution:AB={a,b,c,d,e,f,h,k,m}andAB={c,e}|A|=5,|B|=6,|AB|=9and|AB|=2|A|+|B|-|AB|=9=|AB|Q.E.D72020/1/5CollegeofComputerScience&Technology,BUPTTheAdditionprincipleforDisjointSets|AB|=|A|+|B|82020/1/5CollegeofComputerScience&Technology,BUPTDefinitionsThedifference(差)ofAandB,orthecomplementofBrelativetoA(,denotedA-B,isthesetABNote:The(absolute)complementofAisU-A.Thesymmetricdifference(对称差)ofAandB,denotedAB,istheset(A-B)(B-A)92020/1/5CollegeofComputerScience&Technology,BUPTVennDiagramsAusefulgeometricvisualizationtool(for3orlesssets)TheUniverseUistherectangularboxEachsetisrepresentedbyacircleanditsinteriorAllpossiblecombinationsofthesetsmustberepresented102020/1/5CollegeofComputerScience&Technology,BUPTVennDiagramsShadetheappropriateregiontorepresentthegivensetoperation.112020/1/5CollegeofComputerScience&Technology,BUPTVennDiagrams122020/1/5CollegeofComputerScience&Technology,BUPT132020/1/5CollegeofComputerScience&Technology,BUPT142020/1/5CollegeofComputerScience&Technology,BUPTExamplesU={0,1,2,3,4,5,6,7,8,9,10}A={1,2,3,4,5},B={4,5,6,7,8}.ThenAB={1,2,3,4,5,6,7,8}AB={4,5}A={0,6,7,8,9,10}B={0,1,2,3,9,10}A-B={1,2,3}B-A={6,7,8}AB={1,2,3,6,7,8}152020/1/5CollegeofComputerScience&Technology,BUPTAlgebraicPropertiesofSetOperations(集合运算的基本定律)Commutativeproperties(交换律)Associativeproperties(结合律)Distributiveproperties(分配律)ABBAABBA()()()()ABCABCABCABC()()()()()()ABCABACABCABAC162020/1/5CollegeofComputerScience&Technology,BUPTAlgebraicPropertiesofSetOperations(集合运算的基本定律)Idempotentproperties(等幂律)PropertiesoftheComplementAAAAAAAAAAUAAUUABABABAB172020/1/5CollegeofComputerScience&Technology,BUPTAlgebraicPropertiesofSetOperationsPropertiesofaUniversalSetPropertiesoftheEmptySetAUUAUAAAA182020/1/5CollegeofComputerScience&Technology,BUPTProvingSetIdentitiesToprovestatementsaboutsets,oftheformE1=E2(wheretheEsaresetexpressions),herearethreeusefultechniques:1.ProveE1E2andE2E1separately.2.Usesetbuildernotation&logicalequivalences.3.Useamembershiptable.192020/1/5CollegeofComputerScience&Technology,BUPTMethod1:MutualsubsetsExample:ShowA(BC)=(AB)(AC).Part1:ShowA(BC)(AB)(AC).AssumexA(BC),&showx(AB)(AC).WeknowthatxA,andeitherxBorxC.Case1:xB.ThenxAB,sox(AB)(AC).Case2:xC.ThenxAC,sox(AB)(AC).Therefore,x(AB)(AC).Therefore,A(BC)(AB)(AC).Part2:Show(AB)(AC)A(BC).…202020/1/5CollegeofComputerScience&Technology,BUPTMethod2:UsesetbuildernotationEXAMPLE10ProofthatAB={x|xAB}bydefinitionofcomplement={x|{x(AB)}bydefinitionofdoesnotbelongsymbol={x|(xAxB)}bydefinitionofintersection={x|(xA)(xB)}bythefirstDeMorganlawforlogicalequivalences={x|xAxB}bydefinitionofdoesnotbelongsymbol={x|xAxB}bydefinitionofcomplement={x|xAB}bydefinitionofunion=ABbymeaningofsetbuildernotationABAB212020/1/5CollegeofComputerScience&Technology,BUPTMethod3:MembershipTablesJustliketruthtablesforpropositionallogic.Columnsfordifferentsetexpressions.Rowsforallcombinationsofmembershipsinconstituentsets.Use“1”toindicatemembershipinthederivedset,“0”fornon-membership.Proveequivalencewithidenticalcolumns.222020/1/5CollegeofComputerScience&Technology,BUPTMembershipTableExampleProve(AB)-B=A-B.AABBAABB((AABB))--BBAA--BB00000011001011111100232020/1/5CollegeofComputerScience&Technology,BUPTMembershipTableExerciseProve(AB)-C=(A-C)(B-C).ABCAABB((AABB))--CCAA--CCBB--CC((AA--CC))((BB--CC))000001010011100101110111242020/1/5CollegeofComputerScience&Technology,BUPTGeneralizedUnions&IntersectionsSinceunion&intersectionarecommutativeandassociative,wecanextendthemfromoperatingonorderedpairsofsets(A,B)tooperatingonsequencesofsets(A1,…,An),orevenonunord