Wolfram (2,3) universality in Lean

2. The machine model🔗

2.1. Orientation🔗

Two machine types appear in the development. BiTM (BiTM/Basic.lean) is the ordinary Turing machine on a two-way tape with implicit blanks; Wolfram's machine and the simulated machines of the chapter on the machine reduction are both BiTM machines. The lookahead machine type LMachine (Smith/Lookahead.lean) reads the active cell and its right neighbour and may rewrite both; Smith's Systems 1 to 3 need it (p. 4-5), and System 0 is Wolfram's machine written in it. The bridge Smith.toBi (Smith/Wolfram23Bridge.lean) carries System 0 runs to BiTM.wolfram23 runs.

2.2. Shared definitions🔗

TM/Defs.lean holds three definitions. States and symbols are natural numbers; state 0 is the halt state; numStates and numSymbols are documentation, never read by the step function.

Definition2.2.1
Group: The Turing machine vocabulary of <missing> shared by every machine of the development: directions, rules and machines. (2)
Group member previews
Preview
Definition 2.2.2
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 0
Used by 3
Reverse dependency previews
Preview
Definition 2.2.2
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

A direction of head movement: L (left) or R (right).

Lean code for Definition2.2.1●1 definition
  • inductive(2 constructors)defined in TM/Defs.lean
    complete
    inductive TM.Dir : Type
    inductive TM.Dir : Type
    Direction of head movement 
    TM.Dir.L : TM.Dir
    TM.Dir.R : TM.Dir
Definition2.2.2
Group: The Turing machine vocabulary of <missing> shared by every machine of the development: directions, rules and machines. (2)
Group member previews
Preview
Definition 2.2.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 1
Used by 3
Reverse dependency previews
Preview
Definition 2.2.3
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

A transition rule: the next state nextState, the symbol write to write, and the direction dir (Definition 2.2.1) to move. States and symbols are natural numbers.

Lean code for Definition2.2.2●1 definition
  • structure(3 fields)defined in TM/Defs.lean
    complete
    structure TM.Rule : Type
    structure TM.Rule : Type
    A transition rule: (nextState, writeSymbol, direction) 
    nextState : ℕ
    write : ℕ
    dir : TM.Dir
Definition2.2.3
Group: The Turing machine vocabulary of <missing> shared by every machine of the development: directions, rules and machines. (2)
Group member previews
Preview
Definition 2.2.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 1
Used by 4
Reverse dependency previews
Preview
Definition 2.3.3
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

A deterministic Turing machine: numStates, numSymbols, and transition : Nat → Nat → Rule, the rule (Definition 2.2.2) for a state and a read symbol. State 0 is the halt state; numStates and numSymbols are documentation, never read by the step function.

Lean code for Definition2.2.3●1 definition
  • structure(3 fields)defined in TM/Defs.lean
    complete
    structure TM.Machine : Type
    structure TM.Machine : Type
    A deterministic Turing machine.
    The transition function maps (state, readSymbol) -> Rule.
    States are 0..numStates-1, symbols are 0..numSymbols-1.
    State 0 is the halt state. 
    numStates : ℕ
    numSymbols : ℕ
    transition : ℕ → ℕ → TM.Rule

2.3. BiTM: configurations, steps, runs🔗

Definition2.3.1
Group: The two-way tape machine BiTM with implicit blanks: configurations, the step, runs, and the number of explicit cells. (5)
Group member previews
Preview
Definition 2.3.2
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 0
Used by 12
Reverse dependency previews
Preview
Definition 2.3.3
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

A configuration (state, left, head, right): the state, the cells left of the head nearest first, the head cell, and the cells right of the head nearest first. Cells are natural numbers, implicitly 0 beyond the two lists. State 0 means halted.

Lean code for Definition2.3.1●1 definition
  • structure(4 fields)defined in BiTM/Basic.lean
    complete
    structure BiTM.Config : Type
    structure BiTM.Config : Type
    Configuration of a bi-infinite tape TM.
    
    ```
    left:  cells to the left of head (closest first), implicitly 0 beyond
    head:  current cell symbol
    right: cells to the right of head (closest first), implicitly 0 beyond
    ```
    
    State 0 = halted. 
    state : ℕ
    left : List ℕ
    head : ℕ
    right : List ℕ
Definition2.3.2
Group: The two-way tape machine BiTM with implicit blanks: configurations, the step, runs, and the number of explicit cells. (5)
Group member previews
Preview
Definition 2.3.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 0
Used by 3
Reverse dependency previews
Preview
Definition 2.3.3
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

Reads a list of cells: its first cell and the rest, or 0 and the empty list beyond its end.

Lean code for Definition2.3.2●1 definition
  • defdefined in BiTM/Basic.lean
    complete
    def BiTM.readHead (l : List ℕ) : ℕ × List ℕ
    def BiTM.readHead (l : List ℕ) : ℕ × List ℕ
    Read from a list, returning 0 (blank) if beyond bounds 
Definition2.3.3
Group: The two-way tape machine BiTM with implicit blanks: configurations, the step, runs, and the number of explicit cells. (5)
Group member previews
Preview
Definition 2.3.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 5
Statement dependency previews
Preview
Definition 2.2.1
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
Used by 10
Reverse dependency previews
Preview
Definition 2.3.4
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

