Antihydra: Difference between revisions

From BusyBeaverWiki
Jump to navigation Jump to search
No edit summary
(Refactor page completely.)
Line 1: Line 1:
{{machine|1RB1RA_0LC1LE_1LD1LC_1LA0LB_1LF1RE_---0RA}}{{unsolved|Does Antihydra run forever?}}
{{machine|1RB1RA_0LC1LE_1LD1LC_1LA0LB_1LF1RE_---0RA}}{{unsolved|Does Antihydra run forever?}}
[[File:Antihydra-depiction.png|right|thumb|Artistic depiction of Antihydra by Jadeix]]
[[File:Antihydra-depiction.png|right|thumb|Artistic depiction of Antihydra by Jadeix]]
'''Antihydra''' is the 6-state 2-symbol machine {{TM|1RB1RA_0LC1LE_1LD1LC_1LA0LB_1LF1RE_---0RA|undecided}}.
'''Antihydra''' ({{TM|1RB1RA_0LC1LE_1LD1LC_1LA0LB_1LF1RE_---0RA|undecided}}) is a [[probviously]] nonhalting [[BB(6)]] [[Collatz-like]] [[Cryptid]]. In fact, it was the first identified BB(6) Cryptid. It is closely related to [[Hydra]].


This machine was the first identified [[BB(6)]] [[Collatz-like]] [[Cryptid]], and is closely related to [[Hydra]].
It simulates iterations of the Collatz-like [[Hydra function]]:


It simulates the Collatz-like iteration
<math display="block">H(n) = \left\lfloor \frac{3n}{2} \right\rfloor = \begin{cases}
  \frac{3n}{2}    & \text{if } n \text{ even} \\
  \frac{3n-1}{2}  & \text{if } n \text{ odd} \\
\end{cases}</math>starting from 8:


<math display="block">\begin{array}{l}
<math display="block">8 \to 12 \to 18 \to 27 \to 40 \to 60 \to 90 \to 135 \to 202 \cdots</math>
  A(2a,  & b) & \to & A(3a,  & b+2) \\
  A(2a+1, & b) & \to & A(3a+1, & b-1) & \text{if} & b>0 \\
  A(2a+1, & 0) & \to & \text{HALT}
\end{array}</math>
<br>
starting from <math>A(8, 0)</math>, using configurations of the form <math>A(a+4, b) = 0^\infty \; 1^b \; 0 \; 1^a \; E> \; 0^\infty</math>.<ref>S. Ligocki, "[https://www.sligocki.com/2024/07/06/bb-6-2-is-hard.html BB(6) is Hard (Antihydra)]" (2024). Accessed 22 July 2024.</ref>


Hence, the machine halts if and only if, in the orbit of 8 under the Collatz-like map <math>x \mapsto 3x/2</math> for x even and <math>x \mapsto (3x-1)/2</math> for x odd, there is ever twice as many more odd terms than even terms.
Antihydra halts if and only if the cumulative number of odd values in this sequence is ever more than twice the cumulative number of even values.


