Sie sind auf Seite 1von 18

TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success)

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA


The Central Concept of Automata
PERSONAL REMARK :
,

We will often encounter the terms like alphabet (a set of symbols),


strings (a list of symbols from an alphabet), and language (a set of
strings from the same alphabet).
1. Alphabet: An alphabet is a finite, non-empty set of symbols.
Conventionally, we use the symbol for an alphabet. Common alphabets
are like
(i) 0,1 , the binary alphabet
(ii) a,b,c,......,z , the set of all lower case
letters
(iii) The set of ASCII character.
2. Strings: A string (sometimes called a word) is a finite sequence of
symbols chosen from some alphabet. For example, 001001 is a string
from the binary alphabet 0,1.
The Empty String: The empty string is the string with zero occurrences
of the symbols. This string is denoted by either or A.
Length of a String: It is the number of positions for symbols in the
string. For example the string 01101 has length 5, we often say that the
length of a string is the number of symbols in the string, but this is not
strictly correct. There are only two symbols, 0 and 1 in the string 01101,
but there are five positions for symbols, and its length is 5.
,

The standard notation of the length of a string is


Thus 01101 5, 1 1 etc.,
,

Power of an alphabet: If is an alphabet, we can express the set of all


strings of a certain length from this alphabet by using an exponential
notation. We define K to be the set for all strings of length K, each of
whose symbols are in .
Example:
03,1 , then 1 0,1 , 2 00, 01,10,11 ,
000, 001, 010, 011,100,101,110, 111 , and so on.
Note that

= set of strings of length 0 = and 1 are different,

first one is alphabet and second one is the set of all string of length 1.
*The set of all strings over an alphabet is conventionally denoted by

* for instance if = 0,1 then * = ,0,1,00,01,10,11,000,......


In other words

* 0 1 2 .........
*Sometimes, we wish to exclude the empty string from the set of all
LUCKNOW
0522-6563566

LUCK NOW

GORAKHPUR
9919526958

ALLAHABAD
AGRA
9919751941
9451056682

PATNA
9919751941

NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES

TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success)

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA


PERSONAL REMARK :
strings from alphabet is denoted by . Thus denotes the set

of all strings whose length is at least one.


So,

1 2 3 ......... or
*
Operation on Strings:
Concatenation: Let x and y be two strings in * . Let us form a
new string z by placing y after x, i.e.frorm z = xy. The string z is said to
be obtained by concatenation of x and y.
,

If x is a string composed of i symbols and y is the string composed of j


symbols then xy is a string of length i + j.

Concatenation on a set * is associative since for each x,y and z in

* , then x yz = xy z
* has left and right cancellation property. For x, y, z in * .
zx = zy implies x = y (left cancellation)
xz = yz implies x = y (right cancellation)

For xy in * , we have

xy x y where xy , x , y denotes the length of the string


xy, x and y respectively.
Transpose Operation: The reverse of a string is obtained by writing
the symbols in reverse order, if is a string a1 , a 2 ...... a n then
reverse of is R an, ...... a2a1
Palindrome: A palindrome is a string which is the same whether written
forward or backward.
Example: malayalam.
A palindrome of even length can be obtained by concatenating a string
with its transpose or reverse (i.e if is a string then R is a palindrome).
Prefix and Suffix of a string:
If uv
Then the sub-string u and v are said to be a prefix and suffix of ,
respectively.
3. Languages: A set of strings, all of which are chosen from some

* , where is is a particular alphabet, is called a language. If is an


alphabet, and L * , then L is language over .
Example 1: The set of all strings of 0s and 1s with an equal number
LUCKNOW
0522-6563566

LUCK NOW

GORAKHPUR
9919526958

ALLAHABAD
AGRA
9919751941
9451056682

PATNA
9919751941

NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES

TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success)

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA


each.
,01,10,0011,0101,1001,1100......
Example 2: The set of binary numbers whose value is prime.

