0% found this document useful (0 votes)
17 views15 pages

Toc CHP-2

Uploaded by

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

Toc CHP-2

Uploaded by

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

CHAPTER - 2

Regular Expression and Finite Automata

2.1 Chomsky Hierarchy of Grammar


 Language: A language is a collection of sentences of finite length, all constructed from a
finite alphabet of symbols. Thus, the string or sentences is a sequential occurrence of input
alphabets or symbols such as 0011.
 Grammar: A grammar can be regarded as a device that enumerates the sentences of a
language.
 Formal Grammar: Formal grammar is a way to describe a formal language i.e. set of finite
length strings over a certain finite alphabet. They are named “formal grammar” by the
analogy with the concept of grammar of human language.

It is the containment hierarchy of class of formal


grammar which was describe by Noam
Chomsky in 1956.Here, the automation of the
respective grammar is the mathematical model
to operate the language of grammar.

2.2 Regular Expression


The regular expressions are useful for representing certain set of strings in an algebraic fashion.
The regular expressions are generated by the regular grammar as they are the language
generator. Actually, the regular expression describes the language accepted by the finite state
automata. Any set represented by a regular expression is called a regular set. We give a formal
definition of regular expression over  as follows:
1. Any terminal symbol of the input alphabet such as 0, 1, a, b… or  and ϕ are regular
expression.
2. The union of two regular expression R1 & R2, written as R1+R2 or R1R2 is also RE.
3. The concatenation of two regular expression R1 & R2, written as R1.R2 is also RE.
4. The iteration of any regular expression R, written as R* is also regular expression.
5. If R is a regular expression then (R) is also RE. This have different mean for the case of
iteration i.e. 1+0*  (1+0)*

Identities for Regular Expression


There are some identities for the regular expression that are helpful for simplifying the regular
expressions.
 Φ+R=R
 ΦR=Rϕ=ϕ
 R=R=R
 * =  and ϕ* = 
 R+R=R

Theory of Computation - Compiled by Yagya Raj Pandeya, NAST, Dhangadhi ©[email protected] Page 1

