• Aucun résultat trouvé

The halting problem is decidable for pushdown automata

Dans le document An Introduction to the Theory of Computation (Page 164-173)

Bibliographic Notes

Theorem 3.6.3 The halting problem is decidable for pushdown automata

Proof Consider any pair (M, x) of a pushdown automaton M and of an input x for M. From x, a finite-state automaton Mx can be constructed that accepts only the input x. However, from M, a pushdown automaton M1 can be constructed to accept a given input if and only if M has a sequence of transition rules that leads M to a simple loop on the input. The construction can be similar to the proof of

Theorem 3.6.2.

From M and Mx, a pushdown automaton Ma,x can be constructed that accepts the intersection of L(M) with L(Mx) (see Theorem 3.5.1). By construction, Ma,x accepts a nonempty set if and only if M accepts x. By Theorem 3.6.1 it can be determined if Ma,x accepts a nonempty set. If so, then M is determined to halt on input x. Otherwise, in a similar way, a pushdown automaton M1,x can be constructed to accept the intersection of L(M1) and L(Mx). By construction, M1,x accepts the empty set if and only if M has only halting computations on input x. The result then follows from Theorem 3.6.1.

[next] [prev] [prev-tail] [front] [up]

[next] [prev] [prev-tail] [tail] [up]

Exercises

3.1.1

For each of the following relations give a recursive finite-domain program that computes the relation.

a. { (aibi, ci) | i 0 }

b. { (xy, x) | xy is in {a, b}* and |x| = |y| }

c. { (x, y) | x and y are in {0, 1}*, |x| = |y|, and y xrev }

3.2.1

For each of the following relations give a (deterministic, if possible) pushdown transducer that computes the relation.

a. { (aibj, ajbi) | i, j 0 }

b. { (x, aibj) | x is in {a, b}*, i = (number of a's in x), and j = (number of b's in x) } c. { (xyz, xyrevz) | xyz is in {a, b}* }

d. { (aibj, ck) | i k j } e. { (aibj, ck) | k = min(i, j) }

f. { (w, ck) | w is in {a, b}*, and k = min(number of a's in w, number of b's in w) } g. { (xy, yxrev) | x and y are in {a, b}* }

h. { (x, xrevx) | x is in {a, b}* }

i. { (x, y) | x and y are in {a, b}*, and y is a permutation of x }

3.2.2

Find a pushdown transducer that simulates the computations of the recursive finite-domain program of Figure 3.E.1. Assume that the variables have the domain {0, 1}, and the initial value 0.

call RP(x) /* I1 */

if eof then accept /* I2 */

reject /* I3 */

procedure RP(y)

read x /* I4 */

if x y then /* I5 */

call RP(x) /* I6 */

write y /* I7 */

return /* I8 */

end

Figure 3.E.1

3.2.3

For each of the following languages find a (deterministic, if possible) pushdown automaton that accepts the language.

a. { vwwrev | v and w are in {a, b}*, and |w| > 0 }

b. { x | x is in {a, b}* and each prefix of x has at least as many a's as b's } c. { aibjajbi | i, j > 0 }

d. { w | w is in {a, b}*, and w wrev }

e. { xxrev | x is accepted by the finite-state automaton of Figure 3.E.2 }

Figure 3.E.2

f. { x | x = xrev and x is accepted by the finite-state automaton of Figure 3.E.2 }

3.3.1

For each of the following languages construct a context-free grammar that generates the language.

a. { x#y | x and y are in {a, b}* and have the same number of a's } b. { aibjck | i j or j k }

c. { x | x is in {a, b}* and each prefix of x has at least as many a's as b's } d. { x#y | x and y are in {a, b}* and y is not a permutation of x }

e. { x#y | x and y are in {a, b}* and x y }

3.3.2

Find a Type 2 grammar that is equivalent to the context-free grammar G = <N, , P, S>, whose production rules are given in Figure 3.E.3(a).

Figure 3.E.3

3.3.3

Let G = <N, , P, S> be the context-free grammar whose production rules are listed in

Figure 3.E.3(b). Find a recursive finite-domain program and a pushdown automaton that accept the language generated by G.

3.3.4

Let M be the pushdown automaton whose transition diagram is given in Figure 3.E.4.

Figure 3.E.4

Find a context-free grammar that generates L(M).

3.3.5

Find a deterministic pushdown automaton that accepts the language generated by the grammar G

= <N, , P, S>, whose production rules are given in Figure 3.E.3(c).

3.3.6

Let the program P and the grammar G be as in Example 3.3.5. Find a derivation in G that corresponds to an accepting computation of P on input bab.

3.3.7

Find the context-free grammar that accepts the same language as the program P in Figure 3.E.5, according to the proof of Theorem 3.3.3. Assume that the domain of the variables is equal to {a, b}, with a as initial value.

Redo Example 3.4.1 for the case that G has the production rules listed in Figure 3.E.3(d) and w = a5b4.

3.4.2

Show that each of the following sets is not a context-free language.

a. { anblct | t > l > n > 0 } b. { rev | is in {a, b}* }

c. { rev rev | and are in {a, b}* }

d. { an an | is in {a, b}*, and n = (the number of a's in ) } e. { # | and are in {a, b}* and is a permutation of }

f. { | The finite-state transducer whose transition diagram is given in Figure 3.E.6

Figure 3.E.6 has output on input }

g. { an! | n 1 }

3.4.3

Show that the relation { (x, dn) | x is in {a, b, c}* and n = min(number of a's in x, number of b's in x, number of c's in x) } is not computable by a pushdown transducer.

3.5.1

Show that the class of the relations computable by pushdown transducers is closed under each of the following operations .

a. Inverse, that is, (R) = R-1 = { (y, x) | (x, y) is in R }.

b. Composition , that is, (R1, R2) = { (x, y) | x = x1x2 and y = y1y2 for some (x1, y1) in R1 and some (x2, y2) in R2 }.

c. Reversal, that is, = { (xrev, yrev) | (x, y) is in R }.

3.5.2

Show that the class of context-free languages is not closed under the operation (L1, L2) = { xyzw

| xz is in L1 and yw is in L2 }.

3.5.3

Find a pushdown automaton that accepts the intersection of the language accepted by the pushdown automaton whose transition diagram is given in Figure 3.E.7(a), and the language accepted by the finite-state automaton whose transition diagram is given in Figure 3.5.1(b).

Figure 3.E.7

3.5.4

Let M be the deterministic pushdown automaton given in Figure 3.E.7(b). Find the pushdown automaton that accepts the complementation of L(M) in accordance with the proof of

Theorem 3.5.2.

3.5.5

Show that if a relation is computable by a deterministic pushdown transducer, then its complementation is computable by a pushdown transducer.

3.6.1

Show that the membership problem is decidable for pushdown automata.

3.6.2

Show that the single valuedness problem is decidable for finite-state transducers.

3.6.3

Show that the equivalence problem for finite-state transducers is reducible to the equivalence problem for pushdown automata.

[next] [prev] [prev-tail] [front] [up]

[prev] [prev-tail] [tail] [up]

Bibliographic Notes

McCarthy (1963) introduced recursion to programs. Recursive finite-domain programs and their relationship to pushdown transducers were considered in Jones and Muchnick (1978).

The pushdown automata were introduced by Oettinger (1961) and Schutzenberger (1963). Evey (1963) introduced the pushdown transducers. The equivalence of pushdown automata to context-free languages were observed by Chomsky (1962) and Evey (1963).

The pumping lemma for context-free languages is from Bar-Hillel , Perles , and Shamir (1961).

Scheinberg (1960) used similar arguments to show that { anbncn | n 1 } is not context-free.

The closure of context-free languages under union , and their nonclosure under intersection and

complementation, were noticed by Scheinberg (1960). The closure of the class of context-free languages under composition and under intersection with regular languages is due to Bar-Hillel , Perles , and

Shamir (1961). Schutzenberger (1963) showed the closure under complementation of the class of

languages that are accepted by the deterministic pushdown automata (Theorem 3.5.2). Bar-Hillel , Perles , and Shamir (1961) showed the closure of context-free languages under reversal (see Exercise 3.5.1(c)).

The decidability of the emptiness problem for context-free grammars is also due to Bar-Hillel , Perles , and Shamir (1961). The decidability of the equivalence problem for the deterministic finite-state

transducers in Corollary 3.6.1 follows from Bird (1973). The proof technique used here is from Gurari (1979). This proof technique coupled with proof techniques of Valiant (1973) were used by Ibarra and Rosier (1981) to show the decidability of the equivalence problem for some subclasses of deterministic pushdown transducers.

Greibach (1981) and Hopcroft and Ullman (1979) provide additional insight into the subject.

[prev] [prev-tail] [front] [up]

[next] [prev] [prev-tail] [tail] [up]

Dans le document An Introduction to the Theory of Computation (Page 164-173)