0% found this document useful (0 votes)
88 views78 pages

Chapter 2:sets: School of Computer Science & Engg

Let's analyze each statement: (a) {2,3} is a subset of A since all elements of {2,3} are in A. (b) {1,2,3,4,5,6,7} is not a subset of A since 7 is not in A. (c) 8 is not a subset of A since it is not a set. (d) {3,5,1,7} is not a subset of A since 1 and 7 are not in A. Therefore, the only correct statement is (a) {2, 3} ⊆ A.

Uploaded by

kishor rao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
88 views78 pages

Chapter 2:sets: School of Computer Science & Engg

Let's analyze each statement: (a) {2,3} is a subset of A since all elements of {2,3} are in A. (b) {1,2,3,4,5,6,7} is not a subset of A since 7 is not in A. (c) 8 is not a subset of A since it is not a set. (d) {3,5,1,7} is not a subset of A since 1 and 7 are not in A. Therefore, the only correct statement is (a) {2, 3} ⊆ A.

Uploaded by

kishor rao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 78

Chapter 2 :Sets

School Of Computer Science & Engg.


Topic Outcomes
 Explain the significance of Sets and functions in computer
science.
 Apply the appropriate set operations for solving the given
problems.
 Identify the nature of function for the given problem.
 Identify the given set is countable or uncountable.

School Of Computer Science & Engg. 2


Contents

Introduction
Set Operations
Functions: One-to-One Functions
Onto Functions
Inverse Functions
Compositions of Functions
Cardinality

School Of Computer Science & Engg.


Why Sets?

Discrete structures are built using sets , they are :


• Programming Language: uses Data types
• Combinations: unordered collections of objects used
extensively in counting(Computer Networks)
• Relations: sets of ordered pairs that represent relationships
between objects(Database Management system)
• Graphs: sets of vertices and edges that connect
vertices(Computer Networks)
• Finite state machines: used to model computing machines.
(Theory of Computations)

School Of Computer Science & Engg. 4


Introduction
 A set is a collection or group of objects or elements or members.
(Cantor 1895)

◦ The objects in a set are called the elements or the members, of


the set.

◦ A set is said to contain its elements.

Set of fingers Set of Primary colours

.
School Of Computer Science & Engg. 5
Definition: A set is an unordered collection of objects

School Of Computer Science & Engg. 6


Notation:
x is a member of S or x is an element of S:
x  S.
x is not an element of S:
x  S.
Ways to describe set:
 List the elements between braces: S = {a, b, c, d}={b, c, a, d, d}-
