Module 2 · Web viewThe word “AUTOMATA” is used for recognizing or recognizer and word...

27
Theory of computation (TOC) MODULE 2 Introduction to Automata theory – Definition of Automation – Finite Automata – Formal definition – Language acceptability by Finite Automata – Transition Diagrams and Transition systems - Deterministic and Nondeterministic finite automation – Finite Automation with ε-Transitions – Eliminating ε-Transitions - Conversion of NFA to DFA – Regular operations – Regular Expressions – Pumping lemma for regular languages – Applications of finite state automata – Lexical analyzers – Text search INTRODUCTION TO AUTOMATA THEORY We have several things to be done in designing and implementation of an automatic machine.one one important and initial thing is: what is the behavior of a machine? If we want to describe the behavior of an automatic machine, then there should be some effective way.an effective way is using some kind of mathematics .the subject that solves this purpose is known as “Automata theory “or “Theory of computation”. Automata theory is a subject which describes the behavior of automatic machines mathematically” I.e. “A computational model or a recognition model can be described by automata theory” It is philosophy of automatic machines mathematically The word “AUTOMATA” is used for recognizing or recognizer and word “AUTOMATION” is plural of word automata. An automata understands a set of words or strings and reject others.it is also known as accepter. All machines have their internal configurations and these are changes time to time. The meaning is that at particular moment the machine resides in a configuration and next moment on next input the machine changes its configuration and enters the next configuration. Such type of internal confirmations is known as states. DEFINITION OF AN AUTOMATA 1

Transcript of Module 2 · Web viewThe word “AUTOMATA” is used for recognizing or recognizer and word...

Module 2

Theory of computation (TOC)

MODULE 2

Introduction to Automata theory – Definition of Automation – Finite Automata – Formal definition – Language acceptability by Finite Automata – Transition Diagrams and Transition systems - Deterministic and Nondeterministic finite automation – Finite Automation with ε-Transitions – Eliminating ε-Transitions - Conversion of NFA to DFA – Regular operations – Regular Expressions – Pumping lemma for regular languages – Applications of finite state automata – Lexical analyzers – Text search

INTRODUCTION TO AUTOMATA THEORY

We have several things to be done in designing and implementation of an automatic machine.one one important and initial thing is: what is the behavior of a machine? If we want to describe the behavior of an automatic machine, then there should be some effective way.an effective way is using some kind of mathematics .the subject that solves this purpose is known as “Automata theory “or “Theory of computation”.

“Automata theory is a subject which describes the behavior of automatic machines mathematically” I.e. “A computational model or a recognition model can be described by automata theory” It is philosophy of automatic machines mathematically

The word “AUTOMATA” is used for recognizing or recognizer and word “AUTOMATION” is plural of word automata. An automata understands a set of words or strings and reject others.it is also known as accepter. All machines have their internal configurations and these are changes time to time. The meaning is that at particular moment the machine resides in a configuration and next moment on next input the machine changes its configuration and enters the next configuration. Such type of internal confirmations is known as states.

DEFINITION OF AN AUTOMATA

An automata is defined as a system where information is transmitted and used for performing some function without direct, participation of man. An automaton in which the output depends only on the input is called an automaton without memory. An automaton in which the output depends on the input and state is called as automaton with memory. An automata in which the output depends only on the states of machine is called Moore machine. An automaton in which the output depends on the state and input at any instant of time is called a mealy machine.

DESCRIPTION OF AN AUTOMATA

Finite Automata is a mathematical model of a system with descrete input and output. The system can be in any no of internal configuration on state The state of a system summarize the information concerning past input that is needed to determine the behavior of the system or subsequent input

Definition