PERSONAL REMARK :

10,11,101,111,1011,......

*
Example 3: is a language over any alphabet .
,

Example 4: , the empty language, is a language over any alphabet.


Since languages are sets, the union, intersection and difference of two
languages is defined. The complement of a language is defined with

*
respect to ; that is the complement of L is: L * L
,

The reverse of a language is the set of all string reversals, that is


,

LR R ; L
The concatenation of languages L1 and L2 are obtained by concatenating
any element of L1 with any element of L2 , i.e.
L1L 2 12 : 1 L1 and 2 L 2

We define L* as L concatenated with itself n items n 0 , with special


,

cases
L0

Finally, we define the star closure of a language as


L* L0 L1 L2 ........

and positive closure as


L L1 L2 L3 ........

Finite Automata
Automata: An automata is an abstract model of a digital computer.
Every automata includes some essential features. It has a mechanism
for reading input. It is assumed that the input is a string over a given
alphabet, written on an input file, which the automaton can read but not
change. The input file is divided into cells, which the automaton can read
but not change. The input file is divided into cells, each of which holds
one symbol. The input mechanism can read the input file left to right, one
symbol at a time. The input mechanism can also detect the end of the
input string (by sensing the end-of-file condition). The automaton can
produce output of some form. It may have a temporary storage device,
consisting of an unlimited number of cells, each capable of holding a
single symbol from an alphabet (not necessarily the same one as the
input alphabet). The automaton can read and change the contents of the
storage cells. Finally the automaton has control unit which can be in any
of the finite number of internal states, and which can change its state in
some specified.

LUCKNOW
0522-6563566

LUCK NOW

GORAKHPUR
9919526958

ALLAHABAD
AGRA
9919751941
9451056682

PATNA
9919751941

NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES

TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success)

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA


PERSONAL REMARK :

Input file

Storage

Control Unit

An automaton is assumed to operate in a discrete time frame. At any


time, the control unit is in some internal state, and the input mechanism is
scanning a particular symbol on the input file. The internal state of the
control unit at the next time step is determined by the transition function.
This transition function gives the next state in terms of current state, the
current input symbol, and the information currently in the temporary
storage.
,

The term configuration will be used to refer to a particular state of the


control unit, input file, and temporary storage. The transition of the
automata from one configuration to the another configuration will be called
as a move.
DFA (Deterministic Finite Automata) :
,

Analytically a deterministic finite automaton can be represented by a 5


tuple. Q, , , q 0 , F where
(i) Q is a finite non-empty set of states.
(ii) is a finite non-empty set of symbol, called
input alphabet.
(iii) is a transition function which takes as argument states and an
input symbol and returns a state. is called transit function.
(iv) q 0 Q is called the initial state
(v) F Q is called the set of final state.
,

The term deterministic refer to the fact that on each input symbol
there is one and only one state to which the automaton can transition
from its current state.
,

It is called finite, since it has finite number of states.


Notation for DFA:
,

There a two preferred notation for describing automata.


1. Transition diagram: To visualize and represent finite automata, we
use a graph in which each vertex (or node) represents a state and directed
LUCKNOW
0522-6563566

LUCK NOW

GORAKHPUR
9919526958

ALLAHABAD
AGRA
9919751941
9451056682

PATNA
9919751941

NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES

TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success)

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA

edge indicate the transition of a state and the edges are labeled with
input/output symbols. For every transition rule (q,i a) qj the graph has
an edge q i , q j labeled a di rected from q i to q j and the edge labeled
with a.
In the transition diagram there is an arrow at start vertex q0. This arrow
does not originate at any node.
In transition diagram the nodes corresponding to the final state are marked
by a double circle. States not in F have a single circle.
,

0,1

0
0

PERSONAL REMARK :

q1

q2

The transition graph in Figure represent the DFA


M q 0 ,q1 , q 2 0,1 , q 0 , q 2

Where is given by
(q 0 , 0) q1 , (q1 ,0) q1 (q 2 ,0) q 2
(q 0 ,1) q 0 , (q1 ,1) q 2 (q 2 ,1) q 2
2. Transition Table: A transition table is a conventional, tabular
representation of a function that takes two arguments and returns a value.
The row of the table correspond to the states and the columns, correspond
to the inputs. The transition table of the corresponding transition graph of
the above is given below.

States/

q0

q1

q0

q1

q1

q2

q2

q2

q2

Extended Transition Function:


,

The extended transition function * maps Q * into Q i.e. maps a state


and as string of input symbols (including the empty string) into a state.
,

We can informally define the language accepted by a DFA as the set of


all strings that result in a sequence of state transition from the start state
to the final state.
,

The extended transition function describes what happens when we start


in any state and follow any sequence of inputs. If is our transition
function, then the extended transition function constructed from will be
called or * .
,

The extended transition function is a function that takes a state q and a


string and returns a state p the state that the automaton reaches
LUCKNOW
0522-6563566

LUCK NOW

GORAKHPUR
9919526958

ALLAHABAD
AGRA
9919751941
9451056682

PATNA
9919751941

NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES

TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success)

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA


when starts in state q and process the sequence of inputs .

PERSONAL REMARK :

Property 1:
q, q in a finite automation. This means the state
of the system can be change only by an input symbol.
For all string and input symbols a

Property 2:

q, a q , a ,

q, a q, , a
This property gives the state after the automaton consumes or reads the
first symbol of a string a and the state after the automaton consumes
a prefix of the string a .

Language accepted by DFA: The language accepted by a DFA


M Q, , , q 0 , F is the set of all strings on accepted by M. In formal

notation,
L M * ; q 0 F

Example 1:

a,b
q1

b
,

a,b

q2

The automaton in the above figure remains in state q 0 (initial state) until
the first b is encountered. If this is the last symbol of the input, then the
string is accepted. If not, the DFA goes into state q 2 , from which it cantt
escape. Such a state is called trap state. Thus the automaton accepts all
string consisting of an arbitrary number of as followed by a single b. all
other strings are rejected.
Problem: Find a deterministic finite accepter that recognize the set of
all strings on a , b starting with the prefix a b.
Solution: If the first symbol is an a and the second is a b, the automation
goes into a final state, where it will stay since the rest of the input does
not matter on the other hand, if the first symbol is not an a or the second
input is not a b the automaton enters the non-final trap state.
a,b
a
b

q2

q1
a
q2
a,b

Regular language:
A language L is called regular if and only if there exists some deterministic
LUCKNOW
0522-6563566

LUCK NOW

GORAKHPUR
9919526958

ALLAHABAD
AGRA
9919751941
9451056682

PATNA
9919751941

NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES

TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success)

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA


finite accepter M such that
L = L(M)

PERSONAL REMARK :

Problem: Show that the language L a a : a , b* is a regular..

a
b

a,b
,

The DFA in the figure shown on the left accept the language
L a a : t a , b* So, L is regular..
Problem: For a , b , construct DFAs that accept the sets of
(a) all strings with exactly one a
(b) all strings with atleast one a.
(c) all string no more than three as
(d) all string with at least one a and exactly two bs.
Solution:

b
(a)
,

a,b
a

q1

q2

The DFA is describe by


M q 0 , q1 , q 2 , a , b, , q 0 , q1

Where is given by
q 0 , a q1 , q 0 , b q 0 , q1 , a q 2
q1 , b q1 , q 2 , a q 2 , q 2 , b q 2

a,b

(b)
,

q2

The DFA, M is given by M q 0 , q1 , a , b, , q 0 , q1


Where is given by
q 0 , a q1 , q1 , a q1
q 0 , b q 0 , q1 , b q1

b
(c)
LUCKNOW
0522-6563566

LUCK NOW

q0

b
a

GORAKHPUR
9919526958

q1

q2

