TSL

From Esolang
Jump to: navigation, search

A TSL or a Tiny Self-Modifying Language is any member of a specific group of esolangs, rather than an individual language. In order for a language to be designated a TSL, it need necessarily have a minimal number of instructions, be capable of trivial self-modification and further interpretation of modified code, and rely solely on self-modification for decision logic. This as originally described by Tslil Clingman upon creation of the category in early 2010.

As it so happens, a convenient structure for a TSL is an unbounded, one-dimensional tape that is accessed through two heads. A read head which reads the programme state and a write head that can alter the contents of the tape. Note: This structure does not constitute a TSL alone, nor a TSL this structure.

RWLR III

RWLR III (or TSL-A, as it is the first of the TSL group) is merely a revised form of RWLR to make it compliant with the above restrictions. The revised spec is as follows:

There is an unbounded tape, with each cell capable of holding any arbitrary integer. A read head (RH) and a write head (WH) access this tape and move independently of each other. The read head alters the machine state, while the write head alters the tape contents. These roles are not interchangeable. There are four "special" integers that will constitute a change of state when read by the read head. They are 0, 1, 2, and 3. The states of the machine are given by:

 INC,MVW+  =>  Increase the cell under the WH, Move WH in positive direction by one cell
 DEC,MVW+  =>  Decrease the cell under the WH, Move WH in positive direction by one cell
 MVW-      =>  Move WH in negative direction
 MVR[+]    =>  Move RH by the decimal value in the next cell

The effects of the 'special' integers are as follows:

 0 => INC,MVW+
 1 => DEC,MVW+
 2 => MVW-
 3 => MVR[+1]

Decision logic is implemented through decreasing a number by an amount in order to either bring it to 3 or a number greater. Then, by setting the RH to run over it a state transition and subsequent RH jump will occur iff. that number was exactly a specific amount away from three. There are, however, many subtleties to this method. Most importantly, by decreasing a number too much, it may turn into another valid instruction, which if read may wreak havoc, or become negative and thus erroneous altogether (in the context of this method). Thus, when using this decision structure, it is recommended that that condition number be decreased by one and checked - every cycle.

An example of decision logic is as follows (where V indicates the initial WH position and * the initial RH position). Here, iff a=6, then the RH will move to T, otherwise it will move to F. Code may later choose to restore the value of a by adding three to it.

 V
 a 12 3 12 0 2 0 2 0 2 0 3 -12 T F
           *

RWLR IV

RWLR IV (TSL-B) attempts to further reduce the number of instructions from TSL-A by limiting the range of integers that a cell may store to any of the set {-2,-1,0,1,2}. This has the effect of allowing each cell to store but one digit of 'balanced quinery'. This, in turn, allows for the decrease structure to be removed in favour of a wrap-around increase structure thus eliminating one instruction. The new states are as follows:

 INC,MVW+         => Increase the cell under the WH, Move WH in positive direction by one cell
 MVW-             => Move WH in negative direction
 MVR[[+][++][+++]]=> Move RH by value in the next three cells, taken as a balanced quinery number

Thus the new instructions are:

 -2 : INC,MVW+
 -1 : MVW-
 0  : MVR[[+][++][+++]]

In order to affect useful computations, however, an encoding scheme needs to be implemented in order to allow for decision logic to operate using decision values as commands. Thus, a binary system is the trivial solution, as achieved through the designation of 1 to logic 0 (False) and 2 to logic 1 (True). With that in place, code need only subtract one (achieved through the addition of four) in order to test whether a value is true using the same method as above. For example:

 V
 a 1 -1 0 0 1 -2 2 -2 -1 -2 -1 -2 -1 -2 -1 0 1 -2 2 T F
                    *

If a, then jump to T else jump to F. The above, however, is also vulnerable to the subtleties of using data as code as mentioned above, however, it is (in a sense) less likely to cause unintended behaviour due to the fact that there are only two values in this encoding scheme, and hence no reason to decrease any one value by more than one. Another key point to note is that, should a be False, the write head will be moved one cell to the left, due to the reading of the -1 (originally part of the True jump offset) as an instruction. Such irregularities in execution lead the author to doubt that TSL-B can be Turing Complete.

It is unclear if TSL-B is capable of scaling to non-trivial code. Thus, as of writing, the computational class of TSL-B remains an open question.