A New Kind of Science: The NKS Forum : Powered by vBulletin version 2.3.0 A New Kind of Science: The NKS Forum > Pure NKS > sequences of instructions to copy and kill terms
  Last Thread   Next Thread
Thread Post New Thread    Post A Reply
Michael Orwin


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)

I label the terms: t-1, t0, t1, t2 ... with t-1 being the leftmost term, and it is always t-1 which is executed.

On execution, an 'i' in t-1 is replaced by t0. For instance if you execute:
each 'i' in t-1 is replaced by t0 (which is iii) giving the result iiiiii. I usually write this as:
and the multiplication 3 x 2 x 4 can be represented as:
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:
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:
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:
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.

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:
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:
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:
for 2 raised to the power 4:
which is sixteen 'i's, and for 3 to the power zero:
which is one 'i', corresponding to 1.

First, note that this sequence simply repeats itself indefinitely:
(also ni,ni)
This can be used to build loops such as:


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 11-09-2007 at 03:30 PM

Report this post to a moderator | IP: Logged

Old Post 11-09-2007 03:13 PM
Michael Orwin is offline Click Here to See the Profile for Michael Orwin Edit/Delete Message Reply w/Quote
Post New Thread    Post A Reply
  Last Thread   Next Thread
Show Printable Version | Email this Page | Subscribe to this Thread


wolframscience.com  |  wolfram atlas  |  NKS online  |  Wolfram|Alpha  |  Wolfram Science Summer School  |  web resources  |  contact us

Forum Sponsored by Wolfram Research

© 2004-16 Wolfram Research, Inc. | Powered by vBulletin 2.3.0 © 2000-2002 Jelsoft Enterprises, Ltd. | Disclaimer | Archives