User blog comment:Mh314159/Natural number recursion - first 4 rule sets/@comment-35470197-20191019143654

> Replace the zero with the entire expression

According to the explanation 2 of the comparison to the previous one, I guess that you intend that superscripts are solved as compositions when \(S\) consists of non-zero entries. However, if you intend to include superscripts into the entire expression when \(S\) includes a zero entry, you need to explicitly define the rule to solve superscripts.

It is because that the replacement rule refers to the formal expression with formal function symbols of the form \(A \langle S \rangle^m\), while usual composition is an actual function which is not a formal symbol. Therefore you need to clarify that the superscripts are portion of expressions and to add rules like \(A \langle S \rangle^0(x) = x\) and \(A \langle S \rangle^{m+1}(x) = A \langle S \rangle^m(A \langle S \rangle(x))\) for strings \(S\) of one or more non-zero entries.

For example, the current rule is ambiguous because \(A \langle 0,1 \rangle^2(x)\) has two meanings: \(A \langle 0,1 \rangle(A \langle 0,1 \rangle(x))\) and \(A \langle A \langle 1,0 \rangle^2(x),0 \rangle^2(x)\). If you overload usual conventions such as power and composition, you need to clarify the meanings.