Homework - PowerPoint PPT Presentation

About This Presentation
Title:

Homework

Description:

... (b) Design a 2-D Turing machine which draws a figure of eight with 8's on the ... The machine should be in an accepting state when it has completed the drawing. ... – PowerPoint PPT presentation

Number of Views:24
Avg rating:3.0/5.0
Slides: 11
Provided by: csr8
Learn more at: http://www.cs.rpi.edu
Category:
Tags: draws | homework

less

Transcript and Presenter's Notes

Title: Homework


1
Key to Homework 3 (Models of Computation,
Spring, 2001)
1. (a) We know how to formally define a Turing
machine with one-dimensional (1-D) tape and a
finite state control with one two-way read/write
head. How will you extend this definition and
define a 2-D Turing machine with one two
dimensional tape and a finite state control with
one read/write head that can move up, down, to
the left, to the right, or stay? (See Figure (a)
below.) Write a complete formal definition of
such computational model with a tuple (i.e., set
of information) as we did for the Turing
machines. 2. (b) Design a 2-D Turing machine
which draws a figure of eight with 8s on the
blank tape as show in Figure (b) below. The
machine should be in an accepting state when it
has completed the drawing. What is the minimum
number of states needed for this machine? Why?
Your answer for this question will be evaluated
according to the soundness of your argument.
Answer (See next slide.)
(over)
2
1. (a) Answer The 2-D TM can be formally defined
as 6-tuple M ( Q, ? , ? , ? , q0 , F ), where
Q is the finite set of states, ? is the set of
tape symbols (alphabet) including the blank
symbol, usually denoted by B (a square box in the
text), ? is the set of input symbols, which is a
subset of ?, q0 is the start state, F is the set
of accepting states (F ? Q ), and ? is the
transition function which maps Q ? ? ? Q ? ? ?
L, N, R, U, D, where L, N, R are as defined in
1-D TM, and U and D are for moving up and down
from the current position.
1.(b) Answer Figure (a) below shows a
straightforward design with 14 states, each state
drawn at the relative location where the machine
writes 8. Figure (b) is an improved version with
10 states. Notice that to reduce the number of
states this machine uses the symbol written on
the tape in the past moves. (For minimality, see
next slide.)
3
Surprisingly, after Sam put the key answers on
the web, TA Yining reported that one of our
students made 8-states automaton! I thought what
should his idea be, and got the following. This
implies that my proof in previous slide is
incorrect.
Figure (a) 2-D TM with 8 states
Notice that with the above idea, by increasing
the number of different symbols to some constant
k that can be written at the start state, it is
possible with the same automaton shown above to
draw a sequence of k square block of 8s as
illustrated below.
8 8 8 8 8 block 1 8
8 8 8 8 2 8 8
8 8 8 3 8 8
8 . . .
k 8 8 8
4
The question concerning the minimality of the
number of states is challenging. The argument is
based on the minimum number of states required to
write a symbol on a blank cell located at the
distance (going along vertical and/or horizontal
direction) of k blank cells from the current
position. For the formal argument we need the
following definition. Definition For a given
position p on a 2-D tape, we say a blank cell c
is in an open column (or row) with respect to p,
if c is located in the same column (or row) of p,
and in the extension of the column (or row) from
p to c there are only blank cells. Figure (a)
below shows an example of cell c which is in an
open row with respect to position p, where we
assume that no symbol is written to the right of
cell c. Claim For any 2-D TM which is located
in a position p, it takes at least k states to
write (in a finite number of steps) a symbol on a
blank cell c that is in an open column (or row)
with respect to p separated by k cells. Proof.
Suppose that the machine takes less than k. Then
as Figure (b) below illustrates, the machine
should move to the right entering a previous
state (say state i). Notice that in j1st cell,
the machine will write ai, and move to the right,
and on the next blank cell, write ai1, and so
non. These transitions form a cycle and the
machine will keep moving to the right. Now,
using the above claim, we can prove the
minimality (10 states) of the 2-D TM shown in
Figure (b) in the preceding slide. Notice that
the machine writes top row first, and comes down
along the center column (writing at the center).
Then the machine writes the bottom row. This way
we can minimize the number of cells to be written
that are in an open column or row with respect to
possible machine positions. Notice that once the
four corners have been written, the machine can
move to those corners along the vertical column
until it hits a flag (see the star marked 8s).
This can be done by a self-looping transition as
shown in the state transition graph (see the
highlighted loop).
5
  • 2. For each of the following languages Li
    construct a DPDA (deterministic pushdown
    automaton) which accepts Li. For your
  • answer it it enough to show the state transition
    graph of the automaton. (Make sure if your
    machine does not have a bug by
  • running it with several short input strings.)
  • (a) L1 aibj i gt j gt 0
    (b) L2 aibj i ? j gt 0 (c)
    L3 aibj i ? j ? 0
  • (d) L4 aibj i gt j gt 0
    (e) L5 aibj i ? j gt 0 (f)
    L6 aibj i ? j ? 0
  • (g) L7 aibkci i, k gt 0
    (h) L8 aibkci i, k ? 0

Answers
( a, a/aa )
(b, a/? )
(a, Z0/aZ0 )
(b, a/? )
( , a/a )
( , a/? ), ( , Z0/Z0 )
( , Z0/Z0 )
start
(c) L3 aibj i ? j ? 0
6

7
(No Transcript)
8
  • 3. For each of the following grammars, construct
    a DPDA which accepts the language generated by
    the grammar, where S is the
  • only nonterminal, and others are all terminal
    symbols. For your answer it it enough to show the
    state transition graph of the
  • automaton.
  • (a) G1 S ? aSbb abb
    (b) G2 S ? aSbb ?
    (c ) G3 S ? aSbb ccc

9
  • 4. For each of the following languages, construct
    a DFA (deterministic finite automaton) which
    accepts the language. For your
  • answer it it enough to show the state transition
    graph of the automaton.
  • (a) L9 x x ? a, m, t, o, u and x
    has automata as a substring.
  • (b) L10 x x ? a, b, c , and the
    leftmost and the rightmost symbols in x are same.

a
Answer (a)
a
m, t, o, u
u
2
t
1
to state 1
a
m, o, u
start
a
m, t, o
m, t, u
o
a, m, t, o, u
t, o, u
to state 1
a
m, t, o, u
m, o,
m, t, o, u
m
a
a
t
u
a
to state 1
to state 2
10
Answer (b)
Write a Comment
User Comments (0)
About PowerShow.com