Skip to content

About

Turing Machine tools

Resources

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

TuringMachine

A Wolfram Language paclet for exploring and analyzing Turing machines, powered by a Rust backend for high-performance enumeration and search.

📦 Paclet Repository: https://resources.wolframcloud.com/PacletRepository/resources/WolframInstitute/TuringMachine/

The published README.md is generated from README-raw.md with MarkdownToNotebook; its output images are live evaluations. Edit README-raw.md and regenerate — don't edit README.md by hand.

Installation

PacletInstall["WolframInstitute/TuringMachine"]
Needs["WolframInstitute`TuringMachine`"]

Documentation

Full documentation — a guide page, a reference page for every symbol, and a tutorial — ships with the paclet and is browsable on its documentation site and the Paclet Repository page. The markdown sources live under TuringMachine/docs/ and are built into the paclet's documentation notebooks by scripts/build_docs.wls.

Usage

A machine is identified by its Wolfram enumeration number together with its state and color counts, written {number, s, k}. A bare integer is shorthand for a 2-state, 2-color machine.

Deterministic (one-sided) machines

Run the s=3, k=2 rule 600720 on input 1 for at most 32 steps:

OneSidedTuringMachineFunction[{600720, 3, 2}, 1, 32]

output

Return the steps, value, and width together as {steps, value, width}:

OneSidedTuringMachineFunction[{600720, 3, 2}, 1, 32, All]

output

A bare integer rule is treated as a 2-state, 2-color machine:

OneSidedTuringMachineFunction[2506, 1, 100]

output

Give the transition table explicitly, as {state, symbol} -> {nextState, writeSymbol, direction} (direction 1 = right, -1 = left):

OneSidedTuringMachineFunction[{{1, 0} -> {1, 1, 1}, {1, 1} -> {1, 0, -1}}, 1, 100]

output

Tabulating whole rule spaces

Count the distinct rules with 2 states and 2 colors:

TuringMachineRuleCount[2, 2]

output

Tabulate step counts for all 4096 two-state, two-color machines over inputs 1 through 100 (backed by Rust):

Dimensions[TuringMachineSteps[2, 2, 200, 100]]

output

See also TuringMachineOutput, TuringMachineWidths, and the combined TuringMachineOutputWithStepsWidths (and their numeric ...Float variants).

Nondeterministic (multiway) machines

A multiway machine is a list of integer rule numbers; where their transitions disagree, the machine branches. Search for a sequence of transitions turning input 0 into output 5 within 50 steps:

MultiwayTuringMachineSearch[{2506, 1953}, 0, 5, 50]

output

Count how many branches remain unexplored after 20 steps:

MultiwayNonHaltedStatesLeft[{2506, 1953}, 0, 20]

output

Cycle detection

Rule 257 enters a cycle within 1000 steps on input 1:

NonTerminatingTuringMachineQ[257, 1, 1000]

output

Rule 2506 does not:

NonTerminatingTuringMachineQ[2506, 1, 1000]

output

Visualization

Plot the space-time evolution — tape cells colored by symbol, the head a black marker:

OneSidedTuringMachinePlot[{600720, 3, 2}, 1, 16]

output

Plot the output value as a function of the input:

OneSidedTuringMachineFunctionPlot[{600720, 3, 2}, {1, 50}, 200]

output

Plot the running time as a function of the input:

OneSidedTuringMachineRuntimePlot[{600720, 3, 2}, {1, 50}, 200]

output

Building from source

The Rust backend (TuringMachine/Libs/ndtm_search) is built with cargo wl, which compiles the library and writes it, with its generated Wolfram Language loader, into TuringMachine/Binaries/ndtm_search-<SystemID>/. The build scripts live in scripts/.

Build the library for the host and every cross target (macOS x86-64/ARM64, Linux x86-64/ARM64, Windows x86-64). Cross-compiling needs the toolchains that scripts/setup_rust.sh and scripts/setup_cross_compile.sh install; on a Mac it is easiest to build inside the Wolfram Engine container with scripts/docker_build.sh:

./scripts/build_all_targets.sh

Load the paclet from this checkout:

PacletDirectoryLoad["TuringMachine"]
Needs["WolframInstitute`TuringMachine`"]

Rebuild the documentation notebooks and the Paclet Repository definition notebook (TuringMachine/ResourceDefinition.nb) from their markdown sources, with PacletPage (pinned in scripts/pacletpage.wl):

wolframscript -f scripts/build_docs.wls

Releasing

Releases go through PacletPage. Bump "Version" in TuringMachine/PacletInfo.wl, rebuild the docs, then submit to the Paclet Repository as the account that owns the WolframInstitute publisher (nikm@wolfram.com), and publish the paclet's resource and documentation site in the Wolfram Institute's cloud account. The accounts are connected by the wolfram-cloud-account skill's run-as.wls; every archive is checked to hold the Rust libraries of all five platforms.

wolframscript -f scripts/build_docs.wls
RUNAS=~/.claude/skills/wolfram-cloud-account/run-as.wls
wolframscript -f $RUNAS nikm scripts/submit.wls --dry-run      # everything but the submission
wolframscript -f $RUNAS nikm scripts/submit.wls                # submit to the Paclet Repository
wolframscript -f $RUNAS wolframinstitute scripts/release.wls   # resource and documentation site

CI (.github/workflows/build_paclet.yml) builds all targets and the paclet archive on every push to main; scripts/act_run.sh runs the same workflow locally with act.

About

Turing Machine tools

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages