Turing Machines and Computers - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

Turing Machines and Computers

Description:

Simulating a Computer by a Turing Machine. Run-time Comparisons between Turing Machines ... intersperse additions with shifts of the multiplicand one bit left ... – PowerPoint PPT presentation

Number of Views:90
Avg rating:3.0/5.0
Slides: 14
Provided by: joseph276
Category:

less

Transcript and Presenter's Notes

Title: Turing Machines and Computers


1
Turing Machines and Computers
  • Simulating a Turing Machine by Computer
  • Simulating a Computer by a Turing Machine
  • Run-time Comparisons between Turing Machines and
    Computers

2
  • Simulating a Turing Machine by Computer
  • given a Turing Machine M, we must write a program
    that acts like M
  • M has finite control
  • there are only a finite number of states, tape
    symbols and transition rules in M
  • encode states and tape symbols as character
    strings
  • lookup transition moves in a table
  • tape can be infinitely long, but computer
    resources are finite
  • if we cannot replace storage devices, the
    simulation ends with the computer just being a
    finite automaton
  • current computers have swappable storage devices,
    so we assume the existence of such resources

3
  • replacing storage devices (disks)
  • assume all necessary disks are available
  • place the disks in two stacks
  • left stack data in cells of Turing Machine tape
    to the left of the tape head
  • right stack data in cell of Turing Machine tape
    to the right of the tape head
  • the closer to the top of its stack a disk is, the
    closer it is to the head and vice versa

4
  • replacing storage devices (contd.)
  • if the tape head moves too far to the left and
    reaches cells not on the current disk
  • print swap left
  • human operator
  • unmounts current disk
  • places it on top of right disk stack
  • mounts disk from the top of the left disk stack
  • computation resumes
  • likewise if tape head reaches cells too far to
    the right
  • if either swap operation is called and there are
    no disks in the respective stack
  • TM has entered an all-blank region of the tape
  • human operator must purchase more disks

5
  • Simulating a Computer by a Turing Machine
  • assumptions
  • computer storage
  • consists of a sequence of words, each with an
    integer address
  • there is no limit on the number of words in
    memory (there could be an arbitrary number of
    disks anyway)
  • computers program is stored in some memory words
  • each word represents an instruction (add, copy,
    etc.)
  • indirect addressing is allowed (array addressing,
    linked lists, pointer operations, etc.)
  • each instruction
  • involves a finite number of words
  • changes the value of at most one word
  • operations are not restricted to registers
  • speed difference (between registers and memory)
    is insignificant it only increases access by a
    constant factor
  • we are interested in running time to within a
    polynomial
  • besides, we are looking at the language
    recognizing abilities of computers vs. Turing
    machines

6
  • assume a multi-tape Turing machine (equivalent to
    a single-tape Turing machine)
  • first tape entire memory of the computer
  • format add cont add cont . . .
  • beginning of sequence of address/contents
  • add an address
  • cont the addresss contents
  • second tape instruction counter
  • holds an integer (in binary) corresponding to a
    memory location on tape 1
  • this is the address of the next instruction to be
    executed

7
  • third tape memory address or its contents after
    the address has been located on tape 1
  • instruction execution find contents of memory
    addresses holding data needed for the
    computation
  • copy desired address onto tape 3, compare with
    tape 1 until the two match
  • copy the address contents to tape 3 and move it
    to wherever its needed
  • fourth tape input file for the computer
  • fifth tape scratch area
  • instruction cycle simulation
  • search the first tape for the address that
    matches the instruction address on tape 2
  • when instruction address is found, examine its
    contents
  • first few bits instruction (add, mult, copy,
    etc.)
  • remaining bits addresses involved in the
    instruction
  • handle first involved address
  • copy address to tape 3
  • mark current position on tape 1
  • find memory address on tape 1
  • copy its contents to tape 3

