User blog:Hyp cos/R function II

R function II is the second version of R function. It's not an extension of original R function. Here I make it more simple, but the strength remains the same.

Main process
Scan and apply rules. Case A1, A2, A3, B1 and B2 are terminal, but A4, B3 and C are not. After you apply a terminal rule, you'll return here, then you can choose any R to start scanning.

Scanning starts at the R symbol. Scan from left to right. There're 3 kinds of things we scan - 0, non-0 numbers and braces not a separator. Before scanning, set s = 1, and save the original brace to A1 (that's for case A3).
 * Case A: If there's a 0,
 * Case A1: If nothing is after it(or an R symbol immediately after it, this also mark the end), then apply \(nR0=10^n\). And return.
 * Case A2: If a simple rbrace (no +m's) is immediately after it, that means the brace is equvalent to {0}. So change it into number 1. And return.
 * Case A3: If an rbrace with +m's is immediately after it, that means the whole brace is the standard m-separator \(\{0^{+m}\}\).
 * Let Ss = \(\{0^{+m}\}\), set t = s
 * Repeat this:
 * Subtract t by 1
 * Let St be the brace such that "nested level of St = nested level of St+1 - 1" and "St+1 is inside St"
 * If t = 1, then break the repeating, or else continue repeating.
 * Set k = m, s(m) = s, B(m) = \(\{0^{+(m-1)}\}\), string X(m) = \(\{0\) and Y(m) = \(1^{+m-1}\}\).
 * Repeat this:
 * Subtract k by 1
 * Set s(k) = s(k+1)
 * Repeat this:
 * Subtract s(k) by 1
 * If level of As(k) < level of As(k+1), then break the repeating, or else continue repeating.
 * If level of As(k) < level of B(k+1), then let string P and Q be such that A1 = P As(k)+1 Q, then change the original brace A1 into P X(k+1) As(k)+1 Y(k+1) Q, and return. Or else -
 * If k = 0, then break the repeating, or else -
 * Let string X(k) and Y'(k) be such that Ss(k) = X(k) Ss(k+1) 1 Y'(k), set Y(k) = 1 Y'(k) and set B(k) = X(k) Y'(k).
 * Let string P and Q be such that Ss(0) = P Ss(1) Q, then apply Ss(0) = P P ... P P Q Q ... Q Q with n P's and n Q's, and return.
 * Case A4: Otherwise, continue scanning to right.


 * Case B: If there's a non-0 number,
 * Case B1: If R is immediately before it, then apply \(nRa+1\odot=nRa\odot Ra\odot\cdots Ra\odot\) with n \(Ra\odot\)'s. And return.
 * Case B2: If lbrace is immediately before it, then apply \(\{a+1\odot\}=\{a\odot\}0\{a\odot\}0\cdots0\{a\odot\}\) with n \(\{a\odot\}\)'s (here n is the base number). And return.
 * Case B3: If a separator is immediately before it, then apply \(\{\odot\}a+1=\{\odot\}1\{\odot\}a\), add s by 1 then set As = \(\{\odot\}\), then scan on the first \(\{\odot\}\).

The \(\odot\) can be any string or empty.
 * Case C: If there's a brace not separator, then continue scanning inside it.

Levels
First, we see the whole string after the "R" as an invisible brace here and it has the lowest level (and it cannot appear in other places), 1 has the second lowest level, {0} has the third lowest level. We can compare the level of A and B as follows:
 * Use subrule on A and B until the subrule cannot apply any more.
 * Let \(A=\{A_I^{+a}\}\) and \(B=\{B_I^{+b}\}\)
 * If a>b then A>B on level; If a {BM}, then A>B ; if {AM} < {BM}, then A {BM}, then A>B ; if the amount of {AM} < {BM}, then A {B+}, then A>B ; if {A+} < {B+}, then A {B-}, then A>B ; if {A-} < {B-}, then A<B ; if {A-}={B-}, then A=B.