TuME help

Contents

  1. Introduction
  2. General description
  3. Program edition
  4. Emulation
  5. TML syntax
  6. Limitations

Introduction

TuME stands for "Turing machine emulator" and this is what it is actually aimed to do. The Turing machine is a mathematical model of an idealized digital computer, described by English scientist Alan Turing in 1936. Almost every modern book about algorithm theory contains a thorough, formal description of the Turing machine, so here I will give only a brief overview, enough to start your experience with TuME. The Turing machine consists of an infinite length tape divided into cells, each containing a symbol from a finite set. The latter set is called the machine's external alphabet. One of its symbol is reserved and called empty symbol. There is also a head over the tape, able to move in both directions (namely right and left), read a symbol from cell below it and write a symbol to it. When head attempts to move behind the last cell of the tape, a new cell is attached to the corresponding end of the tape, and it is filled with an empty symbol. That is how tape becomes infinite. Machine always reside in a state from a finite state set and operates in a discrete time. There are two elements of state set with a special meaning: an initial and final states. The head's behavior is determined by a set of commands, each of which specifies the conditions that must be met at the time (i), and actions undertaken at (i+1). Previously mentioned initial state is supposed to appear only in the conditional part of the commands, whilst final state - only in the actions part. Other states can appear anywhere. Combination of an external alphabet, state set, tape with a word on it and a head located somewhere on it, and current machine state is called configuration. A set of commands is called the machine's program.
During the execution step (i), machine compares currently observed symbol on tape and current state with those of commands from its program. When a command matches, it is executed (which means, its actions are performed at the step (i+1)). Now current symbol/state are compared with the program data and the process continues... It halts due to one of the following conditions:

  1. Current state is the final state. As long as it is not supposed to be met in conditional part of any command, it will always lead to the end of execution. Such end can be called "successful". Machine is then called applicable to the word on tape in initial configuration.
  2. Current state is not the final state but, still, there is no command in program for machine's current configuration. It's a faulty situation and it means that program is incorrect. (The same is true for those programs that put machine in an infinite loop).
Besides of algorithm notion formal illustration, Turing machines are used for computability researches and some other mathematical problems. This emulator is intended to be a "material" illustration of the Turing machine itself, as well as debug tool for computer scientists.

General description

TuME is a fast, easy to use tool for running Turing machine programs on multiple platforms, both desktop and mobile. Amongst its features are the following:

TuME might be useful to those who study (or teach) algorithm theory as a visual aid, to mathematicians and computer science researchers, and to all those geeks who play with their smart phones in subway.

Program edition

Once You have loaded TuME, You can see two tabs at the top of main window, corresponding to "Emulation" and "Program" sections of the application. Select the "Program" tab. Now, at the left side of main window You should see three tabs relating to  “Sets”, “Commands” and “Tape” subsections of editor. Their content relates to edition of the corresponding aspects of machine. Note that, as far as word on tape and program commands depend on external alphabet and state set elements, this aspect should be edited before the other two.

Sets edition

Select the "Sets" subsection in the "Program" section, You will see two lists corresponding to state set and external alphabet edition. Below each of them there is a line of control elements. To add a new element of the set, write its name into text field below the corresponding list and press Add new <...> button. To rename the element, select it in the list, enter new name into text field and press Rename <...> button. Once the element is renamed in the sets editor, it will be renamed everywhere it is already in use. To remove last element, simply press Delete last <...> button. You cannot delete an element that is in use somewhere in the program or tape, so alter or remove relative commands and tape cells first.
Note: restriction to delete only the last element might seem inconvenient, but remember, that You can achieve same effect by removing some elements from the tail of the list and then renaming the others.

Commands edition

On the "Commands" subsection You shall see a big table in the center and four buttons below it. The table describes program of the machine. Each row refers to a command. There are 6 columns in the table:

Column name Editable Description
Current state
yes
A state that machine needs to reside in at (i) for this command to be chosen
Observed symbol
yes
A symbol that must appear below the head at (i) for this command to be chosen
Movement direction
yes
Where to move the head at (i+1) if this command is executed
State to switch to
yes
A state that machine will switch to at (i+1) if this command is executed
Symbol to write
yes
A symbol that will be written in the cell at (i+1) before the head movement performed
TML code
no
The command represented in TML

To edit a command, select the corresponding cell in the table and switch to edit mode (it is platform-dependent, e. g., pressing a space for desktop, pressing a command hard button on a Symbian device, etc.). From a drop-down list select an appropriate item and leave edit mode. To add a new row, press Add production button. Newly added rows are highlighted with gray, so that You could easily identify them. Once such row has been altered, it is no longer highlighted. To remove a row, select a row You wish to remove (if You won't do, the last one will be removed) and press Remove production button.
Once You have finished the edition, press Apply changes button to push the program into machine, or Revert changes to erase the changes You have made and pull the program from machine to editor.
Note: unlike the other editor subsections, changes made in this one need to be explicitly confirmed by user. If You won't press Apply changes button after edition is completed, machine will still run an obsolete set of commands (although changes won't be dropped until Revert changes button is pressed).

