Michael Orwin
London
Registered: Oct 2007
Posts: 1 
sequences of instructions to copy and kill terms
I would like to know if this has already been invented, as I've described it in a forum for science enthusiasts and I would not like to steal credit.
I've got a system where terms consist of instructions to copy and instructions to kill, and sequences consist of terms separated by commas. When the leftmost term is executed, the instructions in it act on the remaining terms. Some sequences can mimic simple arithmetic when repeatedly executed, for instance producing the Fibonacci sequence.
Here I explain:
1) how I label terms
2) how 'copy into' a term works
3) how 'copy then make new term' works
4) indexing
5) an example (the Fibonacci sequence)
LABELLING TERMS
I label the terms: t1, t0, t1, t2 ... with t1 being the leftmost term, and it is always t1 which is executed.
COPY INTO
On execution, an 'i' in t1 is replaced by t0. For instance if you execute:
ii,iii
each 'i' in t1 is replaced by t0 (which is iii) giving the result iiiiii. I usually write this as:
ii,iii
iiiiii
and the multiplication 3 x 2 x 4 can be represented as:
iii,ii,iiii
iiiiii,iiii
iiiiiiiiiiiiiiiiiiiiiiii
It is obvious that with this instruction alone you get multiplication and nothing more.
The instruction 'n' also copies, but with this difference: if an 'n' does not have a comma immediately on it's right, you put a comma after the copy (of term t0) it produces. For instance:
nnn,ii
becomes: ii,ii,ii
because the first two 'n's each get replaced by 'ii,' but the third 'n' does not, as there is a comma immediately on its right.
If you work it out completely it's like this:
nnn,ii
ii,ii,ii
iiii,ii
iiiiiiii
and it's worked out 2 cubed which is 8. And you could start with nn,iiii and it would give you 4 squared which is 16. If you prefer you can start like this:
iii,n,ii
where you just have one 'n' in the middle, so you are only using 'i's to represent numbers. When you execute that it becomes nnn,ii which I've already described.
However, taking powers fails for a power equal to zero, which should give 1 (in this system, 'i') but instead you get nothing. This is easier to see if I use {} to represent nothing.
{},n,iiiii
{},iiiii
{}
INDEXING
An 'i' or an 'n' is said to 'target' t0. An instruction can be made to target a different term by putting a string of '~' characters in front of it. ~i targets t1, ~~n targets t2 etc. ~~~i targets t3 and is not considered to target t2 (it's the largest possible number of preceding consecutive '~' characters that count). For example, given:
i~i,iii,iiii
The 'i' on the left copies 'iii' as you woud expect, but '~i' copies the next term along which is 'iiii', giving the result 'iiiiiii'. That's 3+4=7.
I'd better explain how terms get killed (i.e. deleted). t0 is always killed, and anything targeted by some "~"s gets killed, which is why the term 'iiii' got killed above, leaving only 'iiiiiii'. And you can have some "~"s just to kill something off without copying it. Example:
i~~~i~i~~,ii,iii,iiii,iiiii
becomes: ii iiiii iii
(I left some spaces in that but really it should just be iiiiiiiiii.)
The term t2 which was iiii got killed by the ~~ at the end of i~~~i~i~~.
That's all the rules, and enough to do powers even when the power is zero, using this:
~~~~~ii,~i,~n,i~,i,a,b
for 2 raised to the power 4:
~~~~~ii,~i,~n,i~,i,ii,iiii
iiii~i,~n,i~,i,ii
~n~n~n~ni~,i,ii
ii,ii,ii,ii,i
iiii,ii,ii,i
iiiiiiii,ii,i
iiiiiiiiiiiiiiii,i
iiiiiiiiiiiiiiii
which is sixteen 'i's, and for 3 to the power zero:
~~~~~ii,~i,~n,i~,i,iii,
~i,~n,i~,i,iii
i~,i,iii
i
which is one 'i', corresponding to 1.
FIBONACCI SEQUENCE
First, note that this sequence simply repeats itself indefinitely:
nn,nn
(also ni,ni)
This can be used to build loops such as:
nn~i~~n~i,nn~i~~n~i,i,i
nn~i~~n~i,nn~i~~n~i,ii,i
nn~i~~n~i,nn~i~~n~i,iii,ii
nn~i~~n~i,nn~i~~n~i,iiiii,iii
etc.
The terms on the end are i i ii iii ... which is like 1, 1, 2, 3, 5, 8, ... where each number is the sum of the two previous numbers, except for 1, 1 which you start with.
I have a sequence which can produce the nth Fibonacci number for n in {0,1,2,3, ...}, and I will post it if asked. Terminating loops seems more complicated than iterating them, and I use a more condensed notation for such sequences.
__________________
The principle of economy may be stated thus:
Last edited by Michael Orwin on 11092007 at 03:30 PM
Report this post to a moderator  IP: Logged
