User blog:Hyp cos/R function v2.0.1

I made some changes on R function II, and get this version. The strength still remains the same.

Syntax
Symbol { is called lbrace, with ASCII=123, LaTeX=\{ or \lbrace.

Symbol } is called rbrace, with ASCII=125, LaTeX=\} or \rbrace.

Symbol + is called plus, with ASCII=43.

The brace can be defined as follows: A separator is a brace with brace rank > 0.
 * String where "+m" is at the superscript position and m is a nonnegative integer is a brace. This m is called the brace rank of that brace.
 * String {A1A2...Ak+m} is a brace iff all the A1, A2, ..., Ak are brace. And its brace rank is m, too.

The standard form of R function is nRA1A2...Ak, where - And there're some shorthands:
 * n is a positive integer, here called "base number"
 * R is a symbol for the function
 * All the A1, A2, ..., Ak are braces but not separators. k=0 is allowed too, which means the string after R is empty.
 * The superscript "+0" can be omitted, and the superscript "+1" can be written as "+".
 * can be also written as a comma.

Main process
Scan and apply rules. Case A1, A2, D and E are terminal, but A3, B 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. Scan braces at the same nested level. Before scanning, set s = 0 (that's for case D). The \(\odot\) can be any string or empty.
 * Case A: If there's a {},
 * ​Case A1: If R is immediately before it, then apply \(nR\{\}\odot=(\cdots(nR\odot) R\odot\cdots) R\odot\) with n \(R\odot\)'s. And return.
 * Case A2: If an lbrace is immediately before it, then apply \(\{\{\}\odot\}=\{\odot\}\{\odot\}\cdots\{\odot\}\) with n \(\{\odot\}\)'s (here n is the base number). And return.
 * Case A3: If a separator is immediately before it, then apply \(\{\odot\}\{\}=\{\odot\}\{\}\{\odot\}\), add s by 1 then set As = \(\{\odot\}\), then scan inside the first \(\{\odot\}\).
 * Case B: If there's a brace neither a separator nor the {}, add s by 1 then set As to that brace, then continue scanning inside it.
 * ​Case C: If there's a separator, ignore it and continue scanning.
 * Case D: If there's no more braces you can scan, and you meet "+m}" with m > 0,
 * 1) Let brace Ss be such that the rbrace of the "+m}" is the rbrace of it, set t = s
 * 2) Repeat this:
 * 3) Subtract t by 1
 * 4) Let St be the brace such that "nested level of St = nested level of St+1 - 1" and "St+1 is inside St"
 * 5) If t = 1, then break the repeating, or else continue repeating.
 * 6) Set k = m, s(m) = s, B(m) =, string X(m) = "{" and Y(m) = "{}+(m-1)}".
 * 7) Repeat this:
 * 8) Subtract k by 1
 * 9) Set s(k) = s(k+1)
 * 10) Repeat this:
 * 11) Subtract s(k) by 1
 * 12) If level of As(k) < level of As(k+1), then break the repeating, or else continue repeating.
 * 13) 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 -
 * 14) If k = 0, then break the repeating, or else -
 * 15) Let string X(k) and Y'(k) be such that Ss(k) = X(k) Ss(k+1) {} Y'(k), set Y(k) = {} Y'(k) and set B(k) = X(k) Y'(k).
 * 16) 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 E: If there's nothing you can scan, and nothing is after you, change the whole expression into 2^n where n is the base number, and return.

Subrule
It's actually a property of the main process. But it's necessary when comparing levels.
 * 1) \(\{\odot_1\{\odot_2^{+a}\}^{+b}\}=\{\odot_1^{+b}\}\) where a>0
 * 2) AB = B where A and B are separator and level of A < level of B (this one is just an approximation)

Levels
First, {} has the lowest level, and others have higher 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.
 * If brace rank of A > brace rank of B then A>B on level; If brace rank of A < brace rank of B then 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.