Presentation is loading. Please wait.

Presentation is loading. Please wait.

Discrete Structure Sets. 2 Set Theory Set: Collection of objects (“elements”) a  A “a is an element of A” “a is a member of A” a  A “a is not an element.

Similar presentations


Presentation on theme: "Discrete Structure Sets. 2 Set Theory Set: Collection of objects (“elements”) a  A “a is an element of A” “a is a member of A” a  A “a is not an element."— Presentation transcript:

1 Discrete Structure Sets

2 2 Set Theory Set: Collection of objects (“elements”) a  A “a is an element of A” “a is a member of A” a  A “a is not an element of A” A = {a 1, a 2, …, a n } “A contains…” Order of elements is meaningless It does not matter how often the same element is listed.

3 Sets Curly braces “ { “ and “ } ” are used to denote sets. Java note: In Java curly braces denote arrays, a data-structure with inherent ordering. Mathematical sets are unordered so different from Java arrays. Java arrays require that all elements be of the same type. Mathematical sets don ’ t require this, however. EG: { }

4 Standard Numerical Sets The natural numbers: N = { 0, 1, 2, 3, 4, … } The integers: Z = { … -3, -2, -1, 0, 1, 2, 3, … } The positive integers: Z + = {1, 2, 3, 4, 5, … } The real numbers: R --contains any decimal number of arbitrary precision The rational numbers: Q --these are decimal numbers whose decimal expansion repeats Q: Give examples of numbers in R but not Q.

5 Set Theory (a) Z=the set of integers={0,1,-1,2,-1,3,-3,...} (b) N=the set of nonnegative integers or natural numbers (c) Z + =the set of positive integers (d) Q=the set of rational numbers={a/b| a,b is integer, b not zero} (e) Q + =the set of positive rational numbers (f) Q*=the set of nonzero rational numbers (g) R=the set of real numbers (h) R + =the set of positive real numbers (i) R*=the set of nonzero real numbers (j) C=the set of complex numbers

6  -Notation The Greek letter “  ” (epsilon) is used to denote that an object is an element of a set. When crossed out “  ” denotes that the object is not an element. ” EG: 3  S reads: “ 3 is an element of the set S ”. Q: Which of the following are true: 1. 3  R 2. -3  N 3. -3  R 4. 0  Z + 5.  x x  R  x 2 =-5

7 7 Examples for Sets A =  or A={ } “empty set/null set” A = {z} Note: z  A, but z  {z} A = {{b, c}, {c, x, d}} A = {{x, y}} Note: {x, y}  A, but {x, y}  {{x, y}} A = {x | P(x)} “set of all x such that P(x)” A = {x | x  N  x > 7} = {8, 9, 10, …} “set builder notation”

8 Set Builder Notation Up to now sets have been defined using the curly brace notation “ { … } ” or descriptively “ the set of all natural numbers ”. The set builder notation allows for concise definition of new sets. For example { x | x is an even integer } { 2x | x is an integer } are equivalent ways of specifying the set of all even integers.

9 9 Set Operations Union: A  B = {x | x  A  x  B} Example: A = {a, b}, B = {b, c, d} A  B = {a, b, c, d} Intersection: A  B = {x | x  A  x  B} Example: A = {a, b}, B = {b, c, d} A  B = {b}

10 Set Builder Notation. Examples. A1: U = N. { x |  y (y  x ) } = { 0 } A2: U = Z. { x |  y (y  x ) } = { } A3: U = Z. { x |  y (y  R  y 2 = x )} = { 0, 1, 2, 3, 4, … } = N A4: U = Z. { x |  y (y  R  y 3 = x )} = Z A5: U = R. { |x | | x  Z } = N A6: U = R. { |x | } = non-negative reals.

11 L411  -Notation DEF: A set S is said to be a subset of the set T iff every element of S is also an element of T. This situation is denoted by S  T A synonym of “ subset ” is “ contained by ”. Definitions are often just a means of establishing a logical equivalence which aids in notation. The definition above says that: S  T   x (x  S )  (x  T ) We already had all the necessary concepts, but the “  ” notation saves work.

12 L412  -Notation When “  ” is used instead of “  ”, proper containment is meant. A subset S of T is said to be a proper subset if S is not equal to T. Notationally: S  T  S  T   x (x  S  x  T ) Q: What algebraic symbol is  reminiscent of?

13 13 Subsets Useful rules: A = B  (A  B)  (B  A) (A  B)  (B  C)  A  C (see Venn Diagram) U A B C

14 Union A  B = { x | x  A  x  B } Elements in at least one of the two sets: AB U ABAB

15 Intersection A  B = { x | x  A  x  B } Elements in exactly one of the two sets: AB U ABAB

16 Disjoint Sets DEF: If A and B have no common elements, they are said to be disjoint, i.e. A  B = . AB U

17 Set Difference A  B = { x | x  A  x  B } Elements in first set but not second: A B U ABAB

18 Symmetric Difference AB UABAB A  B = { x | x  A  x  B } Elements in exactly one of the two sets:

19 Complement  A = { x | x  A } Elements not in the set (unary operator): A U AA

20 Set Identities  Identity laws  Domination laws  Idempotent laws  Double complementation  Commutativity  Associativity  Distribuitivity  DeMorgan logical identities rewriting as follows: disjunction “  ” becomes union “  ” conjunction “  ” becomes intersection “  ” negation “  ” becomes complementation “–” false “ F ” becomes the empty set  true “ T ” becomes the universe of reference U

