You are on page 1of 2

Practicum TI2320 Assignment tm-n-19

Group 36 Jelle Licht (studentno.: 4106946) Je Smits (studentno.: 4104889) April 30, 2012

High-level description

M is a multi-tape Turingmachine with two tapes. The tapes are unlimited in both directions. The head may go Left, Right or Stay Put. M = On input w, 1. 2. 3. 4. 5. 6. 7. 8. Keep a count of the amount of ones, starting with zero. Repeat the following stage until a # is found: For each 1 in the input word, increment the counter. Skip the #. Binary reverse the value of the counter. Repeat the following stage until the end of the input is reached: For each 1 in the input word, decrement the counter. If the counter is zero, the word is accepted. Otherwise, reject. If the repetition stages do not match with the input, also reject.

Implementation description

Lets follow the stages of the high-level description:

Stage 1
Simply put a 0 on the second tape, given that the rst tape contains the input word.

Stage 2 & 3
The counter on the second tape is in binary notation. The incremention of the counter value can be split into two situations, where the tape head is positioned next to the least signicant bit of the number. INCREMENT Now move left until a 0 or a is read, replace it with a 1, and replace all digits to the right with 0s. (The machine head ends up in the same position it started in. ) Use this increment to read all 1s in the input word until the # is reached. If you reach a in stead of a #, reject. 1

Stage 4
Thats a basic enough step.

Stage 5
The number doesnt actually need to be reversed, just read it the other way around. So in this stage just replace 0s with s while moving left until you read a 1. After that move left until you reach a space, then move right again.

Stage 6 & 7
DECREMENT Now move right until a 1 is read, replace it with a 0, and replace all digits to the left with 1s. (The machine head ends up in the same position it started in. ) Use this decrement to read all 1s in the input word until the is reached or the counter is 0. If both are true at the same time, accept; otherwise, reject. If another # is read, you can also reject the input word. EOF

You might also like