IN210 − lecture 2 Review How to solve the information-processing problems efficiently. ; : abstraction, formalisation Problems solutions efficiency ; ; ; I/O pairs, functions, “interesting problems” algorithms resources, upper/lower bounds ; ; ; formal languages Turing machines complexity classes high-level information low-level information Autumn 1999 1 of 11 IN210 − lecture 2 Theorem 1 There are more problems than solutions. Corollarly 1 There are (many) problems that cannot be solved by algorithms. The “egg of all problems” which we want to divide into (complexity) classes: Unsolvable Intractable P Today • Turing machines as an algorithm model • Turing’s theorem which gives us a (provably) unsolvable problem. Autumn 1999 2 of 11 IN210 − lecture 2 Algorithm 11 397 46 443 397 + 46 = input 443 output computation rules Turing machine – intuitive description b ... b 0 1 0 b b ... (input/output) tape read/write head "processor" or s finite state control ... q2 q1 Autumn 1999 steps of computation ... states "loaded program" or rules δ (s,o) =( q1, b, R) δ (q1 ,1)=(q2, b , R) 3 of 11 IN210 − lecture 2 Turing machine – formal description A Turing machine (TM) is M = (Σ, Γ, Q, δ) where Σ , the input alphabet is a finitive set of input symbols Γ , the tape alphabet is a finite set of tape symbols which includes Σ, a special blank symbol b ∈ Γ \ Σ, and possibly other symbols Q is a finite set of states which includes a start state s and a halt state h δ , the transition function is δ : (Q \ {h}) × Γ → Q × Γ × {L, R} NB! “Almost” every textbook has its own unique definition of a Turing machine, but they are all equivalent in a certain sense. Autumn 1999 4 of 11 IN210 − lecture 2 Computation – formal definition A configuration of a Turing machine M is a triple C = (q, wl , wr ) where q ∈ Q is a state and wl and wr are strings over the tape alphabet. We say that a configuration (q, wl , wr ) yields in one step configuration (q 0, wl0, wr0 ) and write (q, wl , wr )` (q 0, wl0, wr0 ) if (and only if) for some M a, b, c ∈ Γ and x, y ∈ Γ∗ either wl = xa wl0 = x wl ... b b and δ(q, b) = (q 0, c, L) wr = by wr0 = acy x wr a bc w l’ y b b ... w r’ or wl = x wl0 = xb wl ... b b x w l’ Autumn 1999 and δ(q, a) = (q 0, b, R) wr = acy wr0 = cy wr ab c y b b ... w r’ 5 of 11 IN210 − lecture 2 Note: wl is the written portion of the tape to the left of the read/write head. wr is the written portion of the tape to the right of the read/write head, inluding the square the head is currently scanning. We say that a configuration C = (q, wl , qr ) yields configuration C 0 = (q 0, wl0, qr0 ) and write ∗ C ` C 0 if (and only if) there is a sequence of M configurations C = C1, C2, · · · , Cn = C 0 of M such that Ci ` Ci+1 M for i = 1, · · · , n − 1 We say that Turing machine M computes function f if (and only if) for all w1, w1 ∈ Σ∗ ∗ (s, , w1) ` (h, , w2) ⇔ f (w1) = w2 M Autumn 1999 6 of 11 IN210 − lecture 2 We say that Turing machine M decides language L if (and only if) M computes the function f : Σ∗ → {Y, N } and for each x ∈ L : f (x) = Y for each x ∈ / L : f (x) = N Language L is (Turing) decidable if (and only if) there is a Turing machine which decides it. We say that Turing machine M accepts language L if M halts if and only if its input is an string in L. Language L is (Turing) acceptable if (and only if) there is a Turing machine which accepts it. Autumn 1999 7 of 11 IN210 − lecture 2 Example A Turing machine M which decides L = {010}. ... b 0 1 0 b b ... s h qe q2 q3 q1 M = (Σ, Γ, Q, δ) Γ = {0, 1, b, Y, N } Σ = {0, 1} Q = {s, h, q1, q2, q3, qe} δ: s q1 q2 q3 qe 0 1 b (q1, b, R) (qe, b, R) (q3, b, R) (qe, b, R) (qe, b, R) (qe, b, R) (q2, b, R) (qe, b, R) (qe, b, R) (qe, b, R) (h, N, −) (h, N, −) (h, N, −) (h, Y, −) (h, N, −) (’−’ means “don’t move the read/write head”) Autumn 1999 8 of 11 IN210 − lecture 2 Church’s thesis ’Turing machine’ ∼ = ’algorithm’ Turing machines can compute every function that can be computed by some algorithm or program or computer. ’Expressive power’ of PL’s Turing complete programming languages. ’Universality’ of computer models Neural networks are Turing complete (Mc Cullok, Pitts). Uncomputability If a Turing machine cannot compute f , no computer can! Autumn 1999 9 of 11 IN210 − lecture 2 Uncomputability What algorithmic can and cannot do. Strategy 1. Show that H ALTING (the Halting problem) is unsolvable LH Unsolvable Solvable R 2. Use reductions 7−→ to show that other problems are unsolvable R1 Autumn 1999 R 2 10 of 11 IN210 − lecture 2 Step 1: H ALTING is unsolvable Def. 1 (H ALTING) LH = {(M, x)|M halts on input x} Lemma 1 Every Turing decidable language is Turing acceptable. Proof (by reduction): Given a Turing machine M that decides L we can construct a Turing machine M 0 that accepts L as follows: YES input halt M NO M’ Lemma 2 The complement of every decidable language is decidable. (The complement of language L is LC , Σ∗ \ L.) Proof: Given a Turing machine M that decides L . . . YES YES NO NO M Autumn 1999 M’ 11 of 11