Unit 1 Toc
Unit 1 Toc
Unit 1 Toc
Introduction
Strings, Alphabets and Languages
Symbol :
A symbol is abstract entity.
Letters and digits are examples of symbols.
String :
A string or word is finite sequence of symbol.
Example
a, b and c are symbols and abcd is a string.
The length of a string w is the number of symbols composing the string.
It is denoted as |w|
Example :
abcd has length 4
The empty string E, the string consisting of zero symbols |E| =0.
A prefix of a string is any number of leading symbols of the string.
Example :
String abc has prefixes,
E, a, ab, abc.
A suffix is any number of trailing symbols of that string.
Example :
String abc has suffixes
E, c, bc, abc
A prefix or suffix of a string other than the string itself is called a proper prefix
or suffix.
The concatenation of two strings is the string formed by writing the first
followed by the second without space.
For eg.
Concatenation of dog and house is doghouse
The empty string is the identity for concatenation operator
∈w = w∈ = w
Alphabet :
An alphabet is a finite set of symbols.
Language :
A language is a set of string of symbols from some one alphabet.
The empty set φ and the set consisting of the empty string { ∈ } are
languages.
The set of all string over a fixed alphabet ∑ ¿¿ , this language is denoted by
¿
∑ ¿¿
Example
1. a
¿
∑ ¿ { ∈, a,aa, aaa, .. . }
2. ∑ = { 0, 1 }
¿
∑ = { ∈, 0, 1, 01 , 10 , 00 , 11, 000, 000, ... }
Set Notation :
Set is a collection of objects without repetition.
Finite sets may be specified by two forms
i. listing their members between brachets.
ii. Set former
{x | p (x )}
{ x in A | p ( x ) }
If every member of A is a member of B, then we write A ⊆ B and say A is
contained in B.
If A ⊆ B but A ≠ B , that is every member of A is in B and there is same
member of B that is not in A, then we write A ⊆ B .
A and B are equal if they have same members That is A = B iff A ⊆ B nad
B⊆A .
Operations on Sets :
1. A ∪ B , the union of A and B is
{ x | x is in A of x is in B }
2. A ∪ B , the intersection of A and B is
{ x | x is in A and x is in B }
3. A – B, the difference of A and B is
{ x | x is in A and x is not in B }
4. A x B, the Cartesian product of A and B, is the set of ordered pairs (a, b) such
that a is in A and b is in B.
5. 2A , is the power set of A is the set of all, subsets of A
Example :
Let A = {1, 2}
B = {2, 3}
1. A ∪ B = {1, 2, 3}
2. A ∩ B = {2}
3. A – B = {1}
4. A x B = {(1, 2), (1, 3), (2, 2), (2, 3)}
5. 2A = { φ {1 } , { 2 } , {1, 2 } }
If A and B have n and m members respectively, then
A x B has nm members
2A has 2n members.
Relations :
A binary relation is a set of pairs.
The first component of each pair is chosen from a set called the domain and the
second component of each pair is chosen from a set called a range.
If R is a relation and (a, b) is a pair in R then we write a R b.
Properties of Relations :
We say a relation R on set S is
1. Reflexive
if aRa for all a in S
2. Irreflexive
if aRa is false for all a in S
3. Transitive
if aRb and bRc imply aRc
4. Symmetric
if aRb implies bRa
5. Asymmetic
if aRb implies that bRa is false.
Any asymmetric relation must be irreflexive.
Equivalence relation :
A relation R that is
i. Reflexive
ii. Symmetric
iii. Transitive
is said be an equivalence relation.
Closure of relations :
The transitive closure of R, denoted Rt is defined by
1) If (a, b) is in R, then (a, b) is in R+
2) if (a, b) is in Rt and (b, c) is in R then (a, c) is in R+
3) Nothing is in R+, unless it follows from (1) and (2)
The reflexive and transitive closure of R denoted R+ is defined as
R+ U {( a, a ) | a is in s }
Example :
Let R = {(1, 2), (2, 2), (2, 3)} be a relation on the set {1, 2, 3}
R+ = {(1, 2), (2, 2) (2, 3), (1, 3)}
R* = {(1, 2), (2, 2), (2, 3), (1, 3), (1, 1) (3, 3)}
Graphs :
A graph consist of a finite set of verticles V and a set of paris of vertices E
called edges.
Graph is denoted as G = (V, E)
A path in a graph is a sequence of verticle V 1, V2, V3, …., Vk k ≤ 1, such that
there is an edge (Vi, Vi+1) for each I |≤ i ≤ k
Directed Graphs:
A directed graph or digraph consists of a finite set of vertices V and a set of
ordered pairs of vertices E called arcs.
The arc from V → W is denoted as V →W
If V → W is an arc, we say
V →Pr edecessor of W
W → Successor of V
Trees:
A tree is a digraph with the following properties
1. Three is one vertex, called the root that has no predecessor and from
which there is a path to every vertex.
2. Each vertex other than the root has exactly one predecessor.
3. The successor of each vertex is ordered from the left.
If there is a path from vertex V 1 to Vertex V2 then V2 is said to be descendant
of V1 and V1 is said to be an ancestor of V2.
INDUCTIVE PROOFS
Inductive Proofs :
Theorems can be proved by mathematical induction
Let P(n) be a statement about a non negative integer n
The Principal of mathematical induction is that P(n) follows from
(a) P (o)
(b) P (n-1) imples P(n) for n ≥ 1
Condition (a) is called the basis and condition (h) is called the inductive step.
Example 1 :
Prove by mathematical induction.
n (n + 1) (2n + 1)
02 + 12 + 22 + …. + n2 = 6
Solution
n (n + 1) (2n + 1)
Let P (n) = 12 + 22 + 32 + ….. n2 = 6
Basic Step
for n = 0
n
L.H.S. ∑ ¿¿i=0
i2 = 0
n (n + 1) (2n + 1)
=0
R.H.S. 6
Inductive step
for n = n – 1
n−1 (n) (n − 1) (2n 1 1) n n (n + 1) (2n + 1)
∑ ¿¿i=0 i2 = 6 implies ∑ ¿¿i=0 i2 = 6
Since
n n−1
∑ ¿¿i=0 i2 = ∑ ¿¿i=0 i2 + n2
n (n−1) (2n−1) 2
+n
= 6
2 2
(n −n ) (2 n−1) + 6 n
= 6
2 n3 − 2n 2 − n2 + n + 6 n 2
= 6
3 2
2n + 3n + n
= 6
n (2 n2 + 3n + 1)
= 6
n (n+1 ) (2n+1)
= 6
L.H.S = R.H.S.
∴ Thus by induction it is true for all n
Example 2 :
Prove by mathematical induction.
n (n+1)
0 + 1 + 2 + …. + n = 2
Solution
n (n+1)
Let P (n) = 1 + 2+ 3 + n = 2
Basis Step
for n = 0
n
L.H.S. ∑ ¿¿i=0 i = 0
n n (n+1)
R.H.S. ∑ ¿¿i=0 i = 2
=0
Inductive step
for n = n – 1
n (n−1)n n n (n+1)
∑ ¿¿i=0 i = 2 implies ∑ ¿¿i=0 i = 2
Since
n n
∑ ¿¿i=0 i = ∑ ¿¿i=0 i + n
(n−1)n
+n
= 2
(n−1)n + 2n
= 2
2
n −n+2 n
= 2
n2 +1
= 2
n(n+1)
= 2
L.H.S. = R.H.S.
Thus by induction it is true for all n.
Example 3 :
x 2
Prove if x ≥ 4 then 2 ≥ x by mathematical inducations
Solution
Basic step :
4 2
If x = 4 then 2 ≥4
16 ≥ 16
5 2
x = 5 then 2 ≥5
32 ≥ 25
Inductive step
putx = x + 1
x+1 2
∴2 ≥ ( x+1)
2 x .2 ≥ ( x+1)2
x 2 2
2 .2 ≥ 2x ≥ ( x1+)
2 2
2x ≥ x + 2x + 1
2
x ≥ 2x + 1
¿ by x
1
x≥2+
x
1 1
x ≥ 4, ≤ ,
Since x 4 where RHS = 2.25
2x 2 ≥ ( x + 1) for x ≥ 4
1 x = a2 + b2 + c2 + d2 Given
2 a ≥ 1, b ≥ 1, c ≥ 1, d≥ 1 Given
Reduction to definitions
If you are not sure how to start a proof convert all terms in the hypothesis to
their definitions.
Theorem :
Let S be a finite subset of some infinite set Let T be the complement of S with
respect to Then T is infinite.
Proof :
Original Statement New Statement
SUT = U and
T is the complement of S
S∩T = φ
The Contrapositive :
The contrapositive of the statement “if H then C” is “if not C then not H”
A statement and its contrapositive are either both true or both false.
To see “if H then C” and if not C then not H are logically equivalent.
There are four cases to consider
1. H and C both true
2. H true and C false
3. C true and H false
4. H and C both false
Proof by contradiction :
Another way to prove a statement of the form.
“if H then C is to prove the statement.
H and not C implies false hood.
Start by assuming both the hypothesis H and the negation of the conclusion C
Complete the proof by showing that something known to be false follows
logically from H and C
This form of proof is called proof by contradiction.
Counter example :
Statements that have no parameters, or that apply to only a finite number of
values of its parameter are called observations.
It is easier to prove that a statement is not a theorem than to prove it is a
theorem.
Example
All primes are odd.
More formally, we might say
if integer x is a prime, then x is odd
Example
There is no pass of integers a and b such that
a mod b = b mod a
BASIC DEFINITIONS DFA AND NFA
Finite Control
Basic Definitions :
Deterministic finite automata :
A finite automator (FA) consists of a finite set of states and a set of transitions
from state to state that occur on an inpul symbol chosen from an alphabet
For each input symbol there is exactly one transition out of each state.
One state denoted qo is the initial state in which the transition starts.
Some states are designated as final states or accepting states.
The Deterministic finite automata can be represented as a transition diagram or
transition table.
The directed graph is used to represent the transition diagram.
The vertices of the graph correspond to the states of FA
If there is a transition from state q to state p on input a there is an are
labeled a from state q to state p
The FA accepts a string x if the sequence of symbols of x leads start
state to final state.
Example :
The initial state, qo is indicated by the arrow labeled start.
The final state indicated by the double circle.
The FA accepts all string of 0’s and 1’s in which both the number 0’s and the
number of 1’s are even.
for eg.
The string accepted by the above FA, 11, 1100, 00, 0000, 1111, 110110
Formal Definition of DFA :
We formally denote a finite automaton by a 5 tube.
M = Q, , , q o , F
Q is a finite set of states
is a finite input alphabet
q o in Q is the initial state
F F Q is the set of final states
is the transition function mapping from Q x to
0 1 0 1 0 0 0
Finite Control
Finite control which is in same state from Q reads a sequence of symbols from
written on a tape.
In one move, the FA in state q, scanning a symbol a enters state (q, a ) and
moves its head one symbol to the right.
(q, w ) is the unique state p such that there is a path in the transition diagram
from q to p labeled w
Formally we define
(1)
(q, t ) q
(2) for all string w and input symbols a
This FA is denoted as
M = (Q, , , q o , F) where
Q = q 0 , q1 , q 2 , q 3
0,1
q0 = q0
F = q 0
is given as a transition table
s 0 1
q0 q2 q1
q1 q2 q1
q1 q3 q0
q2 q0 q3
q3 q1 q2
(q 0,01001) q
(q 0 , 0) {q, q 3 )
(q 0 , 01) ( (q 0 , 0),1)
= ( {q 0 , q 3 },1)
= (q 0 ,1) (q 3 ,1)
= {q0,q1)
= {q0, q1}
(q 0 , 010) ( (q 0 , 01), 0)
= ( {q 0 , q1 }, 0)
= (q 0 , 0) (q1 , 0)
= {q0,q3)
= {q0, q3}
(q 0 , 0100) ( (q 0 , 010),1)
= ( {q 0 , q 3 }, 0)
= (q 0 ,1) (q 3 , 0)
= {q0,q3) {q4}
= {q0, q3, q4}
(q 0 , 01001) ( (q 0 , 0100),1)
= ( {q 0 , q 3 , q 4 },1)
= (q 0 ,1) (q 3 ,1) (q 4 ,1)
= {q0,q1) {q4}
= {q0, q1, q4}
(q 0 , 01001) contains a state in F so the input string 01001 is accepted by the NFA.
Basis :
The result is trivial for 1 x 1 = 0, since q01 = [q0] and x must be ∈
1
δ ( [q 0 ], ∈ = [ q 0 ]
iff
δ ( q0 ∈) = q 0
Induction :
Suppose that the hypothesis is true for inputs of length m or less
Let xa be a string of length m + 1 with a in ∑ ¿¿ then
δ 1 (q 0 1 , xa) = δ 1 (δ 1 ( q 1 , x ), a)
0
iff
δ (q0 , x) = [ p1 , p 2 , ... p j ]
δ 1 (q 0 , xa) = δ 1 ( δ 1 (q 0 1 , x), a)
1
= δ [ p 1 , p 2 , .. .. . p j ], a )
= {r 1 , r 2 , ... r k }
iff
1
δ (q 0 , xa) = δ (δ (q 0 , x), a)
= δ 1 [ p 1 , p 2 , .. .. . p j ], a )
= {r 1 , r 2 , ... r k }
Thus
iff
δ 1 (q 1 , xa) = [ r 1 , r 2 , .. . r k ]
0
iff
δ (q0 , xa) = [ r 1 , r 2 , ... r k ]
which establishes the inductive hypothesis
1 1
δ (q 0 , x) is in F1 exactly when δ (q0 , x) contains a state in F
L (M) = L (M)
Example 1:
1. Let M = ( {q 0 , q1 } 0 , 1 , δ , q 0 , {q 1 } be an )
{ }
[q0, q1] ? ?
1
To find δ ( [q 0 , q 1 ], 0
δ ( {q 0 , q 1 } , 0 )
= δ (q 0 , 0) ∪ δ (q 1 , 0)
= {q 0 , q 1 }∪ φ
= {q0, q1}
δ 1 ( [ q 0 , q 1 ], 0) = [q 0 , q1 ]
1
To find δ ( [q 0 , q 1 ], 1
δ ( {q 0 , q 1 } , 1 )
= δ (q 0 , 1) ∪ δ (q1 , 1)
= {q 1 } ∪ {q 0 , q 1 }
= {q0, q1}
1
δ ( [q 0 , q 1 ], 1) = [q 0 , q1 ]
1 1 1 1
∴ M1 = (Q1, ∑ , δ , q 0 , F )
Q1 = { [q0], [q1], [q0, q1], φ }
∑ = {0, 1}
q01 = [q0]
F1 = { [q1], [q0, q1] }
δ1
0 1
Transition Diagram
Examples 2 :
Consider the following NFA
a b
q0 {q0, {q2}
q1}
q1 {q1} {q0}
[q0, q1] ? ?
[q0, q2] ? ?
[q1, q2] ? ?
[q0, q1, q2 ] ? ?
1
To find δ ( [q 0 , q 1 ], a
δ ( {q 0 , q 1 } , a )
= δ (q 0 , a) ∪ δ ( q1 , a)
= {q 0 , q 1 }∪ { q 1 }
= {q0, q1}
1
δ ( [q 0 , q 1 ], a) = [q 0 , q1 ]
1
To find δ ( [q 0 , q 1 ], b
δ ( {q 0 , q 1 } , b )
= δ (q 0 , b) ∪ δ ( q1 , b)
= {q 2 }∪ { q 0 }
= {q0, q2}
1
δ ( [q 0 , q 1 ], b) = [q 0 , q2 ]
1
To find δ ( [q 0 , q 2 ], a
δ ( {q 0 , q 2 } , a )
= δ (q 0 , a) ∪ δ ( q2 , a)
= {q 0 , q 1 }∪ { q 0 }
= {q0, q1}
1
δ ( [q 0 , q 2 ], a) = [q 0 , q1 ]
1
To find δ ( [q 0 , q 2 ], b
δ ( {q 0 , q 2 } , b )
= δ (q 0 , b) ∪ δ ( q2 , b)
= {q 2 }∪ { q 1 , q 2 }
= {q0, q1}
= [q 1 , q 2 ]
1
δ ( [q 0 , q 2 ], b) = [q 1 , q 2 ]
1
To find δ ( [q 1 , q 2 ], a
δ ( {q 1 , q 2 } , a )
= δ (q 1 , a) ∪ δ (q 2 , a)
= {q 1 }∪ { q 0 }
= {q0, q1}
1
δ ( [q 1 , q 2 ], a) = [q 0 , q1 ]
1
To find δ ( [q 1 , q 2 ], b
δ ( {q 1 , q 2 } , b )
= δ (q 1 , b) ∪ δ (q 2 , b)
= {q 0 }∪ { q 1 , q 2 }
= {q0, q1, q2}
1
δ ( [q 1 , q 2 ], b ) = [q 0 , q 1 , q 2 ]
1
To find δ ( [q 0 , q 1 , q 2 ], a
= δ (q 0 , a) ∪ δ ( q1 , a) ∪ δ ( q2 , a)
δ ( {q 0 , q 1 , q 2 } , a )
= {q 0 , q 1 }∪ { q 1 }∪ {q 0 }
= {q0, q1,}
1
δ ( [q 0 , q 1 , q 2 ], a) = [q 0 , q 1 , ]
1
To find δ ( [q 0 , q 1 , q 2 ], b
)
= δ (q 0 , b) ∪ δ ( q1 , b) ∪ δ ( q2 , b)
δ ( {q 0 , q 1 , q 2 } , b )
= { q 2 }∪ {q 0 }∪{q 1 , q 2 }
= {q0, q1, q2}
1
δ ( [q 0 , q 1 , q 2 ], b) = [q 0 , q 1 , q 2 ]
a b
q1 [q1] [q0]
For eg.
We say an NFA accepts a string w if there is some labeled w from the initial
state to a final state of course edges labeled ∈ may be included in the path
although the ∈' s do not appear explicitly in w.
For eg. the word 002 is accepted by the NFA by the path q 0 – q0 – q0 – q1 – q2 –
q2 with arcs labeled 0, 0, ∈, ∈, 2
Formal definition :
A NFA with ∈ − moves to be a 5 – tuple,
M = (Q , ∑ , δ , q 0 , F)
δ is the transition function maps
Q
Q x (∑ ∪ { ∈ } to 2
δ (q, a) will consist of all states P such that there is a transition labeled a from
q to p where a is either ∈ or a symbol in ∑ ¿¿
0 1 2 ∈
q0 {q0 φ φ {q1
} }
q1 {q1 {q2
} }
[q2] {q2
}
∈ - closue (q)
∈ -closue (q) is the set of all vertices p such that there is a path from q to p
labeled
Example :
∈ - closure (q0) = {q0, q1, q2}
ie) the path consisting of q0 alone is a from q0 to q0 with all arcs labeled ∈.
Path q0 – q1, shows that q1 is in ∈ − closure. (q0)
Path q0 – q1 – q2 shows that q2is in ∑ ¿¿ -closure.
¿
δ can be defined as follows :
¿
1. δ (q, ∈) = ∈− closure ( q)
2. for w in ∑ ¿ and a in ∑ ¿¿
¿
δ (q, wa) = ∈ - closure (p)
Where p = { p| }
¿
4. δ (R , W ) =∪ δ (q,w)
q in R
We can define L (M) as
The language accepted by M ( Q , ∑ , δ , q 0 , F) to be
¿
{w| q δ (q,w) contains a state in F}
Example :
Consider the NFA
¿
q2 {q2
}
∈ − closure( q1 )= {q 1 , q 2 }
∈ − closure( q2 )= {q 2 }
δ (q0, ∈) = ∈ − closure( q0 )
= {q0, q1, q2}
1
δ (q0, 0) = ∈ − closure (δ ( q0 , 0))
= ∈ − closure (δ ( δ (q 0 , ∈), 0)
= ∈ − closure (δ ({q 0 , q 1 , q 2 }, 0)
= ∈ − closure (δ ( q 0 , 0) ∪δ (q 1 , 0) ∪δ (q 2 , 0))
= ∈ − closure (δ ({q 0 } ∪φ∪φ)
= {q0, q1, q2}
1
δ (q 0 , 1) = ∈ − closure (δ ( q0 , 1))
= ∈ − closure (δ ( δ (q 0 , ∈), 1)
= ∈ − closure (δ ({q 0 , q 1 , q 2 }, 1)
= ∈ − closure (δ ( q 0 , 1) ∪δ ( q 1 , 1) ∪δ (q 2 , 1))
= ∈ − closure (φ∪ ({q 1 }∪φ)
= {q1, q2}
1
δ (q 0 , 2) = ∈ − closure (δ ( q0 , 2))
= ∈ − closure (δ ( δ (q 0 , ∈), 2)
= ∈ − closure (δ ({q 0 , q 1 , q 2 }, 2)
= ∈ − closure (δ ( q 0 , 2) ∪δ (q 1 , 2) ∪δ (q 2 , 2))
= ∈ − closure (φ∪φ∪ {q 2 }
= {q2}
1
δ (q 1 , 0) = ∈ − closure (δ ( q1 , 0))
= ∈ − closure (δ ( δ (q 1 , ∈), 0)
= ∈ − closure (δ ({ q 1 , q 2 }, 0)
= ∈ − closure (δ ( q 1 , 0) ∪δ (q 2 , 0))
= ∈ − closure (φ∪φ)
= φ
1
δ (q 1 , 0) = ∈ − closure (δ ( q1 , 0))
= ∈ − closure (δ ( δ (q 1 , ∈), 1)
= ∈ − closure (δ ({ q 1 , q 2 }, 1)
= ∈ − closure (δ ( q 1 , 1) ∪δ (q 2 , 1) ))
= ∈ − closure ({q 1 }∪φ)
= {q1, q2}
1
δ (q 1 , 2) = ∈ − closure (δ ( q1 , 2))
= ∈ − closure (δ ( δ (q 1 , ∈), 2)
= ∈ − closure (δ ({ q 1 , q 2 }, 2)
= ∈ − closure (δ ( q 1 , 2) ∪δ (q 2 , 2) )
= ∈ − closure (φ∪ {q 2 } )
= {q2}
1
δ (q 2 , 0) = ∈ − closure (δ ( q2 , ∈), 0)
= ∈ − closure (δ (¿¿
= ∈ − closure (φ)
= φ
δ 1 (q 2 , 1) = ∈ − closure (δ ( q2 , ∈), 1)
= ∈ − closure (δ (¿ ¿
= ∈ − closure (φ)
= φ
1
δ (q 2 , 2) = ∈ − closure (δ ( q2 , ∈), 2)
= ∈ − closure (δ (¿¿
= ∈ − closure (q 2 )
= φ
Example 2 :
Construct a NFA without ∈ - moves from NFA with ∈ - moves
Solution :
∈ − closure (q0) = {q0, q1}
∈ − closure (q1) = {q1}
Let Given NFA with ∈ − moves
M = (Q , ∑ , δ , q 0 , F)
We have to find M’, NFA without ∈ − move
1 1
M = (Q , ∑ , δ , q 0 , F )
F1 = {q0, q1} ∈−closure (q 0) contains a state in F
F1 = F∪ {q 0 }
1
δ (q 0 , ∈) = ∈−closure (q0 )
= {q0, q1}
1 1 1
δ (q 0 , 0) = ∈ − closure (δ (δ (q 0 , ∈), 0)
1
= ∈ − closure ( δ ( ¿ ¿
= ∈ − closure ( δ ( ¿ ¿
= ∈ − closure ( ¿ ¿
= {q0, q1}
1 1 1
δ (q 0 , 1) = ∈ − closure (δ (δ (q 0 , ∈), 1)
1
= ∈ − closure ( δ ( ¿ ¿
= ∈ − closure ( δ ( ¿ ¿
= ∈ − closure (φ∪¿¿
= {q1}
1 1 1
δ (q 1 , 0) = ∈ − closure (δ (δ (q 1 , ∈), 0)
1
= ∈ − closure (δ (¿ ¿
= ∈ − closure (φ)
= φ
δ 1 (q 1 , 1) = ∈ − closure (δ1 (δ1 (q 1 , ∈), 1)
1
= ∈ − closure (δ (¿ ¿
= ∈ − closure (q 1 )
= {q1}
0 1
q1 {q1
}
Induction :
One or more operators in the regular expressions.
Assure that the theorem is true for regular expression with fewer that I
operators.
i≥1
Let r have I operators.
Case 1 :
r = r1 + r2
Both r1 and r2 must have fewer than i operator
Thus there are 2 NFA’s
M1 = (Q 1 , ∑ 1 , δ 1 , q 1 , {f 1 } with
= L (M1) = L (r1)
Assume Q1 and Q2 are disjoint
Let q0 → be a new initial state
f0 → be a new initial state
Now we can construct NFA with
M = Q1 , ∪ Q 2 ∪ {q 0 , f 0}, ∑ , ∪∑ 2 , δ , q 0 , {f 0 })
where δ is defined by
(i) δ (q 0 , ∈) = {q 1 , q 2 }
(ii) δ (q, a) = δ 1 (q , a) for q in Q 1 − {f 1 } and a in ∑ 1 ∪ {∈}
(iii) δ (q, a) = δ 2 (q , a) for q in Q 2 − {f 2 } and a in ∑ 2 ∪ {∈}
(iv) δ 1 ( f 1 , ∈) = δ 2 (f 2 , ∈) = {f 0 }
Hence
L (M) = L (M1) U L (M2)
Any path in the transition diagram of M from q 0 to f0 must begin by going to
either q1 or q2on ∈ . If the path goes to q1 it may follow any path in M1 to f1 and then
go to f0 on ∈
Hence L (M) = L (M1) U L (M2)
Case 2 :
r = r1 r2
Let M1 and M2 be 2 NFA’s
M = Q 1 , ∑ 1 , δ 1 , q 1 , {f 1 }) with
1
L (M1) = L (r1)
and
M2 = Q 2 , ∑ 2 , δ 2 , q 2 , {f 2 }) with
L (M2) = L (r2)
Assume Q1 and Q2 are disjoint
No we can construct NFA with
L (M) = L (r)
M = (Q , ∪Q 2 , ∑ , ∪∑ 2 , δ , {q 1 }, {f 2 })
where
δ is defined as
Thus
L (M) = L (M1) L (M2)
ie. L (M) = {xy| x is in L ( M 1 ) and y is in L ( M 2 )}
Case (iii)
r = r1*
Let M1 = (Q 1 , ∑ 1 , δ 1 , q 1 , {f 1 }) with
L (M1) = L (r1)
Now we can construct NFA
Let M1 = (Q 1 {q 0 , f 0 }, ∑ 1 , δ 1 , q 0 , {f 0 }) with
L (M) = L (r)
where
q0 → be an new initial state
f0 → be an new final state
and δ is given by
(i) δ (q0 , ∈) = δ ( f 1 , ∈) = {q 1 , f 0 }
δ (q , a ) = δ (q , a) for q in Q − {f } and a in
∑1 ¿ {∈}
(ii) 1 1 1
Theorem 2
If L is accepted by DFA, then L is denoted by the regular expression.
Proof :
Let L be the set accepted by accepted by the DFA
M = ({q 1 , ........, q n }, ∑ , δ , q 1 , F)
Let
k
R ij → denote the set of all string x such that δ (q i , x ) = q j and δ (q i , y) = q for any
l
i.e.) Rij = is the set of all strings that take the FA from state qi to qj without going
though any state numberd higher than k.
k
we can define ij R
= is the set of all strings that take the FA from state q i to qj
without going through any state numbered higher than k.
k
1) in R ij
(or)
k −1 k −1
k −1
followed by a string R kj
k
We must show that for each i, j and k, there exists a regular expression r ij
r4 = r5*
r5 = 1
The NFA for r5 = 1
Ro
ij = ¿ ¿¿
¿
r 011 = ∈ + 1
r 012 = 0
r 021 = φ
r 022 = ∈ + 0 + 1
k k−1 k−1 k−1 k−1
Rij , = Rik ( Rkk )∗ Rkj ∪ Rij
r kij = r k−1 k−1 k−1 k−1
ik (r kk )∗ r kj + r ij
For K = 1
0 0 0 0
R(1)
11 = r 11 (r 11 )∗ r 11 + r 11
= (∈ + 1) (∈ + 1)∗ (∈ + 1) + (∈ + 1)
= 1* + (∈ + 1)
= 1*
0 0 0 0
r (1)
12 = r 11 (r 11 )∗ r 12 + r 12
= (∈ + 1) (∈ + 1)∗0 + 0
= 1* + 0
= 1*0
0 0 0 0
r (1)
21 = r 21 (r 11 )∗ r 11 + r 21
= φ (∈ + 1)∗ (∈ + 1) + φ
= φ1∗ + φ
= φ
0 0 0 0
r (1)
22 = r 21 (r 11 )∗ r 12 + r 22
= φ (∈ + 1)∗ (0) + ∈ + 0 + 1
= φ1∗+ 0 + ∈ + 0 + 1
= φ+ ∈+ 0+1
= ∈+0+ 1
Let K = 2
r (211 ) = r 112 (r 122 )∗ r 121 + r 111
= 1∗0 (∈ + 0 + 1)∗ φ + 1∗¿ ¿
= φ + 1∗
= 1∗¿ ¿
r (212) = r 112 (r 122 )∗ r 122 + r 112
= 1∗0 (∈ + 0 + 1)∗(∈ + 0 + 1) + 1∗¿ ¿
= 1∗0 (0+1)∗+ 1∗0
= 1∗0 (0+1)∗¿ ¿
r (221) = r 122 (r 122 )∗ r 121 + r 121
= (∈ + 0 + 1) (∈ + 0 + 1)∗ φ + φ
= (0+1)∗ φ + φ
= φ
r (222) = r 122 (r 122 )∗ r 122 + r 122
= (∈ + 0 + 1) (∈ + 0 + 1)∗ (∈ + 0 + 1) + (∈ + 0 + 1)
= (0+1)∗ + (∈+0+1)
= (0+1)∗¿ ¿
(2 )
L (M) = r 12
= 1* 0 (0 + 1)*
L (M) = 1* 0 (0 + 1)*
MINIMIZATION OF DFA
Minimization of DFA :
There is unique minimum state DFA for every regular set.
Theorem :
The minimum state automata accepting a language L is unique upto an
isomorphism ie) renaming of the states.
Proof :
Any DFA M = (Q , ∑ , δ , q 0 , F) accepting L defines an equivalence relation that
is a refinement of RL
Thus the number of states of M is greater than or equal to the number of states
of M1
If equality holds then each of the states of M can be identified with one of the
states of M1
Let q be a state of M there must be some x in ∑ ¿ such that
δ (q 0 , x) = q , otherwise q would be removed from Q
1 1 1
Identify q with the state δ (q 0 , x) of M
The identification will be consistent.
If δ (q 0 , x) = δ (q 0 , y) = q , then x and y are in the same equivalence class of RL.
0 δ 1 (q 1 , x ) = δ 1 (q , y )
1
Thus 0
A Minimization Algorithm :
There is a simple method for finding the minimum state DFA M 1, equivalent a
given DFA M = ( Q , ∑ , δ , q0 , F )
Let ¿ be the equivalence relation on the states of M.
If P ≡ q, we say p is equivalent to q.
P ≡ q iff for each input string x
δ ( p , x ) is an accepting state.
δ (q, x) is an accepting state.
We say that p is distinguishable from q if there exists on x such that
δ ( p , x ) is an F and
δ (q, x) is not in F and vice versa.
Procedure :
An X is placed in the table each time a of states that cannot be equivalent.
Initially an X is placed in each entry corresponding to one find state and one
non – final state.
Next for each pair of states P and q that are not distinguishable, we consider.
r = δ ( p , a)
s = δ (q, a) for each input symbol a
If states r and s have been shown to be distinguishable by some string x, then p
and q are distinguishable by string ax.
Thus if the string (r,s) in the table has an x, an x is placed at the entry (p, q)
Example :
Minimize the following DFA
Solution :
b x
c x x
d x x x
e x x x
f x x x x
g x x x x x x
h x x x x x x
a b c d e f g
Intially an x placed in each entry corresponding to one final state and one final
state.
The entries
(c, a), (c, b), (c, d), (c, e), (c, f), (c, g), (c, h)
Now the unmarked pairs are
(a, b) (b, d) (d, e) (l, f) (f, g) (g, h)
(a, d) (b, e) (d, f) (e, g) (f, h)
(a, e) (b, f) (d, g) (e, b)
(a, f) (b, g) (d, b)
(a, h)
(a, b)
δ (a, 0) = b
δ (b, 0) = g (b, g) is unmarked
δ (a, 1) = f
δ (b, 1) = c (f, c) is marked, so mark (a, b)
(a, b)
δ (a, 0)= b
δ (d , 0) = c (b, c) is marked so mark (a, d)
(a, l)
δ (a, 0) = b
δ (l, 0) = h (b, g) is unmarked
δ (a, 1) = f
δ (l, 1)= f (f, f) is unmarked
(a, f)
δ (a, 0) = b
δ (f , 0) = c (b, c) is marked so mark (a, f)
(a, g)
δ (a, 0) = b
δ (g , 0) = g (b, g) is unmarked
δ (a, 1) = f
δ (g , 1)= e (f, e) is unmarked
(a, h)
δ (a, 0)= b
δ (h, 0) = g (b, g) is unmarked
δ (a, 1) = f
δ (h, 1) = c (f, c) is marked. So mark (a, h)
(b, d)
δ (b, 0) = g
δ (d , 0) = c (g, c) is marked. so mark (b, d)
(b, e)
δ (b, 0) = g
δ (e, 0)= h (g, h) is unmarked
δ (b, 1) = c
δ (e, 1)= f (c, f) is marked. So mark (b, e)
(b, f)
δ (b, 0) = g
δ (f , 0)= c (g, c) is marked. So mark (b, f)
(b, g)
δ (b, 0) = g
δ (g , 0) = g (g, g) is unmarked
δ (b, 1) = c
δ (g , 1)= e (e, e) is marked. So place an x in (b, g)
(b, h)
δ (b, 0) = g
δ (h, 0) = g (g, g) is unmarked
δ (b, 1) = c
δ (h, 1)= c (c, c) is unmarked.
(d, e)
δ (d , 0) = c
δ (e, 0) = h (c, h) is unmarked. So place x in (d, e)
(d, f)
δ (d , 0) = c
δ (f , 0) = c (c, c) is unmarked
δ (d , 1)= g
δ (f , 1) = g (g, g) is unmarked.
(d, g)
δ (d , 0) = c
δ (g , 0) = g (c, g) is marked. So place an x in (d, g)
(d, h)
δ (d , 0) = c
δ (g , 0) = g (c, g) is marked. So place an x in (d, g)
(d, h)
δ (d , 0) = c
δ (h, 0) = g (c, g) is marked. So place an x in (d, h)
(e, f)
δ (e, 0) = h
δ (f , 0) = c (h, c) is marked. so place x in (e, f)
(e, h)
δ (e, 0) = h
δ (h, 0) = g (h, g) is unmarked.
δ (e, 1) = f
δ (h, 1) = c (f, c) is marked. So place an x in (e, h)
(e, g)
δ (e, 0) = h
δ (g , 0) = g (h, g) is unmarked
δ (e, 1)= f
δ (g , 1)= e (f, e) is marked. So place x in (e, g)
(f, g)
δ (f , 0) = c
δ (g , 0) = g (c, g) is marked. So place an x in (f, g)
(f, h)
δ (f , 0) = c
δ (h, 0) = g (c, g) is marked. So place an x in (f, h)
(g, h)
δ (g , 0) = g
δ (h, 0) = g (g, g) is unmarked
δ (g , 1) = e
δ (h, 1) = c (e, c) is marked. So place x in (g, h)
Now the unmarked place are,
(a, e) (b, h) (d, f) (a, g)
(a, e)
δ (a, 0) = b
δ (e, 0) = h (b, h) is unmarked
δ (a, 1) = f
δ (e, 1)= f (f, f) is unmarked.
(a, g)
δ (a, 0) = b
δ (g , 0) = g (b, g) is marked. So pace an x in (a, g)
(b, h)
δ (b, 0) = g
δ (h, 0) = g (g, g) is unmarked
δ (b, 1) = c
δ (h, 1)= c (c, c) is unmarked.
(d, f)
δ (d , 0) = c
δ (f , 0) = c (c, c) is unmarked
δ (d , 1)= g
δ (f , 1) = g
(g, g) is unmarked.
On completion of the table, we conclude that the equivalent states are
a≡e b≡h d≡f
Algorithm :
begin
for p in F and q in Q-F do mark (p, q) for each pair of disfinct states (p, q)in F x F
or (Q – F) x (Q – F) do
if for some input symbol a
(δ ( p, a), δ (q, a) is marked then begin mark (p, q)
recursively mark all unkarked pairs on the lists of other paurs that are marked at this
step.
end.
else
for all input symbols a do
put (p, q) on the list for (δ ( p, a), δ (q, a) unless
(δ ( p, a) = δ (q , a)
end.
Method II
For the above same problem, the DFA can be minimized using DFA minimization
algorithm.
Solution :
Transition table :
0 1
a b f
b g c
c a c
d c g
e h f
f c g
f c g
g g c
h g c
Step 1
The pair of status (b, h) are same state transition. So b and h are equivalent state.
b≡h
0 1
a b f
[b,h g c
]
*c a c
d c g
e h f
f c g
g c g
Step 2
The pair of status (d, f) are same state transition.
d≡f
0 1
a [b, h] c
c a c
⇒ [d, c g
f]
e [b, h] [d, f]
g g e
Step e
The pair of states (a, e) are same state transition diagram. ∴ a ≡ e
0 1
[b, h] g c
c [a, e] c
[d, f] c g
g g [a, e]