
6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, 2010 Class 10 Nancy Lynch Today • Final topic in computability theory: Self-Reference and the Recursion Theorem • Consider adding to TMs (or programs) a new, powerful capability to “know” and use their own descriptions. • The Recursion Theorem says that this apparent extra power does not add anything to the basic computability model: these self-referencing machines can be transformed into ordinary non- self-referencing TMs. Today • Self-Reference and the Recursion Theorem • Topics: – Self-referencing machines and programs – Statement of the Recursion Theorem – Applications of the Recursion Theorem – Proof of the Recursion Theorem: Special case – Proof of the Recursion Theorem: General case • Reading: – Sipser, Section 6.1 Self-referencing machines and programs Self-referencing machines/programs • Consider the following program P1. •P1: – Obtain < P1 > –Output < P1 > •P1 simply outputs its own representation, as a string. • Simplest example of a machine/program that uses its own description. Self-referencing machines/programs • A more interesting example: •P2: On input w: – If w = ε then output 0 –Else • Obtain < P2 > • Run P2 on tail(w) • If P2 on tail(w) outputs a number n then output n+1. • What does P2 compute? • It computes |w|, the length of its input. • Uses the recursive style common in LISP, Scheme, other recursive programming languages. • We assume that, once we have the representation of a machine, we can simulate it on a given input. • E.g., if P2 gets < P2 >, it can simulate P2 on any input. Self-referencing machines/programs • One more example: •P3: On input w: – Obtain < P3 > – Run P3 on w –If P3 on w outputs a number n then output n+1. • A valid self-referencing program. • What does P3 compute? • Seems contradictory: if P3 on w outputs n then P3 on w outputs n+1. • But according to the usual semantics of recursive calls, it never halts, so there’s no contradiction. •P3 computes a partial function that isn’t defined anywhere. Statement of the Recursion Theorem The Recursion Theorem • Used to justify self-referential programs like P1, P2, P3, by asserting that they have corresponding (equivalent) basic TMs. • Recursion Theorem (Sipser Theorem 6.3): Let T be a TM that computes a (possibly partial) 2- argument function t: Σ* ×Σ* →Σ*. Then there is another TM R that computes the function r: Σ* →Σ*, where for any w, r(w) = t(<R>, w). The Recursion Theorem • Recursion Theorem: Let T be a TM that computes a (possibly partial) 2-argument function t: Σ* ×Σ* →Σ*. Then there is another TM R that computes the function r: Σ* → Σ*, where for any w, r(w) = t(<R>, w). <M> w • Thus, T is a TM that takes 2 inputs. • Think of the first as the description of T some arbitrary 1-input TM M. t(<M>, w) • Then R behaves like T, but with the first input set to <R>, the description w of R itself. • Thus, R uses its own representation. R t(<R>, w) The Recursion Theorem • Recursion Theorem: Let T be a TM that computes a (possibly partial) 2-argument function t: Σ* ×Σ* →Σ*. Then there is another TM R that computes the function r: Σ* → Σ*, where for any w, r(w) = t(<R>, w). <M> w • Example: P2, revisited – Computes length of input. T – What are T and R? t(<M>, w) – Here is a version of P2 with an extra input <M>: –T2: On inputs <M> and w: w • If w = ε then output 0 • Else run M on tail(w); if it outputs n then R output n+1. t(<R>, w) The Recursion Theorem • Example: P , revisited 2 <M> w –T2: On inputs <M> and w: • If w = ε then output 0 T • Else run M on tail(w); if it outputs n then output n+1. t(<M>, w) –T2 produces different results, depending on what M does. – E.g., if M always loops: w •T2 outputs 0 on input w = ε and loops on every other input. R – E.g., if M always halts and outputs 1: t(<R>, w) •T2 outputs 0 on input w = ε and outputs 2 on every other input. The Recursion Theorem • Example: P , revisited 2 <M> w –T2: On inputs <M> and w: • If w = ε then output 0 T • Else run M on tail(w); if it outputs n then output n+1. t(<M>, w) – Recursion Theorem says there is a TM R computing t(<R>, w)---just like T2 but with input <M> set to <R> for the same R. w – This R is just P2 as defined earlier. R t(<R>, w) The Recursion Theorem • Recursion Theorem (Sipser Theorem 6.3): <M> w Let T be a TM that computes a (possibly partial) 2-argument T function t: Σ* ×Σ* →Σ*. t(<M>, w) Then there is another TM R that w computes the function r: Σ* →Σ*, R where for any w, r(w) = t(<R>, w). t(<R>, w) Applications of the Recursion Theorem Applications of Recursion Theorem • The Recursion Theorem can be used to show various negative results, e.g., undecidability results. • Application 1: AccTM is undecidable – We already know this, but the Recursion Theorem provides a new proof. – Suppose for contradiction that D is a TM that decides AccTM. – Construct another machine R using self-reference (justified by the Recursion Theorem): • R: On input w: – Obtain < R > (using Recursion Theorem) – Run D on input <R, w> (we can construct <R, w> from <R> and w) – Do the opposite of what D does: • If D accepts <R, w> then reject. • If D rejects <R, w> then accept. Application 1: AccTM is undecidable • Suppose for contradiction that D decides AccTM. • R: On input w: – Obtain < R > – Run D on input <R, w> – Do the opposite of what D does: • If D accepts <R, w> then reject. • If D rejects <R, w> then accept. • RT says that TM R exists, assuming decider D exists. • Formally, to apply RT, use the 2-input machine T: • T: On inputs <M> and w: – Run D on input <M, w> – Do the opposite of what D does: • If D accepts <M, w> then reject. • If D rejects <M, w> then accept. Application 1: AccTM is undecidable • Suppose for contradiction that D decides AccTM. • R: On input w: – Obtain < R > – Run D on input <R, w> – Do the opposite of what D does: • If D accepts <R, w> then reject. • If D rejects <R, w> then accept. • Now get a contradiction: – If R accepts w, then • D accepts <R, w> since D is a decider for AccTM, so • R rejects w by definition of R. – If R does not accept w, then • D rejects <R, w> since D is a decider for AccTM, so • R accepts w by definition of R. • Contradiction. So D can’t exist, so AccTM is undecidable. Applications of Recursion Theorem • Application 2: Acc01TM is undecidable – Similar to the previous example. – Suppose for contradiction that D is a TM that decides Acc01TM. – Construct another machine R using the Recursion Theorem: • R: On input w: (ignores its input) – Obtain < R > (using RT) – Run D on input <R> – Do the opposite of what D does: • If D accepts <R> then reject. • If D rejects <R> then accept. • RT says that R exists, assuming decider D exists. Application 2: Acc01TM is undecidable • Suppose for contradiction that D decides Acc01TM. • R: On input w: – Obtain < R > – Run D on input <R> – Do the opposite of what D does: • If D accepts <R> then reject. • If D rejects <R> then accept. • Now get a contradiction, based on what R does on input 01: – If R accepts 01, then • D accepts <R> since D is a decider for Acc01TM, so • R rejects 01 (and everything else), by definition of R. – If R does not accept 01, then • D rejects <R> since D is a decider for Acc01TM, so • R accepts 01 (and everything else), by definition of R. • Contradiction. So D can’t exist, so Acc01TM is undecidable. Applications of Recursion Theorem • Application 3: Using Recursion Theorem to prove Rice’s Theorem – Rice’s Theorem: Let P be a nontrivial property of Turing-recognizable languages. Let MP = { < M > | L(M) ∈ P }. Then MP is undecidable. – Nontriviality: There is some M1 with L(M1) ∈ P, and some M2 with L(M2) ∉ P. – Implies lots of things are undecidable. – We already proved this; now, a new proof using the Recursion Theorem. – Suppose for contradiction that D is a TM that decides MP. – Construct machine R using the Recursion Theorem:… Application 3: Using Recursion Theorem to prove Rice’s Theorem • Rice’s Theorem: Let P be a nontrivial property of Turing- recognizable languages. Let MP = { < M > | L(M) ∈ P }. Then MP is undecidable. • Nontriviality: L(M1) ∈ P, L(M2) ∉ P. • D decides MP. • R: On input w: – Obtain < R > – Run D on input <R> – If D accepts <R> then run M2 on input w and do the same thing. – If D rejects <R> then run M1 on input w and do the same thing. •M1 and M2 are as above, in the nontriviality definition. • R exists, by the Recursion Theorem. • Get contradiction by considering whether or not L(R) ∈ P: Application 3: Using Recursion Theorem to prove Rice’s Theorem • Rice’s Theorem: Let P be a nontrivial property of Turing- recognizable languages. Let MP = { < M > | L(M) ∈ P }. Then MP is undecidable. •L(M1) ∈ P, L(M2) ∉ P. • D decides MP. • R: On input w: – Obtain < R > – Run D on input <R> – If D accepts <R> then run M2 on input w and do the same thing.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages46 Page
-
File Size-