User:Hyp cos/Dimensional Array Notation

Dimensional array notation (DAN) is the 4th part of R function.

Up to a flatten brace
Now I bring you a new thing - {0,,1} - called a flatten brace. The double comma here is a separator string. Actually, in R function only separator string can separate entries, but separator itself cannot. Notice that a separator string can contain only 1 separator, such as the normal comma separator string.

When {0,,1} appears immediately inside an array that doesn't contain double-comma separator strings, it will be flatten into a string: 0,1,1,...,1,1 with a 0 and n 1's, where n is the base number. If there isn't such an array, add one to immediately enclose it (here we use encloser { and }). e.g. 4R{0,,1}=4R=4R{0,1,1,1,1}.

But a problem is coming now. Support we solve this thing: 3R{0,1}{0,,1}, first we get 3R=3R=3R, but it'll be reduce to and then expand in the same way. This time it'll cause forever recusion and won't be solved. The main cause is that the brace has not only 1 entry - actually it has "many" entries because the {0,,1} inside it will finally flatten to many entries. What's more, in growth rate and {0,0,0,0,{0,,1}} are almost the same. If we know that is approximately {{0,1},{0,,1}} or {{0,1},0,0,0,0,{0,,1}} things won't go wrong.

To make it clear, let {0,,1} has a "brace rank"=1, and linear arrays have "brace rank"=0. And linear arrays containing more {0,,1}'s immediately have higher level than ones containing less {0,,1}'s immediately because they have more entries actually. e.g. has higher level than {1,1,0,1,{0,0,3,{0,,1}},,6,{0,,1}}.

So 3R{0,1}{0,,1}=(S2)3R=(S2 again)3R=(R5)3R=... that's OK.

Then {0,2}{0,,1}, {0,0,1}{0,,1}, {0,,1}, {0,,1}, {0,,1}, {0,1{0,,1}}, {0,0,1{0,,1}}, {0,,1}{0,,1},... and {1,,1} expands to {0,,1}{0,,1}...{0,,1} with n {0,,1}'s by Rule 4.

Next row
(n is the base number.) Imagine this: we use {A,,1} where A is a string of entries and single-comma, e.g. {0,1,0,{2,1}{3,3,,1},{0},,1}. And the double-comma separator string separates entries into rows. In {A,,1} the A is the first row and the 1 is the second row. So {A,,0} is {A} (remove 0's by Subrule 1, and I'll add this soon) and has a "brace rank"=0. {A,,1} has a "brace rank"=1. Then {0,,2} is flatten into 0,1,1...,1 with a 0 and n 1's when it appears immediately inside an {A,,1}, e.g. 5R{{0,,2}{0,,2},,1}=5R{0,1,1,1,1,1{0,,2},,1}. Then {A,,2}, {0,,3}, {A,,3}, {A,,k} and so on. They all have "brace rank"=1.

e.g. 3R{{0,1},,2}=3R=3R=3R=3R =3R=3R{,0,1,1,,1}=...

Then we have {A,,{0}}, {A,,{A}}, {A,,{A,,1}}, {A,,{A,,k}}, {A,,{A,,{A}}},...

Planar arrays
We can have more entries in the 2nd row, just using R5 and S2. e.g. 3R{0,,0,1}=3R{0,,{0,,0,1},0}=3R{0,,{0,,{0,,0,0},0},0}=3R{0,,{0,,{0}}}=3R{0,,{0,,3}}=3R{0,,{{0,,3},,2}}=3R{0,,{0,1,1,1,,2}}=... And {0,,1,1}, {0,,0,2}, {0,,0,0,1}, {0,,0,0,0,1},...

