My University Life - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

My University Life

Description:

Given two positive integers x and y, design a TM that. computes x y. ... Design a TM that multiplies two integers in unary notation. ... – PowerPoint PPT presentation

Number of Views:1831
Avg rating:3.0/5.0
Slides: 19
Provided by: Peng46
Category:

less

Transcript and Presenter's Notes

Title: My University Life


1
Lecture 11
Turing Machines II
2
Turing Machines (II)
  • Turing machines are not only interesting as
    language accepters, they provide us with a simple
    abstract model for digital computers in general.
  • The input for a computation is all the non-blank
    symbols on the tape at the initial time. The
    output is whatever on the tape after the
    computation.

3
Computability of a function defined by a TM
  • A function f with domain D is computable if there
    exists some TM
  • such that
  • We will see shortly, all the common
    mathematical functions, no matter how
    complicated, are computable.

4
Example 1
  • Given two positive integers x and y, design a TM
    that
  • computes xy.
  • For simplicity, we use unary notation in which
    any positive integer x is represented by w(x) in
    1, such that w(x) x. We assume that w(x)
    and w(y) are on the tape in unary notation,
    separated by a single 0, with the head on the
    leftmost symbol of w(x). After the computation,
    w(xy) will be on the tape followed by a single
    0, with the head at the left end of the result.

5
Example 1 (Conti.)
  • We therefore want to design a TM for performing
    the computation
  • All we need to do is to move the separating 0
    to the right end of w(y), so that the addition
    amounts to nothing more than the coalescing of
    the two strings. To achieve this, we construct
    with

6
Other Basic Operations
  • Unary notation is very convenient for programming
    TMs. The resulting programs are much simpler than
    binary or decimal representations.
  • Other basic operations are copying strings and
    simple comparisons. These can also be done easily
    on a TM.

7
Example 2
  • Design a TM that copies strings of 1s.
  • More precisely, we want a TM to perform
  • To solve the problem, we implement the following
    intuitive process
  • 1. Replace every 1 by x.
  • 2. Find the rightmost x and replace it with 1.
  • 3. Travel to the right end and create a 1 there.
  • 4. Repeat steps 2 and 3 until there are no more
    xs.

8
Example 2 (Conti.)
  • A Turing machine implementing the process is
  • where is the only final state. You should
    try to trace the program with some input strings.

9
Example 3
  • Design a TM as a comparer. More precisely, we
    want a TM to perform
  • if
  • if
  • The idea is to match each 1 on the left of
    dividing 0 with the 1 on the right. At the end of
    the matching, we will have on the tape, one of
    the following

10
Example 3 (Conti.)
  • Depending on whether or In the
    1st case, we encounter the blank at the right of
    the working place when we attempt to match
    another 1. In the 2nd case, we still find a 1 on
    the right when all 1s on the left have been
    replaced. We use these signs to enter the two
    different states. The complete program is left as
    exercise.

11
Combining TMs for Complicated Tasks
  • Study how to combine together the TMs which
    perform basic operations into a single TM for
    complicated tasks.
  • We start with a high-level description (block
    diagram or pseudo-code), then refine it
    successively until the program is in the actual
    language with which we are working.

12
Example 4
  • Design a TM that compute the function
  • where x and y are positive integers in unary
    representation.

13
Example 4 (Conti.)
  • The computation of f(x,y) can be described by the
    diagram below.

xy
Adder
Comparer
x,y
f(x,y)
Eraser
0
14
Example 5
  • Design a TM that multiplies two integers in unary
    notation.
  • Assume the initial and final tape contents are
    as follows 00y0x and 0xy0y0x.
  • The multiplication can be seen as a repeated
    copying of the multiplicand y for each 1 in the
    multiplier x. The following pseudo-code shows the
    main steps of the process.

15
Example 5 (Conti.)
  • 1. Repeat the following steps until x contains no
    more 1s
  • Find a 1 in x and replace it with another symbol
    a.
  • Replace the leftmost 0 by 0y.
  • 2. Replace all as with 1s.

16
Turings Thesis
  • The Turings thesis states that any computation
    that can be carried out by mechanical means
    (digital computer) can be performed by some
    Turing machine.
  • No one has been able to suggest a problem,
    solvable by an algorithm, for which a TM program
    cannot be written.

17
Homework
  • Construct TMs to compute the following functions,
    where x and y are positive integers represented
    in unary.
  • 1.
  • 2.
  • 3.

18
Homework (Conti.)
  • Write the pseudo-code for the TM program that
    compute the following functions (you may use
    adder, copier or multiplier in your program.)
  • 1.
  • 2.
Write a Comment
User Comments (0)
About PowerShow.com