Document

advertisement
Lecture11 Decidability
 2005 SDU
Topics
Discuss the power of algorithms to solve
problems.
Demonstrate that some problems can be solved
by algorithms while other cannot.
Explore the limits of algorithmic solvability.
Demonstrate the un-solvability of certain
problems.
 2005 SDU
2
Example problems
Consider the acceptance problem for DFAs:
test whether a particular finite automaton
accepts a given string.
This can be expressed as a language ADFA.
ADFA contains the encodings of all DFAs
together with strings the DFAs accept, i.e.,
ADFA={<B, w> | B is a DFA that accepts w}
Hence, testing whether DFA B accepts w is the
same as testing whether <B, w>  ADFA.
 2005 SDU
3
Decidability related to DFA
ADFA is a decidable language
Proof idea: construct a TM M that decides ADFA
M=“On input <B, w>, where B is a DFA and w
is a string:
1. Simulate B on w;
2. If the simulation ends in an accept state then accept;
if it ends in a non-accept state then reject.”
Note: w is finite and simulation always ends.
 2005 SDU
4
Decidability related to NFA
ANFA = { <B,w> | B is an NFA that accepts string w} is decidable.
N = “On input <B, w>, where B is an NFA and w is a string:
1. Convert NFA B to a DFA C;
2. Run TM M on <C, w>;
3. If M accepts , accept; otherwise reject.”
Note: running M in stage 2 means incorporating M into the
design of N as a sub-procedure, where M is the decider of
ADFA.
 2005 SDU
5
Concerning regular expression
AREX = {<R, w> | R is a regular expression that yields string w}
Conclusion: AREX is a decidable language.
The following TM P decides AREX
P=“On input <R, w>, where R is a regular expression and w is a
string
1. Convert R to an equivalent DFA A;
2. Run TM M on input <A, w>;
3. If M accepts, accept; if M rejects, reject.”
 2005 SDU
6
Emptiness problem
EDFA = {<A> | A is a DFA and L(A)=} is decidable.
Proof idea:
A DFA accepts some string iff reaching a final state from the start
state by traveling along the arrows of the DFA is possible.
To test this condition we can construct the TM T that marks states
of DFA using the state transition function of the DFA.
Use T to solve the emptiness problem.
T = “On input <A>, where A is a DFA:
1. Mark the start state of A
2. Repeat until no new states get marked:
–
Mark any state that has a transition coming into it from any state that is
already marked.
3. If no final state is marked, accept; otherwise, reject.
”
 2005 SDU
7
Language equality
1.
2.
3.
4.
The problem: for two DFA-s A and B, is L(A) = L(B)?
The language: EQDFA = {<A, B>| A and B are DFAs and L(A) =
L(B)}
EQDFA is decidable.
Proof idea:
Construct a DFA C from A and B where C accepts only those
strings that are accepted either by A or B but not by both.
If A and B recognize the same language, then C accepts nothing.
The language of C is defined by L(C )  ( L( A)  L( B))  ( L( A)  L( B))
, which is called the symmetric difference of L(A) and L(B)
Use T to check whether L(C) is empty.
 2005 SDU
8
Decide language equality
F = “On input <A, B>, where A and B are DFAs:
1. Construct DFA C that recognizes L(C) as described
above;
2. Run TM T on input <C>;
3. If T accepts, accept; if T rejects, reject.”
 2005 SDU
9
String generation problem
Problem: For a given CFG grammar G =(V, , R,
S) and a string w*, does G generates w (i.e., is
S=>*w true?)
Language: ACFG={<G, w>| G is a CFG that
generates string w}
ACFG is decidable.
 2005 SDU
10
Decidability concerning CFG
Proof idea: For a CFG G and a string w:
First idea: Go through all derivations generated by G
checking whether any is a derivation of w.
 Since there are infinitely many derivations this idea does not work. If G
does not generates w, the algorithm does not halt, i.e., this idea provides a
recognizer but not a decider.
If G is a CFG in Chomsky normal form then for any w  L(G), where
|w|=n, exactly 2n-1 steps are required for any derivation of w.
Proof. Derivation rules of a Chomsky normal form are of the forms:
AA1A2|Aa. The rule AA1A2 adds 1 to the length of w. That is if
|w|=n, then S=>A1A2=>A1A2A3=>…A1A2…An, using n-1 steps. To
eliminate A1, A2, …, An by rules of the from Aa we need another n
steps. Hence, only 2n-1 steps are required.
 2005 SDU
11
Decide ACFG
The TM S that decides ACFG is:
S = “On input <G, w>, where G is a CFG and w is a
string:
1. Convert G to an equivalent grammar in Chomsky normal form;
2. List all derivations with 2n-1 steps, n = length (w) except if n  1;
for n  1 list all derivations with 1 step;
3. If any of the derivations listed above generates w, accept; if not,
reject.”
Theorem 2.12 provides a mechanism to convert a CFG
into a PDA and vice versa; hence, everything about
decidability of problems concerning CFG applies equally
to PDA.
 2005 SDU
12
Decide CFL
Every CFL is decidable
Proof. Let A be a CFL and G be a CFG for A.
Design a TM MG that decides A. We build a copy
of G into MG.
MG=“On input w:
1. Run TM S on input <G, w>
2. If S accepts, accept, if it rejects, reject.”
decidable
regular
 2005 SDU
recognizable
Context free
13
Download