Class 14: Modeling Computers


Published on

Modeling Computers
Finite State Machines
Turing Machines

Published in: Technology, Business
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Class 14: Modeling Computers

  1. 1. Class 14: Modeling Computers Monday’s class will meet in Rice Hall Bagel Shop Areacs1120 Fall 2011David Evans23 September 2011
  2. 2. PlanModeling ComputersTuring’s ModelProgramming Turing Machines 2
  3. 3. What makes agood model? Copernicus F = GM1M2 / R2 Ptolomy Newton 3
  4. 4. How should we model a Computer? Turing invented the Colossus (1944) model we’ll use today in 1936. What “computer” was he modeling? Cray-1 (1976)Apollo GuidanceComputer (1969) Palm Pre (2009) Apple II (1977) Flickr: louisvolant Honeywell Kitchen Computer (1969) 4
  5. 5. “Computers” before WWII 5
  6. 6. Mechanical Computing 6
  7. 7. Modeling ComputersInput Without it, we can’t describe a problemOutput Without it, we can’t get an answerProcessing Need some way of getting from the input to the output Memory: Need to keep track of what we are doing 7
  8. 8. Modeling Input Punch CardsAltair BASIC Paper Tape, 1976 Engelbart’s mouse and keypad 8
  9. 9. Turing’s Model “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, 1936 9
  10. 10. Modeling Pencil and Paper ... ... # C S S A 7 2 3 How long should the tape be?Infinitely long! We are modeling a computer, notbuilding one. Our model should not have silly practicallimitations (like a real computer does). 10
  11. 11. Modeling OutputBlinking lights are cool, but hard to modelUse the tape: output is what is written on the tape at the end Connection Machine CM-5, 1993 11
  12. 12. Modeling Processing (Brains) Look at the current state of the computation Follow simple rules about what to do next 12
  13. 13. Modeling ProcessingEvaluation Rules Given an input on our tape, how do we evaluate to produce the outputWhat 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 0 0 1 1 0 0 1 0 0 0 Is that enough to model a computer? 13
  14. 14. Modeling ProcessingRead, write and move is not enoughWe 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? 14
  15. 15. Finite State Machines 0 1 0Start 1 2 1 # HALT 15
  16. 16. Hmmm…maybe we don’t need those infinite tapes after all? not a ( not a paren parenStart 1 2 ) ) # What if the next input symbolERROR HALT is ( in state 2? 16
  17. 17. How many states do we need? not a ( not a paren paren not aStart 1 2 paren ( ) ) ) 3 not a paren # (ERROR HALT 4 ) ( 17
  18. 18. Finite State MachineThere are lots of things we can’t compute with only a finite number of statesSolutions: “Infinite” State Machine Hard to define, draw, and reason about Add an infinite tape to the Finite State Machine 18
  19. 19. Modeling Processing (Brains) Follow simple rules Remember what you are doing “For the present I shall only say that the justification lies in the fact that the human memory is necessarily limited.” Alan Turing 19
  20. 20. FSM + Infinite TapeStart: FSM in Start State Input on Infinite Tape Pointer to start of inputStep: Read one input symbol from tape Write symbol on tape, and move L or R one square Follow transition rule from current stateFinish: Transition to halt state 20
  21. 21. Turing’s Model: Turing Machine... # 1 0 1 1 0 1 1 1 0 1 1 0 1 1 1 # ... Infinite Tape: Finite set of symbols, one in each square Can read/write one square each step Start Input: # Controller: Input: 1 Limited (finite) Write: # Write: 0 number of states Move: Move: 1 Follow rules based 2 Input: 0 on current state and read symbol Write: # Input: 1 Input: 0 Move: Halt Write one square Write: 1 Write: 0 each step, move Move: Move: 3 left or right or halt, change state 21
  22. 22. Take on faith for now: we will argue this more convincingly near the end of the course! Church-Turing ThesisAll mechanical computers are equally powerful (except for practical limits like memory size, time, display, energy, etc.) Alonzo Church, 1903-1995Some Turing machine can simulate any mechanical computerAny computer that can simulate a Turing machine, can simulate any mechanical computer Alan Turing, 1912-1954 22
  23. 23. Turing Machine SummaryModel Input, Output, and Scratch Memory Infinite tape, divided into discrete squares Each square can contain a single symbol from a finite alphabetModel Processing Finite State Machine Keep track of a finite state (in your head) Follow transition rules: next state = f(current state, input symbol) 23
  24. 24. Monday’s class willExample meet in Rice Hall Bagel Shop Area 24
  25. 25. ChargePS4 Posted Today, due Monday 3 OctoberExam 1: out October 7, due October 12 Covers: Problem Sets 1-4 including PS Comments Course Book Chapters 1-6 Classes 1-18Monday’s class in Rice Hall 25