DECIDABILITY, Study notes of Theory of Computation

Theory of computation

Typology: Study notes

2011/2012

Uploaded on 09/19/2012

courageouscse
courageouscse ๐Ÿ‡ฎ๐Ÿ‡ณ

4

(1)

2 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
DECIDABLE LANGUAGES
THEOREM A DFA is a decidable language.
M = "On input {B, w), where B is a DFA and w is a string:
1. Simulate B on input w.
2. If the simulation ends in an accept state, accept. If it ends in a
nonaccepting state, reject."
PROOF
We mention just a few implementation details of this proof. For those
of you familiar with writing programs in any standard programming language,
imagine how you would write a program to carry out the simulation.
First, let's examine the input (B, w). It is a representation of a DFA B together
with a string w. One reasonable representation of B is simply a list of its five
components, Q, E, 6, go, and F. When M receives its input, M first checks on
whether it properly represents a DFA B and a string w. If not, M rejects.
Then M carries out the simulation in a direct way. It keeps track of B's current
state and B's current position in the input w by writing this information down
on its tape. Initially, B's current state is go and B's current input position is the
leftmost symbol of w. The states and position are updated according to the spec-
ified transition function . When M finishes processing the last symbol of w, M
accepts the input if B is in an accepting state; M rejects the input if B is in a
nonaccepting state.
THEOREM A nfa is a decidable language.
PROOF
We present a TM , N that decides nfa- We could design N to operate
like M, simulating an NFA instead of a DFA. Instead, we'll do it differently to illus-
trate a new idea: have N use M as a subroutine. Because M is designed to work
with DFAs, N first converts the NFA it receives as input to a DFA before passing it
toM.
N = "On input (I?, w) where B is an NFA, and w is a string:
1. Convert NFA B to an equivalent DFA C using the procedure for
this conversion.
2. Run TM M on input (C,w).
3. If M accepts, accept; otherwise reject."
Running TM M in stage 2 means incorporating M into the design of N as a
subprocedure. Similarly, we can test whether a regular expression generates a
given string.
pf3
pf4
pf5

Partial preview of the text

Download DECIDABILITY and more Study notes Theory of Computation in PDF only on Docsity!

DECIDABLE LANGUAGES

THEOREM A DFA is a decidable language.

M = "On input {B, w), where B is a DFA and w is a string:

  1. Simulate B on input w.
  2. If the simulation ends in an accept state, accept. If it ends in a nonaccepting state, reject."

PROOF We mention just a few implementation details of this proof. For those of you familiar with writing programs in any standard programming language, imagine how you would write a program to carry out the simulation. First, let's examine the input (B, w). It is a representation of a DFA B together with a string w. One reasonable representation of B is simply a list of its five components, Q, E, 6, go, and F. When M receives its input, M first checks on whether it properly represents a DFA B and a string w. If not, M rejects. Then M carries out the simulation in a direct way. It keeps track of B's current state and B's current position in the input w by writing this information down on its tape. Initially, B's current state is go and B's current input position is the leftmost symbol of w. The states and position are updated according to the spec- ified transition function. When M finishes processing the last symbol of w, M accepts the input if B is in an accepting state; M rejects the input if B is in a nonaccepting state.

THEOREM A nfa is a decidable language.

PROOF

We present a TM , N that decides nfa- We could design N to operate like M, simulating an NFA instead of a DFA. Instead, we'll do it differently to illus- trate a new idea: have N use M as a subroutine. Because M is designed to work with DFAs, N first converts the NFA it receives as input to a DFA before passing it toM.

N = "On input (I?, w) where B is an NFA, and w is a string:

  1. Convert NFA B to an equivalent DFA C using the procedure for this conversion.
  2. Run TM M on input (C,w).
  3. If M accepts, accept; otherwise reject." Running TM M in stage 2 means incorporating M into the design of N as a subprocedure. Similarly, we can test whether a regular expression generates a given string.

Let Arex = {(R, w) | R is a regular expression that generates string w}.

THEOREM Arex is a decidable language.

PROOF

The following TM P decides P = "On input (jR, w) where R is a regular expression and w is a string:

  1. Convert regular expression R to an equivalent DFA.
  2. Run TM, M on input (A,w).
  3. If M accepts, accept; if M rejects, reject."

Now we turn to a different kind of problem concerning finite automata: empti- ness testing for the language of a finite automaton. In the preceding theorems we had to test whether a finite automaton accepts a particular string. In the next proof we must test whether a finite automaton accepts any strings at all. Let -Edfa = {(-4)| A is a DFA and L(A) = 0}.