Raster notation
The set of vowels in the English alphabet V={a,e,i,o,u}.
The set of all whole numbers less than ten R={0,1,2,3,4,5,6,7,8,9}

 Specification using set builder notation.(when it is not practical to


list all the elements of a set.
O= {x|x is an odd positive integer less than 10).
School Of Computer Science & Engg. 7
Activity on Set builder notation
List the members of the sets.
 (i) {x : x is an even natural numbers less than 12}
(ii) {x : x is a prime numbers less than 12}
(iii) {x : x is a month whose name starts with letter J}
(iv) {x : x is a natural number upto 30 and divisible by 5}

Write the following sets in Set-Builder Form or Rule form


(i) A = {1, 3 5, 7, 9}
(ii) B = {16, 25, 36, 49, 64}
(iii) C = {a, e, i, o, u}
(iv) D = {violet, indigo, blue, green, yellow, orange, red}
(v) E = {January, March, May, July, August, October, December}

School Of Computer Science & Engg. 8


Equal sets

• Two sets are equal if and only if they have the same elements.
Therefore, if A and B are sets,then A and B are equal if and only if
∀x(x ∈ A ↔ x ∈ B).We write A = B if A and B are equal sets.

• The sets {1, 3, 5} and {3, 5, 1} are equal.

• Note :The order in which the elements of a set are listed does not
matter and also an element of a set can appear many times,
i.e {1, 3, 3, 3, 5, 5, 5, 5}={1, 3, 5} .

School Of Computer Science & Engg. 9


Activity
1.State, whether each pair of sets, given below, has equal
sets or equivalent sets:
(i) {3, 5, 7} and {5, 3, 7}
(ii){7, 7, 2, 1, 2} and {1, 2, 7}
(iii){x : x is a letter in the word STRAND} and {x : x is a letter in
the word STANDARD}
(iv){x : x is a month having 33 days} and {x : x is a year having
360 days }
(v){2, 4, 6, 8, 10} and {even natural numbers less than 12}

School Of Computer Science & Engg.


Types of sets
• Empty Set or Null Set:
• Singleton Set:
• Finite Set:
• Infinite Set:

School Of Computer Science & Engg. 11


Empty Set
• A set which does not contain any element is called an empty set, or the
null set and it is denoted by ∅ (read as phi).
• In roster form, ∅ is denoted by {}.
• An empty set is a finite set, since the number of elements in an empty
set is finite, i.e., 0.
Ex:(i)The set of whole numbers less than 0.
(ii)N = {x : x ∈ N, 3 < x < 4}. 
(iii)The set of all positive integers that are greater than their
squares is the null set.
 Note:
• ∅ ≠ {0} ∴ has no element. 
{0} is a set which has one element 0. 

School Of Computer Science & Engg. 12


Activity
1. Which of the following sets are empty?
i. Set of counting numbers between 5 and 6.
ii. Set of odd numbers between 7 and 19.
iii. Set of even numbers which are not divisible by 2.
iv. {0}
v. { }
vi. {Prime numbers between 7 and 11}
vii. {x | x ∈ N and 3< x < 4}
viii.{1, 4, 7, 10, ………, 31}
ix. {Month having more than 31 days}
x. {x | x(22 = 0}
xi. {x | x ∈ N and x < 1}
xii.{Prime numbers divisible by 2}
xiii.{Negative natural numbers}
xiv.{Integers less than 5}
School Of Computer Science & Engg. 13
Singleton Set
• A set with one element is called a singleton set.
• Is{∅}=∅?
• Ex: Folders in a computer file system.
Empty set ==empty folder
Singleton set==folder with exactly one folder inside,
namely, the empty folder.
B={x:x is a whole number, x < 1} 
A = {x : x ∈ N and x² = 4} 
 
• The singleton set {3} is the set whose only element is 3.
• The singleton set {{3}} is the set whose only element is {3}.

School Of Computer Science & Engg. 14


Activity
1.Determine whether each of these statements is true or false.
a) x ∈ {x} b) {x} ⊆ {x} c) {x} ∈ {x}
d) {x} ∈ {{x}} e) ∅ ⊆ {x} f ) ∅ ∈ {x}

2.Determine whether these statements are true or false.


a) ∅ ∈ {∅} b) ∅ ∈ {∅, {∅}}
c) {∅} ∈ {∅} d) {∅} ∈ {{∅}}
e) {∅} ⊂ {∅, {∅}} f ) {{∅}} ⊂ {∅, {∅}}
g) {{∅}} ⊂ {{∅}, {∅}}

School Of Computer Science & Engg. 15


Venn Diagram
• Sets can be represented graphically using Venn diagrams,
named after the English mathematician John Venn in 1881.
• In Venn diagrams the universal set U,, is represented by a
rectangle, which contains all the objects under consideration
Inside this rectangle, circles or other geometrical figures are
used to represent sets.
• Points are used to represent the particular elements of the set.
• Venn diagrams are also used to indicate the relationships
between sets.

School Of Computer Science & Engg. 16


Vowels

School Of Computer Science & Engg. 17


Common Universal Sets

◦ R = The set of real numbers


◦ N = natural numbers = {0,1, 2, 3, . . . }, the counting numbers
◦ Z = all integers = {. . , -3, -2, -1, 0, 1, 2, 3, 4, . .}
◦ Z+ ={1,2,3,…} is the set of positive integers

Data type or type is built upon the concept name of a set.


Ex: boolean is the set {0,1}

Definition: Two sets are equal if and only if they have the same
elements. i.e x [x  A ↔ x  B].A=B if A and B are equal
sets.

Ex:{1,3,5} and{3,5,1}are equal—order does not matter.


Also(1,3,3,5,5,5,3,1}={1,3,5}—element can appear more
than once.
School Of Computer Science & Engg. 18
Universal Set
◦ There must be an underlying universal set.
◦ A Universal Set is the set of all elements under
consideration, denoted by capital U.
◦ It's a set that contains everything that is relevant to our
question. Ex: In Calculus the universal set is almost always
the real numbers. And in number theory always the
universal set is the integers.

◦ U={{alex, blair, casey, drew, erin, francis, glen, hunter, ira,


jade}-Set of all players(football and hockey)
School Of Computer Science & Engg. 19
Activity
1.Use a Venn diagram to illustrate the set of all months of the year
whose names do not contain the letter R in the set of all months
of the year.
2.Use a Venn diagram to illustrate the relationships A ⊂ B and B ⊂
C.

School Of Computer Science & Engg. 20


Subsets
• If A and B are two sets, and every element of set A is also an
element of set B, then A is called a subset of B and we write it
as A ⊆ B or B ⊇ A , iff x [x  A  x  B].

• Every set is a subset of itself, i.e., A ⊆ A, B ⊆ B. 


• Empty set is a subset of every set. ∅ ⊆ S
• Symbol ‘⊆ ’ is used to denote ‘is a subset of’ or ‘is contained
in’. 
A = {1, 3, 4} and B = {1, 4, 3, 2} then, A is a subset of B
School Of Computer Science & Engg. 21
Examples
• The set of all odd positive integers less than 10 is a subset of the
set of all positive integers less than 10
• The set of rational numbers is a subset of the set of real numbers,
• The set of all computer science majors at your school is a subset
of the set of all students at your school,
• The set of all people in India is a subset of the set of all people in
India(that is, it is a subset of itself).

School Of Computer Science & Engg. 22


Activity
1. Which of the following are correct statements?
• A = {1, 2, 3, 4, 5, 6} 
(a) {2, 3} ⊆ A 
(b) {1, 2, 3, 4, 5,6, 7} ⊆ A 
(c) 8 ⊆ A ⊆
(d) {3, 5, 1, 7} ⊆ A 
(e) {1} ⊆ A 
(f) {1, 2, 3, 4} ⊆ A
(g) { } ⊆ A 
(h) ϕ ⊆ A 
2. Write down all the subsets of
• (a) {8} , (b) {p, q}, (c) {1, 3, 5}, (d) ϕ
3
School Of Computer Science & Engg. 23
Activity
3.For each of these pairs of sets, determine whether the first is a
subset of the second, the second is a subset of the first, or neither
is a subset of the other.
a) The set of people who speak English, the set of people who speak
English with an Australian accent.
b) the set of fruits, the set of citrus fruits
c) the set of students studying discrete mathematics, the set of
students studying data structures

School Of Computer Science & Engg. 24


4.Fill in the blank spaces using the symbols ⊂ or ⊄.

(a){1, 2, 3} _____ {1, 3, 5} 


(b) ϕ ____ {4, 7, 9} 
(c) {x : x is rectangle in a plane} _____ {x : x is a quadrilateral in
a plane} 
(d) {x : x is an odd natural number} {x : x is an integer} 
(e) {x : x is a prime number} {x : x is a composite number}
(f) {5, 10, 15, 20, 25, 30}____{10, 20, 30, 40}

School Of Computer Science & Engg. 25


Proper subset
• A is a proper subset of B if and only if every element in A is
also in B, and there exists at least one element in B that
is not in A.
• i.e If A  B but A  B the we say A is a proper subset of B,
denoted A  B . x [x  A ↔ x  B]Λ  [x  B ↔ x A ]
• Is {1, 2, 3} is a subset  of {1, 2, 3}, but is not a proper
subset of {1, 2, 3}.
• {1, 2, 3} is a proper subset of {1, 2, 3, 4} because the element
4 is not in the first set.

School Of Computer Science & Engg. 26


Activity
1. Find the number of proper subsets of the following.
(a)P = {x : x ∈ N, x < 5} 
(b) Q = {x : x is an even prime number}
(c) R = {x : x ∈ W, x < 2} 
d) T = { } 
(e) X = {0} 
(f) Y = {x : x is prime, 2 < x < 10}

2.Let A be the set of letters of the word FOLLOW. Find Number


of subsets of A and Number of proper subsets of A.

School Of Computer Science & Engg. 27


