esolang

Gödelang

A program is one number. Factor it, and the exponents of 2, 3, 5, 7 and on are the instructions.

TJC games · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 2 known programs · Test method

Run it

Expected: 0

The idea

TJC games based Gödelang on Gödel numbering and calls it another brainfuck clone. A list of instructions becomes one number, 2 to the first instruction times 3 to the second times 5 to the third, and so on through the primes. Reading the program back means factoring it. The first prime that does not divide the number gives the instruction 0, and 0 ends the program.

Read the story

The specification has four versions with four tables. This is version 1.1, the one its cat and truth machine are written in. The specification says an exponent its table does not list is recompiled and run; in this implementation that exponent is read as a number of its own, so 8, which is 2 to the 3, does what 3 does.

The machine

ExponentBrainfuckDoes
0End the program
1 2> <Move right, move left
3 5+ -Add 1, take 1
7 9.Print the value as a character, or as a number
10 11,Read a character, or a line as a number
13 14[ ]Loop while the value is not 0
15 17Skip to the 17 if the value is 0
19[-]Set the value to 0

Values are whole numbers without bounds, and reading past the input gives 0.

Example

The truth machine factors into 2 to the 11, 3 to the 13, 5 to the 9, 7 to the 14 and 11 to the 9.

The truth machine factors into 2 to the 11, 3 to the 13, 5 to the 9, 7 to the 14 and 11 to the 9. That is read a number, loop while it is not 0, print it, end the loop, print it. On 0 it skips the loop and prints 0 once. On 1 it prints 1 for ever.

421,875,000 is 2 to the 3 times 3 to the 3 times 5 to the 9. It adds 1 twice and prints the value as a number.

Expected: 2

Six times seven. The first six primes carry a 3 each, which sets the value to 6, and a loop adds 7 to the next cell six times. The number has 119 digits.

Expected: 42

The cat is 59,250,896,327,476,337,572,570,276,385,712,371,250,000,000,000, which is ,.[,.].

Patterns it teaches

  • Encoding tricks: a list of instructions packed into one number by unique factorization.
  • Turing tarpit: brainfuck underneath, with a few more instructions.

Further

Gödelang builds on Brainfuck.

Brainfuck derivatives

Write your own in Run Convert a program from Gödelang

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: godelang.

Command line

shib run godelang -e '10198658019570622936267207428000000000' --input '0'
shib manual godelang

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/godelang.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org