21 Set Identities In fact, the logical identities create the set identities by applying the definitions of the various set operations. For example: LEMMA: (Associativity of Unions) (A  B )  C = A  (B  C ) Proof : (A  B )  C = {x | x  A  B  x  C } (by def.) = {x | (x  A  x  B )  x  C } (by def.) = {x | x  A  ( x  B  x  C ) } (logical assoc.) = {x | x  A  (x  B  C ) } (by def.) = A  (B  C ) (by def.)  Other identities are derived similarly.

22 L522 Visual DeMorgan =

23 Cardinality The cardinality of a set is the number of distinct elements in the set. |S | denotes the cardinality of S. Q: Compute each cardinality. 1. |{1, -13, 4, -13, 1}| 2. |{3, {1,2,3,4},  }| 3. |{}| 4. |{ {}, {{}}, {{{}}} }|

24 L424 Cardinality Hint: After eliminating the redundancies just look at the number of top level commas and add 1 (except for the empty set). A: 1. |{1, -13, 4, -13, 1}| = |{1, -13, 4}| = 3 2. |{3, {1,2,3,4},  }| = 3. To see this, set S = {1,2,3,4}. Compute the cardinality of {3,S,  } 3. |{}| = |  | = 0 4. |{ {}, {{}}, {{{}}} }| = |{ , {  }, {{  }}| = 3

25 L425 Cardinality DEF: The set S is said to be finite if its cardinality is a nonnegative integer. Otherwise, S is said to be infinite. EG: N, Z, Z +, R, Q are each infinite. Note: We ’ ll see later that not all infinities are the same. In fact, R will end up having a bigger infinity-type than N, but surprisingly, N has same infinity-type as Z, Z +, and Q.

26 Set Theory Counting and Venn Diagrams In a class of 50 college freshmen, 30 are studying BASIC, 25 studying PASCAL, and 10 are studying both. How many freshmen are studying either computer language? U AB 101520 5

27 Set Theory Counting and Venn Diagrams Given 100 samples set A: with D 1 set B: with D 2 set C: with D 3 Defect types of an AND gate: D 1 : first input stuck at 0 D 2 : second input stuck at 0 D 3 : output stuck at 1 with |A|=23, |B|=26, |C|=30,, how many samples have defects? A B C 11 4 3 5 7 12 15 43 Ans:57

28 Power Set DEF: The power set of S is the set of all subsets of S. Denote the power set by P (S ) or by 2 s. The latter weird notation comes from the following. Lemma: | 2 s | = 2 |s|

29 Power Set – Example To understand the previous fact consider S = {1,2,3} Enumerate all the subsets of S : 0-element sets: {} 1 1-element sets: {1}, {2}, {3} +3 2-element sets: {1,2}, {1,3}, {2,3} +3 3-element sets: {1,2,3}+1 Therefore: | 2 s | = 8 = 2 3 = 2 |s|

30 Cartesian Product The most famous example of 2-tuples are points in the Cartesian plane R 2. Here ordered pairs (x,y) of elements of R describe the coordinates of each point. We can think of the first coordinate as the value on the x- axis and the second coordinate as the value on the y-axis. DEF: The Cartesian product of two sets A and B – denoted by A  B – is the set of all ordered pairs (a, b) where a  A and b  B. Q: Describe R 2 as the Cartesian product of two sets.

31 Cartesian Product A: A = {1,2}, B = {3,4}, C = {5,6,7} A  B  C = { (1,3,5), (1,3,6), (1,3,7), (1,4,5), (1,4,6), (1,4,7), (2,3,5), (2,3,6), (2,3,7), (2,4,5), (2,4,6), (2,4,7) } Lemma: The cardinality of the Cartesian product is the product of the cardinalities: | A 1  A 2  …  A n | = |A 1 |  |A 2 |  …  |A n | Q: What does  S equal?

32 Set Theory Set Operations and the Laws of Set Theory The Laws of Set Theory

33 Set Theory Set Operations and the Laws of Set Theory The Laws of Set Theory

34 Generalized Union Binary union operator: A  B n-ary union: A  A 2  …  A n :  ((…((A 1  A 2 )  …)  A n ) (grouping & order is irrelevant) “Big U” notation: Or for infinite sets of sets:

35 Generalized Intersection Binary intersection operator: A  B n-ary intersection: A  A 2  …  A n  ((…((A 1  A 2 )  …)  A n ) (grouping & order is irrelevant) “Big Arch” notation: Or for infinite sets of sets:

36 Mutual subsets 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).  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). …

37 Membership Table Exercise Prove (A  B)  C = (A  C)  (B  C).

38 Ordered n-tuples Notationally, n-tuples look like sets except that curly braces are replaced by parentheses: ( 11, 12 ) – a 2-tuple aka ordered pair (,, ) – a 3-tuple (,,, 11, Leo ) – a 5-tuple Java: n -tuples are similar to Java arrays “ { … } ”, except that type-mixing isn ’ t allowed in Java. As opposed to sets, repetition and ordering do matter with n-tuples. (11, 11, 11, 12, 13)  ( 11, 12, 13 ) (,,)  (,,)

39 39 Exercises Question 1: Given a set A = {x, y, z} and a set B = {1, 2, 3, 4}, what is the value of | 2 A  2 B | ? Question 2: Is it true for all sets A and B that (A  B)  (B  A) =  ? Or do A and B have to meet certain conditions? Question 3: For any two sets A and B, if A – B =  and B – A = , can we conclude that A = B? Why or why not?

40 Blackboard Exercise Prove the following: If A  B and B  C then A  C.

41 Set Theory


Download ppt "Discrete Structure Sets. 2 Set Theory Set: Collection of objects (“elements”) a  A “a is an element of A” “a is a member of A” a  A “a is not an element."

Similar presentations


Ads by Google