User:Hyp cos/Dropping hydra

Dropping hydra is a simplified variant of DAN or R function. It's a kind of hydra game, but with a more complex ruleset (still simpler than the rules in DAN or R function).

The notation is a 2-colored ordered rooted tree T, appending 2 positive integers as its "numeric arguments". In the notation T[x,y], black and white are used. To make this notation "valid", the distance between any black nodes and the root must be at least x.

Tree comparison
Similar to level comparison in DAN and R function, dropping hydra also need comparison.

First, the white root-only tree is less than all other trees, the black root-only tree (doesn't appear in the original notation, but can be generated in the comparison process) is greater than all other trees. To compare tree A and tree B, follow these steps.
 * 1) Let \(A_1,A_2\cdots,A_k\) are trees separated from A by deleting the root of A. \(B_1,B_2\cdots,B_l\) are trees separated from B by deleting the root of B.
 * 2) Let \(M(A)=\{i\in\{1,2\cdots,k\}|\forall j\in\{1,2\cdots,k\}(A_i\ge A_j)\}\), and \(M(B)=\{i\in\{1,2\cdots,l\}|\forall j\in\{1,2\cdots,l\}(B_i\ge B_j)\}\).
 * 3) If \(|M(A)|>|M(B)|\), then A > B; if \(|M(A)|<|M(B)|\), then A < B; if \(|M(A)|=|M(B)|\), follow these steps.
 * 4) Tree C is obtained by deleting all \(A_i\ (i\in M(A))\) from tree A. Tree D is obtained by deleting all \(B_i\ (i\in M(B))\) from tree B.
 * 5) If C > D, then A > B; if C < D, then A < B; if C = D, then A = B.

Ruleset
T[x,y] will result a positive integer according to these rules.
 * If T is a root-only tree, then T[x,y] = y+1.
 * If the rightmost leaf c of T is white (i.e. same as the root), and c has parent b, then
 * Tree T1 is obtained by deleting leaf c from T.
 * If b has parent a, then
 * The subtree of T1 rooted at a is \((A_1A_2\cdots A_kB)\), where B is the subtree of T1 rooted at b.
 * Tree T2 is obtained by change \((A_1A_2\cdotsA_kB)\) into \((A_1A_2\cdots A_kBB\cdots B)\) (with y B's) from T1.
 * T[x,y] = T2[x,y].
 * If b is the root of T1, then T[x,y] = T1[x,T1[x,...T1[x,T1[x,y]]...]] with y T1's.
 * If the rightmost leaf c of T is black (i.e. different from the root), then
 * Let node \(c_0=c\), \(c_{i+1}\) is the parent of \(c_i\), until the root \(c_r\).
 * Let tree \(C_i\) is the subtree of T rooted at \(c_i\).
 * Let \(j(0)=0\).
 * Repeat these steps x times, for n from 1 to x.
 * Let \(j(n)=\min\{i|C_ij(n-1)\}\).
 * If n > 1, then tree \(B_n\) is obtained by deleting \(C_{j(n-2)}\) from \(C_{j(n-1)}\).
 * If n > 1 and \(C_{j(n)}<B_n\), then
 * Let \(k=\max\{i|C_i<C_{j(n-2)}\land i<j(n)\}\).
 * Tree A is obtained by replacing \(C_{j(n-2)}\) by \(C_k\) from \(C_{j(n-1)}\).
 * Tree T1 is obtained by replacing \(C_k\) by A from T.
 * T[x,y] = T1[x,y].
 * Let tree \(S_0\) be the white root-only tree, \(S_{i+1}\) is obtained by replacing \(C_{j(x-1)}\) by \(S_i\) from \(C_{j(x)}\), until \(S_y\).
 * Tree T2 is obtained by replacing \(C_{j(x)}\) by \(S_y\) from T.
 * T[x,y] = T2[x,y].