b
a

ALLAHABAD
AGRA
9919751941
9451056682

a,b
a

PATNA
9919751941

NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES

TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success)

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA


(d)

PERSONAL REMARK :
a

q5

q0

a,b

q1

q6

a
b

q2

Problem: Construct a DFA to accept the language L : has both


an even number of 0s and odd number of 1s
Solution: The states in the DFA will remember whether the number of
0s seen so far is even or odd and also remember whether the numbers
of 1s seen so far is even or odd. There are thus four states, which can
be given the following interpretation.
qEE : both the number of 0s and 1s seen so far are even
qOE : number of 0s seen so far is odd but number of 1s seen so far is
even.
both the number of 0s and 1s seen so far are odd.
q00 :
qE0 :
number of 0s seen so far is even but number of 1s seen is odd.
It is clear that qEE is the initial state, because before reading any inputs,
the number of 0s and 1s seen are both zero (i.e. even).
,

When the automation is in state qEE, it makes a transition to state qOE on


input symbol O and makes a transition to state qEO when it reads the
input symbol 1. Similarly we can find transition for other states also
clearly qEO would be the final state.

qEE

qE0

1
0

0
q0E

0
1

0
q00

1
Problem: Construct a DFA for the language L a n : a 4
Solution:

Note, q4 is the only non-final state.


Problem: Construct a DFA for the following language.
L a , b * : n a mod 3 0
LUCKNOW
0522-6563566

LUCK NOW

GORAKHPUR
9919526958

ALLAHABAD
AGRA
9919751941
9451056682

PATNA
9919751941

NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES

TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success)

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA


Solution: n a mod 3 could be 0, 1, or 2. so we need three states to
remember these three remainder. Let the states be q 0, q 1 and q 2
corresponding to these remainders. Now the DFA looks like

PERSONAL REMARK :

b
q2

q1

Problem: Construct a DFA for the language


L a , b* : mod 3 1
Solution:
q1

q2

Problem: Construct a DFA for the following language.


L a , b* : n a mod 3 n b mod 3
Solution: Let
i n a mod 3 , and
j n a mod 3 , for a particular string .
Now both i, j could be 0,1, 2
So there are 9 possible combinations of i and j . Let qij denote a state for
a particular combination of values i and j , so the states are q00, q01, q02
q10 q11 q12 q20 q21 q22. Final states will be all those qijs for which i > j.
Now we can draw the transition diagram.

LUCKNOW
0522-6563566

LUCK NOW

GORAKHPUR
9919526958

ALLAHABAD
AGRA
9919751941
9451056682

PATNA
9919751941

NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES

TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success)

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA


PERSONAL REMARK :

Problem: Construct a DFA that will accept all those binary strings
whose decimal equivalent is divisible by 5.
Solution: We know that (from mathematics of mod operation)
If x mod n = p, then
2x mod n = 2p mod n
and 2x + 1 mod n 2p 1 mod n.
,

Now assume that the partial string read by the DFA has decimal equivalent
x. If next bit 0, the string read
so far will have a decimal equivalent 2x and it 2x 1 if the next bit is 1.
x mod 5 could be any values between 0 and 4. so we need 5 states to
remember these values. Let q0, q1, q2, q3 and q4 denotes the states
corresponding to remainders 0, 1, 2, 3 and 4 respectively. Draw the
transition table first.
1

0
q0

q2

q1

q4

q3

LUCKNOW
0522-6563566

LUCK NOW

States

q0

q0

q1

q1

q2

q3

q2

q4

q0

q3

q1

q2

q4

q3

q4

GORAKHPUR
9919526958

ALLAHABAD
AGRA
9919751941
9451056682

PATNA
9919751941

NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES

10

TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success)

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA


NFA (Non-deterministic Finite Automata):
A non-deterministic finite automata (NFA) has the power to be in several
states at a time. Nondeterministic is a powerful, but at first unusual idea.
We normally think of computers as a completely
deterministic.
For example consider the figure on the LHS. If the automation is in state
q0 and the input symbol is 0, the next state will be either q0 or q1. Thus
some moves of the machine can't be uniquely determined by the input
symbol and the present state. Such machine are called non-deterministic
automata.
,

PERSONAL REMARK :

1
0

q1
1

1
q2
Definition (NFA):
,

A non-deterministics finite automata (NFA) is a 5 tuple Q, , , q 0 , F


where
(i) Q is a finite nonempty set of states.
(ii) is a finite non-empty set of symbols called inputs.
(iii) is the transition function, mapping from Q into 2Q , which
is the power set Q, i.e. the set of all possible subset of Q.
i.e. Q 2 Q
(iv) q 0 Q is the initial state.
(v) F Q in the set of final states or accepting state.
,

Note that the difference between deterministic and non-deterministic


automata is only in . For deterministic automata (DFA), the outcome of
is a state, i.e. an element of Q. For non-deterministic automata the outcome
is a subset of Q.
Definition: Acceptance of NFA:
,

A string W is accepted by NFA i f , q 0 , W contains some final


state. A string * is rejected. (that is not accepted) only if there is no
,
,

possible sequence of moves by which a final state can be reached.


Like DFA, NFA can also be represented by transition graph or transition
table.
In NFA there may be state transition labeled with (means null string).
Such transitions are called -transition. For example below figure has
transition.

LUCKNOW
0522-6563566

LUCK NOW

GORAKHPUR
9919526958

ALLAHABAD
AGRA
9919751941
9451056682

PATNA
9919751941

NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES

11

TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success)

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA


PERSONAL REMARK :

q1
,

q2

In the above figure there is a walk labeled involving two -transitions


form q1 to itself. By using some of the edges twice, we see that there
are also walks involving transitions to q0 and q2 . Thus,
* q1 , a q 0 , q1 , q 2

Now we find * q 2 , . Since there is a edge between q2 and q0 ,we


have immediately that * q 2 , , contains q0. Also since any state can be
reached from itself by making no move, and consequently using no input
symbol. * q 2 , , also contains q2.
* q 2 , q 0 , q 2

Definition: The language L accepted by an NFA M Q, , , q 0 , F is


defined as the set of all strings
accepted by M. formally,
L M * : * q 0 , F

Equivalence of deterministic and non-deterministic finite


accepters:
Obviously there is a difference in the definition of DFA and NFA s but
this does not imply that there is any essential distinction between them.
Although there is many language for which an NFA is easier to construct
than DFA, it is surprising fact every language that can be described by
some NFA can also be described by some DFA.

Procedure NFA to DFA conversion :


1. Create a graph GD with vertex q0 . Identify this vertex as the initial
vertex.
2. Repeat the following steps until no more edges are missing.
Take any vertex qi, qj,...., qk of GD that has no outgoing edge for some
a.
Compute N q i , a , N q j , a , ............. N q k , a
,

Then from the union of all these N , yielding the set q , q m , .........., q n
i.e
q , q m , ....., q n N q i , a N q j , a N q k , a

Create a vertex q , q m , ....., q n if it does not all ready exist. Add to GD an


edge from q i , q j , ........q k to q , q m , ....., q n and label it with a.
3. Every state of GD whole label contains any q f FN is identified as
final state.
LUCKNOW
0522-6563566

LUCK NOW

GORAKHPUR
9919526958

ALLAHABAD
AGRA
9919751941
9451056682

PATNA
9919751941

NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES

12

TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success)

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA


4. If MN accepts , the vertex q0 in GD also made a final vertex.

PERSONAL REMARK :

Example: Convert the NFA in figure below into a DFA.

1
q1

0,1

q2

0,1

Solution: The state table of the NFA is given below.

States/
q0

q0 , q1

q1

q2

q2

q1
q2
,

q2

By applying the procedure NFA to DFA we get the following transition