Size of a set
• Let S be a set. If there are exactly n distinct elements in S where n
is a nonnegative integer, we say that S is a finite set and that n is the
cardinality of S. The cardinality of S is denoted by |S|.

Ex: Let A be the set of odd positive integers less than 10. Then |A| = 5.
Let S be the set of letters in the English alphabet. Then |S| = 26.
The null set has no elements, it follows that |∅| = 0
• A set is said to be infinite if it is not finite.

Ex: The set of positive integers is infinite.

School Of Computer Science & Engg. 28


Finite Set:
• A set which contains a definite number of elements is called a finite set.
Empty set is also called a finite set. 
Ex: The set of all colors in the rainbow.
N = {x : x ∈ N, x < 7}  
P = {2, 3, 5, 7, 11, 13, 17, ...... 97}
Infinite Set:
• The set whose elements cannot be listed, i.e., set containing never-ending
elements is called an infinite set. 
Ex:
 A = {x : x ∈ N, x > 1}
 Set of all prime numbers 
 B = {x : x ∈ W, x = 2n} 
Note: All infinite sets cannot be expressed in roster form. 

School Of Computer Science & Engg. 29


Activity

1. State, whether the given set is infinite or finite:


(i) {3, 5, 7, ….}
(ii) {….., -3, -2, -1, 0, 1, 2}
(iv) {20, 30, 40, 50, ………., 200}
(v) {7, 14, 21, …………, 2401}
(vi) {0}
(vii) (∅)
(viii) {x | x is an even natural number less than 10, 000}
(ix) {All people in the world}
(x) {x | x is a prime number}
(xi)Set of integers
(xii){Multiples of 5}

School Of Computer Science & Engg. 30


Power sets
• Given a set S, the power set of S is the set of all subsets of the set
S. The power set of S is denoted by P(S).
• If the original set has n members, then the Power Set will
have 2n members.
Ex: The set A={ a, b, c}, consists of three members(a,b and c).
Then P(A) 23 = 8.{Ø,{a},{b},{c},{a,b},{b,c},{c,a},{a,b,c}}
Notation
• The number of members of a set is often written as |S|, so we can
write:|P(S)| = 2n
• Example: for the set S={1,2,3,4,5} how many members will the
power set have?
• |P(S)| = 2n=25=32

School Of Computer Science & Engg. 31


Activity
1.What is the power set of the empty set? What is the power set of the
set {∅}?
2.How many elements does each of these sets have where
a and b are distinct elements?
a) P({a, b, {a, b}}), b) P({∅, a, {a}, {{a}}})
c) P(P(∅))
3. Determine whether each of these sets is the power set of
a set, where a and b are distinct elements.
a) ∅, b) {∅, {a}}
c) {∅, {a}, {∅, a}} d) {∅, {a}, {b}, {a, b}}

School Of Computer Science & Engg. 32


Cartesian product
The Cartesian product of A with B, denoted A x B, is the set of
ordered pairs {(a, b) | a  A  b  B}.
Ex: Let A = {a, b} , B = {1, 2, 3}
AxB = {(a, 1), (a, 2), (a, 3), (b, 1), (b, 2), (b, 3)}
Note: AХB B ХA

• Cartesian product of the sets A1,A2, . . . , An, denoted by


A1 × A2 × ・ ・ ・ ×An, is the set of ordered n-tuples (a1,
a2, . . . , an), where ai belongs to Ai for i = 1, 2, . . . , n. In
other words, A1 × A2 × ・ ・ ・ ×An = {(a1, a2, . . . , an) |
ai ∈ Ai for i = 1, 2, . . . , n}.

School Of Computer Science & Engg. 33


• What is the Cartesian product A × B × C, where A = {0, 1}, B = {1,
2}, and C = {0, 1, 2} ?
A × B × C = {(0, 1, 0), (0, 1, 1), (0, 1, 2), (0, 2, 0), (0, 2, 1), (0, 2, 2),
(1, 1, 0), (1, 1, 1), (1, 1, 2), (1, 2, 0), (1, 2, 1), (1, 2, 2)}.
• Notation
A2 = A × A, the Cartesian product of the set A with itself.
A3 = A × A × A,
A4 = A × A × A × A, and so on.
i.e An = {(a1, a2, . . . , an) | ai ∈ A for i = 1, 2, . . . , n}.