One step of a machine (Definition 2.2.3) on a configuration (Definition 2.3.1): none in state 0, and otherwise the rule (Definition 2.2.2) for the state and the head cell is applied. Moving left (Definition 2.2.1) pops left into the head by Definition 2.3.2 and pushes the written symbol onto right; moving right symmetrically pops right into the head and pushes the written symbol onto left.

Lean code for Definition2.3.3●1 definition
  • defdefined in BiTM/Basic.lean
    complete
    def BiTM.step (tm : TM.Machine) (cfg : BiTM.Config) : Option BiTM.Config
    def BiTM.step (tm : TM.Machine)
      (cfg : BiTM.Config) : Option BiTM.Config
    Single step of a bi-infinite tape TM.
    Returns none if already halted. 
Definition2.3.4
Group: The two-way tape machine BiTM with implicit blanks: configurations, the step, runs, and the number of explicit cells. (5)
Group member previews
Preview
Definition 2.3.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 1
Used by 7
Reverse dependency previews
Preview
Lemma 2.4.4
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

n iterations of Definition 2.3.3, none as soon as a step is stuck.

Lean code for Definition2.3.4●1 definition
  • defdefined in BiTM/Basic.lean
    complete
    def BiTM.nSteps (tm : TM.Machine) (cfg : BiTM.Config) :
      ℕ → Option BiTM.Config
    def BiTM.nSteps (tm : TM.Machine)
      (cfg : BiTM.Config) :
      ℕ → Option BiTM.Config
    Run for exactly n steps without checking halting. Returns none if
    the machine halts before n steps. 
Definition2.3.5
Group: The two-way tape machine BiTM with implicit blanks: configurations, the step, runs, and the number of explicit cells. (5)
Group member previews
Preview
Definition 2.3.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 1
Used by 7
Reverse dependency previews
Preview
Theorem 1.2.1
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

The number of explicit cells of a configuration (Definition 2.3.1), left.length + 1 + right.length. Defined in Smith/Wolfram23Bridge.lean.

Lean code for Definition2.3.5●1 definition
  • complete
    def Smith.biSize (cfg : BiTM.Config) : ℕ
    def Smith.biSize (cfg : BiTM.Config) : ℕ
    The number of explicit cells of a `BiTM.Config`. 
Lemma2.3.6
Group: The two-way tape machine BiTM with implicit blanks: configurations, the step, runs, and the number of explicit cells. (5)
Group member previews
Preview
Definition 2.3.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 2
Statement dependency previews
Preview
Definition 2.3.3
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
used by 1✓L∃∀N

A step of any machine (Definition 2.3.3) never decreases Definition 2.3.5: if BiTM.step tm cfg = some cfg' then biSize cfg <= biSize cfg'.

