computational models: class...

65
Computational Models: Class 8 y Benny Chor School of Computer Science Tel Aviv University December 7, 2015 y Based on slides by Maurice Herlihy, Brown University, and modications by Iftach Haitner and Yishay Mansour. Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 1 / 65

Upload: others

Post on 26-Sep-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Computational Models: Class 8†

Benny Chor

School of Computer ScienceTel Aviv University

December 7, 2015

†Based on slides by Maurice Herlihy, Brown University, and modifications by IftachHaitner and Yishay Mansour.

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 1 / 65

Page 2: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Class Outline

Universal TMs, HTM /∈ R, an L3 /∈ RE ∪ co−RE (reminder)Hilbert’s 10th problemMapping reductionsProving undecidability by mapping reductionsThe Busy Beaver problem

Sipser’s book, 5.1–5.3

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 2 / 65

Page 3: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Part I

Previous Lecture – Reminders

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 3 / 65

Page 4: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Encoding of Turing Machines

Just like any piece of code in any programming language, Turingmachines can be encoded as strings.Such encoding will enable us

To check (by an algorithm) that a given string is a legal encodingof a TM.(Similar to a compiler checking for syntax errors.)To build a universal machine that can read such encoding andemulates the encoded TM on any input string.(Similar to running an interpreter.)

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 4 / 65

Page 5: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Universal Turing Machines

Algorithm 1 (Universal TM U)On input 〈M,w〉, where 〈M〉 and 〈w〉 are binary strings separated by111.

Checks that 〈M,w〉 is a proper encoding of a TM.Emulate M(w) (how?)

I Accept, if M enters its accept stateI Reject, if M enters its reject state

Notice that as a consequence, if M on input w enters an infinite loop,so does U on input 〈M,w〉.

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 5 / 65

Page 6: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Universal Turing Machines (2)

The universal machine U obviously has a fixed number of states(100 should do).Despite this, it can simulate machines M with many more states.Universal machines inspired the development of stored-programcomputers in the 40s and 50s.Most of you have seen a universal machine, and have even usedone!

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 6 / 65

Page 7: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Alan Mathison Turing: The Halting Problem is Undecidable

(figure courtesy of Sivan Toledo)

Turing has shown that no computer program can check if a computercode (say written in Python) will halt or enter an infinite loop.

This is a fundamental limitation of computations. Not just a limitation ofa specific programming language or a manifestation of incompetenceof today’s programmers.

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 7 / 65

Page 8: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

The Acceptance Problem (a close sister of the Halting Problem)

ATM = {〈M,w〉|M is a TM that accepts w}

HTM = {〈M,w〉|M is a TM that halts on w}

Theorem 2ATM is recursively enumerable (namely in ATM ∈ RE).

Proof: The universal machine accepts ATM. ♣

Theorem 3ATM is not recursive (namely ATM /∈ R).

Proof: A diagonalization argument. ♣

Small modifications yield proofs of HTM ∈ RE and HTM /∈ R as well.

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 8 / 65

Page 9: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

A Non-Enumerable Language

We already saw two non-decidable language: ATM and HTM.Can we do better (i.e., worse)?We now display a language that isn’t even recursively enumerable. . . .

Corollary 4

If L is not decidable, then either L or L is not recursively enumerable.

Proof: Assume otherwise, by R = RE ∩ co−RE , L would bedecidable. ♣

Corollary 5

ATM is not recursively enumerable

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 9 / 65

Page 10: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

A Language Outside RE ∪ co−RE

Consider the languageL3 = {〈M1〉,w1, 〈M2〉,w2|w1 ∈ L(M1),w2 6∈ L(M2)}.

We will show that L3 6∈ RE and also L3 6∈ co−RE .

The idea of the proof is that if L3 ∈ co−RE , we can design a Turingmachine, M ′, which accepts ATM.

And if L3 ∈ RE , we can design another Turing machine, M ′′, which alsoaccepts ATM.

In both cases, this leads to a contradiction, as ATM /∈ RE .

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 10 / 65

Page 11: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Claim: L3 6∈ RE

Recall L3 = {〈M1〉,w1, 〈M2〉,w2|w1 ∈ L(M1),w2 6∈ L(M2)}

Proof:Assume that L3 ∈ RE , i.e., ∃M∗ s.t. L3 = L(M∗).

Algorithm 6 (TM M ′ for ATM)On input 〈M,w〉

1 Let M1 be a TM s.t. L(M1) = 1∗.

2 Give 〈M,w〉, generate < M1,1,M,w >.