Ex: Suppose that A = {1, 2}. It follows that A2 = {(1, 1), (1, 2), (2, 1),
(2, 2)} and A3 ={(1, 1, 1), (1, 1, 2), (1, 2, 1), (1, 2, 2), (2, 1, 1), (2, 1,
2), (2, 2, 1), (2, 2, 2)}.
School Of Computer Science & Engg. 34
Actvity
1.What is the Cartesian product A × B × C, where A is the set of all
airlines and B and C are both the set of all cities in the United
States? Give an example of how this Cartesian product can be
used.
2. Find A2 if a) A = {0, 1, 3}. b) A = {1, 2, a, b}.
3. How many different elements does A × B have if A has m
elements and B has n elements?

School Of Computer Science & Engg. 35


Set Operations
• Arithmetic operators (+,-,  ,) can be used on pairs of
numbers to give us new numbers.
• Similarly, set operators exist and act on two sets to give us
new sets. They are
– Union
– Intersection
– Set difference
– Set complement
– Generalized union
– Generlized intersection

School Of Computer Science & Engg. 36


UNION

Let A and B be sets. The Union of the sets A and B, denoted by A⋃B,
is the set contains those elements that are either in A or in B or
both.
A ⋃ B={x|x  A ⋁ x  B}
The symbol for denoting union of sets is ‘∪’. 
Venn Diagram:

School Of Computer Science & Engg. 37


Example
• Let set A = {2, 4, 5, 6}and set B = {4, 6, 7, 8}
A⋃B = {2, 4, 5, 6, 7, 8}
•  If A = {1, 3, 7, 5} and B = {3, 7, 8, 9}. Find union of two set
A and B. 
A ∪ B = {1, 3, 5, 7, 8, 9} 
Note:No element is repeated in the union of two sets. The
common elements 3, 7 are taken only once.

 

School Of Computer Science & Engg. 38


Activity
1. If set P = {2, 3, 4, 5, 6, 7}, set Q = {0, 3, 6, 9, 12} and set R ={2,
4, 6, 8}.
(i) Find the union of sets P and Q,(ii) Find the union of two set P
and R, (iii) Find the union of the given sets Q and R
2. Let X = {a, e, i, o, u} and Y = {ф}. Find union of two given sets
X and Y. 

School Of Computer Science & Engg. 39


Intersection
Let A and B be sets. The intersection of A and B, denoted by A∩B,
is the set containing those elements that are in both A and B. A ⋂
B={x|x  A ⋀ x  B}
• The symbol for denoting intersection of sets is ‘⋂’.
• Venn Diagram:

• Two sets are called disjoint if their intersection is empty set.


• A={1,2,3} B={5,7,9},then A⋂B=Ø

School Of Computer Science & Engg. 40


Example
• Let set A = {2, 3, 4, 5, 6} and set B = {3, 5, 7, 9}A⋂B={3,5} is
the intersection of set A and B.3,5 are common elements.
• If A = {2, 4, 6, 8, 10} and B = {1, 3, 8, 4, 6}. Find intersection of
two set A and B. 
A ∩ B = {4, 6, 8}
4, 6 and 8 are the common elements in both the sets. 

School Of Computer Science & Engg. 41


Activity
1. If X = {a, b, c} and Y = {ф}. Find intersection of two given sets
X and Y. 
2. If set A = {4, 6, 8, 10, 12}, set B = {3, 6, 9, 12, 15, 18} and set C
= {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}.
(i) Find the intersection of sets A and B.
(ii) Find the intersection of two set B and C.
(iii) Find the intersection of the given sets A and C.

School Of Computer Science & Engg. 42


