15-251 Great Theoretical Ideas in Computer Science.

Slides:



Advertisements
Similar presentations
Turing Machines Memory = an infinitely long tape Persistent storage A read/write tape head that can move around the tape Initially, the tape contains only.
Advertisements

CS 345: Chapter 9 Algorithmic Universality and Its Robustness
Variants of Turing machines
Foundations of (Theoretical) Computer Science Chapter 3 Lecture Notes (Section 3.2: Variants of Turing Machines) David Martin With.
Turing Machines (At last!). Designing Universal Computational Devices Was Not The Only Contribution from Alan Turing… Enter the year 1940: The world is.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Variants.
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture11: Variants of Turing Machines Prof. Amos Israeli.
Lecture 8 Recursively enumerable (r.e.) languages
CS5371 Theory of Computation Lecture 11: Computability Theory II (TM Variants, Church-Turing Thesis)
CHAPTER 3 The Church-Turing Thesis
CS5371 Theory of Computation Lecture 10: Computability Theory I (Turing Machine)
Computability and Complexity 3-1 Turing Machine Computability and Complexity Andrei Bulatov.
Turing Machines CS 105: Introduction to Computer Science.
1 Introduction to Computability Theory Lecture11: The Halting Problem Prof. Amos Israeli.
Theory of Computation. Computation Computation is a general term for any type of information processing that can be represented as an algorithm precisely.
Turing Machines A more powerful computation model than a PDA ?
 Computability Theory Turing Machines Professor MSc. Ivan A. Escobar
1 CO Games Development 2 Week 21 Turing Machines & Computability Gareth Bellaby.
Introduction to CS Theory Lecture 15 –Turing Machines Piotr Faliszewski
Halting Problem Introduction to Computing Science and Programming I.
Turing Machines. Intro to Turing Machines A Turing Machine (TM) has finite-state control (like PDA), and an infinite read-write tape. The tape serves.
CSE 311 Foundations of Computing I Lecture 26 Computability: Turing machines, Undecidability of the Halting Problem Spring
CSE 311 Foundations of Computing I Lecture 29 Computability: Turing machines, Undecidability of the Halting Problem Autumn 2012 CSE 3111.
The Church-Turing Thesis Chapter 3 Giorgi Japaridze Theory of Computability.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
1 Turing’s Thesis. 2 Turing’s thesis: Any computation carried out by mechanical means can be performed by a Turing Machine (1930)
 2005 SDU Lecture13 Reducibility — A methodology for proving un- decidability.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich
Lecture 17 Undecidability Topics:  TM variations  Undecidability June 25, 2015 CSCE 355 Foundations of Computation.
1 IDT Open Seminar ALAN TURING AND HIS LEGACY 100 Years Turing celebration Gordana Dodig Crnkovic, Computer Science and Network Department Mälardalen University.
1 Turing Machines and Equivalent Models Section 13.1 Turing Machines.
Overview of the theory of computation Episode 3 0 Turing machines The traditional concepts of computability, decidability and recursive enumerability.
Lecture 24UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 24.
1 Turing Machines - Chap 8 Turing Machines Recursive and Recursively Enumerable Languages.
Automata & Formal Languages, Feodor F. Dragan, Kent State University 1 CHAPTER 3 The Church-Turing Thesis Contents Turing Machines definitions, examples,
1 Introduction to Turing Machines
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 12 Mälardalen University 2007.
Umans Complexity Theory Lectures Lecture 1b: Turing Machines & Halting Problem.
The Church-Turing Thesis Chapter Are We Done? FSM  PDA  Turing machine Is this the end of the line? There are still problems we cannot solve:
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY * Read chapter 4 of the book for next time * Lecture9x.ppt.
CS 154 Formal Languages and Computability April 5 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
Recursively Enumerable and Recursive Languages. Definition: A language is recursively enumerable if some Turing machine accepts it.
Fall 2013 Lecture 27: Turing machines and decidability CSE 311: Foundations of Computing.
Chapters 11 and 12 Decision Problems and Undecidability.
Modeling Arithmetic, Computation, and Languages Mathematical Structures for Computer Science Chapter 8 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesTuring.
Introduction to Computing Science and Programming I
Busch Complexity Lectures: Turing Machines
CSE 311 Foundations of Computing I
CS21 Decidability and Tractability
Pumping Lemma Revisited
CSE 105 theory of computation
CS154, Lecture 7: Turing Machines.
Turing Machines 2nd 2017 Lecture 9.
CSE 105 theory of computation
COSC 3340: Introduction to Theory of Computation
Theory of Computation Turing Machines.
Decidable Languages Costas Busch - LSU.
CS21 Decidability and Tractability
Recall last lecture and Nondeterministic TMs
Decidability and Tractability
CSE S. Tanimoto Turing Completeness
CSE 105 theory of computation
Instructor: Aaron Roth
Instructor: Aaron Roth
CO Games Development 2 Week 21 Turing Machines & Computability
Turing Machines Everything is an Integer
CSE 105 theory of computation
Presentation transcript:

Great Theoretical Ideas in Computer Science

Lecture 21 - Dan Kilgallin Turing Machines

Goals Describe the nature of computation Mathematically formalize the behavior of a program running on a computer system Compare the capabilities of different programming languages

Turing Machines What can we do to make a DFA better? Idea: Give it some memory! How much memory? Infinite! What kind of memory? Sequential access (e.g. CD, hard drive) or RAM? An infinite amount of RAM requires remembering really big numbers and needlessly complicates proofs

Turing Machines: Definition A Turing Machine consists of o A DFA to store the machine state, called the controller o An array that is infinitely long in both directions, called the tape o A pointer to some particular cell in the array, called the head

Operation The head begins at cell 0 on the tape The DFA begins in some initial state Symbols from some alphabet are written on a finite portion of the tape, beginning at cell 1

Operation At each step, the machine uses as input: o The state of the controller o The symbol written on the cell which the head is at Using this, the machine will: o Transition to some state in the DFA (possibly the same state) o Write some symbol (possibly the same symbol) on the tape o Move the head left or right one cell

Two Flavors! The machine will stop computation if the DFA enters one of a pre-defined set of "halting" states A "decision" machine will, if it reaches a halting state, output either "Yes" or "No" (i.e. there are "accepting" and "rejecting" halt states) A "function" machine will, if it reaches a halting state, have some string of symbols written on the tape. This string of symbols is the output of the function

Example: Doubling a Number Notation: (old symbol, new symbol, direction to move) "epsilon" denotes empty cell, "H" denotes halting state(s)

Example: Doubling a Number

Example: Doubling a Number

Example: Doubling a Number

Example: Doubling a Number

Example: Doubling a Number

Example: Doubling a Number

Example: Doubling a Number

Example: Doubling a Number

Example: Doubling a Number

Example: Doubling a Number

Example: Doubling a Number

TM vs DFA Is a decision machine more powerful than a DFA? Yes! Claim: A decision machine can recognize the set {anbn | n >= 0}

Example: anbn

a a b b

a a b b

a b b

Example: anbn a b b

Example: anbn a b b

Example: anbn a b b

Example: anbn a b b

Example: anbn a b

Example: anbn a b

Example: anbn a b

Example: anbn a b

Example: anbn b

Example: anbn b

Example: anbn b

Example: anbn

Example: anbn

Correctness Every time we reach the bottom-right state, the number of "b"s deleted equals the number of "a"s

Correctness

Correctness Every time we reach the bottom-right state, the number of "b"s deleted equals the number of "a"s If there are more "a"s, it crashes right after deleting the last "b"

Correctness a No "a" transition!

Correctness Every time we reach the bottom-right state, the number of "b"s deleted equals the number of "a"s If there are more "a"s, it crashes right after deleting the last "b" If there are more "b"s, it crashes in the bottom-right state after scanning to the left of the "b"s

Correctness b No epsilon transition!

Correctness Every time we reach the bottom-right state, the number of "b"s deleted equals the number of "a"s If there are more "a"s, it crashes right after deleting the last "b" If there are more "b"s, it crashes in the bottom-right state after scanning to the left of the "b"s If NO "a"s, crashes immediately

