The Power Set 1/3 Suppose A = {a, b}. The subsetsof A are, {a},{b}&{a, b} The set of these subsets is called the power setof A, denoted by P (A) i.e. P(A) = {,{a},{b},{a, b}} Note that P(A) is a set whose elements are themselves sets i.e. it is a set of sets Also note that A has 2 elements, & P(A) has 4 elements 2
Definition: The power set of a set S, denoted P(S), is the set of all subsets of S. Examples The Power Set 2/3 Let A={a,b,c}, P(A)={,{a},{b},{c},{a,b},{b,c},{a,c},{a,b,c}} Let A={{a,b},c}, P(A)={,{{a,b}},{c},{{a,b},c}} Note: the empty set and the set itself are always elements of the power set.
The Power Set 3/3 The power set is a fundamental combinatorial object useful when considering all possible combinations of elements of a set Fact: Let S be a set such that S =n, then P(S) = 2 n
Example for A = {2, 4, 17, 23}, calculate P(A) P(A) ={, {2}, {4}, {17}, {23}, {2, 4}, {2, 17}, {2, 23}, {4, 17}, {4, 23}, {17, 23},{2, 4, 17}, {2, 4, 23}, {2, 17, 23}, {4, 17, 23}, {2, 4, 17, 23} } B = {a,b}, calculate P(B) P(B) = {, {a}, {b}, {a,b}}.
Cardinality of the Power Set The cardinalityof a finite set Ais the no. of elements in the set, written as A Example: If A = {a, b, c}, then A = 3 Observe that A has 3 elements, & P(A) has 8 elements This leads to the general observation: If A has n elements, then P(A) has 2 n elements i.e. if A = n, then P(A) = 2 n Then a set with nelements has 2 n subsets 6
Ordered Pairs When dealing with sets, the ordering of elements in the set is immaterial e.g.{2, 1, 4} = {1, 4, 2} Sometimes, though, orderdoes matter e.g.: (i) a list of place-getters in a race, or a list of football teams in order of leader position; (ii) an ordered string of characters such as a tax file no., password, credit card PIN or car reg. no. An ordered pair is a pair of elements in a particular order, written as (a, b) 7
Tuples Sometimes we need to consider ordered collections of objects Definition: The ordered n-tuple (a 1,a 2,,a n ) is the ordered collection with the element a i being the i-th element for i=1,2,,n Two ordered n-tuples (a 1,a 2,,a n ) and (b 1,b 2,,b n ) are equal if and only if for every i=1,2,,n we have a i =b i (a 1,a 2,,a n ) A 2-tuple (n=2) is called an ordered pair
Ordered n-tuples Thus the ordered pair (3, 5) is differentto (5, 3) Note the use of parentheses( round brackets ), and not braces ( curly brackets ) as for sets If we have nelements, an ordered n-tupleis a list of the n elements in a particular order it is written as (x 1, x 2, x 3,, x n ) Since order is important, the only way for (x 1, x 2, x 3,, x n ) = (y 1, y 2, y 3,, y n )is if the 1 st elements are the same (i.e. x 1 = y 1 ), the 2 nd elements are the same (i.e. x 2 = y 2 ), and so on So (1, 4, 5) (1, 5, 4) (but{1, 4, 5} = {1, 5, 4}) 9
Cartesian Product Definition: Let A and B be two sets. The Cartesian product of A and B, denoted AxB, is the set of all ordered pairs (a,b) where a A and b B AxB={ (a,b) (a A) (b B) } The Cartesian product is also known as the cross product Definition: A subset of a Cartesian product, R AxB is called a relation. We will talk more abot relations in the next set of slides Note: AxB BxA unless A= or B= or A=B. Find a counter example to prove this.
Cartesian Product Cartesian Products can be generalized for any n-tuple Definition: The Cartesian product of n sets, A 1,A 2,, A n, denoted A 1 A 2 A n, is A 1 A 2 A n ={ (a 1,a 2,,a n ) a i A i for i=1,2,,n}
The Cartesian Product of 2 Sets The Cartesian product of 2 sets Aand Bis A B = {(x, y): x A and y B} i.e. It is the set of all ordered pairs, where the first element is from A& the second element is from B e.g.if A is the set of digits 0-9, & B is the set of letters a-z, then (3, t) is in A B, but (m, 7) is not in A B although it is in B A e.g.if A = {1, 2, 3} & B = {p, q}, then A B = {(x, y): x A and y B} = {(1, p), (1, q), (2, p), (2, q), (3, p), (3, q)} 12
Example K = {a,b,c} and L = {1,2}, then K L = {(a,1),(a,2),(b,1),(b,2),(c,1),(c,2)} L K = {(1,a),(2,a),(1,b),(2,b),(1,c),(2,c)} L L = {(1,1),(1,2),(2,1),(2,2)} 13
The Cartesian Product of n Sets The Cartesian product of n sets A 1, A 2,, A n is A 1 A 2 A n = {(x 1, x 2, x 3,, x n ): x 1 A 1, x 2 A 2,, x n A n } i.e. It is the set of all ordered n-tuples, where the 1 st eltis from A 1, the 2 nd eltis from A 2,etc e.g.a car reg. no. such as KCT454 can be regarded as an ordered 6-tuple (K, C, T, 4, 5,4). If L is the set of all letters, & D is the set of all decimal digits, then the set of all possible car registration is L L L D D D 14
Cartesian Product of a Set with Itself The set A A A (n times) is written as A n e.g.if Ris the set of real nos, then R 2 is the set of all ordered pairs (x, y),where x& y are real nos geometrically, R 2 is the 2-dimensional plane Similarly, think of R 3 as all points in 3-dim space 15
Cartesian Product of a Set with Itself e.g.{0, 1} 2 = {(0, 0), (0, 1), (1, 0), (1, 1)} e.g.the elements of {0, 1} n are ordered n-tuples in which each element is 0or 1 so a typical element of {0, 1} 6 is (0, 1, 1, 1, 0, 1) Think of {0, 1} n as the set of all strings of nbits Notethat L L L D D D = L 3 D 3 16
Computer Representation of Sets Now look at how computersstore and manipulate sets A set is always defined with reference to a universal set U To enable computers to handle sets, assume the elements of Uare listed in a definite order Then, if U = n and Ais a set, Ais represented by a string of nbits b 1 b 2 b 3 b n Here b i is 1if the i th eltof Uis in A, and b i is 0 if the i th eltof Uis not in A 17
Computer Representation of Sets Example:Suppose E = {a, b, c, d, e, f, g}.find: (a) the representation of {d, f, a, g} as a bit string (b) the set represented by the bit string 0111011 For sets defined w.r.t. the sameuniversal set, the operations of intersection, union & complement can be carried out directly on the bit strings, without having to convert to the original sets 18
Example Let U = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, and the ordering of elements of U has the elements in increasing order; that is, a i = i. What bit strings represent the subset of all odd integers in U, the subset of all even integers in U, and the subset of integers not exceeding 5 in U?
Example The bit string that represents the set of odd integers in U, namely, {1, 3, 5, 7, 9}, has a one bit in the first, third, fifth, seventh, and ninth positions, and a zero elsewhere. It is 1010101010. (We have split this bit string of length ten into blocks of length four for easy reading because long bit strings are difficult to read.) Similarly, we represent the subset of all even integers in U, namely, {2, 4, 6, 8, 10}, by the string 0101010101. The set of all integers in U that do not exceed 5, namely, {1, 2, 3, 4, 5}, is represented by the string 1111100000.
Computer Representation of Sets