You are on page 1of 52

CC1041: Discrete Structures

Lecture 13-14 (Sets & Its Operations)


Instructor:
Muhammad Awais Ali
Lecturer
awaisali@umt.edu.pk

School of Systems and Technology


Department of Computer Science
05/28/2023 University of Management and Technology, Lahore
Previous Lecture

In the previous lecture you learned about:

 Proof Terminologies

 Proof Methods

05/28/2023
2
Today’s Contents

In this today’s lecture you will learn about:

 Why sets?

 What is set?

 Basic notations of Sets

 Basic Properties of Sets

 Finite & Infinite Sets

 Venn Diagrams

 Sets Relationship with Venn Diagrams E

 Set Operations

 Sets equality

05/28/2023
3
Why study Set Theory?

Understanding set theory helps people to …

1. See things in terms of systems.

2. Organize things into groups.

3. Begin to understand logic.


Sets
 A set is a new type of structure, representing an unordered
collection (group) of zero or more distinct (different) objects.
The objects are called elements or members of the set.
 The elements or members of a set can be anything: numbers,
people, letters of the alphabet, other sets, and so on. Sets are
conventionally denoted with capital letters.
 Notation: a is an element of the set S, denoted by a ∈ S.
 a is not an element of the set A, denoted by a ∉ A.
 Set theory deals with operations between, relations among,
and statements about sets.
 Note: A set should be well defined and distinct.
Basic Notations for Sets
 For sets, we’ll use capital letters (variables) S, T, U,…
 We can denote a set S in writing by listing all of its elements in curly
braces:
 {a,b,c} is the set whose elements are a, b, and c

 Set builder notation:


 Characterize all elements in the set by stating properties they must
have
The vertical bar
 For any statement P(x) over any domain, means “such that”
{x | P(x)} is the set of all x such that P(x) is true

 Example: S={1, 2, 3, 4}
= {x | x is an integer where x  0 and x  5 }
= {x Z | x  0 and x  5 }
Examples
 A = {tiger, lion, puma, cheetah, leopard, ocelot} (this is a set of large
species of animals).
 A = {a, b, c, ..., z} (this is a set consisting of the lowercase letters of
the alphabet)
 A = {-1, -2, -3, ...} (this is a set of the negative numbers)
 Set D: Students taking Discrete Mathematics course.
 Assume Ali is taking Discrete Mathematics course and Saeed is not
taking Discrete Mathematics course.
 Ali ∈ D & Saeed ∉ D
 In all above examples each element of the sets is distinct and well
defined.
Basic Properties of Sets

 Sets are inherently unordered: No matter what


objects a, b, and c denote,
{a, b, c} = {a, c, b} = {b, a, c} =
{b, c, a} = {c, a, b} = {c, b, a}.

 All elements are distinct (unequal); multiple


listings make no difference!
Special Sets
 There are some sets which hold great mathematical importance and are referred
to with such regularity that they have acquired special names and notational
conventions to identify them.
 One of these is the empty set, denoted { } or ∅.
 Another is the singleton set {x} which contains exactly one element, namely x.
 P or ℙ, denoting the set of all primes P = {2, 3, 5, 7,11, 13, 17, ...}.
 N or ℕ, denoting the set of all natural numbers: N = {1, 2, 3, . . .}.
 Z or ℤ, denoting the set of all integers (whether positive, negative or zero):
Z = {..., −2, −1, 0, 1, 2, ...}.
 Set of positive integers 𝐙+ = {1,2,3,…}
 We write a ∈ A to denote that a is an element of the set A. The notation a ∈ A
denotes that a is not an element of the set A
Special Sets (Conts…)

 Set of rational numbers Q or ℚ, Q = {a/b : a, b


∈ Z, b ≠ 0}. For example, 1/4 ∈ Q and 11/6 ∈ Q.
 R or ℝ, denoting the set of all real numbers. This set
