Skip to content

TuringViz-org/TuringViz

Repository files navigation

TuringViz

Interactive visualizer for deterministic and nondeterministic k-tape Turing machines.

LIVE WEBSITE

The production website is hosted on turingviz.org.

What TuringViz does

TuringViz lets you define and run k-tape Turing machines in the TuringViz DSL and inspect them from multiple angles:

  • State Graph: machine-level transition graph.
  • Configuration Graph: reachable configurations including tape contents and head positions.
  • Computation Tree: unfolded nondeterministic branching over time, with optional compression.
  • Execution controls: step-by-step execution, auto-run, and manual choice of nondeterministic branches.
  • DSL editor: Monaco-based editor with custom syntax highlighting, hovers, and diagnostics.

Input format

  • Machine definitions are written in the TuringViz machine language.
  • Transition styles supported:
    • compact read rules such as on 1/0 -> move R/S;
    • optional write and goto actions, with same for unchanged tape symbols
    • choose { ... } blocks for nondeterministic choices
    • readable if ... then ... rules for tape-specific conditions
  • Language reference:
    • src/tmLanguage/turingviz-machine-language.md

Sharing and loading machines

  • Share links: generated links encode the current machine in the URL hash (#tm=...).
  • Gist import: machine programs can be loaded from GitHub Gists via ?gist=....
  • Examples menu: built-in machine examples for quick exploration.
  • Recent machines: recently loaded machines are available in the UI.

Project background

This project was started in the Softwarepraktikum course at the University of Regensburg and developed by Christoph Greger and Gregor Porsch.

Beyond the core functionality and the first prototypes, a significant part of the development process also used LLM agents.

Local development

Prerequisites

  • Node.js (LTS recommended)
  • npm

Install dependencies

npm install

Start dev server

npm run dev

Build production bundle

npm run build

Preview production build locally

npm run preview

Run tests

npm test
npm run test:coverage

Tech stack

  • React + TypeScript + Vite
  • Material UI
  • Monaco Editor with the custom TuringViz language adapter
  • Cytoscape + React Flow + ELK layout
  • Zustand state management
  • Vitest + Testing Library

Feedback and contact

Feedback is always welcome.

  • Open an issue: GitHub Issues
  • Contact by mail: public@christoph-greger.de

We would also love to hear where you use TuringViz (course, lecture, project, etc.). We are also very happy to hear from people who want to contribute and further develop the project.

We are always happy to receive new, high-quality example machines.
If you share one (via issue or email), we are glad to add it to the website and give proper credits.

Current built-in examples

The following examples are currently available in the "Load Examples" menu:

  • BinaryAdd: Adds two binary numbers (input on tapes 1 and 2) and writes the result on tape 3.
  • NonDetSubstring: Nondeterministically guesses a start position and checks whether tape 2 is a substring of tape 1.
  • vvWord: Checks whether an input word has the form vv (the same substring repeated twice).
  • NonDetSubSetSum: Nondeterministic subset-sum machine using binary-encoded numbers.
  • CheckEven: Accepts iff the number of 1 symbols in a binary input is even.
  • GCD: Computes the greatest common divisor of two unary numbers.
  • AllStrings: Nondeterministically generates all binary strings of a fixed input length.
  • Fib: On input 1^n, this machine has exactly fib(n) accepting paths.
  • DAG: Example whose configuration graph is acyclic (a directed acyclic graph).
  • Circle: Produces a cyclic configuration graph (a simple loop/circle structure).
  • NonDetSAT: Nondeterministic SAT solver for CNF formulas (accepts iff satisfiable).

Acknowledgements

The TuringViz input format is based on the YAML-based Turing machine description format used by turingmachine.io (aepsilon/turing-machine-viz), which is licensed under the BSD 3-Clause License. TuringViz does not include source code from turingmachine.io.

Releases

No releases published

Packages

 
 
 

Contributors

Languages