UVA CS 150 - Lecture 36- Modeling Computing

Unformatted text preview:

1David Evanshttp://www.cs.virginia.edu/evansCS150: Computer ScienceUniversity of VirginiaComputer ScienceLecture 36: Lecture 36: Modeling Modeling ComputingComputing2Lecture 36: Modeling ComputingHow convincing is our Halting Problem proof?(define (contradict-halts x)(if (halts? contradict-halts)(loop-forever)#t))contradicts-halts cannot exist. Everything we used to make it except halts? does exist, therefore halts? cannot exist.This “proof” assumes Scheme exists and is consistent!3Lecture 36: Modeling ComputingDrSchemeIs DrScheme a proof that Scheme exists?(define (make-huge n)(if (= n 0) null(cons (make-huge (- n 1))(make-huge (- n 1)))))(make-huge 10000)Scheme/Charme/Python/etc. all fail to evaluate some program!4Lecture 36: Modeling ComputingSolutions• Option 1: Prove “Scheme” does exist– Show that we could implement all the evaluation rules (if we had “Python”, our Charme interpreter would be a good start, but we don’t have “Python”)• Option 2: Find a simpler computing model– Define it precisely– Show that “contradict-halts” can be defined in this model5Lecture 36: Modeling ComputingModeling Computation• For a more convincing proof, we need a more precise (but simple) model of what a computer can do• Another reason we need a model:Does complexity really make sense without this? (how do we know what a “step” is? are they the same for all computers?)6Lecture 36: Modeling ComputingWhat is a model?27Lecture 36: Modeling ComputingHow should we model a Computer?Apollo Guidance Computer (1969)Colossus (1944)IBM 5100 (1975)Cray-1 (1976)Turing invented the model we’ll use today in 1936. What “computer”was he modeling?8Lecture 36: Modeling Computing“Computers” before WWII9Lecture 36: Modeling ComputingModeling 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 doing10Lecture 36: Modeling ComputingModeling InputEngelbart’s mouse and keypadPunch CardsAltair BASIC Paper Tape, 197611Lecture 36: Modeling ComputingTuring’s “Computer”“Computing is normally done by writing certain symbols on paper. We may suppose this paper is divided into squares like a child’s arithmetic book.”Alan Turing, On computable numbers, with an application to the Entscheidungsproblem, 193612Lecture 36: Modeling ComputingSimplest Input• Non-interactive: like punch cards and paper tape• One-dimensional: just a single tape of values, pointer to one square on tape0 0 1 1 0 0 1 0 0 0How 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).313Lecture 36: Modeling ComputingModeling Output• Blinking lights are cool, but hard to model• Output is what is written on the tape at the end of a computationConnection Machine CM-5, 199314Lecture 36: Modeling ComputingModeling Processing (Brains)•Rules for steps•Remember a little“For the present I shall only say that the justification lies in the fact that the human memory is necessarily limited.”Alan Turing15Lecture 36: Modeling ComputingModeling 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 square0 0 1 1 0 0 1 0 0 0Is that enough to model a computer?16Lecture 36: Modeling ComputingModeling 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?17Lecture 36: Modeling ComputingFinite State Machines1Start2HALT101#018Lecture 36: Modeling ComputingHmmm…maybe we don’t need those infinite tapes after all?1Start2HALT(not a paren)#not a paren)ERRORWhat if thenext input symbolis ( in state 2?419Lecture 36: Modeling ComputingHow many states do we need?1Start2HALT(not a paren)#not a paren)ERROR3not a paren()4()not a paren(20Lecture 36: Modeling ComputingFiniteState 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 an infinite tape to the Finite State Machine21Lecture 36: Modeling ComputingTuring’s Explanation“We have said that the computable numbers are those whose decimals are calculable by finite means. ... For the present I shall only say that the justification lies in the fact that the human memory is necessarily limited.”22Lecture 36: Modeling ComputingFSM + Infinite Tape• Start: – FSM in Start State– Input on Infinite Tape– Pointer to start of input• Step:– Read one input symbol from tape– Write symbol on tape, and move L or R one square– Follow transition rule from current state• Finish:–Transition to halt state23Lecture 36: Modeling ComputingTuring Machine1Start2Input: #Write: #Move: ←# 1 0 1 1 0 1 1... ...1 0 1 1 0 1 1 1 #Input: 1Write: 0Move: ←Input: 1Write: 1Move: →Input: 0Write: 0Move: →3Input: 0Write: #Move: ←24Lecture 36: Modeling ComputingMatching Parentheses• 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 halt525Lecture 36: Modeling ComputingMatching Parentheses1: look for )StartHALTInput: )Write: XMove: L), X, L2: look for (X, X, RX, X, L(, X, R#, 0, ##, 1, #(, (, RWill this report thecorrect result for (()?26Lecture 36: Modeling ComputingMatching Parentheses1StartHALT), X, L2: look for ((, (, R(, X, R#, 0, ##, 1, #X, X, LX, X, R#, #, L3: look for (X, X, L#, 1, #(, 0, #27Lecture 36: Modeling ComputingTuring Machinez z z z z z z z z z z z z z z zz z z zTuringMachine::= < Alphabet, Tape, FSM>Alphabet::= { Symbol*}Tape::= < LeftSide, Current, RightSide>OneSquare::= Symbol| #Current::= OneSquareLeftSide::= [ Square* ]RightSide::= [ Square* ]Everything to left of LeftSideis #.Everything to right of RightSideis #.1StartHALT), X, L2: look for (#, 1, -¬), #, R¬(, #, L(, X, R#, 0, -Finite State MachineHow well does this


View Full Document

UVA CS 150 - Lecture 36- Modeling Computing

Documents in this Course
Objects

Objects

6 pages

Load more
Download Lecture 36- Modeling Computing
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 36- Modeling Computing and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 36- Modeling Computing 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?