Professional Documents
Culture Documents
INTRODUCTION
1.1 INTRODUCTION
PUSH
Start
OF ON
F
PUSH
Introduction 1.2
Here,
When the electric switch = “ON” indicates logic ‘1’ when pushed from start state.
t h e n
t t the the
h n
a u t o m a t
a a au auto auto autom automa
u t m a t
a
automat
a
A1 A2
COMPLEMENT OF A SET [A']
Let A be a set of finite number of elements. Then A' is a set of elements that are not the
elements of set A. [A' A]
Example:
A1 = {a, e, i, o, u}
OPERATIONS ON SETS
Union [ ]
The union of two sets results in a set containing the elements of both the sets (without
repeatition of elements).
Example:
A1 = {1, 3, 5, 7}
A2 = {1, 2, 3, 4,}
A1 A2 = {1, 2, 3, 4, 5, 7}
Intersection [ ]
The intersection of two sets contains a set of elements that are available in both the sets.
Example:
A1 = {1, 3, 5, 7}
A2 = {1, 2, 3, 4}
A1 A2 = {1, 3}
Difference [ - ]
The difference of two sets A and B results in the set of elements that are in A and not in B.
Example:
A1 = {1, 3, 5, 7}
A2 = {1, 2, 3, 4}
Introduction 1.4
LAWS ON SETS
Commutative Laws
A B =B A
A B=B A
Associative Laws
A (B C) = (A B) C
A (B C) = (A B) C
Distributive Laws
A (B C) = (A B) (A C)
A (B C) = (A B) (A C)
Idempotent Laws
A A= A
A B=A
Absorptive Laws
A (A B) = A
A (A B) = A
De Morgan’s Laws
(A B) ' = A' B'
Other Laws
(A') ' = A
A A' =
A A' = Universal set, ’U’
A =A
1.5 Theory of Computation
A =
A U=U
A U=A
Equality of sets [ = ]
Two sets are set to be equal if both the sets contain the same elements.
Example:
A = {1, 3, 5, 7}
Then, A = B
Empty set [ ]
Example:
A= or { }
Power of a set [ Ak ]
The power of a set A, denoted by A k is the set containing all elements of A, whose length is
less than or equal to k.
Example:
A = {1, 2}
A2 = { , 1, 2, 12}
RELATIONSHIP OF SETS
LOGIC
PROPOSITION
Proposition is a meaningful, objective, declarative statement that has a truth value as true /
false.
Example:
0 1, New Delhi is the capital of India, 5 is an even number, Chennai is in AP.
CONNECTIVE
Logical connective is a compound statement formed from simple proportions using a
connective such as
or connective /disjunction
p Q p^q p q p q
T T T T F F
T F F T F T
F T F T T F
F F F F T T
IMPLICATION
It is a conditional statement of the form, “if p then q” (p implies q), where p and q are simple
proportions.
It is denoted as p q = p q
p q p q
T T T
1.7 Theory of Computation
T F F
F T T
F F T
1.2.2 Proofs
A proof is single line / multiline derivation that provide a convincing argument to make a
statement true.
Proofs can be derived from assumptions or facts or existing derivations.
Forms of Proofs
There are basically two forms of proofs. Thery are,
1) Deductive Proofs
2) Inductive Proofs
1.2.2.1 Deductive Proofs
These are sequence of statements which are derived from any assumption (hypothesis) or a
given initial statement to a conclusion statement.
The proofs are generated using some facts / accepted logics.
Example: If x 4, 2x x2
The hypothesis statement x 4
Conclusion statement 2x x2
This can be provided as substitution statement as:
When x = 4:- 24 42 16 16 True
When x = 5:- 25 52 32 25 True
When x = 6:- 26 62 16 36 True
When x = 3:- 23 32 16 9 False
Hence proved.
Inductive Proof
Introduction 1.8
It has a sequence of recursive / parametrical statements that handle the statement with lower
values of its parameters.
Mathematical Induction
Structural Induction
Mathematical Induction
Structural Induction
Structural Induction follows the mathematical induction concept but applies for trees and
expressions.
Example: Every tree has one node than it has edges, balancing parenthesis etc.
Proof by contradiction
Direct Proofs
Proof about the set includes the proofs on the properties of the sets.
Consider, A = P Q, B = Q P
This proof follows “if and only if” type. This is A= B is true if and only if P Q = Q P is
true.
Proof by contradiction
The proof p q is true, then the method follows a contradictory assumption that p q and
from the result, it proves the assumption is false and thus proves, p q.
Example:
xϵPQ
Given a statement, that can be proved to be true for a domain of input instances, and false for
other inputs.
Let a = 5 and b = 10
a % b = 5 % 10 = 5
b % a = 10 % 5 = 0
Thus proved.
These are special type of proofs used to prove recursively defined objects.
It consists of sequence of parameterized statement that uses the statement itself with lower
values of its parameter.
Two steps
SAMPLE PROBLEMS:
1. Prove that: 1+2 +3+ ………+n (n+1) / 2 using method of induction for (n>0).
Proof:
Basis of Induction
Let n = 1 [We cannot take n = 0 since U.H.S starts from 1]
L.H.S = 1
We have
Sub n = n + 1
L.H.S 1 + 2 + 3 +…… + n =
L.H.S = Eg:
1.11 Theory of Computation
= ----- (1)
R.H.S =
R.H.S =
= ----- (2)
2. For all
Basis of induction
Let n=1 (we can’t take n=0 since i=1 in L.H.S)
L.H.S = = 12 = 1
Introduction 1.12
R.H.S =
L.H.S = R.H.S.
Hence basis of induction is proved.
Inductive step
= ----- (1)
=
1.13 Theory of Computation
Solution
Basis of induction
Let n = 0
L.H.S =
= 13 multiple of 13
Inductive proof
Let n=n+1
Multiple of 13
=
Introduction 1.14
= multiple of 13
Hence proved.
Inductive step
Let us assume that is divisible by 3 for n, and try to prove the same for n=n+1
Divisible by 3
1.3 FINITE AUTOMATA
1.3.1 Basic Definitions
Alphabet
Digits
String (w)
A string is a finite sequence of symbols chosen from some alphabet.
Example:
Length of a string
Let be the string, then the length of the string, is the number of symbols
composing the string.
Example:
Concatenation of strings
The concatenation of two strings and is the string obtained by appending the symbols
of v to the right end of .
Example:
Power of an alphabet
Introduction 1.16
If is an alphabet, we can express the set of all string of a certain length from that alphabet
by using an exponential notation.
Example:
Let
Reversing a string
The reverse of the string is obtained by writing the string in reverse order.
Example:
Kleene closure
Let be an alphabet. Then the kleen closure, denotes the set of all strings over the
alphabet,
Example:
1) Let
2) Let
1.17 Theory of Computation
Let be an alphabet. Then the positive closure, denotes the set of all strings over the
alphabet, except null string .
Example:
Let
Substring
The string, v if it appears within another string , then v is called as the substring of .
Example:
Let
v is a substring of
Let
Prefixes
Introduction 1.18
Suffixes
Palindrome
is a palindrome
Example:
equal is a palindrome.
Language (L)
Example:
2. If u and v are two strings, then the length of this concatenation is the sum of the
langth of the individual lengths.
Example:
1.19 Theory of Computation
Operations of Languages
1. Product or concatenation
2. Reversal
The reversal of a language is a set of all string reverses.
4. Positive Closure
L1 L2 = {x | x ϵ L1 or x ϵ L2}
2. Intersection
3. Difference:
Introduction 1.20
a1 a2 a3 a4 … Infinite tape
Read Head
Finite
CPU
control
Input Tape
FA consist of 5 Tuples,
Set of finite states.
Transition function
Start state
Representation of FA
1.21 Theory of Computation
1. Transition Diagram
2. Transition Table
Transition Diagram
It can be directed graph with vertices of a graph corresponding to states and edges indicates
transition from one state to another
0 1
q q q
0 1 2
Start
Final
state
state
a b
q q q
0 1 2
State a b
Input
*q2
Applications
2. String searching
Introduction 1.22
Types
There is only one path for specific input from current state to next state.
where,
Initial state
Transition function
Properties of DFA
There is only one path for an input from current state to next state.
If
1.23 Theory of Computation
b
q q
0 1
Here,
Transition function,
0 1 Valid input
q q q 01
0 1 2
0 1
q q q 0101
0 1 0 2
1 1
101, 1101
0 1
q q q Invalid inputs:
0 1 0 2 00, 10, 1100, 1001, ….
0
Trap
q
2 0, 1
4. Design a DFA that accept only ‘101’.
1 0 1
q q q q Valid input: 101
0 1 2 3
1 0 1
q q q q Invalid inputs:
0 1 2 3 00, 100, 010, 1010, …
1 0
0 0, 1
q
Trap 4
0, 1
a b Valid inputs:
q q q 101
0 1 2
a, b
a b
q q q aba, abb, abaa, abbb,
0
abab, ….
1 2
1.25 Theory of Computation
a, b Invalid inputs:
a b
q q q ba, aa, aab, bab, aaaa,
0 1 2 baab, ….
b a
q
Trap 1
a, b
Valid inputs:
0, 00, 000, 0000,
0, 1 0, 1 0, 1 0, 1 0, 1 00000, 1, 11, 111,
q q q q q q
1111, 1111, 10101,
0 1 2 3 4 5
010, 100, 0010, …
0, 1 0, 1 0, 1 0, 1 0, 1
q Invalid inputs:
q q q q q
101010, 0000000,
0 1 2 3 4 5
11110000,
0, 1 100011001,
q 1111111111, …
Trap 1
0, 1
a a Valid inputs:
q q q
aa
0 1 2
a a
q q q
aaaa, aaaaaa, a8, a16, ...
0 1 a 2
a q a
3 Invalid input
q q a, aaa, aaaaa, a7, a17, ...
0 2
a a
q
1
8. Design a DFA that accepts a language, L having even number of 0s and 1s.
0
Valid inputs:
q q 00, 11, 0000, 1111, 08, 18, …
2 0 1
1 1
q
1
0
q q 0110, 0101, 1010, 1100, 110011,
2
0 1
10101010, 00001111, ...
1 1 1 1 Invalid inputs
0 0, 1, 000, 111, 101010, 110, 1101,
q 0100, …
q 0
1
1
9. Design a DFA that accepts all strings containing atleast two zeroes.
1.27 Theory of Computation
0 Valid inputs:
0
q q q 00
0 1 2
0, 1
0 0 00, 000, 0000, 00000, 0001,
q q q
000111, …
0 1 2
1
0, 1
0 0 100, 1100, 11100000, 110011,
q q q 1001, 11000010, …
0 1 2
1 1 1010, 10110, 11011011, 0101,
0, 1 1101101101, …
0 0
q q q
0 1 2 Invalid inputs:
1, 10, 111, 0111, 101, 11011,
01, …
10. Design a DFA that accepts strings ending with ‘00’ over
0 Valid inputs:
0
q q q 00
0 1 2
0
0 0 000, 0000, 00000, …
q q q
0 1 2
1
0
0 0 100, 1000, 1100 110000, …
q q q
0 1 2
1
0 0100, 101000, 110100, …
0 0
q q q
0
1 1 2
1
0 00100, 1000, 1010100, 001000
0 0
q q q
0
1 1 2 Invalid input:
1 001, 0011, 101, 10011, 1, 01, ..,
Introduction 1.28
11. Design a DFA that accepts a language, L which has the number of zeroes is of
multiples of 3.
0 Valid inputs:
0
q q q 000, 000000, 09, 012, …
0 1 2
0
1
0 0
q q q 1, 1000, 100000, …
0 1 2
0
1 1
0 0
q q q 10100, 11000, 101100, …
0 1 2
0
1 1
1
0 0 101010, 1101010, 1101110110, …
q q q Invalid inputs: 0,00,10000,01011, …
0 1 2
0
0 1 1 1
q q q q q Valid inputs:
0 1 2 3 4 i = 1, j = 1 L = 0111
0 1 1 1 i = 1, j = 2, L = 011111
q q q q q
0
i = 1, j = 3, L = 01111111
1 2 3
1 4
i = 2, j = 1 L = 010111
0 1 1 1 i = 3, j = 1, L = 01010111
q q q q q
i = 2, j = 2 L = 01011111
0 1 0 2 3
1 4
i = 3, j = 3, L = 010101111111
1.29 Theory of Computation
1 1 Invalid inputs:
0 1
q q q q q 1, 00, 0100, 0110, 01110,
0 1 2 3 1 4 011110, 1000, 101, …
0 0
0
Q
Trap 5
0, 1
Valid inputs:
b b
q q q bb, b5, b8, b11 [No. of b%3]
0 1 2 bb 2b’s 2% 3 2 > 1
b bbbbb 5b’s 5% 3 2 > 1
a bbb 3b’s 3% 3 0 > 1
b b
q q q
0 1 2 abb, abbbbb, ab8, …
b ab2, a3b5, ...
a a
b b
q q q
0 1 2 bab, abab, aabbbbb, …
b
a a a
1 Valid inputs:
q q 1
0 1
0
1
q q 01, 001, 0001, …
0 1
0 0
1
q q 10, 100, 1000, 010, 0100, …
0 1
0 0
1
q q Invalid inputs:
0 1 11
1
Trap q
2
0 0
1
q q 0110, 0101, 1111, 101,…
0 1
1
Trap q 0, 1
2
1.31 Theory of Computation
15. Design a DFA that accepts all strings with exactly two 1s over
Valid inputs:
1 1
q q q 1
0 1 2
0
1 1
q q q 011, 0011, 00011, …
0 1 2
0 0
1 1
q q q 0101, 1001, 101, …
0 1 2
0 0 0
1 1
q q q 110, 01010, 1010, 11000 ….
0 1 2
0 0 0
1 1 Invalid inputs:
q q q 111, 1110, 0111, 10101, 1111,
0 1 2
1110101, …
1
Trap q 0, 1
3
Valid inputs:
0 0
q q q 00
0 1 2
0 0
q q q 000, 0000, 00000, …
0 1 2
1 0
0 0
q q q 100, 1100, 11000, …
0 1 2
1 0
0 0
q q q 10100, 1101100, 101101, ….
0 1 1 2
0, 1
1
0 0 Invalid inputs:
q q q
1001, 11001, 101001, …
0 1 1 2
17. Design a DFA that accepts string, such that its second symbol is zero and fourth
symbol is 1.
Valid inputs:
0 0 0 1
q q q q q 0001
0 1 2 3 4
0, 1 0 0 1 1001
q q q q q
0 1 2 3 4
0, 1 0 0 1
q q q q q 0011, 1011
0 1 2 3 4
0, 1
0, 1 0 0, 1 1 00010, 10010, 00110, 00011,
q q q q q 10011, 00111, …
0 1 2 3 4
1.33 Theory of Computation
0, 1
0, 1 0, 1 Invalid inputs:
0 1
q q q q q 0101, 0100, 0010, 1100,
0 1 2 3 4 0000, 1000, …
1 0
Trap q
5
0, 1
0, 1 0 0, 1 1
q q q q q 01010, 01000, 11111,
0 1 2 3 4 0100000, …
1 0
Trap q
5
0, 1
a a a Valid inputs:
q q q q aaa, a, aa,
0 1 2 3
b
a a a
q q q q b, ba, baa, baaa, bb, bba, bbba, …
0 1 2 3
b b
a a a
q q q q bab, abba, abbbaa, babba,…
0 1 2 3
b b b
a a a
q q q q babab, aabb, aaba, bbbaaba, …
0 1 2 3
b b b b
a a a
aaabbb, aaabab, baaaba, …
q q q q
0 1 2 3
Introduction 1.34
b b b b
a a a Invalid inputs:
q q q q aaaa, aaabab, baaaba,
0 1 2 3
…
a
a, b q
4
Trap
19. Design a DFA that accepts all strings containing substring ‘101’.
1 0 1 Valid inputs:
q q q q 101
0 1 2 3
0
1 0 1
q q q q 0101, 000101, …
0 1 2 3
0 1
1 0 1
q q q q 011101
0 1 2 3
0 1 0, 1
1 0 1
q q q q 10100, 101, 101101, …
0 1 2 3
0
0 1 0,1
Complementary
1 0 1 [Does not accept
q q q q
substring with ‘101’]
0 1 2 3
0
1.35 Theory of Computation
20. Design a DFA to check whether a string over contains ‘abb’ is accepted.
a b Valid inputs:
b
q q q q abb
0 1 2 3
b
a b b
q q q q babb, bbabb, …
0 1 2 3
b a
a b b
q q q q aabb, baaabb, …
0 1 2 3
b a
a b b
q q q q ababb, abaabb, bababb, …
0 1 a 2 3
b a a, b
abba, abbb, abbab
a b b
q q q q
0 1 a 2 3
Invalid inputs:
ab, bbb, aaaa,abab, aaba,…
1 Valid inputs:
q q 1
0 1
1
q q 111, 11111, 17, 19, 111, …
0 1 1
0
1
q q 01, 001, 0000111, …
0 1 1
0 0
10, 1011, 10001111, 01101,…
1
q q
Invalid inputs:
0 1 1
11, 1111, 0110110, 111100110, …
0 0 1 Valid inputs:
q q q q 001
0 1 2 3
1
0 0 1
q q q q 1001, 11001, 111001, …
0 1 2 3
1 0
0 0 1
q q q q 0001, 000001, …
0 1 2 3
1 0 0, 1
0 0 1
q q q q 00010, 110011, 110010, …
0 1 2 3
1 0 0, 1
0 0 1 101001, 10101001, …
q q q q
0 1 1 2 3
Invalid inputs:
1111, 0111, 0101, 000, …
23. Design a DFA that recognize words which do not end in ‘b’ over
a
Valid inputs:
a, aa, aaa, aaaa, …
q
0
a
a
b
aabbaa, bba, bbabba, …
b
q q
Invalid inputs:
0 a 1
b, bbb, abb, aabb, abab, …
1.37 Theory of Computation
Valid inputs:
1 1 1 1
q q q q q 1111
0 1 2 3 4
0 0 0 0 0
1 0 0 1 01111, 010100, 01010101,
q q q q q
0
1111000, 1101100, …
1 2 3 4
0 0 0 0 0
1 1 1 1 Invalid inputs:
q q q q q
0 1 2 3 4
111101, 10101011, 110111, …
1
Trap q
5
0 0 0 0 0
1 1 1 1 1111010, 1111011, …
q q q q q
0 1 2 3 4
1
q
0, 1
5
The extended transition function, takes two parameters, state and string.
It is a mapping from
Introduction 1.38
PROBLEMS
1) Consider the transition diagram
b a a, b
a b
q q q
0 1 2
Final state
b
q q
0
b 1
1)
1.39 Theory of Computation
2)
3) Check whether the strings “ababba” ,”baab” are accepted by the DFA?
AU – May / June, Nov / Dec 2009
a b
a
q q q
0 1
a, b 2
1)
Introduction 1.40
2)
M=
1.41 Theory of Computation
where,
Q a finite set of states
A finite set of inputs
Subset
PROBLEMS
∑ 0 1
Q
Introduction 1.42
*
Solution
0, 1 0, 1
0 q 0
1
q q
0 3
1 1
q
2
2) Design a NFA with no more than five states for the set .
a b a
q q q q
2
0 1
a 3
a
q
4
a
a a, b
q q q
0 1 2
0
q q
0 1
1
0
1 1
q
2
0
1.43 Theory of Computation
∑ 0 1
Q
*
Solution:
Calculate 1)
2)
∑ a b
Q
1
5
Solution:
1)
1.45 Theory of Computation
2) :
NFA: where,
Introduction 1.46
is given as
∑ 0 1
Q
a, b
a a b
q q q q
0 1 2 3
∑ a b
Q
is given as
*
1.47 Theory of Computation
8) Design a NFA to accept strings over alphabet , such that the third symbol from
right end is 0.
0, 1
0 0, 1 0, 1
q q q q
0 1 2 3
∑
0 1
Q
following c}.
Introduction 1.48
a, b a, b, c
c a, c
q q q
0 1 1
1 b
a Trap
b
q
4
3}.
0, 1
q Trap
0 4
q
1
1 0, 1
q q
1 2
0, 1
0, 1
q
3
11) Design a NFA for L = contains any number of a’s followed by atleast
one b .
a b a, b
b a
q q q
0 1 2
Trap
12) Design a NFA for a binary number where the first and the last digits are same.
1.49 Theory of Computation
0, 1
0
q q
0 2 4
q
1
1 1
q q
3 5
0, 1
13) Construct a NFA over such that each ‘0’ is immediately preceded and
immediately followed by 1.
1
1
q q
0 1
0 1
0
0
q q
3 2
0, 1
Trap
0,1
0 1
q q q
0 1 2
D=
where,
Set of all subsets of
Procedure
2. Construct the transition table for the subsets over the given language, .
3. Minimise the table by considering only the reachable states from the start state.
PROBLEMS
1) Construct a DFA from the following NFA that accepts all strings of 0’s and 1’s that
end with ‘01’. AU - NOV/DEC 2013, NOV/DEC 2003, MAY/JUNE 2006
Solution:
NFA
0,1
0 1
q q q
0 1 2
Here ,
∑ 0 1
Q
*
1.51 Theory of Computation
Subsets
Transition table:
∑
0 1
Q
*
*
Minimised transition table
∑ 0 1
Q
Processed
Processed
*
Introduction 1.52
0 1
{q 0 } {q 0 , q1} {q 0 , q 2 }
0
1
∑
0 1
Q
s
*
NFA for the above specification
0, 1 0, 1
0 0, 1 0, 1
p q r s
Subsets
Transition table
∑ 0 1
Q
*
Minimised transition table
∑
* 0 1
Q
*
*
DFA
*
Introduction 1.54
0 0
{p} {p, q} {p, q, r}
1 0
1
1 0
{p, r} {p, q, r,s}
0
0 1
1
{p, q,s} {p, r,s}
0
0 1
{p,s}
p,s
1
3) Convert the following NFA to DFA. AU NOV/DEC 2004
∑
0 1
Q
*s
Solution
Here,
1.55 Theory of Computation
0, 1 0, 1 0
p r r s
1 1
1
Subsets
∑
0 1
Q
Transition table
*
*
*
*
* *
*
Introduction 1.56
∑ 0 1
Q
*
DFA diagram
1
1
{q,s} {p, q, r}
0 0
1
{p {r} 0 1 {r,s}
} 1 0 1
0
1 1 {q, r,s}
{q
} 0
1 {q, r}
{s} 0
0
0 1
q q q
0 1 2
0 1
Solution
QN = {q0, q1, q2}
∑ = {0, 1}
q0 = {q0}
FN = {q2}
∑
0 1
Q
* {q2} {q2}
Construction of DFA
QD = {, {q0}, {q1}, {q2}, {q0, q1}, {q0, q2}, {q1, q2}, {q0, q1, q2}}
FD = {{q2}, {q0, q2}, {q1, q2}, {q0, q1, q2}}
q0 = {q0}
Transition table
∑
0 1
Q
{q0} {q0, q1}
{q1} {q2}
*{q2} {q2}
{q0, q1} {q0, q1} {q2}
*{q0, q2} {q0, q1} {q2}
*{q1, q2} {q2}
{q0, q1, q2} {q0, q1} {q2}
Introduction 1.58
∑
0 1
Q
0 1
{q 0 } {q 0 , q1} {q 2 }
5. Convert M = ({q1, q2, q3}, {0, 1}, {q1}, {q3}), where is given by,
1 0
0
0 0,1
q q q
1 0 2 3
∑
0 1
Q
DFA construction
∑ = {0, 1}
QD = {, {q1}, {q2}, {q3}, {q1, q2}, {q1, q3}, {q2, q3}, {q1, q2, q3}}
q0 = {q1}
FD = {{q3}, {q1, q3}, {q2, q3}, {q1, q2, q3}}
Transition table
∑ 0 1
Q
*
{q1} {q2, q3} {q1}
*
{q2} {q1, q2}
*
{q3} {q2} {q1, q2}
*
{q1, q2} {q1, q2, q3} {q1}
Minimized {q1, q3} {q2, q3} {q1, q2} DFA table
Minimized DFA
Introduction 1.60
0
1
0 0,1 0
{q1} {q 2 , q 3 } {q1 , q 2 } {q1 , q 2 , q 3}
1
1
Then w = ε
By the definition of extended transition function,
----- (1)
----- (2)
is true for w = Є Hence proved that L [D] = L [N].
Inductive step
Let us assume that the theorem is true for all the strings, w of length ‘n’. (i.e.) .
Now let us prove that the same is true for a string of length, n+1
Let w = xa, where
a → last symbol of w.
1.61 Theory of Computation
By assumption, we have,
=
By induction principle, the theorem is true for all the strings, w of the given
language.
Thus, L [D] = L [N]
1.7 NFA WITH Є TRANSITIONS
The Є [Epsilon] used to indicate null string. The string is used for transition from one
state to other without any input. AU DEC 2007
q q q
0 1 2
0 0 2
Є CLOSURE {q0} = {q0, q1, q2}
Є CLOSURE {q1} = {q1, q2}
Є CLOSURE {q2} = {q2}
2) Find Є- CLOSURE of States 1,2 and 4 from the following transition diagram. AU
MAY 2008
Є Є
3 6
2
Є
1 Є
a 7
4 5
Є
b)
c)
PROBLEMS
∑
Є a b c d
QE
q0 q0, q1
q1 q1 q1, q2 q3
q2 q2, q3 q2 q2
*q3 q3 q3 q3
a c,d
Є a
q0 q1 q2
b Є
q3
a,b
Solution
Start state of DFA
ECLOSE (q0) = {q0, q1} → Start State of DFA
Successors of {q0, q1} for the input symbols, {a,b,c,d}
Introduction 1.64
Transition Table
∑
a b c d
QD
Equivalent DFA
a
{q 0 , q1} {q1 , q 2 , q 3}
b b
c, d
{{q3}
{q3 {q 2 , q 3}
a, b } a, b c, d
Solution
Start of DFA
ECLOSE(q0) ={q0, q1} ∑
Є a b c d e
↓ QD
q3 q3, q5 q3
q4 q4, q5 q4 q2
*q5 q5
a d e
Є C e
q0 q1 q2 q3
Є
b C
q0 Є
q
5
TRANSITION TABLE
∑ a b c d e
QD
{q0,q1} {q1} {q4,q5} {q2}
*{q3,q5} {q3,q5}
a
{q 0 , q1} {q1}
b
b c e
c
{q4, {q 2 , q 3 } {q3,
q5} q5}
a
d
∑ Є a b c
QE
*r
a) – closure of states
State - Closure
p {p,q,r}
q {q}
r {r}
b) Є NFA → DFA
Start state of DFA, qD
ECLOSE (P) = {p, q, r}
Successors of {p, q, r} over ∑ = {a, b, c}
1.75 Theory of Computation
Transition Table
∑
a b c
QD
* {r}
Transition diagram
1.77 Theory of Computation
b
{p,q,r {q,r
} a,c }
{r
}
The languages accepted by a finite automation can easily be described by a simple expression
called Regular Expressions.
Regular Expressions serve s the input language for many systems that process strings Regular
expression uses a set of operators (like +,., *,….) to represent the language.
Search systems convert RE into DFA/NFA that stimulates the automation on the file being
searched.
Example: Lexical Analyzer accepts tokens as inputs and produces a DFA that recognizes
which token appears next on the input. The set of Stings accepted by finite automata is known
as regular language.
Representation
{Є} R.E = ε
{a} R.E = a
b {a, b} R. E = a + b
a b
{ab} R.E = a.b = ab
Formal Definition of a RE
Introduction 1.78
L0 = {}
L1 = {0, 1}
L2 = {01, 00, 11, 10}
PROBLEMS
1) What is {10, 11}*? Write atleast first seven terms. AU DEC 2009
(10, 11)* = (10, 11)) U (10, 11)’U (10, 11) 2 U (10, 11) 3 U…..
2) Write a RE for the language accepting all combinations of a’s over the set ∑ = {a}
L = {all combination of a’s over {a}}
= {Є, a, aa, aaa,…….}
R = a*
3) Design the RE for the language accepting all combinations of a’s except the null string
over
{}
R = (00)*
12) Write a RE which denotes a language, L overt the set, ∑ = {1}, having odd length of
strings
L = {1, 111, 11111, 1111111,…}
R = (11)*1
13) Write the RE to denote the language, L over ∑ = {a, b}, such that all the strings do
not contain the substring ab.
L = {bbaa, ba, bbbaaa, bb, aa,….}
R = b* a*
14) Write a RE which contains L having the strings which have at least one 0 and 1.
L = {01,001,101,010,011, 10101,10,..}
→ R = (0+1)* 0(0+1)* 1(0+1)* + (0+!)* 1(0+1)*0(0+1)*
15) Describe the following by RE
a) L1 = the set of all strings of 0’s and 1’s ending in 00.
b) L2 = the set of all strings of 0’s and 1’s beginning with 0 and ending with 1
AU MAY 2004
1.81 Theory of Computation
a) R1 = (0+1)* 00
b) R2 = 0(0+1)* 1
16) Find the RE for
a) The language of all strings containing exactly two 0’s
` b) The language of all strings containing at least two 0’s
c) The language of all string that do not end with 01.
Solution
a) R1 = 1* 0 1* 0 1*
b) R2 = 1* 0 1* 0 (1+0)*
c) R3 = (1+0)* (00 + 11 + 10)
1.9 CONVERTING DFA TO RE
THEOREM
If L is a language defined by some DFA, then there is a regular expression defining L.
(or)
If L = L(A) for some DFA, then there is a RE, R such that L = L [R]
PROOF
Let a be a DFA which defines a language L Assume that A has ‘n’ states.
Let us construct the RE of the form, , whose language is the set of strings, w that takes
the DFA from state I to j without going to any state, numbered greater than k.
Basis
Let k = 0 [since all the states are numbered 1]. The Restriction on paths is that the path must
have no intermediate states at all.
There are only two kinds of paths that need such a condition,
An arc from state I to state j.
A path of length zero, that consists of only some state i.
Case 1:- if i≠j
Introduction 1.82
Only (i) is possible. We must examine the DFA, A and find those input symbol, a
such that there is a transition from state, I to j on symbol, a
c) If there are symbols a1, a2,….ak that label arcs from state i to j then = a1 + a2
+ a3 + …. + ak
Case 2:- if i = j
The legal paths are the path of length zero and all loops from I to itself.
The path of length zero is represented by the regular expression, since the path has
no symbols along it. Thus we add, Є to the various expressions derived in (a) through (c)
above.
i.e., Case (a) → No symbol ‘a’ → The expression becomes .
Case (b) → One symbol ‘a’→ The expression becomes +a
Case (c) → Multiple symbols ‘a’→ The expression becomes + a1 + a2 +a3 +….+ ak
Induction
Suppose there is a path from state i to state j that goes through no state higher than K.
There are two possible cases to consider.
Case 1
The path does not go through state k at all. In this case, the label of the path is in the
language of
Case 2
The path goes through state k at least once. Then we can break the path into several pieces.
The first goes from state I to state k without passing through k.
The Last piece goes from k to j without passing through k and all the pieces in the middle go
from k to itself without passing through k. If a path goes through state k only once, then there
are not middle pieces just a path from I to k and a path from k to I.
The set of labels for all paths of this type is represented by the regular expression
, i.e., the first expression represents the part of the path that gets to state k,
the first time, the second represents the quotient that goes from k to itself ‘0‘ times, once or
more than once. And the third expression represents the part of the path that leaves k for the
last time and goes to state, j.
When we combine the expressions for the paths of the two types, we have the expression
1.83 Theory of Computation
Therefore, by induction hypothesis, we can conclude that the RE can be constructed for
all values of I,j and n. The RE for the language defined by the DFA is the sum of all
expressions of all expressions such that state j is an accepting state.
PROBLEMS
Solution: To find
i → start state = 1
j → Final state = 2
Introduction 1.84
Basis Step
Step 1:
Inductive Step
k takes the values 1 and 2. For k =0, basis step has already been calculated.
Step 2:
k=1
i=1; j=1
1.85 Theory of Computation
i=1; j=2
i=2; j=1
i=2; j=2:-
Step 3:
k=2
To find
Introduction 1.86
i=1; j=2
1 0
q1 q2 q3
1
0 1
Solution
Here;
i=1
j=1
k=3
To find:
Basis
Step 1:
1.87 Theory of Computation
Inductive step
Step 2:
k=1
Introduction 1.88
1.89 Theory of Computation
Step 3:
k =2
To find:
So at k = 2; it is enough to find
Introduction 1.90
Step 4:
k=3
To find:
0 q 1
q1 q3
1
0
0,1
Solution
To find:
i = 1 ←Initial State.
j = 2 ← Final state
k = 3 ← No of states.
Basis
Step 1:
1.91 Theory of Computation
Inductive step
Step 2:
k=1
Introduction 1.92
Step 3:
k=2
1.93 Theory of Computation
To find :
At k = 2; It is enough to find
Introduction 1.94
Step 4:
k=3
1
1
1 2 1 3
0
Solution
To find:
Basis
Step 1:
Inductive Step
We Require
Step 2:
1.95 Theory of Computation
k=1
Step 3:
k=2
R.E.
q1 1 0
q2 q3
0,1
0 1
Solution
The language accepted by the above DFA is [since there are two final states]
0 1
1
q1 q2
Basis
Step 1:
Step 2:
k=1
It is enough to find
1.97 Theory of Computation
Step 3:
k =2
Introduction 1.98
The R.E
Rij
qi pj
Qj
Pj
Assume that the state, qi is predecessors of the state S. P j is the successor of s. When we
eliminate the state s, the regular expression, is labeled to R from Q i to Pj. Note that Qi and Pj
may also be same.
R
U
q0 S
q
T
We can represent the accepting string of this two-state automaton in many ways. In general,
we take the string accepted by this automaton, of the form;
1.99 Theory of Computation
(iii) If the start state and the accepting state are the same, then we are left with one –
state automaton.
q0
(iv) The derived regular expression is the sum of all expressions from the reduced
automaton for each accepting states by rules (ii) and (iii)
PROBLEMS
1) Construct the transition diagram for the given DFA and give a R.E by using state
elimination technique.
∑
0 1
Q
q2 {q3} {q1}
* q3 {q3} {q2}
1 0
0
1 0
q1 q2
q
1 3
Solution
q3 → Final State
Introduction 1.100
We use the Regular Expression: is labeled for the arcs from q1 to q3.
To be found
q1-q2-q3
q3-q2-q1
q1-q2-q1
q3-q2-q1
Rij
q1 ___ q2 ___ q3
Qi Pj
Here, S
Rij =
Qi = 0
S=
Pj = 0
Rij
Rij =
1.101 Theory of Computation
q3 - q2 - q1 Qi = 1
Qi S=
Pj
S Pj = 1
r2 = + 1 * 1
= + 11 ← * = None
r2 = 11 ←+a=a
Rij = 0
Rij
Qi = 1
q1 - q2 - q1 S =
Pj = 0
Qi Pj
S
Step 4: Eliminating q2 from q3 - q2 - q3
Rij = 0
Rij
Qi = 1
q3 - q2 - q3 S = Ǿ
Qi Pj = 0
Pj
S
r4 = 0 + 1. * . 0
r4 = 0 + 10 ← * = None
00
1+01 0 + 10 R
S U
q1 q1
q q
11 3
T 3
Introduction 1.102
∑
0 1
Q
*p s p
q p s
r r q
s q r
1 0
P 0 1 1
q r s
1
Solution
[First eliminate the state that is far away from start state].
States to be eliminated: s, r, q
To find:
1.103 Theory of Computation
Step 1:
Rij
Rij =
p - s - q Q1 = 0
Qi Pj S=
Pj = 0
S
Rij = 0
Rij
Qi = 1
q - s - p S =
Pj Pj =
Qi
S
Introduction 1.104
Rij
p - s - r
Qi Pj
S
Rij
r - s - p
Qi Pj
S
Rij
q - s - r
Qi Pj
S
Rij
Pj
r - s - q
Qi Pj
1.105 Theory of Computation
p - s - p
Qi Pj
S
Rij
q - s - q
Qi Pj
S
Rij
r - s - r
Qi Pj
S
Reduced Automaton
Introduction 1.106
10
1 0
00 11
P q r
1
0
01
r1 : p – r – q
r2 : q - r - p
r3 : p – r – p
r4 : q – r – q
Elimination of r from p – r- q ( r1)
Rij
p - r - q
Qi Pj
S
Rij
q - r - p
Qi Pj
S
Rij
p - r - p
Qi Pj
1.107 Theory of Computation
q - r - q
Qi Pj
S
00 + 01(0)*1
1
10 + 11(0)*1
p q
p - q - p
Qi Pj
S
The RE = r*
3) Convert the following NFA that accepts all strings of 0’s and 1’s such that either the second or
third position from right end has 1 to a R.E using state elimination technique.
AU NOV/DEC 2013
0, 1
A 1 B 0, 1 0, 1
C D
Solution
Eliminate B. A → Start state cannot be eliminated
C, D → Final states cannot be eliminated first
To find:
Elimination of state B
r1 : A – B - C
r2 : C – B - A
r3 : A – B - D
r4 : D – B - A
r5 : A – B - A
r6 : C – B - C
r7 : D – B - D
r8 : C – B - D
r9 : D – B – C
Step 1:
A - B - C
Qi
Pj
S
1.109 Theory of Computation
Rij
C - B - A
Qi Pj
S
Rij
A - B - D
Qi Pj
S
D - B - A
Qi
Pj
S
Rij
A - B - C
Qi Pj
S
Introduction 1.110
Rij
C - B - C
Qi Pj
S
D - B - D
Qi Pj
S
Eliminating B from C – B – D (r8)
Rij
C - B - D
Qi Pj
S
Rij
D - B - C
Qi Pj
S
Reduced Automaton
1.111 Theory of Computation
0+1
1 ( 0 + 1)
0+1
A C D
Step 2:
r1 : A - C - D
r2 : D - C - A
r3 : A - C - A
r4 : D - C - D
Rij
A - C - D
Qi Pj
S
Rij
D - C - A
Qi
Pj
S
Rij
r1 :
A - C - A
Qi Pj
S
Introduction 1.112
Rij
r1 :
D - C - D
Qi
Pj
S
Resulting Automaton
0, 1
1(0+1) (0+1) R U
S
A D
1 2
T
A - C - D
D - C - A
A - C - A
Eliminating D from A- D – C (r1)
Rij
A - D - C
1.113 Theory of Computation
Qi Pj
S
A - D - C
Qi Pj
S
A - D - A
Qi Pj
S
C - D - A
Qi Pj
S
0+1 R
1 (0+1)
S U
A C
c 1 2
c T
Regular Expression (RE1) = (R + Su*T)*
c SU*
RE1 = (0+ 1) + (1 (0 + 1)) * )* (1 (0 + 1)) *
Introduction 1.114
RE2 = (0 + 1) * 1 (0 + 1)
Final Automaton
R = RE1 + RE2
= (0 + 1)* 1(0+1)(0 + 1) + ( 0 + 1)* 1( 0 + 1)
THEOREM
(or)
Let ‘r’ be a regular expression, then there exists a NFA with Є – transition that accepts L (r).
Proof
Suppose L = L[R] for a regular expression, R. we show that L = L[E] for some – NFA, with
(i) Exactly one accepting state.
(ii) No arcs into the initial state.
(iii) No arcs out of the accepting state.
Structural Induction on R
Basis
Є
(a) r =
(b) r =
a
(c) r = a
In (a) → the RE, is handled. The language = {}, since the only part from the start state to
the accepting state, labeled Є.
In (b) → It shows the construction of clearly there are no paths from start state L = {}
1.115 Theory of Computation
In ( c) → It gives the automaton for a RE ,’a’. The language of their automaton evidently
consists of the one string, ‘a’ which is also L [a]. These automaton satisfy conditions (i), (ii),
(iii) of the induction hypothesis.
Inductive Step
Assume that the theorem is true for the immediate sub-expressions of a given regular
expression. The languages of Є- NFA’s with a single accepting state.
It starts at a new state, can go to the start state of either R or S, and then reach the
accepting state of one of these automata following a path labeled by some string L[R]
or L[S] respectively.
Є
Є
Є
(a) R + S
Є
Є
Є
We can follow one of the Є – arcs to the accepting state of the new automaton.
R Є S
The start state of the first automaton becomes the start state of the whole and the
accepting state is the accepting state of the whole.
The idea is that the only paths from start state to accepting state, go first through the
automaton for R where it must follow a path labeled by a string in L[R], and then
prove the automaton for S where it follows a path labeled by a string in L [S].
Thus the language is the concatenation of two regular expressions, L[R] L[S].
Introduction 1.116
(c) R*
Є R Є
o Directly from the start state to the accepting state along a path labeled . That
path which is in L [R*] doesn’t matter what expression R is.
o Goes to the start state of the automaton for R and processes through that
automaton one or more times and then to the accepting state. This set of paths
allows us to accept strings in Є, L[R], L[R]L[R], L[R]L[R]L[R and so on.
Thus covering all strings in L[R*] except perhaps which was covered by the direct
arc to the accepting state mentioned in (c)
(d) The expression is (r) for some smaller expression, R.
Since the parenthesis does not change the language defined by the expression.
0
2 4 Є
Є
6
1
1
Є 3 5 Є
(0+1)*
0
Є
3 5 Є
7 8
Є
1 2 Є
1
Є 4 6
(0+1)*1
0
Є
3 5 Є Є 1
8 9 1
Є 7
0
1 2 Є
1
Є 4 6
(0+1)* 1(0+1)
Introduction 1.118
0
0 1 1
1 3 Є
3 5 Є Є 1
Є 1
Є 1
Є 7 8 9 1
5
1 2 Є Є
0
0
1 1
4 6 Є 1 1 Є
2 4
Є Є
1*
Є
Є 1 Є
1 2 3 4
01*
Є
Є Є Є 1 Є
1 2 3 4 5 6
0
Є
Є 2 4
Є 0
6 7 8
1
1
Є 3 5 Є
1 Є 0
1 2 3
4
0+11
0
Є
Є 2 4
8
1 Є Є
1 Є 1
3 5 6 7
0*1
Є Є Є 1
1 2 0 3 4 5 6
Є
10 + (0 + 11)0*1
Introduction 1.120
1 Є 0
2 3 4 5
Є
Є
1
1 Є 0
9
8 9
Є
1
Є Є 0 Є
1 1 1 1
6 7 11 5 6 7 8
4
Є Є
1 Є 1 Є
1 Є
0 1 1 1
1 2 3
0 Є 0
1 2 3
4
(0+1)*
0
3 4 Є
Є 0 0
Є Є
1 2 7 8
0 Є Є 0 0
1
5 6
0
5 Є
00(0+1)*
1.121 Theory of Computation
0
9
8
0 Є 0 Є Є Є Є
1
1 2 3 4 5 6 7 1
Є Є 2 3
1
1 1
0 1
Є
Є 0
3 4
Є Є
1 2 7 8
Є Є
1
5 6
00+11:-
0 Є 0
1 3 4 5
2
Є
Є
1
1
0
Є
Є 1 Є 1
6 7 8 9
Introduction 1.122
(0+1)*(00+11)(0+1)*
Є 0 Є 0
0
1 Є
Є
Є 1 Є
Є Є Є
Є
1 Є
1 Є 1
Є
0
Є
Є
Є Є
1
Є Є
Є
Two finite automata m1 and m2 are said to be equivalent if they accept the same language.
Two FA m1 and m2 are not equivalent over ∑ if there exists a string w such that,
(or)
1.123 Theory of Computation
EXAMPLE:
1) Show that the automata given below are equivalent or not.
c c
d
q1 d q4 q5
d q1
d
c d
d c c
q1 c q6 q7
c
M M
1 2
Step 1:
Here the start states are <q1> and <q4>
We shall start with <q1, q4> over ∑ ={c, d}
Step 2:
State <q2, q6> over ∑ ={c, d}
Introduction 1.124
Step 3:
State <q3,q7> over ∑ ={c, d}
Step 4:
State <q2, q5> over ∑ ={c, d}
d
<q1 , q4> <q2 , q5>
d c
d c
0 1 0
q q q q
0 1 2 3
0 1
1
0 1
1 1 0
q q q q
4 5 6 7
1
0
0
Solution
0 - Equivalence partitioning:
The given set of states in the DFA are classified into two,
1) States that are not final states bock 1
2) Final states block 2
P0
block1 = {q0, q1, q3, q4, q5, q6, q7}
block2 = {q2}
1 – Equivalence partitioning:
This divides the existing non final states based on the inputs that the states accept.
Processing input ‘0’:
Equivalent states
From the above process of input o and 1, {q3, q5}-, {q1, q7} are a set of equivalent states.
1 – equivalence partitioning
P1 = (q3 , q5) , (q1, q7), (q0,q4,q6), (q2)
2 – Equivalence partitioning:
Block – 11
Block – 12
Block – 13
Here q6 doesn’t map with any other states hence it is distinguished from {q0, q4}
2 – Equivalence partitioning
P2 = (q3, q5), (q1, q7) (q0, q4) (q6) (q2)
Since further partitioning cannot be done, the final minimized DFA is given by
0
1
<
0 1
q2>
< q0, q4> < q1, q7>
0
1
0
1
<q6>
< q1, q7
>
1 0
Input a b
States
→ q0 q0 q3
q1 q2 q5
q2 q3 q4
q3 q0 q5
q4 q0 q6
q5 q1 q4
* q6 q1 q3
0- equivalence partitioning
P0 = (q0, q1, q2, q3, q4, q5) (q6)
block 1 block 2
1 – equivalence partitioning
There are no equivalent states. But still, q4 is the distinguishable state from the rest of the
states
P1 (q0, q1, q2, q3, q5) (q4) (q6)
2 – equivalence partitioning:
From the above transitions, there are no equivalent states but there are distinguishable states,
{q2, q5} since
→ block 11
→ block 12
Since no states are equivalent, q0, q1, q3 are distinguishable from each other.
4 - Equivalence partitioning:
(q2, b) = q4 → block 12
(q3, b) = q4 → block 12
Thus the given DFA cannot be minimized since no equivalent states are obtained.
Inputs
0 1
States ↓
→ q0 q1 q4
q1 q2 q5
* q2 q3 q7
q3 q4 q7
q4 q5 q8
* q5 q6 q1
q6 q7 q1
q7 q8 q2
* q8 q0 q4
o- equivalence Partitioning:-
P0 =(q0, q1, q3,q4,q6,q7) (q2,q5,q8)
Introduction 1.132
Block 1 Block 2
1- equivalence partitioning:-
Block 12 Block 12
1.133 Theory of Computation
Block 2 Block 2
Block 11 Block 11
0, 1
{q1, q4, q7}
{q0, q3, q0}
0, 1
0
1
{q2, q5, q8}
Let L be a regular language, then there exist a constant n (which depends on L) such that for
every string w in L such that , we can break ‘w’ into 3 strings:
w = xyz
such that
(i) y ≠
(ii)
P0 Pi Pn-1
That is, x takes us from P0 to Pi once, y takes us from Pi back to Pi (since Pi is also Pj ) and z
takes us from Pi to Pn-1. Note that x may be empty in the case that i = 0, also z may be empty if
1.135 Theory of Computation
j = n = m. However y cannot be empty since I is strictly less than j. Now consider what
happens if the automaton A receives the input xykz for any k ≥ 0.
Case 1:
If k = 0, then the automaton from the start state q 0 (which is also Po) to Pi on input x. Since Pi
is also Pj it must be that A goes from Pi to the accepting state on input z. Thus accepts xz.
Case 2:
If k > 0 , then A goes from q0 to Pi on input, x circles from Pi to Pi, k – times on input y k and
then goes to the accepting state on input, z Thus for any k ≥ 0, xy kz is also accepted by A that
xykz is in L. Therefore we can say that L is a regular language.
PROBLEMS
(i) y ≠ [ i.e, ]
(ii)
(iii) xykz L
Since y≠
x= 0 n-1 // since
y=0 // Since
z = 10n
Thus
(i) y≠
(ii)
(1)
(2)
Since
x = an-1 xy = an-1. a1 = an
y=a
z = bn+1 cn+2
At k = 0:-
xy0z = xz
= an-1.bn+1.cn+2 = an-1.bn+1.cn+2
At k = 1:-
xy1z = an-1.a. bn+1.cn+2
= an.bn+1.c n+2
At k = 2:-
xy2z = an-1.a.a. bn+1.cn+2
= an+1.bn+1.cn+2
Comparing the powers of a, b and c, the language L is not regular.
3) Show that L = {ap | p is a prime number} is not regular. AU – DEC 2007, NOV 2011
Assume that L is regular and n be any integer. Let P ≥ n is a prime number and w = ap Є L.
By pumping lemma, w can be written as w = xyz such that
1.137 Theory of Computation
(i)
(ii)
(iii) xykz L
Let,
Y = am where m ≥ 1
= P + (k-1) =k+k
= P + Pm ← k = p+1 P = k -1
= P(1+m)
Both p and (1+m) are greater than 1. The product of P and (1 + m) cannot be prime
xykz L for k = p+1
L is not regular
4) Show that L = {0n 1n | n ≥ 1} is not regular. AU MAY 2004, DEC 2004, DEC 2005
(i) y ≠ (i.e )
(ii)
(iii) xykz L
Since and y ≠ ,
x= 0n-1
y=0
z = 1n
Introduction 1.138
i = 2; L = { } = aaaa = a4
i = 3; L = { } = aa
At k = 1 xy1z = xyz = 1
2
At k = 2 3
From 2 and 3,
>
4
Since
When and x
1.139 Theory of Computation
xy 2 z n 2 n
xy 2 z < (n 1) 2
From 4 and 5,
n 2 < xy 2 z < (n 1) 2
Example: n = 2; n2 = 22 = 4
L is not regular.
m,n m n
6) Using Pumping lemma, prove that L = o o
m 1 and n 1 is not regular.
AU DEC 2006, DEC 2013, MAY 2013
Let us assume that L is regular and L is accepted by a FA with ‘n’ states.
Let w = o m,n o m n
w m n (m n) 2(m n) n
y > 0 and
xy n
x o m 1
y=0
z = 1n om+n
At k = 0; xykz xyoz = om-1.1n.om+n 1
From (1), the powers of O is not equal with that of L
Introduction 1.140
Hence xyz L
L is not regular language.
R
7) Using pumping lemma, P.T:- L = {ww w (0,1)*} is not regular. AU DEC 2006
(i) y > 0
(ii) xy n
(iii) xy k z L k 0
(i) y > 0
(ii) xy n
1.141 Theory of Computation
(iii) xy k z L k 0
w can be splitted as
x = a n-1
y=a
z =b.an b.
At k = 0:-
xykz xy0z xz = a n-1.b.an b
Since the powers of a does not match with w, L is not regular.
1.15 CLOSURE PROPERTIES OF REGULAR LANGUAGES
AU MAY 2012, MAY 2013, NOV 2010, NOV 2011, NOV 2013, NOV 2012
If an operation on regular languages generates a regular language, then we say that the class of
regular languages is closed under the above operation.
Some of the important closure properties of RL are as follows.
1. Union
2. Difference
3. Concatenation
4. Intersection
5. Complementation
6. Transpose / Reversal
7. Kleene star
8. Homomorphism
9. Inverse homomorphism
Closure under Union
Theorem
If L and M are regular languages, then LUM is also regular.
Proof
Let, L = L [R]
Introduction 1.142
M = L[S]
LUM = L[R] U L [S]
= L [R+S]
Example
Where r0 → New start state having two Є – moves from r0 → s0 and r0 → q0 being added,
R = SUQ U{r0}
H = FUG
Example
Find the complement of (0+1)*01
0,1
0 1
q0 q0
q0
Here,
QN = {q0, q1, q2}
∑= {0, 1}
q0 = {q0}
FN = {q2}
∑
N → 0 1
QN
q1 {q2}
*q2
QD = {, {q0}, {q1},{q2}, {q0, q1}, {q0, q2}, {q1, q2},{q1, q2, q3}}
FD = {{q2}, {q0, q2},{q1, q2},{q1, q2, q3}}
D ∑
0 1
QN
{q1} {q2}
* {q2}
0
1
0 1
{q0, q1}
{q0} {q0, q2}
0
Complement of DFA
0
1
{q0 0 1
{q0, q1} {q0, q2}
}
0
Proof
where,
L[A] L [A L ] L[A M ]
By induction on w ,
(q M , w) must be in FM
1
0,11
0
A p
q
0 0,11
1
r s
B
A B (Q A x Q B , , (q A x q B , FA x F B )
Where
Here,
QA x QB = {p,q} x {r,s}
={(p, r), (p, s), (q, r), (q, s)}
Introduction 1.146
Z = {0, 1}
qA x qB = {p, r}
FA x FB = {q, s}
∑
δ(qA, qB) 0 1
Q↓
Finite Automata
{p, r } 1 {p, s }
0
0
{q, r } 1
{q, s }
0, 1
0
Assume L i9s defined by regular expression. The proof is a structural induction on the size of
E. We show that there is another regular expression.
ER such that L(ER) = (L(E))R.
That is the language ER is the reversal of the language of E.
Basis
If = Є / / a, then
ER = / / a
E = ER
Induction
There are 3 cases depending on the form of E.
1) E = E1 + E2 then ER = E1R + E2 R
The justification is that the reversal of the union of two languages is obtained by
computing the reversals of the two languages and taking the union of those languages.
2) E = E1.E2 then ER = E2R. E1R
Example: L (E1) = {01,111}; L (E2) = {00, 10}
Then, L (E1. E2) = {0100, 0110, 11100, 11110}
L (E1 . E)R = {0010, 0110, 00111, 01111} 1
L(E1)R = {10,111}
L (E2)R = {00,01}
L(E2)R. L (E1)R = {0010, 0110, 00111, 01111} 2
From (1) and (2) L (E1E2) R = L(E2)R. L (E1)R
The justification is that any string w in L (E) can be written as w1, w2,…, wn where each w1 is
in L(E). But,
w R w Rn w Rn 1 .......w1R
Each w1R is in L (ER), so wR is in ( E1R ) Conversely any string in L ( E1R )* is of the form w1, w2,
…wn, where each w1 is the reversal of a string in L(E1). The reversal of the string,
w Rn w Rn 1 .......w1R is therefore a string in L ( E1* ) which is L (E).
Introduction 1.148
Example: If L = (0 + 1)0*
Then LR = 0* (0 + 1) [By applying closure under concatenation, and union]
Closure under Difference
Theorem
If L and M are regular languages then L – M is also regular
L M L M
Proof
Let M1 ( s, , 1 , s o , F)
Theorem
If two languages, M1 and M2 are regular, then L (M1) . L (M2) is also regular.
Theorem
Let M1 = (Q, ∑, δ, q0, F) be the given automata. Then M2 can be constructed such that, L(M2)
= L (M1)*.
M2 is constructed as:
Homomorphism
h(1) =
h(0011) = h(0)h(0)h(1)h(1)
= abab
Theorem
Proof
To prove: L [h(E)] = hb [L(E)]
Basis
If E = or , then
H(E) = or
L[h(E)] = L (E)
Let E = F + G
L[h(E)] = L[h(F + G)]
= L[h(F) U h (G)]
= L[h(F)] U L[h(G)] 1
H[L(E)] = h[L(F + G)]
= h [L(f) U L (G)]
= h [L(f)] U h [L(G)] 2
Therefore by induction, from (1) and (2)
L[h(f)] = h[L(f)] and
L[h(G)] = h [L(G)]
Similarly concatenation and closure is also true,
L[h®] = h[L(R)] Hence proved
Inverse homorphism
Theorem
If h is a homomorphism from alphabet, ∑ to alphabet T and L is regular language over T, then
h 1 (L) is also a regular language.
Proof
We construct a DFA, A for L, then a DFA for h 1 (L) by using A and h. This DFA uses the
states of A but translates the input symbol according to h before deciding on the next state. Let
L be L(A) where DFA, A |(Q, ∑,δ, q0, F) define a DFA, B = (Q, ∑, γ, q0, F) where the
transition function γ is constructed by,
(q, a) (q, h (a)). It is a easy induction on w to show that
(q, h (w)) (q, w)
Since the accepting states of A and B are same, B accepts w if and only if A accepts h(w) i.e.,
B accepts exactly those strings w that are in h 1 (L)
Example: Suppose h is a homomorphism from the alphabet {0, 1, 2} to the alphabet {a, b}
defined by h(0) = a, h(1) = ab, h(2) = ba.
1.151 Theory of Computation
= h-1(a)h-1(ba)h-1(ba)
= 022.