3 Run M∗ on < M1,1,M,w >.

4 If M∗ accepts < M1,1,M,w >, then M ′ will accept 〈M,w〉.

M ′ accepts ATM, contradiction. ♣

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 11 / 65

Page 12: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Claim: L3 6∈ co−RE

Recall L3 = {〈M1〉,w1, 〈M2〉,w2|w1 ∈ L(M1),w2 6∈ L(M2)}.

Proof:Assume that L3 ∈ co−RE , i.e. ∃M∗∗ s.t. L̄3 = L(M∗∗).

Algorithm 7 (TM M ′′ for ATM)On input 〈M,w〉

1 Let M2 be a TM s.t. L(M2) = 0∗.

2 Given 〈M,w〉, generate < M,w ,M2,1 >.

3 Run M∗∗ on < M,w ,M2,1 >.

4 If M∗∗ accepts < M,w ,M2,1 >, then M ′′ will accept 〈M,w〉.

M ′′ accepts ATM, contradiction. ♣

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 12 / 65

Page 13: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

And Now to Something Completely Different:Hilbert’s 10th Problem

Har Karbolet, south east boundary of The Big CraterBenny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 13 / 65

Page 14: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Part II

Hilbert’s Tenth Problem

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 14 / 65

Page 15: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Hilbert’s 10th Problem

In 1900, David Hilbert delivered a now-famous address at theInternational Congress of Mathematicians in Paris, France.

Presented 23 central mathematical problems, (additional ref)challenge for the next (20th) centurythe 10th problem directly concerned algorithms

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 15 / 65

Page 16: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Hilbert’s Tenth Problem

The Problem: Devise an algorithm that tests whether a multivariatepolynomial with integer coefficients† has an integral root.

Actually, what he said (translated from German) was

“to devise a process according to which it can be determinedby a finite number of operations”.

Note thatHilbert explicitly asks that algorithm be “devised”apparently Hilbert assumes that such an algorithm must exist, andsomeone “only” need find it.

†e.g. 3x2y2 + z2 − 2 or x3 + y3 + t4 − z3 − 3xytzBenny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 16 / 65

Page 17: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Hilbert’s Tenth Problem

We now know no algorithm exists for this task.Mathematicians in 1900 could not have proved this, because theydidn’t have a formal notion of an algorithm.Intuitive notions suffice for constructing algorithms, like Euclid gcdor Newton–Raphson root finding (we know one when we see it).

Formal notions are required to show that no algorithm exists.

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 17 / 65

Page 18: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Hilbert’s Tenth Problem

In 1970, 23 years old Yuri Matijasevic̆, building on work of MartinDavis, Hilary Putnam, and Julia Robinson, proved that no algorithmexists for testing whether a multivariate polynomial has integral roots(a survey of the proof)

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 18 / 65

Page 19: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Reformulating Hilbert’s Tenth Problem

Consider the language:

D = {p | p is a multivariate polynomial with integer coefficients,which has an integral root}

Hilbert’s tenth problem asks whether this language is decidable.

It is easy to see that this language is recursively enumerable(why?).

By Matijasevic̆ theorem, it is not decidable, so it is in RE \ R.

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 19 / 65

Page 20: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Univariate Polynomials

Consider the simpler language:

D1 = {p | p is a polynomial over x with an integral root}

Here is an algorithm that accepts D1.On input p,

evaluate p with x set successively to 0,1,−1,2,−2, . . ..if p evaluates to zero, accept.

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 20 / 65

Page 21: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Univariate Polynomials (2)

D1 = {p | p is a polynomial over x with an integral root}

Note that

If p has an integral root, the machine accepts.If not, M1 loops.M1 is an acceptor, but not a decider.

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 21 / 65

Page 22: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Univariate Polynomials (3)

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 22 / 65

Page 23: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Univariate Polynomials (4)

In fact, D1 is decidable.

Can show that all real roots of p[x ] lie inside interval

( −|kcmax/c1|, |kcmax/c1| ) ,

where k is number of terms, cmax is max coefficient, and c1 ishigh-order coefficient.

By Matijasevic̆ theorem, such effective bounds on range of real rootscannot be computed for multivariable polynomials.

Furthermore, it was shown that the problem is undecidable even whenrestricted to polynomials of degree ≤ 4 in just nine variables.

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 23 / 65

Page 24: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

And Now to Something Completely Different:Reductions

Har Karbolet, south east boundary of The Big CraterBenny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 24 / 65

