Universality and Computability. 7.4 Turing Machines. Fundamental Questions. Turing Machine

Similar documents
Universality and Computability. 7.4 Turing Machines. Fundamental Questions. Turing Machine

Universality and Computability

! Princeton == center of universe. ! Hilbert, Gödel, Turing, Church, von Neumann.

Universality and Computability

Lecture 19: Universality and Computability

Fundamental Questions. Universality. What is a general purpose computer? Computability. Are there problems that no machine can solve?

COMPUTER SCIENCE. 18. Turing Machines. Section

COMPUTER SCIENCE. Computer Science. 15. Turing Machines. Computer Science. An Interdisciplinary Approach. Section 7.4.

CS.15.A.Turing.Context

Computation. Some history...

Introduction to Turing Machines

Decidability: Church-Turing Thesis

Most General computer?

CS187 - Science Gateway Seminar for CS and Math

Automata Theory. Definition. Computational Complexity Theory. Computability Theory

Decidable Languages - relationship with other classes.

Undecidability COMS Ashley Montanaro 4 April Department of Computer Science, University of Bristol Bristol, UK

Models. Models of Computation, Turing Machines, and the Limits of Turing Computation. Effective Calculability. Motivation for Models of Computation

(a) Definition of TMs. First Problem of URMs

Complexity Theory Part I

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Turing Machines. Lecture 8

Church s undecidability result

CS 301. Lecture 17 Church Turing thesis. Stephen Checkoway. March 19, 2018

highlights proof by contradiction what about the real numbers?

Turing Machines Part Three

Part I: Definitions and Properties

IV. Turing Machine. Yuxi Fu. BASICS, Shanghai Jiao Tong University

Computability Theory. CS215, Lecture 6,

TURING MAHINES

Computation Histories

Large Numbers, Busy Beavers, Noncomputability and Incompleteness

The purpose here is to classify computational problems according to their complexity. For that purpose we need first to agree on a computational

CS 275 Automata and Formal Language Theory

Computability, Undeciability and the Halting Problem

CSCE 551: Chin-Tser Huang. University of South Carolina

CS 275 Automata and Formal Language Theory

MACHINE COMPUTING. the limitations

Theory of Computation Lecture Notes. Problems and Algorithms. Class Information

Creative Objectivism, a powerful alternative to Constructivism

HIS LEGACY. 100 Years Turing celebration. Gordana Dodig Crnkovic, IDT Open Seminar. Computer Science and Network Department Mälardalen University

Gödel s Theorem: Limits of logic and computation

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Turing Machines Part III

Undecidability. Andreas Klappenecker. [based on slides by Prof. Welch]

The Legacy of Hilbert, Gödel, Gentzen and Turing

Recap (1) 1. Automata, grammars and other formalisms can be considered as mechanical devices to solve mathematical problems

Theory of Computation CS3102 Spring 2014 A tale of computers, math, problem solving, life, love and tragic death

15-251: Great Theoretical Ideas in Computer Science Fall 2016 Lecture 6 September 15, Turing & the Uncomputable

Great Theoretical Ideas

Chapter 2 Algorithms and Computation

Theory of Computer Science. Theory of Computer Science. D8.1 Other Halting Problem Variants. D8.2 Rice s Theorem

Turing Machine Recap

7.1 The Origin of Computer Science

CSCI3390-Lecture 6: An Undecidable Problem

ON COMPUTAMBLE NUMBERS, WITH AN APPLICATION TO THE ENTSCHENIDUGSPROBLEM. Turing 1936

and Models of Computation

17.1 The Halting Problem

The roots of computability theory. September 5, 2016

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) October,

Informal Statement Calculus

Turing machine recap. Universal Turing Machines and Undecidability. Alphabet size doesn t matter. Robustness of TM

Fundamentals of Computer Science

Non-emptiness Testing for TMs

Complexity Theory. Ahto Buldas. Introduction September 10, Slides based on S.Aurora, B.Barak. Complexity Theory: A Modern Approach.

