简体   繁体   English

图灵机协助

[英]Turing Machine Assistance

I've been practicing with designing Turing machines, and one that I recently solved was for a language L = { w : n a (w) = n b (w)}, where the number of a's in w are equal to the number of b's in w. 我一直在设计图灵机,最近解决的是一种语言L = {w:n a (w)= n b (w)},其中w中a的数量等于数量的b在w中

However, how would I go about designing a Turing machine for a language where the number of a's in w does not equal the number of b's in w? 但是,我将如何设计一种图灵机,使其语言在w中a的个数不等于w中b的个数? (eg. L = {w : n a (w) ≠ n b (w)}? (例如L = {w:n a (w)≠n b (w)}?

The book and websites that I've been using for reference define a Turing machine as follows: 我一直在参考的书和网站对图灵机的定义如下:

M = (Q, Σ, ℾ, δ, q 0 , ☐, F), where Q is the states, Σ is the input alphabet, ℾ is the tape alphabet, δ is the transitions, q 0 is the start state, ☐ is a blank space that is an element of ℾ (☐ ∊ ℾ), and F is the final state designated as q f . M =(Q,Σ,ℾ,δ,q 0 ,☐,F),其中Q是状态,Σ是输入字母,ℾ是磁带字母,δ是过渡,q 0是开始状态,☐是一个空白空间,是ℾ(☐∊)的元素,F是指定为q f的最终状态。

If you've recently solved the case where the number of a and b are equal, an immediate solution for the case where they're not equal is this: 如果您最近解决了a和b的数目相等的情况,那么对于不相等的情况的直接解决方案是:

  • if you used to crash (have no valid transition) then add a transition to halt_accept instead; 如果您曾经崩溃过(没有有效的过渡),则向halt_accept添加过渡;
  • if you used to explicitly reject by going to halt_reject, go to halt_accept instead; 如果您过去曾经通过halt_reject来明确拒绝,则转到halt_accept;
  • if you used to accept by entering halt_accept, go to halt_reject instead. 如果您以前通过输入halt_accept接受,则转至halt_reject。

This new TM (1) accepts anything that would not have been accepted by your TM for the case of equal numbers of a and b, and (2) rejects anything that would have been accepted by your TM for the case of equal numbers of a and b. 新的TM(1)接受a和b相等的情况下TM不会接受的任何内容,(2)拒绝a数目等于a的情况下TM可以接受的任何东西和b。

In fact, this procedure works for any TM whose job is simply to decided membership of the input string in the language of the machine; 实际上,该过程适用于任何仅以机器语言确定输入字符串成员资格的TM; it would not work to enumerate strings in the complementary language, but that's not necessarily something you need (and you could get enumeration by using a machine constructed like this as a sub-machine in another that enumerates all strings and checks them). 枚举补充语言中的字符串是行不通的,但这并不一定是您所需要的(您可以通过将像这样构造的机器作为子机器,再枚举所有字符串并对其进行检查来获得枚举)。

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

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