3. T7: from a binary Turing machine to a cyclic tag system
3.1. Orientation
This link is independent of Smith's paper. It supplies what Smith's theorem
consumes: a two-colour cyclic tag system that simulates a given Turing machine,
with a decoder. It is a genuine construction, not an appeal to the literature: a
2-tag system after Cocke and Minsky (1964; Minsky 1967, section 14.6) in a phase
design of our own, carried onto a finite alphabet, then onto a cyclic tag system
by Cook's encoding (TagSystem/TagToCTS.lean, which predates the rebuild and is
used unchanged).
The class of machines is the binary machines: TagSystem.WF restricts the
transition table to bits and TagSystem.ValidCfg the tape to bits. A k-symbol
machine must be encoded in binary before this theorem applies; that reduction is
not formalized (the chapter on open items).
3.2. Rounds of a 2-tag system
TagSystem/TagRounds.lean treats a 2-tag system over any alphabet.
The 2-tag step with productions P, on a word over any alphabet: read the first
symbol, delete the first two and append P of the symbol read. A word of fewer
than two symbols has no step.
Lean code for Definition3.2.1●1 definition
Associated Lean declarations
-
TagSystem.stepP[complete]
-
TagSystem.stepP[complete]
-
defdefined in TagSystem/TagRounds.leancomplete
def TagSystem.stepP.{u} {σ : Type u} (P : σ → List σ) : List σ → Option (List σ)
def TagSystem.stepP.{u} {σ : Type u} (P : σ → List σ) : List σ → Option (List σ)
The 2-tag step with productions `P`: read the first symbol, delete the first two, append the production of the symbol read.
nStepsP P w n iterates Definition 3.2.1 n times from w; it is
none as soon as a step is undefined.
Lean code for Definition3.2.2●1 definition
Associated Lean declarations
-
TagSystem.nStepsP[complete]
-
TagSystem.nStepsP[complete]
-
defdefined in TagSystem/TagRounds.leancomplete
def TagSystem.nStepsP.{u} {σ : Type u} (P : σ → List σ) (w : List σ) : ℕ → Option (List σ)
def TagSystem.nStepsP.{u} {σ : Type u} (P : σ → List σ) (w : List σ) : ℕ → Option (List σ)
`n` steps.
The step of a tag system ts : Tag k of TagSystem/Basic.lean on a word over
Fin k: read the first symbol, delete the first two, append ts.productions of
the symbol read.
Lean code for Definition3.2.3●1 definition
Associated Lean declarations
-
TagSystem.Tag.step[complete]
-
TagSystem.Tag.step[complete]
-
defdefined in TagSystem/Basic.leancomplete
def TagSystem.Tag.step {k : ℕ} (ts : TagSystem.Tag k) (cfg : TagSystem.TagConfig k) : Option (TagSystem.TagConfig k)
def TagSystem.Tag.step {k : ℕ} (ts : TagSystem.Tag k) (cfg : TagSystem.TagConfig k) : Option (TagSystem.TagConfig k)
Single step of a 2-tag system. Returns none if halted (word too short).
The step Definition 3.2.3 is Definition 3.2.1 with the
productions of the system: ts.step w = stepP ts.productions w.
Lean code for Lemma3.2.4●1 theorem
Associated Lean declarations
-
TagSystem.Tag.step_eq_stepP[complete]
-
TagSystem.Tag.step_eq_stepP[complete]
-
theoremdefined in TagSystem/TMToCTS.leancomplete
theorem TagSystem.Tag.step_eq_stepP {k : ℕ} (ts : TagSystem.Tag k) (w : List (Fin k)) : ts.step w = TagSystem.stepP ts.productions w
theorem TagSystem.Tag.step_eq_stepP {k : ℕ} (ts : TagSystem.Tag k) (w : List (Fin k)) : ts.step w = TagSystem.stepP ts.productions w
By cases on the word: on fewer than two symbols both sides are none, and on
a :: b :: rest both are some (rest ++ ts.productions a).
A round processes the whole current word.
passOut P u is the concatenation of the productions of every other symbol of
u, starting with the first.
Lean code for Definition3.2.5●1 definition
Associated Lean declarations
-
TagSystem.passOut[complete]
-
TagSystem.passOut[complete]
-
defdefined in TagSystem/TagRounds.leancomplete
def TagSystem.passOut.{u} {σ : Type u} (P : σ → List σ) : List σ → List σ
def TagSystem.passOut.{u} {σ : Type u} (P : σ → List σ) : List σ → List σ
The productions of every other symbol, starting with the first.
Two facts describe a round.
For a word u of even length 2 * n and any pending tail t, n steps of
Definition 3.2.2 take u ++ t to t ++ passOut P u
(Definition 3.2.5): a word of even length is replaced by passOut
of it in half as many steps.
Lean code for Lemma3.2.6●1 theorem
Associated Lean declarations
-
TagSystem.nStepsP_even[complete]
-
TagSystem.nStepsP_even[complete]
-
theoremdefined in TagSystem/TagRounds.leancomplete
theorem TagSystem.nStepsP_even.{u} {σ : Type u} (P : σ → List σ) (n : ℕ) (u t : List σ) : u.length = 2 * n → TagSystem.nStepsP P (u ++ t) n = some (t ++ TagSystem.passOut P u)
theorem TagSystem.nStepsP_even.{u} {σ : Type u} (P : σ → List σ) (n : ℕ) (u t : List σ) : u.length = 2 * n → TagSystem.nStepsP P (u ++ t) n = some (t ++ TagSystem.passOut P u)
A round over a word of even length `2n`: `n` steps replace it by `passOut` of it, after whatever was pending.
Induction on n. Each step deletes one pair a b of u and appends P a,
which is the next block of passOut P u; the tail t is carried along in
front.
For a word u of even length 2 * n whose passOut P u is nonempty and a last
symbol z, n + 1 steps of Definition 3.2.2 take u ++ [z] to
(passOut P (u ++ [z])).tail: a word of odd length reads its last symbol
together with the first symbol of what was appended, so the result is
Definition 3.2.5 of it without its first symbol.
Lean code for Lemma3.2.7●1 theorem
Associated Lean declarations
-
TagSystem.nStepsP_odd[complete]
-
TagSystem.nStepsP_odd[complete]
-
theoremdefined in TagSystem/TagRounds.leancomplete
theorem TagSystem.nStepsP_odd.{u} {σ : Type u} (P : σ → List σ) (n : ℕ) (u : List σ) (z : σ) (hu : u.length = 2 * n) (hne : TagSystem.passOut P u ≠ []) : TagSystem.nStepsP P (u ++ [z]) (n + 1) = some (TagSystem.passOut P (u ++ [z])).tail
theorem TagSystem.nStepsP_odd.{u} {σ : Type u} (P : σ → List σ) (n : ℕ) (u : List σ) (z : σ) (hu : u.length = 2 * n) (hne : TagSystem.passOut P u ≠ []) : TagSystem.nStepsP P (u ++ [z]) (n + 1) = some (TagSystem.passOut P (u ++ [z])).tail
A round over a word of odd length `2n + 1` whose first productions are not all empty: `n + 1` steps replace it by `passOut` of it without its first symbol (the last symbol read takes the first appended symbol as its deleted partner).
The even round Lemma 3.2.6 on u with the pending tail
[z] leaves z :: passOut P u after n steps. One more step reads z and deletes with it
the first symbol of passOut P u, which exists by the hypothesis, and appends
P z; the result is passOut P (u ++ [z]) without its first symbol.
After an odd round the frame of the next round is shifted by one, and that round
reads the second of every pair. This one dropped symbol is the whole mechanism of
the construction. The computation lemmas give passOut on aligned pairs
(TagSystem.passOut_pairs2), on pairs read after a leading symbol
(TagSystem.passOut_cons_pairs2) and on runs of one symbol
(TagSystem.passOut_cons_replicate_append: a symbol, half the run rounded down,
then the rest read from its first or second symbol by the run's parity).
3.3. The Cocke-Minsky construction
TagSystem/CockeMinsky.lean. The configuration (q, left, head, right) of the
machine is the word
A_q x (al_q x)^m B_q x (be_q x)^N, m = val left, N = head + 2 * val right,
with the scanned cell the lowest bit of the right number.
The kinds of symbols, 21 of them: A, al, B, be of the configuration
word; P1, P0, p, Q, r after round 1; E, e, F, f after round 2;
G, g, H, k after round 3 of a move to the left; I, i, J, j
after round 4.
Lean code for Definition3.3.1●1 definition
Associated Lean declarations
-
TagSystem.Kind[complete]
-
TagSystem.Kind[complete]
-
inductivedefined in TagSystem/CockeMinsky.leancomplete
inductive TagSystem.Kind : Type
inductive TagSystem.Kind : Type
The kinds of symbols.
Constructors
TagSystem.Kind.A : TagSystem.Kind
TagSystem.Kind.al : TagSystem.Kind
TagSystem.Kind.B : TagSystem.Kind
TagSystem.Kind.be : TagSystem.Kind
TagSystem.Kind.P1 : TagSystem.Kind
TagSystem.Kind.P0 : TagSystem.Kind
TagSystem.Kind.p : TagSystem.Kind
TagSystem.Kind.Q : TagSystem.Kind
TagSystem.Kind.r : TagSystem.Kind
TagSystem.Kind.E : TagSystem.Kind
TagSystem.Kind.e : TagSystem.Kind
TagSystem.Kind.F : TagSystem.Kind
TagSystem.Kind.f : TagSystem.Kind
TagSystem.Kind.G : TagSystem.Kind
TagSystem.Kind.g : TagSystem.Kind
TagSystem.Kind.H : TagSystem.Kind
TagSystem.Kind.k : TagSystem.Kind
TagSystem.Kind.I : TagSystem.Kind
TagSystem.Kind.i : TagSystem.Kind
TagSystem.Kind.J : TagSystem.Kind
TagSystem.Kind.j : TagSystem.Kind
A symbol is the pad x (none; TagSystem.X) or a Definition 3.3.1
with a state and two bits: the scanned bit and the parity of the left number,
where the kind uses them.
Lean code for Definition3.3.2●1 definition
Associated Lean declarations
-
TagSystem.Sym[complete]
-
TagSystem.Sym[complete]
-
abbrevdefined in TagSystem/CockeMinsky.leancomplete
abbrev TagSystem.Sym : Type
abbrev TagSystem.Sym : Type
A symbol: the pad `x` (`none`), or a kind with a state and two bits (the scanned bit and the parity of the left number, where the kind uses them).
A tape half read as a number, nearest cell least significant:
val (a :: l) = a + 2 * val l.
Lean code for Definition3.3.3●1 definition
Associated Lean declarations
-
TagSystem.val[complete]
-
TagSystem.val[complete]
-
defdefined in TagSystem/CockeMinsky.leancomplete
def TagSystem.val : List ℕ → ℕ
def TagSystem.val : List ℕ → ℕ
A tape half as a number, nearest cell least significant.
The configuration word of a state q and two numbers m, N:
A_q x (al_q x)^m B_q x (be_q x)^N, a word over Definition 3.3.2 of
length 2 * (m + N + 2) (TagSystem.length_cword).
Lean code for Definition3.3.4●1 definition
Associated Lean declarations
-
TagSystem.cword[complete]
-
TagSystem.cword[complete]
-
defdefined in TagSystem/CockeMinsky.leancomplete
def TagSystem.cword (q m N : ℕ) : List TagSystem.Sym
def TagSystem.cword (q m N : ℕ) : List TagSystem.Sym
The configuration word.
The word of a configuration c (Definition 2.3.1) is
Definition 3.3.4 at the state of c, m = val c.left and
N = c.head + 2 * val c.right (Definition 3.3.3). The scanned cell is
the lowest bit of the right number.
Lean code for Definition3.3.5●1 definition
Associated Lean declarations
-
TagSystem.word[complete]
-
TagSystem.word[complete]
-
defdefined in TagSystem/CockeMinsky.leancomplete
def TagSystem.word (c : BiTM.Config) : List TagSystem.Sym
def TagSystem.word (c : BiTM.Config) : List TagSystem.Sym
The word of a configuration.
A configuration (Definition 2.3.1) is valid when its tape holds bits: the scanned cell is below 2 and so is every cell of the left and of the right half.
Lean code for Definition3.3.6●1 definition
Associated Lean declarations
-
TagSystem.ValidCfg[complete]
-
TagSystem.ValidCfg[complete]
-
defdefined in TagSystem/CockeMinsky.leancomplete
def TagSystem.ValidCfg (c : BiTM.Config) : Prop
def TagSystem.ValidCfg (c : BiTM.Config) : Prop
The tape holds bits.
The configuration word (Definition 3.3.5) has at least 4 symbols: the tag system does not halt on it.
Lean code for Lemma3.3.7●1 theorem
Associated Lean declarations
-
TagSystem.length_word[complete]
-
TagSystem.length_word[complete]
-
theoremdefined in TagSystem/TMToCTS.leancomplete
theorem TagSystem.length_word (c : BiTM.Config) : 4 ≤ (TagSystem.word c).length
theorem TagSystem.length_word (c : BiTM.Config) : 4 ≤ (TagSystem.word c).length
The configuration word is never short: the tag system does not halt on it.
The word is A x ... B x ..., of length 2 * (m + N + 2).
One machine step is three or five rounds of the tag system.
The productions of the tag system of a machine tm (Definition 2.2.3) on
Definition 3.3.2: the pad produces nothing; A -> P1 P0, al -> p p,
B -> Q, be -> r; the round-2 productions split each symbol into a pair
indexed by the scanned bit (P1 -> E1 E0, p -> e1 e0, Q -> F1 F0,
r -> f1 f0, and P0 produces nothing); the round-3 productions consult
tm.transition at (q, h) and write the next configuration word for a move to
the right, or G, g, H, k symbols for a move to the left; the round-4
productions split again by the parity of the left number; and the round-5
productions write the next configuration word. The production of the first
symbol read in round 3 (E) and in round 5 (I) carries a leading pad x
when the frame is shifted (TagSystem.pad).
Lean code for Definition3.3.8●1 definition
Associated Lean declarations
-
TagSystem.prod[complete]
-
TagSystem.prod[complete]
-
defdefined in TagSystem/CockeMinsky.leancomplete
def TagSystem.prod (tm : TM.Machine) : TagSystem.Sym → List TagSystem.Sym
def TagSystem.prod (tm : TM.Machine) : TagSystem.Sym → List TagSystem.Sym
The productions.
Round 1 (A -> P1 P0, al -> p p, B -> Q, be -> r): m + N + 2 steps of
Definition 3.2.2 with Definition 3.3.8 take
Definition 3.3.4 q m N to P1 P0 (p p)^m Q r^N, whose length
2 * m + N + 3 has the parity of N + 1.
Lean code for Lemma3.3.9●1 theorem
Associated Lean declarations
-
TagSystem.round1[complete]
-
TagSystem.round1[complete]
-
theoremdefined in TagSystem/CockeMinsky.leancomplete
theorem TagSystem.round1 (tm : TM.Machine) (q m N : ℕ) : TagSystem.nStepsP (TagSystem.prod tm) (TagSystem.cword q m N) (m + N + 2) = some (TagSystem.W1 q m N)
theorem TagSystem.round1 (tm : TM.Machine) (q m N : ℕ) : TagSystem.nStepsP (TagSystem.prod tm) (TagSystem.cword q m N) (m + N + 2) = some (TagSystem.W1 q m N)
The even round Lemma 3.2.6 on the whole word, of even
length 2 * (m + N + 2), and the computation of Definition 3.2.5
on the aligned pairs.
Round 2 reads P1, m of the p, Q and N / 2 of the r: m + N / 2 + 2
steps take the word after Lemma 3.3.9 to the pairs
E1 E0 (e1 e0)^m F1 F0 (f1 f0)^(N / 2) in the frame of h = N mod 2. When
N is even the round has odd length, its last read takes E1 as its deleted
partner, and round 3 reads the second of every pair: every symbol read in round
3 knows the scanned bit h, and N has lost its lowest bit.
Lean code for Lemma3.3.10●1 theorem
Associated Lean declarations
-
TagSystem.round2[complete]
-
TagSystem.round2[complete]
-
theoremdefined in TagSystem/CockeMinsky.leancomplete
theorem TagSystem.round2 (tm : TM.Machine) (q m N : ℕ) : TagSystem.nStepsP (TagSystem.prod tm) (TagSystem.W1 q m N) (m + N / 2 + 2) = some (TagSystem.W2 q (decide (N % 2 = 1)) m (N / 2))
theorem TagSystem.round2 (tm : TM.Machine) (q m N : ℕ) : TagSystem.nStepsP (TagSystem.prod tm) (TagSystem.W1 q m N) (m + N / 2 + 2) = some (TagSystem.W2 q (decide (N % 2 = 1)) m (N / 2))
By the parity of N: Lemma 3.2.7 (in its whole-word form
TagSystem.nStepsP_odd') when N is even, the word having odd length
2 * m + N + 3, and Lemma 3.2.6 when N is odd; with
Definition 3.2.5 on a run of r after a leading symbol
(TagSystem.passOut_W1).
Round 3 executes the transition (q, h) -> (q', w, d). For a move to the right
(d = R), m + N / 2 + 2 steps take the word after Lemma 3.3.10
directly to the next configuration word
Definition 3.3.4 q' (w + 2 * m) (N / 2), that is,
A_q' x (al x)^(w + 2m) B x (be x)^(N/2).
Lean code for Lemma3.3.11●1 theorem
Associated Lean declarations
-
TagSystem.round3R[complete]
-
TagSystem.round3R[complete]
-
theoremdefined in TagSystem/CockeMinsky.leancomplete
theorem TagSystem.round3R (tm : TM.Machine) (q : ℕ) (h : Bool) (m n2 : ℕ) (hd : TagSystem.dr tm q h = TM.Dir.R) : TagSystem.nStepsP (TagSystem.prod tm) (TagSystem.W2 q h m n2) (m + n2 + 2) = some (TagSystem.cword (TagSystem.nxt tm q h) (TagSystem.wr tm q h + 2 * m) n2)
theorem TagSystem.round3R (tm : TM.Machine) (q : ℕ) (h : Bool) (m n2 : ℕ) (hd : TagSystem.dr tm q h = TM.Dir.R) : TagSystem.nStepsP (TagSystem.prod tm) (TagSystem.W2 q h m n2) (m + n2 + 2) = some (TagSystem.cword (TagSystem.nxt tm q h) (TagSystem.wr tm q h + 2 * m) n2)
Round 3 of a move to the right.
The pass Definition 3.2.5 of the round-2 word is the next
configuration word, behind a leading pad when h is not set
(TagSystem.passOut_W2 and the right-move productions of
Definition 3.3.8). When h is set the word
has even length and the round is Lemma 3.2.6; when it is
not, the word has odd length, the round is Lemma 3.2.7
(TagSystem.nStepsP_odd'), and the dropped first symbol is the pad.
For a move to the left (d = L), m + N / 2 + 2 steps take the word after
Lemma 3.3.10 to G g^m H H k^(4 (N/2)).
Lean code for Lemma3.3.12●1 theorem
Associated Lean declarations
-
TagSystem.round3L[complete]
-
TagSystem.round3L[complete]
-
theoremdefined in TagSystem/CockeMinsky.leancomplete
theorem TagSystem.round3L (tm : TM.Machine) (q : ℕ) (h : Bool) (m n2 : ℕ) (hd : TagSystem.dr tm q h = TM.Dir.L) : TagSystem.nStepsP (TagSystem.prod tm) (TagSystem.W2 q h m n2) (m + n2 + 2) = some (TagSystem.W3 q h m n2)
theorem TagSystem.round3L (tm : TM.Machine) (q : ℕ) (h : Bool) (m n2 : ℕ) (hd : TagSystem.dr tm q h = TM.Dir.L) : TagSystem.nStepsP (TagSystem.prod tm) (TagSystem.W2 q h m n2) (m + n2 + 2) = some (TagSystem.W3 q h m n2)
Round 3 of a move to the left.
As for Lemma 3.3.11, with the left-move productions of
Definition 3.3.8: Definition 3.2.5 of the round-2 word is
G g^m H H k^(4 (N/2)) behind a leading pad when h is not set, consumed by
the odd round (Lemma 3.2.6 or
Lemma 3.2.7 by the parity of h).
Round 4 halves m and reads its parity into the frame of round 5:
m / 2 + 2 * (N / 2) + 2 steps take the word after Lemma 3.3.12
to pairs I1 I0 (i1 i0)^(m/2) J1 J0 (j1 j0)^(2 (N/2)) in the frame of
b = m mod 2.
Lean code for Lemma3.3.13●1 theorem
Associated Lean declarations
-
TagSystem.round4[complete]
-
TagSystem.round4[complete]
-
theoremdefined in TagSystem/CockeMinsky.leancomplete
theorem TagSystem.round4 (tm : TM.Machine) (q : ℕ) (h : Bool) (m n2 : ℕ) : TagSystem.nStepsP (TagSystem.prod tm) (TagSystem.W3 q h m n2) (m / 2 + 2 * n2 + 2) = some (TagSystem.W4 q h (decide (m % 2 = 1)) (m / 2) n2)
theorem TagSystem.round4 (tm : TM.Machine) (q : ℕ) (h : Bool) (m n2 : ℕ) : TagSystem.nStepsP (TagSystem.prod tm) (TagSystem.W3 q h m n2) (m / 2 + 2 * n2 + 2) = some (TagSystem.W4 q h (decide (m % 2 = 1)) (m / 2) n2)
By the parity of m, as in Lemma 3.3.10:
Lemma 3.2.7 (TagSystem.nStepsP_odd') when m is even
and Lemma 3.2.6 when it is odd, with
Definition 3.2.5 on the two runs (TagSystem.passOut_W3).
Round 5 writes the next configuration word of a move to the left:
m / 2 + 2 * (N / 2) + 2 steps take the word after Lemma 3.3.13
to Definition 3.3.4 q' (m / 2) (2 * w + b + 4 * (N / 2)), that
is, A_q' x (al x)^(m/2) B x (be x)^(2w + (m mod 2) + 4 (N/2)).
Lean code for Lemma3.3.14●1 theorem
Associated Lean declarations
-
TagSystem.round5[complete]
-
TagSystem.round5[complete]
-
theoremdefined in TagSystem/CockeMinsky.leancomplete
theorem TagSystem.round5 (tm : TM.Machine) (q : ℕ) (h b : Bool) (i n2 : ℕ) : TagSystem.nStepsP (TagSystem.prod tm) (TagSystem.W4 q h b i n2) (i + 2 * n2 + 2) = some (TagSystem.cword (TagSystem.nxt tm q h) i (2 * TagSystem.wr tm q h + TagSystem.bit b + 4 * n2))
theorem TagSystem.round5 (tm : TM.Machine) (q : ℕ) (h b : Bool) (i n2 : ℕ) : TagSystem.nStepsP (TagSystem.prod tm) (TagSystem.W4 q h b i n2) (i + 2 * n2 + 2) = some (TagSystem.cword (TagSystem.nxt tm q h) i (2 * TagSystem.wr tm q h + TagSystem.bit b + 4 * n2))
As for Lemma 3.3.11: Definition 3.2.5 of the round-4
word is the next configuration word, behind a leading pad when b is not set
(TagSystem.passOut_W4); the round is Lemma 3.2.6 when
b is set and Lemma 3.2.7 (TagSystem.nStepsP_odd'),
dropping the pad, when it is not.
Whenever a round reads the second of each pair, the production of the first
symbol read carries a leading pad x that the odd round before it consumes, so
the tag word at the start of every machine step is exactly the configuration
word.
For a valid configuration c (Definition 3.3.6) whose transition
writes a bit, and a step c' of the machine from c (Definition 2.3.3),
there is a k with 1 <= k such that k steps of Definition 3.2.2
with the productions Definition 3.3.8 take Definition 3.3.5
c to word c'.
Lean code for Theorem3.3.15●1 theorem
Associated Lean declarations
-
TagSystem.tm_step_tag[complete]
-
TagSystem.tm_step_tag[complete]
-
theoremdefined in TagSystem/CockeMinsky.leancomplete
theorem TagSystem.tm_step_tag (tm : TM.Machine) (c c' : BiTM.Config) (hv : TagSystem.ValidCfg c) (hb : (tm.transition c.state c.head).write < 2) (hs : BiTM.step tm c = some c') : ∃ k, 1 ≤ k ∧ TagSystem.nStepsP (TagSystem.prod tm) (TagSystem.word c) k = some (TagSystem.word c')
theorem TagSystem.tm_step_tag (tm : TM.Machine) (c c' : BiTM.Config) (hv : TagSystem.ValidCfg c) (hb : (tm.transition c.state c.head).write < 2) (hs : BiTM.step tm c = some c') : ∃ k, 1 ≤ k ∧ TagSystem.nStepsP (TagSystem.prod tm) (TagSystem.word c) k = some (TagSystem.word c')
One step of the machine is three or five rounds of the tag system.
By cases on the direction of the transition. For a move to the right the rounds
Lemma 3.3.9, Lemma 3.3.10 and
Lemma 3.3.11 compose, with k the sum of their step counts
m + N + 2, m + N / 2 + 2, m + N / 2 + 2; for a move to the left the five
rounds Lemma 3.3.9, Lemma 3.3.10,
Lemma 3.3.12, Lemma 3.3.13 and
Lemma 3.3.14 compose, the last two of m / 2 + 2 * (N / 2) + 2
steps each. The scanned bit is N mod 2 and the right number without it is
val right, since c is valid; the new configuration of
Definition 2.3.3 has the numbers the rounds produce (TagSystem.step_R,
TagSystem.step_L, TagSystem.val_readHead).
The step counts are explicit in the proof. They grow with the numbers m and
N, that is, exponentially in the tape length. The construction was validated by
a Python simulation of random machines before it was proved.
3.4. The finite alphabet and the cyclic tag system
enc S sends the symbols (Definition 3.3.2) whose state is below S
injectively into Fin (1 + 84 * S): the pad to 0, a kind with a state and two
bits to 1 + ((kind index * S + state) * 4 + bits).
Lean code for Definition3.4.1●1 definition
Associated Lean declarations
-
TagSystem.enc[complete]
-
TagSystem.enc[complete]
-
defdefined in TagSystem/TMToCTS.leancomplete
def TagSystem.enc (S : ℕ) (s : TagSystem.Sym) : Fin (1 + 84 * S)
def TagSystem.enc (S : ℕ) (s : TagSystem.Sym) : Fin (1 + 84 * S)
The encoding of a symbol.
dec S inverts Definition 3.4.1: 0 is the pad, and any other index is
read back as a kind, a state below S and two bits.
Lean code for Definition3.4.2●1 definition
Associated Lean declarations
-
TagSystem.dec[complete]
-
TagSystem.dec[complete]
-
defdefined in TagSystem/TMToCTS.leancomplete
def TagSystem.dec (S : ℕ) (i : Fin (1 + 84 * S)) : TagSystem.Sym
def TagSystem.dec (S : ℕ) (i : Fin (1 + 84 * S)) : TagSystem.Sym
The decoding of a symbol.
For a kind, a state q < S and two bits, Definition 3.4.2 S after
Definition 3.4.1 S is the identity (and TagSystem.dec_enc_X for
the pad).
Lean code for Lemma3.4.3●1 theorem
Associated Lean declarations
-
TagSystem.dec_enc[complete]
-
TagSystem.dec_enc[complete]
-
theoremdefined in TagSystem/TMToCTS.leancomplete
theorem TagSystem.dec_enc (S : ℕ) (kd : TagSystem.Kind) (q : ℕ) (h b : Bool) (hq : q < S) : TagSystem.dec S (TagSystem.enc S (some (kd, q, h, b))) = some (kd, q, h, b)
theorem TagSystem.dec_enc (S : ℕ) (kd : TagSystem.Kind) (q : ℕ) (h b : Bool) (hq : q < S) : TagSystem.dec S (TagSystem.enc S (some (kd, q, h, b))) = some (kd, q, h, b)
Arithmetic on the index, which is below 1 + 84 * S (TagSystem.symIdx_lt,
from the 21 kinds and the 4 bit patterns).
WordOK S w says all states of the word w are below S
(TagSystem.SymOK on every symbol).
Lean code for Definition3.4.4●1 definition
Associated Lean declarations
-
TagSystem.WordOK[complete]
-
TagSystem.WordOK[complete]
-
defdefined in TagSystem/TMToCTS.leancomplete
def TagSystem.WordOK (S : ℕ) (w : List TagSystem.Sym) : Prop
def TagSystem.WordOK (S : ℕ) (w : List TagSystem.Sym) : Prop
The productions Definition 3.3.8 preserve Definition 3.4.4
S when the transitions do: if the next state from every state below S is
below S, then the production of a symbol with state below S is a word with
states below S.
Lean code for Lemma3.4.5●1 theorem
Associated Lean declarations
-
TagSystem.prod_OK[complete]
-
TagSystem.prod_OK[complete]
-
theoremdefined in TagSystem/TMToCTS.leancomplete
theorem TagSystem.prod_OK (tm : TM.Machine) (S : ℕ) (hn : ∀ (q : ℕ) (h : Bool), q < S → TagSystem.nxt tm q h < S) (s : TagSystem.Sym) (hs : TagSystem.SymOK S s) : TagSystem.WordOK S (TagSystem.prod tm s)
theorem TagSystem.prod_OK (tm : TM.Machine) (S : ℕ) (hn : ∀ (q : ℕ) (h : Bool), q < S → TagSystem.nxt tm q h < S) (s : TagSystem.Sym) (hs : TagSystem.SymOK S s) : TagSystem.WordOK S (TagSystem.prod tm s)
The productions keep the states below `S` when the transitions do.
By cases on the kind of the symbol; every state in a production is the state of the symbol or the next state of the transition.
tagK tm S is the resulting Tag (1 + 84 * S): the production of an index is
Definition 3.3.8 of its Definition 3.4.2, mapped by
Definition 3.4.1.
Lean code for Definition3.4.6●1 definition
Associated Lean declarations
-
TagSystem.tagK[complete]
-
TagSystem.tagK[complete]
-
defdefined in TagSystem/TMToCTS.leancomplete
def TagSystem.tagK (tm : TM.Machine) (S : ℕ) : TagSystem.Tag (1 + 84 * S)
def TagSystem.tagK (tm : TM.Machine) (S : ℕ) : TagSystem.Tag (1 + 84 * S)
The Cocke-Minsky tag system with states below `S`, on `Fin (1 + 84 S)`.
Runs are carried over: when the transitions keep the states below S, k
steps of Definition 3.2.2 with the productions of
Definition 3.4.6 tm S from the encoding of a word w with
Definition 3.4.4 S are the encoding of k steps with
Definition 3.3.8 from w.
Lean code for Lemma3.4.7●1 theorem
Associated Lean declarations
-
TagSystem.nStepsP_enc[complete]
-
TagSystem.nStepsP_enc[complete]
-
theoremdefined in TagSystem/TMToCTS.leancomplete
theorem TagSystem.nStepsP_enc (tm : TM.Machine) (S : ℕ) (hn : ∀ (q : ℕ) (h : Bool), q < S → TagSystem.nxt tm q h < S) (k : ℕ) (w : List TagSystem.Sym) : TagSystem.WordOK S w → TagSystem.nStepsP (TagSystem.tagK tm S).productions (List.map (TagSystem.enc S) w) k = Option.map (List.map (TagSystem.enc S)) (TagSystem.nStepsP (TagSystem.prod tm) w k)
theorem TagSystem.nStepsP_enc (tm : TM.Machine) (S : ℕ) (hn : ∀ (q : ℕ) (h : Bool), q < S → TagSystem.nxt tm q h < S) (k : ℕ) (w : List TagSystem.Sym) : TagSystem.WordOK S w → TagSystem.nStepsP (TagSystem.tagK tm S).productions (List.map (TagSystem.enc S) w) k = Option.map (List.map (TagSystem.enc S)) (TagSystem.nStepsP (TagSystem.prod tm) w k)
Induction on k; one step commutes with the encoding (TagSystem.stepP_enc, by
Lemma 3.4.3 on the symbol read) and keeps WordOK
(TagSystem.stepP_OK, by Lemma 3.4.5).
Cook's encoding turns a tag system on k symbols into a cyclic tag system with
2k appendants.
The cyclic tag system of a tag system ts on k > 0 symbols: symbol i is the
one-hot word of length k (TagSystem.symbolEncode; a tag word is the
concatenation, TagSystem.tagWordEncode), the first k appendants are the
encoded productions, the next k are empty (they consume the second deleted
symbol). TagSystem.tagConfigToCTS encodes a tag word as a cyclic tag
configuration at phase 0.
Lean code for Definition3.4.8●1 definition
Associated Lean declarations
-
TagSystem.tagToCTS[complete]
-
TagSystem.tagToCTS[complete]
-
defdefined in TagSystem/TagToCTS.leancomplete
def TagSystem.tagToCTS {k : ℕ} (ts : TagSystem.Tag k) (hk : k > 0) : TagSystem.CTS
def TagSystem.tagToCTS {k : ℕ} (ts : TagSystem.Tag k) (hk : k > 0) : TagSystem.CTS
Construct a Cyclic Tag System that simulates a given 2-tag system. Cook's encoding uses **2k appendants** (not k): - Appendants 0..k-1: encode production(a_j) as tagWordEncode k (productions(a_j)) - Appendants k..2k-1: all empty (consume the second deleted symbol silently) One 2-tag step on word `a :: b :: rest -> rest ++ productions(a)` corresponds to 2k CTS steps: - First k steps process `symbolEncode k a`: the one-hot bit at position a.val fires appendant[a.val] = tagWordEncode(productions(a)), appending the correct production - Next k steps process `symbolEncode k b`: the one-hot bit at position b.val fires appendant[k + b.val] = [] (empty), so nothing is appended Reference: Cook, "Universality in Elementary Cellular Automata" (2004).
The cyclic tag system Definition 3.4.8 has exactly 2 * k
appendants.
Lean code for Lemma3.4.9●1 theorem
Associated Lean declarations
-
TagSystem.tagToCTS_appendants_length[complete]
-
TagSystem.tagToCTS_appendants_length[complete]
-
theoremdefined in TagSystem/TagToCTS.leancomplete
theorem TagSystem.tagToCTS_appendants_length {k : ℕ} (ts : TagSystem.Tag k) (hk : k > 0) : (TagSystem.tagToCTS ts hk).appendants.length = 2 * k
theorem TagSystem.tagToCTS_appendants_length {k : ℕ} (ts : TagSystem.Tag k) (hk : k > 0) : (TagSystem.tagToCTS ts hk).appendants.length = 2 * k
The constructed CTS has exactly 2*k appendants
Two lists of length k.
One tag step is 2k cyclic tag steps: if Definition 3.2.3 takes
cfg to cfg', then 2 * k steps of Definition 3.4.8 take the
encoding of cfg to the encoding of cfg'.
Lean code for Lemma3.4.10●1 theorem
Associated Lean declarations
-
TagSystem.tagToCTS_simulation[complete]
-
TagSystem.tagToCTS_simulation[complete]
-
theoremdefined in TagSystem/TagToCTS.leancomplete
theorem TagSystem.tagToCTS_simulation {k : ℕ} (ts : TagSystem.Tag k) (hk : k > 0) (cfg cfg' : TagSystem.TagConfig k) : ts.step cfg = some cfg' → (TagSystem.tagToCTS ts hk).nSteps (TagSystem.tagConfigToCTS k cfg) (2 * k) = some (TagSystem.tagConfigToCTS k cfg')
theorem TagSystem.tagToCTS_simulation {k : ℕ} (ts : TagSystem.Tag k) (hk : k > 0) (cfg cfg' : TagSystem.TagConfig k) : ts.step cfg = some cfg' → (TagSystem.tagToCTS ts hk).nSteps (TagSystem.tagConfigToCTS k cfg) (2 * k) = some (TagSystem.tagConfigToCTS k cfg')
The first k steps process the one-hot block of the first symbol a: its
single true fires appendant a, the encoded production. The next k steps
process the block of the second symbol b: its true fires appendant k + b,
which is empty. The phase returns to 0 modulo 2k.
k tag steps are 2 * K * k cyclic tag steps: for a tag system ts on
K > 0 symbols, if k steps of Definition 3.2.2 with
ts.productions take w to w', then 2 * K * k steps of
Definition 3.4.8 take the encoding of w to the encoding of w'.
Lean code for Lemma3.4.11●1 theorem
Associated Lean declarations
-
TagSystem.cts_of_tag[complete]
-
TagSystem.cts_of_tag[complete]
-
theoremdefined in TagSystem/TMToCTS.leancomplete
theorem TagSystem.cts_of_tag {K : ℕ} (ts : TagSystem.Tag K) (hK : K > 0) (k : ℕ) (w w' : List (Fin K)) : TagSystem.nStepsP ts.productions w k = some w' → (TagSystem.tagToCTS ts hK).nSteps (TagSystem.tagConfigToCTS K w) (2 * K * k) = some (TagSystem.tagConfigToCTS K w')
theorem TagSystem.cts_of_tag {K : ℕ} (ts : TagSystem.Tag K) (hK : K > 0) (k : ℕ) (w w' : List (Fin K)) : TagSystem.nStepsP ts.productions w k = some w' → (TagSystem.tagToCTS ts hK).nSteps (TagSystem.tagConfigToCTS K w) (2 * K * k) = some (TagSystem.tagConfigToCTS K w')
`k` tag steps are `2 K k` cyclic tag steps.
Induction on k, one step by Lemma 3.4.10 through
Lemma 3.2.4.
A well-formed binary machine tm (Definition 2.2.3): from every state
below numStates (the halt state 0 included), reading a bit, the machine writes
a bit and moves to a state below numStates. The predicate is decidable.
Lean code for Definition3.4.12●1 definition
Associated Lean declarations
-
TagSystem.WF[complete]
-
TagSystem.WF[complete]
-
defdefined in TagSystem/TMToCTS.leancomplete
def TagSystem.WF (tm : TM.Machine) : Prop
def TagSystem.WF (tm : TM.Machine) : Prop
A well-formed binary machine: from a state below `numStates` reading a bit, it writes a bit and moves to a state below `numStates`. The quantifier `q < numStates` includes `q = 0`, the halt state that `BiTM.step` never executes: the tag productions `prod` are defined on the state-0 symbols too and keep applying `tm.transition 0 _` after the machine halts, so the transport lemmas (`prod_OK`, `stepP_OK`, `nStepsP_enc`) need that row in range as well.
For a well-formed machine (Definition 3.4.12), a step
(Definition 2.3.3) from a valid configuration (Definition 3.3.6)
with state below numStates is valid with state below numStates.
Lean code for Lemma3.4.13●1 theorem
Associated Lean declarations
-
TagSystem.step_valid[complete]
-
TagSystem.step_valid[complete]
-
theoremdefined in TagSystem/TMToCTS.leancomplete
theorem TagSystem.step_valid (tm : TM.Machine) (hwf : TagSystem.WF tm) (c c' : BiTM.Config) (hv : TagSystem.ValidCfg c) (hst : c.state < tm.numStates) (hs : BiTM.step tm c = some c') : TagSystem.ValidCfg c' ∧ c'.state < tm.numStates
theorem TagSystem.step_valid (tm : TM.Machine) (hwf : TagSystem.WF tm) (c c' : BiTM.Config) (hv : TagSystem.ValidCfg c) (hst : c.state < tm.numStates) (hs : BiTM.step tm c = some c') : TagSystem.ValidCfg c' ∧ c'.state < tm.numStates
A step keeps the configuration valid and its state below `numStates`.
The written cell is a bit and the next state is below numStates by WF; the
cell moved onto is a cell of the tape or a blank.
The encoding of a configuration as a cyclic tag configuration:
Definition 3.3.5 c, mapped by Definition 3.4.1 S, encoded
as a cyclic tag configuration over 1 + 84 * S symbols
(TagSystem.tagConfigToCTS).
Lean code for Definition3.4.14●1 definition
Associated Lean declarations
-
TagSystem.ctsOfCfg[complete]
-
TagSystem.ctsOfCfg[complete]
-
defdefined in TagSystem/TMToCTS.leancomplete
def TagSystem.ctsOfCfg (S : ℕ) (c : BiTM.Config) : TagSystem.CTSConfig
def TagSystem.ctsOfCfg (S : ℕ) (c : BiTM.Config) : TagSystem.CTSConfig
The encoding of a configuration as a cyclic tag configuration.
Both simulations are stated as forward simulations (Definition 4.2.3,
the calculus of the chapter on cyclic tag to System 5)
between step systems (Definition 4.2.1): the machine is the step system
TagSystem.tmSys tm (its nSteps is BiTM.nSteps, TagSystem.tmSys_nSteps),
the cyclic tag system is Smith.ctsSys of it, and the tag system on the finite
alphabet is TagSystem.tagSysK tm S.
For a well-formed machine tm (Definition 3.4.12), the cyclic tag system
Definition 3.4.8 of Definition 3.4.6 tm tm.numStates
forward-simulates (Definition 4.2.3) the machine along the relation
"c is valid (Definition 3.3.6), its state is below numStates,
and d = ctsOfCfg tm.numStates c" (Definition 3.4.14).
Lean code for Theorem3.4.15●1 theorem
Associated Lean declarations
-
TagSystem.tm_cts_forwardSim[complete]
-
TagSystem.tm_cts_forwardSim[complete]
-
theoremdefined in TagSystem/TMToCTS.leancomplete
theorem TagSystem.tm_cts_forwardSim (tm : TM.Machine) (hwf : TagSystem.WF tm) : Smith.ForwardSim (TagSystem.tmSys tm) (Smith.ctsSys (TagSystem.tagToCTS (TagSystem.tagK tm tm.numStates) ⋯)) fun c d => TagSystem.ValidCfg c ∧ c.state < tm.numStates ∧ d = TagSystem.ctsOfCfg tm.numStates c
theorem TagSystem.tm_cts_forwardSim (tm : TM.Machine) (hwf : TagSystem.WF tm) : Smith.ForwardSim (TagSystem.tmSys tm) (Smith.ctsSys (TagSystem.tagToCTS (TagSystem.tagK tm tm.numStates) ⋯)) fun c d => TagSystem.ValidCfg c ∧ c.state < tm.numStates ∧ d = TagSystem.ctsOfCfg tm.numStates c
T7 as a `ForwardSim`: the cyclic tag system `tagToCTS (tagK tm S)` tracks the machine through the encoding of configurations.
A step of the machine is k >= 1 tag steps on word c by
Theorem 3.3.15 (the write is a bit by WF).
Lemma 3.4.7 carries them onto the finite alphabet (the
states stay below numStates by WF, TagSystem.WF_nxt, and the configuration
word satisfies WordOK, TagSystem.WordOK_cword), and
Lemma 3.4.11 onto 2 * (1 + 84 * numStates) * k cyclic tag
steps. Lemma 3.4.13 keeps the relation.
For a well-formed machine tm (Definition 3.4.12), the tag system
Definition 3.4.6 tm tm.numStates on the finite alphabet
forward-simulates (Definition 4.2.3) the machine along the relation
"c is valid (Definition 3.3.6), its state is below numStates,
and w is Definition 3.3.5 c mapped by Definition 3.4.1
tm.numStates".
Lean code for Theorem3.4.16●1 theorem
Associated Lean declarations
-
TagSystem.tm_tag_forwardSim[complete]
-
TagSystem.tm_tag_forwardSim[complete]
-
theoremdefined in TagSystem/TMToCTS.leancomplete
theorem TagSystem.tm_tag_forwardSim (tm : TM.Machine) (hwf : TagSystem.WF tm) : Smith.ForwardSim (TagSystem.tmSys tm) (TagSystem.tagSysK tm tm.numStates) fun c w => TagSystem.ValidCfg c ∧ c.state < tm.numStates ∧ w = List.map (TagSystem.enc tm.numStates) (TagSystem.word c)
theorem TagSystem.tm_tag_forwardSim (tm : TM.Machine) (hwf : TagSystem.WF tm) : Smith.ForwardSim (TagSystem.tmSys tm) (TagSystem.tagSysK tm tm.numStates) fun c w => TagSystem.ValidCfg c ∧ c.state < tm.numStates ∧ w = List.map (TagSystem.enc tm.numStates) (TagSystem.word c)
T7 at the tag level: the tag system `tagK tm S` tracks the machine through the encoding of configurations.
As for Theorem 3.4.15 without the last transport: Theorem 3.3.15, Lemma 3.4.7 and Lemma 3.4.13.
The tag-level simulation TagSystem.tm_tag_forwardSim is what
the chapter on the composition uses, because the number of
cyclic tag cycles must be the number of tag steps.
3.5. The decoder
TagSystem.decodeCTS S d reads the one-hot blocks of the cyclic tag word back
as tag symbols, the symbols as a configuration word, and the two numbers as tape
halves. It returns the configuration without trailing blanks.
The symbol of a one-hot block: symbolDecode k l is the position of the single
true of l as an element of Fin k, and none unless l has length exactly
k and holds a single true (TagSystem.symbolDecodeAux).
Lean code for Definition3.5.1●1 definition
Associated Lean declarations
-
TagSystem.symbolDecode[complete]
-
TagSystem.symbolDecode[complete]
-
defdefined in TagSystem/TMToCTS.leancomplete
def TagSystem.symbolDecode (k : ℕ) (l : List Bool) : Option (Fin k)
def TagSystem.symbolDecode (k : ℕ) (l : List Bool) : Option (Fin k)
The symbol of a one-hot block: `none` unless the block has length exactly `k` and holds a single `true`.
The block decoder Definition 3.5.1 accepts exactly the one-hot
blocks of length k: if symbolDecode k l = some a then
l = symbolEncode k a. (Completeness,
TagSystem.symbolDecode_encode: symbolDecode k (symbolEncode k a) = some a.)
Lean code for Lemma3.5.2●1 theorem
Associated Lean declarations
-
TagSystem.symbolDecode_sound[complete]
-
TagSystem.symbolDecode_sound[complete]
-
theoremdefined in TagSystem/TMToCTS.leancomplete
theorem TagSystem.symbolDecode_sound (k : ℕ) (l : List Bool) (a : Fin k) (h : TagSystem.symbolDecode k l = some a) : l = TagSystem.symbolEncode k a
theorem TagSystem.symbolDecode_sound (k : ℕ) (l : List Bool) (a : Fin k) (h : TagSystem.symbolDecode k l = some a) : l = TagSystem.symbolEncode k a
A block `symbolDecode` accepts is the encoding of the symbol it returns.
l has length k and symbolDecodeAux found its true at position a with
only false before and after it (TagSystem.symbolDecodeAux_sound), which is
the one-hot word of a.
The one-hot blocks of a cyclic tag word as tag symbols: tagWordDecode k hk l
splits l into blocks of length k, decodes each by
Definition 3.5.1, and is none unless l is a sequence of
whole blocks of length k, each one-hot.
Lean code for Definition3.5.3●1 definition
Associated Lean declarations
-
TagSystem.tagWordDecode[complete]
-
TagSystem.tagWordDecode[complete]
-
defdefined in TagSystem/TMToCTS.leancomplete
def TagSystem.tagWordDecode (k : ℕ) (hk : 0 < k) (l : List Bool) : Option (List (Fin k))
def TagSystem.tagWordDecode (k : ℕ) (hk : 0 < k) (l : List Bool) : Option (List (Fin k))
The one-hot blocks of a cyclic tag word as tag symbols: `none` unless the word is a sequence of whole blocks of length `k`, each one-hot.
The word decoder Definition 3.5.3 accepts exactly the
concatenations of one-hot blocks: if tagWordDecode k hk l = some w then
l = tagWordEncode k w.
(Completeness, TagSystem.tagWordDecode_encode:
tagWordDecode k hk (tagWordEncode k w) = some w.)
Lean code for Lemma3.5.4●1 theorem
Associated Lean declarations
-
TagSystem.tagWordDecode_sound[complete]
-
TagSystem.tagWordDecode_sound[complete]
-
theoremdefined in TagSystem/TMToCTS.leancomplete
theorem TagSystem.tagWordDecode_sound (k : ℕ) (hk : 0 < k) (l : List Bool) (w : List (Fin k)) : TagSystem.tagWordDecode k hk l = some w → l = TagSystem.tagWordEncode k w
theorem TagSystem.tagWordDecode_sound (k : ℕ) (hk : 0 < k) (l : List Bool) (w : List (Fin k)) : TagSystem.tagWordDecode k hk l = some w → l = TagSystem.tagWordEncode k w
A word `tagWordDecode` accepts is the encoding of the tag word it returns: the decoder is the inverse of `tagWordEncode` and rejects every other word.
Induction along the blocks, each block by Lemma 3.5.2.
The state and the two numbers of a configuration word: parseWord w reads
A_q x, counts the pairs al_q x (TagSystem.countPairs), reads B_q x with
the same state, counts the pairs be_q x, and requires nothing to remain; it
returns (q, m, N). On Definition 3.3.4 q m N it returns
some (q, m, N) (TagSystem.parseWord_cword).
Lean code for Definition3.5.5●1 definition
Associated Lean declarations
-
TagSystem.parseWord[complete]
-
TagSystem.parseWord[complete]
-
defdefined in TagSystem/TMToCTS.leancomplete
def TagSystem.parseWord (w : List TagSystem.Sym) : Option (ℕ × ℕ × ℕ)
def TagSystem.parseWord (w : List TagSystem.Sym) : Option (ℕ × ℕ × ℕ)
The state and the two numbers of a configuration word.
The binary digits of a number, least significant first, without trailing zeros:
natBits 0 = [] and natBits n = n % 2 :: natBits (n / 2) otherwise. It
inverts Definition 3.3.3: val (natBits n) = n
(TagSystem.val_natBits), and its digits are bits (TagSystem.natBits_lt).
Lean code for Definition3.5.6●1 definition
Associated Lean declarations
-
TagSystem.natBits[complete]
-
TagSystem.natBits[complete]
-
defdefined in TagSystem/TMToCTS.leancomplete
def TagSystem.natBits (n : ℕ) : List ℕ
def TagSystem.natBits (n : ℕ) : List ℕ
The binary digits of a number, least significant first, without trailing zeros.
A configuration (Definition 2.3.1) without trailing blanks on either side: the same state and scanned cell, and each tape half replaced by Definition 3.5.6 of its Definition 3.3.3.
Lean code for Definition3.5.7●1 definition
Associated Lean declarations
-
TagSystem.canon[complete]
-
TagSystem.canon[complete]
-
defdefined in TagSystem/TMToCTS.leancomplete
def TagSystem.canon (c : BiTM.Config) : BiTM.Config
def TagSystem.canon (c : BiTM.Config) : BiTM.Config
A configuration without trailing blanks on either side.
The decoder of a cyclic tag configuration d with parameter S: the data of
d is read as tag symbols over 1 + 84 * S by
Definition 3.5.3, the symbols are mapped by
Definition 3.4.2 S, the word is parsed by Definition 3.5.5
and the numbers (q, m, N) become the configuration with state q, left half
Definition 3.5.6 m, scanned cell N % 2 and right half
natBits (N / 2) (TagSystem.decodeWord, TagSystem.cfgOfNums).
Lean code for Definition3.5.8●1 definition
Associated Lean declarations
-
TagSystem.decodeCTS[complete]
-
TagSystem.decodeCTS[complete]
-
defdefined in TagSystem/TMToCTS.leancomplete
def TagSystem.decodeCTS (S : ℕ) (d : TagSystem.CTSConfig) : Option BiTM.Config
def TagSystem.decodeCTS (S : ℕ) (d : TagSystem.CTSConfig) : Option BiTM.Config
The decoder of the cyclic tag configuration: the one-hot blocks as tag symbols, the tag symbols as a configuration word, its numbers as the tape halves.
For a valid configuration c (Definition 3.3.6) with state below
S, Definition 3.5.8 S of Definition 3.4.14 S c
is some (canon c) (Definition 3.5.7).
Lean code for Theorem3.5.9●1 theorem
Associated Lean declarations
-
TagSystem.decodeCTS_word[complete]
-
TagSystem.decodeCTS_word[complete]
-
theoremdefined in TagSystem/TMToCTS.leancomplete
theorem TagSystem.decodeCTS_word (S : ℕ) (c : BiTM.Config) (hv : TagSystem.ValidCfg c) (hst : c.state < S) : TagSystem.decodeCTS S (TagSystem.ctsOfCfg S c) = some (TagSystem.canon c)
theorem TagSystem.decodeCTS_word (S : ℕ) (c : BiTM.Config) (hv : TagSystem.ValidCfg c) (hst : c.state < S) : TagSystem.decodeCTS S (TagSystem.ctsOfCfg S c) = some (TagSystem.canon c)
The block stage inverts the one-hot encoding (TagSystem.tagWordDecode_encode),
Definition 3.4.2 inverts Definition 3.4.1 on a word with states
below S (TagSystem.map_dec_enc, from Lemma 3.4.3),
Definition 3.5.5 reads (q, val left, head + 2 * val right) off
the configuration word (TagSystem.parseWord_cword), and since head is a bit,
(head + 2 * val right) % 2 = head and (head + 2 * val right) / 2 = val right.
T7 in the finite form shared by every link:
For a well-formed machine tm (Definition 3.4.12), a valid configuration
c (Definition 3.3.6) with state below numStates, and a run of
n steps of tm from c (Definition 2.3.4), there is a schedule
times : Nat -> Nat with times 0 = 0, strictly increasing on [0, n], such
that for every i <= n the i-th configuration ci of the run exists, the
cyclic tag system Definition 3.4.8 of Definition 3.4.6
tm tm.numStates reaches a configuration di at time times i from
Definition 3.4.14 tm.numStates c, and
Definition 3.5.8 tm.numStates di = some (canon ci)
(Definition 3.5.7).
Lean code for Theorem3.5.10●1 theorem
Associated Lean declarations
-
TagSystem.t7_finite[complete]
-
TagSystem.t7_finite[complete]
-
theoremdefined in TagSystem/TMToCTS.leancomplete
theorem TagSystem.t7_finite (tm : TM.Machine) (hwf : TagSystem.WF tm) (c : BiTM.Config) (hv : TagSystem.ValidCfg c) (hst : c.state < tm.numStates) (n : ℕ) (c' : BiTM.Config) (hrun : BiTM.nSteps tm c n = some c') : ∃ times, times 0 = 0 ∧ (∀ (i : ℕ), i < n → times i < times (i + 1)) ∧ ∀ (i : ℕ), i ≤ n → ∃ ci di, BiTM.nSteps tm c i = some ci ∧ (TagSystem.tagToCTS (TagSystem.tagK tm tm.numStates) ⋯).nSteps (TagSystem.ctsOfCfg tm.numStates c) (times i) = some di ∧ TagSystem.decodeCTS tm.numStates di = some (TagSystem.canon ci)
theorem TagSystem.t7_finite (tm : TM.Machine) (hwf : TagSystem.WF tm) (c : BiTM.Config) (hv : TagSystem.ValidCfg c) (hst : c.state < tm.numStates) (n : ℕ) (c' : BiTM.Config) (hrun : BiTM.nSteps tm c n = some c') : ∃ times, times 0 = 0 ∧ (∀ (i : ℕ), i < n → times i < times (i + 1)) ∧ ∀ (i : ℕ), i ≤ n → ∃ ci di, BiTM.nSteps tm c i = some ci ∧ (TagSystem.tagToCTS (TagSystem.tagK tm tm.numStates) ⋯).nSteps (TagSystem.ctsOfCfg tm.numStates c) (times i) = some di ∧ TagSystem.decodeCTS tm.numStates di = some (TagSystem.canon ci)
T7 in finite form: the cyclic tag system `tagToCTS (tagK tm S)` tracks every run of the well-formed binary machine from a valid configuration, at strictly increasing times, and `decodeCTS` reads the configurations back up to trailing blanks.
The lifting Lemma 4.2.6 applied to
Theorem 3.4.15 along the run gives the schedule and, at
each time, a cyclic tag configuration related to the i-th configuration of the
run, which is valid with state below numStates;
Theorem 3.5.9 reads it back as canon ci.
3.6. Notes and caveats
-
Binary machines only.
WFquantifies overs < 2and never readsnumSymbols; a machine withnumSymbols := 17and junk on symbols 2 and up isWFif its bit rows are (the chapter on open items). -
The halt row.
BiTM.stepreturnsnonein state 0 before consulting the table, butWFrequires the row of state 0 to be in range, because the tag productions keep applyingtm.transition 0 _after the machine has halted andprod_OKneeds the states to stay bounded. A machine whose halt row is out of range can be patched without changing any run; the wrapper lemma is not written (the chapter on open items). -
The tag system carries out the halting row too: its run never stops, and past the machine's halt it follows the raw run of
TagSystem.rawRun(the chapter on the composition). -
decodeCTSis proved complete (it inverts the encoder:TagSystem.decodeCTS_word), and its block stage is also sound:TagSystem.symbolDecodeaccepts exactly the one-hot blocks of lengthk(TagSystem.symbolDecode_sound) andTagSystem.tagWordDecodeexactly their concatenations (TagSystem.tagWordDecode_sound), so a word with a short last block or a stray bit is rejected. The later stages (decodeWord,cfgOfNums) are used for completeness only. Only completeness is used by the headline. -
The cyclic tag system has
2kappendants, notk, and the factor 2 is load-bearing in the chapter on the composition.
3.7. Depends on
This chapter depends on the modules TagSystem.Basic, TagSystem.TagRounds,
TagSystem.CockeMinsky, TagSystem.TagToCTS, TagSystem.TMToCTS,
Smith.Simulation (for ForwardSim) and BiTM.Basic. From the other chapters
it uses the machine model (TM.Machine, BiTM.Config, BiTM.step,
BiTM.nSteps) and the simulation calculus (Smith.StepSys, Smith.ForwardSim,
Smith.ForwardSim_nSteps).