Você está na página 1de 7

SetUnion

SetOperations

Section2.2

Definition:LetA andB besets.Theunion ofA andB,denotedA B,isthesetcontaining thoseelementsthatareeitherinA orinB,orin both. Formally,A B={x|x A xB} VennDiagram
U A B

SetIntersection
Definition:LetA andB besets.Theintersection ofA andB,denotedbyA B,istheset containingthoseelementswhichareinbothA andB. Formally,A B={x|x A xB }
U A B

SetComplement
Definition:LetU betheuniversalset.The complement ofasetS,denotedS, istheset containingelementsofU whicharenotinS. Formally,S ={x U |x S} S =U S
U S

2006 by A-H. Esfahanian. All Rights Reserved.

1-

SetDifference
Definition: LetA and B besets.Thedifference ofA andB,denotedA B ,istheset containingthoseelementsthatareinA but arenotinB.
A Bisalsocalledthecomplement of Bwithrespect to A. A B={x|x A xB} U A B

DisjointSets
Definition:TwosetsA andB aredisjoint iftheir intersectionistheemptyset, Thatis,ifA B= . Principleofinclusionexclusionforfinitesets:
|A B|=|A|+|B|- |A B| IfA B =,then|A B|=|A|+|B|

SetIdentities
Sets togetherwith the operators{,, } defineaspecialclassofBooleanalgebraic structures.

SetIdentities
A U =A A =A Identitylaws

2006 by A-H. Esfahanian. All Rights Reserved.

1-

SetIdentities
A U =A A =A A U =U A = Identitylaws Dominationlaws

SetIdentities
A U =A A =A A U =U A = A A =A A A =A Identitylaws Dominationlaws Idempotentlaws

10

SetIdentities
A U =A A =A A U =U A = A A =A A A =A A =A Identitylaws Dominationlaws Idempotentlaws Complementationlaw

SetIdentities
A U =A A =A A U =U A = A A =A A A =A A =A A B =B A A B =B A Commutativelaws Identitylaws Dominationlaws Idempotentlaws Complementationlaw

11

12

2006 by A-H. Esfahanian. All Rights Reserved.

1-

SetIdentities
(A B) C =A (B C) (A B) C =A (B C) Associative laws

SetIdentities
(A B) C =A (B C) (A B) C =A (B C) A (B C)=(A B) (A C) A (B C)=(A B) (A C) Associative laws Distributive laws

13

14

SetIdentities
(A B) C =A (B C) (A B) C =A (B C) A (B C)=(A B) (A C) A (B C)=(A B) (A C) (A B)=A B (A B)=A B Associative laws Distributive laws DeMorgans laws

SetIdentities
(A B) C =A (B C) (A B) C =A (B C) A (B C)=(A B) (A C) A (B C)=(A B) (A C) (A B)=A B (A B)=A B A A =U A A = Associative laws Distributive laws DeMorgans laws

15

16

2006 by A-H. Esfahanian. All Rights Reserved.

1-

SetIdentities Example.
(A B)=A B Toshowthisidentitywecan:
1) 2) 3)

Example:UsingSetBuilder
(A B) = {x |x (A B)} = {x | (x (A B))} Defn.(Complement) Defn.()

Usethedefinitionthat A= B (A B) (B A) UseSetBuildernotation Usemembershiptables

= {x | [(x A) (x B)]} Defn.(Union) = {x | (x A) (x B)} DeMorgans = {x | (x A) (x B)} ={x | (x A) (x B)} =A B Defn.() Defn.(Complement) Defn.(Intersection)

17

18

Example UsingMembershipTable
A B A B AB (A B) AB

Example
Wecanuseprovenidentitiestoprovenewidentities.

1 1 0 0

1 0 1 0

0 0 1 1

0 1 0 1

1 1 1 0

0 0 0 1

0 0 0 1

(A (B C)) = A (B C) = A ( B C) = (A B) (A C) =(A B) (A C)

DeMorganslaw DeMorganslaw Distributivelaw DeMorganslaw

1= an element in the set

0 = an element is not in the set

What similarities do you notice between membership tables and truth tables?
19 20

2006 by A-H. Esfahanian. All Rights Reserved.

1-

ProofofSetIdentities
WecanuseVenndiagramstogetsomeideas aboutthecorrectnessoftheidentity. Thismethodcantbeusedtoprovethe identities.

GeneralizedUnion
Definition: Theunion ofacollectionofsetsisthe setcontainingthoseelementsthataremembersof atleastonesetinthecollection.

A1 U A2 U ... U An = U Ai
i =1

21

22

GeneralizedIntersection
Definition: Theintersection ofacollectionofsetsisthe setcontainingthoseelementsthataremembersofall thesetsinthecollection.

RussellsParadox
LetS bethesetofallsetswhichdonotcontain themselves. Thatis, S ={T |T T } DoesS containitself???

A1 I A2 I ... I An = I Ai
i =1

23

24

2006 by A-H. Esfahanian. All Rights Reserved.

1-

ComputerRepresentationofSets
Useanarbitraryorderingoftheelementsofthe finiteuniversalsetU:
(a1,a2,,an)

ComputerRepresentation
Example:U ={1,2,pen,guitar,car,keyboard}
Weneeda6bitstring(a1,a2,,a6)andanordering: (1,pen,keyboard,2,car,guitar) = (a1,a2,,a6)

RepresentasubsetA ofU withthebitstringof lengthn:


ith bitis:1ifai A 0ifai A

Now,letA ={2,pen,car,keyboard}. Thestring thatrepresentsA is(0,1,1,1,1,0) Whatstringrepresents U? Whatstringrepresents ?

25

26

ComputerRepresentation
Withthestringrepresentationofaset,andthe followingconventions,wecandoany operation
Setcomplementation:Inverteachbit(0to1,1to0) Setunion:Doabitwiseaddition
0+1=1+0=1 1+1=1,0+0=0

Noteoncomputerimplementations
Someprogramminglanguageshavethefinite setasastandarddatatype. TheStandardTemplateLibraryofC++hasaset class.(Themultiset allowsrepeatedelements.) Realnumbers(floats,doubles)typicallycannot bemembersofpracticalsetsbecause uniqueness(=test)isnotwelldefined. SetopsaretypicallyO(log n) orbetterin executiontime,wheren isthesetsize

SetIntersection:Doabitwisemultiplication
0 1=1 0=0 1 1=1,0 0=0

27

2006 by A-H. Esfahanian. All Rights Reserved.

1-

Você também pode gostar