Presentation is loading. Please wait.

Presentation is loading. Please wait.

15-453 FLAC Lecture 19 Turing Machines and Real Life * Reductions Mihai Budiu March 3, 2000.

Similar presentations


Presentation on theme: "15-453 FLAC Lecture 19 Turing Machines and Real Life * Reductions Mihai Budiu March 3, 2000."— Presentation transcript:

1 15-453 FLAC Lecture 19 Turing Machines and Real Life * Reductions Mihai Budiu March 3, 2000

2 03/03/2000FLAC: Reductions2 A Turing Machine solves one problem We must distinguish between –The set of all strings –A problem (e.g. the language to be accepted) –A problem instance (e.g. a word from the language) A TM solves each instance presented as inpu t  L w

3 03/03/2000FLAC: Reductions3 First computers: custom computing machines 1950 -- Eniac: the control is hardwired manually for each problem. Control Input tape (read only) Output tape (write only) Work tape (memory)

4 03/03/2000FLAC: Reductions4 TMs can be described using text Input tape (read only) Control Output tape (write only) Work tape (memory) Program n states s letters for alphabet transition function: d(q0,a) = (q1, b, L) d(q0,b) = (q1, a, R) …. Consequence: There is a countable number of Turing Machines

5 03/03/2000FLAC: Reductions5 There is a TM which can simulate any other TM (Alan Turing, 1930) Input tape Universal TM Output tape Work tape (memory) Interpreter Program

6 03/03/2000FLAC: Reductions6 The Digital Computer: a UTM Machine code Universal TM Output Memory + disk Machine-code Interpreter Input

7 03/03/2000FLAC: Reductions7 Random Access Memories Sequential access tape Column access Row access Address x x

8 03/03/2000FLAC: Reductions8 Turing machines as functions TM Input word Output word f  A function f is a computable function if a TM with word w as input halts with f(w) as output. w f(w)

9 03/03/2000FLAC: Reductions9 Computable functions Many functions encountered in everyday life are computable: –Addition : binary strings * binary strings -> binary strings –Sort : sequence of strings -> sequence of strings –Roots : polynomial -> sequence of integer roots [pg 144] A TM which decides a language computes a function from the set of all words to {y,n} There are many uncomputable functions: –|funs : N -> N| = uncountable –|TMs| = countable

10 03/03/2000FLAC: Reductions10 Compilers: computable functions Translator TM Compiler

11 03/03/2000FLAC: Reductions11 Multiple levels of virtualization Ex: running a BASIC interpreter written in Java CPU Java interpreter Basic interpreter Basic program

12 03/03/2000FLAC: Reductions12 The operating system: another (multi-tape) universal turing machine CPU Operating system Process 1Process 2 OS

13 03/03/2000FLAC: Reductions13 The operating system = dovetailing CPU Operating system Process 1Process 2 We used this technology in the proof of the last theorem during the last lecture: Theorem: L is decidable if and only if L and ~L are recognizable. Proof: execute in parallel recognizers for L and ~L and stop when the first stops.

14 03/03/2000FLAC: Reductions14 Reconfigurable Hardware Universal gates and/or storage elements Interconnection network 00010001 Universal gate = RAM a0 a1 a0 a1 data A switch is controlled by a 1-bit RAM cell 0 1 1 1 a1 & a2 Switches

15 03/03/2000FLAC: Reductions15 Reconfigurable hardware Generate a TM for a specific problem! Back to ENIAC! Compiler Program Custom hardware (configuration) If (a) c = 2; Compiler

16 03/03/2000FLAC: Reductions16 Reductions between languages ** f L1 L2 f :  * ->  *, computable f reduces L1 to L2 iff w in L1 f(w) in L2 ** f is called reduction. We write L1 L2. < m

17 03/03/2000FLAC: Reductions17 Reductions are useful Notice that neither L1 or L2 must be decidable. Theorem: if L1 L2 and L2 is decidable then L1 is decidable. Proof: If M decides L2 and N computes a reduction f from L1 to L2, build a TM P which on input w: Computes f(w) using N Runs M on f(w) Outputs the result of M. < m