8
  • instruction simulation (contd.)
  • execute the instruction using the value just
    fetched
  • add get the other value and perform the
    addition
  • copy get the second address and copy the first
    fetched value into it
  • jump copy the first fetched value to tape 2
  • increment the instruction counter on tape 2
  • begin instruction cycle again
  • shifting over certain instructions may need to
    make more space for their result (e.g.
    add/copy/mult)
  • copy to the scratch tape the entire non-blank
    tape to the right of where the result goes
  • write the result to tape 1
  • copy the scratch tape back to tape 1 to the right
    of where the result was just placed
  • acceptance
  • assume the computer has an accept condition or
    some other such stopping state
  • the Turing machine simulating the computer
    execution will simply enter an accept state and
    halt

9
  • Running time comparisons
  • observations
  • importance in addition to indicating what
    can/cannot be computed, Turing machines also
    indicate whether or not computer-based solutions
    are efficient enough to be used in practice
  • tractability
  • tractable efficiently solvable
  • intractable solvable, but not efficiently
    enough to be useful
  • usually measured by whether or not the solution
    can be found in polynomial time
  • need to show
  • what is polynomial-time solvable on a computer is
    polynomial-time solvable on a Turing machine, and
    vice versa
  • with this equivalence, what a Turing machine can
    do efficiently can be done efficiently on a
    computer as well

10
  • observations (contd.)
  • limits
  • multiplication can cause computer words to very
    grow large
  • if word size is not limited, the Turing machine
    can take exponential time to simulate such
    instructions
  • solution words can grow to any length, but one
    instruction can only increase the word size by
    one bit
  • addition is still allowed, but multiplication
    must be simulated
  • intersperse additions with shifts of the
    multiplicand one bit left
  • arbitrarily long words can still be multiplied,
    but the time taken is proportional to the square
    of the length of the operands
  • tape length
  • after n instructions, O(n) words have been
    mentioned on the Turing machine tape
  • O(n) Turing machine cells are required to
    represent each computer word
  • therefore, the tape is O(n2) cells long and the
    Turing machine can locate the finite number of
    words needed by one computer instruction in O(n2)
    time

11
  • observations (contd.)
  • instruction steps
  • instructions cannot produce long words (from the
    above restriction), but they could take a great
    deal of time to compute their result
  • therefore, assume instructions applied to words
    up to length k can be performed in O(k2) steps on
    our multi-tape Turing machine
  • Theorem 8.17 given that instructions increase
    word length by at most 1 and take at most O(k2)
    steps, our Turing machine can simulate n steps of
    the computer in O(n3) steps of its own
  • proof
  • constants
  • c length of the largest of the computers words
    and addresses appearing in the program (tape 1)
  • d number or words occupied by the program
  • after n steps
  • the computer created no words longer than cn and
    thus neither created nor used addresses longer
    than cn bits
  • total number of addresses is at most dn
  • at most 2(c n) 2 bits are required for
    address, its contents and the two marker symbols
    ( and ) to separate them
  • thus as most 2(d n)(c n 1) cells are
    occupied
  • d and c are constants, so this number of cells is
    O(n2)

12
  • proof of Theorem 8.17 (contd.)
  • words are O(n) in length, thus instructions can
    be carried out in O(n2) time (by the second
    assumption)
  • creating space for new addresses
  • needed to hold a new or expanded word
  • shifting over copies at most O(n2) data from tape
    1 to the scratch tape and back
  • thus O(n2) time is needed for shifting over
  • conclusion
  • the Turing machine simulates one step of the
    computer in O(n2) steps of its own
  • therefore n computer steps can be simulated in
    O(n3) steps of the Turing machine

13
  • Theorem 8.18 n steps of the computer described
    can be simulated in at most O(n6) steps of a
    single-tape Turing machine
  • proof
  • we have already shown that a single-tape Turing
    machine can simulate a multi-tape Turing machine
    in at most O(n2) steps
  • the multi-tape Turing machine described can
    simulate n computer steps in O(n3) steps of its
    own
  • thus since O(n3) O(n2) O(n6), a single-tape
    Turing machine can simulate n computer steps in
    O(n6) steps of its own
Write a Comment
User Comments (0)
About PowerShow.com