You are on page 1of 2

Formal Methods: Assignment 1

Dr. Jochen Nessel

A function f is called total, if it is defined for all inputs, i.e., if Dom(f ) = N.


Exercise 1: Assume two functions g, h : N 7→ N. Let f : N 7→ N for all
x ∈ N be defined as follows: f (x) = h(g(x)).

1. Show that f is total if h and g are total.


2. Assume f is total. Under which circumstances will g have to be total?
When will h have to be total?

Exercise 2: Write a Turing program that computes f (x) = x + 1 over the


alphabet A = {0, 1}. Show how your machine works on the input 1011.
Exercise 3: Write a Turing program that works on alphabet A = {0, 1} and
that stops if the input n has an even number of “1”. If the numbers of “1”
in n is odd, then your machine should never stop. Show how your machine
works on the inputs 111 and 01001. If possible, try to use not more than
three states.
The following is an example for a POST program. Assume the read/write
head stands on the first letter of the input over the alphabet A = {0, 1}.
The machine will then shift the given input one field to the left. After the
shift the read/write head is on the field that contained the last letter of the
shifted word. If the input is empty, i.e., the program is started with with the
read/write head standing on a *, the machine will move one field to the left
and stop.

. . . |*|*|1|0|1|*|. . .
↑Start

. . . |*|1|0|1|*|*|. . .
↑End

1

1?1 + 5 
  
−2 5L 6 9L 10



 
 
 
2?0 + 9 6↓17 10 ↓ 0 11 13 L 14
  
(1) (2) (3) (4)
−3 
 7R 8 
 11R 12 
 14 ↓ ∗ 4
3? ∗ +13 8R 1 12R 1

  


−4

4! Stop
Where

• (1) Case distinction, depending on work tape content.


• (2) Shift “1” to the left.
• (3) Shift “0” to the left.
• (4) Stop on *.

Now assume you have the following commands, which you might use as one
command in your POST programs.

• SSL: stands for “search star left”. This command places the read/write
head on the next field left of the current one, that contains a *. If the
current field contains a *, the command will do nothing.
• SSR: stands for “search star right” and is the same as the previous one,
except that it searches to the right.
• SL: stands for “shift left” and shifts the current input to the left; see
above.
• SR: “shift right”; same as SL, just shifting to the right.

A command could therefore be: 4 SSL 5.


Exercise 4: Write a POST program that mirrors an arbitrary input over the
alphabet {0, 1}. For example, if the program is started on . . . |*|1|0|0|*|. . .,
it will stop with output . . . |*|0|0|1|*|. . . and the read/write head will
stand on the first letter of 001. Please comment your program and show how
it works on the input 1101.

Hand in: 28. September, 2007

You might also like