autometa theory gate notes

18
TECHGURU CLASSES for ENGINEERS (Your Dedication + Our Guidance = Sure Success) CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA PERSONAL REMARK : LUCKNOW 1 ONLINE TEST SERIES OFF-LINE TEST SERIES SUMMER CRASH COURSE WINTER CRASH COURSE AGRA 9451056682 GORAKHPUR 9919526958 LUCKNOW 0522-6563566 PATNA 9919751941 NOIDA 9919751941 ALLAHABAD 9919751941 The Central Concept of Automata 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: 1 , 0 , then 1 , 0 1 , 11 , 10 , 01 , 00 2 , 111 , 110 , 101 , 100 , 011 , 010 , 001 , 000 3 , and so on. Note that 0 = 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 ......... 2 1 0 * *Sometimes, we wish to exclude the empty string from the set of all

Upload: multan-singh-bhati

Post on 08-Dec-2015

53 views

Category:

Documents


1 download

DESCRIPTION

automata

TRANSCRIPT

Page 1: Autometa Theory gate notes

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

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA

PERSONAL REMARK :

LUCKNOW 1 ONLINE TEST SERIES OFF-LINE TEST SERIES

SUMMER CRASH COURSE WINTER CRASH COURSE

AGRA 9451056682

GORAKHPUR 9919526958

LUCKNOW 0522-6563566

PATNA 9919751941

NOIDA 9919751941

ALLAHABAD 9919751941

The Central Concept of Automata

, 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:

1,0 , then 1,01 , 11,10,01,002 ,

111,110,101,100,011,010,001,0003 , and so on.

Note that 0 = 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

.........210*

*Sometimes, we wish to exclude the empty string from the set of all

Page 2: Autometa Theory gate notes

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

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA

PERSONAL REMARK :

LUCKNOW 2 ONLINE TEST SERIES OFF-LINE TEST SERIES

SUMMER CRASH COURSE WINTER CRASH COURSE

AGRA 9451056682

GORAKHPUR 9919526958

LUCKNOW 0522-6563566

PATNA 9919751941

NOIDA 9919751941

ALLAHABAD 9919751941

strings from alphabet is denoted by . Thus denotes the set

of all strings whose length is at least one.

So,

or.........321

*

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

yxxy where y,x,xy 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 n21 a......a,a then

reverse of is Rn 2 1a , ...... a a

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 0’s and 1’s with an equal number

Page 3: Autometa Theory gate notes

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

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA

PERSONAL REMARK :

LUCKNOW 3 ONLINE TEST SERIES OFF-LINE TEST SERIES

SUMMER CRASH COURSE WINTER CRASH COURSE

AGRA 9451056682

GORAKHPUR 9919526958

LUCKNOW 0522-6563566

PATNA 9919751941

NOIDA 9919751941

ALLAHABAD 9919751941

each.

,01,10,0011,0101,1001,1100......

Example 2: The set of binary numbers whose value is prime.

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: LL *

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

L;L RR

, The concatenation of languages L1 and L

2 are obtained by concatenating

any element of L1 with any element of L

2 , i.e.

22112121 LandL:LL

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

cases

0L

, Finally, we define the star closure of a language as

........LLLL 210*

and positive closure as

........LLLL 321

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.

Page 4: Autometa Theory gate notes

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

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA

PERSONAL REMARK :

LUCKNOW 4 ONLINE TEST SERIES OFF-LINE TEST SERIES

SUMMER CRASH COURSE WINTER CRASH COURSE

AGRA 9451056682

GORAKHPUR 9919526958

LUCKNOW 0522-6563566

PATNA 9919751941

NOIDA 9919751941

ALLAHABAD 9919751941

Input file

Control Unit Storage

, 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. F,q,,,Q 0 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) Qq0 is called the initial state

(v) QF 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

Page 5: Autometa Theory gate notes

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

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA

PERSONAL REMARK :

LUCKNOW 5 ONLINE TEST SERIES OFF-LINE TEST SERIES

SUMMER CRASH COURSE WINTER CRASH COURSE

AGRA 9451056682

GORAKHPUR 9919526958

LUCKNOW 0522-6563566

PATNA 9919751941

NOIDA 9919751941

ALLAHABAD 9919751941

edge indicate the transition of a state and the edges are labeled with

input/output symbols. For every transition rule i j(q, a) q the graph has

an edge ji q,q labeled a di rected from iq to jq 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.

q1

01 0,1

q210

The transition graph in Figure represent the DFA

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

Where is given by

0 1 1 1 2 2(q , 0) q , (q ,0) q (q ,0) q