Page 25: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Part III

Reductions

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 25 / 65

Page 26: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Reminder and Goal

We have alreadyEstablished Turing Machines as the gold standard of computersand computability.Seen examples of solvable problems.And saw two related problem, ATM and HTM that arecomputationally unsolvable (i.e. undecidable)

ATM = {〈M,w〉 |M is a TM that accepts w}

HTM = {〈M,w〉 |M is a TM that halts on input w}

Today, we look at other computationally unsolvable problems, andprove undecidability via the technique of mapping reductions.

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 26 / 65

Page 27: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Computable Functions

Definition 8 (total computable functions)A TM M computes a total function f : Σ∗ −→ Σ∗, if when starting withan input w , M halts with (only) f (w) written on tape.a

aThe definition naturally extends to functions of more than one variable,where some special separator symbol indicates end of one variable andbeginning of next.

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 27 / 65

Page 28: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Computable Functions (take 2)

Definition 9 (partially computable functions)A TM M computes a partial function f : Σ∗ −→ (Σ∗∪ ⊥), if whenstarting with an input w :

if f (w) is defined (i.e., 6=⊥), M halts with only f (w) on tape,if f (w) is undefined, M does not halt.

Computable functions are also called (total or partial) recursivefunctions.

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 28 / 65

Page 29: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Examples

Claim 10All the “usual” arithmetic functions on integers are computable.

These include addition, subtraction, multiplication, division (quotientand remainder), exponentiation, roots (to a specified precision),modular exponentiation, greatest common divisor.

Even non-arithmetic functions, like logarithms and trigonometricfunctions, can be computed (to a specified precision), using Taylorexpansion or other numeric mathematic techniques.

Exercise 11Design a TM that on input 〈m,n〉, halts with 〈m + n〉 on tape.

Remark: Note that unary, binary, octal, decimal, or hexadecimalencoding of the numbers will influence the details of such TM.

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 29 / 65

Page 30: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Examples, take 2

A useful class of functions modifies TM descriptions. For example†:

Algorithm 12On input w : If w 6= 〈M〉 for some TM, return w .Else if w = 〈M〉 for some TM, return 〈M ′〉, where

L(M ′) = L(M), andM ′ does not halt for w 6∈ L(M ′)

Question 13Is the function defined above total? is it computable?

†We saw TM encodings in lecture 7. Checking if a string is a legal TM encoding isa simple syntactic issue, similar to IDLE checking that a given Python program issyntactically OK - parenthesis are balanced, newline and tab after a colon, etc.

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 30 / 65

Page 31: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Examples, take 3

Implementing the M to M ′ transformation:

Given M = (Q,Σ, Γ, δ,q0,qa,qr ), build M ′ = (Q′,Σ, Γ, δ′,q0,qa,qr )

Let Q′ = Q ∪ {q∗} (a new state).Define δ′ as follows:

δ′(q, σ) :=

(q∗, σ,R), if δ(q, σ) = (qr , ·, ·) M’ enters q∗

(q∗, σ,R) q = q∗ in q∗, M’ moves right(q′, σ′,D), otherwise if δ(q, σ) = (q′, σ′,D)

Question 14Suppose your input is a Python function that returns either True orFalse. Viewing it as a string, how would you code (in Python) amodification similar to the above?

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 31 / 65

Page 32: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Reducibility

Finding your way around a new city, reduces to . . .obtaining a city map (more realistically, it probably reduces tohaving google maps on your smartphone :-).Finding the median in an array, reduces to . . . sorting an array.

This is the core idea behind programming languages’ functionsand procedures.

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 32 / 65

Page 33: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Reducibility, in our Context

Involves two problems, or languages, A and B.

Desired property: If A reduces to B, then any solution of B can be usedto find a solution of A.

Remark 15“A reduces to B” says nothing about solving A by itself or B by itself.

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 33 / 65

Page 34: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Reducibility, in our Context (cont.)

Fact 16If A reduces to B, then A cannot be harder than B

if B is decidable, so is A.if A is undecidable, then B is undecidable.

We next use reductions and the undecidability of ATM, to show theundecidability of several additional problems.

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 34 / 65

Page 35: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

HTM is undecidable

ATM = {〈M,w〉|M is a TM that accepts w}HTM = {〈M,w〉|M is a TM and M halts on input w}

Theorem 17HTM is undecidable.

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 35 / 65

Page 36: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

HTM is undecidable (proof by reduction)

Proof: Assume, by way of contradiction, that TM R decides HTM.

