TOC Chapter-1 SRG - Final
TOC Chapter-1 SRG - Final
TOC Chapter-1 SRG - Final
Chapter 1
Introduction
The Subset
• S⊆T (“S is a subset of T”) means that every element of S
is also an element of T.
• S⊆T ⇔ ∀x (x∈S → x∈T)
• ∅⊆S, S⊆S.
• A⊂B (“A is a proper subset of B”): Set A is said to be a
proper subset of B if there is at least one element of B
which is not in A.
Example:
{1,2} ⊂ {1,2,3}
8
The Power Set
• The power set P(S) of a set S is the set of all
subsets of S. P(S) = {x | x⊆S}.
• E.g. P({a,b}) = {∅, {a}, {b}, {a,b}}.
• Sometimes P(S) is written 2S.
Note that for finite S, |P(S)| = 2|S|.
A∪ B = A ∩ B
A∩ B = A ∪ B
One‐to‐one One‐to‐many
Many‐to‐one Many‐to‐many
Sol :
R3
By: Shayak Raj Giri 25
2. Symmetric relation
• A relation R defined on a set A is called
symmetric if:
• ∀a ∀b ((a, b)∈R → (b, a)∈R)
Example1:
• Let A={1,2,3}
• Then, R = {(1,2), (2,1)} is symmetric.
a b a b
d c d c
Vertices : 1, 2, 3, 4 1 2
Edges : (1,1), (1,3),
(2,1), (2,3), (2,4),
(3,1), (3,2),
(4,1)
By: Shayak Raj Giri 4 3 40
Function
• Function is a special type of relation where
every elements of A has only one image on
set B.
• A relation f from A to B is a function from A to
B iff
– for every x ∈ A, there exists a unique y ∈ B such
that x f y, or equivalently (x, y) ∈ f
function from A to B
1
• R = {(1, a), (1, b), (2, a), (3, b)} a
is not a function from A to B 2
b
3
• Domain is {1, 2, 3}
• Codomain is {a, b, c}
• Range is {a, c}
1 a 1 a
2 b 2 b
c c
3 3
d
(d) One to one on to (bijective)
(c) Into
By: Shayak Raj Giri 45
Proof Techniques
• Three fundamental proof techniques:
1. Mathematical induction
2. Pigeon‐hole principle
3. Diagionalization principle
• Other techniques are:
1. Deductive proofs
2. Reduction to definition
3. Proof by contradiction
4. Proof by counter example
5. Proof by contraposition etc.
• Similarly:
1. Direct proof
2. Indirect proof
By: Shayak Raj Giri 46
1. Mathematical induction
• Let us consider a property P defined on the set
of all natural numbers N. If P is true for n=1
and is we can show that P is true for n=k+1;
given P is true for n=k, then we can say that P
is always true.
Statement:
• It states that, if we prove S(i) and we prove
that for all n≥i, S(n) implies S(n+1), then we
may conclude S(n) for all n≥i.
49
Cont..
• Induction step:
• Assume that, it is true for n=k, where n≥1
• i.e. P(k): 1+2+3+……+k = k(k+1)/2 ‐‐‐‐‐‐(1)
• Equation (1) is induction hypothesis.
• Now for n=k+1
1+2+3+……+k+(k+1) = (1+2+3+……+k)+(k+1)
=k(k+1)/2 +(k+1) [Using hypothesis]
= (k(k+1)+2(k+1))/2
=(k+1)(k+2)/2
This shows that, it is true for n=k+1.
Hence it is true for all n≥1 proved. 50
Example 1 Revisited
Prove that:
Proof:
51
Class Work
• Prove by mathematical induction that:
1) The sum of first n positive odd numbers,
1 + 3 + 5 + . . . . . . . . . . + (2n‐1) is n2
2) The sum of first n positive even numbers,
2 + 4 + 6 + . . . . . . . . . . + 2n is n(n+1)
For more practice: Follow provided Tutorial Sheet and old questions.
53
2. The Pigeon‐hole Principle
• Suppose that you have n pigeonholes and m
pigeons (where m > n ).
• If you put the pigeons into the pigeonholes,
some pigeonhole will have more than one
pigeon in it.
If A and B are two non empty finite sets with |A| > |B|,
then there is no one‐to‐one function from A to B.
By: Shayak Raj Giri 54
The Pigeon‐hole Principle
• Pigeonhole Principle: If k is a positive integer and
k + 1 objects are placed into k boxes, then at least
one of the boxes will contain two or more objects
Proof:
• Suppose on the contrary that the proposition is
false. Then, we have the case that
(i) k + 1 objects are placed into k boxes, and
(ii) No boxes contain two or more objects.
• From (ii), it follows that the total number of
objects is at most k (since each box has 0 or 1
objects). Thus, a contradiction occurs.
By: Shayak Raj Giri 55
Cont..
Ra‐>
Rf‐> 62
Cont..
• The sequence of boxes along the diagonal is:
67
Dovetailing
• The technique of interweaving the enumeration
of several sets is called “dovetailing”.
• We can show that the union of any finite number
of countably infinite set is countably infinite.
• Let A,B, and C be countably infinite and disjoint
sets as follows:
A = { a0,a1,a2,a3,……..}
B = { b0,b1,b2,b3,……..}
C = { c0,c1,c2,c3,……..}
AUBUC = { a0,b0,c0,a1,b1,c1,a2,b2,c2……..}
By: Shayak Raj Giri 68
Cont..
For dovetailing,
• Visit first element of first set, then
• Visit first element of second set, then
• Visit first element of third set and so on.
N×N={(0,0),(0,1),(1,0),(0,2),(1,1),(2,0),(0,3),(1,2),(2,1),(3,0),….…}
A={0} ×N={(0,0,(0,1),(0,2),(0,3)……..}
B={1} ×N={(1,0),(1,1),(1,2),(1,3)……..}
…………………………………………………….
Where, N={0,1,2,3,4,………..………….} 72
Closures on relation
1. Reflexive closure
• Let R be a relation on set A. The reflexive
closure of R is the minimal set which contains R
and its reflexive.
• Example:
Let A={1,2,3}
And R={(1,1),(1,2),(1,3)}
Then
Reflexive(R)={(1,1),(1,2),(1,3),(2,2),(3,3)}
i.e. Reflexive(R)=RUΔA
Where ΔA ={(1,1),(2,2),(3,3)}
73
Cont..
2. Symmetric closure
• The symmetric closure of a relation R defined on
s set A is the minimal set which contains R and
its symmetric.
• Example:
Let A={1,2,3}
R={(1,1),(1,2),(2,3)}
R −1 ={(1,1),(2,1),(3,2)}
Then, Symmetric(R)={(1,1),(1,2),(2,1),(2,3),(3,2)}
• Symmetric(R)= RUR‐1
By: Shayak Raj Giri 74
Cont..
3.Transitive closure
• The transitive closure of a binary relation R on a
set A is the minimal relation on A that contains
R and is transitive.
• Example:
Let A={1,2,3}
R={(1,1),(1,2),(2,3)}
Transitive(R) ={(1,1),(1,2),(2,3),(1,3)}
(Detail will be on Data Structure and Algorithm, next semester)
For example:
If ∑ ={a,b} then a(aUb)* OR a(a+b)*, a*ba* etc. are regular expressions on ∑ .
By: Shayak Raj Giri 84
Cont..
Q. What language is
represented by
(c*(aUbc*))*) ?
Ref: pp 48‐49
85
Writing Regular Expressions
Some examples:
• 10* : A 1 followed by any number of 0’s (including no
zeros).
• (10)* : Any number of copies of 10 (including null
string).
• (0+01) : The string 0 or string 01
• (0+1)* : Any strings of 0’ and 1’s including empty string.
• 0(0+1)* : Any string beginning with 0.
• (0*1)* : Any string not ending with 0.
• Note: (0+1) and (0U1) are same.
92
Thank you
93