Set difference
Let A and B be sets. The difference of A and B, denoted by A-B,
is the set containing those elements that are in A but not in B.
(complement of B with respect to A.
A - B={x|x  A ⋀ x B}
The symbol for denoting difference of sets is ‘-’.
Venn diagram:

School Of Computer Science & Engg. 43


Example
• If A = {2, 3, 4} and B = {4, 5, 6}.Then
A - B = {2, 3} 

• A = {1, 2, 3} and B = {4, 5, 6}. Then


A -B={1,2,3}.
B –A={4,5,6}

School Of Computer Science & Engg. 44


Activity
1. Let A = {a, b, c, d, e, f} and B = {b, d, f, g}.Find the difference between
the two sets:(i) A and B,(ii) B and A.

2. Given three sets P, Q and R such that:


• P = {x : x is a natural number between 10 and 16},
• Q = {y : y is a even number between 8 and 20} and
• R = {7, 9, 11, 14, 18, 20}
(i) Find the difference of two sets P and Q
(ii) Find Q - R
(iii) Find R - P
(iv) Find Q – P

School Of Computer Science & Engg. 45


Set complement

Let U be the universal set. The complement of the set A denoted by


Ā, ,is the complement of A with respect to U. i.e Ā =U-A={x|x
A}
• We denote the complement Ā of A with respect to U as Ā
• Venn diagram:

U
A
Ā

School Of Computer Science & Engg. 46


Example
If U = {1, 2, 3, 4, 5, 6, 7},A = {1, 3, 7} find A'.
We observe that 2, 4, 5, 6 are the only elements of U which do not belong to A. Therefore, Ā
= {2, 4, 5, 6}.
Note:
The complement of a universal set is an empty set.
The complement of an empty set is a universal set.
The set and its complement are disjoint sets.
• Let A={a,e,i,o,u} and U=set of letters of the English alphabet,then
Ā={b,c,d,f,g,h,j,k,l,m,n,o,p,q,r,s,t,v,w,x,y,z}.

School Of Computer Science & Engg. 47


Activity
1. Let the set of natural numbers be the universal set and A is a set of
even natural numbers. Find Ā.
2. Show that the complement of a universal set is an empty set. 
3. A set and its complement are disjoint sets. 
4. Let U = {2, 4, 6, 8, 10, 12, 14, 16} and A = {6, 10, 4, 16}.Find Ā 

School Of Computer Science & Engg.


Activity
1. Find the union of each of the following pairs of sets.
(a) A = {2, 4, 6} ,B = {1, 2, 3} ,
(b) P = {a, e, i, o, u} , Q = {a, b, c, d} 
2. X = {x : n ∈ N, x = 2n, n < 4} ,Y = {x : x is an even number less
than 10}.
3. M = {x : x is natural number and multiple of 3},N = {x : x is a
prime number less than 19}.
4. D = {x : x is an integer -3 < x < 3} ,E = {x : x is a factor of 8}.
5.G = {x : x ∈ N, x < 7}, H = {x : x ∈ Z, -2 ≤ x ≤ 3}.

School Of Computer Science & Engg. 49


Activity
1. Find the intersection of each of the following pairs of sets.
(a) A = {1, 4, 9, 16}, B = {3, 6, 9, 12}.
(b) C = {p, q, r, s}, D = {a, b} .
(c) P = {x : n ∈ N, x = 3n   n< 3},Q = {x : x ∈ N   x < 7}.
(d) X = {x : x is a letter of the word ‘LOYAL’}, Y = {x : x is a
letter in the word ‘FLOW’}.
(e) G = {x : x = n2, when n ∈ N} ,H = {x : x = 4n, when n ∈ W  
n < 5}.
 

School Of Computer Science & Engg. 50


Activity
1. If A = {a, b, c, d}   B = {b, c, d, e}   C = {c, d, e, f}   D = {d, e, f, g}, find (a) A
– B (b) B – C (c) C – D (d) D – A (e) B - A 
2.. Let U = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10},A = {1, 2, 4, 6, 8, 10}
B = {1, 3, 5, 7, 8, 9}Find: (a) A‘ (b) B‘ (c) A' ∪ B’,(d) A' ∩ B‘
(e)show(A ∪ B)' = A' ∩ B‘.
3. Find the complement of the following sets if universal set is the set of natural
numbers.
(a) {x : x is a prime number},(b) {x : x is a multiple of 2},(c) {x : x is a perfect
cube},(d) {x : x ≥ 10} ,(e) {x : x Є N, 5x + 1 > 20}
(f) {x : x is an odd natural number}.
4 If U = {a, b, c, d, e, f} find the complement of the following.
(a) A = { },(b) B = {c, d, f} (c) D = {a, b, c, d, e, f},(d) C = {a, b, d} 
e) E = {b, c} ,(f) F = {a, c, f} 

