Lecture 37: A Universal Computer

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

David Evans cs302: Theory of Computation University of Virginia Computer Science Lecture 13: Turing Machines.
CS 345: Chapter 9 Algorithmic Universality and Its Robustness
David Evans CS200: Computer Science University of Virginia Computer Science Class 30: Models of Computation.
Class 39: Universality cs1120 Fall 2009 David Evans University of Virginia.
David Evans CS150: Computer Science University of Virginia Computer Science Lecture 39: Lambda Calculus.
Applied Computer Science II Chapter 3 : Turing Machines Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany.
Computability and Complexity 4-1 Existence of Undecidable Problems Computability and Complexity Andrei Bulatov.
David Evans CS150: Computer Science University of Virginia Computer Science Lecture 40: Computing with Glue and Photons.
Fall 2004COMP 3351 A Universal Turing Machine. Fall 2004COMP 3352 Turing Machines are “hardwired” they execute only one program A limitation of Turing.
David Evans cs302: Theory of Computation University of Virginia Computer Science Lecture 2: Modeling Computers.
Class 19: Undecidability in Theory and Practice David Evans cs302: Theory of Computation University of Virginia Computer.
Theory of Computation. Computation Computation is a general term for any type of information processing that can be represented as an algorithm precisely.
David Evans CS200: Computer Science University of Virginia Computer Science Class 31: Universal Turing Machines.
Lecture 14: Church-Turing Thesis Alonzo Church ( ) Alan Turing ( )
Cs3102: Theory of Computation Class 17: Undecidable Languages Spring 2010 University of Virginia David Evans.
Lecture 20: λ Calculus λ Calculus & Computability Yan Huang Dept. of Comp. Sci. University of Virginia.
Class 37: Computability in Theory and Practice cs1120 Fall 2011 David Evans 21 November 2011 cs1120 Fall 2011 David Evans 21 November 2011.
David Evans CS588: Security and Privacy University of Virginia Computer Science Lecture 15: Complexity Notes This is selected.
Alan Turing WWII code-breaker mathematical proof of ‘Turing machines’ …in particular, “Universal Turing machine” laid foundations of computer science father.
David Evans CS150: Computer Science University of Virginia Computer Science Class 33: Computing with Photons From The.
Cs3102: Theory of Computation Class 14: Turing Machines Spring 2010 University of Virginia David Evans.
David Evans cs302: Theory of Computation University of Virginia Computer Science Lecture 16: Universality and Undecidability.
David Evans CS150: Computer Science University of Virginia Computer Science Lecture 36: Modeling Computing.
1 Turing’s Thesis. 2 Turing’s thesis: Any computation carried out by mechanical means can be performed by a Turing Machine (1930)
Computer Theory Michael J. Watts
David Evans CS200: Computer Science University of Virginia Computer Science Class 32: The Meaning of Truth.
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 - Chap 8 Turing Machines Recursive and Recursively Enumerable Languages.
1 Introduction to Turing Machines
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 12 Mälardalen University 2007.
1 Turing Machines. 2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
David Evans CS200: Computer Science University of Virginia Computer Science Class 32: The Meaning of Truth.
Turing Machines Sections 17.6 – The Universal Turing Machine Problem: All our machines so far are hardwired. ENIAC
Recall last lecture and Nondeterministic TMs Ola Svensson.
David Evans CS150: Computer Science University of Virginia Computer Science Class 32: Computability in Theory and Practice.
David Evans CS200: Computer Science University of Virginia Computer Science Class 26: Halting Problem It is plain at any.
1 A Universal Turing Machine. 2 Turing Machines are “hardwired” they execute only one program A limitation of Turing Machines: Real Computers are re-programmable.
A Universal Computer. #2#2 One-Slide Summary The Turing machine is a fundamental model of computation. It models input, output, processing and memory.
(Thunking about Thunks)
Operational Semantics of Scheme
Functional Programming
Lecture 6: Lambda Calculus
8. Introduction to Turing Machines
Class 27: Universal Turing Machines CS150: Computer Science
Class 30: Models of Computation CS200: Computer Science
September 4, 1997 Programming Languages (CS 550) Lecture 6 Summary Operational Semantics of Scheme using Substitution Jeremy R. Johnson TexPoint fonts.
Lambda Calculus Revisited
Turing Machines, Busy Beavers, and Big Questions about Computing
Chapter 3: The CHURCH-Turing thesis
فصل سوم The Church-Turing Thesis
Theory of Computation Turing Machines.
8. Introduction to Turing Machines
Class 36: The Meaning of Truth CS200: Computer Science
Computing Functions with Turing Machines
Decidable Languages A language L is decidable if there is a Turing machine ML such that given any word w  0*, then: Input of ML: a  b  … w Output of.
Lecture 24: Metalinguistics CS200: Computer Science
Class 37: Making Lists, Numbers and Recursion from Glue Alone
MA/CSSE 474 Theory of Computation
Class 33: Making Recursion M.C. Escher, Ascending and Descending
Recall last lecture and Nondeterministic TMs
Class 24: Computability Halting Problems Hockey Team Logo
Class 31: Universal Turing Machines CS200: Computer Science
Class 34: Models of Computation CS200: Computer Science
Lecture 3: Rules of Evaluation CS200: Computer Science
Computability Catch up last lecture. Turing machines. Variations
Class 26: Modeling Computing CS150: Computer Science
The Church-Turing Thesis and Turing-completeness
Lecture 23: Computability CS200: Computer Science
Presentation transcript:

David Evans http://www.cs.virginia.edu/evans Lecture 37: A Universal Computer PS8 returned at your project design review meetings Remember to email your project descriptions before midnight tonight CS150: Computer Science University of Virginia Computer Science David Evans http://www.cs.virginia.edu/evans

Turing Machine: FSM + Infinite Tape Start: FSM in Start State Input on Infinite Tape Tape head at start of input Step: Read current input symbol from tape Follow transition rule from current state on input Write symbol on tape Move L or R one square Update FSM state Finish: Transition to halt state

Turing Machine 1 2 3 ... ... # 1 1 1 1 1 1 1 1 1 1 1 # Input: # 1 1 1 1 1 1 1 1 1 1 # Input: # Write: # Move:  Start Input: 1 Write: 0 Move:  1 2 Input: 0 Write: # Move:  Input: 1 Write: 1 Move:  Input: 0 Write: 0 Move:  3

Adding Input on tape: ...#nknk-1...n0+mlml-1...m0#..... Output: Number represented in binary Output: ...#rdrd-1...r0#..... where r = n + m Can we implement addition with a TM?

Adder TM (Start) Input: + 0, 0, R Write: + +, +, L Move: L X, X, L 2: look for digit 1: look for + Start 0, X, R 1, X, R 3: adding to 0 4: adding to 1

2: look for digit 0, 0, R +, +, L X, X, L 1, 1, R 1: look for + Start 0, X, R 1, X, R 3: adding to 0 4: adding to 1 0, 0, R 0, 0, R 1, 1, R 1, 1, R #, #, L #, #, L 5: look for digit 6: look for digit

2: look for digit 0, 0, R +, +, L X, X, L 1, 1, R 1: look for + Start 0, X, R 1, X, R 3: adding to 0 4: adding to 1 0, 0, R 0, 0, R 1, 1, R 1, 1, R #, #, L #, #, L 5: look for digit 6: look for digit X, X, L X, X, L 1, X, R 0, X, R 0, X, R 1, X, R 7: 0+0 8: 0+1 9: 1+1

go to end of answer digits, write 0 +, +, L X, X, L 1, 1, R 2: look for digit 1: look for + Start 0, X, R 1, X, R 3: adding to 0 4: adding to 1 0, 0, R 0, 0, R 1, 1, R 1, 1, R #, #, L #, #, L 5: look for digit 6: look for digit X, X, L X, X, L 1, X, R 0, X, R 0, X, R 1, X, R 7: 0+0 8: 0+1 9: 1+1 #, #, R X, X, R go to end of answer digits, write 0 21: return for next digits, carry 1 20: return for next digits, no carry

Turing Machine z z z z z z z z z z z z z z z z z z z z TuringMachine ::= < Alphabet, Tape, FSM > Alphabet ::= { Symbol* } Tape ::= < LeftSide, Current, RightSide > OneSquare ::= Symbol | # Current ::= OneSquare LeftSide ::= [ Square* ] RightSide ::= [ Square* ] Everything to left of LeftSide is #. Everything to right of RightSide is #. ), X, L ), #, R (, #, L 1 2: look for ( Start (, X, R HALT #, 1, - #, 0, - Finite State Machine

