Relations
One relation of triples, rules that only ever add to it, and output that appears when the right triple turns up.
Hakerh400, 2026 · Turing complete: yes · ●●● hard · esolangs.org
Tested with 4 known programs · Test method
Run it
The idea
Hakerh400 made Relations in 2026. The whole state is one set R of triples of natural numbers. At the start it holds n 0 n+1 for every n, which is all the arithmetic there is. A rule says that when some triples are in R, another one is too. Rules are never run in order. They keep adding triples until the ones that mean output and stop have appeared.
The machine
A rule is triples joined by ->. The last one is added whenever all the others are in R, for any values of the names in them.
| Triple | Means |
|---|---|
n 0 n+1 | There from the start, for every n |
i 1 c | Input character i has code c |
n 2 0 | The input has n characters |
n 3 c | Character n of the output is c |
n 4 0 | After n characters the program stops |
-- comments to the end of the line and /- ... -/ comments a block. The empty program never stops, because 0 4 0 never appears.
Example
The first two are the cats.
The first two are the cats. The one-line cat adds 2 to the middle number of every triple whose middle number has a predecessor, so 1 becomes 3 and 2 becomes 4. The third adds 1 to each character code.
The longest example builds equality, less than, less or equal and parity out of n 0 n+1, then replaces every even digit with #.
R is infinite, and a 10 a alone adds a triple for every number. This implementation adds triples in waves and lets one more number in after each wave, so every triple that follows from the rules turns up in time. The digits example needs 60,900 steps.
Patterns it teaches
- Encoding tricks: input, output and halting are all just triples.
- Turing completeness: successor and rules that add facts are enough.
Further
See also
Also in Rewriting
Write your own in Run Convert a program from Relations
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: relations.
Command line
shib run relations -e '0 4 0' --input 'xyz'shib manual relationsSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/relations.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org