SlideShare a Scribd company logo
1 of 9
Download to read offline
Unit1 Formal Languages and Automata Theory 06CS56
DEFINITION OF DETERMINISTIC FINITE AUTOMATON
Let Q be a finite set and let be a finite set of symbols. Also let be a function from Q X to Q, let q0 be a
state in Q and let A be a subset of Q. We call the elements of Q a state, the transition function, q0 the initial
state and A the set of accepting states.
Then a deterministic finite automaton is a 5-tuple < Q, , q0 , , A >
1. The set Q in the above definition is simply a set with a finite number of elements. Its elements can, however,
be interpreted as a state that the system (automaton) is in. Thus in the example of vending machine, for
example, the states of the machine such as "waiting for a customer to put a coin in", "have received 5 cents"
etc. are the elements of Q. "Waiting for a customer to put a coin in" can be considered the initial state of this
automaton and the state in which the machine gives out a soda can be considered the accepting state.
2. The transition function is also called a next state function meaning that the automaton moves into the state
(q, a) if it receives the input symbol a while in state q.
Thus in the example of vending machine, if q is the initial state and a nickel is put in, then (q, a) is equal
to "have received 5 cents".
3. Note that is a function. Thus for each state q of Q and for each symbol a of , (q, a) must be
specified.
4. The accepting states are used to distinguish sequences of inputs given to the finite automaton. If the finite
automaton is in an accepting state when the input ceases to come, the sequence of input symbols given to
the finite automaton is "accepted". Otherwise it is not accepted. For example, in the Example 1 below, the
string a is accepted by the finite automaton. But any other strings such as aa, aaa, etc. are not accepted.
5. A deterministic finite automaton is also called simply a "finite automaton". Abbreviations such as FA and
DFA are used to denote deterministic finite automaton.
DFAs are often represented by digraphs called (state) transition diagram. The vertices (denoted by single
circles) of a transition diagram represent the states of the DFA and the arcs labeled with an input symbol
correspond to the transitions. An arc ( p , q ) from vertex p to vertex q with label represents the transition
(p, ) = q . The accepting states are indicated by double circles.
Transition functions can also be represented by tables as seen below. They are called transition table.
Examples of finite automaton
Example 1: Q = { 0, 1, 2 }, = { a }, A = { 1 }, the initial state is 0 and is as shown in the following table.
State (q) a
0 1
1 2
2 2
A state transition diagram for this DFA is given below
If the alphabet of the Example 1 is changed to { a, b } in stead of { a }, then we need a DFA such as shown in
the following example to accept the same string a. It is a little more complex DFA.
Example 2: Q = { 0, 1, 2 }, = { a, b }, A = { 1 }, the initial state is 0 and is as shown in the following table.
Note that for each state there are two rows in the table for corresponding to the symbols a and b, while in
the Example 1 there is only one row for each state.
A state transition diagram for this DFA is given below.
A DFA that accepts all strings consisting of only symbol a over the alphabet { a, b } is the next example.
Example 3: Q = { 0, 1 }, = { a, b }, A = { 0 }, the initial state is 0 and is as shown in the following table.
A state transition diagram for this DFA is given below.
State (q) a b
0 1 2
*1 2 2
2 2 2
State (q) a b
0 0 1
1 1 1
A finite automaton as a machine
A finite automaton can also be thought of as the device shown below consisting of a tape and a control circuit
which satisfy the following conditions:
1. The tape has the left end and extends to the right without an end.
2. The tape is divided into squares in each of which a symbol can be written prior to the start of the operation
of the automaton.
3. The tape has a read only head.
4. The head is always at the leftmost square at the beginning of the operation.
5. The head moves to the right one square every time it reads a symbol.
It never moves to the left. When it sees no symbol, it stops and the automaton terminates its operation.
6. There is a finite control which determines the state of the automaton and also controls the movement of the
head
Operation of finite automata
Let us see how an automaton operates when it is given some inputs. As an example let us consider the DFA of
Example 3 above.
Initially it is in state 0. When zero or more a's are given as an input to it, it stays in state 0 while it reads all the a's
(without breaks) on the tape. Since the state 0 is also the accepting state, when all the a's on the tape are read,
the DFA is in the accepting state. Thus this automaton accepts any string of a's. If b is read while it is in state 0
(initially or after reading some a's), it moves to state 1. Once it gets to state 1, then no matter what symbol is read,
this DFA never leaves state 1. Hence when b appears anywhere in the input, it goes into state 1 and the input
string is not accepted by the DFA. For example strings aaa, aaaaaa etc. are accepted but strings such as aaba, b
etc. are not accepted by this automaton.
Draw a DFA to accept string of 0’s and 1’s ending with the string 011.
Obtain a DFA to accept strings of a’s and b’s having a sub string aa
q3q1 q2q0
1 0
0
0
1
1 10
q2q1
b
q0
a a
b
a,b
Obtain a DFA to accept strings of a’s and b’s except those containing the substring aab.
Obtain DFAs to accept strings of a’s and b’s having exactly one a,
Obtain a DFA to accept strings of a’s and b’s having even number of a’s and b’s
Obtain a DFA to accept strings of a’s and b’s having even number of a’s and odd number of b’s.
Obtain a DFA to accept strings of a’s and b’s having odd number of a’s and even number of b’s.
Obtain a DFA to accept strings of a’s and b’s having odd number of a’s and odd number of b’s.
Regular language
Definition: Let M = (Q, , , q0, A) be a DFA. The language L is regular if there exists a machine M such that L
= L(M).
q3
a ba
q2q1q0
a,bb
b
a
q1q0
b a,b
a q2
b
a
q1q0
b
q2
b
a
a
b
q3
b
a
a
q1q0
b
q2
b
a
a
b
q3
b
a
a
q1q0
b
q2
b
a
a
b
q3
b
a
a
q1q0
b
q2
b
a
a
b
q3
b
a
a
Applications of Finite Automata
String matching/processing
Compiler Construction
The various compilers such as C/C++, Pascal, FORTRAN or any other compiler is designed using the finite
automata. The DFAs are extensively used in the building the various phases of compiler such as
 Lexical analysis (To identify the tokens, identifiers, to strip of the comments etc.)
 Syntax analysis (To check the syntax of each statement or control statement used in the program)
 Code optimization (To remove the un wanted code)
 Code generation (To generate the machine code)
Other applications
The concept of finite automata is used in wide applications. It is not possible to list all the applications as there
are infinite numbers of applications. This section lists some applications:
1. Large natural vocabularies can be described using finite automaton which includes the applications such as
spelling checkers and advisers, multi-language dictionaries, to indent the documents, in calculators to
evaluate complex expressions based on the priority of an operator etc. to name a few. Any editor that we use
uses finite automaton for implementation.
2. Finite automaton is very useful in recognizing difficult problems i.e., sometimes it is very essential to solve
an un-decidable problem. Even though there is no general solution exists for the specified problem, using
theory of computation, we can find the approximate solutions.
3. Finite automaton is very useful in hardware design such as circuit verification, in design of the hardware
board (mother board or any other hardware unit), automatic traffic signals, radio controlled toys, elevators,
automatic sensors, remote sensing or controller etc.
4. In game theory and games wherein we use some control characters to fight against a monster, economics,
computer graphics, linguistics etc., finite automaton plays a very important role.
Non deterministic finite automata (NFA)
Definition: An NFA is a 5-tuple or quintuple M = (Q, , , q0, A) where
Q is non-empty, finite set of states.
 is non-empty, finite set of input alphabets.
 is transition function which is a mapping from
Q x { U } to subsets of 2Q. This function shows the change of state from one state to a set of states
based on the input symbol.
q0  Q is the start state.
A  Q is set of final states.
Acceptance of language
Definition: Let M = (Q, , , q0, A) be a DFA where Q is set of finite states,  is set of input alphabets (from
which a string can be formed),  is transition function from Q x {U} to 2Q, q0 is the start state and A is the final
or accepting state. The string (also called language) w accepted by an NFA can be defined in formal notation as:
L(M) = { w | w  *and *(q0, w) = Q with atleast one
Component of Q in A}
Obtain an NFA to accept the following language L = {w | w  ababn or aban where n  0}
The machine to accept either ababn or aban where n  0 is shown below:
b
q1
a q3q2
b a q4
q5
a
q6
a b q7
q0



Q
2.1 Conversion from NFA to DFA
Let MN = (QN, N, N, q0, AN) be an NFA and accepts the language L(MN). There should be an equivalent DFA MD =
(QD, D, D, q0, AD) such that L(MD) = L(MN). The procedure to convert an NFA to its equivalent DFA is shown
below:
Step1:
The start state of NFA MN is the start state of DFA MD. So, add q0(which is the start state of NFA) to QD
and find the transitions from this state. The way to obtain different transitions is shown in step2.
Step2:
For each state [qi, qj,….qk] in QD, the transitions for each input symbol in  can be obtained as shown
below:
1. D([qi, qj,….qk], a) = N(qi, a) U N(qj, a) U ……N(qk, a)
= [ql, qm,….qn] say.
2. Add the state [ql, qm,….qn] to QD, if it is not already in QD.
3. Add the transition from [qi, qj,….qk] to [ql, qm,….qn] on the input symbol a iff the state [ql, qm,….qn] is
added to QD in the previous step.
Step3:
The state [qa, qb,….qc]  QD is the final state, if at least one of the state in qa, qb, ….. qc  AN i.e., at least one
of the component in [qa, qb,….qc] should be the final state of NFA.
Step4:
If epsilon () is accepted by NFA, then start state q0 of DFA is made the final state.
Convert the following NFA into an equivalent DFA.
Step1: q0 is the start of DFA (see step1 in the conversion procedure).
So, QD = {[q0]} (2.7)
Step2: Find the new states from each state in QD and obtain the corresponding transitions.
Consider the state [q0]:
When a = 0
D([q0], 0) =
=
N([q0], 0)
[q0, q1]
(2.8)
When a = 1
D([q0], 1) =
=
N([q0], 1)
[q1]
(2.9)
Since the states obtained in (2.8) and (2.9) are not in QD(2.7), add these two states to QD so that
QD = {[q0], [q0, q1], [q1] } (2.10)
The corresponding transitions on a = 0 and a = 1 are shown below.
 0 1
[q0] [q0, q1] [q1]
[q0, q1]
[q1]
q1q0
0 1
0,1 q2
0, 1

Q

Q
Consider the state [q0, q1]:
When a = 0
D([q0, q1],
0)
=
=
=
=
N([q0, q1], 0)
N(q0, 0) U N(q1, 0)
{q0, q1} U {q2}
[q0, q1, q2] (2.11)
When a = 1
D([q0, q1],
1)
=
=
=
=
N([q0, q1], 1)
N(q0, 1) U N(q1, 1)
{q1} U {q2}
[q1, q2] (2.12)
Since the states obtained in (2.11) and (2.12) are the not defined in QD(see 2.10), add these two states to QD so
that
QD = {[q0], [q0, q1], [q1], [q0, q1, q2], [q1, q2] } (2.13)
and add the transitions on a = 0 and a = 1 as shown below:
Consider the state [q1]:
When a = 0
D([q1], 0) =
=
N([q1], 0)
[q2] (2.14)
When a = 1
D([q1], 1) =
=
N([q1], 1)
[q2] (2.15)
Since the states obtained in (2.14) and (2.15) are same and the state q2 is not in QD(see 2.13), add the state q2 to
QD so that
QD = {[q0], [q0, q1], [q1], [q0, q1, q2], [q1, q2], [q2]} (2.16)
and add the transitions on a = 0 and a = 1 as shown below:
 0 1
[q0] [q0, q1] [q1]
[q0, q1] [q0, q1, q2] [q1, q2]
[q1]
[q0, q1, q2]
[q1, q2]
 0 1
[q0] [q0, q1] [q1]
[q0, q1] [q0, q1, q2] [q1, q2]
[q1] [q2] [q2]
[q0, q1, q2]
[q1, q2]
[q2]

Q
Q

Consider the state [q0,q1,q2]:
When a = 0
D([q0,q1,q2], 0) =
=
=
=
N([q0,q1,q2], 0)
N(q0, 0) U N(q1, 0) U N(q2, 0)
{q0,q1} U {q2} U {}
[q0,q1,q2] (2.17)
When a = 1
D([q0,q1,q2], 1) =
=
=
=
N([q0,q1,q2], 1)
N(q0, 1) U N(q1, 1) U N(q2, 1)
{q1} U {q2} U {q2}
[q1, q2]
(2.18)
Since the states obtained in (2.17) and (2.18) are not new states (are already in QD, see 2.16), do not add these
two states to QD. But, the transitions on a = 0 and a = 1 should be added to the transitional table as shown
below:
Consider the state [q1,q2]:
When a = 0
D([q1,q2], 0) =
=
=
=
N([q1,q2], 0)
N(q1, 0) U N(q2, 0)
{q2} U {}
[q2] (2.19)
When a = 1
D([q1,q2], 1) =
=
=
=
N([q1,q2], 1)
N(q1, 1) U N(q2, 1)
{q2} U {q2}
[q2] (2.20)
Since the states obtained in (2.19) and (2.20) are not new states (are already in QD see 2.16), do not add these
two states to QD. But, the transitions on a = 0 and a = 1 should be added to the transitional table as shown
below:
 0 1
[q0] [q0, q1] [q1]
[q0, q1] [q0, q1, q2] [q1, q2]
[q1] [q2] [q2]
[q0, q1, q2] [q0,q1,q2] [q1, q2]
[q1, q2]
[q2]
 0 1
[q0] [q0, q1] [q1]
[q0, q1] [q0, q1, q2] [q1, q2]
[q1] [q2] [q2]
[q0, q1, q2] [q0,q1,q2] [q1, q2]
[q1, q2] [q2] [q2]
[q2]
Consider the state [q2]:
When a = 0
D([q2], 0) =
=
N([q2], 0)
{} (2.21)
When a = 1
D([q2], 1) =
=
N([q2], 1)
[q2] (2.22)
Since the states obtained in (2.21) and (2.22) are not new states (are already in QD, see 2.16), do not add these
two states to QD. But, the transitions on a = 0 and a = 1 should be added to the transitional table. The final
transitional table is shown in table 2.14. and final DFA is shown in figure 2.35.
The DFA
 0 1
[q0] [q0, q1] [q1]
[q0, q1, q2] [q1, q2]
[q2] [q2]
[q0,q1,q2] [q1, q2]
[q2] [q2]
[q2]  [q2]
[q2
]
[q1
]
[q0
]
[q0
, q1
]
[q1
, q2
][q0
, q1
, q2
]
0 1
0 1 0, 1
0, 1
0 1
1
[q0,q1]
[q1]
[q0,q1,q2]
[q1,q2]

More Related Content

What's hot

Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite AutomataRatnakar Mikkili
 
NFA or Non deterministic finite automata
NFA or Non deterministic finite automataNFA or Non deterministic finite automata
NFA or Non deterministic finite automatadeepinderbedi
 
Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)
Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)
Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)Mohammad Ilyas Malik
 
