Hydra: Difference between revisions

From BusyBeaverWiki
Jump to navigation Jump to search
m Capitalization
Fast Hydra sim
Line 52: Line 52:
<math display="block">\begin{array}{|c|}\hline C(3,0)\xrightarrow{55}C(6,2)\xrightarrow{133}C(12,1)\xrightarrow{364}C(21,0)\xrightarrow{856}C(33,2)\xrightarrow{1938}C(51,4)\xrightarrow{4367}C(78,6)\rightarrow\cdots\\\hline\end{array}</math>
<math display="block">\begin{array}{|c|}\hline C(3,0)\xrightarrow{55}C(6,2)\xrightarrow{133}C(12,1)\xrightarrow{364}C(21,0)\xrightarrow{856}C(33,2)\xrightarrow{1938}C(51,4)\xrightarrow{4367}C(78,6)\rightarrow\cdots\\\hline\end{array}</math>
The heuristic argument that suggests Antihydra is a [[probviously]] non-halting machine can be applied here. This means that if <math>b</math> is to be thought of as moving randomly, then the probability of Hydra halting is <math display="inline">{\Big(\frac{\sqrt{5}-1}{2}\Big)}^{2005374}\approx 4.168\times 10^{-419099}</math>.
The heuristic argument that suggests Antihydra is a [[probviously]] non-halting machine can be applied here. This means that if <math>b</math> is to be thought of as moving randomly, then the probability of Hydra halting is <math display="inline">{\Big(\frac{\sqrt{5}-1}{2}\Big)}^{2005374}\approx 4.168\times 10^{-419099}</math>.
== Code ==
Fast Hydra/[[Antihydra]] simulation code by Greg Kuperberg (who said it could be made faster using FLINT):<syntaxhighlight lang="python2" line="1">
# Python script to demonstrate almost linear time hydra simulation
# using fast multiplication.
# by Greg Kuperberg
import time
from gmpy2 import mpz,bit_mask
# Straight computation of t steps of hydra
def simple(n,t):
    for s in range(t): n += n>>1
    return n
# Accelerated computation of 2**e steps of hydra
def hydra(n,e):
    if e < 9: return simple(n,1<<e)
    t = 1<<(e-1)
    (p3t,m) = (mpz(3)**t,bit_mask(t))
    n = p3t*(n>>t) + hydra(n&m,e-1)
    return p3t*(n>>t) + hydra(n&m,e-1)
def elapsed():
    (last,elapsed.mark) = (elapsed.mark,time.process_time())
    return elapsed.mark-last
elapsed.mark = 0
(n,e) = (mpz(3),25)
elapsed()
print('hydra:  steps=%d hash=%016x time=%.6fs'
    % (1<<e,hash(hydra(n,e)),elapsed()))
# Quadratic time algorithm for comparison
# print('simple: steps=%d hash=%016x time=%.6fs'
#    % (1<<e,hash(simple(n,1<<e)),elapsed()))
</syntaxhighlight>
==References==
==References==
[[Category:Cryptids]]
[[Category:Cryptids]]

Revision as of 10:42, 3 July 2025

Unsolved problem:
Does Hydra run forever?

1RB3RB---3LA1RA_2LA3RA4LB0LB0LA (bbch)

Hydra is a BB(2,5) Cryptid. Its high-level rules were first reported on Discord by Daniel Yuan on 20 April 2024, who also gave Hydra said name. Later on, a 6-state, 2-symbol Turing machine was discovered and named Antihydra for having similar behaviour to Hydra, making the study of this machine important to the study of that one.

Hydra is known to not generate Sturmian words[1] (Corollary 4).

0 1 2 3 4
A 1RB 3RB --- 3LA 1RA
B 2LA 3RA 4LB 0LB 0LA
The transition table of Hydra.

Analysis

Let C(a,b):=0<A20a3b20. Then,[2] C(2a,0)6a2+20a+4033a+11A>20,C(2a,b+1)6a2+23a+10C(3a+3,b),C(2a+1,b)4b+6a2+23a+26C(3a+3,b+2).

Proof