Mathematical Logic. Giuseppe Peano ( ) Core Logic 2004/05-1ab p. 2/2

Understanding Computation

CS151 Complexity Theory. Lecture 1 April 3, 2017

Turing Machines (TM) The Turing machine is the ultimate model of computation.

The Church-Turing Thesis

A Note on Turing Machine Design

Turing Machines. The Language Hierarchy. Context-Free Languages. Regular Languages. Courtesy Costas Busch - RPI 1

Limits of Computability

Decision Problems with TM s. Lecture 31: Halting Problem. Universe of discourse. Semi-decidable. Look at following sets: CSCI 81 Spring, 2012

6-1 Computational Complexity

15-251: Great Theoretical Ideas in Computer Science Lecture 7. Turing s Legacy Continues

Turing Machines, diagonalization, the halting problem, reducibility

Great Ideas in Theoretical Computer Science

Complexity Theory Part I

Limits of Computation. Antonina Kolokolova

1 Showing Recognizability

CS20a: Turing Machines (Oct 29, 2002)

CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY

Turing machines and linear bounded automata

Introduction to Turing Machines. Reading: Chapters 8 & 9

COMP-330 Theory of Computation. Fall Prof. Claude Crépeau. Lec. 16 : Turing Machines

Turing Machines Decidability

Turing Machines (TM) Deterministic Turing Machine (DTM) Nondeterministic Turing Machine (NDTM)

Predicate Logic - Undecidability

CS154, Lecture 12: Kolmogorov Complexity: A Universal Theory of Data Compression

where Q is a finite set of states

Theory of Computation Lecture Notes

Turing machines and linear bounded automata

258 Handbook of Discrete and Combinatorial Mathematics

Lecture 11: Gödel s Second Incompleteness Theorem, and Tarski s Theorem

CS20a: Turing Machines (Oct 29, 2002)

CST Part IB. Computation Theory. Andrew Pitts

Lecture 14 Rosser s Theorem, the length of proofs, Robinson s Arithmetic, and Church s theorem. Michael Beeson

Recursive Function Theory and Computability

@igorwhiletrue

Transcription:

Fundamental Questions Universality and Computability Q. What is a general-purpose computer? Q. Are there limits on the power of digital computers? Q. Are there limits on the power of machines we can build? Pioneering work in the 1930s. Princeton == center of universe. Automata, languages, computability, universality, complexity, logic. David Hilbert Kurt Gödel Alan Turing Alonzo Church John von Neumann Introduction to Computer Science obert Sedgewick and Kevin Wayne Copyright 2008 * * 2 Turing Machine 7.4 Turing Machines Desiderata. Simple model of computation that is "as powerful" as conventional computers. Intuition. Simulate how humans calculate. Ex. Addition. 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 4 5 6 0 0 0 0 + 3 1 4 1 5 9 0 0 Alan Turing (1912-1954) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4

Turing Machine: Tape Turing Machine: States Tape. Stores input, output, and intermediate results. One arbitrarily long strip, divided into cells. Finite alphabet of symbols. head State. What machine remembers. State transition diagram. Complete description of what machine will do. 0 1 Tape head. Points to one cell of. eads a symbol from active cell. Writes a symbol to active cell. Moves left or right one cell at a time. + : # # : # 4 # : # H 5 + : + 1 : # if in state 3 and head is 0: write a 1 go to state 2 move head right 2 3 # : 1 head # 1 1 0 0 + 1 0 1 1 # (before) # 1 1 0 0 + 1 0 1 1 # 5 6 Turing Machine: States Binary Adder State. What machine remembers. State transition diagram. Complete description of what machine will do. subtract one from y find plus sign 0 1 + : # clean up halt + : # # : # # : # H + : + 1 : # # : # 4 # : # H 5 + : + 1 : # if in state 3 and head is 0: write a 1 go to state 2 move head right 2 3 find right end of y # : 1 add one to x # : 1 # 1 0 1 0 + 1 1 1 1 # (after) # 1 1 10 0 + 1 0 1 1 # x y 7 8

