Class 27 Universal Turing Machines CS 150 Computer












![What is Calculus? • In High School: d/dx xn = nxn-1 [Power Rule] d/dx What is Calculus? • In High School: d/dx xn = nxn-1 [Power Rule] d/dx](https://slidetodoc.com/presentation_image/1e60c7056ce6b89542bb464d809c8533/image-13.jpg)



![Evaluation Rules -reduction (renaming) y. M v. (M [y v]) where v does not Evaluation Rules -reduction (renaming) y. M v. (M [y v]) where v does not](https://slidetodoc.com/presentation_image/1e60c7056ce6b89542bb464d809c8533/image-17.jpg)


- Slides: 19
Class 27: Universal Turing Machines CS 150: Computer Science University of Virginia Computer Science David Evans http: //www. cs. virginia. edu/evans
Turing Machine (1936) z z z z ), X, L ), #, R (, #, L 2: look for ( 1 Start (, X, R #, 1, - HAL T #, 0, - Finite State Machine z z z Turing. Machine : : = < Alphabet, Tape, FSM > Alphabet : : = { Symbol* } Tape : : = < Left. Side, Current, Right. Side > One. Square : : = Symbol | # Current : : = One. Square Left. Side : : = [ Square* ] Right. Side : : = [ Square* ] Everything to left of Left. Side is #. Everything to right of Right. Side is #. CS 150 Fall 2005: z 2
Describing Finite State Machines Turing. Machine : : = < Alphabet, Tape, FSM > FSM : : = < States, Transition. Rules, Initial. State, Halting. States > States : : = { State. Name* } Initial. State : : = State. Name must be element of States Halting. States : : = { State. Name* } all must be elements of States Transition. Rules : : = { Transition. Rule* } Transition. Rule : : = < State. Name, ; ; Current State Transition Rule is a procedure: One. Square, ; ; Current square Inputs: State. Name, One. Square Outputs: State. Name, One. Square, State. Name, ; ; Next State Direction One. Square, ; ; Write on tape Direction > ; ; Move tape Direction : : = L, R, # CS 150 Fall 2005: 3
), #, R 1 Start #, 1, # ), X, L (, X, R HALT (, #, L 2: look for ( #, 0, # Example Turing Machine Turing. Machine : : = < Alphabet, Tape, FSM > FSM : : = < States, Transition. Rules, Initial. State, Halting. States > Alphabet : : = { (, ), X } States : : = { 1, 2, HALT } Initial. State : : = 1 Halting. States : : = { HALT } Transition. Rules : : = { < 1, ), 2, X, L >, < 1, #, HALT, 1, # >, < 1, ), #, R >, < 2, (, 1, X, R >, < 2, #, HALT, 0, # >, < 2, ), #, L >, } CS 150 Fall 2005: 4
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 1 s • TM= Photomosaic Program • TM= Windows. XP 3523796834721038296738259873 3672349872381692309875823987609823712347823 Not the real numbers – they would be much bigger! CS 150 Fall 2005: 5
Universal Turing Machine P Number of TM I Input Tape Output Tape for running TM-P in tape I Universal Turing Machine Can we make a Universal Turing Machine? also, just a number! CS 150 Fall 2005: 6
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 CS 150 Fall 2005: 7
Manchester Illuminated Universal Turing Machine, #9 from http: //www. verostko. com/manchester. html CS 150 Fall 2005: 8
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 i. Mac, CM 5, Cray, Palm, etc. – But maybe not a quantum computer! (later class) CS 150 Fall 2005: 9
Universal Language • Is Scheme as powerful as a Universal Turing Machine? • Is a Universal Turing Machine as powerful as Scheme? CS 150 Fall 2005: 10
Complexity in Scheme • Special Forms – if, cond, define, etc. • Primitives If we have lazy evaluation and don’t care about abstraction, we don’t need these. – Numbers (infinitely many) – Booleans: #t, #f Hard to get rid of? – Functions (+, -, and, or, etc. ) • Evaluation Complexity – Environments (more than ½ of our eval code) Can we get rid of all this and still have a useful language? CS 150 Fall 2005: 11
-calculus Alonzo Church, 1940 (LISP was developed from -calculus, not the other way round. ) term = variable | term | (term) | variable. term CS 150 Fall 2005: 12
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. . . CS 150 Fall 2005: 13
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. CS 150 Fall 2005: 14
Lambda Calculus • Rules for manipulating strings of symbols in the language: term = variable | term | (term) | variable. term • Humans can give meaning to those symbols in a way that corresponds to computations. CS 150 Fall 2005: 15
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. CS 150 Fall 2005: 16
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 ] CS 150 Fall 2005: 17
CS 150 Fall 2005: 18
Charge • PS 6 Due Monday • PS 7/PS 8 Out Monday – PS 8: “Make a dynamic web application” – PS 7: Learn to use tools you will use for PS 8 – If you have a group and idea in mind for PS 8 soon enough, you may not need to do PS 7 • Friday: – Computability in Theory and Practice – Making Primitives using Lambda Calculus CS 150 Fall 2005: 19