简体   繁体   中英

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?

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 .

We can describe a Turing machine with the following algorithm on an input string x#y:

  1. Read the current symbol. If it is a # (ie x is a blank string), go to step 8.

  2. Read the current symbol. If it is not in {a, b, c, d, e, f}, reject. Otherwise, perform a Caesar shift of 3 on the character. Let this new shifted character be 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. 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.

  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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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