Finity
A goto language that is a finite automaton on purpose, so whether it halts can always be decided.
Silver, 2025 · Turing complete: no · ●○○ easy · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
Silver made Finity in 2025. Every variable is a whole number below a constant MAXINT, so a program has only finitely many states. The example implementation turns each program into that finite automaton. Then it can tell whether any program halts, and it can shrink a program to the smallest automaton that does the same. The specification points out that real computers are finite as well. Finity only builds the automaton in the open.
Read the story
The example implementation sets MAXINT to 4 so that compiling stays fast, and this implementation does the same. Every value is 0, 1, 2 or 3.
The machine
One statement per line.
| Line | Does |
|---|---|
"text" -> OUTPUT | Print a string |
x -> OUTPUT | Print a value |
x <- INPUT | Read a number |
x = a + b | Assign; the operators are + - * / == < > |
:LABEL | Mark a place |
GOTO LABEL | Jump |
GOTO LABEL IF x == 0 | Jump when the expression is not 0 |
Comparisons give 1 or 0. The specification does not say what happens past MAXINT. In this implementation every result wraps around, so 3 + 1 is 0 and 0 - 1 is 3, and a division by 0 gives 0.
Example
The truth machine from the specification.
The truth machine from the specification.
With MAXINT 4 the numbers go round in a circle.
The specification also has a bubble sort that reads five values and swaps neighbours until they are in order. The specification notes that once the automaton is minimised, it is the same machine a cleverer sort would give.
Patterns it teaches
- Turing completeness: what a language gives up, and gains, by staying finite.
Further
See also
Also in Turing tarpits
Write your own in Run Convert a program from Finity
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: finity.
Command line
shib run finity -e '"hello world\n" -> OUTPUT'shib manual finitySource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/finity.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org