Finite automata(For college Seminars)
Finite automata(For college Seminars)Finite automata(For college Seminars)
Finite automata(For college Seminars)Naman Joshi
 
Automata theory introduction
Automata theory introductionAutomata theory introduction
Automata theory introductionNAMRATA BORKAR
 
NFA Converted to DFA , Minimization of DFA , Transition Diagram
NFA Converted to DFA , Minimization of DFA , Transition DiagramNFA Converted to DFA , Minimization of DFA , Transition Diagram
NFA Converted to DFA , Minimization of DFA , Transition DiagramAbdullah Jan
 
Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Srimatre K
 
Introduction to fa and dfa
Introduction to fa  and dfaIntroduction to fa  and dfa
Introduction to fa and dfadeepinderbedi
 
Finite automata-for-lexical-analysis
Finite automata-for-lexical-analysisFinite automata-for-lexical-analysis
Finite automata-for-lexical-analysisDattatray Gandhmal
 
Nondeterministic Finite Automat
Nondeterministic Finite AutomatNondeterministic Finite Automat
Nondeterministic Finite AutomatAdel Al-Ofairi
 
Nondeterministic Finite Automata
Nondeterministic Finite AutomataNondeterministic Finite Automata
Nondeterministic Finite AutomataAdel Al-Ofairi
 