includes all rational numbers, together with all
irrational numbers (that is, numbers which cannot be
rewritten as fractions, such as π, e, and √2, as well as
numbers that cannot be defined).
 C or ℂ, denoting the set of all complex numbers : C =
{a + bi : a, b ∈ R}. For example, 1 + 2i ∈ C.
The Empty Set

  (“null”, “the empty set”) is the unique set


that contains no elements whatsoever.
  = { } = {x | False}
 { }  {} = { { } }
 {} it isn’t empty because it has  as a member!
Sets Are Objects, Too!

 The objects that are elements of a set may


themselves be sets.
 Example:
Let S = {x | x  {1, 2, 3}}
then S = { ,
{1}, {2}, {3},
{1, 2}, {1, 3},
{2, 3},
{1, 2, 3} }

 Note that 1  {1} 


Finite & Infinite Sets

 Finite Set: A set is finite if it contains a specific (finite)


number of elements, i.e., If we can count the element in a
set, such sets are called finite sets.
 Example: Some finite numbers in a set: the number of
digits on your hand, the number of seats on a bus, and
the number of people on earth.
 Infinite Set: If we can not count the elements in a set
such sets are called infinite sets.
 Example: Set of Natural numbers. Set of Whole numbers.
 Cardinality: refers to the number of elements in a set.
Finite and Infinite Set Cardinality

Set Definition Cardinality

A = {x | x is a lower case letter} |A| = 26

B = {2, 3, 4, 5, 6, 7} |B| = 6

C = {x | x is an even number  10} |C|= 4

A = {1, 2, 3, …} |A| =

B = {x | x is a point on a line} |B| =

C = {x| x is a point in a plane} |C| =


Venn Diagrams
 Venn diagrams or set diagrams are diagrams that show all
possible logical relations between a finite collection of sets. Venn
diagrams were conceived around 1880 by John Venn.
 Venn diagrams show relationships between sets and their
elements.
Sets A & B

Universal Set
Notations of Set Relationship
 Symbol Meaning
Upper case designates set name
Lower case designates set elements
{ } enclose elements in set
 (or ∉ ) is (or is not) an element of
 is a subset of (includes equal sets)
 is a proper subset of
 is not a subset of
 is a superset of
| or : such that (if a condition is true)
| | the cardinality of a set
Basic Set Relations : Universal Sets
 The key relation between sets is membership when one set is an
element of another.
 If a is a member of B, this is denoted a ∈ B, while if c is not a
member of B then c ∉ B.
 For example, With respect to the sets A = {1,2,3,4} and B = {blue,
white, red}, 4 ∈ A and green ∉ B.
 Universal Sets: The universal set is the set of all things relevant to a
given discussion and is designated by the symbol U. i.e. it contains
every set.
 U is the universal set – the set of all of elements (or the “universe”)
from which given any set is drawn
Basic Set Relations : Subsets
 Subsets: If every member of set A is also a member of set B, then A
is said to be a subset of B, written A ⊆ B (also pronounced A is
contained in B). The relationship between sets established by ⊆ is
called inclusion or containment.
 Examples
A = {1,2,3,4},
B = {1,2,3,4,5,7}, and
C = {7,9,3}, and the universal set U = {1,2,3,4,5,6,7,8,9}.
Basic Set Relations : Super Set
 Super Set: if we can write B ⊇ A, read as B is a superset of A, B
includes A, or B contains A.
 Proper Subset: If A is a subset of, but not equal to, B, then A is
called a proper subset of B, written A ⊂ B (A is a proper subset of
B) or B ⊃ A (B is a proper superset of A).

 Examples
The set of all men is a proper subset of the set of all people.
{1, 3} ⊂ {1, 2, 3, 4}.
{1, 2, 3, 4} ⊆ {1, 2, 3, 4}.
Proper Subsets & Supersets

 ST (“S is a proper subset of T ”) means


that
ST but TS. Similar for S T.
 Example:

S={1, 2}  T={1, 2, 3}

