【问题标题】:formal description of TM that on input x computes the next word in the lexicographic order在输入 x 上计算字典顺序中的下一个单词的 TM 的正式描述
【发布时间】:2020-09-25 13:10:38
【问题描述】:

对于 Σ = {0, 1},给出一个 TM M 的正式描述,它在输入 x 上根据字典顺序计算 Σ∗ 中的下一个单词。 例如,在输入 11 上,M 在其磁带上以 000 停止

【问题讨论】:

    标签: computation-theory


    【解决方案1】:

    我们将设计一个单磁带确定性图灵机,在给定磁带上的单词 w 的情况下,按照字典顺序计算下一个单词。这是我们的策略:

    1. 扫描到输入的末尾,看看最低有效位是否等于0。如果是,增加它,然后完成。

    2. 否则,向左扫描直到看到 0,在这种情况下,您将其递增然后停止。继续寻找,直到到达磁带的前面。

    3. 如果您到了这里,您的输入格式为 11...1,您需要将除第一个之外的所有 1 替换为 0,然后在末尾添加一个额外的 0。为此,请向右扫描,直到找到第一个空白,将您看到的所有 1 替换为 0;然后,用 0 恰好替换一个空白,然后停止。

    这里是转换和状态:

    state   tape    state'    tape'    direction    comment
    
    q0      blank   halt-acc  0        same         assume 0 for empty tape
    q0      0,1     q1        0,1      right        scan right
    
    q1      blank   q2        blank    left         go to LSB
    q1      0,1     q0        0,1      right        scan to end of input
    
    q2      blank   q3        1        right        input is 11...1
    q2      0       halt-acc  1        same         found the least significant 0
    q2      1       q2        1        left         keep looking
    
    q3      blank   halt-acc  0        same         ran out of tape, add one 0
    q3      0       halt-rej  0        same         this transition cannot happen
    q3      1       q3        0        right        replace all but 1st 1 with 0
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-07-27
      • 1970-01-01
      • 2013-05-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多