15hjhkllkhhkljbghgfyhgjkhjghfgjgjkghg336479.ppt

JITENDER773791 4 views 40 slides Jun 06, 2024
Slide 1
Slide 1 of 40
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40

About This Presentation

ok


Slide Content

CSCI 3130: Formal languages and automata theory
Andrej Bogdanov
http://www.cse.cuhk.edu.hk/~andrejb/csc3130
The Chinese University of Hong Kong
Decidable and
undecidable languages
Fall 2010

Problems about automata
•We can formulate this question as a language:
q
0 q
1
b
b
a
a
Does accept input abb?
A
DFA= {〈D, w〉: Dis a DFA that accepts input w}
((q0,q1)(a,b)((q0,a,q0)(q0,b,q1)(q1,a,q0)(q1,b,q1)(q0)(q1))(abb)
D= (Q, S, d, q
0, F) w
Is A
DFAdecidable?

Problems about automata
A
DFA= {〈D, w〉: Dis a DFA that accepts input w}
pseudocode:
On input 〈D, w〉,
where D= (Q, S, d, q
0, F):
Set q:= q
0
For i := 1 to length(w):
q:= d(q, w
i)
If q F accept, else reject
TM description:
On input 〈D, w〉,
where Dis a DFA, wis a string
SimulateDon input w
If simulation ends in acc state,
accept. Otherwise, reject.

Problems about automata
A
DFA= {〈D, w〉: Dis a DFA that accepts input w}
Turing Machine details:
Check input is in correct format.
(Transition function is complete, no duplicate transitions)
Perform simulation:
((q0,q1)(a,b)((q0,a,q0)(q0,b,q1)(q1,a,q0)(q1,b,q1)(q0)(q1))(abb)
. .
state input symbol
... .
q
acc

Problems about automata
A
DFA= {〈D, w〉: Dis a DFA that accepts input w}
Turing Machine details:
Check input is in correct format.
(Transition function is complete, no duplicate transitions)
Perform simulation:
Put markers on start state of Dand first symol of w
Until wmarker reaches last symbol:
Update both markers
If state marker is on accepting state, accept. Else reject.

Acceptance problems about automata
A
DFA= {〈D, w〉: Dis a DFA that accepts input w}
A
NFA= {〈N, w〉: Nis an NFA that accepts w}
A
REX= {〈R, w〉: Ris a regular expression that generates w}
Which of these is decidable?

Acceptance problems about automata
•The following TM decides A
DFA:
A
DFA= {〈D, w〉: Dis a DFA that accepts input w}
M:=On input 〈D, w〉, where Dis a DFA and wis a string
Simulate Don input w
If the simulation ends in acc state of D, accept.
If it doesn’t, reject.

Acceptance problems about automata
•The following TM decides A
NFA:
A
NFA= {〈N, w〉: Nis an NFA that accepts input w}
N:=On input 〈N, w〉, where Nis an NFA and wis a string
Convert Nto a DFA D
using the conversion procedure from Lecture
2
Run the TM Mfor A
DFAon input 〈D, w〉
If Maccepts, accept. Otherwise, reject.

Acceptance problems about automata
•The following TM decides A
REX:
A
REX= {Ris a regular expression that generates w}
P:=On input 〈R, w〉, where Ris a reg exp and wis a string
Convert Rto an NFA A
using the conversion procedure from Lecture
4
Run the TM Nfor A
NFAon input 〈A, w〉
If Naccepts, accept. Otherwise, reject.

Other problems about automata
MIN
DFA= {〈D〉: Dis a minimal DFA}
On input 〈D〉, where Dis a DFAR:=
Run the distinguishable states
algorithm
from Lecture 7 on D
If every pair of states is distinguishable,
accept.Otherwise, reject.
•The following TM decides MIN
DFA:

Other problems about automata
EQ
DFA= {〈D
1, D
2〉: D
1, D
2are DFAs and L(D
1) = L(D
2)}
On input 〈D
1, D
2〉, where D
1and D
2are DFAsS:=
Run the DFA minimization algorithm
from Lecture 7 on D
1to obtain a DFA D
1’
•The following TM decides EQ
DFA:
If D
1 = D
2accept, otherwise reject.
Run the DFA minimization algorithm
from Lecture 7 on D
2to obtain a DFA D
2’

Other problems about automata
E
DFA= {〈D〉: D is a DFAs and L(D)is empty}
On input 〈D〉, where Dis a DFAT:=
Run the TM Sfor EQ
DFAon input 〈D,〉
•The following TM decides E
DFA:
If Saccepts accept, otherwise reject.

Problems about context-free grammars
A
CFG= {〈G, w〉: Gis a CFG that generates w}
On input 〈G,w〉, where Gis a CFG and wis a stringV:=
If the CYK algorithm produces a parse tree,
accept.
Eliminate the nullable and unit productions from G
Convert Gto Chomsky Normal Form
Run the Cocke-Younger-Kasami algorithm on 〈
G,w〉
Otherwise, reject.

Decidability of context-free languages
Every context-free language is decidable.
Let Lbe a context-free language.
There is a CFG Gfor L.
The following TM decides L:
M
G:=On input w,
Run TM Von input 〈G,
w〉.
If Vacceptsaccept, otherwise reject.

Are all languages about CFGs
decidable?
EQ
CFG= {〈G
1,G
2〉: G
1andG
2are context-free grammars
that generate the same strings}
What’s the difference between EQ
DFAand EQ
CFG?
To decide EQ
DFA, we minimized both DFAs
But there is no method that, given a CFG or PDA,
produces a unique equivalent minimal CFG or PDA

The universal Turing Machine
and undecidability

Turing Machines versus computers
computer
input
program
output
A computeris a machine that manipulates data
according to a list of instructions.
How does a Turing Machine take a program
as part of its input?

The Universal Turing Machine
U
input x
program 〈M
〉 Mon input x
The universal TMUtakes as inputs a program M
and a string xand simulates Mon x
The program Mitself is specified as a TM!

Turing Machines as strings
•This Turing Machine can be described by the
string
〈M〉=(q,qa,qr)(0,1)(0,1,☐)
((q,q,☐/☐R)
(q,qa,0/0R)
(q,qr,1/1R))
(q)(qa)(qr)
M
q
q
a
q
r
☐/☐R
A Turing Machine is
(Q, S,, d, q
0, q
acc,
q
rej)

The universal Turing Machine
U
(q,qa,qr)(0,1)(0,1, 001
input wfor Mprogram 〈M

U:=On input 〈M, w〉,
SimulateMon input w
If Menters accept state, accept.
If Menters reject state, reject.

Acceptance of Turing Machines
A
TM= {〈M, w〉: Mis a TM that accepts w}
U:=On input 〈M, w〉,
SimulateMon input w
Maccepts w Mrejects w Mloops on w
Uaccepts 〈M, w〉Urejects 〈M, w〉Uloops on 〈M, w〉
TM Urecognizesbut does not decideA
TM

Recognizing versus deciding
The language recognized by a TM is the
set of
all inputs that make it accept
A TM decides language Lif it recognizes L
and
halts (does not loop) on every input
q
acc q
rej
accept reject loop
halt

Undecidability
•Turing’s Theorem:
•Before we show this, let’s observe one thing:
The language A
TMis undecidable.
A Turing Machine Mcan be given its own
description〈M〉as an input!

Turing’s theorem
A TM that
decides A
TMis so
potent that it will
destroy itself.

Proof of Turing’s Theorem
•Proof by contradiction:
Suppose A
TMis decidable.
Then there is a TM Hthat decides A
TM:
H
〈M,w〉 acceptifMaccepts w
rejectifMrejects w
or Mloops on
w
〈M,〈M〉〉 acceptifMaccepts 〈M〉
rejectifMrejects 〈M〉
or Mloops on 〈M〉
What happens whenw= 〈M〉?

Proof of undecidability
H
〈M,〈M〉〉 acceptifMaccepts 〈M〉
rejectifMrejects 〈M〉
or Mloops on 〈M〉
Let H’be a TM that does the oppositeof H
H
acc
rej
acc
rej
H’
H= (Q, S,, d, q
0, q
acc, q
rej)
H’= (Q, S,, d, q
0, q
rej, q
acc)

Proof of undecidability
H
〈M,〈M〉〉 acceptifMaccepts 〈M〉
rejectifMrejects 〈M〉
or Mloops on 〈M〉
H’
〈M,〈M〉

rejectifMaccepts 〈M〉
ifMrejects 〈M〉
or Mloops on 〈M〉
accept

Proof of undecidability
H’
〈M,〈M〉〉
rejectifMaccepts 〈M〉
ifMrejects 〈M〉
or Mloops on 〈M〉
accept
Let Dbe the following TM:
copy
〈M〉 〈M,〈M〉〉
H’

Proof of undecidability
D
〈M〉
rejectifMaccepts 〈M〉
ifMrejects 〈M〉
or Mloops on 〈M〉
accept
What happens when M= D?
〈D

rejectifDaccepts 〈D〉
ifDrejects 〈D〉
or Dloops on 〈D〉
If Daccepts 〈D〉then Drejects 〈D〉
If Drejects 〈D〉then Daccepts 〈D〉
so Ddoes not exist!
Hnever loops, so H’
and Dnever loop either

Proof of undecidability: conclusion
•Proof by contradiction
–We assumed A
TMwas decidable
–Then we had Turing Machines H, H’, D
–But Ddoes not exist!
•Conclusion
The language A
TMis undecidable.

What happened?
M
1
M
2
M
3

e 0 1 00…
accrej rej acc
rejacclooprej
rejlooprejrej


Turing Machines
all possible inputs w
We can write an infinite table for every pair (M, w)
all possible

What happened?
M
1
M
2
M
3

〈M
1〉〈M
2〉 〈M
4〉…
acclooprej acc
rejacc rejacc
looprejlooprej


Now let’s look only at those wthat describe a TM M
〈M
3〉

What happened?
M
1
M
2

〈M
1〉〈M
2〉 〈M
4〉…
acclooprej acc
rejacc rejacc…

If A
TMis decidable, then TM Dis in the table
〈M
3〉
Drejrejacc rej
… …

What happened?
M
1
M
2

〈M
1〉〈M
2〉 〈M
4〉…
acclooprej acc
rejacc rejacc…

Ddoes the opposite of the diagonal entries
〈M
3〉
Drejrejacc rej
D
〈M〉
reject ifMaccepts 〈M〉
accept ifMrejects or loops on 〈M〉

What happened?
M
1
M
2

〈M
1〉〈M
2〉 〈M
4〉…
acclooprejacc
rejacc rejacc…

We run into trouble when we look at (D, 〈D〉)!
〈M
3〉
Drejrejacc rej
〈D〉
loop
acc
?…

Unrecognizable languages
•How about languages that are not recognizable?
The language A
TMis recognizable but not
decidable.
A
TM= {〈M, w〉: Mis a TM that does not accept w}
= {〈M, w〉: Mrejects or loops on input w}
The language A
TMis not recognizable.

Unrecognizable languages
•Theorem
•We know A
TMis recognizable, so if A
TMwere
also,
then A
TMwould be decidable
•Impossible by Turing’s Theorem
If Land Lare both recognizable, then Lis
decidable.

Unrecognizable languages
•Proof idea
If Land Lare both recognizable, then Lis
decidable.
M rej/loop ifw∉L
accept ifw∈L
w
M’rej/loop ifw∈L
accept ifw∉L
w
w
accept
reject

Unrecognizable languages
Let M= TM for L, M’= TM for L
On input w,
Simulate Mon input w. If it accepts, accept.
Simulate M’on input w. If it accepts, reject.
If Land Lare both recognizable, then Lis
decidable.
Problem: If Mloops on w, we
will never get to step 2!

Bounded simulation
•Decider for L:
Let M= TM for L, M’= TM for L
On input w,
Simulate Mon input w for ksteps. If it accepts, accept.
Simulate M’on input w for ksteps. If it accepts, reject.
If Land Lare both recognizable, then Lis
decidable.
For k= 0 to infinity
Tags