S
T

Venn Diagram of ST


Example: Subset & Superset
Set Definition Elements
 A = {x | x  Z+ and x  9} {1, 2 ,3, 4, 5, 6 ,7, 8,9}
 B = {x | x  Z+ ; x is even and  8} {2, 4, 6, 8,}

AB
BA
AB
Basic Set Relations : Power Set

 Power set: The power set of a set A is the set containing


all possible subsets of A including the empty subset. 
 It contains 2n elements where n is the number of elements
in A. 
 It is typically denoted by P(A) or 2A. 
 For example, the power set of the set A={a,b,c,d} is the set
 P(A)={{}, {a}, {b}, {c}, {d}, {a, b}, {a, c}, {a, d}, {b, c}, {b, d},
{c, d}, {a,b,c}, {a,b,d}, {a,c,d}, {b,c,d}, {a,b,c,d}}.
The Power Set Operation
 The power set P(S) of a set S is the set of all
subsets of S. P(S) = {x | xS}.
 Examples
 P({a, b}) = { , {a}, {b}, {a, b} }
 S = {0, 1, 2}
P(S) = {, {0}, {1}, {2}, {0, 1}, {0, 2}, {1, 2},
{0, 1, 2}}
 P() = {}
 P({}) = {, {}}
 Note that for finite S, |P(S)| = 2|S|.
Subset Relationships

 A = {x | x is a positive integer  8}
set A contains: 1, 2, 3, 4, 5, 6, 7, 8
 B = {x | x is a positive even integer  10}
set B contains: 2, 4, 6, 8
 C = {2, 4, 6, 8, 10}
set C contains: 2, 4, 6, 8, 10
 The universal set U = {1,2,3,4,5,6,7,8,9,10}.
 (or ∉ ) is (or is not) an element of

 Subset Relationships  is a subset of (includes equal sets)


AA AB AC  is a proper subset of
BA BB BC  is not a subset of
CA CB CC  is a superset of
Set Equality
 Two sets are equal if and only if they contain precisely the same
elements.
 The order in which the elements are listed is not important.
 Elements may be repeated in set definitions without increasing the
size of the sets.
 Examples
A = {1, 2, 3, 4} B = {1, 4, 2, 3}
A  B and B  A; therefore, A = B and B = A.
A = {1, 2, 2, 3, 4, 1, 2} B = {1, 2, 3, 4}
A  B and B  A; therefore, A = B and B = A.
Operations on Set: Union

 Union: Two sets can be "added" together. The union of A


and B, denoted by A ∪ B, is the set of all things which are
members of either A or B.

 Examples:
{1, 2} ∪ {red, white} ={1, 2, red, white}.
{1, 2, green} ∪ {red, white, green} ={1, 2, red, white, green}.
{1, 2} ∪ {1, 2} = {1, 2}.
Union Examples

 {a, b, c}  {2, 3} = {a, b, c, 2, 3}


 {2, 3, 5}  {3, 5, 7} = {2, 3, 5, 3, 5, 7}
= {2, 3, 5, 7}
Operations on Set: Intersection

 Intersection: A new set can also be constructed by


determining which members two sets have "in common".
 The intersection of A and B, denoted by A ∩ B, is the set
of all things which are members of both A and B.
 If A ∩ B = ∅, then A and B are said to be disjoint.
 Examples:
{1, 2} ∩ {red, white} = ∅.
{1, 2, green} ∩ {red, white, green} = {green}.
{1, 2} ∩ {1, 2} = {1, 2}.
Intersection Examples

 {a, b, c}  {2, 3} = 

 {2, 4, 6}  {3, 4, 5} = {4}


Example: Set Intersection
Set Definition Elements
 A = {x | x  Z+ and x  8} {1, 2 ,3, 4, 5, 6 ,7, 8}
 B = {x | x  Z+, x is even and  10} {2, 4, 6, 8, 10}

AB
BA
Disjointedness

 Two sets A, B are called


