Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Hedman. A First Course in Logic, 2004 (Oxford)

.pdf
Скачиваний:
152
Добавлен:
10.08.2013
Размер:
7.17 Mб
Скачать

350

Computability and complexity

one-by-one. The proof of NP-completeness usually involves a construction of some sort. For example, we “constructed” the graph GF to prove Proposition 7.76. The construction relates two ostensibly di erent problems and can be quite convoluted. We describe various known NP-complete problems. Instead of proofs of NP-completeness, we provide references at the end of the section.

The Sum k problem (S UMk)

Recall the SU M 10 Problem from the Preliminaries. Given a finite set of integers, we are asked whether or not there exists a subset that adds up to 10. Similarly, we define the SU M k for any integer k. It is easy to see that these problems are in NP: choose an arbitrary subset and check to see if it sums up to k. Moreover, SU M k is NP-complete. Given an arbitrary formula F , there is a process for constructing a finite set of integers XF such that XF has a subset that sums to k if and only if F is satisfiable.

The Hamilton problem

Let G be a finite graph. A Hamilton path for G is a path that includes each vertex of G once and only once. The Hamilton problem is to determine whether or not a given graph has a Hamilton path. This problem is closely related to the Traveling Salesman problem. Given a set of cities, the Traveling Salesman problem is to find the shortest route that visits each city. There is no known algorithm that e ciently solves this basic problem. The Traveling Salesman problem is not a decision problem and we do not refer to it as being NP-complete. The associated Hamilton problem, however, is NP-complete.

The k-Colorability problem (kC OLOR)

A graph is said to be k-colorable if the vertices can be colored with k di erent colors in such a way that no two vertices of the same color share an edge. The k-Colorability problem is to determine whether or not a given finite graph is k-colorable. For k > 2, this problem is NP-complete. For k = 2, it is not (see Exercise 7.33).

Minesweeper

Many PCs come equipped with the game of Minesweeper. It is played on a grid that is, for our purposes, infinite. There are bombs behind some of the squares of the grid. The player does not know the location of these bombs. The goal

Computability and complexity

351

is to uncover squares that do not have bombs. When a square is uncovered, the player either sees a bomb and the game is over, or there is a number that tells the player how many bombs are under squares adjacent to the uncovered square.

Now suppose we are playing this game and are considering a certain covered square. We may have previously uncovered nearby squares that give us some information. There are three possibilities. Either we can deduce from the known information that there is a bomb under the square we are considering, or we can conclude that there is no bomb, or there is not enough information. To be a good Minesweeper player, we want to be able to determine which of these three situations is confronting us. This problem turns out to be NP-complete.

More precisely, if we were to uncover many squares simultaneously, then we

would see an arrangement of bombs and natural numbers. Let be the set of all finite arrangements consisting of bombs and natural numbers, including arrangements that do not follow the rules of Minesweeper. Let M S be the set of those configurations that can occur in the Minesweeper game. For example, a configuration that has a square containing the number 3 surrounded by 5 bombs is not in M S. The decision problem corresponding to the set M S is NP-complete. This problem is equivalent to the problem in the previous paragraph. If we can determine whether a given configuration is consistent with the rules of Minesweeper, then we can play the game e ectively. Given a covered square, if we can determine whether the existence of a bomb (or the lack thereof) is contradictory, then we can determine which of the three possible scenarios is confronting us.

Since they are each NP-complete, the above problems are equivalent. If we have an algorithm for solving one of these problems, then we can use that algorithm to solve all of these problems. The proof of Proposition 7.76 demonstrates how an algorithm for CLIQU E can be used for P SAT . Likewise, if you are really good at playing Minesweeper, then you can use your skill to determine whether a given graph has a Hamilton path, or is 3-colorable, or whether a given formula of propositional logic is satisfiable. More importantly, if you have a polynomial-time algorithm for solving the Minesweeper Problem, then you can win mathematical fame and the Clay Institute fortune by verifying that

P = NP.

Proposition 7.77 Some NP-complete problem is in P if and only if P = NP.

Proposition 7.78 Some NP-complete problem is in coNP if and only if

NP = coNP.

Each of these propositions follow immediately from the definition of NP-complete.

352

Computability and complexity

Both [36] and [47] are excellent sources for computational complexity. With the exception of the Minesweeper problem, each of the above decision problems can be found in each of these two books. In addition, these books describe in depth the relationship between the complexity classes of the previous section and many other complexity classes that we have not considered. The Minesweeper problem is shown to be NP-complete in the article [22].

Exercises

7.1Let {f1, f2, f3, . . .} be an enumeration of the set of unary primitive recursive functions. Let Upr be the binary function defined by Upr(x, y) = fy(x).

(a)Show that the set of unary primitive recursive functions can be enumerated in such a way that Upr(x, y) is computable.

(b)Show that the unary function defined by g(x) = Upr(x, x) + 1 is not primitive recursive.

(c)Can part (a) and (b) be repeated with the set of recursive functions in place of the set of primitive recursive functions? Why or why not?

7.2 Show that the function G(x) = xx...x is primitive recursive.

x times

7.3Show that the function F (x) = x!(x − 1)!(x − 2)! · · · 3!2!1! is primitive recursive.

7.4Show that the function E(x, n) = n!(1 + x + x22 + x3!3 + · · · + xnn! ) is primitive recursive.

7.5Show that the function P (x, y) = x!/(x − y)! is primitive recursive.

7.6Let f (x, y) and g(x) be primitive recursive functions.

(a)

Show that the function h

a(x, y) =

z<g(y) f (x, z) is primitive

recursive.

(b)Let hb(x) be the least value of y less than g(x) such that f (x, y) = 0. If no such y exists, then hb(x) = g(x). Show that the function hb(x) is primitive recursive.

7.7Let n be a natural number. If we take the definition of “recursive function” and replace the zero function Z(x) = 0 with the constant function cn(x) = n, then we obtain the set of n-recursive functions. That is, the set of n- recursive functions is the smallest set

containing the basic functions s(x), pki (x), and the constant function

cn(x), and

Computability and complexity

353

closed under composition, primitive recursion, and unbounded search.

For each n N, let N≥n = {n, n + 1, n + 2, . . .}. Prove that a function on N≥n is recursive if and only if it is n-recursive.

7.8Write T ++ programs that perform the following tasks on a T -machine:

(a)Swap the contents of B1 and B2.

(b)Set B2 equal to B1 and leave B1 unchanged.

(c)Add B1 and B2 and store the result in B2.

(d)Multiply B1 and B2 and store the result in B2.

7.9Show that the set of T -computable functions is closed under compositions and primitive recursion.

7.10Let f (x) be a function on the non-negative integers.

The history function of f (x), denoted f H (x), is defined inductively as

f H (0) = 1 and

f H (n + 1) = 2f(0)3f(1) · · · pnf(n),

where pi denotes the ith prime.

Suppose that f (x) =

g(f H (x)) for some primitive recursive

function g(x).

(a)Show that f H (x) is primitive recursive.

(b)Show that f (x) is primitive recursive.

7.11Let h1x) and h2x) be k-ary primitive recursive functions. Let g1x, y, z) and g2x, y, z) be (k+2)-ary primitive recursive functions. Suppose that (k+ 1)-ary functions f1x, y) and f2x, y) are defined by simultaneous recursion as follows.

f1(0, x¯) = h1x), f2(0, x¯) = h2x),

f1(n + 1, x¯) = g1x, f1(n, x¯), f2(n, x¯)), and f2(n + 1, x¯) = g2x, f1(n, x¯), f2(n, x¯)).

Show that both f1 and f2 are primitive recursive functions. (Hint: Consider history functions for f1 and f2 as defined in the previous exercise.)

7.12Give an explicit definition of the Ackermann function in terms of unbounded search.

7.13 Let f be a k-ary function. The graph of f is the k +1-ary relation consisting of all (¯x, y) such that f x) = y.

(a)Show that f is a primitive recursive function if and only if the graph of f is a primitive recursive set.