0 0 1 2 2 2(q ,1) q , (q ,1) q (q ,1) q

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/ 0 1

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

Page 6: Autometa Theory gate notes

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

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA

PERSONAL REMARK :

LUCKNOW 6 ONLINE TEST SERIES OFF-LINE TEST SERIES

SUMMER CRASH COURSE WINTER CRASH COURSE

AGRA 9451056682

GORAKHPUR 9919526958

LUCKNOW 0522-6563566

PATNA 9919751941

NOIDA 9919751941

ALLAHABAD 9919751941

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

Property 1: q,q in a finite automation. This means the state

of the system can be change only by an input symbol.

Property 2: For all string and input symbols a

,a,qa,q

a,,qa,q

, 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

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

notation,

Fq;ML 0*

Example 1:

q1

a

q2

a,b

b

a,b

, The automaton in the above figure remains in state 0q (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 2q , from which it can’tt

escape. Such a state is called trap state. Thus the automaton accepts all

string consisting of an arbitrary number of a’s followed by a single b. all

other strings are rejected.

Problem: Find a deterministic finite accepter that recognize the set of

all strings on b,a 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

q1a

b

q2

a,b

a,b

q2

Regular language:

, A language L is called regular if and only if there exists some deterministic

Page 7: Autometa Theory gate notes

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

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA

PERSONAL REMARK :

LUCKNOW 7 ONLINE TEST SERIES OFF-LINE TEST SERIES

SUMMER CRASH COURSE WINTER CRASH COURSE

AGRA 9451056682

GORAKHPUR 9919526958

LUCKNOW 0522-6563566

PATNA 9919751941

NOIDA 9919751941

ALLAHABAD 9919751941

finite accepter M such that

L = L(M)

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

b

bb

a

a

a

a,b

, The DFA in the figure shown on the left accept the language*b,at:aaL So, L is regular..

Problem: For b,a , construct DFA’s 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 ‘a’s

(d) all string with at least one ‘a’ and exactly two ‘b’s.

Solution:

(a) q1a q2

a,bbb

a

, The DFA is describe by

10210 q,q,,b,a,q,q,qM

Where is given by

210010 qa,q,qb,q,qa,q

222211 qb,q,qa,q,qb,q

(b) a q2

a,bb

, The DFA, M is given by 1010 q,q,,b,a,q,qM

Where is given by

1110 qa,q,qa,q

1100 qb,q,qb,q

(c) q1 q2q0

b b b b a,b

a a a a4

Page 8: Autometa Theory gate notes

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

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA

PERSONAL REMARK :

LUCKNOW 8 ONLINE TEST SERIES OFF-LINE TEST SERIES

SUMMER CRASH COURSE WINTER CRASH COURSE

AGRA 9451056682

GORAKHPUR 9919526958

LUCKNOW 0522-6563566

PATNA 9919751941

NOIDA 9919751941

ALLAHABAD 9919751941

(d)

q1q5

q2

q0

a,b

q6

a a a

a

a a

b

b

b

b bb

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

an even number of 0’s and odd number of 1’s

Solution: The states in the DFA will remember whether the number of

0’s seen so far is even or odd and also remember whether the numbers

of 1’s seen so far is even or odd. There are thus four states, which can

be given the following interpretation.

qEE

: both the number of 0’s and 1’s seen so far are even

qOE

: number of 0’s seen so far is odd but number of 1’s seen so far is

even.

q00

: both the number of 0’s and 1’s seen so far are odd.

qE0

: number of 0’s seen so far is even but number of 1’s seen is odd.

, It is clear that qEE

is the initial state, because before reading any inputs,

the number of 0’s and 1’s 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.

qEEqE0

q0E q00

0

1

1

1

1

0 0 0

Problem: Construct a DFA for the language 4a:aL n Solution:

Note, q4 is the only non-final state.

Problem: Construct a DFA for the following language.

03modn:b,aL a*

Page 9: Autometa Theory gate notes

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

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA

PERSONAL REMARK :

LUCKNOW 9 ONLINE TEST SERIES OFF-LINE TEST SERIES

SUMMER CRASH COURSE WINTER CRASH COURSE

AGRA 9451056682

GORAKHPUR 9919526958

LUCKNOW 0522-6563566

PATNA 9919751941

NOIDA 9919751941

ALLAHABAD 9919751941

Solution: 3modna could be 0, 1, or 2. so we need three states to

remember these three remainder. Let the states be q0, q

1 and q

2

corresponding to these remainders. Now the DFA looks like

q1q2

b b b

Problem: Construct a DFA for the language

13mod:b,aL * Solution:

q1q2

Problem: Construct a DFA for the following language.

3modn3modn:b,aL ba*

Solution: Let

3modni a , and

3modnj a , 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 qij’s for which i > j.

Now we can draw the transition diagram.

Page 10: Autometa Theory gate notes

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

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA

PERSONAL REMARK :

LUCKNOW 10 ONLINE TEST SERIES OFF-LINE TEST SERIES

SUMMER CRASH COURSE WINTER CRASH COURSE

AGRA 9451056682

GORAKHPUR 9919526958

LUCKNOW 0522-6563566

PATNA 9919751941

NOIDA 9919751941

ALLAHABAD 9919751941

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, q

1, q

2, q

3 and q

4 denotes the states

corresponding to remainders 0, 1, 2, 3 and 4 respectively. Draw the

transition table first.

q0q1

q3

q2

q4

0

0

0

0

0

1

1

1

1

1

States 0 1

q0 q0 q1

q1 q2 q3

q2 q4 q0

q3 q1 q2

q4 q3 q4

Page 11: Autometa Theory gate notes

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

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA

PERSONAL REMARK :

LUCKNOW 11 ONLINE TEST SERIES OFF-LINE TEST SERIES

SUMMER CRASH COURSE WINTER CRASH COURSE

AGRA 9451056682

GORAKHPUR 9919526958

LUCKNOW 0522-6563566

PATNA 9919751941

NOIDA 9919751941

ALLAHABAD 9919751941

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 q

0 or q

1. 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.

q1

q2

1

0

1

10

Definition (NFA):

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

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 Q2 , which

is the power set Q, i.e. the set of all possible subset of Q.

i.e. Q2Q

(iv) Qq0 is the initial state.

(v) QF 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 W,q, 0 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.

Page 12: Autometa Theory gate notes

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

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA

PERSONAL REMARK :

LUCKNOW 12 ONLINE TEST SERIES OFF-LINE TEST SERIES

SUMMER CRASH COURSE WINTER CRASH COURSE

AGRA 9451056682

GORAKHPUR 9919526958

LUCKNOW 0522-6563566

PATNA 9919751941

NOIDA 9919751941

ALLAHABAD 9919751941

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 q

2 . Thus,

2101* q,q,qa,q

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

2 and q

0 ,we

have immediately that ,q2* , contains q

0. Also since any state can be

reached from itself by making no move, and consequently using no input

symbol. ,q2* , also contains q

2.

202* q,q,q

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

defined as the set of all strings

accepted by M. formally,

F,q:ML 0**

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 q

0 . Identify this vertex as the initial

vertex.

2. Repeat the following steps until no more edges are missing.

, Take any vertex qi, q

j,...., q

k of G

D that has no outgoing edge for some

a .

Compute a,q.............,a,q,a,q kNjNiN

, Then from the union of all these N , yielding the set nm q,..........,q,qi.e

a,qa,qa,qq.....,,q,q kNjNiNnm

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

an

edge from kji q........,q,q to nm q.....,,q,q and label it with a.

3. Every state of GD

whole label contains any Nf Fq is identified as

final state.

Page 13: Autometa Theory gate notes

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

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA

PERSONAL REMARK :

LUCKNOW 13 ONLINE TEST SERIES OFF-LINE TEST SERIES

SUMMER CRASH COURSE WINTER CRASH COURSE

AGRA 9451056682

GORAKHPUR 9919526958

LUCKNOW 0522-6563566

PATNA 9919751941

NOIDA 9919751941

ALLAHABAD 9919751941

4. If MN accepts , the vertex q

0 in G

D also made a final vertex.

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

q10,1 0,1

10

q2

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

States/ 0 1

q0 q0, q1 q1

q1 q2 q2

q2 q2

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

table for corresponding DFA.

States/ 0 1

q0 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

Hence the corresponding DFA is:

q1

q2

01

1

1

0 0

0,10,1

0

1

0,1q0,q1

q1,q2 q q0,q1, 2

Example: Find a deterministic accepter equivalent to

20210 q,q,,b,a,q,q,qM where is given by the following transition

table.

Page 14: Autometa Theory gate notes

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

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA

PERSONAL REMARK :

LUCKNOW 14 ONLINE TEST SERIES OFF-LINE TEST SERIES

SUMMER CRASH COURSE WINTER CRASH COURSE

AGRA 9451056682

GORAKHPUR 9919526958

LUCKNOW 0522-6563566

PATNA 9919751941

NOIDA 9919751941

ALLAHABAD 9919751941

States/ a b

q0 q0, q1 q2

q1 q0 q1

q2 q0, q1

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

transition table of the DFA as

below.

States/ a b

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.

0

q1,q2

q2

q0,q1

b

b b

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

accept only the strings of 0’s and 1’s that end in 01, then convert this

NFD into an equivalent DFA.

Solution: The transition diagram and table of the NFA is given below.

q1

0,1

0 q11

States/ 0 1

q0 q0, q1 q2

q1 - q2

q2 - -

Applying NFA to DFA conversion method we obtain the following

transition table of the DFA.

States/ 0 1

q0 q0, q1 q0

q0, q1 q0, q1 q0, q2

Page 15: Autometa Theory gate notes

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

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA

PERSONAL REMARK :

LUCKNOW 15 ONLINE TEST SERIES OFF-LINE TEST SERIES

SUMMER CRASH COURSE WINTER CRASH COURSE

AGRA 9451056682

GORAKHPUR 9919526958

LUCKNOW 0522-6563566

PATNA 9919751941

NOIDA 9919751941

ALLAHABAD 9919751941

The transition diagram of the DFA is given below.

0 1

01

q0,q1 q0,q2

1

Problem: Construct a NFA accepting ab, ba and use it find a DFA

accepting the same string over .b,a

Solution: The transition table and transition diagram of the NFA is given

below.

q1 q2b

b

q3

States/ a b

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/ a b1

q0 q1 q3

q1 q2

q2

q3 q2

Problem: Draw the transition diagram of DFA for the following language.

On .b,a

03mod:L

Solution:

Page 16: Autometa Theory gate notes

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

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA

PERSONAL REMARK :

LUCKNOW 16 ONLINE TEST SERIES OFF-LINE TEST SERIES

SUMMER CRASH COURSE WINTER CRASH COURSE

AGRA 9451056682

GORAKHPUR 9919526958

LUCKNOW 0522-6563566

PATNA 9919751941

NOIDA 9919751941

ALLAHABAD 9919751941

q1q2

q3

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

(i) 05mod:L

(ii) 13modh:L 3

Solution:

(i)

q1 q2q3

q4

(ii)

q1q2

b b b

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

0i . Then each of the infinite number of pigeons gets a pigeon hole,

and two pigeons have to share a pigeonhole.

Page 17: Autometa Theory gate notes

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

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA

PERSONAL REMARK :

LUCKNOW 17 ONLINE TEST SERIES OFF-LINE TEST SERIES

SUMMER CRASH COURSE WINTER CRASH COURSE

AGRA 9451056682

GORAKHPUR 9919526958

LUCKNOW 0522-6563566

PATNA 9919751941

NOIDA 9919751941

ALLAHABAD 9919751941

NFA with transition:

, 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 0’s followed by any number of 1’s, followed

by any number of 2’s is given in figure below.

q1 q2

, 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, q

0, q

0, q

1,

q2, q

2, with arcs labeled 0, 0, , , 2.

, Formally we define a non-deterministic finite automation with moves

to be a five tuple F,q,,,Q 0 with all components as before, but , the

transition function, maps Q to Q2 . 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:

States

q0

q1

q2

q0

0 1 2

q1

q2

q2

q1

, - 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= q

0, q

1, q

2. That

is the path consisting of q0 alone (there is no arcs on the path), is a path

from q0 to q

0 with all arcs labeled with , path q

0, q

1 shows that q

1 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

pinq - closure.

Definition: Let F,q,,,QM 0 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)

Page 18: Autometa Theory gate notes

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

CHAPTER - 1 (CONCEPT OF AUTOMETA ) : AUTOMETA

PERSONAL REMARK :

LUCKNOW 18 ONLINE TEST SERIES OFF-LINE TEST SERIES

SUMMER CRASH COURSE WINTER CRASH COURSE

AGRA 9451056682

GORAKHPUR 9919526958

LUCKNOW 0522-6563566

PATNA 9919751941

NOIDA 9919751941

ALLAHABAD 9919751941

An algorithm to calculate -closure (p):

, 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 Q2 .

We define ̂ recursively as follows:

(1) ̂ q, = -closure (q)

(2) For * and a in a,q,ˆ, = -closure(p) where

a,rinisp,,q,ˆinrsomeforPP

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

,q,ˆ:ML 0 contains a state in F

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

q1 q2

,q,q,qqclosure,qˆ21000

Thus,

0,,qˆclosure0,qˆ00

0,q,q,qclosure 210

0,q0,q0,qclosure 210

0qclosure

2100 q,q,qqclosure

Then,

1,0,qˆclosure10,qˆ00

1,q,q,qclosure 210

211 q,qqclosure