Skip to content

hornc/godelfish

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gödelfish

Gödelfish is a Gödel numbering for the (joke) esoteric programming language Deadfish.

It has a page on the esolangs wiki.

This repo contains the specification and some simple scripts to work with (generate, convert, and evaluate) code and Gödel numbers.

There are two kinds of Gödelfish numbers (𝜑̈):

  • Natural Gödelfish: Non-negative integers (ℕ), representing all possible Deadfish programs.
  • Unnatural Gödelfish: Real numbers from (ℝ − ℕ), representing all possible Brainf*** programs.

Both kinds are converted numerically into Brainfoctal (a Gödel numbering of Brainf***), and then can be executed as bf to produce the expected output.

Why?

  • Experiment converting between two programming languages directly from Gödel numberings using equations / mathematical functions.
  • Experiment mapping a Gödel numbering of a program to its output solely by means of equations / mathematical functions. (Natural Gödelfish does this to evalute the admittedly simple Deadfish language).

Scripts

  • /scripts
    • dfᗒgf.py: Converts Deadfish code into Gödelfish integer
    • gfᗒbf8.py: Converts a Gödelfish integer into Brainfoctal
    • gfᗒO.py: Converts a Natural Gödelfish value into its resulting output encoding (i.e. evaluates a program directly from its Gödel number)
  • gf.py: Wraps all of the above into one 'helpful' utility.

Usage and examples

Clone this repo from Github and use the scripts directly.

Hello World! (Unnatural conversion)

$ ./gf.py -b -0.02267050412500270959407579713247251696870738403389181782725188269749688319088642196836222187626319203264982082686924411902690
++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.

Assuming you have a bf interpreter bff4 on your $PATH you can pipe the output to see it evaluate:

$ ./gf.py -b -0.02267050412500270959407579713247251696870738403389181782725188269749688319088642196836222187626319203264982082686924411902690 | bff4
Hello World!

Deadfish overflow test (Natural conversion)

The 0d prefix for the number is a custom base-4 notation:

$ ./gf.py -b 0d011221203
++-[>+>+<<-]>>[<<+>>-]>-<<[->>-<<]+>>[<<->>[-]]<<[[-]<[-]>]<[>+>+<<-]>>[<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>]<<<<<]>[-]++++++++[<++++++>-]>[<<+>>-]>[<<+>>-]<<]>]<[->>++++++++[<++++++>-]]<[.[-]<]<>++++++++++.++++++++++++[-]<

The input number 0d011221203 is equivalent to decimal 23139, or hex 0x5a63, and all of these formats are recognised as input by the interpreter. Conceptually it is important that the program input is a single numeric value, not a string of symbols from one specific alphabet or in one specific base.

Assuming you have a bf interpreter bff4 on your $PATH you can pipe the output to see it evaluate the correct Deadfish accumulator output value:

$ ./gf.py -b 0d011221203 | bff4
288

Output encoding evalutation

$ ./scripts/gfᗒO.py -h
usage: gfᗒO.py [-h] value [radix] [digits]

Convert a Natural Gödelfish value into its resulting output encoding.

positional arguments:
  value       Gödelfish value, 𝜑̈ ∈ ℕ
  radix       radix of output values
  digits      number of digits per output value in base radix

Deadfish overflow test (Natural evaluation)

Base-10 output encoding:

$ ./scripts/gfᗒO.py 0d011221203 10
288

Hexadecimal ouput:

$ ./scripts/gfᗒO.py 0d011221203 16
0x120

Multi-value output (Natural evaluation):

Base-10, 3 digits per output value:

$ ./scripts/gfᗒO.py 0x59565555d55555555555555d555f570000000000000000000000000000000000000003000000000020c000357000c0003 10 3
72101108108111032119111114108100

Base-10, 5 digits per output value:

$ ./scripts/gfᗒO.py 0x59565555d55555555555555d555f570000000000000000000000000000000000000003000000000020c000357000c0003 10 5
7200101001080010800111000320011900111001140010800100

Base-16, 16 digits per output value:

$ ./scripts/gfᗒO.py 0x59565555d55555555555555d555f570000000000000000000000000000000000000003000000000020c000357000c0003 16 16
0x480000000000000065000000000000006c000000000000006c000000000000006f00000000000000200000000000000077000000000000006f0000000000000072000000000000006c0000000000000064

Interactive arithmetic Deadfish interpreter in shell

while read df;do ./scripts/gfᗒO.py $(./scripts/dfᗒgf.py $df | egrep -o '0x.*$') 10 5 | rev | sed -r 's/(.{5})/\1 /g' | rev ;done

This reads standard Deadfish idso commands from STDIN, converts them to Gödelfish, and evaluates the commands arithmetically. The sed command groups output to 5 decimal place values.