Conventions
A, An, B, and C are 0 or [A0,A1,...,Ak] for some natural k.
X and Xn are empty or A0,A1,...,Ak for some natural k.
L and Ln are empty or A0,A1,...,Ak for some natural k.
n$A$B = (n$A)$B; $ is left-associative.
Strings in {} are always repeated n times.
Helper functions
T(A)
Define T(A) like so:
- T(0) = 0.
- T([0]) = 1.
-
Let A = [A0,X].
T(A) = T(A0).
P(A)
Define P(A) like so:
- P(0) is undefined.
- P([0]) = 1.
-
Otherwise, let A = [A0,X].
P(A) = [P(A0),X].
Definition
We start with n$A for some A, and natural n. This solves into the "result".
-
A = 0. Then, result is 10n.
-
Value of T(A)?
- 0: Jump to 3.
- 1: Result is 1 {$P(A)}.
-
Look at the first entry of A. Assume the array you are currently looking at is B.
Is the entry you are currently looking at 0?
-
Yes: Go to next entry
-
No: Value of T(B)?
- 0: Look at the first entry of B. Jump to 3.
- 1: Jump to 4.
-
Let C = [L,0,B,X], where C is the smallest array that B is contained in that is in A.
Then, replace C with [L, {[} 0 {,P(B),X]} ,P(B),X] in A. Call this new array A'.
The result is 1$A'.