Index

# To B or not...

Explains the essence of number expressions a,b from scratch. People start to pay attention here!

# Structures by RepExp

The highest principle for creating algorithms is frugality – to maximize the effect (function speed, Bigger numbers) with minimal means.

Let Btrix count down variables fully. Except for the initial entry a at the left, we allow a void (number 0) in all positions. This rules out multiple mixed separators, keeping our algorithm simple.

The governing system of Btrix interprets all kinds of general recursive structures numerically. But she has a character rewriter (our Abacus machine) under the hood. Our matrix function, superficially dealing just with numbers, is living in a programmer's world.
Ideally we should always point out the way a new jump to a higher structure is represented by primitive rewrite steps inside a word (string).


From traditional Regular Expressions (RegExp) we may use the quantifiers ? or {0,1} for none or one occurrence, in context {k>0} or {1,} for one or more, and {k≥0} or {0,} for any number. In general {k} for exactly k copies, and {m,n} for at least m and at most n copies of a preceding word: a single sign x or (X) bracketed string.

Our new RepExp meta-notation to select and repeat parts of an expression in rules, is quite practical and concise. It applies a mathematical dot notation :k: to word repetition, and usually regular expressions to repeat {k} single characters. Words can run from either side or from single dots . placed at the beginning of the :left or right: repeated words.
Show a few examples of RepExp.

x.. :3 = x.. x:3 = x{3} = xxx
F(..m..) :3: = F(F(F(m)))
A.n1,..Z :2  = A(n1,){2}Z = An1,n1,Z  
aaaa..b..b.ci.. aa:0 2: :4 = aabbbc0c1c2c3 
A.Li..,{5}..Rj.Z :3: = AL0L1L2,,,,,R2R1R0Z 

The word to Rep(eat) from left to right in the Exp(ression) runs up to the double dot marks .. and we can connect this to a right word repeated inwards (to the left) by a second pair/trio of dots. The quantifier in this tandem repetition :k: counts how many word copies are placed on each side.

# Conventions

Our variables are greedy for number units, naturally for the sign 1. So when a variable n sits next to a wildcard X, the proper substitute of X won't have a number expressed on that end.

n = 1.. :n0 = 1{0,}  (RegExp unlimited)
Xn ≠ Y1n  (greedy variable n)
_n__n1Y  (underscore wildcard for passive parts)

We use the = sign when two expressions are equal, and when the right (decoded - output) expression follows from the left (encoded - input) in the evaluation train to natural number. Expressions are not equal when one side cannot be reduced to the other.
We use the sign for the equivalence of expressions in different formats, or to justify a substitution (exchange) of substrings within an expression.

Our Btrix matrix system applies two conventions: one at the beginning and one at the end of time (of the evaluation of an expression to Big number).

The initial convention is to write the matrix in a simple format – without function title and brackets – which is sufficient because the evaluation rules of Btrix won't nest an expression in place of a variable (so common in other systems).
The final convention is the identity function that reads the number result out. It's a string of 1.. (from here on your dedicated Abacus could translate it to the preferred format ;-)

Because of our initial convention we feel fine that Btrix(a) is defined now. But because our first rule, the rule of choice, chooses to discard a we might as well have left it undefined.

# Choice rules

Our system starts with the simplest of rules. Addition happens of itself when placing two variables ab holding number units 1.. next to each other. There's no use adding a rule to arrange for that, as this could only mess things up.
It is when you want to keep here what you are putting there (and try to repeat that), that complexity arises. A life lesson.

Anyway, more fundamental than any arithmetical operation is selection, the operation of choice. This rule performs the last act of Btrix to evaluate an expression to a (natural) number.
First the initial case where b=0 reduces to 0 and then the standard rule of choice. This rule is extended for when trailing commas have been kept, and must now be discarded.

To drop or keep trailing structures is a convention, with no significant impact on the resulting Big numbers. This was a discovery by Jonathan Bowers, an insight he had in array structures.
Bowers wanted to count off the pilot iterator and just leave the residual ,1 be, even if it is never uploaded again. Rule 1.2 can be extended for this purpose, ignoring the tail separator structures until the very last evaluation, when no iterator entry remains in $ on the right.

In contrast Bird uses a comparison system to determine whether left separators ,[L]1,[R] are smaller than right, and therefore are trailing and consequently dropped off.

Rule 2. is optional. If you work it out there's no need to remove trailing separators. You can either let them be until the very end, reuse some of them, or optionally clean up during evaluation.

# Adding by abacus

To add two numbers ab is pretty straightforward. But how do you copy a number to add it, when you can only distribute a few characters at once? Inside 4+2 for example?

1111,11,1 = ,1,,1111,11,
          = ,11,,111,11, == ,1111,,1,11,  (count down)
          =  ,1111,1,11,  (prefix , and insert 1, to split base)
          = ,111,11,111, == ,1,1111,11111,  (doubling)
          = 1111,111111,  (carry 1 over and drop prefix)

Prefix null  , parameters for special machine modes!
All colours are there to help your human eyes.
Next example 3+0 of adding to zero, coded (with , for 0) in binary.

111,,1 = ,1,,111,,
       = ,11,,11,, = ,111,,1,,
       =  ,111,1,,
       = ,11,11,1, = ,1,111,11,
       = 111,111,

Scheme for adding by doubling in Abacus, with wildcards W, where a>0 is natural.

Word repetition is our main tool in the definition of rules. Here we add numbers on a primitive level – doubling by copy 1 and substitute 1,1 or ,1 in second place.
Check the initial case.

1,,1 = ,1,,1,,  (decrement 1*1+0 to addition mode)
     =  ,1,1,,  (put 1+0 in doubling mode)
     = 1,1,  (finish = 1 in matrix mode)
     = 1,1  (drop trailing separator)  = 1  (choice)

Only a pre-mathematical machine writes null mode , prefixes. We have to do without the natural void   (try unit 0' instead) in the first entry. At the anchor position a0 is mandatory.
The Abacus machine abides, with plenty of shekels to spend in the red. It can resort to lengthy prefixes ,{u}Wi..,{u1}a,Z :v where in W all ,{t<u} to boil our rewrite rules down to the simplest of commands. [it is so vicious :!]


by Giga Gerard
mathematical artist

People can read this article plain or choose the hard & fast & open version.