disjoint (i.e., unjoined) iff
Help, I’ve
their intersection is empty. been
(A  B = ) disjointed!

 Example: the set of even


integers is disjoint with the
set of odd integers.
Operations on Set: Set Difference
 Set Difference: Two sets can also be "subtracted". The relative
complement of B in A (also called the set-theoretic difference of A
and B), denoted by A \ B (or A − B), is the set of all elements which
are members of A but not members of B.
 Note: That it is valid to "subtract" members of a set that are not in
the set, such as removing the element green from the set {1, 2, 3};
doing so has no effect.
 Example: {1, 2} \ {red, white} = {1, 2}.
{1, 2, green} \ {red, white, green} = {1, 2}.
{1, 2} \ {1, 2} = ∅.
 If U is the set of integers, E is the set of even integers, and O is the
set of odd integers, then E′ = O.
Set Difference

 For sets A and B, the difference of A and B,


written A - B, is the set of all elements that
are in A but not B.

 Formally:

A - B  x  xA  xB
 x  xA  xB
 Also called:

The complement of B with respect to A.


Set Difference: Venn Diagram

 A−B
is what’s left after B “takes a bite out of A”

Chomp!
Set
A-B
Set A Set B
Set Difference Examples

 {1, 2, 3, 4, 5, 6} - {2, 3, 5, 7, 9, 11} =


{1, 4, 6}

 Z - N = {… , −1, 0, 1, 2, … } - {0, 1, … }