THEOREM Edfa is a decidable language.

PROOF

A DFA accepts some string if and only if reaching an accept state from the start state by traveling along the arrows of the DFA is possible. To test this condition we can design a TM T that uses a marking algorithm.

T = "On input (A) where A is a DFA:

  1. Mark the start state of A.
  2. Repeat until no new states get marked:
  3. Mark any state that has a transition coming into it from any state that is already marked.
  4. If no accept state is marked, accept; otherwise reject." The next theorem states that testing whether two DFAs recognize the same lan- guage is decidable. Let EQDFA = {(A, B)\ A and B are DFAs and L(A) = L(B)}.

THEOREM EQdfa is a decidable language.

PROOF

To prove this theorem we construct a new DFA C from A and B, where C accepts only those strings that are accepted by either A or B but not by both. Thus, if A and B recognize the same language, C will accept nothing. The language of C is L{C) = (l(A) n L{B)\ U (Til) n L(B).

gives a Turing machine that is an recognizer, but not a decider, for cfg- To make this Turing machine into a decider we need to ensure that the al- gorithm tries only finitely many derivations. If G were in Chomsky normal form, any derivation of w has 2n โ€” 1 steps, where n is the length of w. In that case checking only derivations with 2n โ€” 1 steps to determine whether G generates w would be sufficient. Only finitely many such derivations exist. We can convert G to Chomsky normal form

PROOF The TM for Cfg follows. 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, where n is the length of w, except if n = 0, then instead list all derivations with 1 step.
  3. If any of these derivations generate w, accept; if not, reject."

The problem of testing whether a CFG generates a particular string is related to the problem of compiling programming languages. The algorithm in TM S is very inefficient and would never be used in practice, but it is easy to describe and we aren't concerned with efficiency here. Hence everything we say about the decidability of problems concerning CFGs applies equally well to PDAs. Let's turn now to the emptiness testing problem for the language of a CFG. As we did for DFAs, we can show that the problem of testing whether a CFG generates any strings at all is decidable. Let E cfg = {{G)\ G is a CFG and L[G) = 0}.

THEOREM Ecfg is a decidable language.

PROOF IDEA

To find an algorithm for this problem we might attempt to use TM, S. It states that we can test whether a CFG generates some particular string w. To determine whether L(G) = 0 the algorithm might try going through all possible tu's, one by one. But there are infinitely many w's to try, so this method could end up running forever. We need to take a different approach. In order to test whether the language of a grammar is empty, we need to test whether the start variable can generate a string of terminals. The algorithm does so by solving a more general problem. It determines/or each variable whether that variable is capable of generating a string of terminals.

When the algorithm has determined that a variable can generate some string of terminals, the algorithm keeps track of this information by placing a mark on that variable. First, the algorithm marks all the terminal symbols in the grammar. Then, it scans all the rules of the grammar. If it ever finds a rule that permits some variable to be replaced by some string of symbols all of which are already marked, the algorithm knows that this variable can be marked, too. The algorithm continues in this way until it cannot mark any additional variables. The TM R implements this algorithm.

PROOF R = "On input (G), where G is a CFG:

  1. Mark all terminal symbols in G.
  2. Repeat until no new variables get marked:
  3. Mark any variable A where G has a rule A โ€”> U\ U2โ€ฆUk and each symbol U,... ,Uu has already been marked.
  4. If the start symbol is not marked, accept; otherwise reject." generate the same language. Let EQcfg = {(G, H)\ G and H are CFLs and L(G) = L{H)}.

THEOREM Every context-free language is decidable.

PROOF IDEA

Let A be a CFL. Our objective is to show that A is decidable.

One (bad) idea is to convert a PDA for A directly into a TM. That isn't hard to do because simulating a stack with the TM's more versatile tape is easy. The PDA for A may be nondeterministic, but that seems okay because we can convert it into a nondeterministic TM and we know that any nondeterministic TM can be converted into an equivalent deterministic TM. Yet, there is a difficulty. Some branches of the PDA's computation may go on forever, reading and writing the stack with- out coming to a halt. The simulating TM then would also have some nonhalting branches in its computation, and so the TM would not be a decider. A different idea is necessary. Instead, we prove this theorem with the TM,S.

PROOF Let G be a CFG for A and design a TM, Mq that decides A. We build a copy of G into Me- It works as follows.