How would you design a one-tape, two-head TM for checking tautonyms? - turing-machines

I have to figure out if this language
L = { ww | w {0,1}*}
is decidable by a Turing machine. The TM has 1 tape and 2 heads/pointers. The input string is finite. Any suggestions on how to solve it ?
The way I see it, if I know the length of the string, it's easy to solve it.

As a hint, you can find the midpoint of the string by repeatedly moving one tape head two steps forward and the other one step forward until the faster tape head walks off the string; at that point, the slower tape head is at the halfway point. That might help you find the breakpoint in the string.
Hope this helps!

Related

Turing machine that does not accept - how can we know it?

Suppose i have a TM M that accepts a language L. If i give it an input word w and want to know whether it accepts or loops forever - can i state without explaining what i do if M does NOT accept w ?
I mean - the phrase "if M does not accept w" assumes that each algorithm is implicitly able to identify an infinite loop.
I see it a lot in reducibility problems where M is an inner TM within an algorithm that uses M's acceptances as well as M's non-acceptance and i never saw an explanation how the outer algorithm is able to know that M did not accept. It is just said - "if M accept.... else....", how can the algorithm detect the "else" part ? In case of infinite loop, how is it detected ?
Thanks
You can, in general, not detect algorithmically that a TM does not stop on a given input.
For the "if M accept.... else...." problems, one possibility is that the else part always leads to non-acceptance. In that case it does not matter whether the inner TM loops or not. If it does, the outer one will also loop and not accept. Therefore the else part does not need to be executed.
Another possible case is that you only look at recursive/decidable languages in the inner TM. Then you will always get an answer.

Turing Machine Configuration

I'm fairly new to Turing Machines and I'm stumped on a question. I'm given a Turing machine: M = (Q,Σ,Γ,δ,q) such that Q={q,r,s,t}, Σ={a.b.c}, Γ={B,a,b,c} and δ is defined by the following: [q,a,r,b,R], [q,b,r,a,R], q,c,t,c,R], [t,a,t,a,R], [t,b,t,b,R], [t,B,s,B,R]
And I'm asked if M halts on the input abba, and if so write the configuration in which M halts. The answer is suppose to be brbba, which I don't understand how this can be the configuration. How does a state symbol become apart of the configuration? Any help will be appreciated!
A configuration consists of:
the current state
the position of the read/write head
the tape content
brbba indicates all three as the r shows the current state and the head's position. A less compact way to write it in two lines would be:
r
bbba
or b[rb]ba if you like.

Algorithm to find all substrings of a string within a given edit distance of another string

I know the title is a bit messy, so let me explain in detail:
I have two strings, T and P. T represents the text to be searched, and P represents the pattern to be searched for. I want to find ALL substrings of T which are within a given edit distance of P.
Example:
T = "cdddx"
P = "mdddt"
Say I wanted all substrings within edit distance 2, the answers would be:
cdddx //rewrite c and x
dddx // insert m, rewrite x
cddd //insert t, rewrite c
ddd // insert m and t
Don't know if that's all of them, but you get the point.
I know the Wagner–Fischer algorithm can be employed for solution of this problem - I check the numbers of the last row of the Wagner–Fischer matrix and see if they fulfill this condition and find the substrings that way, then run the algorithm again for T', where T' is T where the first letter has been removed, and so on. The problem is the time complexity of this shoots up to a staggering O(T^3*P). I'm looking for a solution close to the original time complexity of the Wagner-Fisher algorithm, i.e. O(T*P).
Is there a way to get this done in such time or something better than what I have right now? Note that I am not necessarily looking for a Wagner-Fischer solution, but anything is ok. Thanks!

What are the x values for this circuit truthtable? ABC (3) inputs (Homework)

I usually try not ask for homework help but once again I am stuck. I've been going over and over my textbook but I am not able to figure this out. Emailed the instructor and all the help i get is "Check this page" and "check that page", so instead of just not doing it, I would like some advice so I am actually able to learn.
The "G" gate thing, is whats bugging me in the book there is no gate that looks like that so i have no idea what to do. Here's a picture of the question, basically I have to find the X values (outputs). The answer would be nice. But I highly would appreciate a little explaination of "why".
Really appreciate the help!
Ok, so you you're not quite sure what this G gate means from looking at the diagram. In a question like this (where there's something that doesn't make sense to you), it's helpful to start with what you do know.
From looking at the diagram I don't know what the G gate means. In fact I don't know anything about circuits (but I do know something about logic :) ). I start with the truth table that the author has generously given me the formulas for each gate. I notice that there are 3 operators (*,+,') which I know.
If you know what those operators mean, then you can derive the meaning of the G gate.
D looks like an AND
E looks like NAND, the nipple-ish thing is an inverter
F looks like NOT, a buffer with an inverter on the output
G looks like a NOR, an OR with inverted output
The unlabeled one looks like an OR.
That's a really bad drawing though.
Giving you the answer would only cheat you out of your education and this stuff is important. There are 16 logical connectives for binary functions and they're all . . . logical. They make sense.
AND means when both inputs are true the output will be true. "If A and B = 1 output is 1"
OR means if any of the inputs are true the output will be true. "if A or B = 1 output is 1"
NOT means if the input is true the output is false.
XOR means if either input is true, but not both, the output will be true. "If A or B = 1 output is 1 unless both A and B = 1"
AND, OR, and XOR can all have inverters on their outputs which reverses their meanings. When they're supposed to output true they'll output false and when they're supposed to output false they'll output true.
The headings in the table are using * to mean AND, + to mean OR, and ' to mean "invert the symbol on the left".
D is A AND B, so if A and B are true, then put a 1 in the column, the rest of the column is false.
E is B NAND C, so if B and C are true, then put a 0 in the column, the rest of the column is true.
F is NOT C, so put the opposite of C in the column.
G is NOT((A AND B) OR (NOT C)), or if you look at the schematic and think about the formulas a bit you'll see that it's NOT(D OR F). You should be able to figure this out on your own now.
X is G OR E, There's a more complicated formula for it that traces through the circuit like the formula for G, but if you need it to prove your work you'll have to talk to your teacher. You'll probably get more help asking questions that show you put in effort.
I wrote an article about Logical functions in JavaScript that includes schematics. If you memorize the function tables at the top of the article it'll help you a lot when dealing with digital logic. Bonus points for associating the function number with the function name, you'll have memorized the output column of the functions truth table. They've taught you to count in binary right? Anyway, here's the article: http://matthewkastor.blogspot.com/2013/10/logical-functions-in-javascript.html It's not so important for your immediate question but will definitely do you good to read it. Oh, inputs can be inverted as well so don't let that throw you off.

Turing Machine - Learning Skills

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.
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.

Resources