The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V32. Logic, model theory and computability

Mathlib.Computability.TuringMachine.StackTuringMachine

146 declarations. Mathlib docs · Source

Turing machines

The files PostTuringMachine.lean and StackTuringMachine.lean define a sequence of simple machine languages, starting with Turing machines and working up to more complex languages based on Wang B-machines.

PostTuringMachine.lean covers the TM0 model and TM1 model; StackTuringMachine.lean adds the TM2 model.

Naming conventions

Each model of computation in this file shares a naming convention for the elements of a model of computation. These are the parameters for the language:

  • Γ is the alphabet on the tape.
  • Λ is the set of labels, or internal machine states.
  • σ is the type of internal memory, not on the tape. This does not exist in the TM0 model, and later models achieve this by mixing it into Λ.
  • K is used in the TM2 model, which has multiple stacks, and denotes the number of such stacks.

All of these variables denote "essentially finite" types, but for technical reasons it is convenient to allow them to be infinite anyway. When using an infinite type, we will be interested in proving that only finitely many values of the type are ever interacted with.

Given these parameters, there are a few common structures for the model that arise:

  • Stmt is the set of all actions that can be performed in one step. For the TM0 model this set is finite, and for later models it is an infinite inductive type representing "possible program texts".
  • Cfg is the set of instantaneous configurations, that is, the state of the machine together with its environment.
  • Machine is the set of all machines in the model. Usually this is approximately a function Λ → Stmt, although different models have different ways of halting and other actions.
  • step : Cfg → Option Cfg is the function that describes how the state evolves over one step. If step c = none, then c is a terminal state, and the result of the computation is read off from c. Because of the type of step, these models are all deterministic by construction.
  • init : Input → Cfg sets up the initial state. The type Input depends on the model; in most cases it is List Γ.
  • eval : Machine → Input → Part Output, given a machine M and input i, starts from init i, runs step until it reaches an output, and then applies a function Cfg → Output to the final state to obtain the result. The type Output depends on the model.
  • Supports : Machine → Finset Λ → Prop asserts that a machine M starts in S : Finset Λ, and can only ever jump to other states inside S. This implies that the behavior of M on any input cannot depend on its values outside S. We use this to allow Λ to be an infinite set when convenient, and prove that only finitely many of these states are actually accessible. This formalizes "essentially finite" mentioned above.

The TM2 model

The TM2 model removes the tape entirely from the TM1 model, replacing it with an arbitrary (finite) collection of stacks, each with elements of different types (the alphabet of stack k : K is Γ k). The statements are:

  • push k (f : σ → Γ k) q puts f a on the k-th stack, then does q.
  • pop k (f : σ → Option (Γ k) → σ) q changes the state to f a (S k).head, where S k is the value of the k-th stack, and removes this element from the stack, then does q.
  • peek k (f : σ → Option (Γ k) → σ) q changes the state to f a (S k).head, where S k is the value of the k-th stack, then does q.
  • load (f : σ → σ) q reads nothing but applies f to the internal state, then does q.
  • branch (f : σ → Bool) qtrue qfalse does qtrue or qfalse according to f a.
  • goto (f : σ → Λ) jumps to label f a.
  • halt halts on the next step.

The configuration is a tuple (l, var, stk) where l : Option Λ is the current label to run or none for the halting state, var : σ is the (finite) internal state, and stk : ∀ k, List (Γ k) is the collection of stacks. (Note that unlike the TM0 and TM1 models, these are not ListBlanks, they have definite ends that can be detected by the pop command.)

Given a designated stack k and a value L : List (Γ k), the initial configuration has all the stacks empty except the designated "input" stack; in eval this designated stack also functions as the output stack.

TM2 emulator in TM1

To prove that TM2 computable functions are TM1 computable, we need to reduce each TM2 program to a TM1 program. So suppose a TM2 program is given. This program has to maintain a whole collection of stacks, but we have only one tape, so we must "multiplex" them all together. Pictorially, if stack 1 contains [a, b] and stack 2 contains [c, d, e, f] then the tape looks like this:

bottom:  ... | _ | T | _ | _ | _ | _ | ...
stack 1: ... | _ | b | a | _ | _ | _ | ...
stack 2: ... | _ | f | e | d | c | _ | ...

where a tape element is a vertical slice through the diagram. Here the alphabet is Γ' := Bool × ∀ k, Option (Γ k), where:

  • bottom : Bool is marked only in one place, the initial position of the TM, and represents the tail of all stacks. It is never modified.
  • stk k : Option (Γ k) is the value of the k-th stack, if in range, otherwise none (which is the blank value). Note that the head of the stack is at the far end; this is so that push and pop don't have to do any shifting.

In "resting" position, the TM is sitting at the position marked bottom. For non-stack actions, it operates in place, but for the stack actions push, peek, and pop, it must shuttle to the end of the appropriate stack, make its changes, and then return to the bottom. So the states are:

  • normal (l : Λ): waiting at bottom to execute function l
  • go k (s : StAct k) (q : Stmt₂): travelling to the right to get to the end of stack k in order to perform stack action s, and later continue with executing q
  • ret (q : Stmt₂): travelling to the left after having performed a stack action, and executing q once we arrive

Because of the shuttling, emulation overhead is O(n), where n is the current maximum of the length of all stacks. Therefore a program that takes k steps to run in TM2 takes O((m+k)k) steps to run when emulated in TM1, where m is the length of the input.

theorem Turing.TM2to1.Λ'.ret.injEq E0 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (a a_1 : Turing.TM2.Stmt Γ Λ σ),
  (Turing.TM2to1.Λ'.ret a = Turing.TM2to1.Λ'.ret a_1) = (a = a_1)

theorem Turing.TM2.stepAux.match_1.congr_eq_1 E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4}
  (motive : Turing.TM2.Stmt Γ Λ σ → σ → ((k : K) → List (Γ k)) → Sort u_5) (x : Turing.TM2.Stmt Γ Λ σ) (x_1 : σ)
  (x_2 : (k : K) → List (Γ k))
  (h_1 :
    (k : K) →
      (f : σ → Γ k) →
        (q : Turing.TM2.Stmt Γ Λ σ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.push k f q) v S)
  (h_2 :
    (k : K) →
      (f : σ → Option (Γ k) → σ) →
        (q : Turing.TM2.Stmt Γ Λ σ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.peek k f q) v S)
  (h_3 :
    (k : K) →
      (f : σ → Option (Γ k) → σ) →
        (q : Turing.TM2.Stmt Γ Λ σ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.pop k f q) v S)
  (h_4 :
    (a : σ → σ) →
      (q : Turing.TM2.Stmt Γ Λ σ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.load a q) v S)
  (h_5 :
    (f : σ → Bool) →
      (q₁ q₂ : Turing.TM2.Stmt Γ Λ σ) →
        (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.branch f q₁ q₂) v S)
  (h_6 : (f : σ → Λ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.goto f) v S)
  (h_7 : (v : σ) → (S : (k : K) → List (Γ k)) → motive Turing.TM2.Stmt.halt v S) (k : K) (f : σ → Γ k)
  (q : Turing.TM2.Stmt Γ Λ σ) (v : σ) (S : (k : K) → List (Γ k)),
  x = Turing.TM2.Stmt.push k f q →
    x_1 = v →
      x_2 = S →
        (match x, x_1, x_2 with
          | Turing.TM2.Stmt.push k f q, v, S => h_1 k f q v S
          | Turing.TM2.Stmt.peek k f q, v, S => h_2 k f q v S
          | Turing.TM2.Stmt.pop k f q, v, S => h_3 k f q v S
          | Turing.TM2.Stmt.load a q, v, S => h_4 a q v S
          | Turing.TM2.Stmt.branch f q₁ q₂, v, S => h_5 f q₁ q₂ v S
          | Turing.TM2.Stmt.goto f, v, S => h_6 f v S
          | Turing.TM2.Stmt.halt, v, S => h_7 v S) ≍
          h_1 k f q v S

theorem Turing.TM2.Stmt.branch.inj E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} {a : σ → Bool} {a_1 a_2 : Turing.TM2.Stmt Γ Λ σ}
  {a_3 : σ → Bool} {a_4 a_5 : Turing.TM2.Stmt Γ Λ σ},
  Turing.TM2.Stmt.branch a a_1 a_2 = Turing.TM2.Stmt.branch a_3 a_4 a_5 → a = a_3 ∧ a_1 = a_4 ∧ a_2 = a_5

def Turing.TM2to1.StAct.ctorIdx E1 #

{K : Type u_1} → {Γ : K → Type u_2} → {σ : Type u_4} → {k : K} → Turing.TM2to1.StAct K Γ σ k → ℕ

abbrev Turing.TM2to1.StAct.ctorElimType E1 #

{K : Type u_1} →
  {Γ : K → Type u_2} →
    {σ : Type u_4} →
      {k : K} → {motive : Turing.TM2to1.StAct K Γ σ k → Sort u} → ℕ → Sort (max 1 (imax (max (u_2 + 1) (u_4 + 1)) u))

theorem Turing.TM2.SupportsStmt.match_1.congr_eq_4 E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (motive : Turing.TM2.Stmt Γ Λ σ → Sort u_5)
  (x : Turing.TM2.Stmt Γ Λ σ)
  (h_1 : (k : K) → (a : σ → Γ k) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.push k a q))
  (h_2 : (k : K) → (a : σ → Option (Γ k) → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.peek k a q))
  (h_3 : (k : K) → (a : σ → Option (Γ k) → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.pop k a q))
  (h_4 : (a : σ → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.load a q))
  (h_5 : (a : σ → Bool) → (q₁ q₂ : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.branch a q₁ q₂))
  (h_6 : (l : σ → Λ) → motive (Turing.TM2.Stmt.goto l)) (h_7 : Unit → motive Turing.TM2.Stmt.halt) (a : σ → σ)
  (q : Turing.TM2.Stmt Γ Λ σ),
  x = Turing.TM2.Stmt.load a q →
    (match x with
      | Turing.TM2.Stmt.push k a q => h_1 k a q
      | Turing.TM2.Stmt.peek k a q => h_2 k a q
      | Turing.TM2.Stmt.pop k a q => h_3 k a q
      | Turing.TM2.Stmt.load a q => h_4 a q
      | Turing.TM2.Stmt.branch a q₁ q₂ => h_5 a q₁ q₂
      | Turing.TM2.Stmt.goto l => h_6 l
      | Turing.TM2.Stmt.halt => h_7 ()) ≍
      h_4 a q

theorem Turing.TM2.stepAux.match_1.congr_eq_5 E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4}
  (motive : Turing.TM2.Stmt Γ Λ σ → σ → ((k : K) → List (Γ k)) → Sort u_5) (x : Turing.TM2.Stmt Γ Λ σ) (x_1 : σ)
  (x_2 : (k : K) → List (Γ k))
  (h_1 :
    (k : K) →
      (f : σ → Γ k) →
        (q : Turing.TM2.Stmt Γ Λ σ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.push k f q) v S)
  (h_2 :
    (k : K) →
      (f : σ → Option (Γ k) → σ) →
        (q : Turing.TM2.Stmt Γ Λ σ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.peek k f q) v S)
  (h_3 :
    (k : K) →
      (f : σ → Option (Γ k) → σ) →
        (q : Turing.TM2.Stmt Γ Λ σ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.pop k f q) v S)
  (h_4 :
    (a : σ → σ) →
      (q : Turing.TM2.Stmt Γ Λ σ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.load a q) v S)
  (h_5 :
    (f : σ → Bool) →
      (q₁ q₂ : Turing.TM2.Stmt Γ Λ σ) →
        (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.branch f q₁ q₂) v S)
  (h_6 : (f : σ → Λ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.goto f) v S)
  (h_7 : (v : σ) → (S : (k : K) → List (Γ k)) → motive Turing.TM2.Stmt.halt v S) (f : σ → Bool)
  (q₁ q₂ : Turing.TM2.Stmt Γ Λ σ) (v : σ) (S : (k : K) → List (Γ k)),
  x = Turing.TM2.Stmt.branch f q₁ q₂ →
    x_1 = v →
      x_2 = S →
        (match x, x_1, x_2 with
          | Turing.TM2.Stmt.push k f q, v, S => h_1 k f q v S
          | Turing.TM2.Stmt.peek k f q, v, S => h_2 k f q v S
          | Turing.TM2.Stmt.pop k f q, v, S => h_3 k f q v S
          | Turing.TM2.Stmt.load a q, v, S => h_4 a q v S
          | Turing.TM2.Stmt.branch f q₁ q₂, v, S => h_5 f q₁ q₂ v S
          | Turing.TM2.Stmt.goto f, v, S => h_6 f v S
          | Turing.TM2.Stmt.halt, v, S => h_7 v S) ≍
          h_5 f q₁ q₂ v S

theorem Turing.TM2to1.StAct.peek.injEq E0 #

∀ {K : Type u_1} {Γ : K → Type u_2} {σ : Type u_4} {k : K} (a a_1 : σ → Option (Γ k) → σ),
  (Turing.TM2to1.StAct.peek a = Turing.TM2to1.StAct.peek a_1) = (a = a_1)