Correctness b b b No "b" transition!

Correctness Every time we reach the bottom-right state, the number of "b"s deleted equals the number of "a"s If there are more "a"s, it crashes right after deleting the last "b" If there are more "b"s, it crashes in the bottom-right state after scanning to the left of the "b"s If NO "a"s, crashes immediately If no "b"s, crashes after reading the "a"s

Correctness a a a No epsilon transition!

Definitions A set is recursively enumerable if there is a decision machine which answers "yes" if and only if the input belongs to the set A function f is computable or recursive if there is a function machine that, when given input x, produces output f(x)

Interlude: What is an "algorithm"? "A precise step-by-step plan for a computational procedure that begins with an input value and yields an output value in a finite number of steps." -Corbin, Leiserson, Rivest. "Introduction to Algorithms" Turing machines can capture this notion precisely!

Algorithms on a TM Given a human-comprehensible goal, encode the input into some alphabet Define the steps of the algorithm as a DFA Put the input on a tape Let the Turing Machine run Translate the output

Objection Why not just use a programming language, such as C? As it turns out, writing a C program is just using a computer to build a Turing Machine for you

Algorithms on a TM Given a human-comprehensible goal, encode the input into some alphabet Define the steps of the algorithm as a DFA Put the input on a tape Let the Turing Machine run Translate the output

Algorithms in C Given a human-comprehensible goal, encode the input into some alphabet Define the steps of the algorithm as a DFA Put the input on a tape Let the Turing Machine run Translate the output

Algorithms in C Given a human-comprehensible goal, encode the input into binary Define the steps of the algorithm as a DFA Put the input on a tape Let the Turing Machine run Translate the output

Algorithms in C Given a human-comprehensible goal, encode the input into binary Define the steps of the algorithm as a sequence of processor instructions Put the input on a tape Let the Turing Machine run Translate the output

Algorithms in C Given a human-comprehensible goal, encode the input into binary Define the steps of the algorithm as a sequence of processor instructions Put the input in computer memory Let the Turing Machine run Translate the output

Algorithms in C Given a human-comprehensible goal, encode the input into binary Define the steps of the algorithm as a sequence of processor instructions Put the input in computer memory Let the program run Translate the output

Algorithms in C Given a human-comprehensible goal, encode the input into binary Define the steps of the algorithm as a sequence of processor instructions Put the input in computer memory Let the program run Translate the output into radiation beamed at the user's face, or ink on a paper

Extending the parallel: in 60 seconds String of 1's and 0's in memory representing the arguments to a function (tape) Handful of registers that point to locations in memory (head(s)) Block of memory describing instructions (controller transition function) Special register, %eip, pointing to current instruction (controller state)

More Objections Can't computer programs do more than Turing Machines can? o Jump to arbitrary memory address o Wait for input that wasn't given at the program's start (e.g. keyboard)

Jumping to an arbitrary address: Turing Machines can do that! PC: access the memory at byte with address 0xdeadface TM: Encode address in unary (i.e. block of "0xdeadface" ones) Shift the unary number so it starts at 0 Scan through the segment to find the right endpoint. The head will be at cell 0+0xdeadface, as desired

Sub-objection? How do you mark a block of cells as representing a single variable? o Define more symbols. Make a special "marker" symbol to indicate the endpoint of any region you want How do you shift the variable without overwriting other data? o Define an extra bit for each symbol, used exclusively to store the information "is this cell part of the unary sequence?"

Example: Doubling a Number byte x, y, z; //compiler stores at addresses 1,2,3 int n=5; //compiler stores at bytes 4-7 int* charmander = &n; //contains value "4", //stored at location 11 void double(){ int** metapod = &charmander; //metapod = 11 **metapod *= 2; //Finds value 4 at memory //location 11, goes to the memory location //referenced, and doubles the value found //there }

Example: Doubling a Number Want to double here Delimiters Unary Data we don't want to delete

Example: Doubling a Number

Copy "-" over

Example: Doubling a Number Copy "-" over

Example: Doubling a Number Copy "-" over

Example: Doubling a Number Copy "-" over

Example: Doubling a Number Copy "-" over Repeat, without deleting old data

Example: Doubling a Number Copy "-" over Repeat, without deleting old data

Example: Doubling a Number Copy "-" over Repeat, without deleting old data

Example: Doubling a Number Copy "-" over Repeat, without deleting old data

Example: Doubling a Number Copy "-" over Repeat, without deleting old data Two "#" in a row indicate shift complete

Example: Doubling a Number Copy "-" over Repeat, without deleting old data Two "#" in a row indicate shift complete

Example: Doubling a Number Copy "-" over Repeat, without deleting old data Two "#" in a row indicate shift complete Scan left till you find a "-"

Example: Doubling a Number Copy "-" over Repeat, without deleting old data Two "#" in a row indicate shift complete Scan left till you find a "-" Double as before

Waiting for input: Cheat Allow user to edit symbols on the tape while the TM is running Consider a state that does nothing on an empty symbol, moves right on anything else When it sees a blank symbol, it's stuck until the user changes it Note: For doing this, it's convenient to allow the head to stay put on a transition, but not necessary

C vs Turing Machine Any algorithm that can be done in C can be done with a Turing Machine Any algorithm that can be done on a Turing Machine can be done in C (easy to write a TM simulator) Thus, C and Turing Machines have the same computational power

How about Java? It is also easy to simulate a TM in Java Thus, it can simulate a Turing Machine that simulates C! Java has at least as much computational power as C Java can also be simulated on a TM Thus, C can simulate a Turing Machine simulating Java Therefore, C and Java have the same computational power!

Generalizing In fact, a Turing Machine can simulate programs from ANY language that will run on a PC Just like with C; nothing but RAM and registers Thus, any programming language in which it is possible to simulate a Turing Machine has the same power as any other language that can simulate a Turing Machine

Definition A computational system is said to be Turing-complete if it has at least as much computational power as a Turing Machine

Turing-completeness Many, many models of computation are Turing- complete: o Several other theoretical models (e.g. Post productions, Lambda Calculus) o Any mainstream programming language o LaTeX o The C pre-processor o Legos o The Starcraft Map Editor

Meta-simulations Any Turing Machine can be simulated in some C program Any C program can be simulated in some Turing Machine Thus, you can have a Turing Machine simulating a C program simulating a Turing Machine... Or, a C program simulating a Turing Machine simulating a C program

Definition A Universal Turing Machine is a TM that can simulate the behavior of any other Turing Machine Analogous to a Virtual Machine, Interpreter, or Operating System "Yo dawg, I heard you liek Turing Machines, so we put a Turing Machine in your Turing Machine so you can recurse while you recurse."

Universal Turing Machine Universal Machines can be as small as 4 states, and have an alphabet as small as 6 symbols. Stores nearly all data on tape However, It takes much longer to simulate the TM than to run it directly

How Universal is it? So, can a Universal Turing Machine compute every possible function? No! o Halting problem o Busy Beaver function o Rice's Theorem Wait until next week for proof

Interlude: History Lesson In fact, Turing Machines were formulated to prove there were undecidable mathematical problems Developed as an answer to Hilbert's "Entscheidungsproblem" This, along with Alonzo Church's Lambda Calculus, established the field of modern theoretical computer science

Can we do better? Can we modify our definition so that it can compute more functions? o More tape heads?  can simulate multi-threading with just one head o More tapes?  already have infinite space o Non-deterministic controller?  NFA's don't give any more computational power

Can anything else do better? Church-Turing thesis: "Any function that is computable in the intuitive sense is computable by a Universal Turing Machine" -Alonzo Church and Alan Turing

Can anything else do better? Thesis, not theorem Implication: The universe is a giant Turing Machine Theological question, not mathematical! Would solve issues such as o Free will o Possibility of an omnipotent god o Possibility of an omniscient god o Absolute truth

What you should know: Two types of Turing Machines Computable function, R.E. set Turing-completeness Turing Machine/Computer Program Relationship Universal Turing Machine Church-Turing Thesis