354

Computability and complexity

(b)Show that f is a recursive function if and only if the graph of f is a recursively enumerable set.

(c)Show that f is a total recursive function if and only if the graph of f is a recursive set.

7.14Let f (x, y) = "x/y# where "x/y# denotes the greatest integer less than x/y. Let g(x) be a primitive recursive function and let

h(x, y) =

g(x)

y = 0.

 

f (x, y)

y = 0

Show that h(x, y) is primitive recursive. (Use the previous exercise and the fact that a relation is primitive recursive if and only if it is definable by a ∆0 formula.)

7.15 Let f (x), g(x), and h(x) be primitive recursive functions. Let

e(x) =

h(x)

if f (x) + g(x) = 0.

 

f (x)g(x)

if f (x) + g(x) > 0

Show that e(x) is primitive recursive.

7.16Let ϕ(x, y) be a ∆0 formula and let f (x) be a primitive recursive function. Show that the formula y(y < f (x) ϕ(x, y)) is ∆0, where y < f (x) is an abbreviation for the Var-formula z(y + z = f (x)).

7.17Assuming that every primitive recursive set is ∆0, prove the following.

(a)

Every recursively enumerable set is 1.

 

 

 

(b)

Every recursive set is both

Π .

1 and 1

7.18Let A be an infinite set. Prove that A is recursive if and only if it is the range of an increasing recursive function.

7.19Show that every infinite recursively enumerable set has an infinite recursive subset.

7.20Let A and B be recursively enumerable sets. Show that there exist recursively enumerable subsets A1 A and B1 B such that A1 ∩ B1 = and

A1 B1 = A B.

7.21Show that the union of two recursively enumerable sets is recursive enumerable. Moreover, show that the function f (x, y) defined by Wx Wy = Wf(x,y) is a recursive function.

7.22Repeat the previous exercise with intersections instead of unions.

7.23Show that there exists a partial recursive function that cannot be extended to a total recursive function.

Computability and complexity

355

7.24 Let A and B be subsets of N {0}. We say that A and B are recursively

¯

separable if A R and B R for some recursive subset R of N. Otherwise, A and B are said to be recursively inseparable. Show that there exist recursively enumerable A and B that are recursively inseparable.

7.25Let F IN , IN F , COF , T OT , and REC be as defined in Section 7.6.1.

(a)Show that F IN ≤r COF .

(b)Show that IN F ≤r COF .

(c)Show that T OT ≤r COF .

(d)Show that COF ≤r REC.

7.26(a) Show that T OT is Π2.

 

(b)

Show that F IN is

 

2.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(c)

Show that COF is

3.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

7.27

Classify the set SQR =

e ϕ1(x) = x2

 

as either Π

n

or

 

 

n

for some n.

 

e

}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

7.28

Let Γ be either Πn or