Lean code for Lemma2.3.6●1 theorem
  • theoremdefined in Smith/Wolfram23Bridge.lean
    complete
    theorem Smith.biSize_step (tm : TM.Machine) (cfg cfg' : BiTM.Config)
      (h : BiTM.step tm cfg = some cfg') :
      Smith.biSize cfg ≤ Smith.biSize cfg'
    theorem Smith.biSize_step (tm : TM.Machine)
      (cfg cfg' : BiTM.Config)
      (h : BiTM.step tm cfg = some cfg') :
      Smith.biSize cfg ≤ Smith.biSize cfg'
    Every step of a `BiTM` machine keeps or grows the explicit tape. 
Proof for Lemma 2.3.6

Case on the direction of the rule. A move pops one cell from one side of the zipper and pushes one cell onto the other side, so the count is unchanged when the popped side is nonempty; when it is empty, Definition 2.3.2 returns the implicit blank 0 and nothing is popped, so the count grows by one.

So a step never decreases biSize, and a step onto an implicit blank increases it by one. This is how "the head stays on the initial tape" is formalized in the chapter on Conjecture 0 and the chapter on the composition: biSize constant.

2.4. Wolfram's machine🔗

Definition2.4.1
Group: Wolfram's 2-state 3-colour machine as a BiTM machine, and the alphabet it preserves. (3)
Group member previews
Preview
Definition 2.4.2
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 2
Statement dependency previews
Preview
Definition 2.2.2
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
Used by 10
Reverse dependency previews
Preview
Lemma 2.4.3
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

Wolfram's machine as a Definition 2.2.3: numStates := 3 (0 is halt, 1 is A, 2 is B), numSymbols := 3 (the symbols 0, 1, 2), and the six rules (Definition 2.2.2) A,0 -> 1,R,B, A,1 -> 2,L,A, A,2 -> 1,L,A, B,0 -> 2,L,A, B,1 -> 2,R,B, B,2 -> 0,R,A, each read as the state and the symbol before, then the written symbol, the move and the new state. Every other (state, symbol) pair goes to state 0, writes 0 and moves right; that row is unused.

Lean code for Definition2.4.1●1 definition
  • defdefined in BiTM/Basic.lean
    complete
    def BiTM.wolfram23 : TM.Machine
    def BiTM.wolfram23 : TM.Machine
    Wolfram's 2-state 3-symbol Turing machine (machine 596440).
    Proven universal by Alex Smith (2007).
    
    ```
    States: 1 = A, 2 = B (0 = halt, never reached by this machine)
    Symbols: 0, 1, 2
    ```
    
    Transition table:
    
    ```
    +--------+---------+---------+---------+
    |        |  sym 0  |  sym 1  |  sym 2  |
    +--------+---------+---------+---------+
    | A (1)  | 1,R,B   | 2,L,A   | 1,L,A   |
    | B (2)  | 2,L,A   | 2,R,B   | 0,R,A   |
    +--------+---------+---------+---------+
    ```
    

Wolfram's table, in the form of his own presentation: each entry is the symbol written, the move and the new state.

state

symbol 0

symbol 1

symbol 2

A (1)

1, R, B

2, L, A

1, L, A

B (2)

2, L, A

2, R, B

0, R, A

Entry by entry this is Wolfram's rule 596440 as published (A0 -> 1RB, A1 -> 2LA, A2 -> 1LA, B0 -> 2LA, B1 -> 2RB, B2 -> 0RA) and Smith's System 0 table on p. 3, whose four rows read: before (symbol, state), after (symbol, new active position and state); all six entries agree with both sources and with the p. 47 trace. State 0 is never entered from states 1 and 2, so the halt row is dead.

Definition2.4.2
Group: Wolfram's 2-state 3-colour machine as a BiTM machine, and the alphabet it preserves. (3)
Group member previews
Preview
Definition 2.4.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 1
Used by 6
Reverse dependency previews
Preview
Lemma 2.4.3
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

A configuration (Definition 2.3.1) is valid for wolfram23 when its state is 1 or 2, its head cell is below 3, and every cell of left and of right is below 3.

Lean code for Definition2.4.2●1 definition
  • complete
    def BiTM.IsValidWolfram23Cfg (cfg : BiTM.Config) : Prop
    def BiTM.IsValidWolfram23Cfg
      (cfg : BiTM.Config) : Prop
    A valid wolfram23 config: active state, in-range head, and all
    tape values `< 3` on both sides. 
Lemma2.4.3
Group: Wolfram's 2-state 3-colour machine as a BiTM machine, and the alphabet it preserves. (3)
Group member previews
Preview
Definition 2.4.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 3
Statement dependency previews
Preview
Definition 2.3.3
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
used by 1✓L∃∀N

From a valid configuration (Definition 2.4.2) the step (Definition 2.3.3) of Definition 2.4.1 is some cfg' with cfg' valid: the machine does not halt and does not leave the alphabet.

Lean code for Lemma2.4.3●1 theorem
  • theoremdefined in BiTM/Wolfram23Valid.lean
    complete
    theorem BiTM.step_wolfram23_preserves_valid (cfg : BiTM.Config)
      (h : BiTM.IsValidWolfram23Cfg cfg) :
      ∃ cfg',
        BiTM.step BiTM.wolfram23 cfg = some cfg' ∧
          BiTM.IsValidWolfram23Cfg cfg'
    theorem BiTM.step_wolfram23_preserves_valid
      (cfg : BiTM.Config)
      (h : BiTM.IsValidWolfram23Cfg cfg) :
      ∃ cfg',
        BiTM.step BiTM.wolfram23 cfg =
            some cfg' ∧
          BiTM.IsValidWolfram23Cfg cfg'
    Wolfram23's step preserves `IsValidWolfram23Cfg`. 
Proof for Lemma 2.4.3

The state is nonzero, so the step is some. For a state 1 or 2 and a head cell below 3 the six rules give a next state 1 or 2 and a written symbol below 3 (BiTM.wolfram23_nextState_in_range, BiTM.wolfram23_write_in_range, by decide on the six cases). In either direction the cell that Definition 2.3.2 pops into the head is a cell of the old tape or the blank 0, and the cell pushed onto the other side is the written symbol, so the head and both lists stay below 3.

Lemma2.4.4
Group: Wolfram's 2-state 3-colour machine as a BiTM machine, and the alphabet it preserves. (3)
Group member previews
Preview
Definition 2.4.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 3
Statement dependency previews
Preview
Definition 2.3.4
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
used by 0✓L∃∀N

From a valid configuration (Definition 2.4.2) every run of n steps (Definition 2.3.4) of Definition 2.4.1 is some cfg' with cfg' valid: the machine never halts and never leaves the alphabet.

Lean code for Lemma2.4.4●1 theorem
  • theoremdefined in BiTM/Wolfram23Valid.lean
    complete
    theorem BiTM.nSteps_wolfram23_preserves_valid (cfg : BiTM.Config)
      (h : BiTM.IsValidWolfram23Cfg cfg) (n : ℕ) :
      ∃ cfg',
        BiTM.nSteps BiTM.wolfram23 cfg n = some cfg' ∧
          BiTM.IsValidWolfram23Cfg cfg'
    theorem BiTM.nSteps_wolfram23_preserves_valid
      (cfg : BiTM.Config)
      (h : BiTM.IsValidWolfram23Cfg cfg)
      (n : ℕ) :
      ∃ cfg',
        BiTM.nSteps BiTM.wolfram23 cfg n =
            some cfg' ∧
          BiTM.IsValidWolfram23Cfg cfg'
    Wolfram23 nSteps preserves `IsValidWolfram23Cfg` for any `n`. 
Proof for Lemma 2.4.4

Induction on n, with Lemma 2.4.3 for each step.

2.5. The lookahead machine type🔗

Definition2.5.1
Group: The machine type of Smith's Systems 0 to 3: states, rules, configurations, the step, the four tables of p. 45 and the p. 47 check. (13)
Group member previews
Preview
Definition 2.5.2
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 0
Used by 3
Reverse dependency previews
Preview
Definition 2.5.2
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

The states A, B, C of Systems 0 to 3.

Lean code for Definition2.5.1●1 definition
  • inductive(3 constructors)defined in Smith/Lookahead.lean
    complete
    inductive Smith.LState : Type
    inductive Smith.LState : Type
    The states A, B, C of Systems 0 to 3. 
    Smith.LState.A : Smith.LState
    Smith.LState.B : Smith.LState
    Smith.LState.C : Smith.LState
Definition2.5.2
Group: The machine type of Smith's Systems 0 to 3: states, rules, configurations, the step, the four tables of p. 45 and the p. 47 check. (13)
Group member previews
Preview
Definition 2.5.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 2
Statement dependency previews
Preview
Definition 2.2.1
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
Used by 3
Reverse dependency previews
Preview
Definition 2.5.3
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

A rule: one st a d rewrites the active cell to a, and two st a b d rewrites the active cell to a and its right neighbour to b; in both shapes the state becomes st (Definition 2.5.1) and the head moves by one in the direction d (Definition 2.2.1). Symbols are Fin 3.

Lean code for Definition2.5.2●1 definition
  • inductive(2 constructors)defined in Smith/Lookahead.lean
    complete
    inductive Smith.LRule : Type
    inductive Smith.LRule : Type
    A rule: rewrite the active cell (`one`) or the active cell and its
    right neighbour (`two`), change state, move by one. 
    Smith.LRule.one (st : Smith.LState) (a : Fin 3)
      (d : TM.Dir) : Smith.LRule
    Smith.LRule.two (st : Smith.LState) (a b : Fin 3)
      (d : TM.Dir) : Smith.LRule
Definition2.5.3
Group: The machine type of Smith's Systems 0 to 3: states, rules, configurations, the step, the four tables of p. 45 and the p. 47 check. (13)
Group member previews
Preview
Definition 2.5.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 2
Statement dependency previews
Preview
Definition 2.5.1
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
Used by 10
Reverse dependency previews
Preview
Definition 2.5.5
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

A lookahead machine: a function trans from the state (Definition 2.5.1), the active cell and its right neighbour (0 when there is none) to a rule (Definition 2.5.2), a one-cell rule (rewrite the active cell) or a two-cell rule (rewrite both), with a move. These are the two rule shapes of Smith's sys0-3.pl (p. 45).

Lean code for Definition2.5.3●1 definition
  • structure(1 field)defined in Smith/Lookahead.lean
    complete
    structure Smith.LMachine : Type
    structure Smith.LMachine : Type
    A lookahead machine: the rule for a state, the active symbol and the
    right neighbour (`0` when there is none). 
    trans : Smith.LState → Fin 3 → Fin 3 → Smith.LRule
Definition2.5.4
Group: The machine type of Smith's Systems 0 to 3: states, rules, configurations, the step, the four tables of p. 45 and the p. 47 check. (13)
Group member previews
Preview
Definition 2.5.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 1
Used by 8
Reverse dependency previews
Preview
Definition 2.5.5
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

A configuration, the zipper (left, head, right, state) with left nearest first and a state in Definition 2.5.1, like BiTM.Config (Definition 2.3.1) but over Fin 3. LConfig.toList is the tape read left to right and LConfig.pos the index of the head on it.

Lean code for Definition2.5.4●1 definition
  • structure(4 fields)defined in Smith/Lookahead.lean
    complete
    structure Smith.LConfig : Type
    structure Smith.LConfig : Type
    A configuration: cells left of the head nearest first, the head cell,
    cells right of the head nearest first, and the state. 
    left : List (Fin 3)
    head : Fin 3
    right : List (Fin 3)
    state : Smith.LState
Definition2.5.5
Group: The machine type of Smith's Systems 0 to 3: states, rules, configurations, the step, the four tables of p. 45 and the p. 47 check. (13)
Group member previews
Preview
Definition 2.5.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 3
Statement dependency previews
Preview
Definition 2.5.2
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
Used by 8
Reverse dependency previews
Preview
Definition 2.5.6
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

One step of a machine (Definition 2.5.3) on a configuration (Definition 2.5.4): the rule (Definition 2.5.2) for the state, the head cell and the right neighbour (0 when right is empty) is applied, rewriting the cell or cells it read and moving the head. The tape is finite and never extended: the result is none when the move would leave either end of the tape, and none for a two-cell rule with no right neighbour.

Lean code for Definition2.5.5●1 definition
  • defdefined in Smith/Lookahead.lean
    complete
    def Smith.lstep (M : Smith.LMachine) (c : Smith.LConfig) :
      Option Smith.LConfig
    def Smith.lstep (M : Smith.LMachine)
      (c : Smith.LConfig) :
      Option Smith.LConfig
    One step. 
Definition2.5.6
Group: The machine type of Smith's Systems 0 to 3: states, rules, configurations, the step, the four tables of p. 45 and the p. 47 check. (13)
Group member previews
Preview
Definition 2.5.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 2
Statement dependency previews
Preview
Definition 2.5.5
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
Used by 13
Reverse dependency previews
Preview
Lemma 2.5.7
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

n iterations of Definition 2.5.5, none as soon as a step is none. It is the nSteps of the step system Smith.lsys M whose step is lstep M (Definition 4.2.2).

Lean code for Definition2.5.6●1 definition
  • defdefined in Smith/Lookahead.lean
    complete
    def Smith.lnSteps (M : Smith.LMachine) (c : Smith.LConfig) (n : ℕ) :
      Option Smith.LConfig
    def Smith.lnSteps (M : Smith.LMachine)
      (c : Smith.LConfig) (n : ℕ) :
      Option Smith.LConfig
    `n` steps. 
Lemma2.5.7
Group: The machine type of Smith's Systems 0 to 3: states, rules, configurations, the step, the four tables of p. 45 and the p. 47 check. (13)
Group member previews
Preview
Definition 2.5.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 1
Used by 2
Reverse dependency previews
Preview
Lemma 7.3.8
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

Runs concatenate: lnSteps M c (n + m) (Definition 2.5.6) is the run of m steps from the result of the run of n steps, and none when either is none.

Lean code for Lemma2.5.7●1 theorem
  • theoremdefined in Smith/Lookahead.lean
    complete
    theorem Smith.lnSteps_add (M : Smith.LMachine) (c : Smith.LConfig) (n m : ℕ) :
      Smith.lnSteps M c (n + m) =
        (Smith.lnSteps M c n).bind fun c' => Smith.lnSteps M c' m
    theorem Smith.lnSteps_add (M : Smith.LMachine)
      (c : Smith.LConfig) (n m : ℕ) :
      Smith.lnSteps M c (n + m) =
        (Smith.lnSteps M c n).bind fun c' =>
          Smith.lnSteps M c' m
Proof for Lemma 2.5.7
uses 0

This is StepSys.nSteps_add of Smith/Simulation.lean for the step system lsys M.

Definition2.5.8
Group: The machine type of Smith's Systems 0 to 3: states, rules, configurations, the step, the four tables of p. 45 and the p. 47 check. (13)
Group member previews
Preview
Definition 2.5.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 2
Statement dependency previews
Preview
Definition 2.5.3
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
used by 1✓L∃∀N

The exit to the right of a configuration (Definition 2.5.4) under a machine (Definition 2.5.3): when a one-cell rule at the last cell moves right, the state it enters and the tape after its write; none otherwise. It records one-cell exits only and is used only by the p. 47 check.

Lean code for Definition2.5.8●1 definition
  • defdefined in Smith/Lookahead.lean
    complete
    def Smith.exitRight (M : Smith.LMachine) (c : Smith.LConfig) :
      Option (Smith.LState × List (Fin 3))
    def Smith.exitRight (M : Smith.LMachine)
      (c : Smith.LConfig) :
      Option (Smith.LState × List (Fin 3))
    The exit to the right: from `c`, a one-cell rule moving right at the
    last cell leaves the tape in state `st'` after writing `a'`; the result
    is that state and the final tape.  `none` when `c` does not exit. 

The four tables are transcribed from p. 45 (the chapter on Systems 3 to 0 for the relabelings between them).

Definition2.5.9
Group: The machine type of Smith's Systems 0 to 3: states, rules, configurations, the step, the four tables of p. 45 and the p. 47 check. (13)
Group member previews
Preview
Definition 2.5.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 1
Used by 13
Reverse dependency previews
Preview
Definition 2.5.14
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

System 0, Wolfram's table as a lookahead machine (Definition 2.5.3), with one-cell rules only: A0 -> B1>, A1 -> A2<, A2 -> A1<, B0 -> A2<, B1 -> B2>, B2 -> A0> (the new state, the written symbol, the move). The rows for state C, never reached, are dead.

Lean code for Definition2.5.9●1 definition
  • defdefined in Smith/Lookahead.lean
    complete
    def Smith.sys0 : Smith.LMachine
    def Smith.sys0 : Smith.LMachine
    System 0, Wolfram's (2,3) machine:
    `A0 -> B1>, B0 -> A2<, A1 -> A2<, B1 -> B2>, A2 -> A1<, B2 -> A0>`. 
Definition2.5.10
Group: The machine type of Smith's Systems 0 to 3: states, rules, configurations, the step, the four tables of p. 45 and the p. 47 check. (13)
Group member previews
Preview
Definition 2.5.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 1
Used by 6
Reverse dependency previews
Preview
Theorem 7.2.5
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

System 1 (Definition 2.5.3): System 0 with B2 replaced by the three two-cell rules B20 -> A00>, B21 -> B12>, B22 -> B11>.

Lean code for Definition2.5.10●1 definition
  • defdefined in Smith/Lookahead.lean
    complete
    def Smith.sys1 : Smith.LMachine
    def Smith.sys1 : Smith.LMachine
    System 1: System 0 with `B2` replaced by the lookahead rules
    `B20 -> A00>, B21 -> B12>, B22 -> B11>`. 
Definition2.5.11
Group: The machine type of Smith's Systems 0 to 3: states, rules, configurations, the step, the four tables of p. 45 and the p. 47 check. (13)
Group member previews
Preview
Definition 2.5.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 1
Used by 4
Reverse dependency previews
Preview
Lemma 7.2.6
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

System 2 (Definition 2.5.3): the table of p. 45 with the third state C, entered by the two-cell rules on B21 and B22.

Lean code for Definition2.5.11●1 definition
  • defdefined in Smith/Lookahead.lean
    complete
    def Smith.sys2 : Smith.LMachine
    def Smith.sys2 : Smith.LMachine
    System 2. 
Definition2.5.12
Group: The machine type of Smith's Systems 0 to 3: states, rules, configurations, the step, the four tables of p. 45 and the p. 47 check. (13)
Group member previews
Preview
Definition 2.5.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
uses 1
Used by 12
Reverse dependency previews
Preview
Lemma 6.3.1
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

System 3 (Definition 2.5.3): the table of p. 45, a relabeling of System 2 with state C.

Lean code for Definition2.5.12●1 definition
  • defdefined in Smith/Lookahead.lean
    complete
    def Smith.sys3 : Smith.LMachine
    def Smith.sys3 : Smith.LMachine
    System 3. 

Its thirteen rows, the rule being the new state, the written symbols and the move; a one-cell rule ignores the neighbour, written - below, and a two-cell rule writes the head cell and the neighbour.

state

head

neighbour

rule

A

0

-

one B 2 R

A

1

-

one A 1 L

A

2

-

one A 2 L

B

0

-

one A 2 L

B

1

-

one B 1 R

B

2

0

two A 0 0 R

B

2

1

two C 2 1 R

B

2

2

two C 2 2 R

C

0

-

one A 2 L

C

1

0

two A 0 0 R

C

1

1

two C 2 1 R

C

1

2

two C 2 2 R

C

2

-

one B 1 R

Definition2.5.13
Group: The machine type of Smith's Systems 0 to 3: states, rules, configurations, the step, the four tables of p. 45 and the p. 47 check. (13)
Group member previews
Preview
Definition 2.5.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 2
Statement dependency previews
Preview
Definition 2.5.2
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
used by 0✓L∃∀N

A machine (Definition 2.5.3) has this property when a one-cell rule (Definition 2.5.2) does not depend on the neighbour: if trans st a b is a one-cell rule then trans st a b' = trans st a b for every b'.

Lean code for Definition2.5.13●1 definition
  • defdefined in Smith/Lookahead.lean
    complete
    def Smith.LMachine.OneIgnoresNeighbour (M : Smith.LMachine) : Prop
    def Smith.LMachine.OneIgnoresNeighbour
      (M : Smith.LMachine) : Prop
    A `one` rule does not read the neighbour. 

Every table satisfies OneIgnoresNeighbour, checked by decide (Smith.sys0_one, Smith.sys1_one, Smith.sys2_one, Smith.sys3_one).

Definition2.5.14
Group: The machine type of Smith's Systems 0 to 3: states, rules, configurations, the step, the four tables of p. 45 and the p. 47 check. (13)
Group member previews
Preview
Definition 2.5.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 3
Statement dependency previews
Preview
Definition 2.5.6
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
used by 0✓L∃∀N

The 28 tapes of the sys0-3.pl 0 N 00A00000 trace of p. 47. The trace is reproduced tape for tape by decide: from 00A00000 (Smith.cfgP47, the head on the third of seven cells in state A) the run of Definition 2.5.9 gives the 27 tapes with the head on the tape (Smith.tapes); after 26 steps the head is on the last cell in state B; the 27th step leaves the tape (Definition 2.5.6 is none); and Definition 2.5.8 gives state B and the 28th line, the tape after the last write. The leftmost visit of the run, cell 0 in state A after 12 steps, is checked as well.

Lean code for Definition2.5.14●1 definition
  • defdefined in Smith/Lookahead.lean
    complete
    def Smith.traceP47 : List (List (Fin 3))
    def Smith.traceP47 : List (List (Fin 3))
    The tapes of the `sys0-3.pl 0 N 00A00000` trace, p. 47. 

2.6. The bridge to wolfram23🔗

Definition2.6.1
Group: System 0 is wolfram23: the reading of lookahead configurations as BiTM configurations, and the step, exit and run correspondences. (6)
Group member previews
Preview
Definition 2.6.2
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 2
Statement dependency previews
Preview
Definition 2.3.1
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
Used by 8
Reverse dependency previews
Preview
Lemma 2.6.3
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

Reads a System 0 configuration (Definition 2.5.4) as a BiTM.Config (Definition 2.3.1): A is state 1, B is state 2, C is state 3 (never reached from A or B; Smith.stateNat), the symbols by Fin.val, and the zipper is the same zipper.

Lean code for Definition2.6.1●1 definition
  • complete
    def Smith.toBi (c : Smith.LConfig) : BiTM.Config
    def Smith.toBi (c : Smith.LConfig) :
      BiTM.Config
    A System 0 configuration as a `wolfram23` configuration. 
Definition2.6.2
Group: System 0 is wolfram23: the reading of lookahead configurations as BiTM configurations, and the step, exit and run correspondences. (6)
Group member previews
Preview
Definition 2.6.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 2
Statement dependency previews
Preview
Definition 2.3.1
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
Used by 2
Reverse dependency previews
Preview
Lemma 2.6.3
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

Reads a BiTM.Config (Definition 2.3.1) as a System 0 configuration (Definition 2.5.4): the cells by Smith.toFin (reduction modulo 3), the state A when the state is 1 and B otherwise.

Lean code for Definition2.6.2●1 definition
  • complete
    def Smith.ofBi (cfg : BiTM.Config) : Smith.LConfig
    def Smith.ofBi (cfg : BiTM.Config) :
      Smith.LConfig
    The inverse of `toBi` on valid configurations. 
Lemma2.6.3
Group: System 0 is wolfram23: the reading of lookahead configurations as BiTM configurations, and the step, exit and run correspondences. (6)
Group member previews
Preview
Definition 2.6.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 3
Statement dependency previews
Preview
Definition 2.4.2
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
used by 1✓L∃∀N

On valid configurations (Definition 2.4.2) Definition 2.6.2 is the inverse of Definition 2.6.1: toBi (ofBi cfg) = cfg.

Lean code for Lemma2.6.3●1 theorem
  • theoremdefined in Smith/Wolfram23Bridge.lean
    complete
    theorem Smith.toBi_ofBi (cfg : BiTM.Config)
      (hv : BiTM.IsValidWolfram23Cfg cfg) :
      Smith.toBi (Smith.ofBi cfg) = cfg
    theorem Smith.toBi_ofBi (cfg : BiTM.Config)
      (hv : BiTM.IsValidWolfram23Cfg cfg) :
      Smith.toBi (Smith.ofBi cfg) = cfg
Proof for Lemma 2.6.3
uses 0

A cell below 3 is unchanged by reduction modulo 3 followed by Fin.val (Smith.map_val_toFin for the two lists), and a state 1 or 2 goes to A or B and back to 1 or 2.

Theorem2.6.4
Group: System 0 is wolfram23: the reading of lookahead configurations as BiTM configurations, and the step, exit and run correspondences. (6)
Group member previews
Preview
Definition 2.6.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 5
Statement dependency previews
Preview
Definition 2.3.3
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
used by 1✓L∃∀N

For a System 0 configuration c not in state C, if lstep sys0 c = some c' (Definition 2.5.5, Definition 2.5.9) then BiTM.step wolfram23 (toBi c) = some (toBi c') (Definition 2.3.3, Definition 2.4.1, Definition 2.6.1): a System 0 step is a wolfram23 step.

Lean code for Theorem2.6.4●1 theorem
  • theoremdefined in Smith/Wolfram23Bridge.lean
    complete
    theorem Smith.toBi_step (c c' : Smith.LConfig) (hst : c.state ≠ Smith.LState.C)
      (h : Smith.lstep Smith.sys0 c = some c') :
      BiTM.step BiTM.wolfram23 (Smith.toBi c) = some (Smith.toBi c')
    theorem Smith.toBi_step (c c' : Smith.LConfig)
      (hst : c.state ≠ Smith.LState.C)
      (h :
        Smith.lstep Smith.sys0 c = some c') :
      BiTM.step BiTM.wolfram23
          (Smith.toBi c) =
        some (Smith.toBi c')
    A System 0 step is a `wolfram23` step. 
Proof for Theorem 2.6.4
uses 0

Case analysis on the state, the head symbol and whether each side of the zipper is empty. In every case the rule of sys0 is the matching entry of wolfram23 and the zipper moves the same way on both sides; simp with the definitions unfolded closes each case.

Theorem2.6.5
Group: System 0 is wolfram23: the reading of lookahead configurations as BiTM configurations, and the step, exit and run correspondences. (6)
Group member previews
Preview
Definition 2.6.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 6
Statement dependency previews
Preview
Definition 2.3.3
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
used by 1✓L∃∀N

For a System 0 configuration c not in state C, if lstep sys0 c = none (Definition 2.5.5, Definition 2.5.9) then BiTM.step wolfram23 (toBi c) (Definition 2.3.3, Definition 2.4.1, Definition 2.6.1) is some cfg' with biSize cfg' = biSize (toBi c) + 1 (Definition 2.3.5): where System 0 is stuck, wolfram23 steps onto an implicit blank and the explicit tape grows by one cell.

Lean code for Theorem2.6.5●1 theorem
  • theoremdefined in Smith/Wolfram23Bridge.lean
    complete
    theorem Smith.toBi_exit (c : Smith.LConfig) (hst : c.state ≠ Smith.LState.C)
      (h : Smith.lstep Smith.sys0 c = none) :
      ∃ cfg',
        BiTM.step BiTM.wolfram23 (Smith.toBi c) = some cfg' ∧
          Smith.biSize cfg' = Smith.biSize (Smith.toBi c) + 1
    theorem Smith.toBi_exit (c : Smith.LConfig)
      (hst : c.state ≠ Smith.LState.C)
      (h : Smith.lstep Smith.sys0 c = none) :
      ∃ cfg',
        BiTM.step BiTM.wolfram23
              (Smith.toBi c) =
            some cfg' ∧
          Smith.biSize cfg' =
            Smith.biSize (Smith.toBi c) + 1
    Where System 0 leaves its tape, `wolfram23` steps onto a blank and its
    explicit tape grows by one cell. 
Proof for Theorem 2.6.5
uses 0

The same case analysis. sys0 has one-cell rules only, so lstep is none exactly when the move leaves the finite tape; on that side toBi c has the empty list, so BiTM.step reads the implicit blank 0 by BiTM.readHead and pushes the written symbol onto the other side, one explicit cell more.

Theorem2.6.6
Group: System 0 is wolfram23: the reading of lookahead configurations as BiTM configurations, and the step, exit and run correspondences. (6)
Group member previews
Preview
Definition 2.6.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 5
Statement dependency previews
Preview
Definition 2.3.4
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
Used by 3
Reverse dependency previews
Preview
Theorem 7.3.11
Loading preview
Reverse dependency preview content is loaded from the rendered-fragment cache.
✓L∃∀N

For a System 0 configuration c not in state C, if lnSteps sys0 c n = some c' (Definition 2.5.6, Definition 2.5.9) then BiTM.nSteps wolfram23 (toBi c) n = some (toBi c') (Definition 2.3.4, Definition 2.4.1, Definition 2.6.1) and c' is not in state C: a System 0 run is a wolfram23 run.

Lean code for Theorem2.6.6●1 theorem
  • theoremdefined in Smith/Wolfram23Bridge.lean
    complete
    theorem Smith.toBi_run (c : Smith.LConfig) (hst : c.state ≠ Smith.LState.C)
      (n : ℕ) (c' : Smith.LConfig)
      (h : Smith.lnSteps Smith.sys0 c n = some c') :
      BiTM.nSteps BiTM.wolfram23 (Smith.toBi c) n = some (Smith.toBi c') ∧
        c'.state ≠ Smith.LState.C
    theorem Smith.toBi_run (c : Smith.LConfig)
      (hst : c.state ≠ Smith.LState.C) (n : ℕ)
      (c' : Smith.LConfig)
      (h :
        Smith.lnSteps Smith.sys0 c n =
          some c') :
      BiTM.nSteps BiTM.wolfram23
            (Smith.toBi c) n =
          some (Smith.toBi c') ∧
        c'.state ≠ Smith.LState.C
    A System 0 run is a `wolfram23` run. 
Proof for Theorem 2.6.6

Induction on n. System 0 never enters state C from A or B (Smith.sys0_state), so Theorem 2.6.4 applies at every step.

A System 0 step is a wolfram23 step; where System 0 is stuck (the head would leave the finite tape) wolfram23 steps onto an implicit blank and the explicit tape grows by one. This is the only place the finite zipper meets the implicit blanks, and it is where the exit condition of the chapter on Conjecture 0 and the chapter on the composition comes from. The exit step itself, as a BiTM step, is the following computation; it lives in Smith/Conjecture0.lean.

Lemma2.6.7
Group: System 0 is wolfram23: the reading of lookahead configurations as BiTM configurations, and the step, exit and run correspondences. (6)
Group member previews
Preview
Definition 2.6.1
Loading preview
Group member preview content is loaded from the rendered-fragment cache.
Statement uses 2
Statement dependency previews
Preview
Definition 2.3.3
Loading preview
Statement dependency preview content is loaded from the rendered-fragment cache.
used by 1✓L∃∀N

The exit step of Definition 2.4.1 (Definition 2.3.3): from state 2 (B) on a 2 with nothing explicit to the right, the step writes 0, moves right onto the implicit blank and enters state 1 (A): BiTM.step wolfram23 ⟨2, L, 2, []⟩ = some ⟨1, 0 :: L, 0, []⟩.

Lean code for Lemma2.6.7●1 theorem
  • theoremdefined in Smith/Conjecture0.lean
    complete
    theorem Smith.wolfram23_exit_step (L : List ℕ) :
      BiTM.step BiTM.wolfram23
          { state := 2, left := L, head := 2, right := [] } =
        some { state := 1, left := 0 :: L, head := 0, right := [] }
    theorem Smith.wolfram23_exit_step (L : List ℕ) :
      BiTM.step BiTM.wolfram23
          { state := 2, left := L, head := 2,
            right := [] } =
        some
          { state := 1, left := 0 :: L,
            head := 0, right := [] }
    The exit step of wolfram23: `B2 -> 0, R, A` onto the implicit blank right
    of the tape (TM23Proof.pdf p. 4: "if that cell is a 0 it becomes active
    in state A"). 
Proof for Lemma 2.6.7
uses 0

By computation (rfl): the rule B2 -> 0RA and BiTM.readHead [].

2.7. Notes and caveats🔗

  • Direction conventions are consistent across TM.Dir, BiTM.step and lstep: L pops from left, R pops from right. The review checked this.

  • LMachine passes 0 as the neighbour at the right end but lstep discards any two-cell result there. So at the end of the System 4 emulation (System 3 head on the closing 1 in state C, the chapter on Conjecture 0) lstep sys3 and exitRight sys3 are both none; the exit that the theorems report is realized after relabeling, by the BiTM step Smith.wolfram23_exit_step (B2 -> 0RA onto the implicit blank). The Lookahead header says so; exitRight records one-cell exits only and is used only by the p. 47 check.

  • Two branches of BiTM.System4.step (the chapter on System 5 to System 4) and none of the machine model here deviate from Smith's Perl programs; the machine model is faithful.

2.8. Depends on🔗

The modules of this chapter are TM.Defs, BiTM.Basic, BiTM.Wolfram23Valid, Smith.Lookahead and Smith.Wolfram23Bridge; Smith.wolfram23_exit_step is in Smith.Conjecture0. Smith.lnSteps is built on the step-system calculus of Smith/Simulation.lean (the chapter on cyclic tag to System 5). The results at the end of Smith/Wolfram23Bridge.lean on the head leaving every finite tape (Smith.wolfram23_leaves, Smith.wolfram23_not_periodic) and the length bookkeeping Smith.lnSteps_length are described in the chapter on Systems 3 to 0 and the chapter on Conjecture 0.