# Tag system

In the theory of computation, a **tag system** is a deterministic model of computation published by Emil Leon Post in 1943 as a simple form of a Post canonical system.^{[1]} A tag system may also be viewed as an abstract machine, called a **Post tag machine** (not to be confused with Post–Turing machines)—briefly, a finite-state machine whose only tape is a FIFO queue of unbounded length, such that in each transition the machine reads the symbol at the head of the queue, deletes a constant number of symbols from the head, and appends to the tail a symbol-string that depends solely on the first symbol read in this transition.

Because all of the indicated operations are performed in a single transition, a tag machine strictly has only one state.

## Definitions[edit]

A *tag system* is a triplet (*m*, *A*, *P*), where

*m*is a positive integer, called the*deletion number*.*A*is a finite alphabet of symbols, one of which can be a special*halting symbol*. All finite (possibly empty) strings on*A*are called*words*.*P*is a set of*production rules*, assigning a word*P(x)*(called a*production*) to each symbol*x*in*A*. The production (say*P(H)*) assigned to the halting symbol is seen below to play no role in computations, but for convenience is taken to be*P(H)*=*'H'*.

A *halting word* is a word that either begins with the halting symbol or whose length is less than *m*.

A transformation *t* (called the *tag operation*) is defined on the set of non-halting words, such that if *x* denotes the leftmost symbol of a word *S*, then *t*(*S*) is the result of deleting the leftmost *m* symbols of *S* and appending the word *P(x)* on the right. Thus, the system processes the m-symbol head into a tail of variable length, but the generated tail depends solely on the first symbol of the head.

A *computation* by a tag system is a finite sequence of words produced by iterating the transformation *t*, starting with an initially given word and halting when a halting word is produced. (By this definition, a computation is not considered to exist unless a halting word is produced in finitely-many iterations. Alternative definitions allow nonhalting computations, for example by using a special subset of the alphabet to identify words that encode output.)

The term *m-tag system* is often used to emphasise the deletion number. Definitions vary somewhat in the literature (cf. References), the one presented here being that of Rogozhin.^{[2]}

The use of a halting symbol in the above definition allows the output of a computation to be encoded in the final word alone, whereas otherwise the output would be encoded in the entire sequence of words produced by iterating the tag operation.

A common alternative definition uses no halting symbol and treats all words of length less than *m* as halting words. Another definition is the original one used by Post (1943) (described in the historical note below), in which the only halting word is the empty string.

### Example: A simple 2-tag illustration[edit]

This is merely to illustrate a simple 2-tag system that uses a halting symbol.

2-tag system Alphabet: {a,b,c,H} Production rules: a --> ccbaH b --> cca c --> cc Computation Initial word: baa acca caccbaH ccbaHcc baHcccc Hcccccca (halt).

### Example: Computation of Collatz sequences[edit]

This simple 2-tag system is adapted from De Mol (2008). It uses no halting symbol, but halts on any word of length less than 2, and computes a slightly modified version of the Collatz sequence.

In the original Collatz sequence, the successor of *n* is either *n*/2 (for even *n*) or 3*n* + 1 (for odd n). The value 3*n* + 1 is clearly even for odd *n*, hence the next term after 3*n* + 1 is surely 3*n* + 1/2. In the sequence computed by the tag system below we skip this intermediate step, hence the successor of *n* is 3*n* + 1/2 for odd *n*.

In this tag system, a positive integer *n* is represented by the word aa...a with *n* a's.

2-tag system Alphabet: {a,b,c} Production rules: a --> bc b --> a c --> aaa Computation Initial word: aaa <--> n=3 abc cbc caaa aaaaa <--> 5 aaabc abcbc cbcbc cbcaaa caaaaaa aaaaaaaa <--> 8 aaaaaabc aaaabcbc aabcbcbc bcbcbcbc bcbcbca bcbcaa bcaaa aaaa <--> 4 aabc bcbc bca aa <--> 2 bc a <--> 1 (halt)

## Turing-completeness of *m*-tag systems[edit]

For each *m* > 1, the set of *m*-tag systems is Turing-complete; i.e., for each *m* > 1, it is the case that for any given Turing machine **T**, there is an *m*-tag system that emulates **T**. In particular, a 2-tag system can be constructed to emulate a Universal Turing machine, as was done by Wang (1963) and by Cocke & Minsky (1964).

Conversely, a Turing machine can be shown to be a Universal Turing Machine by proving that it can emulate a Turing-complete class of *m*-tag systems. For example, Rogozhin (1996) proved the universality of the class of 2-tag systems with alphabet {*a _{1}*, ...,

*a*, H} and corresponding productions {

_{n}*a*, ...,

_{n}a_{n}W_{1}*a*,

_{n}a_{n}W_{n-1}*a*, H}, where the

_{n}a_{n}*W*are nonempty words; he then proved the universality of a very small (4-state, 6-symbol) Turing machine by showing that it can simulate this class of tag systems.

_{k}The 2-tag system is an efficient simulator of universal Turing machines, in time. That is, if is a deterministic single-tape Turing machine that runs in time , then there is a 2-tag system that simulates it in time.^{[3]}

## The 2-tag halting problem[edit]

This version of the halting problem is among the simplest, most-easily described undecidable decision problems:

Given an arbitrary positive integer *n* and a list of *n*+1 arbitrary words *P*_{1},*P*_{2},...,*P*_{n},*Q* on the alphabet {1,2,...,*n*}, does repeated application of the tag operation *t*: *ijX* → *XP*_{i} eventually convert *Q* into a word of length less than 2? That is, does the sequence *Q*, *t*^{1}(*Q*), *t*^{2}(*Q*), *t*^{3}(*Q*), ... terminate?

## Historical note on the definition of tag system[edit]

The above definition differs from that of Post (1943), whose tag systems use no halting symbol, but rather halt only on the empty word, with the tag operation *t* being defined as follows:

- If
*x*denotes the leftmost symbol of a nonempty word*S*, then*t*(*S*) is the operation consisting of__first appending__the word*P(x)*to the right end of*S*, and__then deleting__the leftmost*m*symbols of the result —__deleting all__if there be less than*m*symbols.

The above remark concerning the Turing-completeness of the set of *m*-tag systems, for any *m* > 1, applies also to these tag systems as originally defined by Post.

### Origin of the name "tag"[edit]

According to a footnote in Post (1943), B. P. Gill suggested the name for an earlier variant of the problem in which the first *m* symbols are left untouched, but rather a check mark indicating the current position moves to the right by *m* symbols every step. The name for the problem of determining whether or not the check mark ever touches the end of the sequence was then dubbed the "problem of tag", referring to the children's game of tag.

## Cyclic tag systems[edit]

A cyclic tag system is a modification of the original tag system. The alphabet consists of only two symbols, **0** and **1**, and the production rules comprise a list of productions considered sequentially, cycling back to the beginning of the list after considering the "last" production on the list. For each production, the leftmost symbol of the word is examined—if the symbol is **1**, the current production is appended to the right end of the word; if the symbol is **0**, no characters are appended to the word; in either case, the leftmost symbol is then deleted. The system halts if and when the word becomes empty.^{[4]}

### Example[edit]

Cyclic Tag System Productions: (010, 000, 1111) Computation Initial Word: 11001 Production Word ---------- -------------- 010 11001 000 1001010 1111 001010000 010 01010000 000 1010000 1111 010000000 010 10000000 . . . .

Cyclic tag systems were created by Matthew Cook and were used in Cook's demonstration that the Rule 110 cellular automaton is universal.^{[5]} A key part of the demonstration was that cyclic tag systems can emulate a Turing-complete class of tag systems.

## Emulation of tag systems by cyclic tag systems[edit]

An *m*-tag system with alphabet {*a _{1}*, ...,

*a*} and corresponding productions {

_{n}*P*, ...,

_{1}*P*} is emulated by a cyclic tag system with

_{n}*m*n*productions (

*Q*, ...,

_{1}*Q*, -, -, ..., -), where all but the first

_{n}*n*productions are the empty string (denoted by '-'). The

*Q*are encodings of the respective

_{k}*P*, obtained by replacing each symbol of the tag system alphabet by a length-

_{k}*n*binary string as follows (these are to be applied also to the initial word of a tag system computation):

a= 100...00_{1}a= 010...00 . . ._{2}a= 000...01_{n}

That is, *a _{k}* is encoded as a binary string with a 1 in the k

^{th}position from the left, and 0's elsewhere. Successive lines of a tag system computation will then occur encoded as every (

*m*n*)

^{th}line of its emulation by the cyclic tag system.