Turing Machine: Initialization and Termination Initialization. Set input on some portion of ; set head. Program and Data head # 1 0 1 0 + 1 1 1 1 # Termination. Stop if enter yes, no, or halt state. infinite loop possible 9 Program and Data Program and Data Data. Sequence of symbols (interpreted one way). Program. Sequence of symbols (interpreted another way). Data. Sequence of symbols (interpreted one way). Program. Sequence of symbols (interpreted another way). Ex 1. A compiler is a program that takes a program in one language as input and outputs a program in another language. machine language Java Ex 2. Self-replication. [von Neumann 1940s] Print the following statement twice, the second time in quotes. "Print the following statement twice, the second time in quotes." 11 12

Program and Data Program and Data Data. Sequence of symbols (interpreted one way). Program. Sequence of symbols (interpreted another way). Data. Sequence of symbols (interpreted one way). Program. Sequence of symbols (interpreted another way). Ex 3. Self-replication. [Watson-Crick 1953] Ex 4. Turing machine. % more adder.tur vertices 2 0 1 3 4 5 H 0:1 1:0 +:# #:# #:# H +:+ 1:# 0:1 #:1 1:0 edges 0 0 0 1 0 1 1 0 0 4 + # 1 3 + + 2 0 # # 3 2 # 1 3 2 0 1 3 3 1 0 4 4 1 # 4 5 # # # 1 0 1 0 + 1 1 1 1 # [1] 0 1 0 + 1 1 1 1 self-replicating DNA 13 graphical representation text representation 14 Universal Machines and Technologies 7.5 Universality Dell PC imac Diebold voting machine ipod Printer Xbox Tivo Turing machine TOY Java language MS Excel Blackberry Quantum computer DNA computer Python language 16

Universal Turing Machine Universal Turing Machine Turing machine M. Given input x, Turing machine M outputs M(x). Turing machine M. Given input x, Turing machine M outputs M(x). Universal Turing machine U. Given input with x and M, universal Turing machine U outputs M(x). x M M(x) x M M(x) M x U M(x) # 0 1 1 # # 0 1 1 # # 0 1 1 # 1 0 1 1 # data x data x data x program M TM intuition. Software program that solves one particular problem. TM intuition. Software program that solves one particular problem. UTM intuition. Hardware platform that can implement any algorithm. 17 18 Universal Turing Machine Universal Turing Machine Consequences. Your laptop (a UTM) can do any computational task. Java programming. Pictures, music, movies, games. Email, browsing, downloading files, telephony. Word-processing, finance, scientific computing. even tasks not yet contemplated when laptop was purchased Consequences. Your laptop (a UTM) can do any computational task. Java programming. Pictures, music, movies, games. Email, browsing, downloading files, telephony. Word-processing, finance, scientific computing. even tasks not yet contemplated when laptop was purchased Again, it [the Analytical Engine] might act upon other things besides numbers the engine might compose elaborate and scientific pieces of music of any degree of complexity or extent. Ada ovelace Wenger Giant Swiss Army Knife 19 20

