Manual

tm File Format

A tm-file is a plain text file. It describes a turing machine by a transition table and commands.

tm-files are roughly processed line by line. Except for some commands, the order of these lines does not matter. Lines that contain only whitespace are ignored.

tm-files are case-sensitive.

Special characters

Whitespace (spaces and tabs) is used to separate words and cannot be used in any other way.

# is a special character (see comments and commands). It can be escaped using the same symbol again (##).

! can be used as a normal symbol, as long as it doesn't come after an unescaped #.

Comments

A comment starts with a # not directly followed by a ! or a further #. It ends at the end of a line.

Commands

A command starts with #! and ends at the next command, comment or at the end of a line.

The first word of a command is its name. The following words are passed to this command as arguments.

All commands are executed in the order from the file (left to right, top to bottom).

There are six commands:

Name Arguments Description
start <state> Defines the initial state. 1
break <state> [...] Defines a set of break states.
Multiple calls will be merged with a logical OR.
*
end <state> [...] Defines a set of end states.
Multiple calls will be merged with a logical OR.
+
fill <word> Defines the default tape content.
<word> is looped over the tape. One of all the looped words is written as if write was used.
1
write <word> Writes one word onto the tape.
The word is written from left to right starting at cell 0.
*
o
write <pos>[<] <word> [...] Writes to a specified position.
The word is always written from left to right.
<pos> is a cell number. This cell contains the first symbol of the word or the last, if <pos> ended with <.
Multiple pairs of positions and words can be specified.
*
o
wildcard <symbol> Declares <symbol> as a wildcard.
A wildcard must be exactly one symbol. It is only interpreted in the fields read and write of rules (see section rules for further information).
?
1Should be called exactly one time
+Should be called once or more
?Can be called at most once
*Can be called arbitrarily often
oThe order of these commands matter

Tursi takes a guess, when something that should be defined (marked with 1 or +) wasn't defined. You will get a warning though.

Rules

A line that contains something, that isn't whitespace, part of a command or command is interpreted as a rule.

A rule is part of the transition function/table. It is a tuple of the form (state, read, write, move, next state). All fields are separated by whitespace.

Field Description
state A word i
read Exactly one symbol
The wildcard stands for all symbols that don't appear in this field from rules with the same state.
i
write Exactly one symbol
The wildcards stands for the symbol from read.
o
move A number or one of the following aliases
-1 = {l, L, <}   0 = {n, N, s, S, =}   1 = {r, R, >}
o
next state A word o
iinput of the transition function
ooutput of the transition function

All input pairs must be unique.

In every step, the turing machine searches the table for a input that matches its current state and symbol under the head. When found, the three remaining fields (output) are applied in the following order: The current cell is overwritten with write, the head moves move cells to the right (this means, negative numbers let it move to the left), the machine changes it state to next state.

Graphical User Interface

sections of the gui tape viewer rule table history statistics tm control panel tape control panel

[A] Tape Viewer

Shows the tape of the turing machine.

Special cells are marked. These are the leftmost cell accessed by the head since the last tape reset (1), the cell where the head started (2), the current position of the head (3) and the rightmost cell (4).
Move the mouse over a cell to show its number.

Scroll the tape manually using the mouse wheel or simply click and drag the tape.
The viewer also offers different scroll modes, which can follow the head as it moves:

Scroll mode Behavior
scroll none None Don't follow the head at all.
scroll borders Borders Follow the head, but only when it is about to move out of the visible section.
scroll immediate Immediate Immediately follow the head. This looks like the head would stay at its place and the tape would move under it.

[B] Rule Table

These are the rules, that where loaded from the last successfully opened tm-file. They always have the order from the file.

States can be marked (see 'View' in the menu). The start state (mark start), the break states (mark break) and the end states (mark end) use icons as marks. All rules for the current state are marked with a other background color.

If a wildcard was defined, it is shown at the top.

[C] History

If a rule was executed, it is written to the end of the history. The number of that step is also stored (first column).

Before a rule is written to the history, wildcards are replaced with the actual read or written symbol.

The history is limited to a fix maximum of steps (see preferences). The oldest steps are discarded, if the maximum is exceeded. In that case, a hint is shown on the top.

[clear history] clears the history.

[D] Statistics

These are some statistics. They reset with certain manual changes (e.g. writing something onto the tape, changing the current state and so on).

All cell statistics (like the leftmost cell) can be clicked to scroll to the according cell.
That's the reason why there is the statistic initial cell, which will always be 0.

[E] Turing Machine Control Panel

This is the most important control panel. It lets you execute your turing machine.

Button Shortcut Action
reset machine Reset Backspace Set the state to the start state. This doesn't reset the tape and the head position.
step backwards Step
Backwards
Left
arrow key
Undo the last step from the history.
step forwards Step
Forwards
Right
arrow key
Execute the next rule.
run
stop
Run
Stop
Space bar Start or stop the automatic execution. The machine stops on its own when an end state is reached.
breakpoints Breakpoints Enable or disable breakpoints. When enabled, the machine will stop the automatic execution when entering a break state.

