Antihydra is the first BB(6)Cryptid to be identified. It operates by repeatedly applying the function , starting with . Determining whether this Turing machine halts requires solving the Collatz-like mathematical problem of whether there eventually exists a step at which has been applied to (strictly) more than twice as many odd as even numbers. Proving a result remains challenging due to the lack of an exploitable pattern in the sequence's parities, although probabilistic arguments based on random walks suggest Antihydra has a minuscule chance of halting.
Antihydra basically repeatedly modifies the integer ordered pair starting at , which is represented on the tape as consecutive s and consecutive s, separated by a single . It does this by "borrowing" a from the right side and, through a series of back-and-forth head movements, "moves" this toward the one separating and , two units at a time. As this happens, the head visits new cells on the right, which has the effect of there being about times as many s on the tape when the distance has been closed. After that, and are updated. If the previous value of was even, then becomes . Otherwise, becomes or Antihydra halts if was 0.
Let , and and be integer sequences defined below:
Antihydra halts if and only if there exists any number for which .
Attributions
Antihydra and its pseudo-random behaviour were reported 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. The "anti-" in the name is due to the fact that the roles of even and odd numbers are switched compared to the behavior of Hydra [1].
Consider the partial configuration . The configuration after two steps is . We note the following shift rule:
As a result, we get after steps. Advancing two steps produces . A second shift rule is useful here:
This allows us to reach in steps. Moving five more steps gets us to , which is the same configuration as . Accounting for the head movement creates the condition that . In summary:
With we have . As a result, we can apply this rule times (assuming ), which creates two possible scenarios:
If , then in steps we arrive at . The matching complete configuration is . After steps this is , which then leads to in steps. After five more steps, we reach , from which another shift rule must be applied:
Doing so allows us to get the configuration in steps. In six steps we have , so we use the shift rule again, ending at , equal to , steps later. This gives a total of steps.
If , then in steps we arrive at . The matching complete configuration is . After steps this becomes . If then we have reached the undefined F0 transition with a total of steps. Otherwise, continuing for six steps gives us . We conclude with the configuration , equal to , in steps. This gives a total of steps.
The information above can be summarized as
Substituting for the first case and for the other two yields the final result.
The page Hydra function shows how these rules can be simplified to use that function instead, along with Hydra.
Trajectory
11 steps are required to enter the configuration before the rules are repeatedly applied. So far, Antihydra has been simulated to rule steps, at which point . Here are the first few:
A heuristic nonhalting argument
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 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 is the probability that the walker will reach position -1 from position , then it can be seen that . Solutions to this recurrence relation come in the form , which after applying the appropriate boundary conditions reduces to . This means that if the walker were to get to position 1073720884 then the probability of it ever reaching position -1 is . This combined with the fact that the expected position of the walker after steps is strongly suggests Antihydra probviously runs indefinitely.
To view an animation of the blank tape becoming in 419 steps, click here.
Code
The following Python programs implement the abstracted behavior of the Antihydra. Proving whether they halt or not would also solve the Antihydra problem:
# Keeps track of how many odd and even numbers have been encountereda=0# The iterated valueb=8# If a < 0 there have been (strictly) more than twice as many odd as even numbers and the program haltswhilea!=-1:# If b is even, add 2 to a so even numbers count twiceifb%2==0:a+=2else:a-=1# Add the number divided by two (integer division, rounding down) to itselfb+=b//2
Integer division by two is equivalent to shifting the binary representation of the number one place to the right (discarding the least significant bit).
Codegolfed versions by mxdys:
a,b=0,8whilea!=-1:a+=2-b%2*3b+=b>>1
even shorter, here the order of the two sequential operations (shifted addition, even/odd counting) is reversed: