Antihydra: Difference between revisions

From BusyBeaverWiki
Jump to navigation Jump to search
MrSolis (talk | contribs)
Changed connection to Hydra function to a mention (better version of simplified rules is on that page), moved restatement of halting problem from Analysis to Description
Add Nico BB vs. Antihydra illustration.
 
(34 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{{machine|1RB1RA_0LC1LE_1LD1LC_1LA0LB_1LF1RE_---0RA}}{{unsolved|Does Antihydra run forever?}}{{TM|1RB1RA_0LC1LE_1LD1LC_1LA0LB_1LF1RE_---0RA|undecided}}
{{machine|1RB1RA_0LC1LE_1LD1LC_1LA0LB_1LF1RE_---0RA}}{{unsolved|Does Antihydra run forever?}}
[[File:Antihydra-depiction.png|right|thumb|200px|Artistic depiction of Antihydra by Jadeix]]
{{TM|1RB1RA_0LC1LE_1LD1LC_1LA0LB_1LF1RE_---0RA|undecided}}, called '''Antihydra''', is a [[BB(6)]] [[Cryptid]]. Its pseudo-random behaviour was first reported [https://discord.com/channels/960643023006490684/1026577255754903572/1256223215206924318 on Discord] by mxdys on 28 June 2024, and Racheline discovered the high-level rules soon after. It was named after the 2-state, 5-symbol [[Turing machine]] called [[Hydra]] for sharing many similarities to it.<ref>[https://discord.com/channels/960643023006490684/960643023530762341/1257053002859286701 Discord conversation where the machine was named]</ref>
'''Antihydra''' is the first [[BB(6)]] [[Cryptid]] to be identified. It operates by repeatedly applying the function <math display="inline">H(n)=\Big\lfloor\frac{3}{2}n\Big\rfloor</math>, starting with <math>n=8</math>. Determining whether this [[Turing machine]] halts requires solving a [[Collatz-like ]] mathematical problem. Specifically, one must establish a significant result regarding the frequency of odd versus even numbers generated throughout the sequence. While probabilistic arguments based on random walks suggest Antihydra [[probviously]] runs indefinitely, proving this remains challenging. The difficulty stems from both the lack of an exploitable pattern in the sequence’s parities and the inherent complexity of Collatz-like problems.
== Description ==
[[File:Antihydra TransitionTable.png|right|150px|thumb|The transition table of Antihydra.]]
Antihydra basically repeatedly modifies the integer ordered pair <math>(x,y)</math> starting at <math>(0,4)</math>, which is represented on the tape as <math>x</math> consecutive <math>1</math>s and <math>y</math> consecutive <math>1</math>s, separated by a single <math>0</math>. It does this by "borrowing" a <math>0</math> from the right side and, through a series of back-and-forth head movements, "moves" this <math>0</math> toward the one separating <math>x</math> and <math>y</math>, two units at a time. As this happens, the head visits new cells on the right, which has the effect of there being about <math display="inline">\frac{3}{2}</math> times as many <math>1</math>s on the tape when the distance has been closed. After that, <math>x</math> and <math>y</math> are updated. If the previous value of <math>x</math> was even, then <math>y</math> becomes <math>y+2</math>. Otherwise, <math>y</math> becomes <math>y-1</math> or Antihydra halts if <math>y</math> was 0.


Let <math display="inline">H(n)=\Big\lfloor\frac{3}{2}n\Big\rfloor</math>, and <math>a_k</math> and <math>b_k</math> be integer sequences defined below:
Antihydra is known to not generate Sturmian words<ref>DUBICKAS A. ON INTEGER SEQUENCES GENERATED BY LINEAR MAPS. ''Glasgow Mathematical Journal''. 2009;51(2):243-252. doi:[https://doi.org/10.1017/S0017089508004655 10.1017/S0017089508004655]</ref> (Corollary 4).
<math display="block">\begin{array}{l}
<table style="margin: auto; text-align: center;"><tr><td style="width: 200px;">[[File:Antihydra-depiction.png|200px]]<br>Artistic depiction of Antihydra by Jadeix</td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td>
a_0=0,&a_{k+1} =  \begin{cases}a_k + 2 & \text{if } b_k\equiv0\pmod{2}\\a_k - 1 & \text{if }b_k\equiv1\pmod{2} \\\end{cases},&b_0=8,&b_{k+1}=H(b_k).\end{array}</math>
{|class="wikitable" style="margin-left: auto; margin-right: auto;"
Antihydra halts if and only if there exists any number <math>i</math> for which <math>a_i<0</math>.
! !!0!!1
=== Attributions ===
|-
Antihydra and its pseudo-random behaviour were reported [https://discord.com/channels/960643023006490684/1026577255754903572/1256223215206924318 on Discord] by mxdys on 28 June 2024, and Racheline discovered the high-level rules soon after, where it was found to be closely related to [[Hydra]].
!A
|1RB
|1RA
|-
!B
|0LC
|1LE
|-
!C
|1LD
|1LC
|-
!D
|1LA
|0LB
|-
!E
|1LF
|1RE
|-
!F
| ---
|0RA
|}
The transition table of Antihydra.
</td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td>[[File:Antihydra_state_diagram.png|200x200px]]
State diagram of Antihydra
</td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td style="width: 220px;">[[File:Antihydra award.jpg|220px]]<br>A community trophy - to be awarded to the first person or group who solves the Antihydra problem
</td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td>[[File:Nico-BB-vs-Antihydra.jpg|thumb|A brave busy beaver confronts the dreaded Antihydra. Copyright [https://www.nicoroper.com/ Nico Roper].]]</td></tr></table>
== Analysis ==
== Analysis ==
Let <math>A(a,b):=0^\infty\;1^a\;0\;1^b\;\textrm{E>}\;0^\infty</math>. Then,<ref name="bl">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>
Let <math>A(a,b):=0^\infty\;1^a\;0\;1^b\;\textrm{E}\textrm{>}\;0^\infty</math>. Then,<ref name="bl">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>
<math display="block">\begin{array}{|lll|}\hline
<math display="block">\begin{array}{|lll|}\hline
A(a,2b)& \xrightarrow{2a+3b^2+12b+11}& A(a+2,3b+2),\\
A(a,2b)& \xrightarrow{2a+3b^2+12b+11}& A(a+2,3b+2),\\
A(0,2b+1)&\xrightarrow{3b^2+9b-1}& 0^\infty\;\textrm{<F}\;110\;1^{3b}\;0^\infty,\\
A(0,2b+1)&\xrightarrow{3b^2+9b-1}& 0^\infty\;\textrm{<}\textrm{F}\;110\;1^{3b}\;0^\infty,\\
A(a+1,2b+1)&\xrightarrow{3b^2+12b+5}& A(a,3b+3).\\\hline
A(a+1,2b+1)&\xrightarrow{3b^2+12b+5}& A(a,3b+3).\\\hline
\end{array}</math>
\end{array}</math>
<div class="toccolours mw-collapsible mw-collapsed">'''Proof'''<div class="mw-collapsible-content">
<div class="toccolours mw-collapsible mw-collapsed">'''Proof'''<div class="mw-collapsible-content">
Consider the partial configuration <math>P(m,n):=0\;1^m\;\textrm{E>}\;0\;1^n\;0^\infty</math>. The configuration after two steps is <math>0\;1^{m-1}\;0\;\textrm{A>}\;1^{n+1}\;0^\infty</math>. We note the following shift rule:
Consider the partial configuration <math>P(m,n):=0\;1^m\;\textrm{E}\textrm{>}\;0\;1^n\;0^\infty</math>. The configuration after two steps is <math>0\;1^{m-1}\;0\;\textrm{A}\textrm{>}\;1^{n+1}\;0^\infty</math>. We note the following shift rule:
<math display="block">\begin{array}{|c|}\hline\textrm{A>}\;1^s\xrightarrow{s}1^s\;\textrm{A>}\\\hline\end{array}</math>
<math display="block">\begin{array}{|c|}\hline\textrm{A}\textrm{>}\;1^s\xrightarrow{s}1^s\;\textrm{A}\textrm{>}\\\hline\end{array}</math>
As a result, we get <math>0\;1^{m-1}\;0\;1^{n+1}\;\textrm{A>}\;0^\infty</math> after <math>n+1</math> steps. Advancing two steps produces <math>0\;1^{m-1}\;0\;1^{n+2}\;\textrm{<C}\;0^\infty</math>. A second shift rule is useful here:
As a result, we get <math>0\;1^{m-1}\;0\;1^{n+1}\;\textrm{A}\textrm{>}\;0^\infty</math> after <math>n+1</math> steps. Advancing two steps produces <math>0\;1^{m-1}\;0\;1^{n+2}\;\textrm{<}\textrm{C}\;0^\infty</math>. A second shift rule is useful here:
<math display="block">\begin{array}{|c|}\hline1^s\;\textrm{<C}\xrightarrow{s}\textrm{<C}\;1^s\\\hline\end{array}</math>
<math display="block">\begin{array}{|c|}\hline1^s\;\textrm{<}\textrm{C}\xrightarrow{s}\textrm{<}\textrm{C}\;1^s\\\hline\end{array}</math>
This allows us to reach <math>0\;1^{m-1}\;0\;\textrm{<C}\;1^{n+2}\;0^\infty</math> in <math>n+2</math> steps. Moving five more steps gets us to <math>0\;1^{m-2}\;\textrm{E>}\;0\;1^{n+3}\;0^\infty</math>, which is the same configuration as <math>P(m-2,n+3)</math>. Accounting for the head movement creates the condition that <math>m\ge 4</math>. In summary:
This allows us to reach <math>0\;1^{m-1}\;0\;\textrm{<}\textrm{C}\;1^{n+2}\;0^\infty</math> in <math>n+2</math> steps. Moving five more steps gets us to <math>0\;1^{m-2}\;\textrm{E}\textrm{>}\;0\;1^{n+3}\;0^\infty</math>, which is the same configuration as <math>P(m-2,n+3)</math>. Accounting for the head movement creates the condition that <math>m\ge 4</math>. In summary:
<math display="block">\begin{array}{|c|}\hline P(m,n)\xrightarrow{2n+12}P(m-2,n+3)\text{ if }m\ge 4.\\\hline\end{array}</math>
<math display="block">\begin{array}{|c|}\hline P(m,n)\xrightarrow{2n+12}P(m-2,n+3)\text{ if }m\ge 4.\\\hline\end{array}</math>
With <math>A(a,b)</math> we have <math>P(b,0)</math>. As a result, we can apply this rule <math display="inline>\big\lfloor\frac{1}{2}b\big\rfloor-1</math> times (assuming <math>b\ge 4</math>), which creates two possible scenarios:
With <math>A(a,b)</math> we have <math>P(b,0)</math>. As a result, we can apply this rule <math display="inline">\big\lfloor\frac{1}{2}b\big\rfloor-1</math> times (assuming <math>b\ge 4</math>), which creates two possible scenarios:
#If <math>b\equiv0\ (\operatorname{mod}2)</math>, then in <math>\sum_{i=0}^{(b/2)-2}(2\times 3i+12)=\textstyle\frac{3}{4}b^2+\frac{3}{2}b-6</math> steps we arrive at <math display="inline">P\Big(2,\frac{3}{2}b-3\Big)</math>. The matching complete configuration is <math>0^\infty\;1^a\;011\;\textrm{E>}\;0\;1^{(3b)/2-3}\;0^\infty</math>. After <math>3b+4</math> steps this is <math>0^\infty\;1^a\;\textrm{<C}\;00\;1^{(3b)/2}\;0^\infty</math>, which then leads to <math>0^\infty\;\textrm{<C}\;1^a\;00\;1^{(3b)/2}\;0^\infty</math> in <math>a</math> steps. After five more steps, we reach <math>0^\infty\;1\;\textrm{E>}\;1^{a+2}\;00\;1^{(3b)/2}\;0^\infty</math>, from which another shift rule must be applied:<math display="block">\begin{array}{|c|}\hline\textrm{E>}\;1^s\xrightarrow{s}1^s\;\textrm{E>}\\\hline\end{array}</math>Doing so allows us to get the configuration <math>0^\infty\;1^{a+3}\;\textrm{E>}\;00\;1^{(3b)/2}\;0^\infty</math> in <math>a+2</math> steps. In six steps we have <math>0^\infty\;1^{a+2}\;011\;\textrm{E>}\;1^{(3b)/2}\;0^\infty</math>, so we use the shift rule again, ending at <math>0^\infty\;1^{a+2}\;0\;1^{(3b)/2+2}\;\textrm{E>}\;0^\infty</math>, equal to <math display="inline">A\Big(a+2,\frac{3}{2}b+2\Big)</math>, <math display="inline">\frac{3}{2}b</math> steps later. This gives a total of <math display="inline">2a+\frac{3}{4}b^2+6b+11</math> steps.
#If <math>b\equiv0\ (\operatorname{mod}2)</math>, then in <math>\sum_{i=0}^{(b/2)-2}(2\times 3i+12)=\textstyle\frac{3}{4}b^2+\frac{3}{2}b-6</math> steps we arrive at <math display="inline">P\Big(2,\frac{3}{2}b-3\Big)</math>. The matching complete configuration is <math>0^\infty\;1^a\;011\;\textrm{E}\textrm{>}\;0\;1^{(3b)/2-3}\;0^\infty</math>. After <math>3b+4</math> steps this is <math>0^\infty\;1^a\;\textrm{<}\textrm{C}\;00\;1^{(3b)/2}\;0^\infty</math>, which then leads to <math>0^\infty\;\textrm{<}\textrm{C}\;1^a\;00\;1^{(3b)/2}\;0^\infty</math> in <math>a</math> steps. After five more steps, we reach <math>0^\infty\;1\;\textrm{E}\textrm{>}\;1^{a+2}\;00\;1^{(3b)/2}\;0^\infty</math>, from which another shift rule must be applied:<math display="block">\begin{array}{|c|}\hline\textrm{E}\textrm{>}\;1^s\xrightarrow{s}1^s\;\textrm{E}\textrm{>}\\\hline\end{array}</math>Doing so allows us to get the configuration <math>0^\infty\;1^{a+3}\;\textrm{E}\textrm{>}\;00\;1^{(3b)/2}\;0^\infty</math> in <math>a+2</math> steps. In six steps we have <math>0^\infty\;1^{a+2}\;011\;\textrm{E}\textrm{>}\;1^{(3b)/2}\;0^\infty</math>, so we use the shift rule again, ending at <math>0^\infty\;1^{a+2}\;0\;1^{(3b)/2+2}\;\textrm{E}\textrm{>}\;0^\infty</math>, equal to <math display="inline">A\Big(a+2,\frac{3}{2}b+2\Big)</math>, <math display="inline">\frac{3}{2}b</math> steps later. This gives a total of <math display="inline">2a+\frac{3}{4}b^2+6b+11</math> steps.
#If <math>b\equiv1\ (\operatorname{mod}2)</math>, then in <math display="inline">\frac{3}{4}b^2-\frac{27}{4}</math> steps we arrive at <math display="inline">P\Big(3,\frac{3b-9}{2}\Big)</math>. The matching complete configuration is <math>0^\infty\;1^a\;0111\;\textrm{E>}\;0\;1^{(3b-9)/2}\;0^\infty</math>. After <math>3b+2</math> steps this becomes <math>0^\infty\;1^a\;\textrm{<F}\;110\;1^{(3b-3)/2}\;0^\infty</math>. If <math>a=0</math> then we have reached the undefined <code>F0</code> transition with a total of <math display="inline">\frac{3}{4}b^2+3b-\frac{19}{4}</math> steps. Otherwise, continuing for six steps gives us <math>0^\infty\;1^{a-1}\;0111\;\textrm{E>}\;1^{(3b-3)/2}\;0^\infty</math>. We conclude with the configuration <math>0^\infty\;1^{a-1}\;0\;1^{(3b+3)/2}\;\textrm{E>}\;0^\infty</math>, equal to <math display="inline">A\Big(a-1,\frac{3b+3}{2}\Big)</math>, in <math display="inline">\frac{3b-3}{2}</math> steps. This gives a total of <math display="inline">\frac{3}{4}b^2+\frac{9}{2}b-\frac{1}{4}</math> steps.
#If <math>b\equiv1\ (\operatorname{mod}2)</math>, then in <math display="inline">\frac{3}{4}b^2-\frac{27}{4}</math> steps we arrive at <math display="inline">P\Big(3,\frac{3b-9}{2}\Big)</math>. The matching complete configuration is <math>0^\infty\;1^a\;0111\;\textrm{E}\textrm{>}\;0\;1^{(3b-9)/2}\;0^\infty</math>. After <math>3b+2</math> steps this becomes <math>0^\infty\;1^a\;\textrm{<}\textrm{F}\;110\;1^{(3b-3)/2}\;0^\infty</math>. If <math>a=0</math> then we have reached the undefined <code>F0</code> transition with a total of <math display="inline">\frac{3}{4}b^2+3b-\frac{19}{4}</math> steps. Otherwise, continuing for six steps gives us <math>0^\infty\;1^{a-1}\;0111\;\textrm{E}\textrm{>}\;1^{(3b-3)/2}\;0^\infty</math>. We conclude with the configuration <math>0^\infty\;1^{a-1}\;0\;1^{(3b+3)/2}\;\textrm{E}\textrm{>}\;0^\infty</math>, equal to <math display="inline">A\Big(a-1,\frac{3b+3}{2}\Big)</math>, in <math display="inline">\frac{3b-3}{2}</math> steps. This gives a total of <math display="inline">\frac{3}{4}b^2+\frac{9}{2}b-\frac{1}{4}</math> steps.
The information above can be summarized as
The information above can be summarized as
<math display="block">A(a,b)\rightarrow\begin{cases}A\Big(a+2,\frac{3}{2}b+2\Big)&\text{if }b\ge 2,b\equiv0\pmod{2};\\0^\infty\;\textrm{<F}\;110\;1^{(3b-3)/2}\;0^\infty&\text{if }b\ge3,b\equiv1\pmod{2},\text{ and }a=0;\\A\Big(a-1,\frac{3b+3}{2}\Big)&\text{if }b\ge3,b\equiv1\pmod{2},\text{ and }a>0.\end{cases}</math>
<math display="block">A(a,b)\rightarrow\begin{cases}A\Big(a+2,\frac{3}{2}b+2\Big)&\text{if }b\ge 2,b\equiv0\pmod{2};\\0^\infty\;\textrm{<}\textrm{F}\;110\;1^{(3b-3)/2}\;0^\infty&\text{if }b\ge3,b\equiv1\pmod{2},\text{ and }a=0;\\A\Big(a-1,\frac{3b+3}{2}\Big)&\text{if }b\ge3,b\equiv1\pmod{2},\text{ and }a>0.\end{cases}</math>
Substituting <math>b\leftarrow 2b</math> for the first case and <math>b\leftarrow 2b+1</math> for the other two yields the final result.
Substituting <math>b\leftarrow 2b</math> for the first case and <math>b\leftarrow 2b+1</math> for the other two yields the final result.
</div></div>
</div></div>
The page [[Hydra function]] shows how these rules can be simplified to use that function instead, along with Hydra.
In effect, the halting problem for Antihydra is about whether repeatedly applying the function <math display="inline">f(n)=\Big\lfloor\frac{3n}{2}\Big\rfloor+2</math> will at some point produce more odd values of <math>n</math> than twice the number of even values.
 
These rules can be modified to use the function <math display="inline">H(n)=\Big\lfloor\frac{3n}{2}\Big\rfloor</math>, or the [[Hydra function]], which strengthens Antihydra's similarities to Hydra.
== Trajectory ==
== Trajectory ==
11 steps are required to enter the configuration <math>A(0, 4)</math> before the rules are repeatedly applied. So far, Antihydra has been simulated to <math>2^{31}</math> rule steps, at which point <math>b=1073720884</math>. Here are the first few:
[[File:Antihydra Walk.png|thumb|Path of parity of repeated applications of Hydra map for Antihydra.]]
Starting from a blank tape, Antihydra reaches <math>A(0, 4)</math> in 11 steps and then the rules are repeatedly applied. So far, Antihydra has been simulated to <math>2^{38}</math> rule steps,<ref>https://discord.com/channels/960643023006490684/1026577255754903572/1271528180246773883</ref> at which point <math>a</math> exceeds <math>2^{37}</math>. Here are the first few:
<math display="block">\begin{array}{|c|}\hline A(0,4)\xrightarrow{47}A(2,8)\xrightarrow{111}A(4,14)\xrightarrow{250}A(6,23)\xrightarrow{500}A(5,36)\xrightarrow{1209}A(7,56)\xrightarrow{2713}A(9,86)\rightarrow\cdots\\\hline\end{array}</math>
<math display="block">\begin{array}{|c|}\hline A(0,4)\xrightarrow{47}A(2,8)\xrightarrow{111}A(4,14)\xrightarrow{250}A(6,23)\xrightarrow{500}A(5,36)\xrightarrow{1209}A(7,56)\xrightarrow{2713}A(9,86)\rightarrow\cdots\\\hline\end{array}</math>
===A heuristic nonhalting argument===
The trajectory of <math>a</math> values resembles a random walk in which the walker can only move in step sizes +2 or -1 with equal probability, starting at position 0. If <math>P(n)</math> is the probability that the walker will reach position -1 from position <math>n</math>, then it can be seen that <math display="inline">P(n)=\frac{1}{2}P(n-1)+\frac{1}{2}P(n+2)</math>. Solutions to this recurrence relation come in the form <math display="inline"> P(n)=c_0{\left(\frac{\sqrt{5}-1}{2}\right)}^n+c_1+c_2{\left(-\frac{1+\sqrt{5}}{2}\right)}^n</math>, which after applying the appropriate boundary conditions reduces to <math display="inline">P(n)={\left(\frac{\sqrt{5}-1}{2}\right)}^{n+1}</math>. This means that if the walker were to get to the position of the current <math>a</math> value, then the probability of it ever reaching position -1 is less than <math display="inline">{\left( \frac{\sqrt{5}-1}{2} \right)}^{2^{37}}\approx 2.884\times 10^{-28723042565}</math>. This combined with the fact that the expected position of the walker after <math>k</math> steps is <math display="inline">\frac{1}{2}k</math> strongly suggests Antihydra [[probviously]] runs indefinitely.
[[File:Antihydra increasing value.png|thumb|200px|A binary representation of the first 1000 steps of the evolution of the exponentially increasing variable of the Antihydra iteration (a = a + a//2). The colored background indicates whether the value is even or odd with blue and red, respectively.]]
 
The trajectory of <math>b</math> values can be approximated by a random walk in which the walker can only move in step sizes +2 or -1 with equal probability, starting at position 0. If <math>P(n)</math> is the probability that the walker will reach position -1 from position <math>n</math>, then it can be seen that <math display="inline">P(n)=\frac{1}{2}P(n-1)+\frac{1}{2}P(n+2)</math>. Solutions to this recurrence relation come in the form <math display="inline"> P(n)=c_0{\left(\frac{\sqrt{5}-1}{2}\right)}^n+c_1+c_2{\left(-\frac{1+\sqrt{5}}{2}\right)}^n</math>, which after applying the appropriate boundary conditions reduces to <math display="inline">P(n)={\left(\frac{\sqrt{5}-1}{2}\right)}^{n+1}</math>. This means that if walker were to get to position 1073720884 then the probability of it ever reaching position -1 is <math display="inline">{\left(\frac{\sqrt{5}-1}{2}\right)}^{1073720885}\approx 4.841\times 10^{-224394395}</math>. This combined with the fact that the expected position of the walker after <math>k</math> steps is <math display="inline">\frac{1}{2}k</math> strongly suggests Antihydra will not halt.
== Code ==
The following Python program implements the abstracted behavior of the Antihydra. Proving whether it halts or not would also solve the Antihydra problem:<syntaxhighlight lang="python" line="1">
# Current value of the iterated Hydra function starting with initial value 8 (the values do not overflow)
h = 8
# (Collatz-like) condition counter that keeps track of how many odd and even numbers have been encountered
c = 0
# If c equals -1 there have been (strictly) more than twice as many odd as even numbers and the program halts
while c != -1:
    # If h is even, add 2 to c so even numbers count twice
    if h % 2 == 0:
        c += 2
    else:
        c -= 1
    # Add the current hydra value divided by two (integer division, rounding down) to itself (Hydra function)
    # Note that integer division by 2 is equivalent to one bit shift to the right (h >> 1)
    h += h//2
</syntaxhighlight>
 
The variable values of this iteration have been put into the On-Line Encyclopedia of Integer Sequences (OEIS):
 
* Hydra function values with Antihydra's starting value 8: https://oeis.org/A386792
* Antihydra's condition values: https://oeis.org/A385902
 
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>


''To view an animation of the blank tape becoming <math>A(6,23)</math> in 419 steps, click [https://wiki.bbchallenge.org/w/images/3/36/AHydra_0-419.gif here].''
==References==
==References==
[[Category:Individual machines]]
 
[[Category:Cryptids]]
[[Category:BB(6)]][[Category:Cryptids]]

Latest revision as of 19:13, 22 October 2025

Unsolved problem:
Does Antihydra run forever?

1RB1RA_0LC1LE_1LD1LC_1LA0LB_1LF1RE_---0RA (bbch), called Antihydra, is a BB(6) Cryptid. Its pseudo-random behaviour was first reported on Discord by mxdys on 28 June 2024, and Racheline discovered the high-level rules soon after. It was named after the 2-state, 5-symbol Turing machine called Hydra for sharing many similarities to it.[1]

Antihydra is known to not generate Sturmian words[2] (Corollary 4).


Artistic depiction of Antihydra by Jadeix
      
0 1
A 1RB 1RA
B 0LC 1LE
C 1LD 1LC
D 1LA 0LB
E 1LF 1RE
F --- 0RA

The transition table of Antihydra.

      

State diagram of Antihydra

      
A community trophy - to be awarded to the first person or group who solves the Antihydra problem
      
A brave busy beaver confronts the dreaded Antihydra. Copyright Nico Roper.

Analysis

Let A(a,b):=01a01bE>0. Then,[3] A(a,2b)2a+3b2+12b+11A(a+2,3b+2),A(0,2b+1)3b2+9b10<F11013b0,A(a+1,2b+1)3b2+12b+5A(a,3b+3).

Proof

Consider the partial configuration P(m,n):=01mE>01n0. The configuration after two steps is 01m10A>1n+10. We note the following shift rule: A>1ss1sA> As a result, we get 01m101n+1A>0 after n+1 steps. Advancing two steps produces 01m101n+2<C0. A second shift rule is useful here: 1s<Cs<C1s This allows us to reach 01m10<C1n+20 in n+2 steps. Moving five more steps gets us to 01m2E>01n+30, which is the same configuration as P(m2,n+3). Accounting for the head movement creates the condition that m4. In summary: P(m,n)2n+12P(m2,n+3) if m4. With A(a,b) we have P(b,0). As a result, we can apply this rule 12b1 times (assuming b4), which creates two possible scenarios:

  1. If b0 (mod2), then in i=0(b/2)2(2×3i+12)=34b2+32b6 steps we arrive at P(2,32b3). The matching complete configuration is 01a011E>01(3b)/230. After 3b+4 steps this is 01a<C001(3b)/20, which then leads to 0<C1a001(3b)/20 in a steps. After five more steps, we reach 01E>1a+2001(3b)/20, from which another shift rule must be applied:E>1ss1sE>Doing so allows us to get the configuration 01a+3E>001(3b)/20 in a+2 steps. In six steps we have 01a+2011E>1(3b)/20, so we use the shift rule again, ending at 01a+201(3b)/2+2E>0, equal to A(a+2,32b+2), 32b steps later. This gives a total of 2a+34b2+6b+11 steps.
  2. If b1 (mod2), then in 34b2274 steps we arrive at P(3,3b92). The matching complete configuration is 01a0111E>01(3b9)/20. After 3b+2 steps this becomes 01a<F1101(3b3)/20. If a=0 then we have reached the undefined F0 transition with a total of 34b2+3b194 steps. Otherwise, continuing for six steps gives us 01a10111E>1(3b3)/20. We conclude with the configuration 01a101(3b+3)/2E>0, equal to A(a1,3b+32), in 3b32 steps. This gives a total of 34b2+92b14 steps.

The information above can be summarized as A(a,b){A(a+2,32b+2)if b2,b0(mod2);0<F1101(3b3)/20if b3,b1(mod2), and a=0;A(a1,3b+32)if b3,b1(mod2), and a>0. Substituting b2b for the first case and b2b+1 for the other two yields the final result.

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

These rules can be modified to use the function H(n)=3n2, or the Hydra function, which strengthens Antihydra's similarities to Hydra.

Trajectory

Path of parity of repeated applications of Hydra map for Antihydra.

Starting from a blank tape, Antihydra reaches A(0,4) in 11 steps and then the rules are repeatedly applied. So far, Antihydra has been simulated to 238 rule steps,[4] at which point a exceeds 237. Here are the first few: A(0,4)47A(2,8)111A(4,14)250A(6,23)500A(5,36)1209A(7,56)2713A(9,86) The trajectory of a values resembles a random walk in which the walker can only move in step sizes +2 or -1 with equal probability, starting at position 0. If P(n) is the probability that the walker will reach position -1 from position n, then it can be seen that P(n)=12P(n1)+12P(n+2). Solutions to this recurrence relation come in the form P(n)=c0(512)n+c1+c2(1+52)n, which after applying the appropriate boundary conditions reduces to P(n)=(512)n+1. This means that if the walker were to get to the position of the current a value, then the probability of it ever reaching position -1 is less than (512)2372.884×1028723042565. This combined with the fact that the expected position of the walker after k steps is 12k strongly suggests Antihydra probviously runs indefinitely.

Code

The following Python program implements the abstracted behavior of the Antihydra. Proving whether it halts or not would also solve the Antihydra problem:

# Current value of the iterated Hydra function starting with initial value 8 (the values do not overflow)
h = 8
# (Collatz-like) condition counter that keeps track of how many odd and even numbers have been encountered
c = 0
# If c equals -1 there have been (strictly) more than twice as many odd as even numbers and the program halts
while c != -1:
    # If h is even, add 2 to c so even numbers count twice
    if h % 2 == 0:
        c += 2
    else:
        c -= 1
    # Add the current hydra value divided by two (integer division, rounding down) to itself (Hydra function)
    # Note that integer division by 2 is equivalent to one bit shift to the right (h >> 1)
    h += h//2

The variable values of this iteration have been put into the On-Line Encyclopedia of Integer Sequences (OEIS):

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. Discord conversation where the machine was named
  2. DUBICKAS A. ON INTEGER SEQUENCES GENERATED BY LINEAR MAPS. Glasgow Mathematical Journal. 2009;51(2):243-252. doi:10.1017/S0017089508004655
  3. S. Ligocki, "BB(6) is Hard (Antihydra)" (2024). Accessed 22 July 2024.
  4. https://discord.com/channels/960643023006490684/1026577255754903572/1271528180246773883