Describing Finite State Machines TuringMachine ::= < Alphabet, Tape, FSM > FSM ::= < States, TransitionRules, InitialState, HaltingStates > States ::= { StateName* } InitialState ::= StateName must be element of States HaltingStates ::= { StateName* } all must be elements of States TransitionRules ::= { TransitionRule* } TransitionRule ::= < StateName, ;; Current State OneSquare, ;; Current square StateName, ;; Next State OneSquare, ;; Write on tape Direction > ;; Move tape Direction ::= L, R, # Transition Rule is a procedure: Inputs: StateName, OneSquare Outputs: StateName, OneSquare, Direction

Example Turing Machine ), X, L ), #, R (, #, L Example Turing Machine 1 2: look for ( Start (, X, R #, 1, # #, 0, # HALT TuringMachine ::= < Alphabet, Tape, FSM > FSM ::= < States, TransitionRules, InitialState, HaltingStates > Alphabet ::= { (, ), X } States ::= { 1, 2, HALT } InitialState ::= 1 HaltingStates ::= { HALT } TransitionRules ::= { < 1, ), 2, X, L >, < 1, #, HALT, 1, # >, < 1, ), #, R >, < 2, (, 1, X, R >, < 2, #, HALT, 0, # >, < 2, ), #, L >,}

Enumerating Turing Machines Now that we’ve decided how to describe Turing Machines, we can number them TM-5023582376 = balancing parens TM-57239683 = even number of 1s TM-3523796834721038296738259873 = Photomosaic Program TM-3672349872381692309875823987609823712347823 = WindowsXP Not the real numbers – they would be much bigger!

Universal Turing Machine P Number of TM Universal Turing Machine Output Tape for running TM-P in tape I I Input Tape Can we make a Universal Turing Machine? also, just a number!

Yes! People have designed Universal Turing Machines with 4 symbols, 7 states (Marvin Minsky) 4 symbols, 5 states 2 symbols, 22 states 18 symbols, 2 states 2 states, 5 symbols (Stephen Wolfram) No one knows what the smallest possible UTM is

Manchester Illuminated Universal Turing Machine, #9 from http://www.verostko.com/manchester/manchester.html

Church-Turing Thesis Any mechanical computation can be performed by a Turing Machine There is a TM-n corresponding to every computable problem We can any “normal” (classical mechanics) computer with a TM If a problem is in polynomial time on a TM, it is in polynomial time on an iMac, Cray, Palm, etc. But maybe not a quantum computer! (later class)

Universal Language Is Scheme/Charme/Python as powerful as a Universal Turing Machine? Is a Universal Turing Machine as powerful as Scheme/Charme/Python? Yes: show we can simulate a UTM with a Scheme program Can we simulate a Scheme interpreter with a TM?

Complexity in Scheme Special Forms Primitives Evaluation Complexity if, cond, define, etc. Primitives Numbers (infinitely many) Booleans: #t, #f Functions (+, -, and, or, etc.) Evaluation Complexity Environments (more than ½ of our eval code) If we have lazy evaluation and don’t care about abstraction, we don’t need these. Hard to get rid of? Can we get rid of all this and still have a useful language?

-calculus Alonzo Church, 1940 term = variable | term term | (term) (LISP was developed from -calculus, not the other way round.) term = variable | term term | (term) |  variable . term

What is Calculus? In High School: d/dx xn = nxn-1 [Power Rule] d/dx (f + g) = d/dx f + d/dx g [Sum Rule] Calculus is a branch of mathematics that deals with limits and the differentiation and integration of functions of one or more variables...

Real Definition A calculus is just a bunch of rules for manipulating symbols. People can give meaning to those symbols, but that’s not part of the calculus. Differential calculus is a bunch of rules for manipulating symbols. There is an interpretation of those symbols corresponds with physics, slopes, etc.

Lambda Calculus Rules for manipulating strings of symbols in the language: term = variable | term term | (term) |  variable . term Humans can give meaning to those symbols in a way that corresponds to computations.

Why? Once we have precise and formal rules for manipulating symbols, we can use it to reason with. Since we can interpret the symbols as representing computations, we can use it to reason about programs.

Evaluation Rules -reduction (renaming) y. M  v. (M [y v]) where v does not occur in M. -reduction (substitution) (x. M)N   M [ x N ]

Charge Project Descriptions due before midnight tonight Exam 2 due Friday at 12:02 pm (beginning of class) Friday’s class: student talks about research and industry