theorem Turing.TM2.stepAux.match_1.congr_eq_6 E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4}
  (motive : Turing.TM2.Stmt Γ Λ σ → σ → ((k : K) → List (Γ k)) → Sort u_5) (x : Turing.TM2.Stmt Γ Λ σ) (x_1 : σ)
  (x_2 : (k : K) → List (Γ k))
  (h_1 :
    (k : K) →
      (f : σ → Γ k) →
        (q : Turing.TM2.Stmt Γ Λ σ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.push k f q) v S)
  (h_2 :
    (k : K) →
      (f : σ → Option (Γ k) → σ) →
        (q : Turing.TM2.Stmt Γ Λ σ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.peek k f q) v S)
  (h_3 :
    (k : K) →
      (f : σ → Option (Γ k) → σ) →
        (q : Turing.TM2.Stmt Γ Λ σ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.pop k f q) v S)
  (h_4 :
    (a : σ → σ) →
      (q : Turing.TM2.Stmt Γ Λ σ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.load a q) v S)
  (h_5 :
    (f : σ → Bool) →
      (q₁ q₂ : Turing.TM2.Stmt Γ Λ σ) →
        (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.branch f q₁ q₂) v S)
  (h_6 : (f : σ → Λ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.goto f) v S)
  (h_7 : (v : σ) → (S : (k : K) → List (Γ k)) → motive Turing.TM2.Stmt.halt v S) (f : σ → Λ) (v : σ)
  (S : (k : K) → List (Γ k)),
  x = Turing.TM2.Stmt.goto f →
    x_1 = v →
      x_2 = S →
        (match x, x_1, x_2 with
          | Turing.TM2.Stmt.push k f q, v, S => h_1 k f q v S
          | Turing.TM2.Stmt.peek k f q, v, S => h_2 k f q v S
          | Turing.TM2.Stmt.pop k f q, v, S => h_3 k f q v S
          | Turing.TM2.Stmt.load a q, v, S => h_4 a q v S
          | Turing.TM2.Stmt.branch f q₁ q₂, v, S => h_5 f q₁ q₂ v S
          | Turing.TM2.Stmt.goto f, v, S => h_6 f v S
          | Turing.TM2.Stmt.halt, v, S => h_7 v S) ≍
          h_6 f v S

theorem Turing.TM2.stepAux.match_1.congr_eq_7 E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4}
  (motive : Turing.TM2.Stmt Γ Λ σ → σ → ((k : K) → List (Γ k)) → Sort u_5) (x : Turing.TM2.Stmt Γ Λ σ) (x_1 : σ)
  (x_2 : (k : K) → List (Γ k))
  (h_1 :
    (k : K) →
      (f : σ → Γ k) →
        (q : Turing.TM2.Stmt Γ Λ σ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.push k f q) v S)
  (h_2 :
    (k : K) →
      (f : σ → Option (Γ k) → σ) →
        (q : Turing.TM2.Stmt Γ Λ σ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.peek k f q) v S)
  (h_3 :
    (k : K) →
      (f : σ → Option (Γ k) → σ) →
        (q : Turing.TM2.Stmt Γ Λ σ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.pop k f q) v S)
  (h_4 :
    (a : σ → σ) →
      (q : Turing.TM2.Stmt Γ Λ σ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.load a q) v S)
  (h_5 :
    (f : σ → Bool) →
      (q₁ q₂ : Turing.TM2.Stmt Γ Λ σ) →
        (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.branch f q₁ q₂) v S)
  (h_6 : (f : σ → Λ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.goto f) v S)
  (h_7 : (v : σ) → (S : (k : K) → List (Γ k)) → motive Turing.TM2.Stmt.halt v S) (v : σ) (S : (k : K) → List (Γ k)),
  x = Turing.TM2.Stmt.halt →
    x_1 = v →
      x_2 = S →
        (match x, x_1, x_2 with
          | Turing.TM2.Stmt.push k f q, v, S => h_1 k f q v S
          | Turing.TM2.Stmt.peek k f q, v, S => h_2 k f q v S
          | Turing.TM2.Stmt.pop k f q, v, S => h_3 k f q v S
          | Turing.TM2.Stmt.load a q, v, S => h_4 a q v S
          | Turing.TM2.Stmt.branch f q₁ q₂, v, S => h_5 f q₁ q₂ v S
          | Turing.TM2.Stmt.goto f, v, S => h_6 f v S
          | Turing.TM2.Stmt.halt, v, S => h_7 v S) ≍
          h_7 v S

theorem Turing.TM2to1.stRun.match_1.congr_eq_3 E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {σ : Type u_3} {k : K} (motive : Turing.TM2to1.StAct K Γ σ k → Sort u_4)
  (x : Turing.TM2to1.StAct K Γ σ k) (h_1 : (f : σ → Γ k) → motive (Turing.TM2to1.StAct.push f))
  (h_2 : (f : σ → Option (Γ k) → σ) → motive (Turing.TM2to1.StAct.peek f))
  (h_3 : (f : σ → Option (Γ k) → σ) → motive (Turing.TM2to1.StAct.pop f)) (f : σ → Option (Γ k) → σ),
  x = Turing.TM2to1.StAct.pop f →
    (match x with
      | Turing.TM2to1.StAct.push f => h_1 f
      | Turing.TM2to1.StAct.peek f => h_2 f
      | Turing.TM2to1.StAct.pop f => h_3 f) ≍
      h_3 f

theorem Turing.TM2.Stmt.pop.inj E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} {k : K} {a : σ → Option (Γ k) → σ}
  {a_1 : Turing.TM2.Stmt Γ Λ σ} {k_1 : K} {a_2 : σ → Option (Γ k_1) → σ} {a_3 : Turing.TM2.Stmt Γ Λ σ},
  Turing.TM2.Stmt.pop k a a_1 = Turing.TM2.Stmt.pop k_1 a_2 a_3 → k = k_1 ∧ a ≍ a_2 ∧ a_1 = a_3

theorem Turing.TM2.SupportsStmt.match_1.congr_eq_1 E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (motive : Turing.TM2.Stmt Γ Λ σ → Sort u_5)
  (x : Turing.TM2.Stmt Γ Λ σ)
  (h_1 : (k : K) → (a : σ → Γ k) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.push k a q))
  (h_2 : (k : K) → (a : σ → Option (Γ k) → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.peek k a q))
  (h_3 : (k : K) → (a : σ → Option (Γ k) → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.pop k a q))
  (h_4 : (a : σ → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.load a q))
  (h_5 : (a : σ → Bool) → (q₁ q₂ : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.branch a q₁ q₂))
  (h_6 : (l : σ → Λ) → motive (Turing.TM2.Stmt.goto l)) (h_7 : Unit → motive Turing.TM2.Stmt.halt) (k : K) (a : σ → Γ k)
  (q : Turing.TM2.Stmt Γ Λ σ),
  x = Turing.TM2.Stmt.push k a q →
    (match x with
      | Turing.TM2.Stmt.push k a q => h_1 k a q
      | Turing.TM2.Stmt.peek k a q => h_2 k a q
      | Turing.TM2.Stmt.pop k a q => h_3 k a q
      | Turing.TM2.Stmt.load a q => h_4 a q
      | Turing.TM2.Stmt.branch a q₁ q₂ => h_5 a q₁ q₂
      | Turing.TM2.Stmt.goto l => h_6 l
      | Turing.TM2.Stmt.halt => h_7 ()) ≍
      h_1 k a q

