1. Automata theory is the study of abstract machines and the problems they are able to solve. It is closely related to formal language theory as automata are often classified by the formal languages they can recognize.
2. A finite automaton is an abstract machine that consists of a finite number of states. It reads an input string and based on its current state and the next input symbol, transitions to the next state according to its transition function. If it ends in an accepting state, the input is accepted.
3. Deterministic finite automata (DFAs) are a type of finite automaton where the transition function maps each state-symbol pair to a unique next state. DFAs can be represented
2. Theory of Computation
In theoretical computer science and mathematics,
the theory
of computation is the branch that deals with how efficiently
problems can be solved on a model of computation, using an
algorithm. The field is divided into three major branches:
• automata theory,
• computability theory
• computational complexity theory.
Er. Deepinder Kaur 2Automata Theory
3. Automata theory
• The word “Automata“ is the plural of “automaton" which
simply means any machine.
• automata theory is the study of abstract machines and
problems they are able to solve.
• Automata theory is closely related to formal language
theory as the automata are often classified by the class of
formal languages they are able to recognize.
Er. Deepinder KaurAutomata Theory 3
4. Abstract Machine
• An abstract machine, also called an abstract computer, is a
theoretical model of a computer hardware or software system
used in Automata theory.
Er. Deepinder KaurAutomata Theory 4
5. Applications of Automata
• A variety of properties concerning the models, grammars, and
languages will be proven.
• These algorithms form the basis of tools for processing languages,
e.g., parsers, compilers, assemblers, etc.
• Other algorithms will form the basis of tools that automatically
construct language processors, e.g., yacc, lex, etc.
– Note that our perspective will be similar to, yet different from a compiler
class.
• Additionally, some things will be proven to be non-computable,
e.g., the enhanced compiler.
Automata Theory 5Er. Deepinder Kaur
6. Automaton
• An automaton is an abstract model of a digital
computer
• It has a mechanism to read input (string over a given
alphabet, e.g. strings of 0’s and 1’s on Σ = {0,1})
written on an input file.
• A finite automaton has a set of states
• Its control moves from state to state in response to
external “inputs”
Automata Theory 6Er. Deepinder Kaur
7. Automaton
• With every automaton, a transition function is
associated which gives the next state in terms of
the current state
• An automaton can be represented by a graph in
which the vertices give the internal states and the
edges transitions
• The labels on the edges show what happens (in
terms of input and output) during the transitions
Automata Theory 7Er. Deepinder Kaur
8. Components of an automaton
• Input file : Contains strings of input symbols
• Storage unit: consists of an unlimited number of
cells, each capable of holding a single symbol
from an alphabet
• Control unit : can be in any one of a finite
number of internal states and can change states
in defined manner
Automata Theory 8Er. Deepinder Kaur
9. Some Terms used in automaton theory
• Alphabets-Everything in mathematics is based on symbols. This
is also true for automata theory. Alphabets are
defined as a finite set of symbols. An example of
alphabet is a set of decimal numbers
∑={0,1,2,3,4,5,6,7,8,9}
• Strings- A string is a finite sequence of symbols selected from some
alphabet
If ∑ {a,b} is an alphabet then abab is string over alphabet ∑. A
string is generally denoted by w. The length of string is denoted by |
w|
• Empty string is string with zero occurrence of symbols . This string is
represented by є
Automata Theory 9Er. Deepinder Kaur
10. • The set of strings, including empty, over an alphabet ∑ is
denoted by ∑*.
• ∑+
= ∑* -{є}
• Languages-A set of strings which are chosen from some ∑*,
where ∑ is a particular alphabet, is called a language . If ∑ is
an alphabet, and L subset of ∑*, then L is said to be
language over alphabet ∑. For example the language of all
strings consisting of n 0’s followed by n 1’s for some n>=0:
{є,01,0011,000111,-------}
Automata Theory 10Er. Deepinder Kaur
11. • Langauge in set forms-
{w|some logical view about w}
e.g {an
bn
|n>=1}
• Kleene closure- Given an alphabet, a language in
which any string of letters from ∑ is a word, even
the null string, is called closure of the alphabet . It is
denoted by writing a star, after the name of
alphabet as a superscript ∑*.
Automata Theory 11Er. Deepinder Kaur
12. Finite Automaton
• One of the powerful models of computation which
are restricted model of actual computer is called
finite automata. These machines are very similar to
CPU of a computer .They are restricted model as
they lack memory.
• Finite automation is called finite because number of
possible states and number of letter in alphabet are
both finite and automation because the change of
state is totally governed by the input.
Automata Theory 12Er. Deepinder Kaur
13. 2.2 Deterministic Finite Automata
– graphic model for a DFA
13Automata Theory Er. Deepinder Kaur
14. Main parts of pictorial representation of Finite
machine
• Strings are fed into device by means of an input tape which is
divided into square with each symbol in each square.
• Main part of machine is a black box which serve that what symbol is
written at any position on input tape by means of a movable
reading head
• P0,p1,p2,p3,p4 are the states in finite control system and x and y
are input symbols.
• At regular intervals, the automation reads one symbol from input
tape and then enters in a new state that depends only on current
state and the symbol just read.
Automata Theory 14Er. Deepinder Kaur
15. Main parts of pictorial representation of Finite
machine
• After reading an input symbol, reading head moves one square to
the right on input tape so that on next move, it will read the symbol
in next tape square. This process is repeated again and again
• Automation then indicates approval or disapproval
• If it winds up in one of the final states, the input string is considered
to be accepted. The language accepted by the machine is the set of
strings it accepts.
Automata Theory 15Er. Deepinder Kaur
16. DFA:
Deterministic Finite Automaton
• An informal definition (formal version later):
– A diagram with a finite number of states represented
by circles
– An arrow points to one of the states, the unique start
state
– Double circles mark any number of the states as
accepting states
– For every state, for every symbol in Σ, there is exactly
one arrow labeled with that symbol going to another
state (or back to the same state)
Automata Theory
Er. Deepinder Kaur
17. Finite Automata FA
• Its goal is to act as a recognizer for specific a
language/pattern.
• Any problem can be presented in form of
decidable problem that can be answered by
Yes/No.
• Hence FA (machine with limited memory) can
solve any problem.
17Automata Theory Er. Deepinder Kaur
18. Deterministic Finite Automata DFA
FA = “a 5-tuple “ (Q, Σ, , q0, F)
1. Q: {q0, q1, q2, …} is set of states.
2. Σ: {a, b, …} set of alphabet.
3. (delta): represents the set of transitions that FA can
take between its states.
: Q x Σ→Q
Q x Σ to Q, this function:
Takes a state and input symbol as arguments.
Returns a single state.
: Q x Σ→Q
4. q0 Q is the start state.
5. F Q is the set of final/accepting states.
18
∈
⊂
Automata Theory Er. Deepinder Kaur
19. Transition function
: Q x Σ→Q
Maps from domain of (states, letters) to range
of states.
19
(q0, a)
(q2, b)
(q1, b)
q1
q2
q3
Automata Theory Er. Deepinder Kaur
20. Transition function
• : Q x Σ→Q
• Maps from domain of (states, letters) to range
of states.
20
(q0, a)
(q2, b)
(q1, b)
q1
q2
q3
Automata Theory Er. Deepinder Kaur
21. How does FA work?
1. Starts from a start state.
2. Loop
Reads a sequence of letters
1. Until input string finishes
2. If the current state is a final state then
Input string is accepted.
1. Else
Input string is NOT accepted.
• But how can FA be designed and represented?
21Automata Theory Er. Deepinder Kaur
22. Transition System
FA = “a 5-tuple “ (Q, Σ, , q0, F)
1. Q: {q0, q1, q2, …} is set of states.
2. Σ: {a, b, …} set of alphabet.
3. (delta): represents the set of transitions that FA can
take between its states.
: Q x Σ→Q
Q x Σ to Q, this function:
Takes a state and input symbol as arguments.
Returns a single state.
: Q x Σ→Q
4. q0 Q is the start state.
5. F Q is the set of final/accepting states.
22
∈
⊂
Automata Theory Er. Deepinder Kaur
24. Transition Diagram Notations
• If any state q in Q is the starting state then
it is represented by the circle with arrow as
• Nodes corresponding to accepting states
are marked by a double circle
q
Automata Theory 24Er. Deepinder Kaur
25. Transition Diagram
Can be represented by directed labeled graph/Transition table
Vertex is a state
States= nodes
Starting/Initial state denoted by circle and arrow/-
Final state(s) denoted by two concentric circles/+
Other states with circle
Transition function =directed arrows connecting states.
25
S1
S2
b
a a,b
Automata Theory Er. Deepinder Kaur
27. Acceptability of a string
A string is accepted by a transition system if
• There exist a path from initial state to final
state
• Path traversed is equal to w
27Automata Theory Er. Deepinder Kaur
28. Example1.1
• Build an FA that accepts only aab
28
S1
-
S3
a
S2
a b
+
S4
a b
S1 S2 ?
S2 S3 ?
S3 ? ?
S4 ? ?
Automata Theory Er. Deepinder Kaur
31. Automata Theory 31
Properties of transition function
1. (q,λ)=q
• It comes back to same state
• It requires an input symbol to change the
state of a system.
2. (q,aw)=((q,a),w)
(q,w,a)=((q,w),a)
Er. Deepinder Kaur
32. Facts in designing FA
First of all we have to analyze set of strings.
Make sure that every state is check for output state
and for every input symbol from given set.
No state must have two different outputs for single
input symbol
There must be one initial and atleast one final state
in FA
32Automata Theory Er. Deepinder Kaur
33. Language of a DFA
• Automata of all kinds define languages.
• If A is an automaton, L(A) is its language.
• For a DFA A, L(A) is the set of strings
labeling paths from the start state to a final
state.
• Formally: L(A) = the set of strings w such
that δ(q0, w) is in F.
33Automata Theory Er. Deepinder Kaur
34. Language
• A language is a set of strings.
For example, {0, 1}, {all English words}, {0, 0, 0, ...} are
all languages.
Automata Theory 34Er. Deepinder Kaur
35. Example #8:
• Let Σ = {0, 1}. Give DFAs for {}, {ε}, Σ*
, and Σ+
.
For {}:
For Σ*
: For Σ+
:
Er. Deepinder Kaur
0/1
q0
0/1
q0
0/1
q0 q1
0/1
Automata Theory 35
36. Example: Design a FA that accepts set of strings such that every string
ends in 00, over the alphabet
{0,1} i,e ∑={0, 1}
Inorder to design any FA, first try to fulfill the
minimum condition.
Start 0 0 0
Being DFA, we must check every input symbol for
output state from every state. So we have to decide
output state at symbol 1 from q0,q1 and q2. Then it
will be complete FA
q0 q1 q2
Automata Theory 36Er. Deepinder Kaur
38. Ex 2 –
• Construct a DFA that accepts a’s and b’s and
‘aa’ must be substring
38Automata Theory Er. Deepinder Kaur
39. Example: String in a Language
39
Start
a
20 1
a
Minimal condition : aa
Automata Theory Er. Deepinder Kaur
40. Example: String in a Language
40
Start
There may be aabbaa.bbbbaa,aa,aab,aabb,….
a
20 1
a
b
Automata Theory Er. Deepinder Kaur
41. Example: String in a Language
41
Start
a
b
A CB
a
b a,b
.
Automata Theory Er. Deepinder Kaur
42. Ex : (0+1)*00(0+1)*
• Idea: Suppose the string x1x2 ···xn is on
the tape. Then we check x1x2, x2x3, ...,
xn-1xn in turn.
• Step 1. Build a checker
0 0
Automata Theory 42Er. Deepinder Kaur
43. • Step 2. Find all edges by the following
consideration:
Consider x1x2.
• If x1=1, then we give up x1x2 and continue to
check x2x3. So, we have δ(q0, 1) = q0.
• If x1x2 = 01, then we also give up x1x2 and
continue to check x2x3. So,
δ(q1, 1) = δ(q0, 1) =q0.
• If x1x2 = 00, then x1x2··· xn is accepted for any
x3···xn. So, δ(q2,0)=δ(q2,1)=q2.
Automata Theory 43Er. Deepinder Kaur
48. Ex4
• All words with even count of letters having “a” in an
even position from the start, where the first letter is
letter number one. (a+b)a((a+b)a)*
Automata Theory 48Er. Deepinder Kaur
53. Construct a FA that accepts set of strings where the number of 0s in
every string is multiple of 3 over alphabet ∑={0,1}
1 1 1
start 0 0
0
As 0 existence of 0 is also multiple of 3, we have to consider starting
state as the final state.
q1 q2q0
Automata Theory 53Er. Deepinder Kaur
54. Design FA which accepts set of strings containing exactly four
1s in every string over alphabet ∑={0,1}
1
q2q4q0 q1 q2
1 1
q3
1
0 0 0
0 0
q5
0/1
star
t
1
q5 is called the trap state or dead state.
Dead states are those states which
transit to themselves for all input
symbols.
Automata Theory 54Er. Deepinder Kaur
55. Design a FA that accepts strings containing exactly one 1 over alphabet
{0,1}. Also draw the transition table for the FA generated
q2q2q1
1
0 0
q3
0/1
1
start
q3 is the dead state
Automata Theory 55Er. Deepinder Kaur
56. Transition table for previous problem
δ/∑ 0 1
q1 q1 q2
*q2 q2 q3
q3 q3 q3
Non final state that transit in
self loop for all inputs
Automata Theory 56Er. Deepinder Kaur
57. Design an FA that accepts the language
L={w ϵ (0,1)*/ second symbol of w is ‘0’ and fourth input is ‘1’}
q0 q3q1 q2
0 1
1/0
1
1/0
0
1/0
q5
0/1
start
q4
Automata Theory 57Er. Deepinder Kaur
58. Design DFA for the language
L={w ϵ (a,b)*/nb(w) mod 3 > 1}
As given in the language, this can be interpreted that number of b mod 3 has to be
greater than 1 and there is no restriction on number of a’s. Thus it will accept string with
2 bs,5 bs, 8bs and so on.
q0 q1 q2
b b
a a
a
b
star
t
Q={q0,q1,q2}
F={q2}
Automata Theory 58Er. Deepinder Kaur
59. Design FA over alphabet ∑= {0,1} which accepts the set of strings either
start with 01 or end with 01
q0 q1
q3
q4
q2
0 1
1/0
q5
1
0
1
0
1
0
0
1
start
Automata Theory 59Er. Deepinder Kaur
60. Example #4:
• Give a DFA M such that:
L(M) = {x | x is a string of 0’s and 1’s and |x| >= 2}
Er. Deepinder Kaur
q1
q0
q2
0/1
0/1
0/1
Automata Theory 60
61. Example #5:
• Give a DFA M such that:
L(M) = {x | x is a string of (zero or more) a’s and b’s such
that x does not contain the substring aa}
Er. Deepinder Kaur
q2q0
a
a/b
a
q1
b
b
Automata Theory 61
62. Example #6:
• Give a DFA M such that:
L(M) = {x | x is a string of a’s, b’s and c’s such that x
contains the substring aba}
Er. Deepinder Kaur
q2q0
a
a/b
b
q1
b a
b
q3
a
Automata Theory 62
63. DFA Practice
• Design a FA which accepts the only input 101
over input set {0,1}
• Strings that end in ab
• Strings that contain aba
• String start with 0 and ends with 1 over {0,1}
• Strings made up of letters in word ‘CHARIOT’
and recognize those strings that contain the
word ‘CAT’ as a substringEr. Deepinder Kaur 63Automata Theory