Print to PDF without this message by purchasing novaPDF (http://www.novapdf.com/)


 R*R* = R*
 RR* = R*
 (R*)* = R*
  + RR* = R* =  + R*R
 (PQ)*P = P(QP)*
 (P + Q)* = (P*Q*)* = (P* + Q*)*
 (P + Q)R = PR + QR and R(P+Q) = RP + RQ

Equivalence of two regular expressions


Let P and Q be two regular expressions then P & Q are equivalent (we write P = Q) iff they
represent the same set. Also, P and Q are equivalent iff the corresponding finite automata are
equivalent or isomorphic.

Operators of Regular Expression


The regular expression denotes the language. For example, the RE 01* + 10* denotes the
language consisting of all strings that are either a single 0 followed by any number of 1’s or a
single 1 followed by number of 0’s. There are three operations on languages that represent the
operators of the regular expression. These operations are:
1. The union of two languages L & M denoted by L+M, is the set of string that are in either L
or M or both. For example, let L = {001, 10, 111} and M = {, 001} then L + M = {, 10,
001, 111}.
2. The concatenation of language L & M is the set of string that can be formed by taking any
string in L and concatenating it with any string in M and is denoted by L.M. For example,
let L = {001, 10, 111} and M = {, 001} then L.M = {001, 10, 111, 001001, 10001,
111001}.
3. The closure (or star or Kleene closure) of language L is denoted by L* and represent the
set of those string that can be formed by taking any number of string form L, possibly with
repetitions (i.e. the same string may be selected more than once) and concatenating all
them. For example, let L = {0,1} then L* is the set of all the string of 0’s and 1’s with  or
, i.e. L* = {, 0, 1, 01, 10, 11, 000, … }.

Example
Let L1 = the set of all string of 0’s and 1’s ending in 00, and then the equivalent regular
expression can be described as:
 Any string in L1 is obtained by concatenating any string over {0, 1} and the string 00.
Since, {0, 1} is represented by 0 + 1. Hence L1 is represented by (0 + 1)*00.

L2 = the set of all string of 0’s and 1’s beginning with 0 and ending with 1, and then the
equivalent regular expression can be described as:
 Any string in L2 is obtained by concatenating 0, any string over {0, 1} and 1. Thus L2
can be represented by 0(0+1)*1.

L3 = {, 11, 1111, 111111 …}, and then the equivalent regular expression can be described as:
 Any element of L3 is either , or a string of even number of 1’s so L3 can be represented
by (11)*.

Notes:
 * =++ 
 (0,1)* = (0+1)* but (0+1)  (0,1)
 0+1 = Either 0 or 1 but not both. Thus, 0* + 1* = Either string of zeros or string of one.
 01 = First consume 0 then 1. Thus, 0*1* = First string of zeros then the string of one.

Theory of Computation - Compiled by Yagya Raj Pandeya, NAST, Dhangadhi ©[email protected] Page 2

Print to PDF without this message by purchasing novaPDF (http://www.novapdf.com/)


Decision properties of regular language
1. Is the language describe is empty?
2. Is the particular string ‘w’ is in the described language ‘L’?
3. Is two described language are equivalent or describe the same language?

A. Testing of emptiness of Regular Language


If there is any path from the start state to some accepting state, then the language is non-
empty, while if the accepting states are all separated from the start state, then the
language is empty. Thus, if we can compute the set or any one of reachable states or
accepting state from the start state by reading the any input string then we answer “NO”
(i.e. the language is non-empty) and otherwise we answer “YES” (i.e. the language is
empty).

B. Testing membership in a Regular Language


The next important question is that if ‘w’ is a given string represented explicitly and ‘L’
be a regular language represented by an automata or regular expression then “Is ‘w’ is in
‘L’ or not?” For this, we have to construct a DFA and then simulate the DFA processing
the string of input symbol ‘w’, beginning in the start state. If the DFA end in the
accepting state, the answer is “YES”, otherwise the answer is “NO”.

C. Testing of equivalence of two Regular Languages


Another important question is “whether the different description of two languages
indicate the same things or not?” Since, the different description of a language is given
by a tool called regular expression. To check the equivalence of regular languages, we
construct the DFA of different description. If we get the same DFA for different
description, the answer is “YES”, otherwise the answer is “NO”.

2.3 Automata Theory


 Automata theory: the study of abstract computing devices, or ”machines”
 Before computers (1930), Alan Turing studied an abstract machine (Turing machine) that
had all the capabilities of today’s computers (concerning what they could compute). His goal
was to describe precisely the boundary between what a computing machines could do and
what it could not do.
 Simpler kinds of machines (finite automata) were studied by a number of researchers and
useful for a variety of purposes. Theoretical developments bear directly on what computer
scientists do today
 Finite automata, formal grammars: design/ construction of software
 Turing machines: help us understand what we can expect from a software
 Theory of intractable problems: are we likely to be able to write a program to solve a
given problem? Or we should try an approximation, a heuristic...

Why Study Automata Theory?


Finite automata are a useful model for many important kinds of software and hardware:
1. Software for designing and checking the behavior of digital circuits
2. The lexical analyzer of a typical compiler, that is, the compiler component that breaks the
input text into logical units
3. Software for scanning large bodies of text, such as collections of Web pages, to find
occurrences of words, phrases or other patterns
4. Software for verifying systems of all types that have a finite number of distinct states, such
as communications protocols of protocols for secure exchange information

Theory of Computation - Compiled by Yagya Raj Pandeya, NAST, Dhangadhi ©[email protected] Page 3

Print to PDF without this message by purchasing novaPDF (http://www.novapdf.com/)


Finite state Machine (FSM)
A finite state machine or simply a state machine is a particular conceptualization of a sequential
circuit composed of inputs & outputs, a finite number of states, transition between those states
and actions. Thus, a computer can be viewed as huge FSMs. In
other word, a finite state machine defined as a system of
automation where energy, material and information are
transformed and use for performing some functions without
direct participation of man. Examples are: automatic machines,
and automatic photo printing machine. In computer science the
term ‘automation’ means ‘discrete automation’ and is defined
in more abstract way as shown in figure.

Formally, the finite state machine M = (Q, , O, δ, q0 g) is a 6-tuple that consists of :


 Q = Finite non-empty set of states.
  = Finite non-empty set of input alphabets.
 O = Finite non-empty set of output alphabets.
 δ = State relation or transition function.
 q0 = Start state, q0  Q.
 g = Output function for all pair of states.

 An automation in which the output depends only on the input is called automation without a
memory.
 An automation, in which the output depends on input and the state as well, is called
automation with finite memory.
 An automation in which the output depends only on state of the machine is called Moore
Machine.
 An automation in which the output depends on the state as well as on the input at any instant
of time is called a Mealy Machine.

Finite State Automata (FSA)


Finite state automata (singular Automation) are a special kind of finite state machine with no
outputs but have a set of final states. They recognize string that take the starting state to final
state but no storage mechanism so sometime called the automation without memory. The finite
state automata can be used as language recognizers. This application plays a fundamental role in
the design and construction of compilers for programming languages.

The sets of strings recognized by finite automata are called regular expression. The sets built up
from the null set, the empty string, and singleton (a set by single digit) strings by concatenations,
unions and Kleene closures, in arbitrary order is called regular sets.
Theory of Computation - Compiled by Yagya Raj Pandeya, NAST, Dhangadhi ©[email protected] Page 4

Print to PDF without this message by purchasing novaPDF (http://www.novapdf.com/)


Analytically, a finite automaton M = (Q, , , q0, F) is quin or 5-tuple which consists of
Q = Finite non-empty set of states
 = Finite non-empty set of input alphabet
 = Transition function that assign a next states and inputs (since, Q x   )
q0 = Initial states or start states (q0  Q)
F = Subset of Q (i.e. F  Q) consisting of final state (or accepting states). It is assumed that
there may more than one final state.

The various component of the FSA or FA are


 Input tape: The input tape is divided into squares,
each square containing a single symbol from the
input alphabet . The absent of the end mark on
the input string indicate the infinite length of
string.
 Reading Head: The reading head examines only
one square at a time and can move one square left
or right (but generally from left to right).
 Finite Control: Here, all the states of the system
on reading the input string remain on this set so it
is called the finite control. It controls the activities
on the system as following manner:
 Motion of the reading head along the tape to the next square.
 The next state of the finite automata after the processing of  (q, a), where q = state of
machine, a = input symbol &  = transition function.

 State: A uniquely identifiable set of values measured at various points in a digital system.
 Next State
o The state to which the state machine makes the next transition, determined by the
inputs present when the device is clocked.
o At the termination of the input string the state of the FA must reach to any one final
state among the various possible final states.

Notation for FA
There are two preferred notation for describing the automata, which are:

A. State Diagram or Transition Diagram or graph


A transition diagram or transition system is a finite directed weight graph in which each
vertex (or node) represents a state and the directed edge indicate the transition of the state and
the edges are labelled with input. The initial state is represented by a circle or bubble with an
arrow pointed towards it, the final state by two concentric circles and other states by just a
circle.

The state diagram accept the string w in * if there exists a path which originates from some
initial states, goes along the arrows and terminate at some final state with path value w.

Example:
Let we have the transition function as: (q0, 0)  q0,
(q0, 1)  q1, (q1, 0)  q0, (q1, 1)  q1, with the
initial state q0 and the final state q1, then the
corresponding state diagram is given by:

Theory of Computation - Compiled by Yagya Raj Pandeya, NAST, Dhangadhi ©[email protected] Page 5

Print to PDF without this message by purchasing novaPDF (http://www.novapdf.com/)


B. State Table or Transition Table
A transition table is a conventional tabular representation of a
function like  that take two arguments and returns a value. The row
of the table corresponds to the status and the column corresponds to
the inputs. The entry for the row corresponding to state ‘q’ and the
column correspond to input ‘a’ is the state (q, a).

Types of Finite Automata

A. Deterministic Finite Automata (DFA)


DFA is a FA that is in a single state after reading any sequence of
inputs. The term ‘deterministic’ refer to the fact that on each input,
there is only one state to which the automata can transition from its
current states.

A deterministic finite automaton M = (Q, , , q0, F) is quin or 5-tuple which consists of


Q = Finite non-empty set of states
 = Finite non-empty set of input alphabet
 = Transition function (usually called the
direct transition function) that assign a next
states and inputs (since, Q x   ). In the
transition diagram representation of DFA, 
is represented by arcs between states and the
label on the arc. If ‘q’ is a state, and ‘a’ is an
input symbol then (q, a) is represent that state ‘p’ such that there is an arc labelled ‘a’ from
‘q’ to ‘p’.
q0 = Initial states or start states (q0  Q)
F = Subset of Q (i.e. F  Q) consisting of final state (or accepting states). It is assumed that
there may more than one final state.

Language of DFA
The language of DFA, A = (Q, , , q0, F) is defined by L(A) = { W: (q0, W) is in F} i.e.
the language of ‘A’ is the set of string ‘W’ that takes the start state q0 to one of the accepting
state. If language ‘L’ is L(A) for some DFA ‘A’, then we say ‘L’ is a regular language.

Acceptability of a string by a DFA


A string ‘x’ is accepted by a DFA, A = (Q,
, , q0, F) if (q0, x) = q for some qF.

Theory of Computation - Compiled by Yagya Raj Pandeya, NAST, Dhangadhi ©[email protected] Page 6

Print to PDF without this message by purchasing novaPDF (http://www.novapdf.com/)


B. Non-deterministic Finite Automata (NFA)
Non-deterministic means a choice of moves for an automata i.e.
rather than prescribing a unique move in each situation of input,
we allow a set of possible moves. As shown in figure the state
from q1 can change to the possible states q2, q3 & q4 on reading
the same input 1. As there are multiple state for the same input so
the system sometime may not reach to the final state, hence
termed as the non-deterministic automata.

A non-deterministic finite automaton M = (Q, , , q0, F) is quin or 5-tuple which consists of


Q = Finite non-empty set of states
 = Finite non-empty set of input alphabet
q0 = Initial states or start states (q0  Q)
F = Subset of Q (i.e. F  Q) consisting of final state (or accepting states). It is assumed that
there may more than one final state.
 = Transition function that assign a next states and inputs (since, Q x   ).

Notice that the only difference between NFA & DFA is that the  returns a set of value in
case of NFA and a single value in case of DFA.

Conversation of NFA to DFA


 For every NFA, there exists a DFA which simulate the behavior of NDFA. Alternatively,
if L is the accepted by NDFA, then there exists a DFA which also accept L.
 Every state of a DFA will be represented by some subset of set of states of NFA and
therefore the transition of NFA to DFA is normally called a subset construction. If there
are ‘n’ states of NFA then the possible subsets are 2n, in which some states are used for
construction of the equivalent DFA. Thus, for two states q0 & q1 for NFA then its
possible subsets are 22 = 4 [i.e. {ϕ},{q0}, {q1}, {q0q1}]
 For converting the NFA to DFA,
 Seek all the transition from start state for every symbol in set of inputs ‘’. If you
get the different state beside the start state then terms them as a new state.
 For all the new state, check all the transition for every symbol in . Repeat step-2
till we are getting a new state.
 All these state which consists at least one accepting or final state of given NFA will
be considered as the final state for the equivalent DFA.

EXERCISE – I

NFA with  Transition


If a FA is modified to permit transition without input symbol, along with zero, one or more
transition on input symbols, then we get a NFA with - transitions because the transition mode
without symbol are called -transitions. The idea of the -NFA come from the concept of
closure or iteration.

Formally we represent an -NFA by A = (Q, , , q0, F), where all components have their
same interpretation as for NFA except  is now a function that takes as arguments: -
i. All the states lie in Q after transition.
ii. A member of   {} i.e. either an input symbol or the symbol for empty string
 and it cannot be the member of the alphabet  only.

Theory of Computation - Compiled by Yagya Raj Pandeya, NAST, Dhangadhi ©[email protected] Page 7

Print to PDF without this message by purchasing novaPDF (http://www.novapdf.com/)


The figure shows the NFA with - transition because
it is possible to make the transition from state q0 to q1
and q1 to q3 without consuming any of the input
symbols. This state diagram accept the string 010 as it
can be written as 010.

-Closure
A string ‘w’ in  will be accepted by -NFA if there exist at least one path corresponding ‘w’,
which start in an initial state and ends in one of the final states. Since this path may be formed
by - transitions as well as non-- transitions. We may require defining a function - Closure
(q), where q is a state of the automata.

The function - Closure (q) is defined as “the set of all those stats of the automata (i.e. -NFA)
which can be reached from q on a path labeled by  i.e. without consuming any input symbols.
Note that if there is no  for any state to transit then the - Closure (q) function for that state
will be the same state.

Conversion of -NFA to DFA


This conversion process follows two steps:
 Find the - Closure (q) function of each states
 Identify the transition function of each state obtained from - Closure (q) function.

EXERCISE – II

Conversation of Regular Expression (RE) into equivalent Deterministic Finite Automata


(DFA)
Theorem: Every regular expression ‘R’ can be recognized by a transition system. In other
word, for every string ‘w’ in the set of regular expression ‘R’, there exists a path from the
initial state to a final state with path value ‘w’.

Since, any string generated by regular


expression is accepted by finite state
automata. Thus, on reading the string
from start to finish, it is accepted by the
FSA in regular order of path.

It should be noted that in the case of


iteration, we can add new state by
performing the null or  move and

Theory of Computation - Compiled by Yagya Raj Pandeya, NAST, Dhangadhi ©[email protected] Page 8

Print to PDF without this message by purchasing novaPDF (http://www.novapdf.com/)


generally we merge the  - move in final step of conversation process. For the RE to FA
conversation, the order of precedence is *, (, +, & . and the associatively moves from left to
right.

Note: The representation of a given regular expression may have multiple isomorphic graphs
in conversion of equivalent deterministic finite automata.

Example
The given regular expression (R) = (1+01)* (0+00) (1+10)*
Now, the equivalent Finite Automata (FA) can be constructed as:

Since, the resulting Finite Automata is NFA, which can be converted in to the DFA as follow.
Let ’ be the new transition function for the equivalent DFA.

Thus,
’ (q0, 0) =  (q0, 0) = {q5, q6, qf} (New state) → qr (Say)
’ (q0, 1) =  (q0, 1) = {q0}

’ [(q5, q6, qf), 0] =  (q5, 0)   (q6, 0)  (qf, 0) = {ϕ}  {qf}  {q7} = {q7, qf} (New state)
→ qs (Say)

’ [(q5, q6, qf), 1] =  (q5, 1)   (q6, 1)  (qf, 1) = {q0}  {ϕ} {qf} = {q0, qf} (New state)
→ qt (Say)

’ [(q7, qf), 0] =  (q7, 0)   (qf, 0) = {ϕ} {q7} = {q7} (New state)


’ [(q7, qf), 1] =  (q7, 1)   (qf, 1) = {qf} {qf} = {qf} (New state)

Theory of Computation - Compiled by Yagya Raj Pandeya, NAST, Dhangadhi ©[email protected] Page 9

Print to PDF without this message by purchasing novaPDF (http://www.novapdf.com/)


’ [(q0, qf), 0] =  (q0, 0)   (qf, 0) = {q5, q6, qf} {q7} = {q5, q6, q7, qf} (New state) → qu
(Say)

’ [(q0, qf), 1] =  (q0, 1)   (qf, 1) = {q0} {qf} = {q0, qf}

’ (q7, 0) =  (q7, 0) = {ϕ}


’ (q7, 1) =  (q7, 1) = {qf}

’ (qf, 0) =  (qf, 0) = {q7}


’ (qf, 1) =  (qf, 1) = {qf}

’ [(q5, q6, q7, qf), 0] =  (q5, 0)   (q6, 0)   (q7, 0)  (qf, 0) = {ϕ}  {qf}  {ϕ}  {q7} =
{q7, qf}

’ [(q5, q6, q7, qf), 1] =  (q5, 1)   (q6, 1)   (q7, 1)  (qf, 1) = {q0}  {ϕ} {qf} {qf} =
{q0, qf}

Thus, the new transition ’ of the DFA can be represented by the transition table as:
Now,
i. Acceptance of string 0011100
 (q0, 0011100) =  (qr, 011100)
=  (qs, 11100)
=  (qf, 1100)
=  (qf, 100)
=  (qf, 00)
=  (q7, 0)
=  (ϕ, )

This implies that the string is not acceptable by the Finite Automata.

ii. Acceptance of string 10111001101


 (q0, 10111001101) =  (q0, 0111001101)
=  (qr, 111001101)
=  (qt, 11001101)
=  (qt, 1001101)
=  (qt, 001101)
=  (qu, 01101)
=  (qs, 1101)
=  (qf, 101)
=  (qf, 01)
=  (q7, 1)
=  (qf, )
= {qf}

This implies that the string is acceptable by the Finite Automata.

EXERCISE – III

Theory of Computation - Compiled by Yagya Raj Pandeya, NAST, Dhangadhi ©[email protected] Page 10

Print to PDF without this message by purchasing novaPDF (http://www.novapdf.com/)


Conversation of Deterministic Finite Automata (DFA) into equivalent Regular Expression
(RE)
Arden’s Theorem: Let P & Q be two regular expressions over . If P does not contain , then
the following equation in R, namely R = Q + RP has a unique solution (i.e. one and only one
solution) given by R = QP*.

Steps for DFA to RE conversion


1. Define the equation for each state. The equation of start state must contain the  also.
2. Attempt to find the expression contain only the alphabet (as RE contain the alphabets
only) for the final state. If there is more than one final state then identify the expression
of alphabets only for all final state and finally merge them into one expression.

Example
For the given Transition table, the Finite Automata M = [{q0, q1, q2,
q3}, {0, 1}, , q0, {q3}] where  can be defined as:

Now, FA can be constructed as:

Now, the equivalent Regular Expression (R.E.) of the Finite


Automata (F.A.) can be constructed as:

Step1: Defining the equation for each state with reference to the input symbol (Only incoming
arrows)
Here,
q0 = q0.1 + q1.1 + q2.1 +  ---- I
q1 = q0.0 ---- II
q2 = q1.0 ---- III
q3 = q2.0 + q3.0 + q3.1 ---- IV

Step2: Finding the expression of symbol only for Final state


Here, From equation IV, we have
q3 = q2.0 + q3.0 + q3.1
q3 = q2.0 + q3 (0 + 1)
Using the Arden’s theorem, we have
q3 = q2.0 (0 + 1)* ---- V
Now, using equation II & III on the equation V, we have
q3 = q0.000 (0 + 1)* ---- VI

Now, from equation I, II, & III, we have


q0 = q0.1 + q0.01 + q0.001 + 
q0 = q0 (1 + 01 + 001) + 

Using the Arden’s theorem, we have


q0 =  (1 + 01 + 001)* = (1 + 01 + 001)* ---- VII

Now, from equation VI, & VII, we have


q3 = (1 + 01 + 001)* 000 (0 + 1)*
This is the R.E. which is accepted by FA.

EXERCISE – IV

Theory of Computation - Compiled by Yagya Raj Pandeya, NAST, Dhangadhi ©[email protected] Page 11

Print to PDF without this message by purchasing novaPDF (http://www.novapdf.com/)


Closure Property of Regular set
The closure property of the regular set is defined with reference to the Finite Automata (FA) i.e.
the language acceptor. Class of language accepted by finite automata is closed under: Union,
concatenation, Kleene closure or Star, omplementation and Intersection.

A. Union
Let M1 = (Q1, 1, 1, q1, F1) be NFA that accept a
regular language L = L (M1) and M2 = (Q2, 2, 2, q2,
F2) be another NFA that accept a regular language L
= L (M2). Here, we assume that Q1 and Q2 are two
disjoint sets.

Now, we construct NFA M = (Q, , , q, F), such


that it can accepts L = L(M1)  L(M2), where q is
the new state not in Q1 or Q2. Where,
• Q = Q1  Q2  {q}
•  = Set of input states = 1  2  {}
•  = 1  2  [(q, )  q1, (q, )  q2]
• q = Start state.
• F = F1 F2.

M begins any computation by non-deterministically choosing to either the initial state of M1


or the initial state of M2 and interpreter, M initiates either M1 or M2. Formally, if w  *,

then if and only if

, or

Hence, L (M) = L (M1)  L (M2).

B. Concatenation
Let M1 = (Q1, 1, 1, q1, F1) be NFA that accept a
regular language L = L (M1) and M2 = (Q2, 2, 2, q2,
F2) be another NFA that accept a regular language L =
L (M2). Now, we construct NFA M = (Q, , , q, F),
such that it can accepts L = L (M) = L (M1) ● L (M2).

Where,
• Q = Q1  Q2
•  = Set of input states = 1  2  {}
•  = 1  2  [(F1, )  q2]
• q = Start state = q1
• F = F2.

Formally, if and only if there are w1, w2  * and there is a

P1F1, such that w = w1w2 and &

Hence, L (M) = L (M1) ● L (M2).

Theory of Computation - Compiled by Yagya Raj Pandeya, NAST, Dhangadhi ©[email protected] Page 12

Print to PDF without this message by purchasing novaPDF (http://www.novapdf.com/)


C. Kleene closure
Let M1 = (Q1, 1, 1, q1, F1) be NFA that accept a
regular language L = L (M1). Now, we construct NFA
M = (Q, , , q, F), such that it can accepts L = L (M)
= L (M1)*.

Where,
• Q = Q1  {q}
•  = Set of input states = 1  {}
•  = 1  [(q, )  q1, (q1, )  F1, (F1, )  q]
• q = Start state
• F = F1 {q}.

Here, M consists of the states of M1 and all the transition of M1 and also, any final state of
M1 is the final state of M. In addition, M has a new initial state ‘q’. The new initial state is
also final so that  is accepted. From it, the state q1 can be reaches on the input , so that the
operations of M1 can be initiated after M has been started in state ‘q’. Finally, the transition
on input are added from each final state of M1 back to q1, once a string in L (M1) has been
read, computation can resume from the initial state of M1.

It follows the inspection of M that if w  L (M) then either w =  or w = w1, w2… wk, for k 

i. for i = 1, 2 …k, there is Fi  F such that

Hence, w  L (M1)* so L (M) = L (M1)*.

Pumping Lemma for Regular Set or Language


 The pumping lemma for regular languages
describes an essential property of all regular
languages. Informally, it says that all
sufficiently long words in a regular language
may be pumped - that is, have a middle
section of the word repeated an arbitrary
number of times - to produce a new word
which also lies within the same language.
 The pumping lemma gives a method of pumping (generating) many input string from a
given string. In general, it gives a necessary condition for an input string to belong to a
regular set.
 We have established that the class of language known as regular language for at least four
different descriptions. They are the language accepted by DFA, NFA, -NFA, and regular
expression. Not every language is regular. The pumping lemma is a powerful technique for
showing certain language is not-regular.
 Let  = {0, 1} = {0, 1, 00, 11, 01, 001…} be the set of string generated from the given input
symbol. These set of the string may fall in different class of language as shown in figure.
Thus, the pumping lemma helps us to identify whether the set of string or language fall in
the class of regular language or not. We can use proof by contradiction together with the
Pumping Lemma to demonstrate a language is not regular.
 Pumping lemma is the relation between the set of string (n) and the length of the string (m or
|w|).

Theory of Computation - Compiled by Yagya Raj Pandeya, NAST, Dhangadhi ©[email protected] Page 13

Print to PDF without this message by purchasing novaPDF (http://www.novapdf.com/)


 Neither the original nor the general version of the pumping lemma gives a sufficient
condition for a language to be regular. That is, the lemma holds for some non-regular
languages. If the lemma does not hold for a language L, then L is not regular. If the lemma
does hold for a language L, L might be regular.

Statement
Let M = (Q, , , q0, F) be a finite automaton with n states that accepts a regular language L. Let
w be any string such that w L and |w|  n then there exists x, y, z such that
1. w = xyz,
2. y   (Given assumption)
3. |xy|  n (|xy| = n when z = ) and
4. xyiz  L, for all i  0.

Here,
 n = Number of states.
 w = Any string w L
 |w|= m= Length of string in w (if w = abcd, |w| = 4.)
 yi = Read i at infinite times.

Proof
Let w = a1, a2, a3 … am, (m is length of string)
(q0, a1, a2, a3 … ai) = qi, (i = 1, 2, 3 … n) = Sequence of states in the path with path value
‘w’.
Q’ = {q0, q1, q2 … qn)

Now, the input string ‘w’ can be decomposed into three substrings as:
 x = a1, a2, a3 … aj
 y = aj+1, … ak
 z = ak+1, … am

Since, we know that for any regular expression,


there exists a path from initial state to final sate
with path value the given regular expression.
Thus, for ‘w’ the finite automata can be
constructed as shown in figure.

Here, on reading the string xyz (i.e. |w| = m =3), a new states are added on the existing states (i.e.
states (n) = 4). But by the definition of pumping lemma, we have, |w|  n. Thus, by using Pigeon-
Hole principle, there must coincides at least two states in Q, as there are only n distinct states
defined but on applying the input string the states becomes n+1. Thus, among various pair of
repeated states, we take first as qj and qk (i.e. qj = qk) for merging & hence the path with value w
in the transition diagram of M is shown in figure below.

xyiz  L, for all i  0.


 When i =0, w = xy (String is recognized by
finite automata)
 When i =1, w = xyz (String is recognized by
finite automata)
 When i =2, w = xy2z (String is recognized
by finite automata) and so on. Hence we can
conclude that this condition is valid for all
regular string.
Theory of Computation - Compiled by Yagya Raj Pandeya, NAST, Dhangadhi ©[email protected] Page 14

Print to PDF without this message by purchasing novaPDF (http://www.novapdf.com/)


The figure shows the string accepted by the finite automata M. Here, M starts for the initial state
q0 and on applying the string x, it reaches the state qj = qk. Again, on applying y, it comes back
to the same state qj = qk until application of yi, i0 and finally it reaches to qm on applying z.
Thus, the string of ‘y’ can pump in several numbers of times to generate large string. Hence, xyiz
 L.

For |xy|  n
The verification of the case is obvious by the help of the given FA defined for the regular string
‘w’. Since, w = xyz = a1, a2 …aj, aj+1…ak, ak+1… am, thus we can write 1 j < k  m and this
implies that |xy|  n.

Hence, we can say that the pumping lemma is proved.

Theory of Computation - Compiled by Yagya Raj Pandeya, NAST, Dhangadhi ©[email protected] Page 15

Print to PDF without this message by purchasing novaPDF (http://www.novapdf.com/)

You might also like