The speed of automatic execution can be set with the slider (5). It regulates the pause time between two steps.
The slider has a quadratic scale for more precision near 0.

On some systems a number is shown on the slider. This is not the pause time! The real pause time is shown in a tooltip. Place your mouse over the slider and stand still.

Below, you can change the current state and position of the head.
The list of possible states is generated from the loaded tm-file. All states from the transition table and from the commands start, break and end are included.

Changing the state or head position resets the history!

[F] Tape Control Panel

This panel lets you modify the tape.

All modifications of the tape will reset the history!

[reset tape] resets the tape. If the current tm-file contains write commands, they are also executed. To get a blank tape, you have to remove them and reload the file (you can also put a space between # and ! to disable the command) or overwrite their output.

To write something onto the tape, type it into the text field (7) and choose a write command. The word will be written to the cell, specified in the spinner below (6).

Command Description
write towards Towards Writes the word from left to right. The last symbol hits the specified cell.
write from From Write the word from left to right. The specified cell contains the first symbol (this is the normal behavior).

When the text field has the keyboard focus, pressing enter will execute the second command.

Preferences

The preferences dialog can be opened from the menu bar 'File/Preferences'.

Setting Description
Reset when starting from end state When enabled, the machine will start from the start state when it should step forwards from an end state. However, if it runs automatically, it will stop before starting over again and again and again.
History max. size The maximum number of rules for the history. For every new step that exceeds this limit, the oldest step will be discarded.
Aliases for field 'move' Replacements for -1, 0 and 1 in the transition table column 'move'. These are used for displaying rules and exporting state diagrams, but not for parsing tm-files.
Frame length Repaint delay for the tape viewer (in ms). When higher, multiple changes can be packed into one repaint, but the tape viewer will stutter more. The maximal frame length is 1000 ms.
Stripe size The tape viewer draws a striped tape. This is the length of one stripe (in cells). 0 means no stripes. Flip the stripes with negative numbers.

Export Filters

There are three export filters under 'File/Export/...'.

Tape

Export a section of the tape to a plain text file (txt).

The content of the text file is equal to the output of the console. Only the leading tabs are missing and you can choose, which section should be displayed.

State Diagram

Export the transition table as a state diagram in graph modelling language (gml).

A state diagram is a graph. Each state is a vertex (also called node). The vertices are connected with edges (also called arrows), where one edge is a rule.
The edges point from state to next state. They are labeled with the remaining fields read, write and move in this order.

No graphical informations (like the position or size of the vertices) are generated.

The start state, break states and end states are written into an extra tag 'Tursi', which is not interpreted by other programs.
In fact it isn't interpreted at all, because Tursi can't load gml files. However, it would be possible to write an import function for such files.

History

Export the history as tab-separated values (tsv).

These are exactly the steps from the history table of the GUI, including the additional step number column.

Console Mode

These are the possible parameters for Tursi:

java -jar tursi.jar [<tm-file>]

Start Tursi with a GUI. If a file is specified, it is loaded.

java -jar tursi.jar -?

Print a short help.

java -jar tursi.jar <tm-file> -c [<groups>=<options> [...]]

Open Tursi in console mode. The specified file is loaded and executed once. The parameters after -c are used to modify the output.

Print options can be applied to one ore more groups from

Group Description Rank
e End states 3
b Break states 2
o Other states 1
<number>
> 0
Every nth step
n must be positive.
*

If a state is part of more than one group, the group rank decides, which options are applied. Groups with higher ranks override other groups. * means, that the options are combined with a logical OR.

If the same group is used multiple times with different options, only the last applied options are used.

Possible print options are none, one ore more from

Option Description
s Print the number of the step and the current state.
If state q was reached after the 57th step, this would be the output:

57\tq

t Print the tape and head position after the state was reached.
The printed tape section goes from the leftmost cell ever reached by the head to the rightmost cell.
The output is splitted into 3 lines. A short information about the printed tape section, negative cells (left part, seen from cell 0) and non-negative cells (right part), including cell 0.
If the tape contained 'xyzabcdefgh' and the head was at cell 4, the following lines would be printed:

\ttape (-3, 11, 7), head 4
\txyz
\tabcdefgh

-3 is the first cell from the output and 7 the last. 11 cells were printed.
r Print the next executed rule (only if a rule is executed after this step).
The output is the rule with a leading tab and tab-separated fields:

\tstate\tr\tw\tN\tnextState

Wildcards are replaced with the actual read or written symbol. The move field always uses L, N and R as aliases.
\t stands for the tabulator, a single character.

The options are printed in the order of the table, no matter in which order they were specified.

The defaults are 'e=st bo='.