table for corresponding DFA.

States/

q0, q1

q1

q0, q1

q0, q1, q2

q1, q2

q0, q1, q2

q0, q1, q2

q1, q2

q1, q2

q2

q2

q1

q2

q2

q2

q2

q0

Hence the corresponding DFA is:

1
0
q1

q0,q1

0,1
1

q1,q2

q2

q0,q1,q2

0,1

Example:

Find

0,1

deterministic

accepter

equivalent

to

M q 0 , q1 , q 2 , a , b, , q 0 , q 2 where is given by the following transition


table.

LUCKNOW
0522-6563566

LUCK NOW

GORAKHPUR
9919526958

ALLAHABAD
AGRA
9919751941
9451056682

PATNA
9919751941

NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES

13

TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success)

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA


PERSONAL REMARK :

States/
q0

q0 , q1

q2

q0

q1

q1
q2

q 0 , q1

Solution: Applying the NFA to DFA conversion method we obtain the


transition table of the DFA as
below.

States/

q0

q0, q1

q2

q0, q1

q0, q1

q1, q2

q2

q0, q1

q1, q2

q0

q0, q1

The transition diagram of the obtained DFA is shown below.

b
q0,q1

q2

q1,q2

Problem: Construct a non-deterministic finite automata whos e job is to


accept only the strings of 0s and 1s that end in 01, then convert this
NFD into an equivalent DFA.
Solution: The transition diagram and table of the NFA is given below.

0,1
0

States/

q1

q1

q0 , q1

q2

q1

q2

q2

q0

Applying NFA to DFA conversion method we obtain the following


transition table of the DFA.
LUCKNOW
0522-6563566

LUCK NOW

States/

GORAKHPUR
9919526958

q0

q0 , q1

q0

ALLAHABAD
AGRA
9919751941
9451056682

PATNA
9919751941

NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES

14

TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success)

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA


The transition diagram of the DFA is given below.

PERSONAL REMARK :

1
0

q0,q1

q0,q2

1
Problem: Construct a NFA accepting ab, ba and use it find a DFA
accepting the same string over a , b.
Solution: The transition table and transition diagram of the NFA is given
below.

q1

q2

b
q3

States/

q0

q1

q3

q1

q2

q2

q3

q2

Now applying NFA to DFA conversion method we obtain the transition


diagram of the DFA as follows:

States/

b1

q0

q1

q3

q1

q2

q2
q3

q2

Problem: Draw the transition diagram of DFA for the following language.
On a , b.
L : mod 3 0

Solution:

LUCKNOW
0522-6563566

LUCK NOW

GORAKHPUR
9919526958

ALLAHABAD
AGRA
9919751941
9451056682

PATNA
9919751941

NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES

15

TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success)

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA


PERSONAL REMARK :

q3

q2

q1

Problem: Find DFA for the following language on a , b.


(i) L : mod 5 0
(ii) L : h 3 mod 3 1
Solution:
(i)
q1

q2

q4

q3

(ii)
b

b
q1

q2

Theorem: Suppose L * and for some positive integer n, there are n


strings in * , any two of which are distinguishable with respect to L.
Then every finite automata recognizing L must have at least n states.
The Pigeon-hole principle: Suppose there are pigeons more than pigeon
holes, and each pigeon flies
into some pigeon hole, then there must be at least one hole that has more
than one pigeon. In our example, the pigeon are the sequence of n bits,
and pi geon holes are the states. Since there are fewer

states than sequences, one state must be assigned two sequences.


The pigeonhole principle is obvious, but it actually depends on the number
of pigeon holes being finite.
That it works for finite state automata, with the states as pigeon holes;
but does not apply to other kind of
automata that have an infinite number of states.
,

To see why the finiteness of the number of pigeonhole is essential, consider


