1 an introduction to formal languages and automata provided by : babak salimi webadd: //utopie.ir/...

23
1 An Introduction to Formal Languages and Automata Provided by : Babak Salimi webAdd: http://utopie.ir/ Email: [email protected]

Upload: rhoda-patterson

Post on 12-Jan-2016

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 An Introduction to Formal Languages and Automata Provided by : Babak Salimi webAdd: //utopie.ir/ Email: bhm.salimi@gmail.com

1

An Introduction to Formal Languages and Automata

Provided by : Babak SalimiwebAdd: http://utopie.ir/

Email: [email protected]

Page 2: 1 An Introduction to Formal Languages and Automata Provided by : Babak Salimi webAdd: //utopie.ir/ Email: bhm.salimi@gmail.com

2

Textbook:

Webadd: http://itla.ir/

Page 3: 1 An Introduction to Formal Languages and Automata Provided by : Babak Salimi webAdd: //utopie.ir/ Email: bhm.salimi@gmail.com

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?

Page 4: 1 An Introduction to Formal Languages and Automata Provided by : Babak Salimi webAdd: //utopie.ir/ Email: bhm.salimi@gmail.com

A simple computer

BATTERY

SWITCH

input: switch

output: light bulb

actions: flip switch

states: on, off

Page 5: 1 An Introduction to Formal Languages and Automata Provided by : Babak Salimi webAdd: //utopie.ir/ Email: bhm.salimi@gmail.com

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

Page 6: 1 An Introduction to Formal Languages and Automata Provided by : Babak Salimi webAdd: //utopie.ir/ Email: bhm.salimi@gmail.com

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

Page 7: 1 An Introduction to Formal Languages and Automata Provided by : Babak Salimi webAdd: //utopie.ir/ Email: bhm.salimi@gmail.com

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?

Page 8: 1 An Introduction to Formal Languages and Automata Provided by : Babak Salimi webAdd: //utopie.ir/ Email: bhm.salimi@gmail.com

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

Page 9: 1 An Introduction to Formal Languages and Automata Provided by : Babak Salimi webAdd: //utopie.ir/ Email: bhm.salimi@gmail.com

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

Page 10: 1 An Introduction to Formal Languages and Automata Provided by : Babak Salimi webAdd: //utopie.ir/ Email: bhm.salimi@gmail.com

10

Computation

CPU memory

Outline of the course contents

Page 11: 1 An Introduction to Formal Languages and Automata Provided by : Babak Salimi webAdd: //utopie.ir/ Email: bhm.salimi@gmail.com

11

CPU

input

output

Program memory

temporary memory

Page 12: 1 An Introduction to Formal Languages and Automata Provided by : Babak Salimi webAdd: //utopie.ir/ Email: bhm.salimi@gmail.com

12

CPU

input

outputProgram memory

temporary memory

3)( xxf

compute xx

compute xx 2

Example:

Page 13: 1 An Introduction to Formal Languages and Automata Provided by : Babak Salimi webAdd: //utopie.ir/ Email: bhm.salimi@gmail.com

13

CPU

input

outputProgram memory

temporary memory

3)( xxf

compute xx

compute xx 2

2x

Page 14: 1 An Introduction to Formal Languages and Automata Provided by : Babak Salimi webAdd: //utopie.ir/ Email: bhm.salimi@gmail.com

14

CPU

input

outputProgram memory

temporary memory3)( xxf

compute xx

compute xx 2

2x

42*2 z82*)( zxf

Page 15: 1 An Introduction to Formal Languages and Automata Provided by : Babak Salimi webAdd: //utopie.ir/ Email: bhm.salimi@gmail.com

15

CPU

input

outputProgram memory

temporary memory3)( xxf

compute xx

compute xx 2

2x

42*2 z82*)( zxf

8)( xf

Page 16: 1 An Introduction to Formal Languages and Automata Provided by : Babak Salimi webAdd: //utopie.ir/ Email: bhm.salimi@gmail.com

16

Automaton

CPU

input

output

Program memory

temporary memory

Automaton

Page 17: 1 An Introduction to Formal Languages and Automata Provided by : Babak Salimi webAdd: //utopie.ir/ Email: bhm.salimi@gmail.com

17

Automaton

input

output

temporary memory

Automaton

state

transition

Page 18: 1 An Introduction to Formal Languages and Automata Provided by : Babak Salimi webAdd: //utopie.ir/ Email: bhm.salimi@gmail.com

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

Page 19: 1 An Introduction to Formal Languages and Automata Provided by : Babak Salimi webAdd: //utopie.ir/ Email: bhm.salimi@gmail.com

19

input

output

temporary memory

Finite Automaton

Finite Automaton

Example: Elevators, Vending Machines

(small computing power)

Page 20: 1 An Introduction to Formal Languages and Automata Provided by : Babak Salimi webAdd: //utopie.ir/ Email: bhm.salimi@gmail.com

20

input

output

Stack

Pushdown

Automaton

Pushdown Automaton

Example: Compilers for Programming Languages

(medium computing power)

Push, PopTemp.memory

Page 21: 1 An Introduction to Formal Languages and Automata Provided by : Babak Salimi webAdd: //utopie.ir/ Email: bhm.salimi@gmail.com

21

input

output

Random Access Memory

Turing

Machine

Turing Machine

Examples: Any Algorithm

(highest computing power)

Temp.memory

Page 22: 1 An Introduction to Formal Languages and Automata Provided by : Babak Salimi webAdd: //utopie.ir/ Email: bhm.salimi@gmail.com

22

Finite

Automata

Pushdown

Automata

Turing

Machine

Power of Automata

Less power More power

Solve more

computational problems

Simple problems

More complexproblems

Hardestproblems

Page 23: 1 An Introduction to Formal Languages and Automata Provided by : Babak Salimi webAdd: //utopie.ir/ Email: bhm.salimi@gmail.com

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)