33
1 Unit 10 Turing machine Decidability Decision problems in FA

Turing machine Decidability Decision problems in FA · Decidability Informally: •Decidability of problem X –whether the problem has an algorithm which solves it (decides it),

  • Upload
    others

  • View
    10

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Turing machine Decidability Decision problems in FA · Decidability Informally: •Decidability of problem X –whether the problem has an algorithm which solves it (decides it),

1

Unit 10

Turing machine

Decidability

Decision problems in FA

Page 2: Turing machine Decidability Decision problems in FA · Decidability Informally: •Decidability of problem X –whether the problem has an algorithm which solves it (decides it),

2

Turing Machines

Proposed by Alan Turing, 1936.

• Unlimited and unrestricted memory.

• A model of a general purpose

computer.

• Can do anything that a real

computer can do.

• Cannot solve all problems!!

Page 3: Turing machine Decidability Decision problems in FA · Decidability Informally: •Decidability of problem X –whether the problem has an algorithm which solves it (decides it),

3

The Turing Machine

• An infinite tape - unlimited memory.

• A tape head - can move left and right.

• Can read from the tape and write on the tape.

b b a c b

head

b d a c __

Page 4: Turing machine Decidability Decision problems in FA · Decidability Informally: •Decidability of problem X –whether the problem has an algorithm which solves it (decides it),

4

Input/Output

*...21 nwwww

0 0 1 1 1 _ _ _

qaccept

*...21 nwwww0 1 0 _ _ _ _ _ ...q0

...

_

InitialConfiguration

FinalConfiguration

Input

Output

Page 5: Turing machine Decidability Decision problems in FA · Decidability Informally: •Decidability of problem X –whether the problem has an algorithm which solves it (decides it),

5

Initial Configuration

• Input: Appears on the leftmost n slots of the

tape.

• The rest of the tape is blank („_‟).

• Head starts on the left-most square.

• Initial state: q0

*...21 nwwwwb b a _ _ _ _ _ ...q0head

Page 6: Turing machine Decidability Decision problems in FA · Decidability Informally: •Decidability of problem X –whether the problem has an algorithm which solves it (decides it),

6

Final Configuration• During the computation the head can read and

write to the tape and move right or left until it

reach reject or accept states.

• Final state: q {qaccept , qreject}

• The tape contains uw.

– The string u appears to the left of the head.

– The string w appears under the head and its right.

– The rest of the tape is blank.

– The output is the string u.

*...21 nwwww0 0 1 0 1 _ _ _

qaccept

u w

Page 7: Turing machine Decidability Decision problems in FA · Decidability Informally: •Decidability of problem X –whether the problem has an algorithm which solves it (decides it),

7

Possible Outcomes of a TM

• The possible outcomes of a TM on a word w

can be:

– stop with “reject” state.

– stop with “accept” state.

– loop forever.

Page 8: Turing machine Decidability Decision problems in FA · Decidability Informally: •Decidability of problem X –whether the problem has an algorithm which solves it (decides it),

8

Differences Between Finite Automata and TM

• A TM can both read and write.

• The head can move left and right.

• The tape is infinite.

• The special cases of reject and accept take

an immediate action.

• A TM can produce an output.

Page 9: Turing machine Decidability Decision problems in FA · Decidability Informally: •Decidability of problem X –whether the problem has an algorithm which solves it (decides it),

9

TM: Definition

Formally: A TM is defined by

(Q, , , , q0, qaccept, qreject)

• Q is the set of states.

• is the input alphabet _ .

• is the tape alphabet, _ and .

• : Qx Qxx{R,L} the transition function.

• q0, qaccept, qreject the start, accept and reject

states. qaccept qreject

Page 10: Turing machine Decidability Decision problems in FA · Decidability Informally: •Decidability of problem X –whether the problem has an algorithm which solves it (decides it),

10

The Transition Function

• The transition function

: Qx Qxx{R,L}

• The transition (p,a)(q,b,R) is depicted as:

p qab,R

p qab,R

a,cb,R

cb,R

