• Aucun résultat trouvé

Reducibility among Problems

A common approach in solving problems is to transform them to different problems, solve the new ones, and derive the solutions for the original problems from those for the new ones. This approach is useful when the new problems are simpler to solve, or when they already have known algorithms for solving them. A similar approach is also very useful in the classification of problems according to their

complexity.

A problem K1, which can be transformed to another problem K2, is said to be reducible to the new problem. Specifically, a problem K1 is said to be reducible to a problem K2 if there exist computable total functions f and g with the following properties (see Figure 1.5.1).

Figure 1.5.1 Reducibility from problem K1 to problem K2.

If I1 is an instance of K1, then

a. I2 = f(I1) is an instance of K2.

b. K1 has a solution S1 at I1 if and only if K2 has a solution S2 at I2 = f(I1) such that S1 = g(S2).

Example 1.5.1 Let be the set { m | m = 2i for some integer i }. The problem of exponentiation of numbers from is reducible to the problem of multiplication of integer numbers. The reducibility is implied from the equalities xy = (2log x)y = 2y log x, which allow the choice of f(x, y) = (y, log x) and g(z)

= 2z for f and g, respectively.1

Example 1.5.2 Let KØ and K be the emptiness problem and the equivalence problem for programs, respectively. Then KØ is reducible to K by functions f and g of the following form. f is a function

whose value at program P is the pair of programs (P, PØ). PØ is a program that accepts no input, for example, the program that consists only of the instruction reject. g is the identity function, that is, g(yes)

= yes and g(no) = no.

If K1 is a problem that is reducible to a problem K2 by total functions f and g that are computable by algorithms Tf and Tg, respectively, and K2 is solvable by an algorithm A, then one can also get an algorithm B for solving K1 (see Figure 1.5.2).

Figure 1.5.2 Reduction of problem K1 to problem K2.

Given an input I, the algorithm B starts by running Tf on I. Then B gives the output I' of Tf to A. Finally B gives the output S' of A to Tg, and assumes the same output S as the one obtained from Tg.

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

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

Exercises

1.1.1

a. Find all the alphabets that use only symbols from the set {a, b, c}. Which of the alphabets is unary? Which is binary?

b. Let S be a set of t symbols. How many unary alphabets can be constructed from the symbols of S? How many binary alphabets?

1.1.2

For each of the following conditions find all the strings over the alphabet {a, b} that satisfy the condition.

For each of the following cases give the first 20 strings in {a, b, c}*.

a. {a, b, c}* is given in alphabetical ordering.

a. S1 contains the t alphabetically smallest strings in S, and S2 contains all the strings in S of length t at most.

b. S1 contains the 127 alphabetically smallest strings in S, and S2 contains the 127

canonically smallest strings in S.

1.1.8

Show that if is an alphabet, then * has the following representations.

a. Binary representation b. Unary representation

1.1.9

Find a binary representation for the set of rational numbers.

1.1.10

Show that if D has a binary representation f1, then it also has a binary representation f2, such that f2(e) is an infinite set for each element e of D.

1.1.11

Let f1 and f2 be binary representations for D1 and D2, respectively. Find a binary representation f for each of the following sets.

Show that the set of real numbers does not have a binary representation.

1.2.1

Let L be the language { , 0, 10}. Determine the following sets.

a. L at most 3 symbols. What are the possible production rules in P?

1.2.3

Let G be the grammar <N, , P, S>, where N = {S}, = {a, b}, and P = {S , S aSbS}.

a. Find all the strings that are directly derivable from SaS in G.

b. Find all the derivations in G that start at S and end at ab.

c. Find all the sentential forms of G of length 4 at most.

1.2.4

Find all the derivations of length 3 at most that start at S in the grammar <N, , P, S> whose production rules are listed below.

1.2.5

For each of the following sets of production rules P find all the strings of length 4 or less in the language generated by the grammar <N, , P, S>.

1.2.6

Give two parse trees for the string aababb in the grammar G = <N, , P, S>, whose production rules are listed below.

1.2.7

Consider the grammar G = <N, , P, E> for arithmetic expressions, where N = {E, T, F}, = {+,

*, (, ), a}, and P is the set consisting of the following production rules.

Give the derivation tree for the expression a * (a + a) in G.

1.2.8

Let G = <N, , P, S> be the grammar with the following production rules. Find the derivation graph for the string a3b3c3 in G.

1.2.9

For each of the following languages give a grammar that generates the language.

a. { x01 | x is in {0, 1}* } b. {01, 10}*

c. { x | x is in {a, b}*, and the number of a's in x or the number of b's in x is equal to 1 } d. { 0i1j | i j }

e. { x | x is in {0, 1}*, and x = xrev }

f. { x | x is in {0, 1}*, and each 01 in x is followed by 10 } g. { x | x is in {0, 1}*, and the length of x is not divisible by 3 }

h. { x | x is in {a, b}*, and x is of odd length if and only if it ends with b } i. { x | x is in {a, b}*, and abb is not a substring of x }

j. { x#y | x is in {a, b}*, and y is a permutation of x } k. { aibicidi | i is a natural number }

l. { ai1#ai2#ai3# #ain | n 2 and ij = ik for some 1 j < k n } m. { aba2b2a3b3 anbn | n is a natural number }

1.2.10

For each of the following conditions show how, from any arbitrary given pair of grammars G1 =

<N1, 1, P1, S1> and G2 = <N2, 2, P2, S2>, a grammar G3 = <N3, 3, P3, S3> that satisfies the condition can be constructed.

a. L(G3) = { w | wrev is in L(G1) } b. L(G3) = L(G1) L(G2)

c. L(G3) = L(G1)L(G2)

Give the leftmost derivation and a nonleftmost derivation for the string abbabb in the grammar of Exercise 1.2.5.

1.2.13

For each of the following cases find all the possible grammars G that satisfy the case, where G =

<N, , P, S> with N = {S}, = {a, b}, and P being a subset of {S , S abAS, S ab, bA

Consider the program P in Figure 1.E.1(a). What are the outputs of P on input "2, 2"? On input "3, 2"?

1.3.2

Consider the program P in Figure 1.E.1(b). Assume that P has the domain of variables {0, 1, 2, 3, 4, 5}. What are the outputs of P on input "2, 2"? On input "3, 2"?

1.3.3

For each of the following cases write a program that corresponds to the case. Assume that the variables have the set of natural numbers as the domain of the variables, and 0 as an initial value.

a. The program outputs an input value v such that v + 2 does not appear in the input.

Example: On input "1, 4, 2, 3" the program should have an accepting computation with output "3", and an accepting computation with output "4". Moreover, each accepting computation of the program should provide either the output "3" or the output "4".

b. The program outputs an input value v such that v + 2 also appears in the input.

Example: On input "1, 4, 3, 2" the program should have an accepting computation with output "1", and an accepting computation with output "2". Moreover, each accepting computation of the program should provide either the output "1" or the output "2".

c. The program outputs a value that does not appear exactly twice in the input.

Example: On input "1, 4, 1, 4, 3, 1" the program should have for each i 4 an accepting computation with output i (i.e., i = 0, 1, 2, 3, 5, 6, . . . ). Moreover, each accepting computation of the program should provide one of these outputs.

d. The program outputs an input value v that appears as the vth value in the input.

Example: On input "3, 2, 1, 2, 5, 3" the program should have an accepting computation with output "2", and an accepting computation with output "5". Moreover, each accepting computation of the program should provide either of these outputs.

e. The program outputs an input value v that appears exactly v times in the input.

Example: On input "3, 2, 1, 2, 5, 3" the program should have an accepting computation with output "1", and an accepting computation with output "2". Moreover, each accepting computation of the program should provide either of these outputs.

f. The program accepts exactly those inputs whose values cannot be sorted into a sequence of consecutive numbers.

Example: The program should accept the input "1, 2, 1", and the input "1, 4, 2". On the other hand, the program should reject the input "1, 3, 2".

1.3.4

For each of the following cases write a program that computes the given relation.

a. { (x, y) | There is a value in the domain of the variables that does not appear in x and does not appear in y }.

Example: With the domain of variables {1, 2, 3, 4, 5, 6} on input "1, 2, 4, 5, 6" the program can have any output that does not contain the value 3.

b. { (x, y) | x is not empty, and the first value in x is equal to the first value in y }.

Let P be the program in Example 1.3.13. Give the sequence of moves between the configurations of P in the computation of P on input "1, 2, 1" that has the minimal number of moves. Find a decision problem K2 whose solutions are defined at the same instances as for K1. 1.4.2

b. Write a program that partially decides K, but does not decide K.

1.4.3

Show that the following problems are partially decidable for Type 0 grammars.

a. Membership problem b. Nonemptiness problem

1.4.4

Show that the membership problem is decidable for Type 1 grammars.

1.4.5

Show that the inequivalence problem is partially decidable for Type 1 grammars.

1.4.6

Which of the following statements is correct?

a. If the emptiness problem is decidable for Type 3 grammars, then it is also decidable for Type 0 grammars.

b. If the emptiness problem is undecidable for Type 3 grammars, then it is also undecidable for Type 0 grammars.

c. If the emptiness problem is decidable for Type 0 grammars, then it is also decidable for

Type 3 grammars.

d. If the emptiness problem is undecidable for Type 0 grammars, then it is also undecidable for Type 3 grammars.

A polynomial expression over the natural numbers, or simply a polynomial expression when the natural numbers are understood, is an expression defined recursively in the following manner.

a. Each natural number is a polynomial expression of degree 0.

b. Each variable is a polynomial expression of degree 1.

c. If E1 and E2 are polynomial expressions of degree d1 and d2, respectively, then i. (E1 + E2) and (E1 - E2) are polynomial expressions of degree max(d1, d2).

ii. (E1 * E2) is a polynomial expression of degree d1 + d2.

A polynomial is called a Diophantine polynomial if it can be is represented by a polynomial expression, and its variables are over the natural numbers. Hilbert's tenth problem is the problem of determining for any given Diophantine polynomial Q(x1, . . . , xn) with variables x1, . . . , xn whether or not there exist

1, . . . , n such that Q( 1, . . . , n) = 0.

A LOOP program is a program that consists only of instructions of the form x 0, x y, x x + 1, and do x end. The variables can hold only natural numbers. can be any sequence of instructions. An execution of do x end causes the execution of for a number of times equal to the value of x upon encountering the do. Each LOOP program has a distinct set of variables that are initialized to hold the input values. Similarly, each LOOP program has a distinct set of variables, called the output variables, that upon halting hold the output values of the program. Two LOOP programs are said to be equivalent if on identical input values they produce the same output values.

1.4.7

The following problems are known to be undecidable. Can you show that they are partially decidable?

a. Hilbert's tenth problem

b. The inequivalence problem for LOOP programs

1.5.1

Let be the set { m | m = 2i for some integer i }. Show that the problem of multiplication of numbers from is reducible to the problem of addition of integer numbers.

1.5.2

Show that the nonemptiness problem for programs is reducible to the acceptance problem for programs.

1.5.3

Show that Hilbert's tenth problem is reducible to the nonemptiness problem for programs.

1.5.4

Show that the problem of determining the existence of solutions over the natural numbers for systems of Diophantine equations of the following form is reducible to Hilbert's tenth problem.

Each Qi(x1, . . . , xn) is assumed to be a Diophantine polynomial.

1.5.5

For each of the following cases show that K1 is reducible to K2.

a. K1 is the emptiness problem for Type 0 grammars, and K2 is the equivalence problem for Type 0 grammars.

b. K1 is the membership problem for Type 0 grammars, and K2 is the equivalence problem for Type 0 grammars.

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

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