Theory of Automata
Introduction
Prof. Dr. Muhammad Saleem Vighio (PhD)
Computer Science Department, Quaid-e-Awam University of
Engineering, Science & Technology, Nawabshah
Monday, 14/10/2024
1
Course Introduction
• Course [Link]:
• 03 [Link]:
- Theoretical work
• Recommended Textbooks:
• Introduction to Automata Theory, Languages and Computation
J.E. Hopcroft, R. Motwani, J.D. Ullman
3rd Edition (Addison Wesley/Pearson)
• Introduction to the Theory of Computation, 2nd Ed.
Michael Sipser
• Introduction to Computer Theory
Daniel I.A. Cohen
• Theory of Automata, Formal Languages and Computation
S. P. Eugene Xavier
• Online Literature
Course Introduction
• Teaching plan:
• 02 tests:
- At the end of 12th and 35th lectures respectively
• Class exercises
• Short presentations
• Practical exercises
Course Introduction
Lecture slides/announcements/results can be found at
course home page:
[Link]
[Link]
Course Outline
• Introduction
• Regular Languages and their descriptors
- Finite state automata
- Non-deterministic automata
- Regular expressions
- Algorithms to decide questions about regular languages,
e.g., is it empty?
- Closure properties of regular languages.
• Context Free Languages and their descriptors
- Context free grammars
- Pushdown automata
• Turing Machines and TM Variants
• Decidable and Undecidable Languages
• Time and Space Complexities
Lecture Outline
• Introduction
• Models of Computation
• Languages
What is Automata Theory?
• Automata, plural of “automaton” is a Greek word
meaning “self-acting, self-willed, self-moving".
• Study of abstract computing devices, or “machines”
• A “device” need not even be a physical hardware!
Logic behind electric bulb
7
Computation
• Computation is a general term for any type of
information processing that can be
represented as an algorithm precisely
(mathematically).
Examples:
• Adding two numbers in our brains, on a piece of
paper or using a calculator.
• Converting a decimal number to its binary
presentation or vice versa.
• Finding the greatest common divisors of two
numbers.
• …
Fundamental Idea
• To understand:
• What different types of computational models
exist and differ from each other,
• How do they compute functions and solve problems,
• What problems they can solve and cannot solve
(theory of computation)
History
• 1936 - Alan Turing studies abstract machines with
ability of today’s computers
• Algorithm and computation (decidability)
• Some computational problem can’t have algorithm (halting
problem)
Alan Turing
History
• 1943 - Finite automata – simple model of computation
• Originally proposed to model brain function
Warren McCulloch and Walter Pitts
(neurophysiologists)
History
1950 - Context-free grammar and context-sensitive
grammar – models of computation
• While not strictly machines, these grammars have close
relationships to abstract automata
• Used in compiler development
Noam Chomsky
History
1970 – Modern computer science – compiler, computational
& complexity theories evolve
Different Model of Computation
Automata are distinguished by the temporary memory
• Finite Automata: no temporary memory
• Pushdown Automata: stack
• Turing Machines: random access memory
14
Finite Automaton
temporary memory
input memory
Finite
Automaton
output memory
Example: Vending Machines
(small computing power)
15
Pushdown Automaton
Stack Push, Pop
input memory
Pushdown
Automaton
output memory
Example: Compilers for Programming Languages
(medium computing power)
16
Turing Machine
Random Access Memory
input memory
Turing
Machine
output memory
Examples: Any Algorithm
(highest computing power)
17
Power of Automata
Finite Pushdown Turing
Automata Automata Machine
Less power More power
Solve more
computational problems
18
Languages
19
A language is a set of strings
String: A sequence of letters
Examples: “cat”, “dog”, “house”, …
Defined over an alphabet:
Σ = {a, b, c, . . . , z}
20
Alphabets and Strings
We will use small alphabets: = a, b
Strings
a
ab u = ab
abba v = bbbaaa
baba w = abba
aaabbbaabab
21
String Operations: Concatenation
w = a1a2 an abba
v = b1b2 bm bbbaaa
Concatenation
wv = a1a2 anb1b2 bm abbabbbaaa
22
String Operations: Reverse
w = a1a2 an ababaaabbb
Reverse
w = an a2 a1
R
bbbaaababa
23
String Operations: String Length
w = a1a2 an
Length: w =n
Examples abba = 4
aa = 2
a =1
24
String Operations:
Length of Concatenation
uv = u + v
Examples u = aab, u = 3
v = abaab, v = 5
uv = aababaab = 8
uv = u + v = 3 + 5 = 8
25
String Operations: Empty String
A string with no letters:
Observations: =0
w = w = w
abba = abba = abba
26
String Operations: Substring
Substring of string:
a subsequence of consecutive characters
String Substring
abbab ab
abbab abba
abbab b
abbab bbab
27
String Operations: Prefix and Suffix
Example: abbab
prefixes Suffixes
abbab w = uv
a bbab
prefix
ab bab
suffix
abb ab
abba b
abbab
28
String Operations: Power
Wn = W1W2 Λ Wn
Example: (abba ) = abbaabba
2
Definition: w =
0
(abba ) =
0
29
String Operations: The * Operation
* : the set of all possible strings from
alphabet
= a, b
* = , a, b, aa, ab, ba, bb, aaa, aab,
30
String Operations: 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,
31
Languages
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}
32
Note that:
Sets = { } {}
Set size {} = = 0
Set size {} = 1
String length =0
33
Another Language Example
An infinite language L = {a b : n 0}
n n
ab
L abb L
aabb
aaaaabbbbb
34
Operations on Languages
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
35
Operations on Languages: Reverse
Definition: L = {w : w L}
R R
Examples: ab, aab, baba = ba, baa, abab
R
L = {a b : n 0}
n n
L = {b a : n 0}
R n n
36
Operations on Languages: Concatenation
Definition: L1L2 = xy : x L1, y L2
Example: a, ab, bab, aa
= ab, aaa, abb, abaa, bab, baaa
37
Operations on Languages: Power
Definition: L =
n
LL L
n
Example:
a, b = a, ba, ba, b =
3
aaa, aab, aba, abb, baa, bab, bba, bbb
0
Special Case: L =
a , bba , aaa 0 =
38
More Examples
L = {a b : n 0}
n n
L = {a b a b : n, m 0}
2 n n m m
aabbaaabbb L 2
39
Operations on Languages:
Star-Closure (Kleene *)
Definition: L* = L L L
0 1 2
Example:
,
a, bb,
a, bb* =
aa , abb , bba , bbbb,
aaa, aabb, abba, abbbb,
40
Operations on Languages:
Positive Closure
Definition: +
L = L L
1 2
= L * −
a, bb,
+
a, bb = aa, abb, bba, bbbb,
aaa, aabb, abba, abbbb,
41
Automata Theory & Model Checking
“The automata- theoretic approach offers a uniform
algorithmic framework for model checking linear- time
properties1”
1Vardi,M. Y. (2007, January). Automata-theoretic model checking revisited. In International Workshop
on Verification, Model Checking, and Abstract Interpretation (pp. 137-150). Berlin, Heidelberg:
Springer Berlin Heidelberg.
Modelling & Verification Tools
• UPPAAL ([Link]
• SPIN
• PRISIM
• TLC, etc
Modelling & Verification Tools
• Recommended Tools:
• UPPAAL
[Link]
• Tool for the modelling, simulation and verification of
different types of computational algorithms: real-
time, embedded, and concurrent systems e.g.,
embedded processors in mobile phones, microwave
ovens, sensor nodes communicating with the
environment, traffic control systems and so on.
INPUT
UPPAAL
Application Bugs
Storm surge barrier Rotterdam
Storm Surge Barrier Rotterdam
Storm Surge Barrier Rotterdam
Storm Surge Barrier Rotterdam
• Year 1953
• Storm kills 1835 people in Netherlands
• Killed 200000 cattle,
• Flooding 2000 kilometer of land,
• Destroying 43000 homes,
• Forcing 720000 people to flee
Storm Surge Barrier Rotterdam
[Link]
_YwS1A
[Link]
HXt-PA