Decidability
Download
Report
Transcript Decidability
Decidability
http://cis.k.hosei.ac.jp/~yukita/
Acceptance Problems
ADFA { B, w | B is a DFA thatacceptsinput string w}.
T heproblemof testingwhethera DFA B acceptsan input w is thesame
as theproblemof testingwhether B, w is a memberof thelanguage ADFA .
A language is decidableif themembershiptest decidable.
ANFA { B, w | B is a NFA thatacceptsinput string w}.
AREX { R, w | R is a regular expressionthatgeneratesstring w}.
2
Theorem 4.1 ADFA is a decidable language.
Proof. T hefollowingmachinedecides thelanguage.
M " On input B, w , where B is a DFA and w is a st ring:
1. Simulat e B on input w.
2. If thesimulat ionends in an acceptst at e,accept.
If it ends in a nonacceptng
i st at e,reject."
3
Theorem 4.2 ANFA is a decidable language.
Proof. T hefollowingmachinedecides thelanguage.
N " On input B, w , where B is a NFA and w is a string:
1. ConvertNFA B to an equivalentDFA C.
2. Run M in T h.4.1on input C , w .
3. If M accepts,accept; otherwisereject."
4
Theorem 4.3 AREX is a decidable language.
Proof. T hefollowingmachinedecides thelanguage.
P " On input R, w , where R is a regular expressionand w is a string:
1. Convertregular expressionR to an equivalentDFA A.
2. Run M in T h.4.1on input A, w .
3. If M accepts,accept; otherwisereject."
5
Other Problems
An emptinessproblem.
EDFA { A | A is a DFA and L( A) }.
An equivalence problem.
EQDFA { A, B | A and B are DFAs and L( A) L( B)}.
6
Theorem 4.4 EDFA is a decidable language.
Proof. A DFA acceptssomestringif and onlyif reachingan accept
statefrom thestart stateby traveling along thearrows of theDFA is
possible.
T hefollowingmachineteststhiscondition.
T " On input A , where A is a DFA :
1. Mark t hestart stateof A.
2. Repeat unt il no new statesget marked:
3.
Mark any state thathas a transition comingintoit from
any state thatis already marked.
4. If no acceptstateis marked,accept; otherwisereject."
7
Theorem 4.5 EQDFA is a decidable language.
Proof. Let L(C ) ( L( A) L( B)) ( L( A) L( B)). T hisconstruction
can be algorithmically performed.
Noticethat A, B EQDFA L(C ) EDFA .
T hefollowingmachineteststhiscondition.
F " On input A, B , where A and B are DFAs :
1. ConstructDFA C as above.
2. Run T fromT h.4.4on input C .
3. If T accepts,accept; otherwisereject."
8
Theorem 4.6 ACFG is a decidable language.
Def.
ACFG { G, w | G is a CFG that generatesstring w}.
Proof. T hefollowingmachinedecides ACFG .
S " On input G, w , whereG is a CFG and w is a string:
1. ConvertG to an equivalentgrammarin Chomskynormalform.
2. List all derivations with 2n 1 steps, where n is thelengthof w.
3. If any of thesederivations generatew, accept; if not,reject."
9
Problem 2.19
Show that,if G is a CFG in Chomskynormalform,thenfor any string w L(G )
of length n 1, exactly2n 1 stepsare required for any derivationof w.
Proof. Afterapplyingtheproduct ionrule of typeA BC k times
and theproduct ionrule of typeA a l times, theint ermediate stringhas
k 1 l variablesand l terminals. When the stringis fully parsed, we must have
k 1 l 0
ln
thus
k l 2n 1.
10
Recognizer and Decider
First sight difference in Th. 4.6
• Enumerate all possible derivations and
check one by one if it coincides with the
string. The number of tests may be infinite.
In this case we obtain a recognizer. The
recognizer may loop.
• If we know the number of tests is finite,
we have a decider. The decider never
loops.
11
Theorem 4.7 ECFG is a decidable language.
Proof.
R " On input G , where G is a CFG :
1. Mark all terminalsymbolsin G.
2. Repeat until no new variablesget marked:
3.
Mark any variable A where G has a rule A U1U 2 U k and
each symbol U1 , U 2 , ,U k has already marked.
4. If thestart symbolis not marked,accept; otherwisereject."
12
Theorem 4.8 Every context-free language is
decidable.
Proof. Let G be a CFG for A and design a T M M G thatdecides A.
M G " On input w :
1. Run T M S on input G, w
2. If thismachineaccepts,accept; if it rejects,reject."
13
Preparation to Theorem 4.9 ATM is Turingrecognizable.
Def. ATM { M , w | M is a T M thatacceptsw}.
Proof. T hefollowinguniversalT uringmachinerecognizesATM .
U " On input M , w , where M is a T M and w is a string:
1. Simulate M on input w.
2. If M ever entersits acceptstate,accept; if M ever enters
its reject state,reject."
14
Q is countable.
Diagonalization.
1/1
1/2
1/3
1/4
1/5
2/1
2/2
2/3
2/4
2/5
3/1
3/2
3/3
3/4
3/5
4/1
4/2
4/3
4/4
4/5
5/1
5/2
5/3
5/4
5/5
15
Theorem 4.14 R is uncountable.
Suppose R is count able. Let t hefollowingsequence enumeratethe whole
real numbersbet ween 0 and1.
0.x11 x12 x13 x1 j
0.x21 x22 x23 x2 j
0.xi1 xi 2 xi 3 xij
Let y 0. y1 y2 y3 yk ,
where yk xkk .
T hen y should not appearin thesequence, which contradicts theassumption.
16
Corollary 4.15 Some languages are not Turingrecognizable.
Proof. (1) T heset of all T M is countable. Consider encoding M .
(2) T heset of all languages is uncountable.
Let be theset of all languages overalphabet.
Let * {s1 , s2 ,}.
For any L ,
we set f ( L) (q1 , q2 ,) {0,1} , where qi 0 if si L, and
qi 1 if si L.
Wesee that f : {0,1} is bijection.
17
Theorem 4.9 ATM is undecidable.
Proof. Suppose that H is a decider for ATM such that
accept if M accept sw
H( M,w )
reject if M does not accept w.
D " On input M , where M is a T M :
1. Run H on input M , M .
2. If H accept s,reject. If H rejects,accept ."
We can summarizethat
accept if M does not accept M
D( M )
reject if M accept s M .
Consider the outcomeof D( D ).
18
Theorem 4.16 A language is decidable if and only
if it is both Turing-recognizable and co-Turingrecognizable.
De f. A language is co - T uring- recognizable if it is thecomplementof a
T uring- recognizable language.
Proof. If A is decidable, thenclearlyit is T R and co - T R.
Let M 1 and M 2 be recognizers for A and A , respectively.
T hefollowingT M M decides A.
M " On input w :
1. Run both M 1 and M 2 on input w in parallel.
2. If M 1 accept s, accept; if M 2 accept s,reject."
19
Corollary 4.17
ATM is not T uring- recognizable.
Proof. Weknow that ATM is T uringrecognizable. If ATM were
T uringrecognizable, ATM would be decidable. T hisis not true.
20