1
An Introduction to Formal Languages and Automata
Provided by : Babak SalimiwebAdd: http://utopie.ir/
Email: [email protected]
2
Textbook:
Webadd: http://itla.ir/
What is automata theory ?
• Automata theory is the study of abstract computational devices
• Abstract devices are (simplified) models of real computations
• Computations happen everywhere: On your laptop, on your cell phone, in nature, …
• Why do we need abstract models?
A simple computer
BATTERY
SWITCH
input: switch
output: light bulb
actions: flip switch
states: on, off
A simple “computer”
BATTERY
SWITCH
off onstartf
f
input: switch
output: light bulb
actions: f for “flip switch”
states: on, off
bulb is on if and only if there was an odd number of flips
Another “computer”
BATTERY
off offstart1
inputs: switches 1 and 2
actions: 1 for “flip switch 1”
actions: 2 for “flip switch 2”
states: on, off
bulb is on if and only if both switches were flipped an odd number of times
1
2
1
off on1
1
2 2 2 2
A design problem
Can you design a circuit where the light is on if and only if all the switches were flipped exactly the same number of times?
4
BATTERY
1
23
5?
A design problem• Such devices are difficult to reason
about, because they can be designed in an infinite number of ways
• By representing them as abstract computational devices, or automata, we will learn how to answer such questions
These devices can model many things
• They can describe the operation of any “small computer”, like the control component of an alarm clock or a microwave
• They are also used in lexical analyzers to recognize well formed expressions in programming languages:
ab1 is a legal name of a variable in C
5u= is not
10
Computation
CPU memory
Outline of the course contents
11
CPU
input
output
Program memory
temporary memory
12
CPU
input
outputProgram memory
temporary memory
3)( xxf
compute xx
compute xx 2
Example:
13
CPU
input
outputProgram memory
temporary memory
3)( xxf
compute xx
compute xx 2
2x
14
CPU
input
outputProgram memory
temporary memory3)( xxf
compute xx
compute xx 2
2x
42*2 z82*)( zxf
15
CPU
input
outputProgram memory
temporary memory3)( xxf
compute xx
compute xx 2
2x
42*2 z82*)( zxf
8)( xf
16
Automaton
CPU
input
output
Program memory
temporary memory
Automaton
17
Automaton
input
output
temporary memory
Automaton
state
transition
18
Different Kinds of Automata
Automata are distinguished by the temporary memory
• Finite Automata: no temporary memory
• Pushdown Automata: stack
• Turing Machines: random access memory
19
input
output
temporary memory
Finite Automaton
Finite Automaton
Example: Elevators, Vending Machines
(small computing power)
20
input
output
Stack
Pushdown
Automaton
Pushdown Automaton
Example: Compilers for Programming Languages
(medium computing power)
Push, PopTemp.memory
21
input
output
Random Access Memory
Turing
Machine
Turing Machine
Examples: Any Algorithm
(highest computing power)
Temp.memory
22
Finite
Automata
Pushdown
Automata
Turing
Machine
Power of Automata
Less power More power
Solve more
computational problems
Simple problems
More complexproblems
Hardestproblems
23
Turing Machine is the most powerful computational model known
Question: Are there computational problems that a Turing Machine cannot solve?
Answer: Yes (unsolvable problems)