This is a collection of systems, such as restricted subsets of programming languages or games, that are Turing-complete, but may not be expected. I have included programs that prove Turing-completeness by construction, but also other interesting programs for fun and demonstration.
- C variable-length arrays: A subset of C99, “disembodied C”, with only VLA
length expressions and functions with empty bodies, parameters, and forward
declarations.
- MD5, SHA-256, and Conway’s Game of Life by lemon (2022)
- C++ templates: A subset of C++ with only templates, template specialization,
struct,typename, andtypedef.-
“Impact of Economics on Compiler Optimization” by Arch D. Robison (2001), in section 4, frames C++ templates as a compile-time optimization in, provides a tree sum example, and compares it to functional programming:
Template metaprograms are programs that run at compilation time. When the ISO C++ committee added templates to C++, the following features were required:
- Instantiation of member types (and member constants of integral type) is demand driven.
- Template identifiers may be overloaded, with resolution based on pattern matching.
- Templates may be recursive.
The list above makes obvious to functional programmers what the committee did not realize until later: templates are a functional language, evaluated at compilation time.
-
λ-calculus by Matt Might (2009)
-
4-bit adder by Aaron Ballman (2013)
-
- Coq typeclass resolver: Typeclass instance resolution is an unrestricted proof search. Notably, Coq's type system is Turing-complete, but it's language is not—the opposite of typical.
- Haskell type system: A subset of Haskell with multi-parameter typeclasses,
functional dependencies, and undecidable instances.
- Turing machine by Keith Wansbrough (1998)
- SK combinator calculus by Rob Dockins (2006)
- Typing the technical interview: N-queens problem by Kyle Kingsbury (2017)
- Java generics: A subset of Java with subtype checking.
- Turing machine and a parser generator for fluent interfaces in “Java Generics are Turing Complete” by Radu Grigore (2016)
- POSIX
printf: A single call to POSIXprintfin a loop.- Introduced in “Control-Flow Bending: On the Effectiveness of Control-Flow Integrity” by Nicholas Carlini, Antonio Barresi, Mathias Payer, David Wagner, and Thomas R. Gross (2015)
- Brainfuck by Mathias Payer and Nicholas Carlini (2015)
- Tic-tac-toe by Nicholas Carlini (2020)
- PostgreSQL: Uses common table expressions (CTEs) and windowing.
- Cyclic tag system by Andrew Gierth (2009)
- Mandelbrot set by Peter Eisentraut (2009)
- Presentation on cyclic tag system, Mandelbrot set, and travelling salesman problem by David Fetter (2009)
- Turing machine by Fabien Coelho (2013)
- Brainfuck with CTEs by David Archibald (2024, unpublished)
- Rust type system: A subset of Rust with type parameters, traits,
multi-parameter traits, and associated types.
- Turing machine by comex (2014) [code], updated (2017) [code]
- Smallfuck by Shea Leffler (2017) [code] [HN 1, 2]
- Minsky machine by Paho Lurie-Gregg (2017)
- Type System Chess by Daniel James (2023), which spurred improvements to rustc [post]
- Rust
macros_rules!and traits - Transact-SQL
- TypeScript type system
- Turing machine and primality test by Henning Dieterichs (2017) [code] [HN]
- Meta-Typing: many math, list, sorting, and puzzle functions and algorithms at type-level by Ronen Amiel (2020) [HN]
- Smallfuck by Ryan Dabler (2021) [code]
- ts-calc: integer arithmetic implemented at type-level as string operations in decimal with table digit lookups by ecyrbe (2022)
- Typescripting the technical interview: N-queens problem by Richard Towers (2023) [HN]
- Type Challenges by Anthony Fu (2020)
- Type System Chess by Daniel James (2023)
- Flappy Bird by Zack Radisic (2023) parses the types in Rust to emit a bytecode, which is evaluated by a VM in Zig
- TypeScript Sudoku by Niklas Gruhn (2024) uses type inference to make an interactive Sudoku
- x86 MMU fault handling
- x86
mov: Only themovinstruction of x86.- “
movis Turing-complete”: Turing machine by Stephen Dolan (2013) - M/o/Vfuscator compiler by Chris Domas (2015), with numerous programs, including DOOM [talk]
- “
Domain-specific languages that are Turing complete.
- awk
- jq
- sed
- dc.sed: an arbitrary-precision RPN calculator by Greg Ubben (1995) [reference]
- turing.sed: Turing machine by Christophe Blaess (2001) [src] [reference]
- SedSokoban: Sokoban game by Aurelio Jargas (2002) [src] [video]
- sedtris: Tetris by Julia Jomantaite (2008)
- Chess in GNU sed by Margulan Moldabekov (2015) [HN]
- cube.sed by Isabella Bosia (2023): interactive 2x2 and 3x3 Rubik's Cube
- Conway's Game of Life
- Turing machine by Paul Rendell (2000)
- Tetris by PhiNotPi, El'endia Starman, K Zhang, Blue (Muddyfish), Cows quack (Kritixi Lithos), Mego, and Quartata (2017)
- Rule 110
- Cyclic tag system in “Universality in Elementary Cellular Automata” by Matthew Cook (2004)
- P-completeness in “P-completeness of cellular automaton Rule 110” by Turlough Neary and Damien Woods (2006) [preprint]
- OpenType fonts
- Addition by Litherum (2019)
- HarfBuzz
- llama.ttf by Søren Fuglede Jørgensen (2024) is a LLM and inference engine in a HarfBuzz Wasm shaper.
- Doom
- counter.wad by fraggle (2006) is an in-game 4-bit binary ripple carry adder circuit using voodoo dolls and conveyor belts [video].
- Half-adder by Jared Candelaria (2021) is an in-game half-adder circuit using lifts and teleporters [video].
- Doom-in-Doom by kgsws (2022) uses a code execution exploit to run Chocolate Doom in Doom 2 on DOS [code].
- conway.wad by Piotr Wieczore (2022) is an in-game simulator for Conway's Game of Life, using scrollers, teleporters and floor movement [code].
- Adding Machine by Danny Spencer (2022) is an in-game calculator that adds 2-digit decimal numbers with a display, using a BDD encoding of logic as monsters, doors, teleporters, and switches [code].
- Dwarf Fortress
- Magic: The Gathering
- Magic Turing Machine by Alex Churchill (2012) embeds a Turing machine in Magic, Wolfram's (2,3) universal Turing machine in versions 1–4 and Yurii Rogozhin's (2,18) universal Turing machine in version 5. Cory Doctorow reported on it.
- “Magic: The Gathering is Turing Complete” by Alex Churchill, Stella Biderman, and Austin Herrick (2019) embeds Rogozhin's (2,18) universal Turing machine in the game, such that the first player is guaranteed to win if and only if the Turing machine halts. Unlike the previous designs by the first author, players are not required to make particular choices.
- I Built a COMPUTER in Magic: The Gathering by Because Science (2019) demonstrates the Turing machine of the paper in gameplay
- Minecraft
- Minecraft in Minecraft by sammyuri, Uwerta, and Stack (2022) [PC Gamer] [HN]
- Rollercoaster Tycoon
- A calculator made from rollercoasters in Rollercoaster Tycoon 2 by Marcel Vos (2016) is a calculator, which can add and multiply single-digit decimal numbers.
- Terraria
- Computerraria: a fully compliant 32-bit RISC-V computer by Xander Naumenko (2023) [video]
- Tetris
- Tetris in Tetris by Mike Birken (2023) [HN]
- Excel
- Excel 16-Bit CPU by Inkbox (2024) is a CPU in Excel with programs compiled from Excel-ASM16 assembly [code]
- Wikipedia: “Unintentional Turing completeness”
- “Surprisingly Turing-Complete” by Gwern Branwen (2012)
- ”Accidentally Turing-Complete” by Andreas Zwinkau (2021)
- “Java Generics are Turing Complete” by Radu Grigore (2016) mentions several other undecidable type systems in section 9 Related Work
- Idris type system (but Idris functions need not be total, i.e., are Turing complete)