Designing a Turing Machine State Table

Are they helpful guidelines for describing what a Turing machine does if you already have pseudo-code for the algorithm?

I take a course in complexity theory, and it takes me some time to describe a Turing machine that solves or accepts any language (states, transitions, etc.), although I know how I could encode it in something something like C or even an assembly. Probably, I just did not have enough practice with Turing machines (work on it), but I appreciate any suggestions.

change

I don’t want to create a Turing machine simulator, I want to describe a Turing machine on paper (alphabet, states, transitions) in order to solve a language.

Here is a trivial example of what I mean, I will say that I need to write a Turing machine that iterates over a string from 0 and 1 and changes all 0 in it for 1 s. For example, if you start at 11010 on a tape (input), it stops at 11111 on a tape (exit). Now in a high-level language, you know something like:

Go over every character on tape
    If character is 0 change it to 1

The Turing machine description unofficially looks like:

You have two states, q and stop. when you are in q state and you see 1, go right without changing it. If you see 0, change it to 1 and go to the right. If you see an empty character (end of tape), then go to the stop state.

Formally, you will have something like {q, halt} for states. {(q, 1) → (q, 1, R)), ((q, 0) → (q, 1, R)), ((q, #) → (halt, 0, L))} for transitions .

, , ( a, b c). , ( ), , - , , .

+3
2

:. , , . , , , , ( , ). .

: , ) b) if -. :

if THIS_LETTER_IS("A"):
    found_an_even_number_of_A = not found_an_even_number_of_A

if THIS_LETTER_IS("Q") and previous_letter_was_X and found_an_even_number_of_A
        and not checking_for_alternative_2:
    # can't be a word of alternative 1, so check for alternative 2
    going_back_to_start_to_check_for_alternative_2 = True

if going_back_to_start_to_check_for_alternative_2:
    MOVE_TO_PREVIOUS
else:
    MOVE_TO_NEXT

if going_back_to_start_to_check_for_alternative_2 and THIS_LETTER_IS(EMPTY):
    # reached the beginning, so let check for alternative 2
    going_back_to_start_to_check_for_alternative_2 = False
    checking_for_alternative_2 = True

if s, and s; else not:

if something:
    if something_else:
        do_a
    else:
        do_b

if something and something_else:
    do_a

if something and not something_else:
    do_b

if MOVE_TO_PREVIOUS MOVE_TO_NEXT, , WRITE .

if, , , . :

if something and something_else:
    do_a

if THIS_LETTER_IS("A") and something and something_else and something_i_dont_care_about_here:
    do_a

if THIS_LETTER_IS("A") and something and something_else and not something_i_dont_care_about_here:
    do_a

if THIS_LETTER_IS("Q") and something and something_else and something_i_dont_care_about_here:
    do_a

if THIS_LETTER_IS("Q") and something and something_else and not something_i_dont_care_about_here:
    do_a

, n m , m * 2 nif s. , , . ,

if THIS_LETTER_IS("A") and bitfield[0] and bitfield[1] and bitfield[2]:
    do_a

if THIS_LETTER_IS("A") and bitfield[0] and bitfield[1] and not bitfield[2]:
    do_a

# ...

if THIS_LETTER_IS("A") and bitfield == 7:
    do_a

if THIS_LETTER_IS("A") and bitfield == 3:
    do_a

# ...

- . do_a ( , ), ( , , ) , , .

, .

+10

Source: https://habr.com/ru/post/1729186/


All Articles