The definitions of the hyperoperation sequence can naturally be transposed to
term rewriting systems (TRS).
TRS based on definition sub 1.1 The basic definition of the hyperoperation sequence corresponds with the reduction rules : \begin{array}{lll} \text{(r1)} & H(0,a,b) & \rightarrow & S(b) \\ \text{(r2)} & H(S(0),a,0) & \rightarrow & a \\ \text{(r3)} & H(S(S(0)),a,0) & \rightarrow & 0 \\ \text{(r4)} & H(S(S(S(n))),a,0) & \rightarrow & S(0) \\ \text{(r5)} & H(S(n),a,S(b)) & \rightarrow & H(n,a,H(S(n),a,b)) \end{array} To compute H_{n}(a, b) one can use a
stack, which initially contains the elements \langle n,a,b \rangle. Then, repeatedly until no longer possible, three elements are popped and replaced according to the rules : \begin{array}{lllllllll} \text{(r1)} & 0 &,& a &,& b & \rightarrow & (b+1) \\ \text{(r2)} & 1 &,& a &,& 0 & \rightarrow & a \\ \text{(r3)} & 2 &,& a &,& 0 & \rightarrow & 0 \\ \text{(r4)} & (n+3) &,& a &,& 0 & \rightarrow & 1 \\ \text{(r5)} & (n+1) &,& a &,& (b+1) & \rightarrow & n &,& a &,& (n+1) &,& a &,& b \end{array} Schematically, starting from \langle n,a,b \rangle:
WHILE stackLength <> 1 {
POP 3 elements;
PUSH 1 or 5 elements according to the rules r1, r2, r3, r4, r5; }
Example Compute H_2(2,2) \rightarrow_{*} 4. The reduction sequence is When implemented using a stack, on input \langle 2,2,2 \rangle
TRS based on definition sub 1.2 The definition using iteration leads to a different set of reduction rules : \begin{array}{lll} \text{(r6)} & H(S(0),0,a,b) & \rightarrow & S(b) \\ \text{(r7)} & H(S(0),S(0),a,0) & \rightarrow & a \\ \text{(r8)} & H(S(0),S(S(0)),a,0) & \rightarrow & 0 \\ \text{(r9)} & H(S(0),S(S(S(n))),a,0) & \rightarrow & S(0) \\ \text{(r10)} & H(S(0),S(n),a,S(b)) & \rightarrow & H(S(b),n,a,H(S(0),S(n),a,0)) \\ \text{(r11)} & H(S(S(x)),n,a,b) & \rightarrow & H(S(0),n,a,H(S(x),n,a,b)) \end{array} As iteration is
associative, instead of rule r11 one can define : \begin{array}{lll} \text{(r12)} & H(S(S(x)),n,a,b) & \rightarrow & H(S(x),n,a,H(S(0),n,a,b)) \end{array} Like in the previous section the computation of H_n(a,b) = H^1_n(a,b) can be implemented using a stack. Initially the stack contains the four elements \langle 1,n,a,b \rangle. Then, until termination, four elements are popped and replaced according to the rules : \begin{array}{lllllllll} \text{(r6)} & 1 &, 0 &, a &, b & \rightarrow & (b+1) \\ \text{(r7)} & 1 &, 1 &, a &, 0 & \rightarrow & a \\ \text{(r8)} & 1 &, 2 &, a &, 0 & \rightarrow & 0 \\ \text{(r9)} & 1 &, (n+3) &, a &, 0 & \rightarrow & 1 \\ \text{(r10)} & 1 &, (n+1) &, a &, (b+1) & \rightarrow & (b+1) &, n &, a &, 1 &, (n+1) &, a &, 0 \\ \text{(r11)} & (x+2) &, n &, a &, b & \rightarrow & 1 &, n &, a &, (x+1) &, n &, a &, b \end{array} Schematically, starting from \langle 1,n,a,b \rangle:
WHILE stackLength <> 1 {
POP 4 elements;
PUSH 1 or 7 elements according to the rules r6, r7, r8, r9, r10, r11; }
Example Compute H_3(0,3) \rightarrow_{*} 0. On input \langle 1,3,0,3 \rangle the successive stack configurations are :\begin{align} & \underline{1,3,0,3} \rightarrow_{r10} 3,2,0,\underline{1,3,0,0} \rightarrow_{r9} \underline{3,2,0,1} \rightarrow_{r11} 1,2,0,\underline{2,2,0,1} \rightarrow_{r11} 1,2,0,1,2,0,\underline{1,2,0,1} \\ & \rightarrow_{r10} 1,2,0,1,2,0,1,1,0,\underline{1,2,0,0} \rightarrow_{r8} 1,2,0,1,2,0,\underline{1,1,0,0} \rightarrow_{r7} 1,2,0,\underline{1,2,0,0} \rightarrow_{r8} \underline{1,2,0,0} \rightarrow_{r8} 0. \end{align} The corresponding equalities are :\begin{align} & H_3(0,3) = H^3_2(0,H_3(0,0)) = H^3_2(0,1) = H_2(0,H^2_2(0,1)) = H_2(0,H_2(0,H_2(0,1)) \\ & = H_2(0,H_2(0,H_1(0,H_2(0,0)))) = H_2(0,H_2(0,H_1(0,0))) = H_2(0,H_2(0,0)) = H_2(0,0) = 0. \end{align} When reduction rule r11 is replaced by rule r12, the stack is transformed according to :\begin{array}{lllllllll} \text{(r12)} & (x+2) &, n &, a &, b & \rightarrow & (x+1) &, n &, a &, 1 &, n &, a &, b \end{array} The successive stack configurations will then be :\begin{align} & \underline{1,3,0,3} \rightarrow_{r10} 3,2,0,\underline{1,3,0,0} \rightarrow_{r9} \underline{3,2,0,1} \rightarrow_{r12} 2,2,0,\underline{1,2,0,1} \rightarrow_{r10} 2,2,0,1,1,0,\underline{1,2,0,0} \\ & \rightarrow_{r8} 2,2,0,\underline{1,1,0,0} \rightarrow_{r7} \underline{2,2,0,0} \rightarrow_{r12} 1,2,0,\underline{1,2,0,0} \rightarrow_{r8} \underline{1,2,0,0} \rightarrow_{r8} 0 \end{align} The corresponding equalities are :\begin{align} & H_3(0,3) = H^3_2(0,H_3(0,0)) = H^3_2(0,1) = H^2_2(0,H_2(0,1)) = H^2_2(0,H_1(0,H_2(0,0))) \\ & = H^2_2(0,H_1(0,0)) = H^2_2(0,0) = H_2(0,H_2(0,0)) = H_2(0,0) = 0 \end{align}
Remarks • H_3(0,3) = 0 is a special case, see above. • The computation of H_{n}(a,b) according to the rules {r6 - r10, r11} is heavily recursive. The culprit is the order in which iteration is executed: H^{n}(a,b) = H(a, H^{n-1}(a,b)). The first H disappears only after the whole sequence is unfolded. For instance, H_4(2,4) converges to 65536 in 2863311767 steps, the maximum depth of recursion is 65534. • The computation according to the rules {r6 - r10, r12} is more efficient in that respect. The implementation of iteration H^{n}(a,b) as H^{n-1}(a, H(a,b)) mimics the repeated execution of a procedure H. The depth of recursion, (n+1), matches the loop nesting. formalized this correspondence. The computation of H_4(2,4) according to the rules {r6-r10, r12} also needs 2863311767 steps to converge on 65536, but the maximum depth of recursion is only 5, as tetration is the 5th operator in the hyperoperation sequence. • The considerations above concern the recursion depth only. Either way of iterating leads to the same number of reduction steps, involving the same rules (when the rules r11 and r12 are considered "the same"). As the example shows the reduction of H_3(0,3) converges in 9 steps: 1 X r7, 3 X r8, 1 X r9, 2 X r10, 2 X r11/r12. The modus iterandi only affects the order in which the reduction rules are applied. ==See also==