{ |

 

 

 

 

N2

 

 

 

 

 

 

 

 

n for some n. We say that U is Γ-complete if

 

 

 

A that is Γ, A

r

U . Show that REC =

{

e : W

 

is

 

U is Γ and for any set

 

 

 

 

 

 

 

 

 

 

 

 

 

e

 

 

recursive } is

3-complete.

 

 

 

 

 

 

 

N2

 

 

 

 

 

 

 

 

7.29

Let Γ be either Π or

n

for some n. We say that U

 

is Γ-universal

 

 

 

n

 

 

 

 

 

 

 

(e, x)

 

 

U

 

.

 

 

 

if for any set A that is Γ, there exists e such that A =

{

x

 

}

 

 

 

 

 

 

 

 

 

 

 

 

 

|

 

 

 

 

 

 

(a)Show that it U is Γ-universal, then U is Γ-complete (see Exercise 7.28).

(b)

Show that if U is

¯

n-universal, then U is Πn-universal.

(c)

Show that if U is

n-universal, then U is not ∆n.

(Hint: consider the set

{x|(x, x) U }.)

7.30 Refer to the previous exercise.

(a)

Show that the set H1 from Section 7.6.1 is 1 universal.

(b)Let f : (N {0})2 (N {0}) be a recursive one-to-one correspondence.

Show that if Un is Πn-universal, then the set

 

 

{(e, n)| y(e, f (x, y)) Un}

 

 

 

(c)

is

 

n

 

n

 

n-universal.

 

 

 

 

Using the previous exercise, conclude that there exist

 

sets and Π

 

 

sets that are not ∆n for each n N.

 

 

7.31 Show that constant functions cannot by computed by a T ++ algorithm in polynomial-time. Which functions can be computed by T ++ in polynomial-time?

356

Computability and complexity

7.32Prove that every decision problem in NP is decidable.

7.33Recall the k-Colorability problem from Section 7.8.

(a)Describe a polynomial-time nondeterministic algorithm for the k-colorability problem for k > 2.

(b)Describe a polynomial-time algorithm for the 2-colorability problem.

7.34Describe an algorithm that computes f (n) = 2n and uses only k bins for some k N.

7.35For each k N, let kP SAT correspond to the set of satisfiable formulas of propositional logic that contain at most k atomic subformulas.

(a)Show that 2P SAT is in P.

(b)Using the fact that P SAT is NP-complete, show that 3P SAT is NP-complete.

7.36 Let P V AL correspond to the set of valid sentences of propositional logic. To which complexity classes does this problem belong? Is P V AL complete for any of these classes? (Use the fact that P SAT is NP-complete.)

7.37Let ϕ be a sentence in the vocabulary VR of graphs. The ϕ-Graph problem is to determine whether or not a given finite graph models ϕ. Show that the ϕ-Graph problem is in P for any first-order sentence ϕ.

8The incompleteness theorems

In this chapter we prove that the structure N = (N|+, ·, 1) has a first-order theory that is undecidable. This is a special case of G¨odel’s First Incompleteness theorem. This theorem implies that any theory (not necessarily first-order) that describes elementary arithmetic on the natural numbers is necessarily undecidable. So there is no algorithm to determine whether or not a given sentence is true in the structure N. As we shall show, the existence of such an algorithm leads to a contradiction. G¨odel’s Second Incompleteness theorem states that any decidable theory (not necessarily first-order) that can express elementary arithmetic cannot prove its own consistency. We shall make this idea precise and discuss the Second Incompleteness theorem in Section 8.5. G¨odel’s First Incompleteness theorem is proved in Section 8.3.

Although they are purely mathematical results, G¨odel’s Incompleteness theorems have had undeniable philosophical implications. G¨odel’s theorems dispelled commonly held misconceptions regarding the nature of mathematics. A century ago, some of the most prominent mathematicians and logicians viewed mathematics as a branch of logic instead of the other way around. It was thought that mathematics could be completely formalized. It was believed that mathematical reasoning could, at least in principle, be mechanized. Alfred North Whitehead and Bertrand Russell envisioned a single system that could be used to derive and enumerate all mathematical truths. In their three-volume Principia Mathematica, Russell and Whitehead rigorously define a system and use it to derive numerous known statements of mathematics. G¨odel’s theorems imply that any such system is doomed to be incomplete. If the system is consistent (which cannot be proved within the system by G¨odel’s Second theorem), then there necessarily exist true statements formulated within the system that the system cannot prove (by G¨odel’s First theorem). This explains why the name “incompleteness” is attributed to these theorems and why the title of G¨odel’s 1931 paper translates (from the original German) to “On Formally Undecidable Propositions of Principia Mathematica and Related Systems” (translated versions appear in both [13] and [14]).

Depending on one’s point of view, it may or may not be surprising that there is no algorithm to determine whether or not a given sentence is true in N. More surprising is the fact that we can prove that there is no such algorithm. The proof itself is truly remarkable. G¨odel’s proof introduced the notions of

358

The incompleteness theorems

primitive recursive sets and relations discussed in the previous chapter. G¨odel’s proof gave impetus to the subject of computability theory years before the advent of the computer. Moreover, G¨odel deduced from his proof that any decidable system that can perform arithmetic on the natural numbers cannot prove its own consistency. This is a gem of mathematical reasoning and is, by any measure, among the great results of twentieth century mathematics.

8.1 Axioms for first-order number theory

We discuss some consequences of G¨odel’s First Incompleteness theorem. We prove this theorem in Section 8.3. In the present section we accept this theorem as a fact.

We distinguish two related first-order theories. The theory of arithmetic, denoted TA is the theory of the structure A = {Z|+, ·, 0, 1}. The theory TN of the structure N = (N|+, ·, 1) is first-order number theory. We focus on the latter of these theories. By G¨odel’s First Incompleteness theorem, not only TN , but also related theories (such as TA) are undecidable.

We claim that elementary number theory is contained in TN . Peruse any book on the subject and you will find that the statements of interest (the theorems, lemmas, conjectures, and so forth) can be formulated as first-order sentences in the vocabulary VN = {1, +, ·}. For example, the following VN -formulas represent the concepts of divisibility and prime number:

let div(x, y) be z(x · z = y)

and prime(x) be z(div(z, x) → z = 1 z = x) ¬(x = 1).

By definition, N |= div(a, b) if and only if a divides b and N |= prime(a) if and only if a is prime. We can express that there are infinitely many primes with the VN -sentence

x(prime(x) → y(prime(y) y > x),

where y > x is the VN -formula z(x + z = y). Less obvious is the fact that we can express the Fundamental Theorem of Arithmetic as a VN -sentence. There are also VN -sentences that express the Chinese Remainder theorem, Wilson’s Theorem, Fermat’s Last theorem, Goldbach’s Conjecture, and Gauss’ Law of Quadratic Reciprocity.

The reader does not need to be familiar with the all of the theorems of number theory listed in the previous paragraph. In the next section we show that for every recursive subset A of Nn (for some n), there exists a VN -formula ϕA(x1, . . . , xn) such that a¯ A if and only if N |= ϕAa). This justifies our admittedly vague claim that elementary number theory is contained in first-order number theory.

The incompleteness theorems

359

The reader does need to be familiar with some basic number theory. The reader should recall the Fundamental Theorem of Arithmetic and the fact that there are infinitely many primes from the previous chapter (Sections 7.1 and 7.3). In the present chapter, we shall state and use the Chinese Remainder theorem. The reader should also be aware that the proof of Fermat’s Last Theorem eluded mathematicians for hundreds of years before Andrew Wiles proved it in 1996 and Goldbach’s Conjecture remains unanswered (see Exercise 2.8).

If TN had a decidable axiomatization, then, in principle, we could use the methods of Chapter 3 to answer every open question of number theory. By G¨odel’s First Incompleteness theorem, this is not the case. Any deductive system (such as formal proofs or resolution) has inherent limitations. Since it is undecidable, TN does not have a decidable first-order axiomatization (see Proposition 5.10). However, we now demonstrate a second-order theory containing TN that does have a decidable axiomatization.

Let us axiomatize TN . We begin with the following two axioms:

(x + 1 = 1),

x y(x + 1 = y + 1 → x = y).

Any model of these two sentences is necessarily infinite. Together they say that the function defined by (x + 1) is one-to-one but not onto. The following axioms describe addition:

x y(x + y = y + x),

x y(x + (y + 1) = (x + y) + 1).

Multiplication is described in a similar manner:

x y(x · y = y · x),

x(x · 1 = x),

x y(x · (y + 1) = (x · y) + x).

Each of these axioms is first-order. The final axiom, called the Induction Axiom, is second-order. Second-order logic is a topic of the next chapter. Presently, it su ces to say that, in second-order logic, one can quantify over relations. In the following second-order sentence, S(x) represents an arbitrary unary relation.

1S(S(1) x(S(x) → S(x + 1))) → xS(x).

In this sentence, “ 1S” is read “for all unary relations S . . . .” In e ect, the Induction Axiom says that any subset of the universe that contains 1 and is closed under the function x+1 necessarily contains every element in the universe.