Computer programs and natural number arithmetic Wong Tin Lok 27 July, 2011 Plan I What is a computer program? I What can(not) be achieved by a computer program? I Can a computer solve Diophantine equations? Characteristics of a program A (computer) program. . . I is a finite sequence of instructions that can be run by a machine; I can take a finite piece of data as input; I can return a finite piece of information as output after a finite amount of time; I may perform an infinite loop without giving an output (depending on the input). Deciding a set of natural numbers Think of k = 1 first. Convention N = {0, 1, 2, . . .} and k ∈ N. Definition A set A ⊆ Nk is decidable if there is a program P which when given any input x̄ ∈ Nk , I outputs true if x̄ ∈ A; I outputs false if x̄ 6∈ A. Global assumptions I All our programs take a fixed finite number of natural numbers as inputs. I Outputs of our programs can only be true or false, if any. I There is no time or memory restriction on our computers. We are only interested in the relationship between the inputs and the outputs of our programs. What is a program? Programs can use I variables v0 , v1 , . . .; I assignments ←; I conditionals and Boolean operations if-then, &, , not, =; I arithmetical operations and relations 0, 1, +, ×, 6; for loops; and restricted versions repeat-until loops. I I Church–Turing Thesis (Definition of a program) Every program is equivalent to one that uses only the above. Example: prime numbers Consider A = {x ∈ N : x is a prime number} ( ) ∀u,v 6x x = uv → u = 1 ∨ v = 1 = x ∈N & x 6= 1 · input x ∈ N. answer ← true. for u ← 0, . . . , x do: for v ← 0, . . . , x do: if x = uv & u 6= 1 & v 6= 1, then answer ← false. if x = 1, then answer ← false. output answer . No repeat-until is involved. Observation This program stops on all inputs. Exercise: coprime numbers Write programs that decide (a) B = {(x, y ) ∈ N2 : hcf(x, y ) = 1}; or (b) B 0 = {(x, y ) ∈ N2 : hcf(x, y ) 6= 1}. Question How to perform negation, conjunction, and disjunction on programs in general? not and Example: Fermat Last Theorem Consider C17 = x ∈ N : ∃z ∃y 6z (y 6= 0 & x 17 + y 17 = z 17 ) . input x ∈ N. repeat, starting with z ← 0: for y ← 0, . . . , z do: if y 6= 0 & x 17 + y 17 = z 17 , then answer ← true. next z until answer = true. output answer . Observation Wiles and Taylor (1995) proved that C17 = {0}. However, the program above does not stop on input 1, for example! Semidecidability (Semi- means half-.) Definition A set A ⊆ Nk is semidecidable if there is a program P such that A = {x̄ ∈ Nk : P outputs true on input x̄}. Example C17 is semidecidable. Remark All decidable sets are semidecidable. Programs and arithmetic Programs if-then, &, , not 0, 1, +, ×, 6 for loops repeat-until loops Formulas in arithmetic →, &, ∨, ¬ 0, 1, +, ×, 6 ∀v 6t and ∃v 6t ∃v Correspondence Principle The above table gives a correspondence between programs P and formulas ϕ(x̄) in arithmetic such that {x̄ ∈ N : P outputs true on input x̄} = {x̄ ∈ N : ϕ(x̄)}. Decidability is arithmetical Definition Formulas that correspond to a program are called Σ1 . They are of the form ∃v̄ χ(v̄ , x̄), where χ(v̄ , x̄) is made up of the Boolean operations, the arithmetical operations and relations, and bounded quantifiers (i.e., ∀v 6t and ∃v 6t). Correspondence Principle (restated) The semidecidable sets are exactly those of the form {x̄ ∈ Nk : ϕ(x̄)}, where ϕ(x̄) is Σ1 . Example: an infinite loop input x ∈ N. answer ← false. repeat, starting with z ← 0: if z 6= z, then answer ← true. next z until answer = true. output answer . This corresponds to the formula ∃z (z 6= z). Undecidable sets Question Are there undecidable sets? Answer Yes, by counting. Question Are all semidecidable sets decidable? Remark Our previous example C17 of a semidecidable set is decidable. The Halting Set (Halt means stop.) Definition H = {(pPq, x) ∈ N2 : the program P stops on input x}. Observation Every program P is a natural number, which we denote by pPq. Proposition H is semidecidable. Proof. Given an input (pPq, x) ∈ N2 , run the program P on input x. Theorem H is not decidable. The Halting Set H is not decidable Proof Suppose there is a program K that decides H. Let L be the following program. input pPq ∈ N. if P stops on input pPq, then perform an infinite loop, else answer ← true. output answer . L stops on input pPq Then ⇔ P does not stop on input pPq. Question What happens when we run L on input pLq? Russell’s Paradox! Running L on input pLq Proof (continued). Recall that L stops on input pPq I ⇐ ⇒ P does not stop on input pPq. If L stops on input pLq, then L does not stop on input pLq. I If L does not stop on input pLq, then L stops on input pLq. This is a contradiction. No program can check whether a program stops on an input. How mathematical is H? The halting set is not quite a ‘mathematically interesting’ object. Open problem Find a ‘mathematically interesting’ semidecidable set that is not decidable. Gödel’s Incompleteness Theorem Gödel Incompleteness Theorem (1931, rudimentary form) No program can tell us the truth of any given statement about N. Proof. I By the Correspondence Principle, there is a formula ϕ(x, y ) in arithmetic that corresponds to the Halting Set H. I Since H is not decidable, there is no program that tells us the truth of ϕ(x, y ) correctly for all x, y ∈ N. Diophantine equations Diophantine equations are polynomial equations with integer coefficients to be solved in the integers (or in the natural numbers). Examples I {(x, y , z) ∈ N3 : x 2 + y 2 = z 2 }. I {(x, y , z, w ) ∈ N4 : x 4 + y 4 + z 4 + w 4 = (x + y + z + w )4 }. I {(a, b, c) ∈ N3 : ∃x (ax 2 + bx + c = 0)}. I {(x, y , z) ∈ N3 : ∃w (x 3 + y 3 + z 3 = w 3 )}. Diophantine sets Definition A set A ⊆ Nk is Diophantine if A = {x̄ ∈ Nk : ∃v̄ p(x̄, v̄ ) = q(x̄, v̄ )} for some polynomials p, q with coefficients in N. Exercise Convince yourself that every Diophantine set is semidecidable. Hilbert’s Tenth Problem Hilbert’s Tenth Problem (1900) Find a general algorithm to solve Diophantine equations. Hilbert’s Tenth Problem (simplified form) Show that every Diophantine set is decidable. Solution (MRDP 1970) This is not possible! The solution MRDP Theorem (Matiyasevich–Robinson–Davis–Putnam) Every semidecidable set is Diophantine. Corollary There is an undecidable Diophantine set. Proof. By the MRDP Theorem, the Halting Set H is a Diophantine set that is not decidable. How mathematical is the Halting Set? Theorem (Jones 1980) H = {(ρ, x) ∈ N2 : ψ(ρ, x)}, where ψ(ρ, x) is ∃a∃b∃c∃d∃e∃f ∃g ∃h∃i∃j∃k∃l∃m∃n∃o∃p∃q∃r ∃s∃t∃u∃w ∃y ∃z∃α∃γ∃η∃θ∃λ∃τ ∃ϕ 60 elg 2 + α − (b − xy )q 2 q − b 5 λ + q 4 − 1 − λb 5 k − r − 1 − hp − h l − u − tθ e − y − mθ n − q 16 p − 2ws 2 r 2 n2 p 2 k 2 − k 2 + 1 − τ 2 2 c − 2r − 1 − ϕ θ + 2z − b 5 (zuy )2 + u + y − ρ a − (wn2 + 1)rsn2 4(c − ksn2 )2 + η − k 2 d − bw − ca + 2c − 4αγ + 5γ d 2 − (a2 − 1)c 2 − 1 f 2 − (a2 − 1)i 2 c 4 − 1 (d + of )2 − (a + f 2 (d 2 − a))2 − 1 (2r + 1 + jc)2 − 1 ! g + eq 3 + lq 5 + 2(e − zλ)(1 + xb 5 + g )4 + λb 5 + λb 5 q 4 q 4 (n2 − n) = 0. + q 3 − bl + l + θλq 3 + (b 5 − 2)q 5 (n2 − 1) − r Connections with complexity theory MRDP Theorem Every semidecidable set is Diophantine. Definition A formula is Σ0 if it is made up of the Boolean operations, the arithmetical operations and relations, and bounded quantifiers. Open question (Paris) Is the MRDP Theorem provable using only Σ0 -induction? Observation (Wilkie) If the answer is yes, then NP = co-NP. Conclusion I There is a correspondence between programs and arithmetic. I Decidability is an arithmetical property. I The Halting Set is an important undecidable set. I An analysis of undecidable sets results in number-theoretic problems that cannot be solved by a program. Webpage: http://mat140.bham.ac.uk/∼wongtl/ E-mail: wongtl03c62@gmail.com