NFA DFA Equivalence theorem
NFA DFA Equivalence theorem NFA DFA Equivalence theorem
NFA DFA Equivalence theorem niveditJain
 

What's hot (19)

Lecture: Automata
Lecture: AutomataLecture: Automata
Lecture: Automata
 
Introduction TO Finite Automata
Introduction TO Finite AutomataIntroduction TO Finite Automata
Introduction TO Finite Automata
 
Finite automata
Finite automataFinite automata
Finite automata
 
Automata theory
Automata theoryAutomata theory
Automata theory
 
NFA or Non deterministic finite automata
NFA or Non deterministic finite automataNFA or Non deterministic finite automata
NFA or Non deterministic finite automata
 
Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)
Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)
Finite Automata: Deterministic And Non-deterministic Finite Automaton (DFA)
 
Finite automata(For college Seminars)
Finite automata(For college Seminars)Finite automata(For college Seminars)
Finite automata(For college Seminars)
 
Automata theory introduction
Automata theory introductionAutomata theory introduction
Automata theory introduction
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
 
NFA Converted to DFA , Minimization of DFA , Transition Diagram
NFA Converted to DFA , Minimization of DFA , Transition DiagramNFA Converted to DFA , Minimization of DFA , Transition Diagram
NFA Converted to DFA , Minimization of DFA , Transition Diagram
 
Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
 
Introduction to fa and dfa
Introduction to fa  and dfaIntroduction to fa  and dfa
Introduction to fa and dfa
 
Theory of computation and automata
Theory of computation and automataTheory of computation and automata
Theory of computation and automata
 
Finite automata-for-lexical-analysis
Finite automata-for-lexical-analysisFinite automata-for-lexical-analysis
Finite automata-for-lexical-analysis
 
Nondeterministic Finite Automat
Nondeterministic Finite AutomatNondeterministic Finite Automat
Nondeterministic Finite Automat
 
Theory of computation and automata
Theory of computation and automataTheory of computation and automata
Theory of computation and automata
 
Nondeterministic Finite Automata
Nondeterministic Finite AutomataNondeterministic Finite Automata
Nondeterministic Finite Automata
 
NFA DFA Equivalence theorem
NFA DFA Equivalence theorem NFA DFA Equivalence theorem
NFA DFA Equivalence theorem
 

Viewers also liked

Viewers also liked (10)

Kharakteristika napoleon
Kharakteristika napoleonKharakteristika napoleon
Kharakteristika napoleon
 
Napoleon
NapoleonNapoleon
Napoleon
 
Śniadanie Daje Moc
Śniadanie Daje MocŚniadanie Daje Moc
Śniadanie Daje Moc
 
Test
TestTest
Test
 
Śniadanie Daje Moc
Śniadanie Daje MocŚniadanie Daje Moc
Śniadanie Daje Moc
 
Naruto 43
Naruto 43Naruto 43
Naruto 43
 
Hello Watch! Build your First Apple Watch App
Hello Watch! Build your First Apple Watch AppHello Watch! Build your First Apple Watch App
Hello Watch! Build your First Apple Watch App
 
Corals i orquestra Orff
Corals i orquestra OrffCorals i orquestra Orff
Corals i orquestra Orff
 
Software Engineering unit 2
Software Engineering unit 2Software Engineering unit 2
Software Engineering unit 2
 
Radnor Township Stormwater Program
Radnor Township Stormwater ProgramRadnor Township Stormwater Program
Radnor Township Stormwater Program
 

Similar to flat unit1

Mba ebooks ! Edhole
Mba ebooks ! EdholeMba ebooks ! Edhole
Mba ebooks ! EdholeEdhole.com
 
