CSCI 2670 Introduction to Theory of Computing - PowerPoint PPT Presentation

About This Presentation
Title:

CSCI 2670 Introduction to Theory of Computing

Description:

Title: PowerPoint Presentation Author: Wim van Dam Last modified by: Shelby Funk Created Date: 8/27/2001 7:35:01 AM Document presentation format: Letter Paper (8.5x11 in) – PowerPoint PPT presentation

Number of Views:112
Avg rating:3.0/5.0
Slides: 28
Provided by: Wim110
Learn more at: http://cobweb.cs.uga.edu
Category:

less

Transcript and Presenter's Notes

Title: CSCI 2670 Introduction to Theory of Computing


1
CSCI 2670Introduction to Theory of Computing
September 28, 2005
2
Agenda
  • This week
  • Turing machines
  • Read section 3.1

3
Announcements
  • Tests will be returned tomorrow
  • Tutorial sessions are suspended until further
    notice
  • Extended office hours while tutorials are
    suspended
  • Monday 1100 1200
  • Tuesday 300 400
  • Wednesday 300 500

4
Recap to date
  • Finite automata (both deterministic and
    nondeterministic) machines accept regular
    languages
  • Weakness no memory
  • Pushdown automata accept context-free grammars
  • Add memory in the form of a stack
  • Weakness stack is restrictive

5
Turing machines
  • Similar to a finite automaton
  • Unrestricted memory in the form of a tape
  • Can do anything a real computer can do!
  • Still cannot solve some problems
  • Church-Turing thesis any effective computation
    can be carried out by some Turing machine

6
Touring machine schematic
  • Initially tape contains the input string
  • Blanks everywhere else (denoted in class
    different symbol in book)
  • Machine may write information on the tape

7
Touring machine schematic
  • Can move tape head to read information written to
    tape
  • Continues computing until output produced
  • Output values accept or reject

8
Touring machine schematic
  • Turing machine results
  • Accept
  • Reject
  • Never halts
  • We may not be able to tell result by observation

9
Differences between TM and FA
  1. TM has tape you can read from and write to
  2. Read-write head can be moved in either direction
  3. Tape is infinite
  4. Accept and reject states take immediate effect

10
Example
  • How can we design a Turing machine to find the
    middle of a string?
  • If string length is odd, return middle symbol
  • If string length is even, reject string
  • Make multiple passes over string Xing out symbols
    at end until only middle remains

11
Processing input
  • Check if string is empty
  • If so, return reject
  • Write X over first and last non-X symbols
  • After this, the head will be at the second X
  • Move left one symbol
  • If symbol is an X, return reject (string is even
    in length)
  • Move left one symbol
  • If symbol is an X, return accept (string is even
    in length)
  • Go to step 2

12
Example
  • 00110
  • First check if string is empty
  • X first and last non-X symbols
  • X011X
  • Move left one symbol
  • X011X
  • Is symbol an X? No
  • Move left one symbol
  • X011X
  • Is symbol an X? No
  • Write X over first and last non-X symbols

13
Example
  • XX1XX
  • Move left one symbol
  • XX1XX
  • Is symbol an X? No
  • Move left one symbol
  • XX1XX
  • Is symbol an X? Yes
  • Return accept

14
Formal definition of a TM
  • Definition A Turing machine is a 7-tuple
    (Q,?,?,?,q0,qaccept,qreject), where Q, ?, and ?
    are finite sets and
  • Q is the set of states,
  • ? is the input alphabet not containing the
    special blank symbol
  • ? is the tape alphabet, where ?? and ???,
  • ? Q???Q???L,R is the transition function,

15
What is the Transition Function??
  • Q set of states, ? tape alphabet
  • ? Q???Q???L,R
  • Given
  • The current internal state ? Q
  • The symbol on the current tape cell
  • Then ? tells us what the TM does
  • Changes to new internal state ? Q
  • Either writes new symbol ? ?
  • Or moves one cell left or right

16
Formal definition of a TM
  • Definition A Turing machine is a 7-tuple
    (Q,?,?,?,q0,qaccept,qreject), where Q, ?, and ?
    are finite sets and
  • q0?Q is the start state,
  • qaccept?Q is the accept state, and
  • qreject?Q is the reject state, where
    qreject?qaccept

17
Computing with a TM
  • M receives input w w1w2wn?? on leftmost n
    squares of tape
  • Rest of tape is blank (all symbols)
  • Head position begins at leftmost square of tape
  • Computation follows rules of ?
  • Head never moves left of leftmost square of the
    tape
  • If ? says to move L, head stays put!

18
Completing computation
  • Continue following ? transition rules until M
    reaches qaccept or qreject
  • Halt at these states
  • May never halt if the machine never transitions
    to one of these states!

19
Another TM example
  • We want to create a TM to add two numbers
  • Use a simple tape alphabet 0,1 plus the blank
    symbol
  • Represent a number n by a string of n1 1s
    terminated by a zero
  • Input to compute 34 looks like this

20
Result of the TM addition example
  • Note that the TM is initially positioned on the
    leftmost cell of the input.
  • When the TM halts in the accept state, it must
    also be on the leftmost cell of the output

21
Breaking down the addition problem
  • Good computer scientists like to simplify
  • A successor TM appends a 1 to the right end of a
    string of 1s

22
The successor subroutine
  • The TM starts in the initial state s0, positioned
    on the leftmost of a string of 1s
  • If it sees a 1, it writes a 1, moves right, and
    stays in state s0
  • If it sees a 0, it writes a 1 and moves to

23
Successor subroutine state transitions
  • lts0, 1, s0, gt
  • lt s0, 0, s1, 1 gt
  • lt s1, 1, s1, gt
  • lt s1, 0, s2, gt
  • (original state, input, new state, action)

24
TM state interpretation
  • S0 the TM has seen only 1s so far and is
    scanning right
  • S1 the TM has seen its first zero and is
    scanning left
  • S2 the TM has returned to the leftmost 1 and
    halts.
  • View movie of this TM

25
From successor TM to addition TM
  • The successor TM will join the two blocks of n1
    1s and m1 1s into a single block of nm3 1s
  • To complete the computation, knock off two 1s
    from left end (states s2 and s3)

26
TM configurations
  • The configuration of a Turing machine is the
    current setting
  • Current state
  • Current tape contents
  • Current tape location
  • Notation uqv
  • Current state q
  • Current tape contents uv
  • Only symbols after last symbol of v
  • Current tape location first symbol of v

27
Acknowledgements
  • TM addition example from Stanford,
    http//plato.stanford.edu/entries/turing-machine/
Write a Comment
User Comments (0)
About PowerShow.com