Algorithm 18 (TM S)On input 〈M,w〉,

1 Emulate R on 〈M,w〉.2 If R rejects, reject.3 If R accepts (meaning M halts on w), emulate M on w until it halts

(namely run U on 〈M,w〉).4 If M accepted, accept; otherwise reject.

TM S decides ATM, a contradiction ♣

What we actually did is a reduction from ATM to HTM.

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 36 / 65

Page 37: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

REGTM is Undecidable (does a TM Accepts a Regular Language)

Consider the languageREGTM = {〈M〉 |M is a TM and L(M) is regular}

Theorem 19REGTM is undecidable.

Proof’s idea: By contradiction.Assume REGTM is decidable and let R be a TM that decidesREGTM.Use R to construct S – a TM that decides ATM.

Question 20But how we construct S?

Intuition: On input 〈M,w〉, build Mw that accepts a regular language iffM accepts w .

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 37 / 65

Page 38: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

The Turing Machine Mw : Design Goals and ImplementationDesign Goals:

if M does not accept w , then Mw accepts the (non-regular)language {0n1n|n ≥ 0}if M accepts w , then Mw accepts the (regular) language Σ∗ .

Implementation:

Algorithm 21 (Mw )On input x ,

1 If x has the form 0n1n, accept it.2 Otherwise, emulate M on input w and accept x if M accepts w .

Claim 221 If M does not accept w , then Mw accepts (the language){0n1n|n ≥ 0}.

2 If M accepts w , then Mw accepts (the language) Σ∗.3 The function: on input 〈M,w〉 output 〈Mw 〉, is computable.

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 38 / 65

Page 39: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

REGTM is Undecidable: The Turing Machine S

Algorithm 23 (S)On input 〈M,w〉,

1 Construct Mw from M and w .2 Emulate R on input 〈Mw 〉, where R be a TM that decides REGTM.3 If R accepts, accept; if R rejects, reject.

Claim 24S decides ATM.

A contradiction to the undecidability of ATM. ♣

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 39 / 65

Page 40: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Bucket of Undecidable Problems

Same techniques can be used to prove undecidability of

Does a TM accept the empty language?Does a TM accept a decidable language?Does a TM accept a context-free language?Does a TM accept a finite language?Does a TM halt on all inputs?Is there an input string that causes a TM to traverse all its states?

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 40 / 65

Page 41: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

And Now to Something Completely Different:Mapping Reductions

The lower part of Nahal Ofran, south east boundary of The Big CraterBenny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 41 / 65

Page 42: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Part IV

Mapping Reductions

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 42 / 65

Page 43: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Reducibility

So far, we have seen a few examples of reductions from one languageto another, but the notion was neither defined nor treated very formally.

Reductions play an important role indecidability theory (here and now)complexity theory (to come)

Time to get formal.

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 43 / 65

Page 44: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Mapping Reductions

Definition 25A total, computable function f : Σ∗ −→ Σ∗ is a reduction from languageA to language B, if w ∈ A⇐⇒ f (w) ∈ B, for every w ∈ Σ∗.

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 44 / 65

Page 45: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Mapping Reductions, take 2

If a reduction from A to B exists, we say that A is mapping reducible toB, denoted by A ≤m B.

A mapping reduction converts questions about membership in A toquestions about membership in B†

Remark 26

Note that A ≤m B ⇐⇒ A ≤m B

†but not the other way around, as we will see soon.Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 45 / 65

Page 46: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Applications

Theorem 27If A ≤m B and B is decidable, then A is decidable.

Proof: Let M be the decider for B, and f a (mapping) reduction from Ato B.

Algorithm 28 (N)On input w

1 Compute f (w)

2 Emulate M on input f (w) and output exactly what M outputs. ♠

Corollary 29If A ≤m B and A is undecidable, then B is undecidable.

In fact, this corollary has already been implicitly used when we provedundecidability of languages other than ATM.

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 46 / 65

Page 47: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

HTM is Undecidable – Revisited

Recall thatATM = {〈M,w〉|M is a TM that accepts w}HTM = {〈M,w〉|M is a TM and M halts on input w}

Earlier we proved that HTM undecidable by (de facto) reduction fromATM. Let us reformulate this by an explicit mapping reduction.

Claim 30ATM ≤m HTM

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 47 / 65

Page 48: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

HTM is Undecidable – Revisited (cont.)

The following computable, program modification function, f ,establishes 〈M,w〉 ∈ ATM ⇐⇒ f (〈M,w〉) ∈ HTM.