Church-Turing Thesis Church-Turing Thesis: Evidence Church Turing thesis (1936). Turing machines can do anything that can be described by any physically harnessable process of this universe. Evidence. 7 decades without a counterexample. Many, many models of computation that turned out to be equivalent. "universal" emark. "Thesis" and not a mathematical theorem because it's a statement about the physical world and not subject to proof. Implications. No need to seek more powerful machines or languages. Enables rigorous study of computation (in this universe). but can be falsified Bottom line. Turing machine is a simple and universal model of computation. model of computation enhanced Turing machines untyped lambda calculus recursive functions unrestricted grammars extended -systems programming languages random access machines cellular automata quantum computer DNA computer description multiple heads, multiple s, 2D, nondeterminism method to define and manipulate functions functions dealing with computation on integers iterative string replacement rules used by linguists parallel string replacement rules that model plant growth Java, C, C++, Perl, Python, PHP, isp, PostScript, Excel registers plus main memory, e.g., TOY, Pentium cells which change state based on local interactions compute using superposition of quantum states compute using biological operations on DNA 21 22 indenmayer Systems: Synthetic Plants Cellular Automata: Synthetic Zoo http://astronomy.swin.edu.au/~pbourke/modelling/plants eference: Generating textures on arbitrary surfaces using reaction-diffusion by Greg Turk, SIGGAPH, 1991. History: The chemical basis of morphogenesis by Alan Turing, 1952. 23 24

Halting Problem 7.6 Computability Halting problem. Write a Java function that reads in a Java function f and its input x, and decides whether f(x) results in an infinite loop. relates to famous open math conjecture Ex. Does f(x) terminate? public void f(int x) { while (x!= 1) { if (x % 2 == 0) x = x / 2; else(x % 2 == 0) x = 3*x + 1; } } f(6): 6 3 10 5 16 8 4 2 1 f(27): 27 82 41 124 62 31 94 47 142 71 214 107 322 4 2 1 f(-17): -17-50 -25-74 -37-110 -55-164 -82-41 -122-17 26 Undecidable Problem Halting Problem Proof A yes-no problem is undecidable if no Turing machine exists to solve it. and (by universality) no Java program either Assume the existence of halt(f,x): Input: a function f and its input x. Output: true if f(x) halts, and false otherwise. Theorem. [Turing 1937] The halting problem is undecidable. Proof intuition: lying paradox. Divide all statements into two categories: truths and lies. How do we classify the statement: I am lying. Key element of lying paradox and halting proof: self-reference. Note. halt(f,x) does not go into infinite loop. We prove by contradiction that halt(f,x) does not exist. eductio ad absurdum : if any logical argument based on an assumption leads to an absurd statement, then assumption is false. encode f and x as strings public boolean halt(string f, String x) { if ( something terribly clever ) return true; else return false; } hypothetical halting function 27 28