= {x | x is an integer but not a natural #}
= {… , −3, −2, −1}
= {x | x is a negative integer}
Operations on Set: Set Complements

 The universe of discourse (or the domain) can


itself be considered a set, call it U.

 When the context clearly defines U, we say that


for any set A  U, the complement of A, written as
, is the complement of A with respect to U, i.e., it is U
- A.

 E.g., If U = N,
{3, 5}  {0,1, 2, 4, 6, 7,...}
Examples : Set Complements

 Let A = { a, b, c, d } and U is the set of English alphabet


 = { e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z }.

 Let A = { x | x ∈ Z ˄ x is odd } and U is Z


 = { x | x ∈ Z ˄ x is even }
Operations on Set: Cartesian Products

 Cartesian Products: A new set can be constructed by associating


every element of one set with every element of another set. The
Cartesian product of two sets A and B, denoted by A × B is the set
of all Ordered pairs (a, b) such that a is a member of A and b is a
member of B.
 Examples
{1, 2} × {red, white} = {(1, red), (1, white), (2, red), (2, white)}.
{1, 2, green} × {red, white, green} =
{(1, red), (1, white), (1, green), (2, red), (2, white), (2, green),
(green, red), (green, white), (green, green)}.
{1, 2} × {1, 2} = {(1, 1), (1, 2), (2, 1), (2, 2)}.
Cartesian Products of Sets

 For sets A and B, their Cartesian product


denoted by A  B, is the set of all ordered pairs
(a, b), where aA and bB. Hence,
A  B = { (a, b) | aA  bB }.
 E.g. {a, b}  {1, 2}
= { (a, 1), (a, 2), (b, 1), (b, 2) }
 Note that for finite A, B, |A  B| = |A||B|.

 Note that the Cartesian product is not


commutative: i.e., A,B (A  B = B  A).
 Extends to A1  A2  …  An

= {(a1, a2, …, an) | ai  Ai for i = 1,


2,…, n}
Cardinality and Finiteness

 |S| (read “the cardinality of S”) is a measure


of how many different elements S has.
 E.g., || = 0, | {1, 2, 3} | = 3, | {a, b} | = 2,

| { {1, 2, 3}, {4, 5} } | =


 If |S|  N, then we say S is finite.
Otherwise, we say S is infinite.
What are some infinite sets
we’ve seen?
N, Z, Q, R
Set Identities

 Identity: A=A=AU
 Domination: AU=U, A=
 Idempotent: AA=A,AA=A
 Double complement: (A) = A
 Commutative: A  B = B  A, A  B = B  A
 Associative: A  (B  C) = (A  B)  C,
A  (B  C) = (A  B)  C
 A  (B  C) = (A  B)  (A
Distributive:
 C),
 Absorption: A  (B  C) = (A  B)  (A
 C)
 Complement: A  A = U, A  A = 
A  (A  B) = A, A  (A 
B) = A
De Morgan’s Law for Sets

 Exactly analogous to (and provable from)


DeMorgan’s Law for propositions.

ABA
B ABA
B
Proving Set Identities

 To prove statements about sets, of the


form E1 = E2 (where the Es are set
expressions), here are three useful
techniques:

1. Prove E1  E2 and E2  E1 separately.

2. Use set builder notation


& logical equivalences.
3. Use a membership table.
4. Use a Venn diagram.
Method 1: Mutual Subsets
Example: Show A  (B  C) = (A  B)  (A  C).
 Part 1: 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A and xB. Then
xAB, so
x(AB)(AC).
 Case 2: xA and xC. Then
xAC, so
x(AB)(AC).
 Therefore, x(AB)(AC).
Method 2: Set Builder Notation &Logical
Equivalence
 Sho ABA
w B
A  B  {x | x ( A  B)} def. of complement
 {x | (x ( A  B))} def. of “does not belong”
 {x | (x  A  x  def. of intersection
B)}
 {x | (x  A)  (x  De Morgan’s law (logic)
B)}
 {x | x  A  x  def. of “does not belong”
B} def. of complement
 {x | x  A  x  def. of union
B}
by set builder notation
 {x | x  A  B}
Method 3: Membership Tables

 Analog to truth tables in propositional logic.


 Columns for different set expressions.

 Rows for all combinations of memberships in

constituent sets.
 Use “1” to indicate membership in the

derived set, “0” for non-membership.


 Prove equivalence with identical

columns.
Membership Table Example

 Prove (A  B) - B = A - B.

A B AB (AB)B AB


1 1 1 0 0
1 0 1 1 1
0 1 1 0 0
0 0 0 0 0
Membership Table Exercise
 Prove (A  B) - C = (A - C)  (B - C).

A B C AB (AB)C AC BC (AC)(BC)


1 1 1 1 0 0 0 0
1 1 0 1 1 1 1 1
1 0 1 1 0 0 0 0
1 0 0 1 1 1 0 1
0 1 1 1 0 0 0 0
0 1 0 1 1 0 1 1
0 0 1 0 0 0 0 0
0 0 0 0 0 0 0 0
Method 4: Venn Diagram

 Prove (A  B) - C = (A - C)  (B - C).
A A

B C B C
AB (A  B) – C
A A A

B C B C B C
A–C B–C (A – C)  (B – C)
Bit String Representation of Sets
 A frequent theme of this course are methods of
representing one discrete structure using another
discrete structure of a different type.
 For an enumerable universal set U with
ordering x1, x2, x3,…, we can represent a finite
set S  U as the finite bit string B = b1b2…bn
where
bi = 1 if xi S and bi = 0 if xi S.
E.g. U = N, S = {2,3,5,7,11}, B = 0011 0101
0001.

 In this representation, the set operators


Examples of Sets as Bit Strings
 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, then
S1 = {1, 2, 3, 4, 5}  B1 = 11 1110 0000
S2 = {1, 3, 5, 7, 9}  B2 = 10 1010 1010
 S1  S2 = {1, 2, 3, 4, 5, 7, 9}
 bit string = 11 1110 1010 = B1  B2
 S1  S2 = {1, 3, 5}
 bit string = 10 1010 0000 = B1  B2
 S1 = {6, 7, 8, 9, 10}
 bit string = 00 0001 1111 = B1
Chapter Reading

• Chapter 2, Kenneth H. Rosen, Discrete Mathematics and Its Applications

Questions?

You might also like