REsKrIb!lo

rEsKrIb!lo --

When I first read about the "rewriting paradigma" for computer languages, well soon after it came to my mind this could be something for a 16th century or medieval "computer".

I will present shortly some designs, some use two drums like early twenty century drum memory. Another uses just a punched tape.

I googled and found rescriptor is already in use for some medicine ....

For practical reason all those models should be modified to allow some form of output to a printer or tape puncher.

The Punched Tape Rescriptor/Reskribilo --

Being the most simple design I present it first. Each tape is 96 bits width the length can vary but the tape must be fixed together on the ends so that it can rotate without further logic.

Every turn the 96 reading heads detect a pattern and compare it with what is stored in the probably mechanic or magnetic relays. Let's say there a 48 of them.

Every time a pattern is read by the reading heads they compare the first 48 bits of it with the content of the relays and if it's equal the relay content will be overwritten by the other half of the 96 bits.

Suppose that is read: G O O D - - - - M O R N I N G -

and that is the content of the relays : G O O D Y E A R

The - represents 111111. Six Bits form one character. A comparison with the - character returns always a true result. Every Character in the Relays is compared with the Pattern and if the result for all characters is true then the Pattern is replaced with the Replacement.

Thus in this sample GOODYEAR is replaced with MORNING. Because the replacement pattern is MORNING- the relays contain now MORNINGR because the R from GOODYEAR is not replaced.

There is no halt defined, however the Reskribilo can be halted and the status of the Relays can be checked.

The Punched Tape Rescriptor/Reskribilo does not match

- G O O D - - - - M O R N I N G -

with

G O O D Y E A R

which would somehow be desireable ( compare with the Thue-command GOOD::=MORNING ).For this reason more commands are needed, thus for our sample 4 more commands. G O O D - - - - M O R N I N G - - G O O D - - - M O R N I N G - - - G O O D - - M O R N I N G - - - - G O O D - M O R N I N G - - - - - G O O D M O R N I N G -

I have choosen the 96 bits because of the ease for giving a sample. Of course it could be longer or smaller. The idea was using a fixed number of bits.

The Shifted Punched Tape Rescriptor/Reskribilo --

Works like the unshifted one but shifts for every character, so that

- G O O D - - - - M O R N I N G -

matches G O O D Y E A R. Actually in my implementation the shifting is performed in the state and the rule pattern does not shift, although it could be quite the opposit.

The Two Drum Rescriptor/Reskribilo --

uses two memory drums who rotate independently to provide the reading headers with fresh bits. One drum is for the rules the other one is for the state. It is like the Punched Tape Rescriptor/Reskribilo however for the relays there's another drum and machine can have more states/statuses ...

However there's also the shifting problem for matching and thus there is also a Shifted Two Drum Rescriptor/Reskribilo. As for the other designs there's no other form of obtaining result then switching of the machine and reading the memory in this case the state drum. For practical reason all those models should be modified to allow some form of output to a printer or tape puncher.

The Correcting Two Drum Resriptor/Reskribilo

is like the one above however, when no rules can be performed for some turns, this is recognized and one Drum actually becomes the rule Drum while the other one changes its role and becomes the state Drum. Until the rules of both Drums can not be performed for some turns.

There is no need for the rule Drum being twice as broad as the state Drum. It is just a matter of interpretation.

Implementation of the The Shifted Punched Tape Reskribilo (SPTR) /*implementation of the rEsKrIb!lo machine */ /* the 96 bit Shifted Punched Tape Rescriptor/Reskribilo */

/* Usage: reskribilo rule-file input-string */ /* Example: reskribilo prog.x GOODYEAR */ /* there are no syntax checks so check for yourself*/


 * 1) include

char R[4096];

void main(int argc,char *argv[]) {FILE *f; int i,j,k,e,t,s; char Z[12],c;

/*the reads the input-string (just eight characters)*/ for(i=0;i<8;++i){Z[i]=argv[2][i];}

/*get rules from file --- just reads the first 4096 bytes */ /* q should end the whole loop by setting i to 32767 */ f=fopen(argv[1],"r"); for(i=0;i<4096;++i) {R[i]=fgetc(f); if(R[i]=='-'){R[i]='-';} /*the speacial - character*/ if(R[i]=='q'){k=i;i=32767;} /*the halting character*/ } fclose(f);

/*program loop ... yawn ! zn aischloufn */ t=0; do  {i=k; /*note that*/ for(k=0;k<i;k=k+16) {       for(s=0;s<8;++s)/*shifting loop*/ {      /*checking for equality and special character '-'*/ e=(R[k+0]==Z[0])||(R[k+0]=='-'); e=e&&((R[k+1]==Z[1])||(R[k+1]=='-')); e=e&&((R[k+2]==Z[2])||(R[k+2]=='-')); e=e&&((R[k+3]==Z[3])||(R[k+3]=='-')); e=e&&((R[k+4]==Z[4])||(R[k+4]=='-')); e=e&&((R[k+5]==Z[5])||(R[k+5]=='-')); e=e&&((R[k+6]==Z[6])||(R[k+6]=='-')); e=e&&((R[k+7]==Z[7])||(R[k+7]=='-'));

c=R[k+16]; Z[8]=0; R[k+16]=0; printf("current rule: %s current state: %s  ",&R[k],Z); R[k+16]=c; scanf("%c",&c); /*replacing, - in the replacement will not replace */ if(e) {for(j=0;j<8;++j) {if(R[k+j+8]!='-') {Z[j]=R[k+8+j];} }       }       /*The ShIfting*/ /*abcdefgh habcdefg*/ c=Z[7];Z[7]=Z[6];Z[6]=Z[5];Z[5]=Z[4];Z[4]=Z[3];Z[3]=Z[2];Z[2]=Z[1];Z[1]=Z[0];Z[0]=c; }/*shifting loop*/ }   scanf("%c",&c);/*input q to exit program or something else to continue*/ Z[8]=0; printf("Turn %d State %s\n",t,Z); ++t; /*and one more */ } while(c!='q'); }

Sample Program for Testing for the Implementation above

--GOODTHIS--q comment: use something like GOODYEAR as input string