the infinite situation where the pigeonholes correspond to i ntegers 1, 2,
. number of pigeons 0, 1, 2,.. So that there is one more pigeon then
there are pigeon holes. However we can send pigeon i to hole i +1 for all
i 0 . Then each of the infinite number of pigeons gets a pigeon hole,
and two pigeons have to share a pigeonhole.
LUCKNOW
0522-6563566

LUCK NOW

GORAKHPUR
9919526958

ALLAHABAD
AGRA
9919751941
9451056682

PATNA
9919751941

NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES

16

TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success)

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA


NFA with transition:
,

PERSONAL REMARK :

We may extend our model of NFA to include transition on empty string


. The transition diagram of such an NFA accepting the language
consisting of any number of 0s followed by any number of 1s, followed
by any number of 2s is given in figure below.

q2

q1

We say that an NFA accepts a string if there is some path labeled from
the initial state to a final state. Of course, edge labeled may be included
in the path, although the s do not appear explicitly in . For example
the word 002 is accepted by NFA above figure, by the path q0, q0, q0, q1,
q2, q2, with arcs labeled 0, 0, , , 2.
Formally we define a non-deterministic finite automation with moves
to be a five tuple Q, , , q 0 , F with all components as before, but , the

transition function, maps Q to 2 Q . The intention is that q, a


will consists all states P such that there is a transition labeled a from q to
p, where a is either or
a symbol in .
Transition table for the above NFA is given as follows:

q0

q0

q1

q1

q1

q2

q2

q2

States

- Closure: it denotes the set of all vertices p such that there is a path
from q to p labeled . In the above figure - closure q0= q0, q1, q2. That
is the path consisting of q0 alone (there is no arcs on the path), is a path
from q0 to q0 with all arcs labeled with , path q0, q1 shows that q1 is in
- closure 0 q and path 0 1 2 q ,q ,q shows that 2 q is in -closure q0.
- closure (p), where p is a set of states, be

- closure.

q in p

Definition: Let M Q, , , q 0 , F be an NFA containing transition


and p be any subset of Q. the
closure of p is the set of -closure (p) as follows:
(1) Every element of p is an element of -closure (p).
(2) For any q -closure (p), every element of q, t is in -closure
(p);
(3) No other elements of Q are in -closure (p)
LUCKNOW
0522-6563566

LUCK NOW

GORAKHPUR
9919526958

ALLAHABAD
AGRA
9919751941
9451056682

PATNA
9919751941

NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES

17

TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success)

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA


An algorithm to calculate -closure (p):
,

PERSONAL REMARK :

Start with T = p make a sequence of passes, in each pass consider every


q T and adding to T all elements of q, , that are not already
elements of T. Stop after any pass in which T does not change.
The set -closure (p) is the final value of T..
Extended Transition Function:
,

We can now define the extended transition that maps Q * to 2Q .


We define recursively as follows:
(1) q, = -closure (q)
(2) For * and a in , , q, a = -closure(p) where
P P for some r in , q, , p is in r , a

We define L(M), the language accepted by M Q, , , q 0 , F to be


L M : , q 0 , contains a state in F

Example: Find q 0 ,, q 0 , 0, q 0 , 01 for the following NFA.

q1

q2

q 0 , closure q 0 q 0 , q1, q 2 ,

Thus,
q 0 , 0 closure q 0 ,, 0
closure q 0 , q1 , q 2 , 0
closure q 0 , 0 q1 , 0 q 2 , 0
closure q 0
closure q 0 q 0 , q1 , q 2

Then,
q 0 , 01 closure q 0 , 0, 1
closure q 0 , q1 , q 2 , 1

closure q1 q1 , q 2

LUCKNOW
0522-6563566

LUCK NOW

GORAKHPUR
9919526958

ALLAHABAD
AGRA
9919751941
9451056682

PATNA
9919751941

NOIDA
SUMMER CRASH COURSE ONLINE TEST SERIES
9919751941 WINTER CRASH COURSE OFF-LINE TEST SERIES

18

Das könnte Ihnen auch gefallen