It was discovered by mxdys on 28 Jun 2024 and shared on Discord.<ref>[https://discord.com/channels/960643023006490684/1026577255754903572/1256223215206924318 Discord message], accessed 30 June 2024.</ref>
If we treat the parity of successive values in this sequence as independent random coin flips, then this is a biased random walk and has a miniscule chance of ever halting, thus we say that this TM "probviously" does not halt. But proving this would require solving a Collatz-like problem.


Racheline found that compared to the [[Hydra]] iteration, this one starts at (8, 0) rather than (3, 0), and the roles of odd and even a are exchanged (in terms of which increases b by two, and which decrements b or halts).
== Turing Machine ==
Obstacles to proving the long-run behavior are equally serious.
Antihydra is the TM {{TM|1RB1RA_0LC1LE_1LD1LC_1LA0LB_1LF1RE_---0RA|undecided}}
Like the [[Hydra]] iteration, this one is biased toward increasing the value of b (assuming equal chances of adding +2 or -1).
{| class="wikitable"
|+Antihydra
!
!0
!1
|-
!'''A'''
|1RB
|1RA
|-
!'''B'''
|0LC
|1LE
|-
!'''C'''
|1LD
|1LC
|-
!'''D'''
|1LA
|0LB
|-
!'''E'''
|1LF
|1RE
|-
!'''F'''
| ---
|0RA
|}
It was discovered by @mxdys on 28 Jun 2024 and shared on Discord<ref>[https://discord.com/channels/960643023006490684/1026577255754903572/1256223215206924318 Discord message], accessed 30 June 2024.</ref> and Racheline discovered that it iterates the Hydra function.


There is no halt in the first 11.8 million iterations, by which point b has reached 5890334 (which means that it also does not halt in the first 17690334 iterations).<ref>[https://discord.com/channels/960643023006490684/1026577255754903572/1256403772998029372 Discord message], accessed 2 July 2024.</ref>
== Analysis ==
Let <math>A(a+4, b) = 0^\infty \; 1^b \; 0 \; 1^a \; E> \; 0^\infty</math>, then<ref>S. Ligocki, "[https://www.sligocki.com/2024/07/06/bb-6-2-is-hard.html BB(6) is Hard (Antihydra)]" (2024). Accessed 22 July 2024.</ref>


== Simulator ==
<math display="block">\begin{array}{l}
 
  \text{Start}&& \to & A(8,   & 0) \\
Antihydra is based on a [[consistent Collatz]] sequence, and as such, its behaviour can be simulated efficiently via using the techniques written in that article.
  A(2a,  & b) & \to & A(3a,  & b+2) \\
 
  A(2a+1, & b) & \to & A(3a+1, & b-1) & \text{if} & b>0 \\
Two older simulators are available (that are much slower for calculating large numbers of elements due to running in <math>O(n^2)</math> rather than quasilinear time, but may be useful in cases where more detail is needed about each element or where only a relatively small number of elements is needed):
  A(2a+1, & 0) & \to & \text{HALT}
 
\end{array}</math>At each iteration, <math>a \mapsto H(a)</math> and
A fast simulator written in Rust for the odd/even sequence used by Antihydra is available [http://nethack4.org/esolangs/fasthydra.zip here].
 
Alternatively, here is a GMP implementation of the program with some performance diagnostics added:<syntaxhighlight lang="c">
/* Tested on GMP 6.3.0, Ubuntu 24.04. */
 
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <time.h>
 
#include <gmp.h>
 
static uint64_t get_milis(void) {
    struct timespec ts;
    timespec_get(&ts, TIME_UTC);
    return (uint64_t)(ts.tv_sec * 1000 + ts.tv_nsec/1000000);
}


int main(int argc, char **argv) {
<math display="block">b \mapsto \begin{cases}
    char *as, *bs;
  b+2    & \text{if } a \text{ is even} \\
    mpz_t a, aq, ar, b;
  b-1    & \text{if } a \text{ is odd} \\
    uint64_t i, time, newtime;
\end{cases}</math>


    /* CLI and init. */
halting iff b ever reaches -1.
    if (argc > 1) {
        as = argv[1];
    } else {
        as = "8";
    }
    if (argc > 2) {
        bs = argv[2];
    } else {
        bs = "0";
    }
    mpz_init_set_str(a, as, 10);
    mpz_init_set_str(b, bs, 10);
    mpz_init(aq);
    mpz_init(ar);
    i = 0;
    time = get_milis();


    /* Run. */
== Biased Random Walk ==
    while (1) {
If we consider the sequence of parities of <math>a</math> to be independent random coin flips, then the movement of <math>b</math> is a biased random walk (50% chance of +2, 50% of -1). Starting from <math>b = n</math>, the chance of such a random walk ever reaching <math>b = -1</math> is <math>\left(\frac{1}{2}\right)^{n+1}</math> and the expected value of b after k steps is <math>\frac{k}{2}</math>.
        /* aq = a / 2
        * ar = a % 2 */
        mpz_fdiv_qr_ui(aq, ar, a, 2);
        if (
            /* odd */
            mpz_cmp_ui(ar, 0)
        ) {
            if (!mpz_cmp_ui(b, 0)) break;
            /* a = aq * 3 + 1 */
            mpz_mul_ui(a, aq, 3);
            mpz_add_ui(a, a, 1);
            /* b -= 1 */
            mpz_sub_ui(b, b, 1);
        } else {
            /* a = aq * 3 */
            mpz_mul_ui(a, aq, 3);
            /* b += 2 */
            mpz_add_ui(b, b, 2);
        }
        i++;
        if (i % 100000 == 0) {
            newtime = get_milis();
            gmp_printf("%" PRIu64 " ms=%" PRIu64 " log10(a)=%ju log10(b)=%ju\n",
                      i/100000, newtime - time, mpz_sizeinbase(a, 10), mpz_sizeinbase(b, 10));
            time = newtime;
        }
    }


    /* Cleanup if we ever reach it. */
== Simulation ==
    mpz_clear(a);
@mxdys has simulated this iteration out to <math>2^{31} = 2\,147\,483\,648</math> steps at which point <math>b = 1\,073\,720\,884</math> ([https://discord.com/channels/960643023006490684/1026577255754903572/1258509066196746351 Discord link]), this is 20940 (0.002%) below the expected value if this were a random walk. If this was a random walk, the chance of ever halting from this point is
    mpz_clear(aq);
    mpz_clear(ar);
    mpz_clear(b);
    return 0;
}‎</syntaxhighlight>


Compile and run with:<syntaxhighlight lang="bash">
<math display="block">\left(\frac{1}{2}\right)^{1\,073\,720\,885}</math>
gcc -ggdb3 -O2 -pedantic-errors -std=c11 -Wall -Wextra -o 'antihydra.out' 'antihydra.c' -lgmp
./antihydra.out‎</syntaxhighlight>


Tested on Tested on GMP 6.3.0, Ubuntu 24.04.
an extremely miniscule chance.


==Sources==
==Sources==

Revision as of 16:52, 25 September 2024

Unsolved problem:
Does Antihydra run forever?
Artistic depiction of Antihydra by Jadeix

Antihydra (1RB1RA_0LC1LE_1LD1LC_1LA0LB_1LF1RE_---0RA (bbch)) is a probviously nonhalting BB(6) Collatz-like Cryptid. In fact, it was the first identified BB(6) Cryptid. It is closely related to Hydra.

It simulates iterations of the Collatz-like Hydra function:

starting from 8:

Antihydra halts if and only if the cumulative number of odd values in this sequence is ever more than twice the cumulative number of even values.

If we treat the parity of successive values in this sequence as independent random coin flips, then this is a biased random walk and has a miniscule chance of ever halting, thus we say that this TM "probviously" does not halt. But proving this would require solving a Collatz-like problem.

Turing Machine

Antihydra is the TM 1RB1RA_0LC1LE_1LD1LC_1LA0LB_1LF1RE_---0RA (bbch)

Antihydra
0 1
A 1RB 1RA
B 0LC 1LE
C 1LD 1LC
D 1LA 0LB
E 1LF 1RE
F --- 0RA

It was discovered by @mxdys on 28 Jun 2024 and shared on Discord[1] and Racheline discovered that it iterates the Hydra function.

Analysis

Let , then[2]

At each iteration, and

halting iff b ever reaches -1.

Biased Random Walk

If we consider the sequence of parities of to be independent random coin flips, then the movement of is a biased random walk (50% chance of +2, 50% of -1). Starting from , the chance of such a random walk ever reaching is and the expected value of b after k steps is .

Simulation

@mxdys has simulated this iteration out to  steps at which point (Discord link), this is 20940 (0.002%) below the expected value if this were a random walk. If this was a random walk, the chance of ever halting from this point is

an extremely miniscule chance.

Sources

  1. Discord message, accessed 30 June 2024.
  2. S. Ligocki, "BB(6) is Hard (Antihydra)" (2024). Accessed 22 July 2024.