### Example[edit]

This is a very small example to illustrate the emulation technique.

2-tag system Production rules: (a --> bb, b --> abH, H --> H) Alphabet encoding: a = 100, b = 010, H = 001 Production encodings: (bb = 010 010, abH = 100 010 001, H = 001) Cyclic tag system Productions: (010 010, 100 010 001, 001, -, -, -) Tag system computation Initial word: ba abH Hbb (halt) Cyclic tag system computation Initial word: 010 100 (=ba) Production Word ---------- ------------------------------- * 010 010 010 100 (=ba) 100 010 001 10 100 001 0 100 100 010 001 - 100 100 010 001 - 00 100 010 001 - 0 100 010 001 * 010 010 100 010 001 (=abH) 100 010 001 00 010 001 010 010 001 0 010 001 010 010 - 010 001 010 010 - 10 001 010 010 - 0 001 010 010 * 010 010 emulated halt --> 001 010 010 (=Hbb) 100 010 001 01 010 010 001 1 010 010 - 010 010 001 ... ...

Every sixth line (marked by '*') produced by the cyclic tag system is the encoding of a corresponding line of the tag system computation, until the emulated halt is reached.

## See also[edit]

## Notes[edit]

**^**Post 1943.**^**Rogozhin 1996.**^**Woods, Damien; Neary, Turlough (2009-02-17). "The complexity of small universal Turing machines: A survey".*Theoretical Computer Science*. Computational Paradigms from Nature.**410**(4): 443–450. doi:10.1016/j.tcs.2008.09.051. ISSN 0304-3975. S2CID 10257004.**^**In a chapter 14 titled "Very Simple Bases for Computability", Minsky (1967) presents a very readable (and exampled) subsection 14.6*The Problem of "Tag" and Monogenic Canonical Systems*(pp. 267–273) (this sub-section is indexed as "tag system"). Minsky relates his frustrating experiences with the general problem: "Post found this (00, 1101) problem "intractable," and so did I, even with the help of a computer." He comments that an "effective way to decide, for any string S, whether this process will ever repeat when started with S" is unknown although a few specific cases have been proven unsolvable. In particular he mentions Cocke's Theorem and Corollary 1964.**^**Cook 2004.

## References[edit]

- Cocke, John; Minsky, Marvin (1964). "Universality of Tag Systems with P=2".
*Journal of the Association for Computing Machinery*.**11**: 15–20. doi:10.1145/321203.321206. hdl:1721.1/6107. S2CID 2799125. - Cook, Matthew (2004). "Universality in Elementary Cellular Automata".
*Complex Systems*.**15**: 1–40. Archived (PDF) from the original on 28 May 2016. - De Mol, Liesbeth (January 2008). "Tag systems and Collatz-like functions".
*Theoretical Computer Science*.**390**(1): 92–101. doi:10.1016/j.tcs.2007.10.020. hdl:1854/LU-436211. - Minsky, Marvin L. (November 1961). "Recursive Unsolvability of Post's Problem of "Tag" and other Topics in Theory of Turing Machines".
*Annals of Mathematics*. 2.**74**(3): 437–455. doi:10.2307/1970290. JSTOR 1970290. - Minsky, Marvin L. (1967).
*Computation: Finite and Infinite Machines*. Englewoord Cliffs, N.J.: Prentice–Hall. pp. 267–273. ISBN 978-0131655638. LCCN 67-12342. - Post, Emil (1943). "Formal reductions of the combinatorial decision problem".
*American Journal of Mathematics*.**65**(2): 197–215. doi:10.2307/2371809. JSTOR 2371809. (Tag systems are introduced on p. 203ff.) - Rogozhin, Yurii (20 November 1996). "Small Universal Turing Machines".
*Theoretical Computer Science*.**168**(2): 215–240. doi:10.1016/S0304-3975(96)00077-1. - Wang, Hao (1963). "Tag Systems and Lag Systems".
*Mathematische Annalen*.**152**: 65–74. doi:10.1007/BF01343730. S2CID 120383146.

## External links[edit]

- https://mathworld.wolfram.com/TagSystem.html
- https://mathworld.wolfram.com/CyclicTagSystem.html
- https://www.wolframscience.com/nks/p95/ (cyclic tag systems)
- https://www.wolframscience.com/nks/p669/ (emulation of tag systems)