简体   繁体   English

图灵机和密码

[英]Turing Machine and Ciphers

I am looking into Turing machines and am trying to work out how I could describe some basic cryptography algorithms (Caesar cipher for example) using Turing machines.我正在研究图灵机,并试图弄清楚如何使用图灵机描述一些基本的密码算法(例如凯撒密码)。

Consider:考虑:

F={x#y|x,y∈{a,b,c,d,e,f}∗,y is equal to x with a Caesar shift of 3}.

How could I describe a Turing machine algorithm that decides F?我如何描述决定 F 的图灵机算法?

Disclaimer: the following algorithm makes a few simplifications/variations from the original Turing machine for clarity and brevity.免责声明:为了清晰和简洁,以下算法对原始图灵机进行了一些简化/变化。 Most notably, we describe the states of the Turing machine implicitly, so for example in step 2, when we say that we keep track of the shifted symbol as character s , and later match this with the symbol we read in step 5, what we really mean is that we transition to a specific state of the Turing machine that will transition to other specific states that move the head as described in steps 3-4, that will then reject if the symbol we finally read is not the shifted character s .最值得注意的是,我们隐式地描述了图灵机的状态,例如在步骤 2 中,当我们说我们将移位的符号跟踪为字符s ,然后将其与我们在步骤 5 中读取的符号匹配,我们真正的意思是我们转换到图灵机的特定 state 将转换到其他特定状态,如步骤 3-4 所述移动头部,然后如果我们最终读取的符号不是移位字符s ,则将拒绝。

We can describe a Turing machine with the following algorithm on an input string x#y:我们可以在输入字符串 x#y 上使用以下算法来描述图灵机:

  1. Read the current symbol.读取当前符号。 If it is a # (ie x is a blank string), go to step 8.如果是#(即x为空字符串),go到第8步。

  2. Read the current symbol.读取当前符号。 If it is not in {a, b, c, d, e, f}, reject.如果不在 {a, b, c, d, e, f} 中,则拒绝。 Otherwise, perform a Caesar shift of 3 on the character.否则,对角色执行 3 的凯撒移位。 Let this new shifted character be s .让这个新的移位字符为s Replace the current symbol with a $.用 $ 替换当前符号。

  3. Move rightwards on the tape until we read a # symbol.在磁带上向右移动,直到我们读到 # 符号。 If we read a blank space before this happens, reject.如果我们在这发生之前读取了一个空格,则拒绝。

  4. Move the head rightwards on the tape until we read a symbol that is not a #.在磁带上向右移动磁头,直到我们读到一个不是 # 的符号。

  5. Read the current symbol.读取当前符号。 If this space is blank, reject.如果此空格为空白,则拒绝。 If this symbol does not match the shifted character s in step 2, reject.如果此符号与步骤 2 中移位的字符s不匹配,则拒绝。 Otherwise, replace the current symbol with a #.否则,将当前符号替换为 #。

  6. Move the head leftwards until we read a $ character.将头部向左移动,直到我们读到一个 $ 字符。 Then move the head one space to the right.然后将头部向右移动一格。

  7. Read the current symbol.读取当前符号。 If it is a #, go to step 8. Otherwise, go to step 2.如果是#,go 执行步骤 8。否则,go 执行步骤 2。

  8. Move the head rightwards on the tape until we read a character that is not a #.在磁带上向右移动磁头,直到我们读取到一个不是 # 的字符。

  9. If this space is not a blank, reject.如果此空格不是空白,则拒绝。 Otherwise, accept.否则,接受。

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

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