Tape edition

Tape edition subsection allows You to specify initial word on tape and initial head position relative to the first symbol on tape. Word on tape is presented in the list at the left side of main window. Unlike tape view in the emulation section, symbols here are aligned vertically, leftmost being at the top of the list and rightmost – at the end. To add a new symbol to the end of the tape, select appropriate symbol from the drop-down list at the right part of the window, and press Add symbol button. To change a symbol somewhere on the tape, select it in the list, select new symbol from drop-down list and press Set symbol button. To remove a symbol from the tape, select it in the list and press Remove symbol button.
When You need to change initial offset of head from the beginning of the tape, enter it manually to the text field with a spinner at the right side of the window ("0" points to the first symbol, "1" to the second and so on). Or You can simply pick the symbol You wish head to point to, and press Use list selection as offset button.

Load and save current program and configuration

Machine configuration and program can be saved to and load from a single file. Current TuME version supports only text-based TML format, but there will be an option in the future to save/load binary files as well. TML files can be easily edited from the simplest external text editor, if You dislike the way TuME editor does.

Once the machine have been saved or loaded, a corresponding restore point is created (or overwritten, if any). Each time the machine is reset, its configuration and program will be set to those from restore point.

Emulation

To begin emulation, go to "Emulation" section by selecting the corresponding tab at the top of main window. Now You shall see the emulation screen. Here is a list of components that You shall see here from top to bottom of the screen:

Execution control is based on the following menu items in "Emulation" menu:

If TuME is running on desktop platform, these items have equivalent buttons in navigation pane.

Running in automatic mode

Running the machine in automatic mode allows You to test quickly, whether it is applicable to the word on tape in initial configuration, and acquire results of its execution.

  1. Ensure the machine is properly configured, program is entered and tape contains proper word.
  2. Activate menu item "Emulation > Start" (or press Run button, if present). During the execution, most of the application functions are disabled. Execution will stop if there is no matching commands in the program or if execution time limit reached this feature is not yet implemented.
  3. If execution hangs (maybe, same command is being chosen infinitely), You can always stop it by activating menu item "Emulation > Pause" (or pressing Pause button, if present).

Execution sessions that are finished due to appearance of the final state in machine configuration are the only that considered successful. Information in the status bar can help You to determine execution status. If execution trace was not disabled at the moment of execution start, it will be available in the emulation screen after the execution is finished.

Running in step-by-step mode

In step-by-step mode You can manually trace the execution, even if it is disabled. Be aware that You cannot enter this mode explicitly – machine always resides in it, except for the periods of automatic execution. Even when the machine is empty, it stays in step-by-step execution mode. There are two main actions to control execution  in this mode: step forward (menu item "Emulation > Step forward") and reset ("Emulation > Reset"). To execute machine in this mode, do the following:

  1. Optionally, change a step size (in machine time units) in the "Stride size for step" number input field at the navigation pane in "Emulation" section, if You are not satisfied with the default one, which is 1.
  2. Optionally, change current machine state and / or currently observed symbol on tape in the monitoring row.
  3. Activate "Emulation > Step forward" menu item (or press Step forward button, if present) one or more times. If You have already debugged programs, it might resemble You "Step over" debugger command.
  4. Look at the monitoring row, execution trace (if not disabled) and status bar to see the results.

These actions can be undertaken continuously, until You find that the program execution finished.
When machine execution finished, You can reset it to the most recent restore point by activating "Emulation > Reset" menu item (or pressing Stop / reset button, if present).

TML syntax

TML stands for Turing machine Markup Language. It has nothing in common with the SGML and its derivatives. It is used for textual representation of TuME configuration and program, and is not knows to be used elsewhere.
The TML file consists of three types of lexical elements:

Here is a sample TML code that, when executed, replaces all "0" symbols with "1" from the beginning of the tape until the first "1" is under machine's head:

# No arbitrary states - only initial and final

# Valid arbitrary alphabet
alphabet: 1

# Mandatory states
state0: Q0
state1: Q1

# Empty symbol
empty: 0

# Tape contents
tape:
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1

# Machine commands
Q1(0)->(1)R.Q1
Q1(1)->(1)S.Q0

Limitations

As it was written in introduction, Turing machine operates with an infinite tape. It is also well-known that computers operate with finite numbers located in finite memory. This limitation is especially sensible for mobile devices. TuME tape size is limited by amount of memory available for a user application on the target platform. Also, as far as TuME counts machine time and traces execution process, execution time is limited by the value 264. It's a reasonable high value, but it's a divergence from formal definition given by A. Turing. That's why I'm not sure the application would fit for all tasks that engage Turing machines.

That's all for now. Your bug reports about TuME are welcome (see below).


TuME v1.0 documentation. Copyright © 2011, Dmitriev K. S.
Send Your notes and bug reports to kulhatzker<at>gmail.com.