Then we enter the third row. {0,,0,,1} is flatten into 0,1,1...,1 (n 1's) in {0,, ____ }, and {0,,1,,1} flatten in { ____ ,,0,,1}, {0,,0,,2} flatten in {0,, ____ ,,1}, ...

Then the 4th and more row. {0,,0,,0,,1} is flatten into 0,1,1...,1 (n 1's) in {0,,0,, ____ }, {0,,0,,1,,1} flatten in {0,, ____ ,,0,,1}, {0,,0,,0,,2} flatten in {0,,0,, ____ ,,1} and {0,,0,,0,,0,,3} flatten in {0,,0,,0,, ____ ,,2}.

To make "where the flatten braces work" clear, we have some definitions now.

Something
(Re-define entries, separators and separator strings) A separator string is a string made up of only separators (can be only one or more). A brace is called array if there're separator string immediately inside it.

Single-comma separate entries, and double-comma separate rows.

If we delete a whole entry of an array and divide it into 2 parts from the deleted entry, they're called a pair of entry encloser. If we delete a whole row of an array and divide it into 2 parts from the deleted entry, they're called a pair of row encloser.

For example, to solve {0,,0,,0,,3} we should find a pair of row encloser {0,,0,, and ,,2} immediately enclosing it, then {0,,0,,{0,,0,,0,,3},,2}={0,,0,,0,1,1,...,1,,2} with n 1's.

Higher dimensional arrays
Now think of this: {0,,,1} (with a new separator string - the truble comma) is a flatten brace that can be flatten to 0,,1,,1...,,1,,1 with n 1's in { ____ ,,,0} arrays. And the truble comma separate planes. In {0,,,1} the 0 is in the first plane and the 1 is in the second plane. Further, 3R{0,1,,,1}=3R{{0,1,,,1},0,,,1}=3R{{{0,0,,,1},0,,,1},0,,,1}=3R{{{0,,,1},,,1},,,1}=3R{{{{0,,,1},,,0},,,1},,,1}=3R{{{0,,1,,1,,1,,,0},,,1},,,1}=3R{{{0,,1,,1,,1},,,1},,,1}=3R{{{{0,,1,,1,,1},,0,,1,,1},,,1},,,1}=3R{{{0,1,1,1,,0,,1,,1},,,1},,,1}=... 3R{0,,1,,,1}=3R{{0,,1,,,1},,0,,,1}=3R{0,1,1,1,,0,,,1}=3R{0,1,1,1,,,1}=... and 3R{0,,,2}=3R{{0,,,2},,,1}=3R{0,,1,,1,,1,,,1}=..., 3R{0,,,0,,,1}=3R{0,,,{0,,,0,,,1},,,0}=3R{0,,,0,,1,,1,,1}=...

Then we reach the limit of 3-dimensional arrays and start to fill numbers in the next realm. And further, we have any amount of commas that make a separator string.

A single-comma separates entries (notice again the comma itself cannot separate anything, it works only inside separator strings), a double-comma separates rows and a truble-comma separate planes. Generally a separator string made up of k commas separates (k-1)-dimensional blocks.

Array with an entry deleted and divided to 2 parts from here is an entry encloser, array with a row deleted and divided to 2 parts from here is a row encloser, and array with a plane deleted and divided to 2 parts from here is a plane encloser. Generally an array with a k-dimensional block deleted and divided to 2 parts from here is a k-dimensional encloser.

Brace rank
But we still have some problem here. {0,1}{0,,,1} will cause endless recusion and never be solved. If we make this change, things won't go wrong.

Let's give all braces this property: brace rank ("BR" for short). Linear arrays all have BR=0, and planar arrays can be flatten to strings immediately contain single-commas in linear arrays and have BR=1. So I define:

If a brace has brace b(1), b(2), ..., b(k) immediately and separator string s(1), s(2), ... s(m) immediately inside it, and each s(i) has c(i) commas, then its BR=max{BR(b(1)),BR(b(2)),...,BR(b(k)),c(1),c(2),...,c(m),1}-1.

And, a BR=1 brace can "release" any amount of ,0's before it when compared on level, a BR=2 brace can "release" any amount of ,,0's before it when compared on level, and a BR=k brace can "release" any amount of ,,...(k commas)...,,0's before it when compared on level. That's it, and everything goes well now.

Formal Definition
So we come to definitions. This is the last definition in R function mainly using pattern test.


 * Rule 1: \(nR0=10^n\)         - base rule


 * Rule 2: \(nRa+1\odot=nRa\odot Ra\odot...Ra\odot\) with n R's


 * Rule 3: \(nR\oslash\{0\}\odot=nR\oslash n\odot\)


 * Rule 4: \(nR\oslash\{a+1\odot_1\}\odot_2=nR\oslash\{a\odot_1\}\{a\odot_1\}...\{a\odot_1\}\odot_2\) with n \(\{a\odot_1\}\)'s


 * Subrule 1: 0 is default, so 0's immediately before a brace can be removed, and the same to 0's at the end of an array and 0's immediately before a lower separator string and immediately after a higher separator string. i.e. 0{={ and \(\diamond 0\}=\}\), and \(\diamond_10\diamond_2=\diamond_2\) if \(\diamond_1\) is lower-level than \(\diamond_2\)


 * Rule 5: For \(nR\oslash_2\{\oslash_10,a+1\odot_1\}\odot_2\), find the nearest entry encloser \(\{\oslash_1\) and \(,a\odot_1\}\) enclosing the \(\{\oslash_10,a+1\odot_1\}\), and this entry encloser has lower level than the \(\{\oslash_10,a+1\odot_1\}\), (you can use Subrule 2 now), then \(nR\oslash_2\{\oslash_1\oslash_3\{\oslash_10,a+1\odot_1\}\odot_3,a\odot_1\}\odot_2=\)   \(nR\oslash_2\{\oslash_1\oslash_3\{\oslash_1\oslash_3...\{\oslash_1\oslash_30\odot_3,a\odot_1\}...\odot_3,a\odot_1\}\odot_3,a\odot_1\}\odot_2\) with n \(\{\oslash_1\oslash_3\)'s and n \(\odot_3,a\odot_1\}\)'s.


 * Subrule 2: If you cannot find an entry encloser \(\{\oslash_1\) and \(,a\odot_1\}\) suit Rule 5, add one to immediately enclose the whole string after R.


 * Rule 6: For \(nR\oslash_2\{\oslash_10,\diamond a+1\odot_1\}\odot_2\), find the encloser \(\{\oslash_1\) and \(,\diamond a\odot_1\}\) immediately enclosing the \(\{\oslash_10,\diamond a+1\odot_1\}\), (you can use Subrule 3 now), then \(nR\oslash_2\{\oslash_1\oslash_3\{\oslash_10,\diamond a+1\odot_1\}\odot_3,\diamond a\odot_1\}\odot_2=\)  \(nR\oslash_2\{\oslash_1\oslash_30\diamond1\diamond1...\diamond1\odot_3,\diamond a\odot_1\}\odot_2\) with n \(\diamond1\)'s.


 * Subrule 3: If you cannot find an encloser \(\{\oslash_1\) and \(,\diamond a\odot_1\}\) suit Rule 6, add one to immediately enclose the entry where the \(\{\oslash_10,\diamond a+1\odot_1\}\) is.

Subrule 1 can apply any time, but subrule 2 applies only be called by Rule 5, subrule 3 applies only be called by Rule 6.