School Of Computer Science & Engg. 51


8. If U = {1, 2, 3, 4, 5, 6} and A = {2, 3, 6}, find
(a) A ∪ A‘  (b) ∅ ∩ A
(c) A ∩ A’, (d) U' ∩ A.
9. Let P = {1, 3, 5, 7}   Q = {3, 7, 9, 11}   R = {1, 5, 8, 11}, then
verify the following.
(a) P ∪ Q = Q ∪ P, (b) (P ∪ Q) ∪ R = P ∪ (Q ∪ R) ,
(c) P ∩ Q = Q ∩P (d) (P ∩ Q) ∩ R = P ∩ (Q ∩ R) ,
(e) P ∩ (Q ∪ R) = (P ∩ Q) ∪ (P ∩ R) .
10. Let U = {a, b, c, d, e, f, g},   A = {a, c ,f , g},   B = {f, g, b, d}
Verify: (a) (A ∪ B)' = (A' ∩ B') , (b) (A ∩ B)' = (A' ∪ B') 

School Of Computer Science & Engg. 52


School Of Computer Science & Engg. 53
1. Two sets are equal –Show that each is subset of the other.

School Of Computer Science & Engg. 54


School Of Computer Science & Engg. 55
Proving DeMorgan’s Law
2. Using set builder notation and logical equivalences

(A U B) = AB

School Of Computer Science & Engg. 56


3. Membership table

School Of Computer Science & Engg. 57


School Of Computer Science & Engg. 58
Generalized unions
The Union of a collection of sets is the set that contains those
elements that are members at least one set in the collection.

School Of Computer Science & Engg. 59


Generalized Intersections
The intersection of a collection of sets is the set that contains
those elements that are members of all the sets in the collection.

School Of Computer Science & Engg. 60


Computer Representation of Sets

• Method for storing elements using an arbitrary ordering of the elements of


the universal set.
• Specify an arbitrary ordering of the elements of U, for
instance a1,a2,.,.,.an.Represent a a subset A of U with the bit string of
length n, where the i th bit in this string is 1 if ai belongs to A 
    and is 0 if ai does not belong to A.
Example1: Let U = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}.
i)What bit strings represent the subset of all odd integers in U?
The bit string that represents the set of odd integers in U, {1, 3, 5, 7, 9}, has a
one bit in the  first, third, fifth, seventh, and ninth positions. It is 10 1010
1010.

 ii)What bit strings represent the subset of all even integers in U?


   The bit string that  represent the subset of  even integers in U,
{2, 4, 6, 8, 10}.   It is 01 0101 0101.

School Of Computer Science & Engg. 61


I

ii)What bit strings represent the subset of integers not


exceeding 5 in U? 
  The set of all integers in U that do not exceed 5,
{1, 2, 3, 4, 5}, is represented by the  string 11 1110 0000.

• iv)To find the bit string for the complement of a set


from the bit string for that set, change each 1 to 0 and
each 0 to 1.

School Of Computer Science & Engg. 62


Functions
Let A and B be nonempty sets. A function f from A to B, is an assignment
of exactly one element of B to each element of A. We write f(a)=b if b is the
unique element of B assigned by the function f to the element a of A. If f is
a function from A to B then it is denoted as f :AB.

 Assignment of a grade to a student is an example of function.


 Multiply by 2 is a simple function.
 Functions can also be called as mappings or transformations.

School Of Computer Science & Engg. 63


Definition:
 If f is a function from A to B, then
A is called the domain of f
B is called the codomain of f
 If f(a) = b
b is called the image of a under f
a is called a preimage of b
(Note: There may be more than one preimage of b but there
is only one image of a).

 The range of f is the set of all images of points in A under f.


We denote it by f(A). i.e f maps A to B

School Of Computer Science & Engg. 64


If S is a subset of A then
f(S) = {f(s) | s in S}.
Example:

• f(a) = Z
• the image of d is Z A B
• the domain of f is A = {a, b, c, d} a
• the codomain is B = {X, Y, Z} X
• f(A) = {Y, Z}
b
Y
• the preimage of Y is b c
• the preimages of Z are a, c and d Z
d
• f({c,d}) = {Z}

School Of Computer Science & Engg. 65


