esolang
Learn · Ideas32 languages show it

Tag systems

Read a letter at the front, throw a few away, glue a word on the back. Repeat. That is a computer.

●●○ moderate · where to see it

The idea

A tag system works on a string, like a queue. Each step it looks only at the first letter, writes a word that depends on it at the end, and deletes a fixed number of letters from the front.

Read the story

Emil Post studied them in the 1920s, hoping to understand them completely, and published on them in

  1. They turned out to be far harder than they look. Marvin Minsky showed in 1961 that tag systems

are universal, and John Cocke and Minsky showed in 1964 that deleting just 2 letters per step is enough.

They matter for esolangs because they are tiny, easy to simulate, and good at hiding inside other systems. The proof that the cellular automaton Rule 110 is universal goes through a variant of them.

How it works

A 2-tag system has a set of rules, one per letter, and deletes 2 letters per step.

A 2-tag system has a set of rules, one per letter, and deletes 2 letters per step.

  1. look at the first letter;
  2. append that letter's word to the end;
  3. delete the first 2 letters.

Stop when the string has fewer than 2 letters.

Collatz in a tag system

This 2-tag system is adapted from Liesbeth De Mol's work (2008). The rules.

a → bc
b → a
c → aaa

Start with aaa, which stands for the number 3. The first steps follow.

0  aaa          read a: append bc, drop "aa"
1  abc          read a: append bc
2  cbc          read c: append aaa
3  caaa         read c: append aaa
4  aaaaa        = 5
5  aaabc
...
10 aaaaaaaa     = 8
18 aaaa         = 4
22 aa           = 2
24 a            = 1, too short: halt

Whenever the string is all a, it is a number, here 3, 5, 8, 4, 2, 1. That is the Collatz sequence in its short form (odd n goes to (3n+1)/2, even n to n/2). No arithmetic anywhere, only reading the front and writing the back.

Whether this run halts for every starting number is the Collatz conjecture, which is still open. A three-rule string game already holds an unsolved problem.

Cyclic tag

Matthew Cook simplified the idea further for his Rule 110 proof. In a cyclic tag system the rules are used in a fixed rotation, whatever the first letter is, and the alphabet is 0 and 1.

  • if the first bit is 1, append the current rule's word;
  • either way, delete the first bit and move to the next rule.

Bitwise Cyclic Tag turns this into a language with two commands.

Seen in

  • Bitwise Cyclic Tag. Cyclic tag as a two-command language.
  • Rule 110. Its universality proof builds a cyclic tag system out of gliders.

Try this

  1. Run the Collatz system by hand from aaaaaa (6). Does it pass through 3?
  2. Change the rule b → a to b → aa. What happens to aaa?
  3. Hard: write a ten-line tag-system interpreter and find the start below 100 whose run takes the most steps to halt.

Further

Where to see it