简体   繁体   English

图灵机元素区别问题

[英]Turing Machine Element Distinctness Problem

So the language is as follows: 所以语言如下:

E = {#x1#x2...#xi where alphabet is {0,1}* and no string can be a duplicate of another string } E = {#x1#x2 ...#xi,其中字母为{0,1} *,并且任何字符串都不能与另一个字符串重复}

I am trying to create the state diagram for this, but even before that I was coming up with the algorithm to solve it, but the issue I was encountering is whenever I compare the first two strings, I have to mark each character with an 'x' so how would I restore the first string? 我正在尝试为此创建状态图,但是在此之前,我想出了一种算法来解决该问题,但是遇到的问题是,每当我比较前两个字符串时,我都必须用' x',那么如何恢复第一个字符串? Like first I compare x1 and x2, by the time I'm done, in x2 and all characters in x1 would be marked with 'x', so when I move on to x3, x1 has nothing to compare. 像我首先比较x1和x2一样,到完成时,在x2中,x1中的所有字符都将标记为“ x”,因此当我移至x3时,x1无需进行比较。

Instead of marking considered symbols with an x, mark them with special symbols corresponding to the symbols being marked. 不用用x标记考虑的符号,而是用与要标记的符号相对应的特殊符号标记它们。 So, instead of writing x for 0 and x for 1, write a for 0 and b for 1. In fact, go ahead and use symbols c and d also to replace values in "the earliest thing I need to check" so you can check all pairs. 因此,与其将x代写为0,将x代写为1,而不是将a代写为0并将b代写为1,实际上,继续使用符号c和d替换“我需要检查的最早内容”中的值,这样您就可以检查所有对。 A high-level description of a Turing machine using this strategy is the following: 使用此策略的图灵机的高级描述如下:

  1. begin reading the first input, replacing 0 with c and 1 with d 开始读取第一个输入,将0替换为c,将1替换为d
  2. go to the second input and if the second input is a match so far, write a for 0 and b for 1, then continue. 转到第二个输入,如果到目前为止第二个输入是匹配的,则将a表示为0,将b表示为1,然后继续。 If it's not a match, we know that these inputs don't match and we can begin comparing other pairs. 如果不匹配,我们知道这些输入不匹配,我们可以开始比较其他对。 Change the input you're checking to a and b only and reset the first input to 0 and 1 only. 将您要检查的输入更改为仅a和b,并将第一个输入重置为仅0和1。
  3. repeat this process skipping over all a and b already there to check all pairs involving the first term. 重复此过程,跳过已经存在的所有a和b,以检查涉及第一项的所有对。
  4. once you've checked all pairs involving the first term, cross it out (using x maybe) and then repeat the whole process on the remaining input 一旦检查完所有涉及第一项的对,将其划掉(也许使用x),然后对其余输入重复整个过程

This will check all pairs and work as expected. 这将检查所有对并按预期工作。 The key is, as you correctly surmised, being able to reconstruct parts of the input, meaning you need extra symbols in your tape alphabet. 正如您正确推测的那样,关键是能够重构输入的一部分,这意味着您在磁带字母中需要额外的符号。 Never hesitate to introduce tape symbols - they're free and can never hurt. 不要犹豫地介绍磁带符号-它们是免费的,并且永远不会受到伤害。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM