Bitwise Cyclic Tag

Bitwise Cyclic Tag (BCT) is a Turing-complete programming language using only two commands (0 and 1) to operate on a finite data-bitstring extensible without bound on the right. Its extremely simple syntax and semantics make it a useful target for simulation-based proofs of a language's computational class.

BCT programs

A BCT program is any finite string of bits (commands), executed as follows:

Command

Execution

0

Delete the leftmost data-bit.

1

Goto the next command (say x). If the leftmost data-bit is 1, copy x to the right end of the data-string.

If the program-string or the data-string is initially empty, execution halts immediately; otherwise, starting at the leftmost program-bit and halting only when the data-string becomes empty, the commands are executed in cyclic sequence from left to right (the leftmost bit following next after the rightmost bit).

The program pointer advances one bit after each command-execution, and also advances one bit when the goto in a 1-command is executed; consequently, a 1-command always pairs with the next command after it (say x), such that 1x is effectively a composite command whose execution is

if the leftmost data-bit is 1:
copy x to the right end of the data-string

Four equivalent variations of BCT are obtained by exchanging the roles of symbols 0 and 1 as commands, and by varying the parity required in the condition for copying a bit to the end of the data-string.

BCT emulation of cyclic tag systems

For any cyclic tag system on a binary alphabet, there is a BCT program that emulates it (thus establishing that BCT is Turing-complete, since the set of cyclic tag systems is Turing-complete).

Specifically, a BCT program that emulates a given cyclic tag system is obtained by writing the cyclic tag system productions as ';'-terminated strings, concatenating these strings, and then applying the following substitutions:

0 <-- 10
1 <-- 11
; <-- 0

The initial data-string for the BCT program is the unaltered initial binary word for the cyclic tag system.

*Note*: BCT remains Turing complete even if the initial data-string is always just a single 1. This is because, for any BCT (program-string, data-string) pair, say (P,Q), there is a pair (P',1) that simulates the same computation. This follows from a result in Undecidability in binary tag systems and the Post correspondence problem for four pairs of words (Turlough Neary, 2013), to the effect that for any cyclic tag system with initial word w (say), the same computation is simulated by some cyclic tag system whose initial word is a single 1.

The language CT

BCT was created upon noticing that the operation of a cyclic tag system is exactly duplicated by interpreting the concatenation of its semicolon-terminated productions as a program that uses three commands {0, 1, ;} to operate on the current word (interpeted as a data bit-string). Calling this three-instruction language CT, with programs that may be any finite string on {0, 1, ;}, the commands of a CT program are executed left-to-right in cyclic sequence, halting only when the data-string becomes empty:

CT Command

Execution

Equivalent BCT Command

0

If the leftmost data-bit is 1, append 0.

10

1

If the leftmost data-bit is 1, append 1.

11

;

Delete the leftmost data-bit.

0

The purpose of replacing CT by BCT was merely to obtain a language whose programs are binary (rather than ternary) strings.

CT programs that might interest someone:

Program "1", data "1". Creates 'a pyramid of 1s'.

Program ";", data whatever. Removes all data and halts.

A sort of quines: Programs where the data remains forever identical to the initial program (and identical to data -- itself -- too). Any string consisting only of 0s and 1s, and which begins with a 0, suffices. Thus, for example: Program "0", data "0" (this is the shortest one possible). Program "0100111", data "0100111".

In the computation, when (and only when) the data-string takes the form (100)k immediately before beginning a cycle through the program, it represents the integer k -- and these will be the successive terms of the Collatz sequence for n. Here is a sample computation for n = 3, showing the data-strings at the beginning of each program-cycle:

Note that the digits 1,2 are represented by the bits 0,1 respectively, and the numeral is read in reverse order from the bit-string. E.g., the BCT data-string 011 corresponds to the bijective base-2 numeral 221, representing the integer 2*22 + 2*21 + 1*20 = 13.

Each BCT command in a program then corresponds to an explicit numerical function defined on the set N of nonnegative integers, as follows:

Command

Equivalent numerical function (mapping N to N)

0

f(n) = [n is positive] * floor((n-1)/2)

10

g0(n) = n + [n is positive and even] * 2(floor(log2(n+1)) + 0)

11

g1(n) = n + [n is positive and even] * 2(floor(log2(n+1)) + 1)

where we've shown separately the two cases for the program-bit that's next after the 1-command. Here [condition] is an Iverson bracket, meaning 1 if condition is true, else 0; so the integer 0 is a fixed-point of all three of the functions f, g0, g1, and represents a permanent "halt" condition. (Also note that floor(log2(n+1)) is just the number of digits in the bijective base-2 numeral for n.)

Thus a BCT program is equivalent to a composition of finitely-many instances of the three functions f, g0, g1, all but some initial portion of which is iterated. Just as the sequence of successive data-strings encodes all input and output in a BCT computation, in the arithmetic interpretation the same role is fulfilled by the sequence of successive nonnegative integer arguments.

Gödel numbering

A Gödel numbering of BCT programs is automatically provided by similarly interpreting each BCT program as the bijective base-2 numeral of an integer (now in the usual digit-order, unlike the data-string). Thus, a BCT program is (the numeral of) its own Gödel number. E.g., the program 011 is interpreted as the integer 10 (ten = 122 in bijective base-2) — and indeed 011 is the tenth nonempty BCT program in a shortlex ordering of the set of all BCT programs.

An asterisk marks the first command executed in each cycle through the program — the first function evaluated in each iteration.

Computations in BCT

It can be shown that for any Turing machine computation, there is a BCT system (program plus data-string) that simulates it — halting if and only if the TM halts, and encoding the TM's input and output in the sequence of deleted data-bits. This is a consequence of the Turing-completeness of cyclic tag systems, together with the fact that BCT can simulate any cyclic tag system.

Self BCT

Any string of bits L...R, when read in cyclic sequence (rightward
from L, with L next after R), parses into a unique sequence of
instructions from the set {0, 10, 11}. Thus, any such string can
be interpreted as a self-modifying program whose instructions are
executed in cyclic sequence as follows (with labels L/R revised
appropriately when a bit is deleted/appended):

Instruction

Execution

0

Delete L.

1x

If L > 0: append x to R.

Program execution halts if and when the program deletes itself.

This is essentially BCT, but with the data-string identified with
the program-string itself.

This language might well be a Turing tarpit, with the 43,074 steps for the program "1011110111" already showing some characteristically rapid growth in the associated uncomputable Radó S-sequence.

Both BCT and Self BCT generalise to languages that use p instructions of the form 0 and pX, where p is a positive base-p digit and X is any base-p digit-string of length p. A program is then any base-p digit-string.

Authorship

The languages CT and BCT were created by "r.e.s." in December 2005.
"Self BCT" was created by "r.e.s." in 2005-2006 (posted 2006 in a
comp.theory usegroup message, "Variations on Cyclic Tag").