18 03/03/2000FLAC: Reductions18 Using reductions to prove undecidability Use the converse of the previous theorem: if A B and A is undecidable, then B is undecidable. We have seen two techniques to prove undecidability –The “diagonalization” proof –Reductions using this theorem. < m

19 03/03/2000FLAC: Reductions19 Undecidability We know that most problems are undecidable Turing exhibited one natural undecidable problem: the Halting Problem (does a TM halt when given an input w?) More than that: many important problems are undecidable When you face a problem, you should be aware that it may be unsolvable: –You can search a solution –You can try to prove it has no solution (usu. by reduction)

20 03/03/2000FLAC: Reductions20 Some undecidable problems Does the TM M accept the word w? Is a mathematical statement true? Does a Diofantine equation have any roots? Does a TM accept a regular language? Does a CFG generate all words in  *? Will a parallel system of processes ever deadlock? Is there a smaller TM implementing the same function? Are two programs computing the same thing?

21 03/03/2000FLAC: Reductions21 Compilers and undecidability The HP is about a language describing TMs Many other problems concerning TMs are undecidable Compilers cannot prove some properties of programs: –Does a C program access an array out of bounds? –Will ever a print instruction be executed? –Can these two pointers point to the same location? –Will a LISP program crash with a type error? –Can this memory location be garbage collected at some point? Compilers behave conservatively

22 03/03/2000FLAC: Reductions22 The full-employment theorem for compiler-writers Theorem: There is no best optimizing compiler for a general-purpose language. Proof: by reduction to the HP. Theorem: For any compiler, there’s a better one. Proof: we can always hardcode a program which doesn’t terminate.

23 03/03/2000FLAC: Reductions23 Research in programming languages Contrast the decision problems for regular and context-free languages with Turing machines. Research in programming languages tries to get the best of both worlds: –Languages powerful enough to express useful computations –But restricted enough to guarantee program properties

24 03/03/2000FLAC: Reductions24 Reduction examples Definition: FIN = { M | L(M) is finite } Theorem: FIN is not Turing-recognizable. ~FIN is not Turing-recognizable. Proof: We will show ~HP FIN ~HP ~FIN Notice that HP is Turing-recognizable HP is not Turing-decidable So ~HP is not Turing-recognizable. < m < m

25 03/03/2000FLAC: Reductions25 A reduction from ~HP to FIN ** f ** ~HPFIN M#x f(M#x) f(M#x) is the description of a TM M’ which on input y: Erases the input y Writes x on the input tape Runs M on x Accepts if M halts on x

26 03/03/2000FLAC: Reductions26 Reducing ~HP to FIN (end) f(M#x) is the description of a TM M’ which on input y: Erases the input y Writes x on the input tape Runs M on x accepts if M halts on x Notice that M halts on xL(M’) =  * M does not halt on xL(M’) =  (finite) Notice that f is computable: f does not run M, f just writes down a machine M’ which calls M on x

27 03/03/2000FLAC: Reductions27 Part 2: Reducing ~HP to ~FIN ** g ** ~HPFIN M#x g(M#x) g(M#x) is the description of a TM M’’ which on input y: Saves y Writes x on the input tape Runs M on x for |y| steps Accepts if M does not halt before |y| steps ~FIN

28 03/03/2000FLAC: Reductions28 Reducing ~HP to ~FIN (end) g(M#x) is the description of a TM M’’ which on input y: Saves y Writes x on the input tape Runs M on x for |y| steps Accepts if M does not halt before |y| steps M halts on x M does not halt on x L(M’’) = { y | |y| < run-time of M on input x } finite L(M’’) =  * Again: g is a computable function it just manipulates machine descriptions.

29 03/03/2000FLAC: Reductions29 To remember The theoretical notion of TM has profoundly influenced computer engineering There are many important undecidable problems Reductions are a tool to prove problems being undecidable (Note: we will see reductions again in complexity theory; we will use them to prove a problem is the hardest in a class of problems)


Download ppt "15-453 FLAC Lecture 19 Turing Machines and Real Life * Reductions Mihai Budiu March 3, 2000."

Similar presentations


Ads by Google