Consider the partial configuration P(m,n):=03mA>020n. After 14 steps this configuration becomes 03m+3<A20n2. We note the following shift rule: 3s<As<A3s Using this shift rule, we get 0<A3m+320n2 in m+3 steps. From here, we can observe that A>03s turns into 3A>03s1 in three steps if s1. By repeating this process, we acquire this transition rule: A>03s3s3sA>0 With this rule, it takes 3m+9 steps to reach the configuration 03m+3A>020n2, which is the same configuration as P(m+3,n2). To summarize: P(m,n)4m+26P(m+3,n2) if n2. With C(a,b) we have P(0,a). As a result, we can apply this rule 12a times, which creates two possible scenarios:

  1. If a0 (mod2), then in i=0(a/2)1(4×3i+26)=32a2+10a steps we arrive at P(32a,0). The matching complete configuration is 03(3/2)aA>023b20, which in four steps becomes 03(3/2)a+11A>3b20. If b=0 then we have reached the undefined A2 transition in 32a2+10a+4 steps total. Otherwise, continuing for three steps gives us 03(3/2)+2<B03b120. Another shift rule is required here:3s<Bs<B0sThis means the configuration becomes 0<B0(3/2)a+33b120 in 32a+2 steps, and 0<A20(3/2)a+33b120, equal to C(32a+3,b1), one step later. This gives a total of 32a2+232a+10 steps.
  2. If a1 (mod2), then in 32a2+7a172 steps we arrive at P(3a32,1). The matching complete configuration is 03(3a3)/2A>0203b20, which in four steps becomes 03(3a1)/21A>03b20, and then 03(3a1)/213bA>020 in 3b steps. After 14 steps, we see the configuration 03(3a1)/213b+3<A20, which turns into 03(3a1)/21<A3b+320 in b+3 steps. In two steps we get 03(3a+1)/2<B03b+220, followed by 0<B0(3a+3)/23b+220 after 3a+12 more steps. We conclude with 0<A20(3a+3)/23b+220, equal to C(3a+32,b+2), one step later. This gives a total of 4b+32a2+172a+16 steps.

The information above can be summarized as C(a,b){03(3/2)a+11A>20if a0(mod2) and b=0,C(32a+3,b1)if a0(mod2) and b>0,C(3a+32,b+2)if a1(mod2). Substituting a2a for the first two cases and a2a+1 for the third yields the final result.

In effect, the halting problem for Hydra is about whether repeatedly applying the function f(n)=3n2+3 will at some point produce more even values of n than twice the number of odd values.

An alternative version of these rules exists that makes the connection to Antihydra more apparent by using the function H(n)=32n, or the Hydra function.[3]

Trajectory

It takes 20 steps to reach the configuration C(3,0), and from there, the Collatz-like rules are repeatedly applied. Simulating Hydra has shown that after 4000000 rule steps, we have b=2005373. Here are the first few: C(3,0)55C(6,2)133C(12,1)364C(21,0)856C(33,2)1938C(51,4)4367C(78,6) The heuristic argument that suggests Antihydra is a probviously non-halting machine can be applied here. This means that if b is to be thought of as moving randomly, then the probability of Hydra halting is (512)20053744.168×10419099.

Code

Fast Hydra/Antihydra simulation code by Greg Kuperberg (who said it could be made faster using FLINT):

# Python script to demonstrate almost linear time hydra simulation
# using fast multiplication. 
# by Greg Kuperberg

import time
from gmpy2 import mpz,bit_mask

# Straight computation of t steps of hydra
def simple(n,t):
    for s in range(t): n += n>>1
    return n

# Accelerated computation of 2**e steps of hydra
def hydra(n,e):
    if e < 9: return simple(n,1<<e)
    t = 1<<(e-1)
    (p3t,m) = (mpz(3)**t,bit_mask(t))
    n = p3t*(n>>t) + hydra(n&m,e-1)
    return p3t*(n>>t) + hydra(n&m,e-1)

def elapsed():
    (last,elapsed.mark) = (elapsed.mark,time.process_time())
    return elapsed.mark-last
elapsed.mark = 0

(n,e) = (mpz(3),25)

elapsed()
print('hydra:  steps=%d hash=%016x time=%.6fs'
    % (1<<e,hash(hydra(n,e)),elapsed()))

# Quadratic time algorithm for comparison
# print('simple: steps=%d hash=%016x time=%.6fs'
#     % (1<<e,hash(simple(n,1<<e)),elapsed()))


References

  1. Dubickas A. On Integer Sequences Generated by Linear Maps. Glasgow Mathematical Journal. 2009; 51(2): 243-252. doi:10.1017/S0017089508004655
  2. S. Ligocki, "BB(2, 5) is Hard (Hydra) (2024). Accessed 22 July 2024.
  3. S. Ligocki, "BB(6) is Hard (Antihydra)" (2024). Accessed 22 July 2024.