5D Brainfuck With Multiverse Time Travel
|Dimensions||Five-dimensional (in spirit)|
|Computational class||Turing complete|
|Reference implementation||Rust interpreter|
|Major implementations||Julia interpreter|
Like brainfuck, 5D Brainfuck With Multiverse Time Travel operates on an array of memory cells initialized to zero. Multiple pointers to memory, and to the program, may coexist in each timeline. The state of the tape is stored as a timeline, allowing programs to rewind time. In addition, programs may create and traverse parallel universes, which are timelines that all execute simultaneously, "below" their parent timeline. Each timeline has its own pointer.
The following graphic demonstrates the behavior of parallel timelines. Note that this does not include time travel, as that would make the graphic impossible to read.
main timeline split -------------------+----------------------------------------------> | split 2nd timeline dies 2nd timeline +-------+-----------X /------------------------> | / 3rd timeline replaces 2nd 3rd timeline +-----------/
Once the main timeline halts (by running out of instructions to run), all other timelines are killed.
Programs consist of single-character instructions, as follows:
||Move all memory pointers in this timeline 1 cell to the right.|
||Move all memory pointers in this timeline pointer 1 cell to the left.|
||Increment all cells pointed to in this timeline.|
||Decrement all cells pointed to in this timeline.|
||Output a character for all cells pointed to in this timeline.|
||Input a character and store it in all cells pointed to in this timeline.|
||Move this instruction pointer to the matching |
||Move this instruction pointer back to the matching |
||Rewind the current tape back in time by 1 step.|
||Spawn a parallel timeline below the current timeline, with a copy of the tape and all pointers in it. This instruction pointer jumps to the matching |
||If this is executed outside of the main timeline, kill this timeline and all the memory/instruction pointers currently in it. Otherwise, do nothing.|
||Move all memory pointers in this timeline to the same location in the next ("lower") parallel universe. If a lower timeline does not exist, these pointers are discarded instead.|
||Move all memory pointers in this timeline to the same location in the previous ("higher") parallel universe. If a higher timeline does not exist, these pointers are discarded.|
||If the next ("lower") parallel universe contains a nonzero amount of memory pointers, freeze this instruction pointer for this turn. If the next parallel universe has no memory pointers, or if this is the "lowest" timeline, do nothing and continue.|
- It is not necessary for
()braces to be matched with each other, as long as each opening brace matches with its own closing brace. This means that
[(])is valid syntax, and so is
- Yes, the language is not strictly five-dimensional.
~instruction will only rewind the tape. That is, it will only undo the effects of
,instructions. Anything that doesn't manipulate the tape is ignored by
The program's cell count, wrapping behavior, cell size, and behavior upon input reaching EoF are implementation-dependent. It is recommended for programs to have at least 30,000 8-bit unsigned wrapping cells, and to return 255 (-1) on EoF.
Race conditions caused by simultaneous instructions are implementation-dependent. The recommended strategy of dealing with race conditions is to give execution priority to a) higher timelines, and then b) older memory pointers.
Being an extension to brainfuck, the language is trivially Turing complete.
Double the amount of pointers in this timeline
Rewind time until the current cell is 0
Cat, but faster
Undefined behavior time
Two instruction pointers??