theorem Turing.TM2.stmts₁.match_1.congr_eq_6 E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (motive : Turing.TM2.Stmt Γ Λ σ → Sort u_5)
  (x : Turing.TM2.Stmt Γ Λ σ)
  (h_1 :
    (Q : Turing.TM2.Stmt Γ Λ σ) →
      (k : K) →
        (a : σ → Γ k) →
          (q : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.push k a q → motive (Turing.TM2.Stmt.push k a q))
  (h_2 :
    (Q : Turing.TM2.Stmt Γ Λ σ) →
      (k : K) →
        (a : σ → Option (Γ k) → σ) →
          (q : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.peek k a q → motive (Turing.TM2.Stmt.peek k a q))
  (h_3 :
    (Q : Turing.TM2.Stmt Γ Λ σ) →
      (k : K) →
        (a : σ → Option (Γ k) → σ) →
          (q : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.pop k a q → motive (Turing.TM2.Stmt.pop k a q))
  (h_4 :
    (Q : Turing.TM2.Stmt Γ Λ σ) →
      (a : σ → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.load a q → motive (Turing.TM2.Stmt.load a q))
  (h_5 :
    (Q : Turing.TM2.Stmt Γ Λ σ) →
      (a : σ → Bool) →
        (q₁ q₂ : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.branch a q₁ q₂ → motive (Turing.TM2.Stmt.branch a q₁ q₂))
  (h_6 : (Q : Turing.TM2.Stmt Γ Λ σ) → (a : σ → Λ) → Q = Turing.TM2.Stmt.goto a → motive (Turing.TM2.Stmt.goto a))
  (h_7 : (Q : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.halt → motive Turing.TM2.Stmt.halt) (a : σ → Λ),
  x = Turing.TM2.Stmt.goto a →
    (match x with
      | Q@h:(Turing.TM2.Stmt.push k a q) => h_1 Q k a q h
      | Q@h:(Turing.TM2.Stmt.peek k a q) => h_2 Q k a q h
      | Q@h:(Turing.TM2.Stmt.pop k a q) => h_3 Q k a q h
      | Q@h:(Turing.TM2.Stmt.load a q) => h_4 Q a q h
      | Q@h:(Turing.TM2.Stmt.branch a q₁ q₂) => h_5 Q a q₁ q₂ h
      | Q@h:(Turing.TM2.Stmt.goto a) => h_6 Q a h
      | Q@h:Turing.TM2.Stmt.halt => h_7 Q h) ≍
      h_6 (Turing.TM2.Stmt.goto a) a ⋯

theorem Turing.TM2.Stmt.load.injEq E0 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (a : σ → σ) (a_1 : Turing.TM2.Stmt Γ Λ σ)
  (a_2 : σ → σ) (a_3 : Turing.TM2.Stmt Γ Λ σ),
  (Turing.TM2.Stmt.load a a_1 = Turing.TM2.Stmt.load a_2 a_3) = (a = a_2 ∧ a_1 = a_3)

abbrev Turing.TM2to1.Λ'.ctorElimType E1 #

{K : Type u_1} →
  {Γ : K → Type u_2} →
    {Λ : Type u_3} →
      {σ : Type u_4} →
        {motive : Turing.TM2to1.Λ' K Γ Λ σ → Sort u} →
          ℕ →
            Sort
              (max 1
                  (imax (u_1 + 1) (max (u_2 + 1) (u_4 + 1)) (max (max (max (u_1 + 1) (u_2 + 1)) (u_3 + 1)) (u_4 + 1)) u)
                  (imax (u_3 + 1) u) (imax (max (max (max (u_1 + 1) (u_2 + 1)) (u_3 + 1)) (u_4 + 1)) u))

theorem Turing.TM2.step.match_1.congr_eq_1 E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (motive : Turing.TM2.Cfg Γ Λ σ → Sort u_5)
  (x : Turing.TM2.Cfg Γ Λ σ)
  (h_1 : (var : σ) → (stk : (k : K) → List (Γ k)) → motive { l := none, var := var, stk := stk })
  (h_2 : (l : Λ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive { l := some l, var := v, stk := S }) (var : σ)
  (stk : (k : K) → List (Γ k)),
  x = { l := none, var := var, stk := stk } →
    (match x with
      | { l := none, var := var, stk := stk } => h_1 var stk
      | { l := some l, var := v, stk := S } => h_2 l v S) ≍
      h_1 var stk

theorem Turing.TM2to1.trStmts₁.match_1.congr_eq_6 E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (motive : Turing.TM2.Stmt Γ Λ σ → Sort u_5)
  (x : Turing.TM2.Stmt Γ Λ σ)
  (h_1 : (k : K) → (f : σ → Γ k) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.push k f q))
  (h_2 : (k : K) → (f : σ → Option (Γ k) → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.peek k f q))
  (h_3 : (k : K) → (f : σ → Option (Γ k) → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.pop k f q))
  (h_4 : (a : σ → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.load a q))
  (h_5 : (a : σ → Bool) → (q₁ q₂ : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.branch a q₁ q₂))
  (h_6 : (x : Turing.TM2.Stmt Γ Λ σ) → motive x) (x_1 : Turing.TM2.Stmt Γ Λ σ),
  x = x_1 →
    (∀ (k : K) (f : σ → Γ k) (q : Turing.TM2.Stmt Γ Λ σ), x_1 = Turing.TM2.Stmt.push k f q → False) →
      (∀ (k : K) (f : σ → Option (Γ k) → σ) (q : Turing.TM2.Stmt Γ Λ σ), x_1 = Turing.TM2.Stmt.peek k f q → False) →
        (∀ (k : K) (f : σ → Option (Γ k) → σ) (q : Turing.TM2.Stmt Γ Λ σ), x_1 = Turing.TM2.Stmt.pop k f q → False) →
          (∀ (a : σ → σ) (q : Turing.TM2.Stmt Γ Λ σ), x_1 = Turing.TM2.Stmt.load a q → False) →
            (∀ (a : σ → Bool) (q₁ q₂ : Turing.TM2.Stmt Γ Λ σ), x_1 = Turing.TM2.Stmt.branch a q₁ q₂ → False) →
              (match x with
                | Turing.TM2.Stmt.push k f q => h_1 k f q
                | Turing.TM2.Stmt.peek k f q => h_2 k f q
                | Turing.TM2.Stmt.pop k f q => h_3 k f q
                | Turing.TM2.Stmt.load a q => h_4 a q
                | Turing.TM2.Stmt.branch a q₁ q₂ => h_5 a q₁ q₂
                | x => h_6 x) ≍
                h_6 x_1

theorem Turing.TM2to1.tr.match_1.congr_eq_1 E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (motive : Turing.TM2to1.Λ' K Γ Λ σ → Sort u_5)
  (x : Turing.TM2to1.Λ' K Γ Λ σ) (h_1 : (q : Λ) → motive (Turing.TM2to1.Λ'.normal q))
  (h_2 : (k : K) → (s : Turing.TM2to1.StAct K Γ σ k) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2to1.Λ'.go k s q))
  (h_3 : (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2to1.Λ'.ret q)) (q : Λ),
  x = Turing.TM2to1.Λ'.normal q →
    (match x with
      | Turing.TM2to1.Λ'.normal q => h_1 q
      | Turing.TM2to1.Λ'.go k s q => h_2 k s q
      | Turing.TM2to1.Λ'.ret q => h_3 q) ≍
      h_1 q

theorem Turing.TM2.Stmt.load.inj E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} {a : σ → σ} {a_1 : Turing.TM2.Stmt Γ Λ σ}
  {a_2 : σ → σ} {a_3 : Turing.TM2.Stmt Γ Λ σ},
  Turing.TM2.Stmt.load a a_1 = Turing.TM2.Stmt.load a_2 a_3 → a = a_2 ∧ a_1 = a_3

theorem Turing.TM2to1.StAct.push.inj E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {σ : Type u_4} {k : K} {a a_1 : σ → Γ k},
  Turing.TM2to1.StAct.push a = Turing.TM2to1.StAct.push a_1 → a = a_1

theorem Turing.TM2to1.stRun.match_1.congr_eq_2 E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {σ : Type u_3} {k : K} (motive : Turing.TM2to1.StAct K Γ σ k → Sort u_4)
  (x : Turing.TM2to1.StAct K Γ σ k) (h_1 : (f : σ → Γ k) → motive (Turing.TM2to1.StAct.push f))
  (h_2 : (f : σ → Option (Γ k) → σ) → motive (Turing.TM2to1.StAct.peek f))
  (h_3 : (f : σ → Option (Γ k) → σ) → motive (Turing.TM2to1.StAct.pop f)) (f : σ → Option (Γ k) → σ),
  x = Turing.TM2to1.StAct.peek f →
    (match x with
      | Turing.TM2to1.StAct.push f => h_1 f
      | Turing.TM2to1.StAct.peek f => h_2 f
      | Turing.TM2to1.StAct.pop f => h_3 f) ≍
      h_2 f

theorem Turing.TM2to1.trStmts₁.match_1.congr_eq_2 E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (motive : Turing.TM2.Stmt Γ Λ σ → Sort u_5)
  (x : Turing.TM2.Stmt Γ Λ σ)
  (h_1 : (k : K) → (f : σ → Γ k) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.push k f q))
  (h_2 : (k : K) → (f : σ → Option (Γ k) → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.peek k f q))
  (h_3 : (k : K) → (f : σ → Option (Γ k) → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.pop k f q))
  (h_4 : (a : σ → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.load a q))
  (h_5 : (a : σ → Bool) → (q₁ q₂ : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.branch a q₁ q₂))
  (h_6 : (x : Turing.TM2.Stmt Γ Λ σ) → motive x) (k : K) (f : σ → Option (Γ k) → σ) (q : Turing.TM2.Stmt Γ Λ σ),
  x = Turing.TM2.Stmt.peek k f q →
    (match x with
      | Turing.TM2.Stmt.push k f q => h_1 k f q
      | Turing.TM2.Stmt.peek k f q => h_2 k f q
      | Turing.TM2.Stmt.pop k f q => h_3 k f q
      | Turing.TM2.Stmt.load a q => h_4 a q
      | Turing.TM2.Stmt.branch a q₁ q₂ => h_5 a q₁ q₂
      | x => h_6 x) ≍
      h_2 k f q

theorem Turing.TM2.SupportsStmt.match_1.congr_eq_3 E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (motive : Turing.TM2.Stmt Γ Λ σ → Sort u_5)
  (x : Turing.TM2.Stmt Γ Λ σ)
  (h_1 : (k : K) → (a : σ → Γ k) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.push k a q))
  (h_2 : (k : K) → (a : σ → Option (Γ k) → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.peek k a q))
  (h_3 : (k : K) → (a : σ → Option (Γ k) → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.pop k a q))
  (h_4 : (a : σ → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.load a q))
  (h_5 : (a : σ → Bool) → (q₁ q₂ : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.branch a q₁ q₂))
  (h_6 : (l : σ → Λ) → motive (Turing.TM2.Stmt.goto l)) (h_7 : Unit → motive Turing.TM2.Stmt.halt) (k : K)
  (a : σ → Option (Γ k) → σ) (q : Turing.TM2.Stmt Γ Λ σ),
  x = Turing.TM2.Stmt.pop k a q →
    (match x with
      | Turing.TM2.Stmt.push k a q => h_1 k a q
      | Turing.TM2.Stmt.peek k a q => h_2 k a q
      | Turing.TM2.Stmt.pop k a q => h_3 k a q
      | Turing.TM2.Stmt.load a q => h_4 a q
      | Turing.TM2.Stmt.branch a q₁ q₂ => h_5 a q₁ q₂
      | Turing.TM2.Stmt.goto l => h_6 l
      | Turing.TM2.Stmt.halt => h_7 ()) ≍
      h_3 k a q

theorem Turing.TM2.Stmt.push.inj E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} {k : K} {a : σ → Γ k} {a_1 : Turing.TM2.Stmt Γ Λ σ}
  {k_1 : K} {a_2 : σ → Γ k_1} {a_3 : Turing.TM2.Stmt Γ Λ σ},
  Turing.TM2.Stmt.push k a a_1 = Turing.TM2.Stmt.push k_1 a_2 a_3 → k = k_1 ∧ a ≍ a_2 ∧ a_1 = a_3

theorem Turing.TM2.stepAux.match_1.congr_eq_3 E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4}
  (motive : Turing.TM2.Stmt Γ Λ σ → σ → ((k : K) → List (Γ k)) → Sort u_5) (x : Turing.TM2.Stmt Γ Λ σ) (x_1 : σ)
  (x_2 : (k : K) → List (Γ k))
  (h_1 :
    (k : K) →
      (f : σ → Γ k) →
        (q : Turing.TM2.Stmt Γ Λ σ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.push k f q) v S)
  (h_2 :
    (k : K) →
      (f : σ → Option (Γ k) → σ) →
        (q : Turing.TM2.Stmt Γ Λ σ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.peek k f q) v S)
  (h_3 :
    (k : K) →
      (f : σ → Option (Γ k) → σ) →
        (q : Turing.TM2.Stmt Γ Λ σ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.pop k f q) v S)
  (h_4 :
    (a : σ → σ) →
      (q : Turing.TM2.Stmt Γ Λ σ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.load a q) v S)
  (h_5 :
    (f : σ → Bool) →
      (q₁ q₂ : Turing.TM2.Stmt Γ Λ σ) →
        (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.branch f q₁ q₂) v S)
  (h_6 : (f : σ → Λ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.goto f) v S)
  (h_7 : (v : σ) → (S : (k : K) → List (Γ k)) → motive Turing.TM2.Stmt.halt v S) (k : K) (f : σ → Option (Γ k) → σ)
  (q : Turing.TM2.Stmt Γ Λ σ) (v : σ) (S : (k : K) → List (Γ k)),
  x = Turing.TM2.Stmt.pop k f q →
    x_1 = v →
      x_2 = S →
        (match x, x_1, x_2 with
          | Turing.TM2.Stmt.push k f q, v, S => h_1 k f q v S
          | Turing.TM2.Stmt.peek k f q, v, S => h_2 k f q v S
          | Turing.TM2.Stmt.pop k f q, v, S => h_3 k f q v S
          | Turing.TM2.Stmt.load a q, v, S => h_4 a q v S
          | Turing.TM2.Stmt.branch f q₁ q₂, v, S => h_5 f q₁ q₂ v S
          | Turing.TM2.Stmt.goto f, v, S => h_6 f v S
          | Turing.TM2.Stmt.halt, v, S => h_7 v S) ≍
          h_3 k f q v S

theorem Turing.TM2.step.match_1.congr_eq_2 E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (motive : Turing.TM2.Cfg Γ Λ σ → Sort u_5)
  (x : Turing.TM2.Cfg Γ Λ σ)
  (h_1 : (var : σ) → (stk : (k : K) → List (Γ k)) → motive { l := none, var := var, stk := stk })
  (h_2 : (l : Λ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive { l := some l, var := v, stk := S }) (l : Λ) (v : σ)
  (S : (k : K) → List (Γ k)),
  x = { l := some l, var := v, stk := S } →
    (match x with
      | { l := none, var := var, stk := stk } => h_1 var stk
      | { l := some l, var := v, stk := S } => h_2 l v S) ≍
      h_2 l v S

theorem Turing.TM2.Cfg.mk.injEq E0 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (l : Option Λ) (var : σ) (stk : (k : K) → List (Γ k))
  (l_1 : Option Λ) (var_1 : σ) (stk_1 : (k : K) → List (Γ k)),
  ({ l := l, var := var, stk := stk } = { l := l_1, var := var_1, stk := stk_1 }) =
    (l = l_1 ∧ var = var_1 ∧ stk = stk_1)

theorem Turing.TM2.stepAux.match_1.congr_eq_4 E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4}
  (motive : Turing.TM2.Stmt Γ Λ σ → σ → ((k : K) → List (Γ k)) → Sort u_5) (x : Turing.TM2.Stmt Γ Λ σ) (x_1 : σ)
  (x_2 : (k : K) → List (Γ k))
  (h_1 :
    (k : K) →
      (f : σ → Γ k) →
        (q : Turing.TM2.Stmt Γ Λ σ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.push k f q) v S)
  (h_2 :
    (k : K) →
      (f : σ → Option (Γ k) → σ) →
        (q : Turing.TM2.Stmt Γ Λ σ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.peek k f q) v S)
  (h_3 :
    (k : K) →
      (f : σ → Option (Γ k) → σ) →
        (q : Turing.TM2.Stmt Γ Λ σ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.pop k f q) v S)
  (h_4 :
    (a : σ → σ) →
      (q : Turing.TM2.Stmt Γ Λ σ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.load a q) v S)
  (h_5 :
    (f : σ → Bool) →
      (q₁ q₂ : Turing.TM2.Stmt Γ Λ σ) →
        (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.branch f q₁ q₂) v S)
  (h_6 : (f : σ → Λ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.goto f) v S)
  (h_7 : (v : σ) → (S : (k : K) → List (Γ k)) → motive Turing.TM2.Stmt.halt v S) (a : σ → σ) (q : Turing.TM2.Stmt Γ Λ σ)
  (v : σ) (S : (k : K) → List (Γ k)),
  x = Turing.TM2.Stmt.load a q →
    x_1 = v →
      x_2 = S →
        (match x, x_1, x_2 with
          | Turing.TM2.Stmt.push k f q, v, S => h_1 k f q v S
          | Turing.TM2.Stmt.peek k f q, v, S => h_2 k f q v S
          | Turing.TM2.Stmt.pop k f q, v, S => h_3 k f q v S
          | Turing.TM2.Stmt.load a q, v, S => h_4 a q v S
          | Turing.TM2.Stmt.branch f q₁ q₂, v, S => h_5 f q₁ q₂ v S
          | Turing.TM2.Stmt.goto f, v, S => h_6 f v S
          | Turing.TM2.Stmt.halt, v, S => h_7 v S) ≍
          h_4 a q v S

theorem Turing.TM2to1.Λ'.normal.inj E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} {a a_1 : Λ},
  Turing.TM2to1.Λ'.normal a = Turing.TM2to1.Λ'.normal a_1 → a = a_1

theorem Turing.TM2.SupportsStmt.match_1.congr_eq_5 E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (motive : Turing.TM2.Stmt Γ Λ σ → Sort u_5)
  (x : Turing.TM2.Stmt Γ Λ σ)
  (h_1 : (k : K) → (a : σ → Γ k) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.push k a q))
  (h_2 : (k : K) → (a : σ → Option (Γ k) → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.peek k a q))
  (h_3 : (k : K) → (a : σ → Option (Γ k) → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.pop k a q))
  (h_4 : (a : σ → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.load a q))
  (h_5 : (a : σ → Bool) → (q₁ q₂ : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.branch a q₁ q₂))
  (h_6 : (l : σ → Λ) → motive (Turing.TM2.Stmt.goto l)) (h_7 : Unit → motive Turing.TM2.Stmt.halt) (a : σ → Bool)
  (q₁ q₂ : Turing.TM2.Stmt Γ Λ σ),
  x = Turing.TM2.Stmt.branch a q₁ q₂ →
    (match x with
      | Turing.TM2.Stmt.push k a q => h_1 k a q
      | Turing.TM2.Stmt.peek k a q => h_2 k a q
      | Turing.TM2.Stmt.pop k a q => h_3 k a q
      | Turing.TM2.Stmt.load a q => h_4 a q
      | Turing.TM2.Stmt.branch a q₁ q₂ => h_5 a q₁ q₂
      | Turing.TM2.Stmt.goto l => h_6 l
      | Turing.TM2.Stmt.halt => h_7 ()) ≍
      h_5 a q₁ q₂

theorem Turing.TM2.stmts₁.match_1.congr_eq_3 E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (motive : Turing.TM2.Stmt Γ Λ σ → Sort u_5)
  (x : Turing.TM2.Stmt Γ Λ σ)
  (h_1 :
    (Q : Turing.TM2.Stmt Γ Λ σ) →
      (k : K) →
        (a : σ → Γ k) →
          (q : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.push k a q → motive (Turing.TM2.Stmt.push k a q))
  (h_2 :
    (Q : Turing.TM2.Stmt Γ Λ σ) →
      (k : K) →
        (a : σ → Option (Γ k) → σ) →
          (q : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.peek k a q → motive (Turing.TM2.Stmt.peek k a q))
  (h_3 :
    (Q : Turing.TM2.Stmt Γ Λ σ) →
      (k : K) →
        (a : σ → Option (Γ k) → σ) →
          (q : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.pop k a q → motive (Turing.TM2.Stmt.pop k a q))
  (h_4 :
    (Q : Turing.TM2.Stmt Γ Λ σ) →
      (a : σ → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.load a q → motive (Turing.TM2.Stmt.load a q))
  (h_5 :
    (Q : Turing.TM2.Stmt Γ Λ σ) →
      (a : σ → Bool) →
        (q₁ q₂ : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.branch a q₁ q₂ → motive (Turing.TM2.Stmt.branch a q₁ q₂))
  (h_6 : (Q : Turing.TM2.Stmt Γ Λ σ) → (a : σ → Λ) → Q = Turing.TM2.Stmt.goto a → motive (Turing.TM2.Stmt.goto a))
  (h_7 : (Q : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.halt → motive Turing.TM2.Stmt.halt) (k : K)
  (a : σ → Option (Γ k) → σ) (q : Turing.TM2.Stmt Γ Λ σ),
  x = Turing.TM2.Stmt.pop k a q →
    (match x with
      | Q@h:(Turing.TM2.Stmt.push k a q) => h_1 Q k a q h
      | Q@h:(Turing.TM2.Stmt.peek k a q) => h_2 Q k a q h
      | Q@h:(Turing.TM2.Stmt.pop k a q) => h_3 Q k a q h
      | Q@h:(Turing.TM2.Stmt.load a q) => h_4 Q a q h
      | Q@h:(Turing.TM2.Stmt.branch a q₁ q₂) => h_5 Q a q₁ q₂ h
      | Q@h:(Turing.TM2.Stmt.goto a) => h_6 Q a h
      | Q@h:Turing.TM2.Stmt.halt => h_7 Q h) ≍
      h_3 (Turing.TM2.Stmt.pop k a q) k a q ⋯

theorem Turing.TM2.Stmt.goto.inj E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} {a a_1 : σ → Λ},
  Turing.TM2.Stmt.goto a = Turing.TM2.Stmt.goto a_1 → a = a_1

theorem Turing.TM2to1.StAct.push.injEq E0 #

∀ {K : Type u_1} {Γ : K → Type u_2} {σ : Type u_4} {k : K} (a a_1 : σ → Γ k),
  (Turing.TM2to1.StAct.push a = Turing.TM2to1.StAct.push a_1) = (a = a_1)

theorem Turing.TM2.stepAux.match_1.congr_eq_2 E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4}
  (motive : Turing.TM2.Stmt Γ Λ σ → σ → ((k : K) → List (Γ k)) → Sort u_5) (x : Turing.TM2.Stmt Γ Λ σ) (x_1 : σ)
  (x_2 : (k : K) → List (Γ k))
  (h_1 :
    (k : K) →
      (f : σ → Γ k) →
        (q : Turing.TM2.Stmt Γ Λ σ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.push k f q) v S)
  (h_2 :
    (k : K) →
      (f : σ → Option (Γ k) → σ) →
        (q : Turing.TM2.Stmt Γ Λ σ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.peek k f q) v S)
  (h_3 :
    (k : K) →
      (f : σ → Option (Γ k) → σ) →
        (q : Turing.TM2.Stmt Γ Λ σ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.pop k f q) v S)
  (h_4 :
    (a : σ → σ) →
      (q : Turing.TM2.Stmt Γ Λ σ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.load a q) v S)
  (h_5 :
    (f : σ → Bool) →
      (q₁ q₂ : Turing.TM2.Stmt Γ Λ σ) →
        (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.branch f q₁ q₂) v S)
  (h_6 : (f : σ → Λ) → (v : σ) → (S : (k : K) → List (Γ k)) → motive (Turing.TM2.Stmt.goto f) v S)
  (h_7 : (v : σ) → (S : (k : K) → List (Γ k)) → motive Turing.TM2.Stmt.halt v S) (k : K) (f : σ → Option (Γ k) → σ)
  (q : Turing.TM2.Stmt Γ Λ σ) (v : σ) (S : (k : K) → List (Γ k)),
  x = Turing.TM2.Stmt.peek k f q →
    x_1 = v →
      x_2 = S →
        (match x, x_1, x_2 with
          | Turing.TM2.Stmt.push k f q, v, S => h_1 k f q v S
          | Turing.TM2.Stmt.peek k f q, v, S => h_2 k f q v S
          | Turing.TM2.Stmt.pop k f q, v, S => h_3 k f q v S
          | Turing.TM2.Stmt.load a q, v, S => h_4 a q v S
          | Turing.TM2.Stmt.branch f q₁ q₂, v, S => h_5 f q₁ q₂ v S
          | Turing.TM2.Stmt.goto f, v, S => h_6 f v S
          | Turing.TM2.Stmt.halt, v, S => h_7 v S) ≍
          h_2 k f q v S

theorem Turing.TM2.stmts₁.match_1.congr_eq_4 E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (motive : Turing.TM2.Stmt Γ Λ σ → Sort u_5)
  (x : Turing.TM2.Stmt Γ Λ σ)
  (h_1 :
    (Q : Turing.TM2.Stmt Γ Λ σ) →
      (k : K) →
        (a : σ → Γ k) →
          (q : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.push k a q → motive (Turing.TM2.Stmt.push k a q))
  (h_2 :
    (Q : Turing.TM2.Stmt Γ Λ σ) →
      (k : K) →
        (a : σ → Option (Γ k) → σ) →
          (q : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.peek k a q → motive (Turing.TM2.Stmt.peek k a q))
  (h_3 :
    (Q : Turing.TM2.Stmt Γ Λ σ) →
      (k : K) →
        (a : σ → Option (Γ k) → σ) →
          (q : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.pop k a q → motive (Turing.TM2.Stmt.pop k a q))
  (h_4 :
    (Q : Turing.TM2.Stmt Γ Λ σ) →
      (a : σ → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.load a q → motive (Turing.TM2.Stmt.load a q))
  (h_5 :
    (Q : Turing.TM2.Stmt Γ Λ σ) →
      (a : σ → Bool) →
        (q₁ q₂ : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.branch a q₁ q₂ → motive (Turing.TM2.Stmt.branch a q₁ q₂))
  (h_6 : (Q : Turing.TM2.Stmt Γ Λ σ) → (a : σ → Λ) → Q = Turing.TM2.Stmt.goto a → motive (Turing.TM2.Stmt.goto a))
  (h_7 : (Q : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.halt → motive Turing.TM2.Stmt.halt) (a : σ → σ)
  (q : Turing.TM2.Stmt Γ Λ σ),
  x = Turing.TM2.Stmt.load a q →
    (match x with
      | Q@h:(Turing.TM2.Stmt.push k a q) => h_1 Q k a q h
      | Q@h:(Turing.TM2.Stmt.peek k a q) => h_2 Q k a q h
      | Q@h:(Turing.TM2.Stmt.pop k a q) => h_3 Q k a q h
      | Q@h:(Turing.TM2.Stmt.load a q) => h_4 Q a q h
      | Q@h:(Turing.TM2.Stmt.branch a q₁ q₂) => h_5 Q a q₁ q₂ h
      | Q@h:(Turing.TM2.Stmt.goto a) => h_6 Q a h
      | Q@h:Turing.TM2.Stmt.halt => h_7 Q h) ≍
      h_4 (Turing.TM2.Stmt.load a q) a q ⋯

theorem Turing.TM2to1.StAct.peek.inj E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {σ : Type u_4} {k : K} {a a_1 : σ → Option (Γ k) → σ},
  Turing.TM2to1.StAct.peek a = Turing.TM2to1.StAct.peek a_1 → a = a_1

theorem Turing.PointedMap.mk.congr_simp E1 #

∀ {Γ : Type u} {Γ' : Type v} [inst : Inhabited Γ] [inst_1 : Inhabited Γ'] (f f_1 : Γ → Γ') (e_f : f = f_1)
  (map_pt' : f default = default), { f := f, map_pt' := map_pt' } = { f := f_1, map_pt' := ⋯ }

theorem Turing.TM2.Stmt.goto.injEq E0 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (a a_1 : σ → Λ),
  (Turing.TM2.Stmt.goto a = Turing.TM2.Stmt.goto a_1) = (a = a_1)

theorem Turing.TM2to1.StAct.pop.inj E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {σ : Type u_4} {k : K} {a a_1 : σ → Option (Γ k) → σ},
  Turing.TM2to1.StAct.pop a = Turing.TM2to1.StAct.pop a_1 → a = a_1

theorem Turing.TM2.stmts₁.match_1.congr_eq_1 E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (motive : Turing.TM2.Stmt Γ Λ σ → Sort u_5)
  (x : Turing.TM2.Stmt Γ Λ σ)
  (h_1 :
    (Q : Turing.TM2.Stmt Γ Λ σ) →
      (k : K) →
        (a : σ → Γ k) →
          (q : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.push k a q → motive (Turing.TM2.Stmt.push k a q))
  (h_2 :
    (Q : Turing.TM2.Stmt Γ Λ σ) →
      (k : K) →
        (a : σ → Option (Γ k) → σ) →
          (q : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.peek k a q → motive (Turing.TM2.Stmt.peek k a q))
  (h_3 :
    (Q : Turing.TM2.Stmt Γ Λ σ) →
      (k : K) →
        (a : σ → Option (Γ k) → σ) →
          (q : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.pop k a q → motive (Turing.TM2.Stmt.pop k a q))
  (h_4 :
    (Q : Turing.TM2.Stmt Γ Λ σ) →
      (a : σ → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.load a q → motive (Turing.TM2.Stmt.load a q))
  (h_5 :
    (Q : Turing.TM2.Stmt Γ Λ σ) →
      (a : σ → Bool) →
        (q₁ q₂ : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.branch a q₁ q₂ → motive (Turing.TM2.Stmt.branch a q₁ q₂))
  (h_6 : (Q : Turing.TM2.Stmt Γ Λ σ) → (a : σ → Λ) → Q = Turing.TM2.Stmt.goto a → motive (Turing.TM2.Stmt.goto a))
  (h_7 : (Q : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.halt → motive Turing.TM2.Stmt.halt) (k : K) (a : σ → Γ k)
  (q : Turing.TM2.Stmt Γ Λ σ),
  x = Turing.TM2.Stmt.push k a q →
    (match x with
      | Q@h:(Turing.TM2.Stmt.push k a q) => h_1 Q k a q h
      | Q@h:(Turing.TM2.Stmt.peek k a q) => h_2 Q k a q h
      | Q@h:(Turing.TM2.Stmt.pop k a q) => h_3 Q k a q h
      | Q@h:(Turing.TM2.Stmt.load a q) => h_4 Q a q h
      | Q@h:(Turing.TM2.Stmt.branch a q₁ q₂) => h_5 Q a q₁ q₂ h
      | Q@h:(Turing.TM2.Stmt.goto a) => h_6 Q a h
      | Q@h:Turing.TM2.Stmt.halt => h_7 Q h) ≍
      h_1 (Turing.TM2.Stmt.push k a q) k a q ⋯

theorem Turing.TM2.stmts₁.match_1.congr_eq_5 E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (motive : Turing.TM2.Stmt Γ Λ σ → Sort u_5)
  (x : Turing.TM2.Stmt Γ Λ σ)
  (h_1 :
    (Q : Turing.TM2.Stmt Γ Λ σ) →
      (k : K) →
        (a : σ → Γ k) →
          (q : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.push k a q → motive (Turing.TM2.Stmt.push k a q))
  (h_2 :
    (Q : Turing.TM2.Stmt Γ Λ σ) →
      (k : K) →
        (a : σ → Option (Γ k) → σ) →
          (q : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.peek k a q → motive (Turing.TM2.Stmt.peek k a q))
  (h_3 :
    (Q : Turing.TM2.Stmt Γ Λ σ) →
      (k : K) →
        (a : σ → Option (Γ k) → σ) →
          (q : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.pop k a q → motive (Turing.TM2.Stmt.pop k a q))
  (h_4 :
    (Q : Turing.TM2.Stmt Γ Λ σ) →
      (a : σ → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.load a q → motive (Turing.TM2.Stmt.load a q))
  (h_5 :
    (Q : Turing.TM2.Stmt Γ Λ σ) →
      (a : σ → Bool) →
        (q₁ q₂ : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.branch a q₁ q₂ → motive (Turing.TM2.Stmt.branch a q₁ q₂))
  (h_6 : (Q : Turing.TM2.Stmt Γ Λ σ) → (a : σ → Λ) → Q = Turing.TM2.Stmt.goto a → motive (Turing.TM2.Stmt.goto a))
  (h_7 : (Q : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.halt → motive Turing.TM2.Stmt.halt) (a : σ → Bool)
  (q₁ q₂ : Turing.TM2.Stmt Γ Λ σ),
  x = Turing.TM2.Stmt.branch a q₁ q₂ →
    (match x with
      | Q@h:(Turing.TM2.Stmt.push k a q) => h_1 Q k a q h
      | Q@h:(Turing.TM2.Stmt.peek k a q) => h_2 Q k a q h
      | Q@h:(Turing.TM2.Stmt.pop k a q) => h_3 Q k a q h
      | Q@h:(Turing.TM2.Stmt.load a q) => h_4 Q a q h
      | Q@h:(Turing.TM2.Stmt.branch a q₁ q₂) => h_5 Q a q₁ q₂ h
      | Q@h:(Turing.TM2.Stmt.goto a) => h_6 Q a h
      | Q@h:Turing.TM2.Stmt.halt => h_7 Q h) ≍
      h_5 (Turing.TM2.Stmt.branch a q₁ q₂) a q₁ q₂ ⋯

theorem Turing.TM2to1.Λ'.normal.injEq E0 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (a a_1 : Λ),
  (Turing.TM2to1.Λ'.normal a = Turing.TM2to1.Λ'.normal a_1) = (a = a_1)

theorem Turing.TM2to1.trStmts₁.match_1.congr_eq_4 E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (motive : Turing.TM2.Stmt Γ Λ σ → Sort u_5)
  (x : Turing.TM2.Stmt Γ Λ σ)
  (h_1 : (k : K) → (f : σ → Γ k) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.push k f q))
  (h_2 : (k : K) → (f : σ → Option (Γ k) → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.peek k f q))
  (h_3 : (k : K) → (f : σ → Option (Γ k) → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.pop k f q))
  (h_4 : (a : σ → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.load a q))
  (h_5 : (a : σ → Bool) → (q₁ q₂ : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.branch a q₁ q₂))
  (h_6 : (x : Turing.TM2.Stmt Γ Λ σ) → motive x) (a : σ → σ) (q : Turing.TM2.Stmt Γ Λ σ),
  x = Turing.TM2.Stmt.load a q →
    (match x with
      | Turing.TM2.Stmt.push k f q => h_1 k f q
      | Turing.TM2.Stmt.peek k f q => h_2 k f q
      | Turing.TM2.Stmt.pop k f q => h_3 k f q
      | Turing.TM2.Stmt.load a q => h_4 a q
      | Turing.TM2.Stmt.branch a q₁ q₂ => h_5 a q₁ q₂
      | x => h_6 x) ≍
      h_4 a q

theorem Turing.TM2.Stmt.push.injEq E0 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (k : K) (a : σ → Γ k) (a_1 : Turing.TM2.Stmt Γ Λ σ)
  (k_1 : K) (a_2 : σ → Γ k_1) (a_3 : Turing.TM2.Stmt Γ Λ σ),
  (Turing.TM2.Stmt.push k a a_1 = Turing.TM2.Stmt.push k_1 a_2 a_3) = (k = k_1 ∧ a ≍ a_2 ∧ a_1 = a_3)

abbrev Turing.TM2.Stmt.ctorElimType E1 #

{K : Type u_1} →
  {Γ : K → Type u_2} →
    {Λ : Type u_3} →
      {σ : Type u_4} →
        {motive : Turing.TM2.Stmt Γ Λ σ → Sort u} →
          ℕ →
            Sort
              (max 1 u
                  (imax (u_1 + 1) (max (u_2 + 1) (u_4 + 1)) (max (max (max (u_1 + 1) (u_2 + 1)) (u_3 + 1)) (u_4 + 1)) u)
                  (imax (u_4 + 1) (max (max (max (u_1 + 1) (u_2 + 1)) (u_3 + 1)) (u_4 + 1)) u)
                  (imax (u_4 + 1) (max (max (max (u_1 + 1) (u_2 + 1)) (u_3 + 1)) (u_4 + 1))
                      (max (max (max (u_1 + 1) (u_2 + 1)) (u_3 + 1)) (u_4 + 1)) u)
                  (imax (max (u_3 + 1) (u_4 + 1)) u))

theorem Turing.TM2to1.stRun.match_1.congr_eq_1 E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {σ : Type u_3} {k : K} (motive : Turing.TM2to1.StAct K Γ σ k → Sort u_4)
  (x : Turing.TM2to1.StAct K Γ σ k) (h_1 : (f : σ → Γ k) → motive (Turing.TM2to1.StAct.push f))
  (h_2 : (f : σ → Option (Γ k) → σ) → motive (Turing.TM2to1.StAct.peek f))
  (h_3 : (f : σ → Option (Γ k) → σ) → motive (Turing.TM2to1.StAct.pop f)) (f : σ → Γ k),
  x = Turing.TM2to1.StAct.push f →
    (match x with
      | Turing.TM2to1.StAct.push f => h_1 f
      | Turing.TM2to1.StAct.peek f => h_2 f
      | Turing.TM2to1.StAct.pop f => h_3 f) ≍
      h_1 f

theorem Turing.TM2to1.Λ'.go.injEq E0 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (k : K) (a : Turing.TM2to1.StAct K Γ σ k)
  (a_1 : Turing.TM2.Stmt Γ Λ σ) (k_1 : K) (a_2 : Turing.TM2to1.StAct K Γ σ k_1) (a_3 : Turing.TM2.Stmt Γ Λ σ),
  (Turing.TM2to1.Λ'.go k a a_1 = Turing.TM2to1.Λ'.go k_1 a_2 a_3) = (k = k_1 ∧ a ≍ a_2 ∧ a_1 = a_3)

theorem Turing.TM2.Cfg.mk.inj E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} {l : Option Λ} {var : σ} {stk : (k : K) → List (Γ k)}
  {l_1 : Option Λ} {var_1 : σ} {stk_1 : (k : K) → List (Γ k)},
  { l := l, var := var, stk := stk } = { l := l_1, var := var_1, stk := stk_1 } → l = l_1 ∧ var = var_1 ∧ stk = stk_1

theorem Turing.TM2to1.trStmts₁.match_1.congr_eq_1 E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (motive : Turing.TM2.Stmt Γ Λ σ → Sort u_5)
  (x : Turing.TM2.Stmt Γ Λ σ)
  (h_1 : (k : K) → (f : σ → Γ k) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.push k f q))
  (h_2 : (k : K) → (f : σ → Option (Γ k) → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.peek k f q))
  (h_3 : (k : K) → (f : σ → Option (Γ k) → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.pop k f q))
  (h_4 : (a : σ → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.load a q))
  (h_5 : (a : σ → Bool) → (q₁ q₂ : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.branch a q₁ q₂))
  (h_6 : (x : Turing.TM2.Stmt Γ Λ σ) → motive x) (k : K) (f : σ → Γ k) (q : Turing.TM2.Stmt Γ Λ σ),
  x = Turing.TM2.Stmt.push k f q →
    (match x with
      | Turing.TM2.Stmt.push k f q => h_1 k f q
      | Turing.TM2.Stmt.peek k f q => h_2 k f q
      | Turing.TM2.Stmt.pop k f q => h_3 k f q
      | Turing.TM2.Stmt.load a q => h_4 a q
      | Turing.TM2.Stmt.branch a q₁ q₂ => h_5 a q₁ q₂
      | x => h_6 x) ≍
      h_1 k f q

def Turing.TM2.Stmt.ctorIdx E1 #

{K : Type u_1} → {Γ : K → Type u_2} → {Λ : Type u_3} → {σ : Type u_4} → Turing.TM2.Stmt Γ Λ σ → ℕ

theorem Turing.TM2to1.StAct.pop.injEq E0 #

∀ {K : Type u_1} {Γ : K → Type u_2} {σ : Type u_4} {k : K} (a a_1 : σ → Option (Γ k) → σ),
  (Turing.TM2to1.StAct.pop a = Turing.TM2to1.StAct.pop a_1) = (a = a_1)

theorem Turing.TM2to1.Λ'.go.inj E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} {k : K} {a : Turing.TM2to1.StAct K Γ σ k}
  {a_1 : Turing.TM2.Stmt Γ Λ σ} {k_1 : K} {a_2 : Turing.TM2to1.StAct K Γ σ k_1} {a_3 : Turing.TM2.Stmt Γ Λ σ},
  Turing.TM2to1.Λ'.go k a a_1 = Turing.TM2to1.Λ'.go k_1 a_2 a_3 → k = k_1 ∧ a ≍ a_2 ∧ a_1 = a_3

abbrev Turing.TM2.Stmt.brecOn.go E1 #

{K : Type u_1} →
  {Γ : K → Type u_2} →
    {Λ : Type u_3} →
      {σ : Type u_4} →
        {motive : Turing.TM2.Stmt Γ Λ σ → Sort u} →
          (t : Turing.TM2.Stmt Γ Λ σ) →
            ((t : Turing.TM2.Stmt Γ Λ σ) → Turing.TM2.Stmt.below t → motive t) → motive t ×' Turing.TM2.Stmt.below t

theorem Turing.TM2.Stmt.peek.inj E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} {k : K} {a : σ → Option (Γ k) → σ}
  {a_1 : Turing.TM2.Stmt Γ Λ σ} {k_1 : K} {a_2 : σ → Option (Γ k_1) → σ} {a_3 : Turing.TM2.Stmt Γ Λ σ},
  Turing.TM2.Stmt.peek k a a_1 = Turing.TM2.Stmt.peek k_1 a_2 a_3 → k = k_1 ∧ a ≍ a_2 ∧ a_1 = a_3

theorem Turing.TM2.SupportsStmt.match_1.congr_eq_6 E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (motive : Turing.TM2.Stmt Γ Λ σ → Sort u_5)
  (x : Turing.TM2.Stmt Γ Λ σ)
  (h_1 : (k : K) → (a : σ → Γ k) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.push k a q))
  (h_2 : (k : K) → (a : σ → Option (Γ k) → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.peek k a q))
  (h_3 : (k : K) → (a : σ → Option (Γ k) → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.pop k a q))
  (h_4 : (a : σ → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.load a q))
  (h_5 : (a : σ → Bool) → (q₁ q₂ : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.branch a q₁ q₂))
  (h_6 : (l : σ → Λ) → motive (Turing.TM2.Stmt.goto l)) (h_7 : Unit → motive Turing.TM2.Stmt.halt) (l : σ → Λ),
  x = Turing.TM2.Stmt.goto l →
    (match x with
      | Turing.TM2.Stmt.push k a q => h_1 k a q
      | Turing.TM2.Stmt.peek k a q => h_2 k a q
      | Turing.TM2.Stmt.pop k a q => h_3 k a q
      | Turing.TM2.Stmt.load a q => h_4 a q
      | Turing.TM2.Stmt.branch a q₁ q₂ => h_5 a q₁ q₂
      | Turing.TM2.Stmt.goto l => h_6 l
      | Turing.TM2.Stmt.halt => h_7 ()) ≍
      h_6 l

theorem Turing.TM2.Stmt.brecOn.eq E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} {motive : Turing.TM2.Stmt Γ Λ σ → Sort u}
  (t : Turing.TM2.Stmt Γ Λ σ) (F_1 : (t : Turing.TM2.Stmt Γ Λ σ) → Turing.TM2.Stmt.below t → motive t),
  Turing.TM2.Stmt.brecOn t F_1 = F_1 t (Turing.TM2.Stmt.brecOn.go t F_1).2

theorem Turing.TM2.SupportsStmt.match_1.congr_eq_2 E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (motive : Turing.TM2.Stmt Γ Λ σ → Sort u_5)
  (x : Turing.TM2.Stmt Γ Λ σ)
  (h_1 : (k : K) → (a : σ → Γ k) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.push k a q))
  (h_2 : (k : K) → (a : σ → Option (Γ k) → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.peek k a q))
  (h_3 : (k : K) → (a : σ → Option (Γ k) → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.pop k a q))
  (h_4 : (a : σ → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.load a q))
  (h_5 : (a : σ → Bool) → (q₁ q₂ : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.branch a q₁ q₂))
  (h_6 : (l : σ → Λ) → motive (Turing.TM2.Stmt.goto l)) (h_7 : Unit → motive Turing.TM2.Stmt.halt) (k : K)
  (a : σ → Option (Γ k) → σ) (q : Turing.TM2.Stmt Γ Λ σ),
  x = Turing.TM2.Stmt.peek k a q →
    (match x with
      | Turing.TM2.Stmt.push k a q => h_1 k a q
      | Turing.TM2.Stmt.peek k a q => h_2 k a q
      | Turing.TM2.Stmt.pop k a q => h_3 k a q
      | Turing.TM2.Stmt.load a q => h_4 a q
      | Turing.TM2.Stmt.branch a q₁ q₂ => h_5 a q₁ q₂
      | Turing.TM2.Stmt.goto l => h_6 l
      | Turing.TM2.Stmt.halt => h_7 ()) ≍
      h_2 k a q

theorem Turing.TM2to1.trStmts₁.match_1.congr_eq_5 E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (motive : Turing.TM2.Stmt Γ Λ σ → Sort u_5)
  (x : Turing.TM2.Stmt Γ Λ σ)
  (h_1 : (k : K) → (f : σ → Γ k) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.push k f q))
  (h_2 : (k : K) → (f : σ → Option (Γ k) → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.peek k f q))
  (h_3 : (k : K) → (f : σ → Option (Γ k) → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.pop k f q))
  (h_4 : (a : σ → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.load a q))
  (h_5 : (a : σ → Bool) → (q₁ q₂ : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.branch a q₁ q₂))
  (h_6 : (x : Turing.TM2.Stmt Γ Λ σ) → motive x) (a : σ → Bool) (q₁ q₂ : Turing.TM2.Stmt Γ Λ σ),
  x = Turing.TM2.Stmt.branch a q₁ q₂ →
    (match x with
      | Turing.TM2.Stmt.push k f q => h_1 k f q
      | Turing.TM2.Stmt.peek k f q => h_2 k f q
      | Turing.TM2.Stmt.pop k f q => h_3 k f q
      | Turing.TM2.Stmt.load a q => h_4 a q
      | Turing.TM2.Stmt.branch a q₁ q₂ => h_5 a q₁ q₂
      | x => h_6 x) ≍
      h_5 a q₁ q₂

theorem Turing.TM2.Stmt.peek.injEq E0 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (k : K) (a : σ → Option (Γ k) → σ)
  (a_1 : Turing.TM2.Stmt Γ Λ σ) (k_1 : K) (a_2 : σ → Option (Γ k_1) → σ) (a_3 : Turing.TM2.Stmt Γ Λ σ),
  (Turing.TM2.Stmt.peek k a a_1 = Turing.TM2.Stmt.peek k_1 a_2 a_3) = (k = k_1 ∧ a ≍ a_2 ∧ a_1 = a_3)

def Turing.TM2.Cfg.ctorIdx E1 #

{K : Type u_1} → {Γ : K → Type u_2} → {Λ : Type u_3} → {σ : Type u_4} → Turing.TM2.Cfg Γ Λ σ → ℕ

theorem Turing.TM2.SupportsStmt.match_1.congr_eq_7 E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (motive : Turing.TM2.Stmt Γ Λ σ → Sort u_5)
  (x : Turing.TM2.Stmt Γ Λ σ)
  (h_1 : (k : K) → (a : σ → Γ k) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.push k a q))
  (h_2 : (k : K) → (a : σ → Option (Γ k) → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.peek k a q))
  (h_3 : (k : K) → (a : σ → Option (Γ k) → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.pop k a q))
  (h_4 : (a : σ → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.load a q))
  (h_5 : (a : σ → Bool) → (q₁ q₂ : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.branch a q₁ q₂))
  (h_6 : (l : σ → Λ) → motive (Turing.TM2.Stmt.goto l)) (h_7 : Unit → motive Turing.TM2.Stmt.halt),
  x = Turing.TM2.Stmt.halt →
    (match x with
      | Turing.TM2.Stmt.push k a q => h_1 k a q
      | Turing.TM2.Stmt.peek k a q => h_2 k a q
      | Turing.TM2.Stmt.pop k a q => h_3 k a q
      | Turing.TM2.Stmt.load a q => h_4 a q
      | Turing.TM2.Stmt.branch a q₁ q₂ => h_5 a q₁ q₂
      | Turing.TM2.Stmt.goto l => h_6 l
      | Turing.TM2.Stmt.halt => h_7 ()) ≍
      h_7 ()

theorem Turing.TM2.stmts₁.match_1.congr_eq_2 E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (motive : Turing.TM2.Stmt Γ Λ σ → Sort u_5)
  (x : Turing.TM2.Stmt Γ Λ σ)
  (h_1 :
    (Q : Turing.TM2.Stmt Γ Λ σ) →
      (k : K) →
        (a : σ → Γ k) →
          (q : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.push k a q → motive (Turing.TM2.Stmt.push k a q))
  (h_2 :
    (Q : Turing.TM2.Stmt Γ Λ σ) →
      (k : K) →
        (a : σ → Option (Γ k) → σ) →
          (q : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.peek k a q → motive (Turing.TM2.Stmt.peek k a q))
  (h_3 :
    (Q : Turing.TM2.Stmt Γ Λ σ) →
      (k : K) →
        (a : σ → Option (Γ k) → σ) →
          (q : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.pop k a q → motive (Turing.TM2.Stmt.pop k a q))
  (h_4 :
    (Q : Turing.TM2.Stmt Γ Λ σ) →
      (a : σ → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.load a q → motive (Turing.TM2.Stmt.load a q))
  (h_5 :
    (Q : Turing.TM2.Stmt Γ Λ σ) →
      (a : σ → Bool) →
        (q₁ q₂ : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.branch a q₁ q₂ → motive (Turing.TM2.Stmt.branch a q₁ q₂))
  (h_6 : (Q : Turing.TM2.Stmt Γ Λ σ) → (a : σ → Λ) → Q = Turing.TM2.Stmt.goto a → motive (Turing.TM2.Stmt.goto a))
  (h_7 : (Q : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.halt → motive Turing.TM2.Stmt.halt) (k : K)
  (a : σ → Option (Γ k) → σ) (q : Turing.TM2.Stmt Γ Λ σ),
  x = Turing.TM2.Stmt.peek k a q →
    (match x with
      | Q@h:(Turing.TM2.Stmt.push k a q) => h_1 Q k a q h
      | Q@h:(Turing.TM2.Stmt.peek k a q) => h_2 Q k a q h
      | Q@h:(Turing.TM2.Stmt.pop k a q) => h_3 Q k a q h
      | Q@h:(Turing.TM2.Stmt.load a q) => h_4 Q a q h
      | Q@h:(Turing.TM2.Stmt.branch a q₁ q₂) => h_5 Q a q₁ q₂ h
      | Q@h:(Turing.TM2.Stmt.goto a) => h_6 Q a h
      | Q@h:Turing.TM2.Stmt.halt => h_7 Q h) ≍
      h_2 (Turing.TM2.Stmt.peek k a q) k a q ⋯

theorem Turing.TM2to1.tr.match_1.congr_eq_2 E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (motive : Turing.TM2to1.Λ' K Γ Λ σ → Sort u_5)
  (x : Turing.TM2to1.Λ' K Γ Λ σ) (h_1 : (q : Λ) → motive (Turing.TM2to1.Λ'.normal q))
  (h_2 : (k : K) → (s : Turing.TM2to1.StAct K Γ σ k) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2to1.Λ'.go k s q))
  (h_3 : (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2to1.Λ'.ret q)) (k : K) (s : Turing.TM2to1.StAct K Γ σ k)
  (q : Turing.TM2.Stmt Γ Λ σ),
  x = Turing.TM2to1.Λ'.go k s q →
    (match x with
      | Turing.TM2to1.Λ'.normal q => h_1 q
      | Turing.TM2to1.Λ'.go k s q => h_2 k s q
      | Turing.TM2to1.Λ'.ret q => h_3 q) ≍
      h_2 k s q

theorem Turing.TM2to1.tr.match_1.congr_eq_3 E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (motive : Turing.TM2to1.Λ' K Γ Λ σ → Sort u_5)
  (x : Turing.TM2to1.Λ' K Γ Λ σ) (h_1 : (q : Λ) → motive (Turing.TM2to1.Λ'.normal q))
  (h_2 : (k : K) → (s : Turing.TM2to1.StAct K Γ σ k) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2to1.Λ'.go k s q))
  (h_3 : (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2to1.Λ'.ret q)) (q : Turing.TM2.Stmt Γ Λ σ),
  x = Turing.TM2to1.Λ'.ret q →
    (match x with
      | Turing.TM2to1.Λ'.normal q => h_1 q
      | Turing.TM2to1.Λ'.go k s q => h_2 k s q
      | Turing.TM2to1.Λ'.ret q => h_3 q) ≍
      h_3 q

theorem Turing.TM2.stmts₁.match_1.congr_eq_7 E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (motive : Turing.TM2.Stmt Γ Λ σ → Sort u_5)
  (x : Turing.TM2.Stmt Γ Λ σ)
  (h_1 :
    (Q : Turing.TM2.Stmt Γ Λ σ) →
      (k : K) →
        (a : σ → Γ k) →
          (q : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.push k a q → motive (Turing.TM2.Stmt.push k a q))
  (h_2 :
    (Q : Turing.TM2.Stmt Γ Λ σ) →
      (k : K) →
        (a : σ → Option (Γ k) → σ) →
          (q : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.peek k a q → motive (Turing.TM2.Stmt.peek k a q))
  (h_3 :
    (Q : Turing.TM2.Stmt Γ Λ σ) →
      (k : K) →
        (a : σ → Option (Γ k) → σ) →
          (q : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.pop k a q → motive (Turing.TM2.Stmt.pop k a q))
  (h_4 :
    (Q : Turing.TM2.Stmt Γ Λ σ) →
      (a : σ → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.load a q → motive (Turing.TM2.Stmt.load a q))
  (h_5 :
    (Q : Turing.TM2.Stmt Γ Λ σ) →
      (a : σ → Bool) →
        (q₁ q₂ : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.branch a q₁ q₂ → motive (Turing.TM2.Stmt.branch a q₁ q₂))
  (h_6 : (Q : Turing.TM2.Stmt Γ Λ σ) → (a : σ → Λ) → Q = Turing.TM2.Stmt.goto a → motive (Turing.TM2.Stmt.goto a))
  (h_7 : (Q : Turing.TM2.Stmt Γ Λ σ) → Q = Turing.TM2.Stmt.halt → motive Turing.TM2.Stmt.halt),
  x = Turing.TM2.Stmt.halt →
    (match x with
      | Q@h:(Turing.TM2.Stmt.push k a q) => h_1 Q k a q h
      | Q@h:(Turing.TM2.Stmt.peek k a q) => h_2 Q k a q h
      | Q@h:(Turing.TM2.Stmt.pop k a q) => h_3 Q k a q h
      | Q@h:(Turing.TM2.Stmt.load a q) => h_4 Q a q h
      | Q@h:(Turing.TM2.Stmt.branch a q₁ q₂) => h_5 Q a q₁ q₂ h
      | Q@h:(Turing.TM2.Stmt.goto a) => h_6 Q a h
      | Q@h:Turing.TM2.Stmt.halt => h_7 Q h) ≍
      h_7 Turing.TM2.Stmt.halt ⋯

theorem Turing.TM2.Stmt.pop.injEq E0 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (k : K) (a : σ → Option (Γ k) → σ)
  (a_1 : Turing.TM2.Stmt Γ Λ σ) (k_1 : K) (a_2 : σ → Option (Γ k_1) → σ) (a_3 : Turing.TM2.Stmt Γ Λ σ),
  (Turing.TM2.Stmt.pop k a a_1 = Turing.TM2.Stmt.pop k_1 a_2 a_3) = (k = k_1 ∧ a ≍ a_2 ∧ a_1 = a_3)

theorem Turing.TM2.Stmt.branch.injEq E0 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (a : σ → Bool) (a_1 a_2 : Turing.TM2.Stmt Γ Λ σ)
  (a_3 : σ → Bool) (a_4 a_5 : Turing.TM2.Stmt Γ Λ σ),
  (Turing.TM2.Stmt.branch a a_1 a_2 = Turing.TM2.Stmt.branch a_3 a_4 a_5) = (a = a_3 ∧ a_1 = a_4 ∧ a_2 = a_5)

def Turing.TM2to1.Λ'.ctorIdx E1 #

{K : Type u_1} → {Γ : K → Type u_2} → {Λ : Type u_3} → {σ : Type u_4} → Turing.TM2to1.Λ' K Γ Λ σ → ℕ

theorem Turing.TM2to1.trStmts₁.match_1.congr_eq_3 E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (motive : Turing.TM2.Stmt Γ Λ σ → Sort u_5)
  (x : Turing.TM2.Stmt Γ Λ σ)
  (h_1 : (k : K) → (f : σ → Γ k) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.push k f q))
  (h_2 : (k : K) → (f : σ → Option (Γ k) → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.peek k f q))
  (h_3 : (k : K) → (f : σ → Option (Γ k) → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.pop k f q))
  (h_4 : (a : σ → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.load a q))
  (h_5 : (a : σ → Bool) → (q₁ q₂ : Turing.TM2.Stmt Γ Λ σ) → motive (Turing.TM2.Stmt.branch a q₁ q₂))
  (h_6 : (x : Turing.TM2.Stmt Γ Λ σ) → motive x) (k : K) (f : σ → Option (Γ k) → σ) (q : Turing.TM2.Stmt Γ Λ σ),
  x = Turing.TM2.Stmt.pop k f q →
    (match x with
      | Turing.TM2.Stmt.push k f q => h_1 k f q
      | Turing.TM2.Stmt.peek k f q => h_2 k f q
      | Turing.TM2.Stmt.pop k f q => h_3 k f q
      | Turing.TM2.Stmt.load a q => h_4 a q
      | Turing.TM2.Stmt.branch a q₁ q₂ => h_5 a q₁ q₂
      | x => h_6 x) ≍
      h_3 k f q

theorem Turing.TM2to1.Λ'.ret.inj E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} {a a_1 : Turing.TM2.Stmt Γ Λ σ},
  Turing.TM2to1.Λ'.ret a = Turing.TM2to1.Λ'.ret a_1 → a = a_1

inductive Turing.TM2.Stmt E1 #

{K : Type u_1} → (K → Type u_2) → Type u_3 → Type u_4 → Type (max (max (max u_1 u_2) u_3) u_4)

The TM2 model removes the tape entirely from the TM1 model, replacing it with an arbitrary (finite) collection of stacks. The operation push puts an element on one of the stacks, and pop removes an element from a stack (and modifies the internal state based on the result). peek modifies the internal state but does not remove an element.

ctor Turing.TM2.Stmt.push E0 #

{K : Type u_1} →
  {Γ : K → Type u_2} →
    {Λ : Type u_3} → {σ : Type u_4} → (k : K) → (σ → Γ k) → Turing.TM2.Stmt Γ Λ σ → Turing.TM2.Stmt Γ Λ σ

ctor Turing.TM2.Stmt.peek E0 #

{K : Type u_1} →
  {Γ : K → Type u_2} →
    {Λ : Type u_3} → {σ : Type u_4} → (k : K) → (σ → Option (Γ k) → σ) → Turing.TM2.Stmt Γ Λ σ → Turing.TM2.Stmt Γ Λ σ

ctor Turing.TM2.Stmt.pop E0 #

{K : Type u_1} →
  {Γ : K → Type u_2} →
    {Λ : Type u_3} → {σ : Type u_4} → (k : K) → (σ → Option (Γ k) → σ) → Turing.TM2.Stmt Γ Λ σ → Turing.TM2.Stmt Γ Λ σ

ctor Turing.TM2.Stmt.load E0 #

{K : Type u_1} →
  {Γ : K → Type u_2} → {Λ : Type u_3} → {σ : Type u_4} → (σ → σ) → Turing.TM2.Stmt Γ Λ σ → Turing.TM2.Stmt Γ Λ σ

ctor Turing.TM2.Stmt.branch E0 #

{K : Type u_1} →
  {Γ : K → Type u_2} →
    {Λ : Type u_3} → {σ : Type u_4} → (σ → Bool) → Turing.TM2.Stmt Γ Λ σ → Turing.TM2.Stmt Γ Λ σ → Turing.TM2.Stmt Γ Λ σ

ctor Turing.TM2.Stmt.goto E0 #

{K : Type u_1} → {Γ : K → Type u_2} → {Λ : Type u_3} → {σ : Type u_4} → (σ → Λ) → Turing.TM2.Stmt Γ Λ σ

ctor Turing.TM2.Stmt.halt E0 #

{K : Type u_1} → {Γ : K → Type u_2} → {Λ : Type u_3} → {σ : Type u_4} → Turing.TM2.Stmt Γ Λ σ

instance Turing.TM2.Stmt.inhabited E0 #

{K : Type u_1} → (Γ : K → Type u_2) → (Λ : Type u_3) → (σ : Type u_4) → Inhabited (Turing.TM2.Stmt Γ Λ σ)

structure Turing.TM2.Cfg E1 #

{K : Type u_1} → (K → Type u_2) → Type u_3 → Type u_4 → Type (max (max (max u_1 u_2) u_3) u_4)

A configuration in the TM2 model is a label (or none for the halt state), the state of local variables, and the stacks. (Note that the stacks are not ListBlanks, they have a definite size.)

ctor Turing.TM2.Cfg.mk E0 #

{K : Type u_1} →
  {Γ : K → Type u_2} → {Λ : Type u_3} → {σ : Type u_4} → Option Λ → σ → ((k : K) → List (Γ k)) → Turing.TM2.Cfg Γ Λ σ

abbrev Turing.TM2.Cfg.l E1 #

{K : Type u_1} → {Γ : K → Type u_2} → {Λ : Type u_3} → {σ : Type u_4} → Turing.TM2.Cfg Γ Λ σ → Option Λ

The current label to run (or none for the halting state)

abbrev Turing.TM2.Cfg.var E1 #

{K : Type u_1} → {Γ : K → Type u_2} → {Λ : Type u_3} → {σ : Type u_4} → Turing.TM2.Cfg Γ Λ σ → σ

The internal state

abbrev Turing.TM2.Cfg.stk E1 #

{K : Type u_1} → {Γ : K → Type u_2} → {Λ : Type u_3} → {σ : Type u_4} → Turing.TM2.Cfg Γ Λ σ → (k : K) → List (Γ k)

The (finite) collection of internal stacks

instance Turing.TM2.Cfg.inhabited E0 #

{K : Type u_1} → (Γ : K → Type u_2) → (Λ : Type u_3) → (σ : Type u_4) → [Inhabited σ] → Inhabited (Turing.TM2.Cfg Γ Λ σ)

def Turing.TM2.stepAux E0 #

{K : Type u_1} →
  {Γ : K → Type u_2} →
    {Λ : Type u_3} →
      {σ : Type u_4} → [DecidableEq K] → Turing.TM2.Stmt Γ Λ σ → σ → ((k : K) → List (Γ k)) → Turing.TM2.Cfg Γ Λ σ

The step function for the TM2 model.

def Turing.TM2.step E1 #

{K : Type u_1} →
  {Γ : K → Type u_2} →
    {Λ : Type u_3} →
      {σ : Type u_4} →
        [DecidableEq K] → (Λ → Turing.TM2.Stmt Γ Λ σ) → Turing.TM2.Cfg Γ Λ σ → Option (Turing.TM2.Cfg Γ Λ σ)

The step function for the TM2 model.

def Turing.TM2.Reaches E1 #

{K : Type u_1} →
  {Γ : K → Type u_2} →
    {Λ : Type u_3} →
      {σ : Type u_4} →
        [DecidableEq K] → (Λ → Turing.TM2.Stmt Γ Λ σ) → Turing.TM2.Cfg Γ Λ σ → Turing.TM2.Cfg Γ Λ σ → Prop

The (reflexive) reachability relation for the TM2 model.

def Turing.TM2.SupportsStmt E1 #

{K : Type u_1} → {Γ : K → Type u_2} → {Λ : Type u_3} → {σ : Type u_4} → Finset Λ → Turing.TM2.Stmt Γ Λ σ → Prop

Given a set S of states, SupportsStmt S q means that q only jumps to states in S.

def Turing.TM2.stmts₁ E1 #

{K : Type u_1} →
  {Γ : K → Type u_2} → {Λ : Type u_3} → {σ : Type u_4} → Turing.TM2.Stmt Γ Λ σ → Finset (Turing.TM2.Stmt Γ Λ σ)

The set of subtree statements in a statement.

theorem Turing.TM2.stmts₁_self E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} {q : Turing.TM2.Stmt Γ Λ σ}, q ∈ Turing.TM2.stmts₁ q

theorem Turing.TM2.stmts₁_trans E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} {q₁ q₂ : Turing.TM2.Stmt Γ Λ σ},
  q₁ ∈ Turing.TM2.stmts₁ q₂ → Turing.TM2.stmts₁ q₁ ⊆ Turing.TM2.stmts₁ q₂

theorem Turing.TM2.stmts₁_supportsStmt_mono E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} {S : Finset Λ} {q₁ q₂ : Turing.TM2.Stmt Γ Λ σ},
  q₁ ∈ Turing.TM2.stmts₁ q₂ → Turing.TM2.SupportsStmt S q₂ → Turing.TM2.SupportsStmt S q₁

def Turing.TM2.stmts E1 #

{K : Type u_1} →
  {Γ : K → Type u_2} →
    {Λ : Type u_3} → {σ : Type u_4} → (Λ → Turing.TM2.Stmt Γ Λ σ) → Finset Λ → Finset (Option (Turing.TM2.Stmt Γ Λ σ))

The set of statements accessible from initial set S of labels.

theorem Turing.TM2.stmts_trans E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} {M : Λ → Turing.TM2.Stmt Γ Λ σ} {S : Finset Λ}
  {q₁ q₂ : Turing.TM2.Stmt Γ Λ σ},
  q₁ ∈ Turing.TM2.stmts₁ q₂ → some q₂ ∈ Turing.TM2.stmts M S → some q₁ ∈ Turing.TM2.stmts M S

def Turing.TM2.Supports E1 #

{K : Type u_1} →
  {Γ : K → Type u_2} → {Λ : Type u_3} → {σ : Type u_4} → [Inhabited Λ] → (Λ → Turing.TM2.Stmt Γ Λ σ) → Finset Λ → Prop

Given a TM2 machine M and a set S of states, Supports M S means that all states in S jump only to other states in S.

theorem Turing.TM2.stmts_supportsStmt E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} [inst : Inhabited Λ] {M : Λ → Turing.TM2.Stmt Γ Λ σ}
  {S : Finset Λ} {q : Turing.TM2.Stmt Γ Λ σ},
  Turing.TM2.Supports M S → some q ∈ Turing.TM2.stmts M S → Turing.TM2.SupportsStmt S q

theorem Turing.TM2.step_supports E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} [inst : Inhabited Λ] [inst_1 : DecidableEq K]
  (M : Λ → Turing.TM2.Stmt Γ Λ σ) {S : Finset Λ},
  Turing.TM2.Supports M S →
    ∀ {c c' : Turing.TM2.Cfg Γ Λ σ}, c' ∈ Turing.TM2.step M c → c.l ∈ Finset.insertNone S → c'.l ∈ Finset.insertNone S

def Turing.TM2.init E1 #

{K : Type u_1} →
  {Γ : K → Type u_2} →
    {Λ : Type u_3} →
      {σ : Type u_4} → [Inhabited Λ] → [DecidableEq K] → [Inhabited σ] → (k : K) → List (Γ k) → Turing.TM2.Cfg Γ Λ σ

The initial state of the TM2 model. The input is provided on a designated stack.

def Turing.TM2.eval E1 #

{K : Type u_1} →
  {Γ : K → Type u_2} →
    {Λ : Type u_3} →
      {σ : Type u_4} →
        [Inhabited Λ] →
          [DecidableEq K] → [Inhabited σ] → (Λ → Turing.TM2.Stmt Γ Λ σ) → (k : K) → List (Γ k) → Part (List (Γ k))

Evaluates a TM2 program to completion, with the output on the same stack as the input.

theorem Turing.TM2to1.stk_nth_val E0 #

∀ {K : Type u_1} {Γ : K → Type u_2} {L : Turing.ListBlank ((k : K) → Option (Γ k))} {k : K} {S : List (Γ k)} (n : ℕ),
  Turing.ListBlank.map (Turing.proj k) L = Turing.ListBlank.mk (List.map some S).reverse → L.nth n k = S.reverse[n]?

def Turing.TM2to1.Γ' E1 #

(K : Type u_1) → (K → Type u_2) → Type (max 0 u_1 u_2)

The alphabet of the TM2 simulator on TM1 is a marker for the stack bottom, plus a vector of stack elements for each stack, or none if the stack does not extend this far.

instance Turing.TM2to1.Γ'.inhabited E0 #

{K : Type u_1} → {Γ : K → Type u_2} → Inhabited (Turing.TM2to1.Γ' K Γ)

instance Turing.TM2to1.Γ'.fintype E0 #

{K : Type u_1} →
  {Γ : K → Type u_2} → [DecidableEq K] → [Fintype K] → [(k : K) → Fintype (Γ k)] → Fintype (Turing.TM2to1.Γ' K Γ)

def Turing.TM2to1.addBottom E1 #

{K : Type u_1} →
  {Γ : K → Type u_2} → Turing.ListBlank ((k : K) → Option (Γ k)) → Turing.ListBlank (Turing.TM2to1.Γ' K Γ)

The bottom marker is fixed throughout the calculation, so we use the addBottom function to express the program state in terms of a tape with only the stacks themselves.

theorem Turing.TM2to1.addBottom_map E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} (L : Turing.ListBlank ((k : K) → Option (Γ k))),
  Turing.ListBlank.map { f := Prod.snd, map_pt' := ⋯ } (Turing.TM2to1.addBottom L) = L

theorem Turing.TM2to1.addBottom_modifyNth E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} (f : ((k : K) → Option (Γ k)) → (k : K) → Option (Γ k))
  (L : Turing.ListBlank ((k : K) → Option (Γ k))) (n : ℕ),
  Turing.ListBlank.modifyNth (fun a ↦ (a.1, f a.2)) n (Turing.TM2to1.addBottom L) =
    Turing.TM2to1.addBottom (Turing.ListBlank.modifyNth f n L)

theorem Turing.TM2to1.addBottom_nth_snd E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} (L : Turing.ListBlank ((k : K) → Option (Γ k))) (n : ℕ),
  ((Turing.TM2to1.addBottom L).nth n).2 = L.nth n

theorem Turing.TM2to1.addBottom_nth_succ_fst E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} (L : Turing.ListBlank ((k : K) → Option (Γ k))) (n : ℕ),
  ((Turing.TM2to1.addBottom L).nth (n + 1)).1 = false

theorem Turing.TM2to1.addBottom_head_fst E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} (L : Turing.ListBlank ((k : K) → Option (Γ k))),
  (Turing.TM2to1.addBottom L).head.1 = true

inductive Turing.TM2to1.StAct E1 #

(K : Type u_1) → (K → Type u_2) → Type u_4 → K → Type (max u_2 u_4)

A stack action is a command that interacts with the top of a stack. Our default position is at the bottom of all the stacks, so we have to hold on to this action while going to the end to modify the stack.

ctor Turing.TM2to1.StAct.push E0 #

{K : Type u_1} → {Γ : K → Type u_2} → {σ : Type u_4} → {k : K} → (σ → Γ k) → Turing.TM2to1.StAct K Γ σ k

ctor Turing.TM2to1.StAct.peek E0 #

{K : Type u_1} → {Γ : K → Type u_2} → {σ : Type u_4} → {k : K} → (σ → Option (Γ k) → σ) → Turing.TM2to1.StAct K Γ σ k

ctor Turing.TM2to1.StAct.pop E0 #

{K : Type u_1} → {Γ : K → Type u_2} → {σ : Type u_4} → {k : K} → (σ → Option (Γ k) → σ) → Turing.TM2to1.StAct K Γ σ k

instance Turing.TM2to1.StAct.inhabited E0 #

{K : Type u_1} → {Γ : K → Type u_2} → {σ : Type u_4} → {k : K} → Inhabited (Turing.TM2to1.StAct K Γ σ k)

def Turing.TM2to1.stRun E1 #

{K : Type u_1} →
  {Γ : K → Type u_2} →
    {Λ : Type u_3} →
      {σ : Type u_4} → {k : K} → Turing.TM2to1.StAct K Γ σ k → Turing.TM2.Stmt Γ Λ σ → Turing.TM2.Stmt Γ Λ σ

The TM2 statement corresponding to a stack action.

def Turing.TM2to1.stVar E1 #

{K : Type u_1} → {Γ : K → Type u_2} → {σ : Type u_4} → {k : K} → σ → List (Γ k) → Turing.TM2to1.StAct K Γ σ k → σ

The effect of a stack action on the local variables, given the value of the stack.

def Turing.TM2to1.stWrite E1 #

{K : Type u_1} →
  {Γ : K → Type u_2} → {σ : Type u_4} → {k : K} → σ → List (Γ k) → Turing.TM2to1.StAct K Γ σ k → List (Γ k)

The effect of a stack action on the stack.

def Turing.TM2to1.stmtStRec E1 #

{K : Type u_1} →
  {Γ : K → Type u_2} →
    {Λ : Type u_3} →
      {σ : Type u_4} →
        {motive : Turing.TM2.Stmt Γ Λ σ → Sort l} →
          ((k : K) →
              (s : Turing.TM2to1.StAct K Γ σ k) →
                (q : Turing.TM2.Stmt Γ Λ σ) → motive q → motive (Turing.TM2to1.stRun s q)) →
            ((a : σ → σ) → (q : Turing.TM2.Stmt Γ Λ σ) → motive q → motive (Turing.TM2.Stmt.load a q)) →
              ((p : σ → Bool) →
                  (q₁ q₂ : Turing.TM2.Stmt Γ Λ σ) → motive q₁ → motive q₂ → motive (Turing.TM2.Stmt.branch p q₁ q₂)) →
                ((l : σ → Λ) → motive (Turing.TM2.Stmt.goto l)) →
                  motive Turing.TM2.Stmt.halt → (n : Turing.TM2.Stmt Γ Λ σ) → motive n

We have partitioned the TM2 statements into "stack actions", which require going to the end of the stack, and all other actions, which do not. This is a modified recursor which lumps the stack actions into one.

theorem Turing.TM2to1.supports_run E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} (S : Finset Λ) {k : K}
  (s : Turing.TM2to1.StAct K Γ σ k) (q : Turing.TM2.Stmt Γ Λ σ),
  Turing.TM2.SupportsStmt S (Turing.TM2to1.stRun s q) ↔ Turing.TM2.SupportsStmt S q

inductive Turing.TM2to1.Λ' E1 #

(K : Type u_1) → (K → Type u_2) → Type u_3 → Type u_4 → Type (max (max (max u_1 u_2) u_3) u_4)

The machine states of the TM2 emulator. We can either be in a normal state when waiting for the next TM2 action, or we can be in the "go" and "return" states to go to the top of the stack and return to the bottom, respectively.

ctor Turing.TM2to1.Λ'.normal E0 #

{K : Type u_1} → {Γ : K → Type u_2} → {Λ : Type u_3} → {σ : Type u_4} → Λ → Turing.TM2to1.Λ' K Γ Λ σ

ctor Turing.TM2to1.Λ'.go E0 #

{K : Type u_1} →
  {Γ : K → Type u_2} →
    {Λ : Type u_3} →
      {σ : Type u_4} → (k : K) → Turing.TM2to1.StAct K Γ σ k → Turing.TM2.Stmt Γ Λ σ → Turing.TM2to1.Λ' K Γ Λ σ

ctor Turing.TM2to1.Λ'.ret E0 #

{K : Type u_1} → {Γ : K → Type u_2} → {Λ : Type u_3} → {σ : Type u_4} → Turing.TM2.Stmt Γ Λ σ → Turing.TM2to1.Λ' K Γ Λ σ

instance Turing.TM2to1.Λ'.inhabited E0 #

{K : Type u_1} →
  {Γ : K → Type u_2} → {Λ : Type u_3} → {σ : Type u_4} → [Inhabited Λ] → Inhabited (Turing.TM2to1.Λ' K Γ Λ σ)

def Turing.TM2to1.trStAct E1 #

{K : Type u_1} →
  {Γ : K → Type u_2} →
    {Λ : Type u_3} →
      {σ : Type u_4} →
        [DecidableEq K] →
          {k : K} →
            Turing.TM1.Stmt (Turing.TM2to1.Γ' K Γ) (Turing.TM2to1.Λ' K Γ Λ σ) σ →
              Turing.TM2to1.StAct K Γ σ k → Turing.TM1.Stmt (Turing.TM2to1.Γ' K Γ) (Turing.TM2to1.Λ' K Γ Λ σ) σ

The program corresponding to state transitions at the end of a stack. Here we start out just after the top of the stack, and should end just after the new top of the stack.

def Turing.TM2to1.trInit E1 #

{K : Type u_1} → {Γ : K → Type u_2} → [DecidableEq K] → (k : K) → List (Γ k) → List (Turing.TM2to1.Γ' K Γ)

The initial state for the TM2 emulator, given an initial TM2 state. All stacks start out empty except for the input stack, and the stack bottom mark is set at the head.

theorem Turing.TM2to1.step_run E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} [inst : DecidableEq K] {k : K}
  (q : Turing.TM2.Stmt Γ Λ σ) (v : σ) (S : (k : K) → List (Γ k)) (s : Turing.TM2to1.StAct K Γ σ k),
  Turing.TM2.stepAux (Turing.TM2to1.stRun s q) v S =
    Turing.TM2.stepAux q (Turing.TM2to1.stVar v (S k) s) (Function.update S k (Turing.TM2to1.stWrite v (S k) s))

def Turing.TM2to1.trNormal E1 #

{K : Type u_1} →
  {Γ : K → Type u_2} →
    {Λ : Type u_3} →
      {σ : Type u_4} → Turing.TM2.Stmt Γ Λ σ → Turing.TM1.Stmt (Turing.TM2to1.Γ' K Γ) (Turing.TM2to1.Λ' K Γ Λ σ) σ

The translation of TM2 statements to TM1 statements. Regular actions have direct equivalents, but stack actions are deferred by going to the corresponding go state, so that we can find the appropriate stack top.

theorem Turing.TM2to1.trNormal_run E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} {k : K} (s : Turing.TM2to1.StAct K Γ σ k)
  (q : Turing.TM2.Stmt Γ Λ σ),
  Turing.TM2to1.trNormal (Turing.TM2to1.stRun s q) = Turing.TM1.Stmt.goto fun x x_1 ↦ Turing.TM2to1.Λ'.go k s q

def Turing.TM2to1.trStmts₁ E1 #

{K : Type u_1} →
  {Γ : K → Type u_2} → {Λ : Type u_3} → {σ : Type u_4} → Turing.TM2.Stmt Γ Λ σ → Finset (Turing.TM2to1.Λ' K Γ Λ σ)

The set of machine states accessible from an initial TM2 statement.

theorem Turing.TM2to1.trStmts₁_run E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} {k : K} {s : Turing.TM2to1.StAct K Γ σ k}
  {q : Turing.TM2.Stmt Γ Λ σ},
  Turing.TM2to1.trStmts₁ (Turing.TM2to1.stRun s q) =
    {Turing.TM2to1.Λ'.go k s q, Turing.TM2to1.Λ'.ret q} ∪ Turing.TM2to1.trStmts₁ q

theorem Turing.TM2to1.tr_respects_aux₂ E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} [inst : DecidableEq K] {k : K}
  {q : Turing.TM1.Stmt (Turing.TM2to1.Γ' K Γ) (Turing.TM2to1.Λ' K Γ Λ σ) σ} {v : σ} {S : (k : K) → List (Γ k)}
  {L : Turing.ListBlank ((k : K) → Option (Γ k))},
  (∀ (k : K), Turing.ListBlank.map (Turing.proj k) L = Turing.ListBlank.mk (List.map some (S k)).reverse) →
    ∀ (o : Turing.TM2to1.StAct K Γ σ k),
      have v' := Turing.TM2to1.stVar v (S k) o;
      have Sk' := Turing.TM2to1.stWrite v (S k) o;
      have S' := Function.update S k Sk';
      ∃ L',
        (∀ (k : K), Turing.ListBlank.map (Turing.proj k) L' = Turing.ListBlank.mk (List.map some (S' k)).reverse) ∧
          Turing.TM1.stepAux (Turing.TM2to1.trStAct q o) v
              ((Turing.Tape.move Turing.Dir.right)^[(S k).length] (Turing.Tape.mk' ∅ (Turing.TM2to1.addBottom L))) =
            Turing.TM1.stepAux q v'
              ((Turing.Tape.move Turing.Dir.right)^[(S' k).length] (Turing.Tape.mk' ∅ (Turing.TM2to1.addBottom L')))

def Turing.TM2to1.tr E1 #

{K : Type u_1} →
  {Γ : K → Type u_2} →
    {Λ : Type u_3} →
      {σ : Type u_4} →
        [DecidableEq K] →
          (Λ → Turing.TM2.Stmt Γ Λ σ) →
            Turing.TM2to1.Λ' K Γ Λ σ → Turing.TM1.Stmt (Turing.TM2to1.Γ' K Γ) (Turing.TM2to1.Λ' K Γ Λ σ) σ

The TM2 emulator machine states written as a TM1 program. This handles the go and ret states, which shuttle to and from a stack top.

inductive Turing.TM2to1.TrCfg E1 #

{K : Type u_1} →
  {Γ : K → Type u_2} →
    {Λ : Type u_3} →
      {σ : Type u_4} → Turing.TM2.Cfg Γ Λ σ → Turing.TM1.Cfg (Turing.TM2to1.Γ' K Γ) (Turing.TM2to1.Λ' K Γ Λ σ) σ → Prop

The relation between TM2 configurations and TM1 configurations of the TM2 emulator.

ctor Turing.TM2to1.TrCfg.mk E0 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} {q : Option Λ} {v : σ} {S : (k : K) → List (Γ k)}
  (L : Turing.ListBlank ((k : K) → Option (Γ k))),
  (∀ (k : K), Turing.ListBlank.map (Turing.proj k) L = Turing.ListBlank.mk (List.map some (S k)).reverse) →
    Turing.TM2to1.TrCfg { l := q, var := v, stk := S }
      { l := Option.map Turing.TM2to1.Λ'.normal q, var := v, Tape := Turing.Tape.mk' ∅ (Turing.TM2to1.addBottom L) }

theorem Turing.TM2to1.tr_respects_aux₁ E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} [inst : DecidableEq K] (M : Λ → Turing.TM2.Stmt Γ Λ σ)
  {k : K} (o : Turing.TM2to1.StAct K Γ σ k) (q : Turing.TM2.Stmt Γ Λ σ) (v : σ) {S : List (Γ k)}
  {L : Turing.ListBlank ((k : K) → Option (Γ k))},
  Turing.ListBlank.map (Turing.proj k) L = Turing.ListBlank.mk (List.map some S).reverse →
    ∀ n ≤ S.length,
      StateTransition.Reaches₀ (Turing.TM1.step (Turing.TM2to1.tr M))
        { l := some (Turing.TM2to1.Λ'.go k o q), var := v, Tape := Turing.Tape.mk' ∅ (Turing.TM2to1.addBottom L) }
        { l := some (Turing.TM2to1.Λ'.go k o q), var := v,
          Tape := (Turing.Tape.move Turing.Dir.right)^[n] (Turing.Tape.mk' ∅ (Turing.TM2to1.addBottom L)) }

theorem Turing.TM2to1.tr_respects_aux₃ E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} [inst : DecidableEq K] (M : Λ → Turing.TM2.Stmt Γ Λ σ)
  {q : Turing.TM2.Stmt Γ Λ σ} {v : σ} {L : Turing.ListBlank ((k : K) → Option (Γ k))} (n : ℕ),
  StateTransition.Reaches₀ (Turing.TM1.step (Turing.TM2to1.tr M))
    { l := some (Turing.TM2to1.Λ'.ret q), var := v,
      Tape := (Turing.Tape.move Turing.Dir.right)^[n] (Turing.Tape.mk' ∅ (Turing.TM2to1.addBottom L)) }
    { l := some (Turing.TM2to1.Λ'.ret q), var := v, Tape := Turing.Tape.mk' ∅ (Turing.TM2to1.addBottom L) }

theorem Turing.TM2to1.tr_respects_aux E0 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} [inst : DecidableEq K] (M : Λ → Turing.TM2.Stmt Γ Λ σ)
  {q : Turing.TM2.Stmt Γ Λ σ} {v : σ} {T : Turing.ListBlank ((i : K) → Option (Γ i))} {k : K}
  {S : (k : K) → List (Γ k)},
  (∀ (k : K), Turing.ListBlank.map (Turing.proj k) T = Turing.ListBlank.mk (List.map some (S k)).reverse) →
    ∀ (o : Turing.TM2to1.StAct K Γ σ k),
      (∀ {v : σ} {S : (k : K) → List (Γ k)} {T : Turing.ListBlank ((k : K) → Option (Γ k))},
          (∀ (k : K), Turing.ListBlank.map (Turing.proj k) T = Turing.ListBlank.mk (List.map some (S k)).reverse) →
            ∃ b,
              Turing.TM2to1.TrCfg (Turing.TM2.stepAux q v S) b ∧
                StateTransition.Reaches (Turing.TM1.step (Turing.TM2to1.tr M))
                  (Turing.TM1.stepAux (Turing.TM2to1.trNormal q) v (Turing.Tape.mk' ∅ (Turing.TM2to1.addBottom T))) b) →
        ∃ b,
          Turing.TM2to1.TrCfg (Turing.TM2.stepAux (Turing.TM2to1.stRun o q) v S) b ∧
            StateTransition.Reaches (Turing.TM1.step (Turing.TM2to1.tr M))
              (Turing.TM1.stepAux (Turing.TM2to1.trNormal (Turing.TM2to1.stRun o q)) v
                (Turing.Tape.mk' ∅ (Turing.TM2to1.addBottom T)))
              b

theorem Turing.TM2to1.tr_respects E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} [inst : DecidableEq K]
  (M : Λ → Turing.TM2.Stmt Γ Λ σ),
  StateTransition.Respects (Turing.TM2.step M) (Turing.TM1.step (Turing.TM2to1.tr M)) Turing.TM2to1.TrCfg

theorem Turing.TM2to1.trCfg_init E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} [inst : DecidableEq K] [inst_1 : Inhabited Λ]
  [inst_2 : Inhabited σ] (k : K) (L : List (Γ k)),
  Turing.TM2to1.TrCfg (Turing.TM2.init k L) (Turing.TM1.init (Turing.TM2to1.trInit k L))

theorem Turing.TM2to1.tr_eval_dom E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} [inst : DecidableEq K] (M : Λ → Turing.TM2.Stmt Γ Λ σ)
  [inst_1 : Inhabited Λ] [inst_2 : Inhabited σ] (k : K) (L : List (Γ k)),
  (Turing.TM1.eval (Turing.TM2to1.tr M) (Turing.TM2to1.trInit k L)).Dom ↔ (Turing.TM2.eval M k L).Dom

theorem Turing.TM2to1.tr_eval E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} [inst : DecidableEq K] (M : Λ → Turing.TM2.Stmt Γ Λ σ)
  [inst_1 : Inhabited Λ] [inst_2 : Inhabited σ] (k : K) (L : List (Γ k)) {L₁ : Turing.ListBlank (Turing.TM2to1.Γ' K Γ)}
  {L₂ : List (Γ k)},
  L₁ ∈ Turing.TM1.eval (Turing.TM2to1.tr M) (Turing.TM2to1.trInit k L) →
    L₂ ∈ Turing.TM2.eval M k L →
      ∃ S L',
        Turing.TM2to1.addBottom L' = L₁ ∧
          (∀ (k : K), Turing.ListBlank.map (Turing.proj k) L' = Turing.ListBlank.mk (List.map some (S k)).reverse) ∧
            S k = L₂

def Turing.TM2to1.trSupp E1 #

{K : Type u_1} →
  {Γ : K → Type u_2} →
    {Λ : Type u_3} → {σ : Type u_4} → (Λ → Turing.TM2.Stmt Γ Λ σ) → Finset Λ → Finset (Turing.TM2to1.Λ' K Γ Λ σ)

The support of a set of TM2 states in the TM2 emulator.

theorem Turing.TM2to1.tr_supports E1 #

∀ {K : Type u_1} {Γ : K → Type u_2} {Λ : Type u_3} {σ : Type u_4} [inst : DecidableEq K] (M : Λ → Turing.TM2.Stmt Γ Λ σ)
  [inst_1 : Inhabited Λ] {S : Finset Λ},
  Turing.TM2.Supports M S → Turing.TM1.Supports (Turing.TM2to1.tr M) (Turing.TM2to1.trSupp M S)