Lecture 3-4
Lecture 3-4
Functions
Discrete Structures
MUHAMMAD UMAR NASIR
LECTURER
FACULTY OF COMPUTING, RIPHAH INTERNATIONAL UNIVERSITY LAHORE
Union of Two Sets:
1- A ∩ B = B ∩ A
2- If A ∩ B = φ, then A & B are called
disjoint sets.
MEMBERSHIP TABLE FOR
INTERSECTION
A B A∩B
1 1 1
1 0 0
0 1 0
0 0 0
Disjoint Sets:
Two sets are called disjoint if their intersection is the empty set.
Example : Let A={1,3,5,7,9} and B={2,4,6,8}
Because A ∩ B= Null, A and B are disjoint.
Difference of Two Sets:
1. A^c = U – A
2. A ∩ A^c = φ
3. A ∪ A^c = U
MEMBERSHIP TABLE FOR
COMPLEMENT
A A^c
1 0
0 1
Principle of inclusion–
exclusion:
The cardinality of a union of two finite sets A and B, |A| + |B|
counts each element that is in A but not in B or in B but not in A
exactly once, and each element that is in both A and B exactly
twice. Thus, if the number of elements that are in both A and B is
subtracted from |A| + |B|, elements in A ∩ B will be counted only
once. Hence,
|A ∪ B| = |A| + |B| − |A ∩ B|
The principle of inclusion–exclusion is an important technique
used in
enumeration.
Principle of inclusion–
exclusion:
Principle of inclusion–
exclusion:
Principle of inclusion–
exclusion:
Since there are 128 ways to do Task 1 and 64 ways to do Task 2, does
this mean that there are 192 bit strings either starting with 1 or ending
with 00 ?
No, because here Task 1 and Task 2 can be done at the same time.
When we carry out Task 1 and create strings starting with 1, some of
these strings end with 00.
How many cases are there, that is, how many strings start with 1 and end
with 00?
Product rule: In 25 = 32 cases, Tasks 1 and 2 are carried out at the same
time.
Principle of inclusion–
exclusion:
Since there are 128 ways to complete Task 1 and 64 ways to complete
Task 2, and in 32 of these cases Tasks 1 and 2 are completed at the same
time, there are
128 + 64 – 32 = 160 ways to do either task.
In set theory, this corresponds to sets A1 and A2 that are not disjoint. Then
we have:
|A1 A2| = |A1| + |A2| - |A1 A2|
A A Identity laws
A U A
A U U Domination laws
A
There are some formulas of sets which are very important in setIdempotent laws
A A A
theory. They are as follows. A A A
( A) A Complementation
laws
A B B A Commutative
A B B A laws
A ( B C ) ( A B ) C Associative laws
A ( B C ) ( A B ) C
A ( B C ) ( A B ) ( A C ) Distributive laws
A ( B C ) ( A B ) ( A C )
A B A B De Morgan’s
A B A B Laws
A ( A B) A Absorption laws
A ( A B) A
A A U Complement laws
A A
Prove Equivalence by
Membership Table:
Set identities can also be proved using membership tables. We
consider each combination of sets that an element can belong to
and verify that elements in the same combinations of sets belong
to both the sets in the identity. To indicate that an element is in a
set, a 1 is used; to indicate that an element is not in a set, a 0 is
used.
A B A B
A B AB AB A B AB
1 1 1 0 0 0 0
1 0 0 1 0 1 1
0 1 0 1 1 0 1
0 0 0 1 1 1 1
Prove by Set Builder notation
and Logical Equivalence
Prove the first De Morgan law A B A B .
Solution: We can prove this identity with the following steps.
A B = {x | x ∉ A ∩ B}
= {x | ¬ (x ∈ (A ∩ B))}
by definition of complement
= {x | ¬ (x ∈ A ∧ x ∈ B)}
by definition of does not belong symbol
= {x | ¬ (x ∈ A) ∨¬ (x ∈ B)}
by definition of intersection
= {x | x ∉ A ∨x ∉ B}
by the first De Morgan law for logical equivalences
by definition of does not belong symbol
= {x | x ∈ A ∨ x ∈ B } by definition of complement
= {x | x ∈ A U B } by definition of union
= AB by meaning of set builder notation
Function
let A, B are two non-empty set than possible sub-sets of are called
binary relation from set A to set B.
Find all binary relations from {0,1} to {1}
SOLUTION: Let A = {0,1} & B = {1}
Then A × B = {(0,1), (1,1)}
All binary relations from A to B are in fact all subsets of
A ×B, which are:
R 1= ∅
R 2={(0,1)}
R 3={(1,1)}
R 4={(0,1), (1,1)} = A × B
Domain of a Binary Relation:
Co-domain of Function:
Set B in the Cartesian product is called co-domain of function.
Range of Function:
The set of elements from co-domain which is called Range of
function.
•Domain: {1, 2, 3, 4}
•Codomain: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
•Range: {3, 5, 7, 9}
Example: What are the domain, codomain, and range of the function
that assigns grades to students described in the next statement. Each
student in a discrete mathematics class is assigned a letter grade from
the set {A. B. C. D. F}. And suppose that the grades are A for Adams, C
for Chou, B for Goodfriend, A for Rodriguez, and F for Stevens.
Solution: Let G be the function that assigns a grade to a student in our
discrete mathematics class.
Domain of G is {Adams, Chou, Goodfriend, Rodriguez, Stevens}
Codomain is the set {A, B, C, D, F}.
Range of G is the set {A, B, C, F}
Types of Functions
One-to-One function:
Some functions never assign the same value to two different
domain elements. These functions are said to be one-to-one or
an injunction. If and only if
x, yA (f(x) =
f(y) x = y)
In other words: f is one-to-one if and only if it does not map two
distinct elements of A onto the same element of B.
Types of Functions
Bijective Function:
A function is called bijective if it is both injective and surjective.