Algorithm 图灵机设计0和1

Algorithm 图灵机设计0和1,algorithm,turing-machines,Algorithm,Turing Machines,f1(1^n01^m)=1^|m−n| 设计计算函数的图灵机(转换图) 如何在中间保持0的轨迹? 我尝试过这样做,但无法理解它我假设您希望磁带字母表仅由0、1和-(空白)组成。我们的策略在使用单带图灵机器时是卓有成效的:我们将在中间0来回跳跃,在我们找到它们时越过1s。我们将继续,直到用完1s并达到空白。此时,磁带上剩下的只有1^ m-n以及n+m+1-| m-n |零。最后,我们将结果复制到磁带的开头(如果磁带的开头不是现在的位置,即,如果m>n),并擦除零 Q s s' D

f1(1^n01^m)=1^|m−n|

设计计算函数的图灵机(转换图)

如何在中间保持0的轨迹?
我尝试过这样做,但无法理解它

我假设您希望磁带字母表仅由0、1和-(空白)组成。我们的策略在使用单带图灵机器时是卓有成效的:我们将在中间0来回跳跃,在我们找到它们时越过1s。我们将继续,直到用完
1
s并达到空白。此时,磁带上剩下的只有1^ m-n以及n+m+1-| m-n |零。最后,我们将结果复制到磁带的开头(如果磁带的开头不是现在的位置,即,如果m>n),并擦除零

Q    s    s'   D    Q'

// read past 1^n
q0   1    1    R    q0

// read through zeroes
q0   0    0    R    q1
q1   0    0    R    q1

// mark out the first 1 remaining in 1^m
q1   1    0    L    q2

// read through zeros backwards
q2   0    0    L    q2

// mark out the last 1 remaining in 1^n
q2   1    0    R    q1

// we were reading through zeroes forward
// and didn't find another 1. n >= m and
// we have deleted the same number from
// the first and last parts so just delete
// zeroes
q1   -    -    L    q3
q3   0    -    L    q3
q3   1    1    L    halt_accept

// we were reading through zeroes backwards
// and didn't find another 1. n < m and we
// accidentally deleted one too many symbols
// from the 1^m part. write it back and start
// copying the 1s from after the 0s back to
// the beginning of the tape. then, clear zeroes.
q2   -    -    R    q4
q4   0    1    R    q5
q5   0    0    R    q5
q5   1    0    L    q6
q6   0    0    L    q6
q6   1    1    R    q4
q5   -    -    L    q7
q7   0    -    L    q7
q7   1    1    L    halt_accept

我假设您希望磁带字母表仅由0、1和-(空白)组成。我们的策略在使用单带图灵机器时是卓有成效的:我们将在中间0来回跳跃,在我们找到它们时越过1s。我们将继续,直到用完
1
s并达到空白。此时,磁带上剩下的只有1^ m-n以及n+m+1-| m-n |零。最后,我们将结果复制到磁带的开头(如果磁带的开头不是现在的位置,即,如果m>n),并擦除零

Q    s    s'   D    Q'

// read past 1^n
q0   1    1    R    q0

// read through zeroes
q0   0    0    R    q1
q1   0    0    R    q1

// mark out the first 1 remaining in 1^m
q1   1    0    L    q2

// read through zeros backwards
q2   0    0    L    q2

// mark out the last 1 remaining in 1^n
q2   1    0    R    q1

// we were reading through zeroes forward
// and didn't find another 1. n >= m and
// we have deleted the same number from
// the first and last parts so just delete
// zeroes
q1   -    -    L    q3
q3   0    -    L    q3
q3   1    1    L    halt_accept

// we were reading through zeroes backwards
// and didn't find another 1. n < m and we
// accidentally deleted one too many symbols
// from the 1^m part. write it back and start
// copying the 1s from after the 0s back to
// the beginning of the tape. then, clear zeroes.
q2   -    -    R    q4
q4   0    1    R    q5
q5   0    0    R    q5
q5   1    0    L    q6
q6   0    0    L    q6
q6   1    1    R    q4
q5   -    -    L    q7
q7   0    -    L    q7
q7   1    1    L    halt_accept