@vtucode.in-module-1-21CS51-5th-semester (1).pdf
@vtucode.in-module-1-21CS51-5th-semester (1).pdf@vtucode.in-module-1-21CS51-5th-semester (1).pdf
@vtucode.in-module-1-21CS51-5th-semester (1).pdfFariyaTasneem1
 
03-FiniteAutomata.pptx
03-FiniteAutomata.pptx03-FiniteAutomata.pptx
03-FiniteAutomata.pptxssuser47f7f2
 
Theory of automata
Theory of automataTheory of automata
Theory of automataArslan905905
 
deterministicfiniteautomatondfa-181008145215 (1).pdf
deterministicfiniteautomatondfa-181008145215 (1).pdfdeterministicfiniteautomatondfa-181008145215 (1).pdf
deterministicfiniteautomatondfa-181008145215 (1).pdfAmayJaiswal4
 
introduction-190804060837.pptx
introduction-190804060837.pptxintroduction-190804060837.pptx
introduction-190804060837.pptxshumPanwar
 
FiniteAutomata_anim.pptx
FiniteAutomata_anim.pptxFiniteAutomata_anim.pptx
FiniteAutomata_anim.pptxamara jyothi
 
FiniteAutomata_anim.pptx
FiniteAutomata_anim.pptxFiniteAutomata_anim.pptx
FiniteAutomata_anim.pptxranjan317165
 
1.3.1 deterministic finite automaton
1.3.1 deterministic finite automaton1.3.1 deterministic finite automaton
1.3.1 deterministic finite automatonSampath Kumar S
 
closure properties of regular language.pptx
closure properties of regular language.pptxclosure properties of regular language.pptx
closure properties of regular language.pptxThirumoorthy64
 
FiniteAutomata_anim.pptx
FiniteAutomata_anim.pptxFiniteAutomata_anim.pptx
FiniteAutomata_anim.pptxMeghnadh
 
Preparatory_questions_final_exam_DigitalElectronics1 (1).pdf
Preparatory_questions_final_exam_DigitalElectronics1 (1).pdfPreparatory_questions_final_exam_DigitalElectronics1 (1).pdf
Preparatory_questions_final_exam_DigitalElectronics1 (1).pdfrdjo
 
In the automata theory, a nondeterministic finite.pdf
                     In the automata theory, a nondeterministic finite.pdf                     In the automata theory, a nondeterministic finite.pdf
In the automata theory, a nondeterministic finite.pdfannesmkt
 
Theory of Computation FSM Conversions and Problems
Theory of Computation FSM Conversions and ProblemsTheory of Computation FSM Conversions and Problems
Theory of Computation FSM Conversions and ProblemsRushabh2428
 

Similar to flat unit1 (20)

Mba ebooks ! Edhole
Mba ebooks ! EdholeMba ebooks ! Edhole
Mba ebooks ! Edhole
 
@vtucode.in-module-1-21CS51-5th-semester (1).pdf
@vtucode.in-module-1-21CS51-5th-semester (1).pdf@vtucode.in-module-1-21CS51-5th-semester (1).pdf
@vtucode.in-module-1-21CS51-5th-semester (1).pdf
 
03-FiniteAutomata.pptx
03-FiniteAutomata.pptx03-FiniteAutomata.pptx
03-FiniteAutomata.pptx
 
Theory of automata
Theory of automataTheory of automata
Theory of automata
 
deterministicfiniteautomatondfa-181008145215 (1).pdf
deterministicfiniteautomatondfa-181008145215 (1).pdfdeterministicfiniteautomatondfa-181008145215 (1).pdf
deterministicfiniteautomatondfa-181008145215 (1).pdf
 
TOC Introduction
TOC Introduction TOC Introduction
TOC Introduction
 
Unit iv
Unit ivUnit iv
Unit iv
 
CS 5th.pptx
CS 5th.pptxCS 5th.pptx
CS 5th.pptx
 
5. NFA & DFA.pdf
5. NFA & DFA.pdf5. NFA & DFA.pdf
5. NFA & DFA.pdf
 
introduction-190804060837.pptx
introduction-190804060837.pptxintroduction-190804060837.pptx
introduction-190804060837.pptx
 
FiniteAutomata_anim.pptx
FiniteAutomata_anim.pptxFiniteAutomata_anim.pptx
FiniteAutomata_anim.pptx
 
FiniteAutomata_anim.pptx
FiniteAutomata_anim.pptxFiniteAutomata_anim.pptx
FiniteAutomata_anim.pptx
 
Automata
AutomataAutomata
Automata
 
Finite automata
Finite automataFinite automata
Finite automata
 
1.3.1 deterministic finite automaton
1.3.1 deterministic finite automaton1.3.1 deterministic finite automaton
1.3.1 deterministic finite automaton
 
closure properties of regular language.pptx
closure properties of regular language.pptxclosure properties of regular language.pptx
closure properties of regular language.pptx
 
FiniteAutomata_anim.pptx
FiniteAutomata_anim.pptxFiniteAutomata_anim.pptx
FiniteAutomata_anim.pptx
 