Page 11: Turing machine Decidability Decision problems in FA · Decidability Informally: •Decidability of problem X –whether the problem has an algorithm which solves it (decides it),

11

Example: L={w#w|w{0,1}*}

0 1 0 0 # 0 1 ...0 0 _

...x 1 0 0 # 0 1 0 0 _

x 1 0 0 # x 1 0 0 _ ...x x x x # x x x x _ ...accept

Page 12: Turing machine Decidability Decision problems in FA · Decidability Informally: •Decidability of problem X –whether the problem has an algorithm which solves it (decides it),

12

Process:

1. Scan and check that the input contains a single #. If not reject.

2. Zig-zag to check whether corresponding positions on either sides of # contain the same symbol. If not, reject. Cross off the checked symbols.

3. When all symbols to the left of # are crossed, check for remaining symbols to the right of #. If any symbol, reject. Otherwise, accept.

Example: L={w#w|w{0,1}*}

Page 13: Turing machine Decidability Decision problems in FA · Decidability Informally: •Decidability of problem X –whether the problem has an algorithm which solves it (decides it),

13

TM’s state diagram recognizing: B={w#w|w{0,1}*}

Page 14: Turing machine Decidability Decision problems in FA · Decidability Informally: •Decidability of problem X –whether the problem has an algorithm which solves it (decides it),

14

The Turing-Church Conjecture 1936

• If an algorithm exists for solving a problem

then there is an equivalent Turing machine

solving that algorithm.

• This gives a formal model for the intuitive

notion of “algorithms”.

• This means that a Turing machine can do

what any computer can do, and there isn‟t a

more powerful computational model than TM.

Page 15: Turing machine Decidability Decision problems in FA · Decidability Informally: •Decidability of problem X –whether the problem has an algorithm which solves it (decides it),

15

Decision Problems

• Problems for which the answer is “yes/no”.

• Any problem can be reduced to a decision

problem.

Page 16: Turing machine Decidability Decision problems in FA · Decidability Informally: •Decidability of problem X –whether the problem has an algorithm which solves it (decides it),

16

Arithmetic as a decision problem

• A membership problem determines whether a

word w is in a language L.

• Any problem can be reduced to the

membership problem of a word in a language.

• Example: An arithmetical problem of finding

the answer to: 3*7=?

• This problem can be formulated as a question:

– which of the following words belong to the language

of correct arithmetic statements:

3*7=0, 3*7=1, … , 3*7=21, 3*7=22, …

Page 17: Turing machine Decidability Decision problems in FA · Decidability Informally: •Decidability of problem X –whether the problem has an algorithm which solves it (decides it),

17

Decidability

Informally:

• Decidability of problem X – whether the problem has an algorithm which solves it (decides it), i.e. whether there is an TM which:

1. always halts

2. with the correct answer

• A decidable problem has such an algorithm/TM/grammar.

• An undecidable problem does not have such an algorithm/TM/grammar.

Page 18: Turing machine Decidability Decision problems in FA · Decidability Informally: •Decidability of problem X –whether the problem has an algorithm which solves it (decides it),

18

DFA Membership

• Input: DFA A and a string w

• Output: “yes” if wL(A); “no” otherwise.

• Theorem: DFA membership is decidable.

Page 19: Turing machine Decidability Decision problems in FA · Decidability Informally: •Decidability of problem X –whether the problem has an algorithm which solves it (decides it),

19

Proof of decidability

• The algorithm to decide the problem is:

– Simulate A with a TM:

• start A on w from q0

• if ‟(q0,w) F return “yes”

• otherwise return “no”

• The algorithm will always halt after |w| steps.

Page 20: Turing machine Decidability Decision problems in FA · Decidability Informally: •Decidability of problem X –whether the problem has an algorithm which solves it (decides it),

20

NFA Membership

• Input: NFA B and a string w

• Output: “yes” if wL(B); “no” otherwise.

• Theorem: NFA membership is decidable.

Page 21: Turing machine Decidability Decision problems in FA · Decidability Informally: •Decidability of problem X –whether the problem has an algorithm which solves it (decides it),

21

Proof of decidability

• The algorithm to decide the problem is:

– Convert NFA B to an equivalent DFA C

– Apply “DFA membership” TM to C and w

– If TM accepts w, accept, otherwise reject.

• The algorithm will always halt after |w| steps.

Page 22: Turing machine Decidability Decision problems in FA · Decidability Informally: •Decidability of problem X –whether the problem has an algorithm which solves it (decides it),

22

CFG Membership

• Input: CFG G and a string w

• Output: “yes” if wL(G); “no” otherwise.

• Theorem: CFG membership is decidable.

Page 23: Turing machine Decidability Decision problems in FA · Decidability Informally: •Decidability of problem X –whether the problem has an algorithm which solves it (decides it),

23

Proof of decidability

• Option 1:

– List all derivations ={u | S * u}

– Check whether w.

– Will it work?

• Option2:

– Convert G into equivalent Chomsky NF.

– List all derivations ={u | S * u} with

2|w|-1 steps

– Check whether w

Page 24: Turing machine Decidability Decision problems in FA · Decidability Informally: •Decidability of problem X –whether the problem has an algorithm which solves it (decides it),

24

TM Membership

• Input: TM M and a string w

• Output: “yes” if M accepts w; “no” otherwise.

• Theorem: TM membership is undecidable.

Page 25: Turing machine Decidability Decision problems in FA · Decidability Informally: •Decidability of problem X –whether the problem has an algorithm which solves it (decides it),

25

Proof of un-decidability

• In next course!

Page 26: Turing machine Decidability Decision problems in FA · Decidability Informally: •Decidability of problem X –whether the problem has an algorithm which solves it (decides it),

Classes of Languages

26

Turing -recognizable

decidable

context-free

regular

Page 27: Turing machine Decidability Decision problems in FA · Decidability Informally: •Decidability of problem X –whether the problem has an algorithm which solves it (decides it),

Recap

27

Page 28: Turing machine Decidability Decision problems in FA · Decidability Informally: •Decidability of problem X –whether the problem has an algorithm which solves it (decides it),

Recap

Regular Languages:

• Finite Automata (Q,,,q0,F)

• Regular languages

• Closures of RL (union, intersection,

complements, minus)

• Non deterministic automaton: : Qx2Q

• Equivalence DFANFA

• Closures of RL (concatenation, Kleene star).

28

Page 29: Turing machine Decidability Decision problems in FA · Decidability Informally: •Decidability of problem X –whether the problem has an algorithm which solves it (decides it),

Recap

• Regular Expressions

• Equivalence DFA RE

• Minimal DFA and equivalent DFAs

• Non regular languages: The Pumping Lemma

29

Page 30: Turing machine Decidability Decision problems in FA · Decidability Informally: •Decidability of problem X –whether the problem has an algorithm which solves it (decides it),

Recap

Context-Free Languages:

• Context-Free Grammar G=(V, , S, R)

• Regular grammar (Aw, AwB)

• Equivalence NFA regular-grammar

• Closure of CFL (Union, Concatenation,

Kleene star)

• Chomsky Normal Form (ABC, A)

• Chomsky Hierarchy of grammars

30

Page 31: Turing machine Decidability Decision problems in FA · Decidability Informally: •Decidability of problem X –whether the problem has an algorithm which solves it (decides it),

Recap

• Pushdown automata (Q, , , , q0, F)

• Equivalence PDA CFG

• Non context-free languages: The pumping

lemma

• Turing Machines

• Decidability

31

Page 32: Turing machine Decidability Decision problems in FA · Decidability Informally: •Decidability of problem X –whether the problem has an algorithm which solves it (decides it),

32

Aims

• Practical techniques and tools - useful in

compilation, translation, data compression etc.

• Formalization of the concept of language -

useful in formal linguistics etc.

• Computational models - useful in answering

basic questions about computations.

• Understanding of the computer abilities and its

limits

– In a problem Solvable?

– At what resources?

Page 33: Turing machine Decidability Decision problems in FA · Decidability Informally: •Decidability of problem X –whether the problem has an algorithm which solves it (decides it),

THE END33