Class 31: Universal Turing Machines CS200: 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
Elements of Lambda Calculus Functional Programming Academic Year Alessandro Cimatti
1 Programming Languages (CS 550) Lecture Summary Functional Programming and Operational Semantics for Scheme Jeremy R. Johnson.
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 CS200: Computer Science University of Virginia Computer Science Class 27: Modeling Computation.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 3: Rules of Evaluation.
David Evans CS150: Computer Science University of Virginia Computer Science Lecture 39: Lambda Calculus.
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.
1 Scheme Scheme is a functional language. Scheme is based on lambda calculus. lambda abstraction = function definition In Scheme, a function is defined.
David Evans cs302: Theory of Computation University of Virginia Computer Science Lecture 2: Modeling Computers.
David Evans CS200: Computer Science University of Virginia Computer Science Class 31: Universal Turing Machines.
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.
CSE S. Tanimoto Lambda Calculus 1 Lambda Calculus What is the simplest functional language that is still Turing complete? Where do functional languages.
David Evans CS588: Security and Privacy University of Virginia Computer Science Lecture 15: Complexity Notes This is selected.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 18: Think Globally, Mutate Locally.
David Evans CS150: Computer Science University of Virginia Computer Science Class 33: Computing with Photons From The.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 3: Rules of Evaluation.
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.
Strings Basic data type in computational biology A string is an ordered succession of characters or symbols from a finite set called an alphabet Sequence.
David Evans CS200: Computer Science University of Virginia Computer Science Class 32: The Meaning of Truth.
1 Turing Machines - Chap 8 Turing Machines Recursive and Recursively Enumerable Languages.
1 Introduction to Turing Machines
David Evans CS200: Computer Science University of Virginia Computer Science Class 32: The Meaning of Truth.
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.
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
Unit – 3 :LAMBDA CALCULUS AND FUNCTIONAL PROGRAMMING
Lecture 6: Lambda Calculus
Lambda Calculus CSE 340 – Principles of Programming Languages
Lecture 4: Evaluation Rules Recursion CS200: Computer Science
Class 27: Universal Turing Machines CS150: Computer Science
Class 30: Models of Computation CS200: Computer Science
Lecture 37: A Universal Computer
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
Class 19: Think Globally, Mutate Locally CS150: Computer Science
Programming Languages and Compilers (CS 421)
Functional Programming
Class 36: The Meaning of Truth CS200: Computer Science
What would be our focus ? Geometry deals with Declarative or “What is” knowledge. Computer Science deals with Imperative or “How to” knowledge 12/25/2018.
Lecture 25: Metalinguistics > (meval '((lambda (x) (* x x)) 4)
Lecture 24: Metalinguistics CS200: Computer Science
Class 37: Making Lists, Numbers and Recursion from Glue Alone
Lecture 27: In Praise of Idleness CS200: Computer Science
MA/CSSE 474 Theory of Computation
Class 33: Making Recursion M.C. Escher, Ascending and Descending
What would be our focus ? Geometry deals with Declarative or “What is” knowledge. Computer Science deals with Imperative or “How to” knowledge 2/23/2019.
Recall last lecture and Nondeterministic TMs
L Calculus.
Class 24: Computability Halting Problems Hockey Team Logo
Class 34: Models of Computation CS200: Computer Science
Class 33: Learning to Count CS200: Computer Science
Lecture 3: Rules of Evaluation CS200: Computer Science
CSE S. Tanimoto Lambda Calculus
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 Class 31: Universal Turing Machines CS200: Computer Science University of Virginia Computer Science David Evans http://www.cs.virginia.edu/evans

Menu Review: Modeling Computation Universal Turing Machines Lambda Calculus 11 April 2003 CS 200 Spring 2003

Describing Turing Machines z z 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 11 April 2003 CS 200 Spring 2003

Describing Finite State Machines ), X, L ), #, R (, #, L Describing Finite State Machines 1 2: look for ( Start (, X, R #, 1, # #, 0, # HALT 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: StateName X OneSquare  StateName X OneSquare X Direction 11 April 2003 CS 200 Spring 2003

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! 11 April 2003 CS 200 Spring 2003

Universal Turing Machines 11 April 2003 CS 200 Spring 2003

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! 11 April 2003 CS 200 Spring 2003

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 No one knows what the smallest possible UTM is 11 April 2003 CS 200 Spring 2003

Manchester Illuminated Universal Turing Machine, #9 from http://www.verostko.com/manchester/manchester.html 11 April 2003 CS 200 Spring 2003

Church-Turing Thesis Any mechanical computation can be performed by a Turing Machine There is a TM-n corresponding to every decidable problem We can simulate one step on any “normal” (classical mechanics) computer with a constant number of steps on a TM: If a problem is in P on a TM, it is in P on an iMac, CM5, Cray, Palm, etc. But maybe not a quantum computer! 11 April 2003 CS 200 Spring 2003

Universal Language Is Scheme as powerful as a Universal Turing Machine? Is a Universal Turing Machine as powerful as Scheme? 11 April 2003 CS 200 Spring 2003

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 meval 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? 11 April 2003 CS 200 Spring 2003

-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 11 April 2003 CS 200 Spring 2003

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... 11 April 2003 CS 200 Spring 2003

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. 11 April 2003 CS 200 Spring 2003

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. 11 April 2003 CS 200 Spring 2003

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. 11 April 2003 CS 200 Spring 2003

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 ] 11 April 2003 CS 200 Spring 2003

Reduction (Uninteresting Rules) y. M  v. (M [y v]) where v does not occur in M. M  M M  N  PM  PN M  N  MP  NP M  N  x. M  x. N M  N and N  P  M  P 11 April 2003 CS 200 Spring 2003

-Reduction (the source of all computation) (x. M)N  M [ x N ] 11 April 2003 CS 200 Spring 2003

Evaluating Lambda Expressions redex: Term of the form (x. M)N Something that can be -reduced An expression is in normal form if it contains no redexes (redices). To evaluate a lambda expression, keep doing reductions until you get to normal form. 11 April 2003 CS 200 Spring 2003

Recall Apply in Scheme “To apply a procedure to a list of arguments, evaluate the procedure in a new environment that binds the formal parameters of the procedure to the arguments it is applied to.” We’ve replaced environments with substitution. We’ve replaced eval with reduction. 11 April 2003 CS 200 Spring 2003

Some Simple Functions I  x.x C  xy.yx Abbreviation for x.(y. yx) CII = (x.(y. yx)) (x.x) (x.x)  (y. y (x.x)) (x.x)  x.x (x.x)  x.x = I 11 April 2003 CS 200 Spring 2003

 f. (( x.f (xx)) ( x. f (xx))) Example  f. (( x.f (xx)) ( x. f (xx))) Try this yourself (but don’t spend your whole weekend on it!) …we’ll return to it Monday. 11 April 2003 CS 200 Spring 2003

Charge Design Reviews (my office, Olsson 236A) It is everyone in your teams responsibility to make sure the whole team is there on time and ready Not a “graded” activity…but up to you to make it as useful as possible Monday: show Lambda calculus is equivalent to a Turing Machine 11 April 2003 CS 200 Spring 2003