Preparatory_questions_final_exam_DigitalElectronics1 (1).pdf
Preparatory_questions_final_exam_DigitalElectronics1 (1).pdfPreparatory_questions_final_exam_DigitalElectronics1 (1).pdf
Preparatory_questions_final_exam_DigitalElectronics1 (1).pdf
 
In the automata theory, a nondeterministic finite.pdf
                     In the automata theory, a nondeterministic finite.pdf                     In the automata theory, a nondeterministic finite.pdf
In the automata theory, a nondeterministic finite.pdf
 
Theory of Computation FSM Conversions and Problems
Theory of Computation FSM Conversions and ProblemsTheory of Computation FSM Conversions and Problems
Theory of Computation FSM Conversions and Problems
 

Recently uploaded

SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 

Recently uploaded (20)

SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 

flat unit1

  • 1. Unit1 Formal Languages and Automata Theory 06CS56 DEFINITION OF DETERMINISTIC FINITE AUTOMATON Let Q be a finite set and let be a finite set of symbols. Also let be a function from Q X to Q, let q0 be a state in Q and let A be a subset of Q. We call the elements of Q a state, the transition function, q0 the initial state and A the set of accepting states. Then a deterministic finite automaton is a 5-tuple < Q, , q0 , , A > 1. The set Q in the above definition is simply a set with a finite number of elements. Its elements can, however, be interpreted as a state that the system (automaton) is in. Thus in the example of vending machine, for example, the states of the machine such as "waiting for a customer to put a coin in", "have received 5 cents" etc. are the elements of Q. "Waiting for a customer to put a coin in" can be considered the initial state of this automaton and the state in which the machine gives out a soda can be considered the accepting state. 2. The transition function is also called a next state function meaning that the automaton moves into the state (q, a) if it receives the input symbol a while in state q. Thus in the example of vending machine, if q is the initial state and a nickel is put in, then (q, a) is equal to "have received 5 cents". 3. Note that is a function. Thus for each state q of Q and for each symbol a of , (q, a) must be specified. 4. The accepting states are used to distinguish sequences of inputs given to the finite automaton. If the finite automaton is in an accepting state when the input ceases to come, the sequence of input symbols given to the finite automaton is "accepted". Otherwise it is not accepted. For example, in the Example 1 below, the string a is accepted by the finite automaton. But any other strings such as aa, aaa, etc. are not accepted. 5. A deterministic finite automaton is also called simply a "finite automaton". Abbreviations such as FA and DFA are used to denote deterministic finite automaton. DFAs are often represented by digraphs called (state) transition diagram. The vertices (denoted by single circles) of a transition diagram represent the states of the DFA and the arcs labeled with an input symbol correspond to the transitions. An arc ( p , q ) from vertex p to vertex q with label represents the transition (p, ) = q . The accepting states are indicated by double circles. Transition functions can also be represented by tables as seen below. They are called transition table. Examples of finite automaton Example 1: Q = { 0, 1, 2 }, = { a }, A = { 1 }, the initial state is 0 and is as shown in the following table. State (q) a 0 1 1 2 2 2
  • 2. A state transition diagram for this DFA is given below If the alphabet of the Example 1 is changed to { a, b } in stead of { a }, then we need a DFA such as shown in the following example to accept the same string a. It is a little more complex DFA. Example 2: Q = { 0, 1, 2 }, = { a, b }, A = { 1 }, the initial state is 0 and is as shown in the following table. Note that for each state there are two rows in the table for corresponding to the symbols a and b, while in the Example 1 there is only one row for each state. A state transition diagram for this DFA is given below. A DFA that accepts all strings consisting of only symbol a over the alphabet { a, b } is the next example. Example 3: Q = { 0, 1 }, = { a, b }, A = { 0 }, the initial state is 0 and is as shown in the following table. A state transition diagram for this DFA is given below. State (q) a b 0 1 2 *1 2 2 2 2 2 State (q) a b 0 0 1 1 1 1
  • 3. A finite automaton as a machine A finite automaton can also be thought of as the device shown below consisting of a tape and a control circuit which satisfy the following conditions: 1. The tape has the left end and extends to the right without an end. 2. The tape is divided into squares in each of which a symbol can be written prior to the start of the operation of the automaton. 3. The tape has a read only head. 4. The head is always at the leftmost square at the beginning of the operation. 5. The head moves to the right one square every time it reads a symbol. It never moves to the left. When it sees no symbol, it stops and the automaton terminates its operation. 6. There is a finite control which determines the state of the automaton and also controls the movement of the head Operation of finite automata Let us see how an automaton operates when it is given some inputs. As an example let us consider the DFA of Example 3 above. Initially it is in state 0. When zero or more a's are given as an input to it, it stays in state 0 while it reads all the a's (without breaks) on the tape. Since the state 0 is also the accepting state, when all the a's on the tape are read, the DFA is in the accepting state. Thus this automaton accepts any string of a's. If b is read while it is in state 0 (initially or after reading some a's), it moves to state 1. Once it gets to state 1, then no matter what symbol is read, this DFA never leaves state 1. Hence when b appears anywhere in the input, it goes into state 1 and the input string is not accepted by the DFA. For example strings aaa, aaaaaa etc. are accepted but strings such as aaba, b etc. are not accepted by this automaton. Draw a DFA to accept string of 0’s and 1’s ending with the string 011. Obtain a DFA to accept strings of a’s and b’s having a sub string aa q3q1 q2q0 1 0 0 0 1 1 10 q2q1 b q0 a a b a,b
  • 4. Obtain a DFA to accept strings of a’s and b’s except those containing the substring aab. Obtain DFAs to accept strings of a’s and b’s having exactly one a, Obtain a DFA to accept strings of a’s and b’s having even number of a’s and b’s Obtain a DFA to accept strings of a’s and b’s having even number of a’s and odd number of b’s. Obtain a DFA to accept strings of a’s and b’s having odd number of a’s and even number of b’s. Obtain a DFA to accept strings of a’s and b’s having odd number of a’s and odd number of b’s. Regular language Definition: Let M = (Q, , , q0, A) be a DFA. The language L is regular if there exists a machine M such that L = L(M). q3 a ba q2q1q0 a,bb b a q1q0 b a,b a q2 b a q1q0 b q2 b a a b q3 b a a q1q0 b q2 b a a b q3 b a a q1q0 b q2 b a a b q3 b a a q1q0 b q2 b a a b q3 b a a
  • 5. Applications of Finite Automata String matching/processing Compiler Construction The various compilers such as C/C++, Pascal, FORTRAN or any other compiler is designed using the finite automata. The DFAs are extensively used in the building the various phases of compiler such as  Lexical analysis (To identify the tokens, identifiers, to strip of the comments etc.)  Syntax analysis (To check the syntax of each statement or control statement used in the program)  Code optimization (To remove the un wanted code)  Code generation (To generate the machine code) Other applications The concept of finite automata is used in wide applications. It is not possible to list all the applications as there are infinite numbers of applications. This section lists some applications: 1. Large natural vocabularies can be described using finite automaton which includes the applications such as spelling checkers and advisers, multi-language dictionaries, to indent the documents, in calculators to evaluate complex expressions based on the priority of an operator etc. to name a few. Any editor that we use uses finite automaton for implementation. 2. Finite automaton is very useful in recognizing difficult problems i.e., sometimes it is very essential to solve an un-decidable problem. Even though there is no general solution exists for the specified problem, using theory of computation, we can find the approximate solutions. 3. Finite automaton is very useful in hardware design such as circuit verification, in design of the hardware board (mother board or any other hardware unit), automatic traffic signals, radio controlled toys, elevators, automatic sensors, remote sensing or controller etc. 4. In game theory and games wherein we use some control characters to fight against a monster, economics, computer graphics, linguistics etc., finite automaton plays a very important role. Non deterministic finite automata (NFA) Definition: An NFA is a 5-tuple or quintuple M = (Q, , , q0, A) where Q is non-empty, finite set of states.  is non-empty, finite set of input alphabets.  is transition function which is a mapping from Q x { U } to subsets of 2Q. This function shows the change of state from one state to a set of states based on the input symbol. q0  Q is the start state. A  Q is set of final states. Acceptance of language Definition: Let M = (Q, , , q0, A) be a DFA where Q is set of finite states,  is set of input alphabets (from which a string can be formed),  is transition function from Q x {U} to 2Q, q0 is the start state and A is the final or accepting state. The string (also called language) w accepted by an NFA can be defined in formal notation as: L(M) = { w | w  *and *(q0, w) = Q with atleast one Component of Q in A} Obtain an NFA to accept the following language L = {w | w  ababn or aban where n  0} The machine to accept either ababn or aban where n  0 is shown below: b q1 a q3q2 b a q4 q5 a q6 a b q7 q0  
  • 6.  Q 2.1 Conversion from NFA to DFA Let MN = (QN, N, N, q0, AN) be an NFA and accepts the language L(MN). There should be an equivalent DFA MD = (QD, D, D, q0, AD) such that L(MD) = L(MN). The procedure to convert an NFA to its equivalent DFA is shown below: Step1: The start state of NFA MN is the start state of DFA MD. So, add q0(which is the start state of NFA) to QD and find the transitions from this state. The way to obtain different transitions is shown in step2. Step2: For each state [qi, qj,….qk] in QD, the transitions for each input symbol in  can be obtained as shown below: 1. D([qi, qj,….qk], a) = N(qi, a) U N(qj, a) U ……N(qk, a) = [ql, qm,….qn] say. 2. Add the state [ql, qm,….qn] to QD, if it is not already in QD. 3. Add the transition from [qi, qj,….qk] to [ql, qm,….qn] on the input symbol a iff the state [ql, qm,….qn] is added to QD in the previous step. Step3: The state [qa, qb,….qc]  QD is the final state, if at least one of the state in qa, qb, ….. qc  AN i.e., at least one of the component in [qa, qb,….qc] should be the final state of NFA. Step4: If epsilon () is accepted by NFA, then start state q0 of DFA is made the final state. Convert the following NFA into an equivalent DFA. Step1: q0 is the start of DFA (see step1 in the conversion procedure). So, QD = {[q0]} (2.7) Step2: Find the new states from each state in QD and obtain the corresponding transitions. Consider the state [q0]: When a = 0 D([q0], 0) = = N([q0], 0) [q0, q1] (2.8) When a = 1 D([q0], 1) = = N([q0], 1) [q1] (2.9) Since the states obtained in (2.8) and (2.9) are not in QD(2.7), add these two states to QD so that QD = {[q0], [q0, q1], [q1] } (2.10) The corresponding transitions on a = 0 and a = 1 are shown below.  0 1 [q0] [q0, q1] [q1] [q0, q1] [q1] q1q0 0 1 0,1 q2 0, 1
  • 7.  Q  Q Consider the state [q0, q1]: When a = 0 D([q0, q1], 0) = = = = N([q0, q1], 0) N(q0, 0) U N(q1, 0) {q0, q1} U {q2} [q0, q1, q2] (2.11) When a = 1 D([q0, q1], 1) = = = = N([q0, q1], 1) N(q0, 1) U N(q1, 1) {q1} U {q2} [q1, q2] (2.12) Since the states obtained in (2.11) and (2.12) are the not defined in QD(see 2.10), add these two states to QD so that QD = {[q0], [q0, q1], [q1], [q0, q1, q2], [q1, q2] } (2.13) and add the transitions on a = 0 and a = 1 as shown below: Consider the state [q1]: When a = 0 D([q1], 0) = = N([q1], 0) [q2] (2.14) When a = 1 D([q1], 1) = = N([q1], 1) [q2] (2.15) Since the states obtained in (2.14) and (2.15) are same and the state q2 is not in QD(see 2.13), add the state q2 to QD so that QD = {[q0], [q0, q1], [q1], [q0, q1, q2], [q1, q2], [q2]} (2.16) and add the transitions on a = 0 and a = 1 as shown below:  0 1 [q0] [q0, q1] [q1] [q0, q1] [q0, q1, q2] [q1, q2] [q1] [q0, q1, q2] [q1, q2]  0 1 [q0] [q0, q1] [q1] [q0, q1] [q0, q1, q2] [q1, q2] [q1] [q2] [q2] [q0, q1, q2] [q1, q2] [q2]
  • 8.  Q Q  Consider the state [q0,q1,q2]: When a = 0 D([q0,q1,q2], 0) = = = = N([q0,q1,q2], 0) N(q0, 0) U N(q1, 0) U N(q2, 0) {q0,q1} U {q2} U {} [q0,q1,q2] (2.17) When a = 1 D([q0,q1,q2], 1) = = = = N([q0,q1,q2], 1) N(q0, 1) U N(q1, 1) U N(q2, 1) {q1} U {q2} U {q2} [q1, q2] (2.18) Since the states obtained in (2.17) and (2.18) are not new states (are already in QD, see 2.16), do not add these two states to QD. But, the transitions on a = 0 and a = 1 should be added to the transitional table as shown below: Consider the state [q1,q2]: When a = 0 D([q1,q2], 0) = = = = N([q1,q2], 0) N(q1, 0) U N(q2, 0) {q2} U {} [q2] (2.19) When a = 1 D([q1,q2], 1) = = = = N([q1,q2], 1) N(q1, 1) U N(q2, 1) {q2} U {q2} [q2] (2.20) Since the states obtained in (2.19) and (2.20) are not new states (are already in QD see 2.16), do not add these two states to QD. But, the transitions on a = 0 and a = 1 should be added to the transitional table as shown below:  0 1 [q0] [q0, q1] [q1] [q0, q1] [q0, q1, q2] [q1, q2] [q1] [q2] [q2] [q0, q1, q2] [q0,q1,q2] [q1, q2] [q1, q2] [q2]  0 1 [q0] [q0, q1] [q1] [q0, q1] [q0, q1, q2] [q1, q2] [q1] [q2] [q2] [q0, q1, q2] [q0,q1,q2] [q1, q2] [q1, q2] [q2] [q2] [q2]
  • 9. Consider the state [q2]: When a = 0 D([q2], 0) = = N([q2], 0) {} (2.21) When a = 1 D([q2], 1) = = N([q2], 1) [q2] (2.22) Since the states obtained in (2.21) and (2.22) are not new states (are already in QD, see 2.16), do not add these two states to QD. But, the transitions on a = 0 and a = 1 should be added to the transitional table. The final transitional table is shown in table 2.14. and final DFA is shown in figure 2.35. The DFA  0 1 [q0] [q0, q1] [q1] [q0, q1, q2] [q1, q2] [q2] [q2] [q0,q1,q2] [q1, q2] [q2] [q2] [q2]  [q2] [q2 ] [q1 ] [q0 ] [q0 , q1 ] [q1 , q2 ][q0 , q1 , q2 ] 0 1 0 1 0, 1 0, 1 0 1 1 [q0,q1] [q1] [q0,q1,q2] [q1,q2]