Theoretical computer science - Turing machines
Welcome to the web application for learning Turing machines.
This application was developed as part of a master's thesis.
This application was developed as part of a master's thesis.
Theory of Turing machines
Informal description - A Turing machine is a theoretical model of a computer described by mathematician Alan Turing. It contains a right-side infinite tape (memory), a reader
head, a state controller (finite state memory), and a program in the form of rules (transitions).
Formal description - A Turing machine is defined as six M = (Q, Σ, Γ, δ, q0, F), where:
This work is based on a TS with a double-sided infinite tape and shifts of the reading head in the directions {L, 0, R}, respectively left, stay and right.
Other TS variants addressed in this application include the following:
Formal description - A Turing machine is defined as six M = (Q, Σ, Γ, δ, q0, F), where:
- Q - finite non-empty set of states.
- Γ - finite non-empty set of tape symbols (tape alphabet).
- Σ ⊂ Γ - finite non-empty set of input symbols (input alphabet).
- δ: (Q\F) x Γ -> Q x Γ x {L, 0, R} - transition function
- q0 ∈ Q - initial state.
- F ⊂ Q - set of final states.
This work is based on a TS with a double-sided infinite tape and shifts of the reading head in the directions {L, 0, R}, respectively left, stay and right.
Other TS variants addressed in this application include the following:
- Basic variant, which was first defined by Alan Turing, contains a right-handed infinite tape and the transition function contains transition possibilities {L, R}.
- Extended basic variant, which transition function contains transition options {L, 0, R} - TS where the reading head can remain in place during the transition.
- Single-tape TS - adds a double-sided infinite tape to the extended basic version, i.e. a possible shift to the left from any configuration. I base on this definition.
- Multi-tape TS - an extended variant of the single-tape TS that reads and writes to multiple tapes in a single transition: δ : (Q \ F ) x Γ1 x ... x Γk -> Q x Γ1 x ... x Γk x {L, 0, R} x ... x {L, 0, R}, where k is the number of tapes.
- TS in the plane - the difference with the single-tape TS is that it works with a two-dimensional surface and the transition function can contain transitions with upward or downward direction, i.e. {L, 0, R, U, D}.
Application content
The web application contains the following tabs:
- Multitape - simulation of one or more double-sided infinite tapes. Predefined inputs are offered that can be customized. Select any number of input tapes, transitions and end states. When the 'solve' button is clicked, the definition is saved to Cookies and the application evaluates the definition, displays any input errors and prepares the simulation.
- Two dimensional - the logic on this tab is very similar to the multitape. It also offers an arbitrary number of transitions, where it is possible to insert comments starting with two slashes. Multiple strips representing rows in two-dimensional space and multiple end states.
- Transformations - contains 3 pages, each devoted to one transfer. The definition of a singletape TS, multitape TS respectively, are offered. The interfaces consist of a left side that contains the original TS definition and can be changed by the user. A predefined TS is offered. The right half contains a simulating TS, which corresponds to one of the transmission variants: arbitrary alphabet to binary alphabet, double-sided tape to right-sided tape, and conversion of two tapes to one tape.
- Settings - possibility to select from defined translations.
Page layout
- Simulation - consisting of a simulation of the processed tapes/rows and the buttons which control the simulation.
- Definition - defines a TM so that the simulation can be run.
- Moves - offers information on all the steps performed while the TM is running.
Simulation
Below the tape you can see information about the next transition that will be made.
This transition shows the current state of the controller and the future state after the transition.
The transition can be expanded at the simulating TS for more information encoded in the current state.
The following is a description of the functions of each button occurring below the tape, from the center to the edge.
- Play/pause - allows the simulation to switch to an animation state that goes through each step. The animation stops when you click the stop button or reaches the end of moves.
- Previous/next - the simulation animates the transition to the next or previous step.
- Skip n-times -the simulation is moved to a step that is distant by n.
- Start/end - the simulation is moved to the initial or last step.
- State - gray highlighting corresponds to all steps except the last one, if there are exactly two end states - the first behaves as accepting (green) and the second as not-accepting (red). Otherwise, the state is red in all steps except the last, where it is green.
- Speed of the animation - in the range of 10 to 300 %, change will take effect when animating the next step.
Definition
User inputs such as state names and symbols on the tape are controlled to a maximum length of 10 characters. Allowed symbols include alphanumeric characters and special symbols ☐, # a _.
All user inputs in definition of TM:
- Predefined inputs - there are already predefined TMs, which are divided into categories and after selection the simulation is updated with the appropriate definition.
- Input tapes - any number of tapes can be added, but in the case of a multitape TM, all transitions need to be rewritten to match the number of tapes. The symbol(s) on the tape are separated by '|'.
- States - the initial state is one, the final states can be multiple. If there are exactly two end states, then the first is accepting and the second is not-accepting state.
-
Transitions - possibility to enter any number of transitions. The line represents one transition. Option to enter blank lines or lines starting with '//' as a comment.
Following with some examples of well-defined transitions- (p,1) = (p,☐,R) - 1-tape/two-dimensional TM
- (q0, a, ☐, ☐) = (q1, ☐, a, ☐, R, R, 0) - 3-tape TM
- (p, 0) = (p, ☐, D) - two-dimensional TM
- Empty symbol - '☐', the application automatically converts the omitted symbol (space) to '☐'.
Moves
The individual steps consist of the state, the current state of the tapes and the position of the read head on the tape. When the simulation is running, the current steps that the simulation is going through are highlighted. When you click on one of the steps, the simulation is transferred to it.