Halting Problem Proof Halting Problem Proof Assume the existence of halt(f,x): Input: a function f and its input x. Output: true if f(x) halts, and false otherwise. Assume the existence of halt(f,x): Input: a function f and its input x. Output: true if f(x) halts, and false otherwise. Construct function strange(f) as follows: If halt(f,f) returns true, then strange(f) goes into an infinite loop. If halt(f,f) returns false, then strange(f) halts. Construct function strange(f) as follows: If halt(f,f) returns true, then strange(f) goes into an infinite loop. If halt(f,f) returns false, then strange(f) halts. f is a string so legal (if perverse) to use for second input public void strange(string f) { if (halt(f, f)) { // an infinite loop while (true) { } } } In other words: If f(f) halts, then strange(f) goes into an infinite loop. If f(f) does not halt, then strange(f) halts. 29 30 Halting Problem Proof Halting Problem Proof Assume the existence of halt(f,x): Input: a function f and its input x. Output: true if f(x) halts, and false otherwise. Assume the existence of halt(f,x): Input: a function f and its input x. Output: true if f(x) halts, and false otherwise. Construct function strange(f) as follows: If halt(f,f) returns true, then strange(f) goes into an infinite loop. If halt(f,f) returns false, then strange(f) halts. Construct function strange(f) as follows: If halt(f,f) returns true, then strange(f) goes into an infinite loop. If halt(f,f) returns false, then strange(f) halts. In other words: If f(f) halts, then strange(f) goes into an infinite loop. If f(f) does not halt, then strange(f) halts. In other words: If f(f) halts, then strange(f) goes into an infinite loop. If f(f) does not halt, then strange(f) halts. Call strange()with ITSEF as input. If strange(strange) halts then strange(strange) does not halt. If strange(strange) does not halt then strange(strange) halts. Call strange()with ITSEF as input. If strange(strange) halts then strange(strange) does not halt. If strange(strange) does not halt then strange(strange) halts. Either way, a contradiction. Hence halt(f,x) cannot exist. 31 32

Consequences More Undecidable Problems Q. Why is debugging hard? A. All problems below are undecidable. Halting problem. Give a function f, does it halt on a given input x? Totality problem. Give a function f, does it halt on every input x? No-input halting problem. Give a function f with no input, does it halt? Program equivalence. Do two functions f and always return same value? Uninitialized variables. Is the variable x initialized before it's used? Dead-code elimination. Does this statement ever get executed? Hilbert's 10 th problem. Devise a process according to which it can be determined by a finite number of operations whether a given multivariate polynomial has an integral root. David Hilbert f (x, y, z) = 6x3 y z 2 + 3xy 2 - x 3 10. yes : f (5, 3, 0) = 0. f (x, y) = x2 + y 2 3. no. Definite integration. Given a rational function f (x) composed of + polynomial and trig functions, does f (x) dx exist? g(x) = cos x (1 + x 2 ) -1 + yes, g(x) dx = π /e. h(x) = cos x (1 - x 2 ) -1 + no, h(x) dx undefined. 33 34 More Undecidable Problems More Undecidable Problems Optimal data compression. Find the shortest program to produce a given string or picture. Virus identification. Is this program a virus? Mandelbrot set (40 lines of code) Private Sub AutoOpen() On Error esume Next If System.PrivateProfileString("", CUENT_USE\Software\Microsoft\Office\9.0\Word\Security", "evel") <> "" Then CommandBars("Macro").Controls("Security...").Enabled = False... For oo = 1 To AddyBook.AddressEntries.Count Can write programs in MS Word. Peep = AddyBook.AddressEntries(x) This statement disables security. BreakUmOffASlice.ecipients.Add Peep x = x + 1 If x > 50 Then oo = AddyBook.AddressEntries.Count Next oo... BreakUmOffASlice.Subject = "Important Message From " & Application.UserName BreakUmOffASlice.Body = "Here is that document you asked for... don't show anyone else ;-)"... Melissa virus March 28, 1999 35 36

Context: Mathematics and ogic Turing's Key Ideas Mathematics. Any formal system powerful enough to express arithmetic. Principia Mathematics Peano arithmetic Zermelo-Fraenkel set theory Complete. Can prove truth or falsity of any arithmetic statement. Consistent. Can't prove contradictions like 2 + 2 = 5. Decidable. Algorithm exists to determine truth of every statement. Q. [Hilbert, 1900] Is mathematics complete and consistent? A. [Gödel's Incompleteness Theorem, 1931] No!!! Turing machine. formal model of computation Program and data. encode program and data as sequence of symbols Universality. concept of general-purpose, programmable computers Church-Turing thesis. computable at all == computable with a Turing machine Computability. inherent limits to computation Q. [Hilbert's Entscheidungsproblem] Is mathematics decidable? A. [Church 1936, Turing 1936] No! Hailed as one of top 10 science papers of 20 th century. eference: On Computable Numbers, With an Application to the Entscheidungsproblem by A. M. Turing. In Proceedings of the ondon Mathematical Society, ser. 2. vol. 42 (1936-7), pp.230-265. 37 38 Alan Turing Alan Turing (1912-1954). Father of computer science. Computer science's "Nobel Prize" is called the Turing Award. It was not only a matter of abstract mathematics, not only a play of symbols, for it involved thinking about what people did in the physical world. It was a play of imagination like that of Einstein or von Neumann, doubting the axioms rather than measuring effects. What he had done was to combine such a naïve mechanistic picture of the mind with the precise logic of pure mathematics. His machines soon to be called Turing machines offered a bridge, a connection between abstract symbols, and the physical world. John Hodges Alan Turing (left) Elder brother (right) 39