Loop preventing brainfuck: Difference between revisions
No edit summary |
C++DSUCKER (talk | contribs) No edit summary Tag: Reverted |
||
Line 25: | Line 25: | ||
|Input a character and store it in the cell at the pointer |
|Input a character and store it in the cell at the pointer |
||
|- |
|- |
||
| style="text-align:center"| <code> |
| style="text-align:center"| <code>(A)(B)</code> |
||
|| Will run A while the current cell being nonzero, UNLESS this would continue forever, in which case B runs instead. If B is empty A is allowed to loop |
|||
|| Repeats the code between <code>[</code> and <code>|</code> while the cell at the pointer is nonzero. |
|||
|- |
|||
| style="text-align:center"| <code>(</code> |
|||
|| Skips the structure if executing the code between <code>(</code> and <code>|</code> will not exit |
|||
|- |
|||
| style="text-align:center"| <code>|</code> |
|||
| Ends a stucture, |
|||
|} |
|} |
||
== Unbounded integers == |
== Unbounded integers == |
||
It is reasonable to assume that, if one does operations on infinity, it will result in the machine never halting. you cant remove any infinities either. One can however test for infinity using <code>( |
It is reasonable to assume that, if one does operations on infinity, it will result in the machine never halting. you cant remove any infinities either. One can however test for infinity using <code>(-)(CODE)</code> |
||
== Examples == |
== Examples == |
||
=== Run CODE If cell at pointer is |
=== Run CODE If cell at pointer is nonzero === |
||
⚫ | |||
⚫ | |||
=== Find 1 to the right and move to it if it exists === |
=== Find 1 to the right and move to it if it exists === |
||
<code>(<- |
<code>(<-(+<-)())(+-)</code> |
||
=== add cell to the left to current cell if cell to the left is NOT infinity === |
=== add cell to the left to current cell if cell to the left is NOT infinity === |
||
<code> |
<code>(>(-<+>)()<)(+-)</code> |
||
=== BrainFuck busy beaver === |
=== BrainFuck busy beaver === |
||
Line 59: | Line 52: | ||
=== Semidecider solver === |
=== Semidecider solver === |
||
If we have a brainfuck program <code>''b''</code> we can replace all <code>]</code> with <code> |
If we have a brainfuck program <code>''b''</code> we can replace all <code>[C]</code> with <code>(C)()</code> to result in a loop preventing brainfuck program with the same behavior. If we have a brainfuck program which semidecides some fact, then we can modify it to set the cell under the pointer to 0 by adding a <code>(-)()</code> at the end. If we then use the structure, we can determine the answer of the semidecision. |
||
Assuming a blank starting tape, this outputs the value 1 if <code>''b''</code> halts, or nul if it doesn't. |
Assuming a blank starting tape, this outputs the value 1 if <code>''b''</code> halts, or nul if it doesn't. |
||
( ''b'' |
+( ''b'' (-)())(+-). |
||
=== Semidecider solver with answer and pretty print === |
|||
<code>+(- ''b'' (-)())(---(--->+<)()>.-------.------.-------.+++++++++++.++++++++.(-)()+) ()() (.<)()</code> |
|||
If b halts, it prints the answer from right to left until zero is found. |
|||
If b does not halt it prints 'UNHALT'. |
|||
=== Solving collatz conjecture === |
=== Solving collatz conjecture === |
Revision as of 13:43, 17 April 2025
Loop preventing brainfuck is a brainfuck derivative that can be used to solve the halting problem, calculate busy beavers, and solve math problems.
Commands
Command | Description |
---|---|
>
|
Move the pointer to the right |
<
|
Move the pointer to the left |
+
|
Increment the memory cell at the pointer |
-
|
Decrement the memory cell at the pointer |
.
|
Output the character signified by the cell at the pointer |
,
|
Input a character and store it in the cell at the pointer |
(A)(B)
|
Will run A while the current cell being nonzero, UNLESS this would continue forever, in which case B runs instead. If B is empty A is allowed to loop |
Unbounded integers
It is reasonable to assume that, if one does operations on infinity, it will result in the machine never halting. you cant remove any infinities either. One can however test for infinity using (-)(CODE)
Examples
Run CODE If cell at pointer is nonzero
()(CODE)
Find 1 to the right and move to it if it exists
(<-(+<-)())(+-)
add cell to the left to current cell if cell to the left is NOT infinity
(>(-<+>)()<)(+-)
BrainFuck busy beaver
nothing here yet
Semidecider solver
If we have a brainfuck program b
we can replace all [C]
with (C)()
to result in a loop preventing brainfuck program with the same behavior. If we have a brainfuck program which semidecides some fact, then we can modify it to set the cell under the pointer to 0 by adding a (-)()
at the end. If we then use the structure, we can determine the answer of the semidecision.
Assuming a blank starting tape, this outputs the value 1 if b
halts, or nul if it doesn't.
+( b (-)())(+-).
Semidecider solver with answer and pretty print
+(- b (-)())(---(--->+<)()>.-------.------.-------.+++++++++++.++++++++.(-)()+) ()() (.<)()
If b halts, it prints the answer from right to left until zero is found.
If b does not halt it prints 'UNHALT'.
Solving collatz conjecture
nothing here yet