Download presentation

Presentation is loading. Please wait.

Published byKira Whitham Modified over 2 years ago

1
David Evans http://www.cs.virginia.edu/evans CS200: Computer Science University of Virginia Computer Science Class 30: Models of Computation

2
2 April 2004CS 200 Spring 20042 Menu How can we model computation? Turing Machines Universal Turing Machine

3
2 April 2004CS 200 Spring 20043 How should we model a Computer? Apollo Guidance Computer (1969) Colossus (1944) IBM 5100 (1975) Cray-1 (1976)

4
2 April 2004CS 200 Spring 20044 Modeling Computers Input –Without it, we can’t describe a problem Output –Without it, we can’t get an answer Processing –Need some way of getting from the input to the output Memory –Need to keep track of what we are doing

5
2 April 2004CS 200 Spring 20045 Modeling Input Engelbart’s mouse and keypad Punch Cards Altair BASIC Paper Tape, 1976

6
2 April 2004CS 200 Spring 20046 Simplest Input Non-interactive: like punch cards and paper tape One-dimensional: just a single tape of values, pointer to one square on tape 0011001000 How long should the tape be? Infinitely long! We are modeling a computer, not building one. Our model should not have silly practical limitations (like a real computer does).

7
2 April 2004CS 200 Spring 20047 Modeling Output Blinking lights are cool, but hard to model Output is what is written on the tape at the end of a computation Connection Machine CM-5, 1993

8
2 April 2004CS 200 Spring 20048 Modeling Processing Evaluation Rules –Given an input on our tape, how do we evaluate to produce the output What do we need: –Read what is on the tape at the current square –Move the tape one square in either direction –Write into the current square 0011001000 Is that enough to model a computer?

9
2 April 2004CS 200 Spring 20049 Modeling Processing Read, write and move is not enough We also need to keep track of what we are doing: –How do we know whether to read, write or move at each step? –How do we know when we’re done? What do we need for this?

10
2 April 2004CS 200 Spring 200410 Finite State Machines 1 Start 2 HALT 1 0 1 # 0

11
2 April 2004CS 200 Spring 200411 Hmmm…maybe we don’t need those infinite tapes after all? 1 Start 2 HALT ( not a paren ) # ) ERRO R What if the next input symbol is ( in state 2?

12
2 April 2004CS 200 Spring 200412 How many states do we need? 1 Start 2 HALT ( not a paren ) # ) ERRO R 3 not a paren ( ) 4 ( ) (

13
2 April 2004CS 200 Spring 200413 Finite State Machine There are lots of things we can’t compute with only a finite number of states Solutions: –Infinite State Machine Hard to describe and draw –Add a tape to the Finite State Machine

14
2 April 2004CS 200 Spring 200414 FSM + Infinite Tape Start: –FSM in Start State –Input on Infinite Tape –Pointer to start of input Move: –Read one input symbol from tape –Follow transition rule from current state To next state Write symbol on tape, and move L or R one square Finish: –Transition to halt state

15
2 April 2004CS 200 Spring 200415 Matching Parentheses Repeat until halt: –Find the leftmost ) If you don’t find one, the parentheses match, write a 1 at the tape head and halt. –Replace it with an X –Look left for the first ( If you find it, replace it with an X (they matched) If you don’t find it, the parentheses didn’t match – end write a 0 at the tape head and halt

16
2 April 2004CS 200 Spring 200416 Matching Parentheses 1 Start HALT Input: ) Write: X Move: L ), X, L 2: look for ( X, X, R X, X, L (, X, R #, 0, # #, 1, # (, (, R Will this report the correct result for (() ?

17
2 April 2004CS 200 Spring 200417 Matching Parentheses 1 Start HALT ), X, L 2: look for ( (, (, R (, X, R #, 0, # #, 1, # X, X, L X, X, R #, #, L 3: look for ( X, X, L #, 1, # (, 0, #

18
2 April 2004CS 200 Spring 200418 Turing Machine Alan Turing, On computable numbers: With an application to the Entscheidungsproblem, 1936 –Turing developed the machine abstraction to show the halting problem really leads to a contradiction –Our informal argument, depended on assuming we could do if and everything else except halts?

19
2 April 2004CS 200 Spring 200419 Describing Turing Machines zzzzzzzzzzzzzzzzzzzzzz TuringMachine ::= Alphabet ::= { Symbol* } Tape ::= OneSquare ::= Symbol | # Current ::= OneSquare LeftSide ::= [ Square* ] RightSide ::= [ Square* ] Everything to left of LeftSide is #. Everything to right of RightSide is #. 1 Start HALT ), X, L 2: look for ( #, 1, - ), #, R (, #, L (, X, R #, 0, - Finite State Machine

20
2 April 2004CS 200 Spring 200420 Describing Finite State Machines TuringMachine ::= FSM ::= 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, # 1 Start HALT ), X, L 2: look for ( ), #, R (, #, L (, X, R #, 0, # #, 1, # Transition Rule is a procedure: StateName X OneSquare StateName X OneSquare X Direction

21
2 April 2004CS 200 Spring 200421 Example Turing Machine TuringMachine ::= FSM ::= Alphabet ::= { (, ), X } States ::= { 1, 2, HALT } InitialState ::= 1 HaltingStates ::= { HALT } TransitionRules ::= {,,,} 1 Start HALT ), X, L 2: look for ( ), #, R (, #, L (, X, R #, 0, # #, 1, #

22
2 April 2004CS 200 Spring 200422 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!

23
2 April 2004CS 200 Spring 200423 Demo http://www.people.virginia.edu/~cw7r/cs200/ Electronic Flash Cards for Learning Languages Edward Mitchell, Justin Pan, Qi Wang and Chalermpong Worawannotai

24
2 April 2004CS 200 Spring 200424 Charge Next week: –Lambda Calculus model of computation –Very different from Turing Machines, but we will show that it is exactly as powerful!

Similar presentations

OK

Cs3102: Theory of Computation Class 14: Turing Machines Spring 2010 University of Virginia David Evans.

Cs3102: Theory of Computation Class 14: Turing Machines Spring 2010 University of Virginia David Evans.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Download ppt on evaporation Ppt on cross-sectional study examples Ppt on teachers day Ppt on narrative writing for 3rd grade Ppt on image compression using wavelet transform Hours by appt only Ppt on forensic science laboratory Ppt on fashion industry in india Full ppt on electron beam machining video Ppt on air pollution