M=(Q, ( ,(,q0,F) Where,

Q : is a non empty finite set of states presents in the finite control.(q0,q1,q2,….)

( : is a non empty finite set of input symbols which can b passed to the finite state machine(a,b,c,d,e,…)

q0 : is a starting state, one of the states in Q q0(Q

F : is a non empty set of final states or accepting states,set of final states belongs to Q F(Q

( : Mapping function,

Which maps, 01010100 inpur string

Q(( ->Q

Fig(2.1)

0 1 0 1 0 1 0 0 input tape

Reading head

finite control

The diagram given in figure is the mathematical model of FINITE AUTOMATA. In this the tape is divided into cells, in each cell we store a single symbol from the alphabet. The reading head examine only one cell at a time and the head moves to the right side with or without changing the state. Finite automa is represented by transition diagram in which the vertices represent the states and edges represent transitions.

Ex:

Q0

REFER NOTE::::

DETERMINISTIC FINITE AUTOMATA

In deterministic finite automata no input symbol causes to move more than one state or a state does not contain more than one transition from same input symbol. Each and every state has to consume all the i/p symbol present in (. A deterministic finite automata is a quintuple

M=(Q, ( ,(,q0,F)

Where,

Q : is a non empty finite set of states presents in the finite control.(q0,q1,q2,….)

( : is a non empty finite set of input symbols which can b passed to the finite state machine(a,b,c,d,e,…)

q0 : is a starting state ,one of the state in Q q0(Q

F : is a non empty set of final states or accepting states,set of final states belongs to Q F(Q

( : is a function called transition function that two arguments a state and a input symbol, it returns a single state.

Transition function maps,

Q(( ->Q

Let ‘q’ is the sate and ’a’ be input symbol passed to the transition function as: ((q,a)=q’

q’ is the output function i.e, a single state only , q’ may be q.we can also view it graphically as:

q’ ( ()

but q’ may be same as q i.e q’=q

q’ (()

q’’

Case discussed above is not valid case in deterministic finite automata(DFA). Some people prefer to call this just a finite acceptor because its sole job is to accept certain input strings and reject others.

Some time it is also referred as language recognizer because FA merely recognize whether the input string is in the language as we can also recognize that some body is speaking Hindi or English without necessarily understanding what it means.

M=({q0,q1,q2},{0,1},(,q0,{q0}), where ( is defined as

((q0,0)=q0 ((q1,1)=q1 ((q2,0)=q0

((q0,1)=q1 ((q2,1)=q1

((q1,0)=q2

0

qo

1 0

0

q1

q2

Consider a string 0100 and let us check whether it is accepted by the above DFA

((q0,0100) (( ((q0,100) (((q0,0)=q0)

(( ((q1,00) ( ((q0,1)=q1)

(( ((q2,0) (((q1,0)=q2)

(( ((q0,ε) ( ((q2,0)=q0 )

(( q0 ( ((q0, ε)=q0 )

The given string is accepted because the transition is ending with Final state

PROCESSING OF STRINGS BY DFA

Suppose a1,a2,a3..an is a sequence of input symbols .We start out with dfa having q0,q1,q2..qn states where q0 is the initial state and qn is the final state and transition function processed as

((q0,a1) =q1

((q1,a2) =q2

((q2,a3) =q3

..

..

..

((qn-1,an) =qn

Input a1,a2,a3….an is said to be ‘’accepted’’ since qn is the member of the final states, and if not then it is rejected. By adopting this approach we can define the language of a particular DFA,and can also check that particular string is accepted or rejected by given FA.

TRANSITION GRAPH

Transition graph is a collection of 3 things:

1.finite set of states,atleast one of which designated as the start state

And some of which are designated as final state

2.An alphabet (of possible input letters from which input strings are formed

3.A finite set of transitions that show how to go from some states to some others,based on reading specified substring of input letters. Transition graph invented by John Myhill in 1957.

A successful path through a transition graph is a series of edges forming a path beginning at some start state and ending in final state

Examples

This TG that accepts nothing, not even the null string, to be accept any thing, it must be final state.

This TG that accept null string

a b

p b q

a

The language accepted by the TG is all words ending in b over alphabet (={a,b}

Simpler notation for DFA

1. Transition diagram and

2. Transition table

Transition diagram notations

A transition diagram for DFA ,M=(Q,(,(,Q0,F) is a graph defined as follows

(a) For each state in Q there is a node reprecented by a circle

(b) For each state q in Q and each input symbol a in (,let ((q,a)=p.

Then transition diagram has an arc from node q to node P,labelled a. If there are several input symbols that cause transition from q to p, then the transition diagram can have one arc labelled by the list of these symbols as:

q a p q a,b p

q a P

b

(C).if any state q in Q is the starting state then it reprecented by the circle wqith arrow as

(d) Nodes corresponding to accepting states are marked by a double circle.State note in F have a single circle

TRANSITION TABLE

A transition table is a conventional, tabular representation of a function like ( that takes two arguments and returns a state . The rows of the table correspond to the state, and the columns correspond to the input a is the state ((q,a) For example

(/(

a

b

(q0

q1

q2

q1

q2

q0

*q2

q2

q2

q0 is the starting state and q2 is the final state

Q={q0,q1,q2}

F={q2}

((q0,a)=q1 ((q0,b)=q2

((q1,a)=q2 ((q1,b)=q0

((q2,a)=q2 ((q2,b)=q2

b

q0 a q1

b a

q2

b,a

So clearly transition diagram can be find from transition table and vice versa is also true.

The language of a DFA

It have been explained informally that DFA defines a language :The set of all string that results in a sequence of state transition from start state to an acceptance state.

Now we can define the language of a DFA M=(Q,(,(,q0,F).This language is denoted by L(M) ,and defined by

L(M)={w/(^(q0,w)is in F}

(^ extended transition function explained afterwords

That is the language of M is the set of strings(w) that take the start q0 to one of the acceptance states. If L is L(M) for some deterministic finite automata ,then we say L is a regular language

Extended transition function to strings

In terms of transition diagram, the language of a DFA is the set of labels along the path that lead from the start to any accepting state. Now we need to make the notation of the language of FA precise. To do so we define extended transition function that describes what happens when we start in any state and follow any sequence of inputs. If ( is our transition function ,the extended function constructed from ( will be called (^.

The extended transition function is the function that takes a state q and a string w and returns a state P,the state that automation reaches when starting in state q and processing the sequence of inputs w. We define (^ by induction on the length of the input string as follows:

BASIS: (^(q,ε)=q.That is ,if we are in state q and read no input ,then we are still in state q.

INDUCTION:suppose w is a strings of the form xa,that is a is the last symbol of w and x is the substring of w, consisting of all except the last symbol ‘a’.For eample

w=1101 is broken into x=110 and a =1 then (^(q,w)= (((^(q,x),a)

i.e. to compute (^(q,w), fist compute (^(q,x),the state that the automation is in after processing all but the last symbol of w. Suppose this state is p’;that is (^(q,x)=p’.then (^(q,w) is what we get by making a transition from state p’ on input a, the last symbol of w

(^(q,w)= ((p’,a)=p

Example ------------refer note:

NONDETERMINISM

Nondeterminism means a choice of moves for an automaton.Rather than prescribing a unique move in each situation , we allow set of possible moves. A nondeterministic finite automation(NFA/NDFA) has the power to be in several state at once .Each NFA accepts a language that is also accepted by some DFA .that is the NFA’s accepts exactly the regular language ,just as DFA’s do.

Definition

Let M be NFA then M is defined as M=(q,(,(, qo,F)

Where,

Q : is a non empty finite set of states presents in the finite control.(q0,q1,q2,….)

( : is a non empty finite set of input symbols which can b passed to the finite state machine(a,b,c,d,e,…)

q0 : is a starting state ,one of the state in Q q0(Q

F : is a non empty set of final states or accepting states,set of final states belongs to Q F(Q

( : is a function called transition function that two arguments a state and a input symbol, it returns a single state.

Transition function maps,

Q((u{ε} ->2^Q

So in nondeterministic accepter the range of ( is in the power set 2^q, so its value is not a single element of Q,but a subset of it.this subset defines the set of possible state that can be reached by transition.

Let ‘q’ is the sate of Q and a (( then, we can transmit from a state q on same input a to different states q0,q1,q2….qn in Q

Examples :design NFA :refer notebook

EXTENDED TRANSITION FUNCTION FOR NFA

Similar to DFA’s ,we need to extend the transition function ( of an NFA to a function (^ that takes a state and string and return the set of states.

BASIS:

(^(q,ε)={q}.That is without reading any input symbols, we are only in the same state.

INDUCTION:

Suppose w is of the form w=xa,where a is the last symbol and x is the substring containing rest of w.let us suppose that

(^(q,x)={p1,p2,p3…pk},

Let (i=1 to k ((pi,a)={r1,r2,r3…rm}

Then (^(q,w)={r1,r2,r3…rm}

Less formally we compute (^(q,w) by first computing (^(q,x) ,and by then following any transition from any of these states that is labeled a.

Examples refer note:::::::

THE LANGUAGE OF NFA

NFA accepts a string w if it is possible to make any sequence of choice of next state while reading the characters of w, and go from the start state to any accepting state.

If M is a NFA

M=(Q,(, (,q0,F) then

L(M)={w/(^(q0,w)(F !=(} is the language of M i.e. NFA.L(M) is the set of strings w in (* such that (^(q0,w) contains at least one accepting state.

TRANSFORMATION OF NFA TO DFA

For every non deterministic finite automata there exist an equivalent deterministic finite automata. the equivalence is defined in terms of language acceptance. Since a NFA is nothing but a finite automata in which zero,one or more transition on an input symbol is permitted, we can always construct a finite automata which will simulate all the moves of NFA on a particular input symbol in parallel ,then get a finite automata in which there will be exactly one transition on every input symbol, hence it will be DFA equivalent to NFA.

Since the DFA equivalent of NFA is to simulate the moves in parallel state of a DFA will be combination of one or more states of NFA,hence every state of a DFA will be represented by some subset of set of states of NFA ,and therefore the transformation of NFA to DFA is normally called a subset construction.

Examples refer note::

NFA WITH ε-TRANSITIONS

If a FA is modified to permit transition without input symbols,along with zero,one or more transition on input symbols,then we get a NFA with ε transitions,because the transition made without symbols are called as ε-transitions.

0 1 0

Start ε ε

q0 q1 q2

This is a NFA with ε transition because it is possible to make transition from state q0 to q1 without consuming any of the input symbols. Being finite automata, NFA with ε transitions will also be denoted as five tuple.

M=(Q,(,(,q0,F) where Q ,(,q0,F are having usual meaning ,and transition function ( defines a mapping from

Q((u{ε} ->2^Q

ACCEPTANCE OF A STRING BY NFA WITH ε-TRANSITIONS

A string w in (* will be accepted by NFA with ε ,which starts in an initial state ,and ends in one of the final states. Since this path may formed by ε transition as well non ε –transitions to fin out whether w is accepted or not by the NFA with ε moves, we require to defined a function ε –closure (q),where q is a state of the automata.

The function ε closure (q) is defined as follows:

ε-closure (q) =set of all those states of the automata (NFA with ε –transitions )which can be reached from q on a path labeled by ε i.e. without consuming any input symbol .

ε-closure (q0) = {q0, q1, q2}

ε-closure (q1) = {q1, q2}

ε-closure (q2) = {q2}

CONVERSION OF NFA WITH ε TRANSITION TO NFA WITHOUT ε TRANSITION

EXAMPLE REFER NOTE:::

CONVERSION OF NFA WITH ε TRANSITION TO NFA DFA

EXAMPLE REFER NOTE:::

MINIMIZATION OF DFA

Any DFA defines a unique language, but the converse is not true; for a given Language, there may be many DFA’s that accepts it. To under stand the minimization first of all one should be very clear about the dead state, inaccessible state, so let us discuss them first;

Dead State: All those non final states which transit to itself for all input symbols in (,are called Dead state

Inaccessible States: All those states which can never reached from initial state are called Inaccessible states

Indistinguishable States: Two states q and r of DFA are called indistinguishable if

(^(q,w)(F =>(^(r,w)(F

And (^(q,w)!(F =>(^(r,w)!(F

Distinguishable States: Two states q1 and q2 of DFA are called Distinguishable if

(^ (q1, w)(F =>(^(r,w)!(F

And (^ (q, w)!(F =>(^(r, w) (F

MINIMIZATIONS OF DFA EXAMPLES REFER NOTE:

REGULAR EXPRESSIONS

The language accepted by FA are regular languages and these languages are easily described by simple expressions called regular expressions. We have some algebraic notations to represent the regular expressions.

Regular expressions are means to represent certain sets of strings in some algebraic manner and regular expressions describe the language accepted by FA

OPERATORS OF REGULAR EXPRESSION

If ( is an alphabet then regular expression(s) over this can be described by following rules.

1. Any symbol from ( ,ε,( are regular expressions

2. If r1 and r2 are two regular expressions then union of these represented as r1(r2 or r1+r2 is also a regular expression

Ex: If r1= {001, 10,111} and r2= {ε, 001}

r1(r2= {ε, 10,001,111}

i.e. the Union of two languages r1 and r2 is the set of string that are in either r1 or r2 or both.

3. If r1 and r2 are two regular expressions then concatenation of these represented as r1r2 is also a regular expression

Ex: If r1= {001, 10,111} and r2= {ε, 001}

Then r1r2= {001,10,111,001001,10001,111001}

i.e. the concatenation of two languages r1 and r2 is the set of string that can be formed by taking any string r1 and concatenating it with any strings in r2.we denote concatenation of languages with a dot.

R1.r2 means r1 followed by r2.

4. The kleene closure (or iterative or reflexive transitive closure) of a regular expression r is denoted by r* is also a regularexpresion.

Ex: if r1= {1}

Then r* is {ε, 1, 11, 111,…}

I.e. the closure of a language is the set of those strings that can be formed by taking any number of strings from r, possibly with repetitions (that is same string repeated more than once) and concatenating all of them.

5. The positive closure of a regular expression r is denoted by r+ is also a regular expression.

Ex: if r1= {1}

Then r* is {1, 11, 111,}

I.e. the positive closure of a language is the set of those strings that can be formed by taking any number of strings from r, possibly with repetitions (that is same string repeated more than once) and concatenating all of them. Excluding null string

I.e. r+=r*-ε

r+=r.r*

6. If r is regular expression, then (r), a parenthesized r, is also a regular expression.

7. The regular expression obtained by applying rules 1 to 6 once or more than once are also regular expression.

Example if r = {a, b} then

(a) a is regular expression (rule 1)

(b) a+b is regular expression (rule 2)

(c) ab is regular expression (rule 3)

(d) {ε, a, b, aa, bb, ab, ba….} i.e. r* is regular expression (rule 4)

(e) { a,b,aa,bb,ab,ba….}ie r+ is regular expression (rule 5)

(f) ab+a* is regular expression (rule 7)

DEFINITION OF REGULAR EXPRESSION

The set of regular expression is defined by the following rules:

1. Every letter of ( can be made into a regular expression ,null string ,ε itself is a regular expression

2. if r1 and r2 are regular expression, then

(i) ( r ) (ii) r1r2

( iii) r1+r2 (iv) r1* ,r2*

(v) r1+,r2+ are also regular expression

3. Nothing else is regular expression

Find the regular expression for the following

1. A language consists of all words over {a,b} and ending in a

A language consists of all words over {a,b} =(a+b)*

Ending in a i.e. last symbol is = a

so, language consists of all words over {a,b} and ending in a ---(=(a+b)*a

2. A language consists of all words over {a,b} and ending in a

(a+b)*aa

3. A language consists of all words over {a,b} and start with a and end in b

a (a+b)*b

4. A language consists of all words over {a,b} and substring aa

(a+b)*aa,aa(a+b)*,(a+b)*aa(a+b)*

5. A language consists of all words over {a,b} and ending in abb

(a+b)*abb

6.write the regular expression for the set of strings of an equal no of 0’s and 1’s such that in every prefix no of 0’s differs from no of 1’s by at most 1.

Ex: 1010101010, 10101010, 0110, 1001,….

r=(01+10)*

ie 01+10 means {01,10}

(01+10)^0={ε}

(01+10)^1 ={01,10}

(01+10)^2={0101,1010,0110,1001}

.

.

.

(01+10)*

7. write the regular expression for the set of strings of 0’s and 1’s , whose 10th symbol from right end is 1.

(0+1)*1(0+1)^9

8.write the regular expression over the alphabet{a,b} for the set of strings with even no of a’s followed by odd no of b’s

r=(aa)*(bb)*b

(aa)^0(bb)^0b={ε}.{ ε}b={b} ie even no of a and odd no of b

(aa)^1(bb)^1b={aa}.{bb}b={aabbb} ie even no of a and odd no of b

(aa)^2(bb)^2b={aaaa}.{bbbb}b={aaaabbbbb} ie even no of a and odd no of b

.

.

.

(aa)*(bb)*b

9.wite regular expression for alphabet a,b,c containing atleast one a atleast one b

(a+b+c)*a(a+b+c)*b (a+b+c)*+ (a+b+c)*b (a+b+c)*a(a+b+c)*

MORE EXAMPLES REFER TEXT::::

REGULAR SET

A set represented by regular expression is called regular set.

(={a,b}

SET REGULAR EXPRESSION

{ } (

{a} a

{a,b} a+b

{ε,a,aa,aaa,…} a*

{a,aa,aaa,…} a+

All the words over {a,b} (a+b)*

HIERARCHY OF EVALUATION OF REGULAR EXPRESSION

1. Parenthesis

2. Kleen closure

3. Concatenation

4. Union

1.Consider the regular expression (a+b)*abb & describe the all words represented by this

(a+b)*={all words over {a,b}}

i.e. {ε,a,b,ab,ba,aa,bb,aaa,bbb,aba,bab,….}

(a+b)*abb={all words over {a,b}abb}

i.e. {abb,aabb,babb,ababb,baabb,aaabb,bbabb,aaaabb,bbbabb,abaabb,bababb,….}

i.e. All words over {a,b} ending in abb

2. Consider the regular expression (a*+b*)*& describe the all words represented by this

a* ={ε,a,aa,aaa,…}

b* ={ε,b,bb,bbb,…}

(a*+b*) ={ ε,a,aa,aaa,b,bb,bbb,…..}

(a*+b*)* ={ ε,a,aa,aaa,b,bb,bbb,ab,ba,abb,bba,abbb,….}

i.e. all words over {a,b}

i.e. (a*+b*)* =(a+b)*

3. Describe following regular set by regular expression

{101}=101

{abba}=abba

{01,10}=01+10

{ε,ab}= ε+ab

{abb,a,b,bba}=abb+a+b+bba

{ ε ,0,00,000,0000,….. }=0*

{1,11,111,…}=1+

4.The set of strings of 0’s and 1’s beginning with 1 & not have two consecutive 0’s

(1+10)* or {1,10}+

(1+10)={1,10}

(1+10)*={ε,1,10,11,1010,110,101,….} ie the set of strings of 0’s and 1’s beginning with 1 & not have two consecutive 0’s

{1,10}^+={ 1,10,11,1010,110,101,….} ie the set of strings of 0’s and 1’s beginning with 1 & not have two consecutive 0’s

IDENTITY RULES FOR REGULAR EXPRESSION [proof: text ->adesh k.pandey]

( + R = R

(R = R( = (

(R = R( = R

RR*=R*

RR+=R+R=R

(R*)R=R*

(*=(

(+RR*=R* =(+R*R =(+R*

(*= (

R + R = R

R* R* =R*

(PQ)*P=P(QP)*

(P+Q)*=(P*Q*)*=(P*+Q*)*

(P+Q)R=PR+QR

R(P+Q)=RP+RQ

ARDENS THEOREM

Let p and q be two regular expression over ( .if p does not contain ε ,then the following equation in R=Q+RP has a unique solution given by R=QP*

R=Q+RP

R=Q+(QP*)P

R=Q((+P*P)

R=(QP*) [using ((+P*P)=p*]

This means that R=QP* is a solution of R=Q+RP

Example

1. prove (1+00*1)+(1+00*1)(0+10*1)*(0+10*1)=0*1(0+10*1)*

Solution: LHS

(1+00*1)(ε+(0+10*1)*(0+10*1))

Using rule (P+Q)R=PR+QR

=(1+00*)(0+10*1)* using rule ε+RR*=R*

=( ε+00*)1(0+10*1)* using rule (P+Q)R=PR+QR

=0*1(0+10*1)* using rule ε+RR*=R*

=RHS

2. prove R=ε+1*(011)*(1*(011)*)* describe (1+011)*

SOLN:

Let,P=1*(011)*

R= ε+PP*

R=P* (using ε+PP* =P*)

R= (1*(011)* )*

Let p1= 1 ,p2= (011)

R=(p1*p2*)*

R= (p1+p2)* (using (p1*p2*)*= (p1+p2)* )

R=(1+011)*

3.prove (1+00*1)+(1+00*1)(0+10*1)*(0+10*1)=0*1(0+10*1)*

(1+00*1)(ε+(0+10*1)*(0+10*1)

=(1+00*1)(0+10*1)*

=1(ε+00*)(0+10*1)*

=0*1(0+10*1)*

=RHS

MORE EXAMPLES REFER TEXT ::::::

EQUIVALANCE OF REULAR EXPRESSION AND FINITE AUTOMATA

Language accepted by the finite automata is the language, which is expressed in the form of regular expression

To prove that for every regular expression there is an equivalent NFA with ε-transitions

We have to proceed the following

The following diagram shows the relation expressions

NFA

DFA

ε-NFA

RE

We must first prove that regular expression and finite automata are equivalent ie that they denote the same set of languages Our proof consists of showing that

Theorem (i) for every regular expression there is a nondeterministic finite automaton with ε transitions

Theorem (ii) for every deterministic finite automata ,there is a regular expression

We have previously seen how to construct a deterministic finite automaton from a nondeterministic one and how to remove ε-transitions.Henc,e once the proof has been made ,it will be possible to go from any form of finite automaton to a regular expression and vice-versa.

Theorem ( i) for every re there is an equivalent finite automata or for every regular expression there is a nondeterministic finite automaton with ε transitions that accepts L( r)

Proof: we show by induction on the no of operators in the regular expression r that there is an 1 NFA M with ε-transitions, having one final state and no transitions out of this final state ,such that

L(M)=L( r ).

Basis zero operator: the expression r must be ε, ( or a for some a in (.the NFA’s are given below which satisfy this conditions

( a) r = ε fig(2.9)

( b) r = ( q0

fig(2.10)

( c ) r = a q0 a qf fig(2.11)

Induction (one or more operators):

Assume that theorem is true for regular expression with fewer than I operators, i>=1.

Let r have i operators. There are three cases depending on the form of r.

CASE 1:

r=r1+r2

Here both r1 and r2 must have fewer than I operators .thus there are NFA’s M1=(Q1,(1,(1,q1,{f1}) and M2=( Q2,(2,(2,q2,{f2}) with L(M1)=L(r1) and L(M2)=L(r2)

Since we may rename states of an NFA at which we assume Q1 and Q2 are disjoint.

Construct M=(Q1(Q2(q0(fo, (1((2, (,q0,{f0})

Where ( is defined by

( i) ((q0,ε)={q1,q2}

( ii) ((q,a)= (1(q,a) for q in Q1-{f1} and a in (1( ε

(iii) ((q,a)= (2(q,a) for q in Q2-{f2} and a in (2( ε

( iv) (1(f1, ε)= (2(f2, ε)={f0}

Recall by the inductive hypothesis that there are no transitions out of f1 or f2 in M1 or M2 . Thus all the moves of M1 and M2 are present in M

ε

ε q1 M1 f1 fig(2.12)

q0

Start ε ε

q2 M2 f2

Any transition path in the transition diagram of M from q0 to f0 must begin by going to either q1 or q2 on .if the path goes to q1 it may follow any path in M1 to f1 and then go to fo on ε .similarly paths that begin by going to q2 may follow any path in M2 to f2 and then go to fo on ε .

CASE 2:

r=r1r2 let M1 and M2 in as in case 1 and M=(Q1(Q2,1((2, (,{q1}{f2});

where ( is given by,

( i) ((q,a)= ((q,a) for q in Q1-{f1} and in (1({ ε}

(ii) ((f1, ε)={q2}

(iii) ((q,a)= (2(q,a) for q in Q2 and a in (2({ ε}

The construction of M is :

Startq1 M1 f1 ε q2 M2 f2

CASE 3:

r=r1*

Let M=(Q1,(1,(1,q1,{f1}) and L(M1)=r1.

Construct M=(Q1({q0,f0},(1,(,q0,{f0}) where ( is given by,

((q0,ε)= ((f1,ε)={q1,f0} ε

((q,a)= (1(q,a) for q in Q1 –{f1} and a in (1({ ε}. ε

Construction of M is :

start

q0 ε q1 M1 f1 ε f0

EXAMPLE :REFER TEXT

Theorem ( ii ) for every deterministic finite automata ,there is a regular expression OR if L is accepted by a DFA ,then L is denoted by a regular expression

Proof:

There are certain assumptions which are made regarding the transition system:

1.The transition diagram should not have ε-transitions.

2.It must have only a single initial state .

3.It vertices are q1…qn

4.qi is final state

5. wij denotes the regular expression representing the set of labels of edges from qi to qj.

The set of equations for q1…qn

q1=q1w11+q2w21+…qnwn1+ε …………………(1)

(since q1 is the initial state)

q2=q1w12+q2w22+…qnwn2 …………………(2)

.

.

.

.

qn=q1w1n+q2w2n+…qnwnn …………………(n)

Solve these equation for qi in terms of wij’s and it will be required regular expression .One thing should be noted that we add ε(null string ) in the equation starts with starting state q1 and we solve equation to find out qi (final state) in terms of wij’s ,it is one of the regular expression for given DFA

EXAMPLE REFER TEXT:

THE PUMPING LEMMA FOR REGULAR LANGUAGES

Pumping lemma is a powerful tool for proving certain language non regular .it’s also useful in the development of algorithm to answer certain questions concerning ,finite automata ,such as weather the language accepted by given FA is finite or infinite.

STATEMENT: 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 |w| >=n,we can break w into three substrings,w=xyz,such that:

(1) y!=ε

(2)| xy |<=n

(3) for all i>=0,the string xy^iz is also in L.

Proof:

Suppose L is regular.then L=L(M) for some DFA M.suppose M has n states.now consider any string w of length n or more,say=w=a1a2a3..am where m>=n and each ai is an input symbol,for i=0,1,2….m define state pi to be (^(q0,a1,a2..ai)where ( is transition function of M , q0 is the start state of M that is pi is the state ,M is in after reading the first i symbol of w.

We can break w =xyz as follows

1. x=a1a2..ai

2.y=ai+1 ai+2..aj

3.z=aj+1aj+2..am

That is x takes us to pi once;y takes us from pi back to pi,and z is balance of w.

Y=ai+1…aj

x=a1..ai z=aj+1..am pn

P0 ----------( p1 --------------(

Note that x may be empty ,in the case that i=0;also z may be empty if j=n=m; However y cannot be empty , since i is strictly less than j.

Now consider what happens if the automation M receives xy^iz for any i>=0;

If i=0, then automatio M goes from the start state q0 to pi on input x.since pi also pj,it must be that M goes from pi to the accepting state in the abve fig on input z.thus it accepts z.

If i>0,then M goes from p0 to pi on input string x,circles from pi to pi , i times on input yi,and then goes to the accepting state on input z. thus for any i>=0,xy^iz is also accepted by M;that is xy^iz is in L.

We can also understand these transactions as follows:

For i=0

(^(p0,x)= (^(pi,x)=p;

(^(pi,z)=pn

For i>0

(^(q0,x)= (^(p0,x)=pi;

(^(pi,y)= pi;

EXAMPLE REFER TEXT ::::

APPLICATION OF AUTOMATA

REFER NOTE::::::

IMPORTANAT:::::::::: REFER NOTE AND TEXT

EQUIVALANCE OF NFA WITHOUT ε & NFA WITH ε

EQUIVALANCE OF NFA & DFA

Extra Reading is strictly recommended

Thank you,

REMYA SIVAN

Dept. CSE

MCT

Qf

0

((q,a)

((q,a)

1 1

q0

qf

F0

- 1 -