What are the domain, codomain and range of the function that assigns
grades to students described below

School Of Computer Science & Engg. 66


Let f1 and f2 be functions from A to R. Then f1+f2 and f1f2 are
also functions from A to R defined by
(f1+f2)(X)=f1(x)+f2(x).
(f1f2)(x)=f1(x)f2(x).
Value of x in terms of f1 and f2 are specified.
Example:

School Of Computer Science & Engg. 67


One-to-One
• A function f is said to be one-to-one or injective if and only if
f(a)=f(b) implies that a=b for all a and b in the domain of A.A
function is said to be an injection if it is one-to-one.i.e
f(a)≠f(b) whenever a≠b

A f B

School Of Computer Science & Engg. 68


• Determine whether the function f from{ a,b,c,d} to
{1,2,3,4,5} with f(a)=4,f(b)=5,f(c)=1 and f(d)=3 is one-to-
one?

• Determine whether the function f(x)=x2 from the set of


integers to the set of integers is one-to-one.

School Of Computer Science & Engg. 69


Onto or surjective
• A function f from A to B is called onto or surjective if and
only if for every elements b B there is an element a A
with f(a)=b. A function f is called a surjection if it is onto.

School Of Computer Science & Engg. 70


Bijection
• The function f is a one-to-one correspondence or a
bijection, if it is both one-to-one and onto.

School Of Computer Science & Engg. 71


Activity
• Classify the following functions  between natural numbers as one-to-one and onto.

fj One-to-One Onto

f1(n)=n2

f2(n)=n+3
f3(n)= n-1,odd n
n+1,even n

• Define functions f from Z to Z and g from R to R by the formulas: for all y ∊Z and x ∊


R,    f(y) =  y2    and g(x) = 2x + 1
   a. Is f onto? Prove or disprove by giving a counter example.
   b. Is g onto? Prove or disprove by giving a counter example.

School Of Computer Science & Engg. 72


Let A = {1, 2, 3, 4, 5} and B = {a, b, c, d}. Which of the following arrow
diagram(s) defines onto functions? Explain

School Of Computer Science & Engg. 73


Give an explicit formula for a function from the set of integers to the set of
positive integers that is
a) one-to-one, but not onto.
b) onto, but not one-to-one.
c) one-to-one and onto.
d) neither one-to-one nor onto

• Determine whether each of these functions is a bijection


• from R to R.
• a) f (x) = 2x + 1
• b) f (x) = x2 + 1
• c) f (x) = (x2 + 1)/(x2 + 2)

School Of Computer Science & Engg. 74


Inverse function
• Let f be a one-to-one correspondence from the set A to
the set B. The inverse function of f is the function that
assigns to an element b belonging to B the unique
element a in A such that f(a)=b. The inverse function of f
is denoted by f-1 .Hence f-1(b)=a when f(a)=b.

• A function which is one-to-one correspondence is called


invertible and it is not invertible if it is not one-to-one
correspondence.
School Of Computer Science & Engg. 75
Activity

Let f be the function from R to R defined by f (x) = x2. Find


a) f−1({1}).
b) f−1({x | 0 < x < 1}).
c) f −1({x | x > 4}).

Let f be a function from A to B. Let S and T be subsets of B. Show that


a) f−1(S ∪ T ) = f−1(S) ∪ f−1(T ).
b) f−1(S ∩ T ) = f−1(S) ∩ f−1(T ).

School Of Computer Science & Engg. 76


Composition
• Let g be a function from the set A to the set B and let f be a function
from the set B to the set C. The composition of the functions f and g,
denoted by ( fog)(a)=f(g(a)).

School Of Computer Science & Engg. 77


Activity
• Find f ◦ g and g ◦ f , where f (x) = x2 + 1 and g(x) =x + 2, are functions
from R to R.
• Find f + g and fg for the functions f and g given in above Exercise .

• Let g be the function from the set {a, b, c} to itself such that g(a) = b, g(b)
= c, and g(c) = a.Let f be the function from the set {a, b, c} to the set {1, 2,
3} such that f (a) = 3, f (b) = 2, andf (c) = 1. What is the composition of f
and g, and what is the composition of g and f ?

School Of Computer Science & Engg. 78

You might also like