2

It took me the whole month to solve this problem, as I got it from the book one of exercise, and I'd love to know how to write this in a turing machine; I would really love to learn this. Please could anyone offer a help?

Consider the last two letters of your login (if both letters are the same, please pick the next letter in the Latin alphabet as your second symbol). Write a Turing Machine that will recognise the language Stretch(x+1). This is the language of all strings that contain a continuous string of occurrences of the two letters, followed by ‘*’, followed by another string of letters with x+1 occurrences of the each letter where there was a single occurrence in the first string of letters. Here, x = 1. Input to the machine is non-null strings of a, b, *. As an example, where the letters are ‘a’ and ‘b’ (and x=1) aba*aabbaa, bb*bbbb and baab*bbaaaabb are in the language, but abb*abbb is not. You may assume that you have subroutines for writing 0 in the first cell and deleting the rest of the tape and for writing 1 in the first cell and deleting the rest of the tape.

I would totally appreciate it if you could help me.

Sabrina
  • 21
  • 1

1 Answers1

3

Use a stack for each unique letter (two stacks, in your examples). This isn't formally written or anything, but all you have to do is provide an algorithm to prove a TM can solve the problem.

F1:
FOREACH letter DO
  IF letter = '*' THEN F2
  ELSE push letter twice onto its respective stack

F2:
FOREACH letter DO
  IF tape is empty THEN F3
  IF respective stack is empty THEN *fail state*
  ELSE pop respective stack

F3:
IF both stacks are empty THEN *accept state*
ELSE *fail state*

Get the idea? TM proofs are fun.

EDIT: In response to your other posts, if you don't understand how to build a TM proof you'll need to do some reading about proofs in general. I would suggest Michael Sipser's Intro to Theory of Computing. After you shell out an arm and a leg for that text, you can turn to page 137 to learn all about TMs.

sholsapp
  • 15,542
  • 10
  • 50
  • 67