Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Class 31: Turing Machines

Class 31: Turing Machines

cs1120: Introduction to Computing
Explorations in Language, Logic, and Machine
University of Virginia, Spring 2016

http://xplorecs.org/class31

Class 31:
Turing Machines

David Evans

April 13, 2016
Tweet

More Decks by David Evans

Other Decks in Programming

Transcript

  1. Class 31: Turing Machines Introduction to Computing: Explorations in Language,

    Logic, and Machines cs1120 Spring 2016 David Evans University of Virginia
  2. Goal Recap Processing Input Output Program A computer is a

    machine that can execute a program. A universal computer is a machine that can execute any program. Monday: formalized input/output as one-dimensional, infinite tape divided into squares, each containing one symbol from a finite set
  3. 1 Start 2 HALT (Balanced) ( not a paren )

    # not a paren ERROR What if the next input symbol is ( in state 2? 5 )
  4. How many states would we need? 6 1 Start 2

    HALT (Balanced) ( not a paren ) # not a paren BAD )
  5. 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 define, draw, and reason about – Add a working memory to the Finite State Machine 7
  6. 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 8
  7. FSM + 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 state 9
  8. Turing’s Model: Turing Machine 1 Start 2 Input: # Write:

    # Move: ¬ # 1 0 1 1 0 1 1 ... ... 1 0 1 1 0 1 1 1 # Input: 1 Write: 0 Move: ¬ Input: 1 Write: 1 Move: ® Input: 0 Write: 0 Move: ® 3 Input: 0 Write: # Move: Halt Infinite Tape: Finite set of symbols, one in each square Can read/write one square each step Controller: Limited (finite) number of states Follow rules based on current state and read symbol Write one square each step, move left or right or halt, change state 10
  9. Read symbol in current square Based on rule for current

    state and read symbol: Write a symbol into current square Move left or right one position Change state of mind 7 One Step 0 0 A 1 0 4 w 0 # 0 $ 1 4 w 0 #
  10. Read symbol in current square Based on rule for current

    state and symbol read: Write a symbol into current square Move left or right one position Change state of mind 7 0 0 A 1 0 4 w 0 # 0 $ 1 4 w 0 # Describing a Turing Machine
  11. 7 0 0 A 1 0 4 w 0 #

    0 $ 1 4 w 0 # Describing a Turing Machine Symbols: a finite set of things you can write in a square States: a finite set of the “states of mind” of the machine Rules: a list of quintuples: (read symbol, state) è (write symbol, move, new state) Read symbol in current square Based on rule for current state and symbol read: Write a symbol into current square Move left or right one position Change state of mind
  12. Power of Turing Machine Can it add? Can it carry

    out any “computation”? Can it solve any problem? Is this a “good” model of computation?
  13. Things Real Computers Can Do That Turing Machines Cannot Generate

    Heat Provide an adequate habitat for fish
  14. Sometimes it couldn’t remember enough. Real machines do not have

    infinite memory, and each step takes time and costs energy
  15. Charge • Friday: – Starting Interpreters • Read Chapter 11

    (Interpreters) and 12 (Computability) from coursebook • Project 6: target completion by April 22 – Opportunity for Red Belt exemption