Professional Documents
Culture Documents
Introduction to Automata
Theory
2/4/2021
1
Models of Computation
2/4/2021 2
Computation
CPU memory
2/4/2021 3
temporary memory
input memory
CPU
output memory
Program memory
2/4/2021 4
Example: f ( x) x 3
temporary memory
input memory
CPU
output memory
Program memory
compute xx
2/4/2021
compute x x
2
5
f ( x) x 3
temporary memory
input memory
x2
CPU
output memory
Program memory
compute xx
2/4/2021
compute x x
2
6
temporary memory f ( x) x 3
z 2*2 4
f ( x) z * 2 8
input memory
x2
CPU
output memory
Program memory
compute xx
2/4/2021
compute x x
2
7
temporary memory f ( x) x 3
z 2*2 4
f ( x) z * 2 8
input memory
x2
CPU
f ( x) 8
Program memory output memory
compute xx
2/4/2021
compute x x
2
8
Automata theory is the study of
abstract machines and automata.
The computational problems can be
solved using them.
It is a theory in theoretical computer
science and discrete mathematics
2/4/2021 9
Automaton
temporary memory
Automaton
input memory
CPU
output memory
Program memory
2/4/2021 10
Different Kinds of Automata
Automata are distinguished by the temporary memory
2/4/2021 11
Finite Automaton
temporary memory
2/4/2021 12
Pushdown Automaton
Stack Push, Pop
2/4/2021 13
Turing Machine
input memory
Turing
Machine output memory
2/4/2021 14
Power of Automata
2/4/2021 15
Applications of finite automata
2/4/2021 16
Applications of Push Down Automata
For designing the parsing phase of a compiler (Syntax
Analysis).
For implementation of stack applications.
For evaluating the arithmetic expressions.
For solving the Tower of Hanoi Problem.
2/4/2021 17
Applications of Turing machine
2/4/2021 18
General Concepts of Automata Theory
• Alphabet
• Strings
• Empty Strings
• Length of the string
• Power of an Alphabet
• Concatenation of two strings
• Languages
2/4/2021
19
Alphabets and Strings
• We will use small alphabets: a, b
• Strings
a
ab u ab
abba
v bbbaaa
baba
aaabbbaabab w abba
2/4/2021
20
String Operations
1. Concatenation
2/4/2021
21
2.Reverse
w a1a2 an ababaaabbb
w R an a2 a1 bbbaaababa
3. String Length
w a1a2 an Examples:
abba 4
Length: w n aa 2
a 1
2/4/2021 22
4. Length of Concatenation
uv u v
• Example:
u aab, u 3
v abaab, v 5
uv aababaab 8
uv u v 3 5 8
2/4/2021
23
5. Empty String
• A string with no letters: or ϵ
• Observations:
0
w w w
2/4/2021
24
6. Substring
• Substring of string:
• a subsequence of consecutive characters
String Substring
abbab ab
abbab abba
abbab b
abbab bbab
2/4/2021
25
7. Prefix and Suffix
abbab
Prefixes Suffixes
abbab w uv
a bbab
ab bab prefix
abb ab suffix
abba b
abbab
2/4/2021
26
8. Another Operation
n
w ww
w
n
• Definition: w0
abba 0
2/4/2021
27
9. The * Operation
2/4/2021
28
10. The + Operation
: the set of all possible strings from
alphabet except
a, b
* , a, b, aa, ab, ba, bb, aaa, aab,
*
a, b, aa, ab, ba, bb, aaa, aab,
2/4/2021 29
Languages
• A language is a set of strings
2/4/2021
30
• A language is any subset of *
• Example:
a, b
* , a, b, aa, ab, ba, bb, aaa,
• Languages:
a, aa, aab
{ , abba, baba, aa, ab, aaaaaa}
2/4/2021
31
Note that
Sets { } {}
Set size {} 0
Set size {} 1
String length 0
2/4/2021 32
Another Example
An infinite language
L {a b : n 0}
n n
ab
L abb L
aabb
aaaaabbbbb
2/4/2021
33
Operations on Languages
1. The usual set operations
a, ab, aaaa bb, ab {a, ab, bb, aaaa}
a, ab, aaaa bb, ab {ab}
a, ab, aaaa bb, ab a, aaaa
Complement: L * L
a, ba , b, aa, ab, bb, aaa,
2/4/2021
34
• L1= { ab,abb}
• L2= { abb,ba}
• Find L1U L2 = { ab,abb,ba}
• L1 –L2 = { ab}
• L1 ⋅ 𝐿2= { abb}
2/4/2021
35
2. Reverse
Definition:
L {w : w L}
R R
Examples:
ab, aab, baba ba, baa, abab
R
L {a b : n 0}
n n
LR
{b a : n 0}
n n
2/4/2021
36
• L = { baa, ab,bb,aba }
• Find 𝐿𝑅
2/4/2021
37
3.Concatenation
2/4/2021
38
4. Another Operation
• Definition: Ln
LLL
n
2/4/2021
39
More Examples
L {a b : n 0}
n n
L {a b a b : n, m 0}
2 n n m m
2
aabbaaabbb L
2/4/2021
40
5. Star-Closure (Kleene *)
Definition:
L* L L L
0 1 2
,
• Example:
a, bb,
a, bb*
aa , abb, bba, bbbb,
aaa, aabb, abba, abbbb,
2/4/2021
41
6. Positive Closure
Definition:
L L L
1 2
L *
a, bb,
a, bb aa, abb, bba, bbbb,
aaa, aabb, abba, abbbb,
2/4/2021
42
Language Recognizers : An example of Finite
Automata
2/4/2021 43
Finite Automaton
Input
String
Output
“Accept”
Finite
or
Automaton
“Reject”
2/4/2021
44
Representation of Finite Automata
1. Transition Graph
2. Transition Table
3. Regular Expression
2/4/2021 45
2/4/2021 46
Transition Graph
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
initial accepting
state state state
transition
2/4/2021
47
Initial Configuration
Input String
a b b a
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
2/4/2021
48
Reading the Input
a b b a
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
2/4/2021
49
a b b a
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
2/4/2021
50
a b b a
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
2/4/2021
51
a b b a
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
2/4/2021
52
Input finished
a b b a
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
accept
2/4/2021 53
Rejection
a b a
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
2/4/2021
54
a b a
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
2/4/2021
55
a b a
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
2/4/2021
56
a b a
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
2/4/2021
57
Input finished
a b a
a, b
reject
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
2/4/2021 58
Another Rejection
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
2/4/2021
59
a, b
q5
a a, b
b a b
q0 a q1 b q2 b q3 a q4
reject
2/4/2021
60
Another Example
a a b
a a, b
q0 b q1 a, b q2
2/4/2021 61
a a b
a a, b
q0 b q1 a, b q2
2/4/2021 62
a a b
a a, b
q0 b q1 a, b q2
2/4/2021 63
a a b
a a, b
q0 b q1 a, b q2
2/4/2021 64
Input finished
a a b
a a, b
accept
q0 b q1 a, b q2
2/4/2021 65
Rejection Example
b a b
a a, b
q0 b q1 a, b q2
2/4/2021 66
b a b
a a, b
q0 b q1 a, b q2
2/4/2021 67
b a b
a a, b
q0 b q1 a, b q2
2/4/2021 68
b a b
a a, b
q0 b q1 a, b q2
2/4/2021 69
Input finished
b a b
a a, b
q0 b q1 a, b q2
reject
2/4/2021 70
Languages Accepted by FAs
Definition:
2/4/2021
71
Example
LM abba M
a, b
q5
b a a, b
a b
q0 a q1 b q2 b q3 a q4
accept
2/4/2021
72
Example
a, b
q5
b a a a, b
b
q0 a q1 b q2 b q3 a q4
accept accept accept
2/4/2021
73
Example
LM {a b : n 0}
n
a a, b
q0 b q1 a, b q2