Definition 31 (f )

On input 〈M,w〉, return 〈M`oop,w〉.TM M`oop is defined as follows:On input x , emulate M(x) and

accepts if M accepts; enters a loop if M rejects.

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 48 / 65

Page 49: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Building M`oop

Yes, you are right. We have already seen this construction:

Given M = (Q,Σ, Γ, δ,q0,qa,qr ), buildM`oop = (Q′,Σ, Γ, δ′,q0,qa,qr )

Let Q′ = Q ∪ {q∗}Define δ′ as follows:

δ′(q, σ) :=

(q∗, σ,R), if δ(q, σ) = (qr , ·, ·)(q∗, σ,R) q = q∗

(q′, σ′,D), otherwise if δ(q, σ) = (q′, σ′,D)

Note that L(M`oop) = L(M) and 〈M,w〉 ∈ ATM⇐⇒ f (〈M,w〉) ∈ HTM

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 49 / 65

Page 50: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

HTM,ε is Undecidable

We have defined HTM = {〈M,w〉 |M is a TM and M halts on input w},and define now HTM,ε = {〈M〉 |M is a TM and M halts on input ε}.

Claim 32HTM ≤m HTM,ε

The following computable function f establishes〈M,w〉 ∈ HTM ⇐⇒ f (〈M,w〉) ∈ HTM,ε.

Definition 33 (f )On input 〈M,w〉, return 〈Me

w 〉.TM Me

w is defined as follows:On input x , erase x , write (the now fixed) w , and emulate M on input w .

If the input to f is not of the form 〈M,w〉, f produces 〈Mloop〉, anencoding of a TM that never halts.

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 50 / 65

Page 51: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Building Mew (for those rough souls)

Given M = (Q,Σ, Γ, δ,q0,qa,qr ) and w = w1, . . .wn, buildMe

w = (Q′,Σ, Γ, δ′,−→q 1,qa,qr ), assume n ≥ 1.Let Q′ = Q ∪ {−→q 1, . . .

−→q n+1,←−q ,←−q 1}

Define δ′ as follows:

δ′(q, σ) :=

(−→q 2, $,R) q =

−→q 1(−→q i+1,wi ,R) q =

−→q i ,2 ≤ i ≤ n(−→q n+1, ,R) q =

−→q n+1, σ 6=(←−q , σ,L) q =

−→q n+1, σ =

(←−q , σ,L) q =

←−q , σ 6= $

(←−q 1,w1,R) q =

←−q , σ = $

(q0, σ,L) q =←−q 1

(q′, σ′,D), otherwise if δ(q, σ) = (q′, σ′,D)

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 51 / 65

Page 52: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

HTM,ε is Undecidable, concluding

If M halt on w , then Mew halts on every input x , including ε.

If M does not halt on w , then Mew does not halt on any input x ,

including ε.

Thus, Mew halts on ε⇐⇒ M halts on w .

In other words, 〈M,w〉 ∈ HTM ⇐⇒ f (〈M,w〉) = 〈Mew 〉 ∈ HTM,ε,

establishing that indeed HTM ≤m HTM,ε. ♠

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 52 / 65

Page 53: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

The Mapping Reducible Relation is Not Symmetric

HTM,ε = {〈M〉|M is a TM and M halts on ε}

Claim 34Let L = {0n : n ∈ N}. Then L ≤m HTM,ε, but HTM,ε �m L

Proof: It is easy to show that HTM,ε �m L (ahhhm..., why?).For proving L ≤m HTM,ε, define f as follows:

Definition 35 (f )On input w . Return 〈MHalt〉 if w ∈ L, and return 〈MLoop〉 otherwise.Where MHalt halts on ε, and MLoop loops on ε.

Note that deciding membership in L is really easy, and that both 〈MHalt〉and 〈MLoop〉 are just fixed strings, which can be hard wired into themachine that computes f .

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 53 / 65

Page 54: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Enumerability

Theorem 36If A ≤m B and B is enumerable, then A is enumerable.

Proof is same as before, using accepters instead of deciders.

Corollary 37If A ≤m B and A is not enumerable, then B is not enumerable.

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 54 / 65

Page 55: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

TM Equality

EQTM = {〈M1,M2〉 : M1,M2 are TMs and L(M1) = L(M2)}

Theorem 38

Both EQTM and, its complement, EQTM, are not enumerable.

Stated differently, EQTM is neither enumerable nor co-enumerable, orEQTM /∈ RE ∪ co−RE .This is the second time we see a language /∈ RE ∪ co−RE .

We will show that

ATM ≤m EQTM, and ATM ≤m EQTM.It follows that ATM ≤m EQTM and ATM ≤m EQTM (why?)Hence, neither EQTM nor EQTM are enumerable.

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 55 / 65

Page 56: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

ATM ≤m EQTM

Claim 39ATM ≤m EQTM.

Definition 40 (f )On input 〈M,w〉

1 Construct a machine M1 that accepts Σ∗

2 Construct a machine M2 (= Mew ) accepting all x , iff M accepts w .

3 Return 〈M1,M2〉.

Noteif M accepts w , then M2 accepts everything. Otherwise, M2accepts nothing.Hence, 〈M,w〉 ∈ ATM ⇐⇒ 〈M1,M2〉 ∈ EQTM. ♣

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 56 / 65

Page 57: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

ATM ≤m EQTM

Claim 41

ATM ≤m EQTM.

Definition 42 (f )On input 〈M,w〉:

1 Construct a machine M1 that accepts ∅.2 Construct a machine M2 (= Me

w ) accepting all x , iff M accepts w .3 Return 〈M1,M2〉.

NoteIf M accepts w then M2 accepts everything. Otherwise, M2accepts nothing.Hence, 〈M,w〉 ∈ ATM ⇐⇒ 〈M1,M2〉 ∈ EQTM ♣

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 57 / 65

Page 58: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

TM Equality, Summary

Since ATM ≤m EQTM, then ATM ≤m EQTM

Since ATM ≤m EQTM then ATM ≤m EQTM

Hence, neither EQTM nor EQTM are enumerable.Stated differently, EQTM is neither enumerable nor co-enumerable,or EQTM /∈ RE ∪ co−RE .

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 58 / 65

Page 59: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

And Now to Something Completely Different:The Busy Beaver Problem

Nahal Ofran, south east boundary of The Big CraterBenny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 59 / 65

Page 60: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

Part V

The Busy Beaver Problem

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 60 / 65

Page 61: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

The Busy Beaver Function, Definition

We focus on one tape TMs, with Σ = {0,1} and Γ = {0,1, }.

Definition 43 (Sn and BB(n))

For n ∈ N, let Sn = {all n-state TM’s that halt on ε}.Let BB(n) be maximum # of steps taken by some M ∈ Sn on input ε.

The set Sn is finite (under standard encoding).Every M ∈ Sn runs for finitely many steps on ε.BB(n) is a total function from N to N (in particular, BB(n) ∈ N forevery n ∈ N).

Known bounds on values of BB (size not including qA,qR states):

size (n) 2 3 4 5 6BB(n) 6 21 107 ≥ 47,176,870 ≥ 7.4× 1036534

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 61 / 65

Page 62: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

The Busy Beaver Function is Not Computable

The BB(n) function grows way too fast. No TM can cope with suchrapid growth. This leads to

Theorem 44The busy beaver function is not computable.

Proof: Consider the undecidable languageHTM,ε = {〈M〉|M is a TM and M halts on ε}.

Suppose, towards a contradiction, that BB is computable, using TM R.

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 62 / 65

Page 63: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

The Busy Beaver Function is Not Computable

Suppose, towards a contradiction, that BB is computable, using TM R.

Algorithm 45 (S)On input 〈M〉

1 Determine the number of states in M, n, and computem = R(n) = BB(n).

2 Emulate M on ε for m + 1 steps.3 If M halts then accept, otherwise reject.

Note that if M did not halt in m + 1 steps, then it will never halt!

Claim 46S decides HTM,ε (a contradiction to BB(·) being computable). ♣.

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 63 / 65

Page 64: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

The Busy Beaver Problem

(taken from http://www.saltine.org/joebeaver1.jpg)

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 64 / 65

Page 65: Computational Models: Class 8ytau-cm2016.wdfiles.com/local--files/course-schedule/Lecture8.pdfHilbert’s 10th problem Mapping reductions Proving undecidability by mapping reductions

The Bounded Busy Beaver Function Is Computable

Definition 47For d ∈ N, define the function BBd : N 7→ N as

BBd (n) :=

{BB(n), n ≤ d ,0, otherwise.

Theorem 48The function BBd is computable for every d ∈ N.

Proof’s idea: “Hardwire" the values BB(1) . . . ,BB(d) into a TM tocompute BBd .Note: Existential proof.

Benny Chor (Tel Aviv University) Computational Models, Class 8 December 7, 2015 65 / 65