The areas / V32. Logic, model theory and computability
Mathlib.Computability.TuringMachine.PostTuringMachine
178 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Λ.Kis 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:
Stmtis 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".Cfgis the set of instantaneous configurations, that is, the state of the machine together with its environment.Machineis 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 Cfgis the function that describes how the state evolves over one step. Ifstep c = none, thencis a terminal state, and the result of the computation is read off fromc. Because of the type ofstep, these models are all deterministic by construction.init : Input → Cfgsets up the initial state. The typeInputdepends on the model; in most cases it isList Γ.eval : Machine → Input → Part Output, given a machineMand inputi, starts frominit i, runsstepuntil it reaches an output, and then applies a functionCfg → Outputto the final state to obtain the result. The typeOutputdepends on the model.Supports : Machine → Finset Λ → Propasserts that a machineMstarts inS : Finset Λ, and can only ever jump to other states insideS. This implies that the behavior ofMon any input cannot depend on its values outsideS. 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 TM0 model
A TM0 Turing machine is essentially a Post-Turing machine, adapted for type theory.
A Post-Turing machine with symbol type Γ and label type Λ is a function
Λ → Γ → Option (Λ × Stmt), where a Stmt can be either move left, move right or write a
for a : Γ. The machine works over a "tape", a doubly-infinite sequence of elements of Γ, and
an instantaneous configuration, Cfg, is a label q : Λ indicating the current internal state of
the machine, and a Tape Γ (which is essentially ℤ →₀ Γ). The evolution is described by the
step function:
- If
M q T.head = none, then the machine halts. - If
M q T.head = some (q', s), then the machine performs actions : Stmtand then transitions to stateq'.
The initial state takes a List Γ and produces a Tape Γ where the head of the list is the head
of the tape and the rest of the list extends to the right, with the left side all blank. The final
state takes the entire right side of the tape right or equal to the current position of the
machine. (This is actually a ListBlank Γ, not a List Γ, because we don't know, at this level
of generality, where the output ends. If equality to default : Γ is decidable we can trim the list
to remove the infinite tail of blanks.)
The TM1 model
The TM1 model is a simplification and extension of TM0 (Post-Turing model) in the direction of
Wang B-machines. The machine's internal state is extended with a (finite) store σ of variables
that may be accessed and updated at any time.
A machine is given by a Λ indexed set of procedures or functions. Each function has a body which
is a Stmt. Most of the regular commands are allowed to use the current value a of the local
variables and the value T.head on the tape to calculate what to write or how to change local
state, but the statements themselves have a fixed structure. The Stmts can be as follows:
move d q: move left or right, and then doqwrite (f : Γ → σ → Γ) q: writef a T.headto the tape, then doqload (f : Γ → σ → σ) q: change the internal state tof a T.headbranch (f : Γ → σ → Bool) qtrue qfalse: Iff a T.headis true, doqtrue, elseqfalsegoto (f : Γ → σ → Λ): Go to labelf a T.headhalt: Transition to the halting state, which halts on the following step
Note that here most statements do not have labels; goto commands can only go to a new function.
Only the goto and halt statements actually take a step; the rest is done by recursion on
statements and so take 0 steps. (There is a uniform bound on how many statements can be executed
before the next goto, so this is an O(1) speedup with the constant depending on the machine.)
The halt command has a one step stutter before actually halting so that any changes made before
the halt have a chance to be "committed", since the eval relation uses the final configuration
before the halt as the output, and move and write etc. take 0 steps in this model.
TM1 emulator in TM0
To prove that TM1 computable functions are TM0 computable, we need to reduce each TM1 program to a TM0 program. So suppose a TM1 program is given. We take the following:
- The alphabet
Γis the same for both TM1 and TM0 - The set of states
Λ'is defined to beOption Stmt₁ × σ, that is, a TM1 statement ornonerepresenting halt, and the possible settings of the internal variables. Note that this is an infinite set, becauseStmt₁is infinite. This is okay because we assume that from the initial TM1 state, only finitely many other labels are reachable, and there are only finitely many statements that appear in all of these functions.
Even though Stmt₁ contains a statement called halt, we must separate it from none
(some halt steps to none and none actually halts) because there is a one step stutter in the
TM1 semantics.
TM1(Γ) emulator in TM1(Bool)
The most parsimonious Turing machine model that is still Turing complete is TM0 with Γ = Bool.
Because our construction in the previous section reducing TM1 to TM0 doesn't change the
alphabet, we can do the alphabet reduction on TM1 instead of TM0 directly.
The basic idea is to use a bijection between Γ and a subset of Vector Bool n, where n is a
fixed constant. Each tape element is represented as a block of n Bools. Whenever the machine
wants to read a symbol from the tape, it traverses over the block, performing n branch
instructions to reach any of the 2^n results.
For the write instruction, we have to use a goto because we need to follow a different code
path depending on the local state, which is not available in the TM1 model, so instead we jump to
a label computed using the read value and the local state, which performs the writing and returns
to normal execution.
Emulation overhead is O(1). If not for the above write behavior it would be 1-1 because we are
exploiting the 0-step behavior of regular commands to avoid taking steps, but there are
nevertheless a bounded number of write calls between goto statements because TM1 statements are
finitely long.
TM0 emulator in TM1
To establish that TM0 and TM1 are equivalent computational models, we must also have a TM0 emulator
in TM1. The main complication here is that TM0 allows an action to depend on the value at the head
and local state, while TM1 does not (in order to have more programming language-like semantics).
So we use a computed goto to go to a state that performs the desired action and then returns to
normal execution.
One issue with this is that the halt instruction is supposed to halt immediately, not take a step
to a halting state. To resolve this we do a check for halt first, then goto (with an
unreachable branch).
theorem Turing.TM1.stmts₁.match_1.congr_eq_3 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} (motive : Turing.TM1.Stmt Γ Λ σ → Sort u_4) (x : Turing.TM1.Stmt Γ Λ σ)
(h_1 :
(Q : Turing.TM1.Stmt Γ Λ σ) →
(a : Turing.Dir) → (q : Turing.TM1.Stmt Γ Λ σ) → Q = Turing.TM1.Stmt.move a q → motive (Turing.TM1.Stmt.move a q))
(h_2 :
(Q : Turing.TM1.Stmt Γ Λ σ) →
(a : Γ → σ → Γ) →
(q : Turing.TM1.Stmt Γ Λ σ) → Q = Turing.TM1.Stmt.write a q → motive (Turing.TM1.Stmt.write a q))
(h_3 :
(Q : Turing.TM1.Stmt Γ Λ σ) →
(a : Γ → σ → σ) → (q : Turing.TM1.Stmt Γ Λ σ) → Q = Turing.TM1.Stmt.load a q → motive (Turing.TM1.Stmt.load a q))
(h_4 :
(Q : Turing.TM1.Stmt Γ Λ σ) →
(a : Γ → σ → Bool) →
(q₁ q₂ : Turing.TM1.Stmt Γ Λ σ) → Q = Turing.TM1.Stmt.branch a q₁ q₂ → motive (Turing.TM1.Stmt.branch a q₁ q₂))
(h_5 : (Q : Turing.TM1.Stmt Γ Λ σ) → motive Q) (a : Γ → σ → σ) (q : Turing.TM1.Stmt Γ Λ σ),
x = Turing.TM1.Stmt.load a q →
(match x with
| Q@h:(Turing.TM1.Stmt.move a q) => h_1 Q a q h
| Q@h:(Turing.TM1.Stmt.write a q) => h_2 Q a q h
| Q@h:(Turing.TM1.Stmt.load a q) => h_3 Q a q h
| Q@h:(Turing.TM1.Stmt.branch a q₁ q₂) => h_4 Q a q₁ q₂ h
| Q => h_5 Q) ≍
h_3 (Turing.TM1.Stmt.load a q) a q ⋯
def Turing.TM1.Stmt.ctorIdx E1 #
{Γ : Type u_1} → {Λ : Type u_2} → {σ : Type u_3} → Turing.TM1.Stmt Γ Λ σ → ℕ
theorem Turing.TM1.Stmt.goto.inj E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} {a a_1 : Γ → σ → Λ},
Turing.TM1.Stmt.goto a = Turing.TM1.Stmt.goto a_1 → a = a_1
theorem Turing.TM1.stmts₁.match_1.congr_eq_1 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} (motive : Turing.TM1.Stmt Γ Λ σ → Sort u_4) (x : Turing.TM1.Stmt Γ Λ σ)
(h_1 :
(Q : Turing.TM1.Stmt Γ Λ σ) →
(a : Turing.Dir) → (q : Turing.TM1.Stmt Γ Λ σ) → Q = Turing.TM1.Stmt.move a q → motive (Turing.TM1.Stmt.move a q))
(h_2 :
(Q : Turing.TM1.Stmt Γ Λ σ) →
(a : Γ → σ → Γ) →
(q : Turing.TM1.Stmt Γ Λ σ) → Q = Turing.TM1.Stmt.write a q → motive (Turing.TM1.Stmt.write a q))
(h_3 :
(Q : Turing.TM1.Stmt Γ Λ σ) →
(a : Γ → σ → σ) → (q : Turing.TM1.Stmt Γ Λ σ) → Q = Turing.TM1.Stmt.load a q → motive (Turing.TM1.Stmt.load a q))
(h_4 :
(Q : Turing.TM1.Stmt Γ Λ σ) →
(a : Γ → σ → Bool) →
(q₁ q₂ : Turing.TM1.Stmt Γ Λ σ) → Q = Turing.TM1.Stmt.branch a q₁ q₂ → motive (Turing.TM1.Stmt.branch a q₁ q₂))
(h_5 : (Q : Turing.TM1.Stmt Γ Λ σ) → motive Q) (a : Turing.Dir) (q : Turing.TM1.Stmt Γ Λ σ),
x = Turing.TM1.Stmt.move a q →
(match x with
| Q@h:(Turing.TM1.Stmt.move a q) => h_1 Q a q h
| Q@h:(Turing.TM1.Stmt.write a q) => h_2 Q a q h
| Q@h:(Turing.TM1.Stmt.load a q) => h_3 Q a q h
| Q@h:(Turing.TM1.Stmt.branch a q₁ q₂) => h_4 Q a q₁ q₂ h
| Q => h_5 Q) ≍
h_1 (Turing.TM1.Stmt.move a q) a q ⋯
theorem Turing.TM1to1.trTape.congr_simp E1 #
∀ {Γ : Type u_1} {n : ℕ} {enc enc_1 : Γ → List.Vector Bool n} (e_enc : enc = enc_1) [inst : Inhabited Γ]
(enc0 : enc default = List.Vector.replicate n false) (T T_1 : Turing.Tape Γ),
T = T_1 → Turing.TM1to1.trTape enc0 T = Turing.TM1to1.trTape ⋯ T_1
theorem Turing.TM1.stepAux.match_1.congr_eq_3 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} [inst : Inhabited Γ]
(motive : Turing.TM1.Stmt Γ Λ σ → σ → Turing.Tape Γ → Sort u_4) (x : Turing.TM1.Stmt Γ Λ σ) (x_1 : σ)
(x_2 : Turing.Tape Γ)
(h_1 :
(d : Turing.Dir) →
(q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → (T : Turing.Tape Γ) → motive (Turing.TM1.Stmt.move d q) v T)
(h_2 :
(a : Γ → σ → Γ) →
(q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → (T : Turing.Tape Γ) → motive (Turing.TM1.Stmt.write a q) v T)
(h_3 :
(s : Γ → σ → σ) →
(q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → (T : Turing.Tape Γ) → motive (Turing.TM1.Stmt.load s q) v T)
(h_4 :
(p : Γ → σ → Bool) →
(q₁ q₂ : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → (T : Turing.Tape Γ) → motive (Turing.TM1.Stmt.branch p q₁ q₂) v T)
(h_5 : (l : Γ → σ → Λ) → (v : σ) → (T : Turing.Tape Γ) → motive (Turing.TM1.Stmt.goto l) v T)
(h_6 : (v : σ) → (T : Turing.Tape Γ) → motive Turing.TM1.Stmt.halt v T) (s : Γ → σ → σ) (q : Turing.TM1.Stmt Γ Λ σ)
(v : σ) (T : Turing.Tape Γ),
x = Turing.TM1.Stmt.load s q →
x_1 = v →
x_2 = T →
(match x, x_1, x_2 with
| Turing.TM1.Stmt.move d q, v, T => h_1 d q v T
| Turing.TM1.Stmt.write a q, v, T => h_2 a q v T
| Turing.TM1.Stmt.load s q, v, T => h_3 s q v T
| Turing.TM1.Stmt.branch p q₁ q₂, v, T => h_4 p q₁ q₂ v T
| Turing.TM1.Stmt.goto l, v, T => h_5 l v T
| Turing.TM1.Stmt.halt, v, T => h_6 v T) ≍
h_3 s q v T
theorem Turing.TM1.SupportsStmt.match_1.congr_eq_3 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} (motive : Turing.TM1.Stmt Γ Λ σ → Sort u_4) (x : Turing.TM1.Stmt Γ Λ σ)
(h_1 : (a : Turing.Dir) → (q : Turing.TM1.Stmt Γ Λ σ) → motive (Turing.TM1.Stmt.move a q))
(h_2 : (a : Γ → σ → Γ) → (q : Turing.TM1.Stmt Γ Λ σ) → motive (Turing.TM1.Stmt.write a q))
(h_3 : (a : Γ → σ → σ) → (q : Turing.TM1.Stmt Γ Λ σ) → motive (Turing.TM1.Stmt.load a q))
(h_4 : (a : Γ → σ → Bool) → (q₁ q₂ : Turing.TM1.Stmt Γ Λ σ) → motive (Turing.TM1.Stmt.branch a q₁ q₂))
(h_5 : (l : Γ → σ → Λ) → motive (Turing.TM1.Stmt.goto l)) (h_6 : Unit → motive Turing.TM1.Stmt.halt) (a : Γ → σ → σ)
(q : Turing.TM1.Stmt Γ Λ σ),
x = Turing.TM1.Stmt.load a q →
(match x with
| Turing.TM1.Stmt.move a q => h_1 a q
| Turing.TM1.Stmt.write a q => h_2 a q
| Turing.TM1.Stmt.load a q => h_3 a q
| Turing.TM1.Stmt.branch a q₁ q₂ => h_4 a q₁ q₂
| Turing.TM1.Stmt.goto l => h_5 l
| Turing.TM1.Stmt.halt => h_6 ()) ≍
h_3 a q
abbrev Turing.TM0to1.Λ'.ctorElimType E1 #
{Γ : Type u_1} →
{Λ : Type u_2} →
{motive : Turing.TM0to1.Λ' Γ Λ → Sort u} → ℕ → Sort (max 1 (imax (u_1 + 1) (u_2 + 1) u) (imax (u_2 + 1) u))
theorem Turing.TM0.Stmt.move.inj E1 #
∀ {Γ : Type u_1} {a a_1 : Turing.Dir}, Turing.TM0.Stmt.move a = Turing.TM0.Stmt.move a_1 → a = a_1
theorem Turing.TM0.Cfg.map.match_1.congr_eq_1 E1 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] {Λ : Type u_2} (motive : Turing.TM0.Cfg Γ Λ → Sort u_3) (x : Turing.TM0.Cfg Γ Λ)
(h_1 : (q : Λ) → (T : Turing.Tape Γ) → motive { q := q, Tape := T }) (q : Λ) (T : Turing.Tape Γ),
x = { q := q, Tape := T } →
(match x with
| { q := q, Tape := T } => h_1 q T) ≍
h_1 q T
theorem Turing.TM1to1.Λ'.normal.injEq E0 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} (a a_1 : Λ),
(Turing.TM1to1.Λ'.normal a = Turing.TM1to1.Λ'.normal a_1) = (a = a_1)
theorem Turing.TM0to1.tr.match_3.congr_eq_2 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} (motive : Turing.TM0to1.Λ' Γ Λ → Sort u_3) (x : Turing.TM0to1.Λ' Γ Λ)
(h_1 : (q : Λ) → motive (Turing.TM0to1.Λ'.normal q))
(h_2 : (d : Turing.Dir) → (q : Λ) → motive (Turing.TM0to1.Λ'.act (Turing.TM0.Stmt.move d) q))
(h_3 : (a : Γ) → (q : Λ) → motive (Turing.TM0to1.Λ'.act (Turing.TM0.Stmt.write a) q)) (d : Turing.Dir) (q : Λ),
x = Turing.TM0to1.Λ'.act (Turing.TM0.Stmt.move d) q →
(match x with
| Turing.TM0to1.Λ'.normal q => h_1 q
| Turing.TM0to1.Λ'.act (Turing.TM0.Stmt.move d) q => h_2 d q
| Turing.TM0to1.Λ'.act (Turing.TM0.Stmt.write a) q => h_3 a q) ≍
h_2 d q
theorem Turing.TM1.SupportsStmt.match_1.congr_eq_2 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} (motive : Turing.TM1.Stmt Γ Λ σ → Sort u_4) (x : Turing.TM1.Stmt Γ Λ σ)
(h_1 : (a : Turing.Dir) → (q : Turing.TM1.Stmt Γ Λ σ) → motive (Turing.TM1.Stmt.move a q))
(h_2 : (a : Γ → σ → Γ) → (q : Turing.TM1.Stmt Γ Λ σ) → motive (Turing.TM1.Stmt.write a q))
(h_3 : (a : Γ → σ → σ) → (q : Turing.TM1.Stmt Γ Λ σ) → motive (Turing.TM1.Stmt.load a q))
(h_4 : (a : Γ → σ → Bool) → (q₁ q₂ : Turing.TM1.Stmt Γ Λ σ) → motive (Turing.TM1.Stmt.branch a q₁ q₂))
(h_5 : (l : Γ → σ → Λ) → motive (Turing.TM1.Stmt.goto l)) (h_6 : Unit → motive Turing.TM1.Stmt.halt) (a : Γ → σ → Γ)
(q : Turing.TM1.Stmt Γ Λ σ),
x = Turing.TM1.Stmt.write a q →
(match x with
| Turing.TM1.Stmt.move a q => h_1 a q
| Turing.TM1.Stmt.write a q => h_2 a q
| Turing.TM1.Stmt.load a q => h_3 a q
| Turing.TM1.Stmt.branch a q₁ q₂ => h_4 a q₁ q₂
| Turing.TM1.Stmt.goto l => h_5 l
| Turing.TM1.Stmt.halt => h_6 ()) ≍
h_2 a q
theorem Turing.TM0to1.Λ'.act.injEq E0 #
∀ {Γ : Type u_1} {Λ : Type u_2} (a : Turing.TM0.Stmt Γ) (a_1 : Λ) (a_2 : Turing.TM0.Stmt Γ) (a_3 : Λ),
(Turing.TM0to1.Λ'.act a a_1 = Turing.TM0to1.Λ'.act a_2 a_3) = (a = a_2 ∧ a_1 = a_3)
theorem Turing.TM1.SupportsStmt.match_1.congr_eq_6 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} (motive : Turing.TM1.Stmt Γ Λ σ → Sort u_4) (x : Turing.TM1.Stmt Γ Λ σ)
(h_1 : (a : Turing.Dir) → (q : Turing.TM1.Stmt Γ Λ σ) → motive (Turing.TM1.Stmt.move a q))
(h_2 : (a : Γ → σ → Γ) → (q : Turing.TM1.Stmt Γ Λ σ) → motive (Turing.TM1.Stmt.write a q))
(h_3 : (a : Γ → σ → σ) → (q : Turing.TM1.Stmt Γ Λ σ) → motive (Turing.TM1.Stmt.load a q))
(h_4 : (a : Γ → σ → Bool) → (q₁ q₂ : Turing.TM1.Stmt Γ Λ σ) → motive (Turing.TM1.Stmt.branch a q₁ q₂))
(h_5 : (l : Γ → σ → Λ) → motive (Turing.TM1.Stmt.goto l)) (h_6 : Unit → motive Turing.TM1.Stmt.halt),
x = Turing.TM1.Stmt.halt →
(match x with
| Turing.TM1.Stmt.move a q => h_1 a q
| Turing.TM1.Stmt.write a q => h_2 a q
| Turing.TM1.Stmt.load a q => h_3 a q
| Turing.TM1.Stmt.branch a q₁ q₂ => h_4 a q₁ q₂
| Turing.TM1.Stmt.goto l => h_5 l
| Turing.TM1.Stmt.halt => h_6 ()) ≍
h_6 ()
abbrev Turing.TM0.Stmt.ctorElimType E1 #
{Γ : Type u_1} → {motive : Turing.TM0.Stmt Γ → Sort u} → ℕ → Sort (max 1 u (imax (u_1 + 1) u))
theorem Turing.TM0to1.tr.match_1.congr_eq_1 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} (motive : Option (Λ × Turing.TM0.Stmt Γ) → Sort u_3)
(x : Option (Λ × Turing.TM0.Stmt Γ)) (h_1 : Unit → motive none)
(h_2 : (q' : Λ) → (s : Turing.TM0.Stmt Γ) → motive (some (q', s))),
x = none →
(match x with
| none => h_1 ()
| some (q', s) => h_2 q' s) ≍
h_1 ()
theorem Turing.TM1.Stmt.brecOn.eq E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} {motive : Turing.TM1.Stmt Γ Λ σ → Sort u} (t : Turing.TM1.Stmt Γ Λ σ)
(F_1 : (t : Turing.TM1.Stmt Γ Λ σ) → Turing.TM1.Stmt.below t → motive t),
Turing.TM1.Stmt.brecOn t F_1 = F_1 t (Turing.TM1.Stmt.brecOn.go t F_1).2
theorem Turing.TM1to1.write.match_1.congr_eq_1 E1 #
∀ {Γ : Type u_3} {Λ : Type u_2} {σ : Type u_1}
(motive : List Bool → Turing.TM1.Stmt Bool (Turing.TM1to1.Λ' Γ Λ σ) σ → Sort u_4) (x : List Bool)
(x_1 : Turing.TM1.Stmt Bool (Turing.TM1to1.Λ' Γ Λ σ) σ)
(h_1 : (q : Turing.TM1.Stmt Bool (Turing.TM1to1.Λ' Γ Λ σ) σ) → motive [] q)
(h_2 : (a : Bool) → (l : List Bool) → (q : Turing.TM1.Stmt Bool (Turing.TM1to1.Λ' Γ Λ σ) σ) → motive (a :: l) q)
(q : Turing.TM1.Stmt Bool (Turing.TM1to1.Λ' Γ Λ σ) σ),
x = [] →
x_1 = q →
(match x, x_1 with
| [], q => h_1 q
| a :: l, q => h_2 a l q) ≍
h_1 q
theorem Turing.TM1.Stmt.branch.inj E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} {a : Γ → σ → Bool} {a_1 a_2 : Turing.TM1.Stmt Γ Λ σ} {a_3 : Γ → σ → Bool}
{a_4 a_5 : Turing.TM1.Stmt Γ Λ σ},
Turing.TM1.Stmt.branch a a_1 a_2 = Turing.TM1.Stmt.branch a_3 a_4 a_5 → a = a_3 ∧ a_1 = a_4 ∧ a_2 = a_5
abbrev Turing.TM1to1.Λ'.ctorElimType E1 #
{Γ : Type u_1} →
{Λ : Type u_2} →
{σ : Type u_3} →
{motive : Turing.TM1to1.Λ' Γ Λ σ → Sort u} →
ℕ → Sort (max 1 (imax (u_1 + 1) (max (max (u_1 + 1) (u_2 + 1)) (u_3 + 1)) u) (imax (u_2 + 1) u))
theorem Turing.TM1.SupportsStmt.match_1.congr_eq_4 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} (motive : Turing.TM1.Stmt Γ Λ σ → Sort u_4) (x : Turing.TM1.Stmt Γ Λ σ)
(h_1 : (a : Turing.Dir) → (q : Turing.TM1.Stmt Γ Λ σ) → motive (Turing.TM1.Stmt.move a q))
(h_2 : (a : Γ → σ → Γ) → (q : Turing.TM1.Stmt Γ Λ σ) → motive (Turing.TM1.Stmt.write a q))
(h_3 : (a : Γ → σ → σ) → (q : Turing.TM1.Stmt Γ Λ σ) → motive (Turing.TM1.Stmt.load a q))
(h_4 : (a : Γ → σ → Bool) → (q₁ q₂ : Turing.TM1.Stmt Γ Λ σ) → motive (Turing.TM1.Stmt.branch a q₁ q₂))
(h_5 : (l : Γ → σ → Λ) → motive (Turing.TM1.Stmt.goto l)) (h_6 : Unit → motive Turing.TM1.Stmt.halt)
(a : Γ → σ → Bool) (q₁ q₂ : Turing.TM1.Stmt Γ Λ σ),
x = Turing.TM1.Stmt.branch a q₁ q₂ →
(match x with
| Turing.TM1.Stmt.move a q => h_1 a q
| Turing.TM1.Stmt.write a q => h_2 a q
| Turing.TM1.Stmt.load a q => h_3 a q
| Turing.TM1.Stmt.branch a q₁ q₂ => h_4 a q₁ q₂
| Turing.TM1.Stmt.goto l => h_5 l
| Turing.TM1.Stmt.halt => h_6 ()) ≍
h_4 a q₁ q₂
theorem Turing.TM1.Stmt.move.inj E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} {a : Turing.Dir} {a_1 : Turing.TM1.Stmt Γ Λ σ} {a_2 : Turing.Dir}
{a_3 : Turing.TM1.Stmt Γ Λ σ}, Turing.TM1.Stmt.move a a_1 = Turing.TM1.Stmt.move a_2 a_3 → a = a_2 ∧ a_1 = a_3
theorem Turing.TM1.SupportsStmt.match_1.congr_eq_1 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} (motive : Turing.TM1.Stmt Γ Λ σ → Sort u_4) (x : Turing.TM1.Stmt Γ Λ σ)
(h_1 : (a : Turing.Dir) → (q : Turing.TM1.Stmt Γ Λ σ) → motive (Turing.TM1.Stmt.move a q))
(h_2 : (a : Γ → σ → Γ) → (q : Turing.TM1.Stmt Γ Λ σ) → motive (Turing.TM1.Stmt.write a q))
(h_3 : (a : Γ → σ → σ) → (q : Turing.TM1.Stmt Γ Λ σ) → motive (Turing.TM1.Stmt.load a q))
(h_4 : (a : Γ → σ → Bool) → (q₁ q₂ : Turing.TM1.Stmt Γ Λ σ) → motive (Turing.TM1.Stmt.branch a q₁ q₂))
(h_5 : (l : Γ → σ → Λ) → motive (Turing.TM1.Stmt.goto l)) (h_6 : Unit → motive Turing.TM1.Stmt.halt) (a : Turing.Dir)
(q : Turing.TM1.Stmt Γ Λ σ),
x = Turing.TM1.Stmt.move a q →
(match x with
| Turing.TM1.Stmt.move a q => h_1 a q
| Turing.TM1.Stmt.write a q => h_2 a q
| Turing.TM1.Stmt.load a q => h_3 a q
| Turing.TM1.Stmt.branch a q₁ q₂ => h_4 a q₁ q₂
| Turing.TM1.Stmt.goto l => h_5 l
| Turing.TM1.Stmt.halt => h_6 ()) ≍
h_1 a q
def Turing.TM1.Cfg.ctorIdx E1 #
{Γ : Type u_1} → {Λ : Type u_2} → {σ : Type u_3} → {inst : Inhabited Γ} → Turing.TM1.Cfg Γ Λ σ → ℕ
theorem Turing.TM0.step.match_3.congr_eq_1 E1 #
∀ {Γ : Type u_2} {Λ : Type u_1} (motive : Λ × Turing.TM0.Stmt Γ → Sort u_3) (x : Λ × Turing.TM0.Stmt Γ)
(h_1 : (q' : Λ) → (a : Turing.TM0.Stmt Γ) → motive (q', a)) (q' : Λ) (a : Turing.TM0.Stmt Γ),
x = (q', a) →
(match x with
| (q', a) => h_1 q' a) ≍
h_1 q' a
def Turing.TM0.Stmt.ctorIdx E1 #
{Γ : Type u_1} → Turing.TM0.Stmt Γ → ℕ
theorem Turing.TM0to1.Λ'.normal.inj E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {a a_1 : Λ}, Turing.TM0to1.Λ'.normal a = Turing.TM0to1.Λ'.normal a_1 → a = a_1
theorem Turing.TM1to1.trCfg.congr_simp E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} {n : ℕ} (enc enc_1 : Γ → List.Vector Bool n) (e_enc : enc = enc_1)
[inst : Inhabited Γ] (enc0 : enc default = List.Vector.replicate n false) (a a_1 : Turing.TM1.Cfg Γ Λ σ),
a = a_1 → Turing.TM1to1.trCfg enc enc0 a = Turing.TM1to1.trCfg enc_1 ⋯ a_1
def Turing.TM0.Cfg.ctorIdx E1 #
{Γ : Type u_1} → {Λ : Type u_2} → {inst : Inhabited Γ} → Turing.TM0.Cfg Γ Λ → ℕ
abbrev Turing.TM1.Stmt.brecOn.go E1 #
{Γ : Type u_1} →
{Λ : Type u_2} →
{σ : Type u_3} →
{motive : Turing.TM1.Stmt Γ Λ σ → Sort u} →
(t : Turing.TM1.Stmt Γ Λ σ) →
((t : Turing.TM1.Stmt Γ Λ σ) → Turing.TM1.Stmt.below t → motive t) → motive t ×' Turing.TM1.Stmt.below t
theorem Turing.TM1.stmts₁.match_1.congr_eq_5 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} (motive : Turing.TM1.Stmt Γ Λ σ → Sort u_4) (x : Turing.TM1.Stmt Γ Λ σ)
(h_1 :
(Q : Turing.TM1.Stmt Γ Λ σ) →
(a : Turing.Dir) → (q : Turing.TM1.Stmt Γ Λ σ) → Q = Turing.TM1.Stmt.move a q → motive (Turing.TM1.Stmt.move a q))
(h_2 :
(Q : Turing.TM1.Stmt Γ Λ σ) →
(a : Γ → σ → Γ) →
(q : Turing.TM1.Stmt Γ Λ σ) → Q = Turing.TM1.Stmt.write a q → motive (Turing.TM1.Stmt.write a q))
(h_3 :
(Q : Turing.TM1.Stmt Γ Λ σ) →
(a : Γ → σ → σ) → (q : Turing.TM1.Stmt Γ Λ σ) → Q = Turing.TM1.Stmt.load a q → motive (Turing.TM1.Stmt.load a q))
(h_4 :
(Q : Turing.TM1.Stmt Γ Λ σ) →
(a : Γ → σ → Bool) →
(q₁ q₂ : Turing.TM1.Stmt Γ Λ σ) → Q = Turing.TM1.Stmt.branch a q₁ q₂ → motive (Turing.TM1.Stmt.branch a q₁ q₂))
(h_5 : (Q : Turing.TM1.Stmt Γ Λ σ) → motive Q) (Q : Turing.TM1.Stmt Γ Λ σ),
x = Q →
(∀ (a : Turing.Dir) (q : Turing.TM1.Stmt Γ Λ σ), Q = Turing.TM1.Stmt.move a q → False) →
(∀ (a : Γ → σ → Γ) (q : Turing.TM1.Stmt Γ Λ σ), Q = Turing.TM1.Stmt.write a q → False) →
(∀ (a : Γ → σ → σ) (q : Turing.TM1.Stmt Γ Λ σ), Q = Turing.TM1.Stmt.load a q → False) →
(∀ (a : Γ → σ → Bool) (q₁ q₂ : Turing.TM1.Stmt Γ Λ σ), Q = Turing.TM1.Stmt.branch a q₁ q₂ → False) →
(match x with
| Q@h:(Turing.TM1.Stmt.move a q) => h_1 Q a q h
| Q@h:(Turing.TM1.Stmt.write a q) => h_2 Q a q h
| Q@h:(Turing.TM1.Stmt.load a q) => h_3 Q a q h
| Q@h:(Turing.TM1.Stmt.branch a q₁ q₂) => h_4 Q a q₁ q₂ h
| Q => h_5 Q) ≍
h_5 Q
theorem Turing.TM1.Stmt.load.inj E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} {a : Γ → σ → σ} {a_1 : Turing.TM1.Stmt Γ Λ σ} {a_2 : Γ → σ → σ}
{a_3 : Turing.TM1.Stmt Γ Λ σ}, Turing.TM1.Stmt.load a a_1 = Turing.TM1.Stmt.load a_2 a_3 → a = a_2 ∧ a_1 = a_3
theorem Turing.TM1to1.Λ'.write.injEq E0 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} (a : Γ) (a_1 : Turing.TM1.Stmt Γ Λ σ) (a_2 : Γ)
(a_3 : Turing.TM1.Stmt Γ Λ σ), (Turing.TM1to1.Λ'.write a a_1 = Turing.TM1to1.Λ'.write a_2 a_3) = (a = a_2 ∧ a_1 = a_3)
theorem Turing.TM1to1.Λ'.normal.inj E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} {a a_1 : Λ},
Turing.TM1to1.Λ'.normal a = Turing.TM1to1.Λ'.normal a_1 → a = a_1
def Turing.TM1to1.Λ'.ctorIdx E1 #
{Γ : Type u_1} → {Λ : Type u_2} → {σ : Type u_3} → Turing.TM1to1.Λ' Γ Λ σ → ℕ
theorem Turing.TM1to1.trTape'.congr_simp E1 #
∀ {Γ : Type u_1} {n : ℕ} {enc enc_1 : Γ → List.Vector Bool n} (e_enc : enc = enc_1) [inst : Inhabited Γ]
(enc0 : enc default = List.Vector.replicate n false) (L L_1 : Turing.ListBlank Γ),
L = L_1 → ∀ (R R_1 : Turing.ListBlank Γ), R = R_1 → Turing.TM1to1.trTape' enc0 L R = Turing.TM1to1.trTape' ⋯ L_1 R_1
theorem Turing.TM1to0.trAux.match_1.congr_eq_6 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} (motive : Turing.TM1.Stmt Γ Λ σ → σ → Sort u_4)
(x : Turing.TM1.Stmt Γ Λ σ) (x_1 : σ)
(h_1 : (d : Turing.Dir) → (q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → motive (Turing.TM1.Stmt.move d q) v)
(h_2 : (a : Γ → σ → Γ) → (q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → motive (Turing.TM1.Stmt.write a q) v)
(h_3 : (a : Γ → σ → σ) → (q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → motive (Turing.TM1.Stmt.load a q) v)
(h_4 : (p : Γ → σ → Bool) → (q₁ q₂ : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → motive (Turing.TM1.Stmt.branch p q₁ q₂) v)
(h_5 : (l : Γ → σ → Λ) → (v : σ) → motive (Turing.TM1.Stmt.goto l) v) (h_6 : (v : σ) → motive Turing.TM1.Stmt.halt v)
(v : σ),
x = Turing.TM1.Stmt.halt →
x_1 = v →
(match x, x_1 with
| Turing.TM1.Stmt.move d q, v => h_1 d q v
| Turing.TM1.Stmt.write a q, v => h_2 a q v
| Turing.TM1.Stmt.load a q, v => h_3 a q v
| Turing.TM1.Stmt.branch p q₁ q₂, v => h_4 p q₁ q₂ v
| Turing.TM1.Stmt.goto l, v => h_5 l v
| Turing.TM1.Stmt.halt, v => h_6 v) ≍
h_6 v
theorem Turing.TM1.Cfg.mk.injEq E0 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} [inst : Inhabited Γ] (l : Option Λ) (var : σ) (Tape : Turing.Tape Γ)
(l_1 : Option Λ) (var_1 : σ) (Tape_1 : Turing.Tape Γ),
({ l := l, var := var, Tape := Tape } = { l := l_1, var := var_1, Tape := Tape_1 }) =
(l = l_1 ∧ var = var_1 ∧ Tape = Tape_1)
theorem Turing.TM0to1.tr.match_1.congr_eq_2 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} (motive : Option (Λ × Turing.TM0.Stmt Γ) → Sort u_3)
(x : Option (Λ × Turing.TM0.Stmt Γ)) (h_1 : Unit → motive none)
(h_2 : (q' : Λ) → (s : Turing.TM0.Stmt Γ) → motive (some (q', s))) (q' : Λ) (s : Turing.TM0.Stmt Γ),
x = some (q', s) →
(match x with
| none => h_1 ()
| some (q', s) => h_2 q' s) ≍
h_2 q' s
theorem Turing.TM1to1.tr.match_1.congr_eq_2 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} (motive : Turing.TM1to1.Λ' Γ Λ σ → Sort u_4) (x : Turing.TM1to1.Λ' Γ Λ σ)
(h_1 : (l : Λ) → motive (Turing.TM1to1.Λ'.normal l))
(h_2 : (a : Γ) → (q : Turing.TM1.Stmt Γ Λ σ) → motive (Turing.TM1to1.Λ'.write a q)) (a : Γ)
(q : Turing.TM1.Stmt Γ Λ σ),
x = Turing.TM1to1.Λ'.write a q →
(match x with
| Turing.TM1to1.Λ'.normal l => h_1 l
| Turing.TM1to1.Λ'.write a q => h_2 a q) ≍
h_2 a q
theorem Turing.TM1.stepAux.match_1.congr_eq_5 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} [inst : Inhabited Γ]
(motive : Turing.TM1.Stmt Γ Λ σ → σ → Turing.Tape Γ → Sort u_4) (x : Turing.TM1.Stmt Γ Λ σ) (x_1 : σ)
(x_2 : Turing.Tape Γ)
(h_1 :
(d : Turing.Dir) →
(q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → (T : Turing.Tape Γ) → motive (Turing.TM1.Stmt.move d q) v T)
(h_2 :
(a : Γ → σ → Γ) →
(q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → (T : Turing.Tape Γ) → motive (Turing.TM1.Stmt.write a q) v T)
(h_3 :
(s : Γ → σ → σ) →
(q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → (T : Turing.Tape Γ) → motive (Turing.TM1.Stmt.load s q) v T)
(h_4 :
(p : Γ → σ → Bool) →
(q₁ q₂ : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → (T : Turing.Tape Γ) → motive (Turing.TM1.Stmt.branch p q₁ q₂) v T)
(h_5 : (l : Γ → σ → Λ) → (v : σ) → (T : Turing.Tape Γ) → motive (Turing.TM1.Stmt.goto l) v T)
(h_6 : (v : σ) → (T : Turing.Tape Γ) → motive Turing.TM1.Stmt.halt v T) (l : Γ → σ → Λ) (v : σ) (T : Turing.Tape Γ),
x = Turing.TM1.Stmt.goto l →
x_1 = v →
x_2 = T →
(match x, x_1, x_2 with
| Turing.TM1.Stmt.move d q, v, T => h_1 d q v T
| Turing.TM1.Stmt.write a q, v, T => h_2 a q v T
| Turing.TM1.Stmt.load s q, v, T => h_3 s q v T
| Turing.TM1.Stmt.branch p q₁ q₂, v, T => h_4 p q₁ q₂ v T
| Turing.TM1.Stmt.goto l, v, T => h_5 l v T
| Turing.TM1.Stmt.halt, v, T => h_6 v T) ≍
h_5 l v T
theorem Turing.TM0.Stmt.move.injEq E0 #
∀ {Γ : Type u_1} (a a_1 : Turing.Dir), (Turing.TM0.Stmt.move a = Turing.TM0.Stmt.move a_1) = (a = a_1)
theorem Turing.TM1to0.tr.match_1.congr_eq_2 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} (M : Λ → Turing.TM1.Stmt Γ Λ σ)
(motive : Turing.TM1to0.Λ' M → Γ → Sort u_4) (x : Turing.TM1to0.Λ' M) (x_1 : Γ)
(h_1 : (snd : σ) → (x : Γ) → motive (none, snd) x)
(h_2 : (q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → (s : Γ) → motive (some q, v) s) (q : Turing.TM1.Stmt Γ Λ σ) (v : σ)
(s : Γ),
x = (some q, v) →
x_1 = s →
(match x, x_1 with
| (none, snd), x => h_1 snd x
| (some q, v), s => h_2 q v s) ≍
h_2 q v s
theorem Turing.TM1.step.match_1.congr_eq_1 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} [inst : Inhabited Γ] (motive : Turing.TM1.Cfg Γ Λ σ → Sort u_4)
(x : Turing.TM1.Cfg Γ Λ σ) (h_1 : (var : σ) → (Tape : Turing.Tape Γ) → motive { l := none, var := var, Tape := Tape })
(h_2 : (l : Λ) → (v : σ) → (T : Turing.Tape Γ) → motive { l := some l, var := v, Tape := T }) (var : σ)
(Tape : Turing.Tape Γ),
x = { l := none, var := var, Tape := Tape } →
(match x with
| { l := none, var := var, Tape := Tape } => h_1 var Tape
| { l := some l, var := v, Tape := T } => h_2 l v T) ≍
h_1 var Tape
theorem Turing.TM1.Stmt.write.injEq E0 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} (a : Γ → σ → Γ) (a_1 : Turing.TM1.Stmt Γ Λ σ) (a_2 : Γ → σ → Γ)
(a_3 : Turing.TM1.Stmt Γ Λ σ), (Turing.TM1.Stmt.write a a_1 = Turing.TM1.Stmt.write a_2 a_3) = (a = a_2 ∧ a_1 = a_3)
theorem Turing.TM0.Cfg.mk.inj E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {inst : Inhabited Γ} {q : Λ} {Tape : Turing.Tape Γ} {q_1 : Λ} {Tape_1 : Turing.Tape Γ},
{ q := q, Tape := Tape } = { q := q_1, Tape := Tape_1 } → q = q_1 ∧ Tape = Tape_1
theorem Turing.TM1to0.trAux.match_1.congr_eq_5 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} (motive : Turing.TM1.Stmt Γ Λ σ → σ → Sort u_4)
(x : Turing.TM1.Stmt Γ Λ σ) (x_1 : σ)
(h_1 : (d : Turing.Dir) → (q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → motive (Turing.TM1.Stmt.move d q) v)
(h_2 : (a : Γ → σ → Γ) → (q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → motive (Turing.TM1.Stmt.write a q) v)
(h_3 : (a : Γ → σ → σ) → (q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → motive (Turing.TM1.Stmt.load a q) v)
(h_4 : (p : Γ → σ → Bool) → (q₁ q₂ : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → motive (Turing.TM1.Stmt.branch p q₁ q₂) v)
(h_5 : (l : Γ → σ → Λ) → (v : σ) → motive (Turing.TM1.Stmt.goto l) v) (h_6 : (v : σ) → motive Turing.TM1.Stmt.halt v)
(l : Γ → σ → Λ) (v : σ),
x = Turing.TM1.Stmt.goto l →
x_1 = v →
(match x, x_1 with
| Turing.TM1.Stmt.move d q, v => h_1 d q v
| Turing.TM1.Stmt.write a q, v => h_2 a q v
| Turing.TM1.Stmt.load a q, v => h_3 a q v
| Turing.TM1.Stmt.branch p q₁ q₂, v => h_4 p q₁ q₂ v
| Turing.TM1.Stmt.goto l, v => h_5 l v
| Turing.TM1.Stmt.halt, v => h_6 v) ≍
h_5 l v
theorem Turing.TM1.Stmt.move.injEq E0 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} (a : Turing.Dir) (a_1 : Turing.TM1.Stmt Γ Λ σ) (a_2 : Turing.Dir)
(a_3 : Turing.TM1.Stmt Γ Λ σ), (Turing.TM1.Stmt.move a a_1 = Turing.TM1.Stmt.move a_2 a_3) = (a = a_2 ∧ a_1 = a_3)
theorem Turing.TM0to1.Λ'.normal.injEq E0 #
∀ {Γ : Type u_1} {Λ : Type u_2} (a a_1 : Λ), (Turing.TM0to1.Λ'.normal a = Turing.TM0to1.Λ'.normal a_1) = (a = a_1)
theorem Turing.TM1to0.trAux.match_1.congr_eq_2 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} (motive : Turing.TM1.Stmt Γ Λ σ → σ → Sort u_4)
(x : Turing.TM1.Stmt Γ Λ σ) (x_1 : σ)
(h_1 : (d : Turing.Dir) → (q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → motive (Turing.TM1.Stmt.move d q) v)
(h_2 : (a : Γ → σ → Γ) → (q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → motive (Turing.TM1.Stmt.write a q) v)
(h_3 : (a : Γ → σ → σ) → (q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → motive (Turing.TM1.Stmt.load a q) v)
(h_4 : (p : Γ → σ → Bool) → (q₁ q₂ : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → motive (Turing.TM1.Stmt.branch p q₁ q₂) v)
(h_5 : (l : Γ → σ → Λ) → (v : σ) → motive (Turing.TM1.Stmt.goto l) v) (h_6 : (v : σ) → motive Turing.TM1.Stmt.halt v)
(a : Γ → σ → Γ) (q : Turing.TM1.Stmt Γ Λ σ) (v : σ),
x = Turing.TM1.Stmt.write a q →
x_1 = v →
(match x, x_1 with
| Turing.TM1.Stmt.move d q, v => h_1 d q v
| Turing.TM1.Stmt.write a q, v => h_2 a q v
| Turing.TM1.Stmt.load a q, v => h_3 a q v
| Turing.TM1.Stmt.branch p q₁ q₂, v => h_4 p q₁ q₂ v
| Turing.TM1.Stmt.goto l, v => h_5 l v
| Turing.TM1.Stmt.halt, v => h_6 v) ≍
h_2 a q v
theorem Turing.TM0.step.match_1.congr_eq_2 E1 #
∀ {Γ : Type u_1} (motive : Turing.TM0.Stmt Γ → Sort u_2) (a : Turing.TM0.Stmt Γ)
(h_1 : (d : Turing.Dir) → motive (Turing.TM0.Stmt.move d)) (h_2 : (a : Γ) → motive (Turing.TM0.Stmt.write a))
(a_1 : Γ),
a = Turing.TM0.Stmt.write a_1 →
(match a with
| Turing.TM0.Stmt.move d => h_1 d
| Turing.TM0.Stmt.write a => h_2 a) ≍
h_2 a_1
theorem Turing.TM1.stmts₁.match_1.congr_eq_4 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} (motive : Turing.TM1.Stmt Γ Λ σ → Sort u_4) (x : Turing.TM1.Stmt Γ Λ σ)
(h_1 :
(Q : Turing.TM1.Stmt Γ Λ σ) →
(a : Turing.Dir) → (q : Turing.TM1.Stmt Γ Λ σ) → Q = Turing.TM1.Stmt.move a q → motive (Turing.TM1.Stmt.move a q))
(h_2 :
(Q : Turing.TM1.Stmt Γ Λ σ) →
(a : Γ → σ → Γ) →
(q : Turing.TM1.Stmt Γ Λ σ) → Q = Turing.TM1.Stmt.write a q → motive (Turing.TM1.Stmt.write a q))
(h_3 :
(Q : Turing.TM1.Stmt Γ Λ σ) →
(a : Γ → σ → σ) → (q : Turing.TM1.Stmt Γ Λ σ) → Q = Turing.TM1.Stmt.load a q → motive (Turing.TM1.Stmt.load a q))
(h_4 :
(Q : Turing.TM1.Stmt Γ Λ σ) →
(a : Γ → σ → Bool) →
(q₁ q₂ : Turing.TM1.Stmt Γ Λ σ) → Q = Turing.TM1.Stmt.branch a q₁ q₂ → motive (Turing.TM1.Stmt.branch a q₁ q₂))
(h_5 : (Q : Turing.TM1.Stmt Γ Λ σ) → motive Q) (a : Γ → σ → Bool) (q₁ q₂ : Turing.TM1.Stmt Γ Λ σ),
x = Turing.TM1.Stmt.branch a q₁ q₂ →
(match x with
| Q@h:(Turing.TM1.Stmt.move a q) => h_1 Q a q h
| Q@h:(Turing.TM1.Stmt.write a q) => h_2 Q a q h
| Q@h:(Turing.TM1.Stmt.load a q) => h_3 Q a q h
| Q@h:(Turing.TM1.Stmt.branch a q₁ q₂) => h_4 Q a q₁ q₂ h
| Q => h_5 Q) ≍
h_4 (Turing.TM1.Stmt.branch a q₁ q₂) a q₁ q₂ ⋯
theorem Turing.TM0to1.tr.match_3.congr_eq_3 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} (motive : Turing.TM0to1.Λ' Γ Λ → Sort u_3) (x : Turing.TM0to1.Λ' Γ Λ)
(h_1 : (q : Λ) → motive (Turing.TM0to1.Λ'.normal q))
(h_2 : (d : Turing.Dir) → (q : Λ) → motive (Turing.TM0to1.Λ'.act (Turing.TM0.Stmt.move d) q))
(h_3 : (a : Γ) → (q : Λ) → motive (Turing.TM0to1.Λ'.act (Turing.TM0.Stmt.write a) q)) (a : Γ) (q : Λ),
x = Turing.TM0to1.Λ'.act (Turing.TM0.Stmt.write a) q →
(match x with
| Turing.TM0to1.Λ'.normal q => h_1 q
| Turing.TM0to1.Λ'.act (Turing.TM0.Stmt.move d) q => h_2 d q
| Turing.TM0to1.Λ'.act (Turing.TM0.Stmt.write a) q => h_3 a q) ≍
h_3 a q
theorem Turing.TM1to1.Λ'.write.inj E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} {a : Γ} {a_1 : Turing.TM1.Stmt Γ Λ σ} {a_2 : Γ}
{a_3 : Turing.TM1.Stmt Γ Λ σ}, Turing.TM1to1.Λ'.write a a_1 = Turing.TM1to1.Λ'.write a_2 a_3 → a = a_2 ∧ a_1 = a_3
def Turing.TM0to1.Λ'.ctorIdx E1 #
{Γ : Type u_1} → {Λ : Type u_2} → Turing.TM0to1.Λ' Γ Λ → ℕ
theorem Turing.TM1.stepAux.match_1.congr_eq_1 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} [inst : Inhabited Γ]
(motive : Turing.TM1.Stmt Γ Λ σ → σ → Turing.Tape Γ → Sort u_4) (x : Turing.TM1.Stmt Γ Λ σ) (x_1 : σ)
(x_2 : Turing.Tape Γ)
(h_1 :
(d : Turing.Dir) →
(q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → (T : Turing.Tape Γ) → motive (Turing.TM1.Stmt.move d q) v T)
(h_2 :
(a : Γ → σ → Γ) →
(q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → (T : Turing.Tape Γ) → motive (Turing.TM1.Stmt.write a q) v T)
(h_3 :
(s : Γ → σ → σ) →
(q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → (T : Turing.Tape Γ) → motive (Turing.TM1.Stmt.load s q) v T)
(h_4 :
(p : Γ → σ → Bool) →
(q₁ q₂ : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → (T : Turing.Tape Γ) → motive (Turing.TM1.Stmt.branch p q₁ q₂) v T)
(h_5 : (l : Γ → σ → Λ) → (v : σ) → (T : Turing.Tape Γ) → motive (Turing.TM1.Stmt.goto l) v T)
(h_6 : (v : σ) → (T : Turing.Tape Γ) → motive Turing.TM1.Stmt.halt v T) (d : Turing.Dir) (q : Turing.TM1.Stmt Γ Λ σ)
(v : σ) (T : Turing.Tape Γ),
x = Turing.TM1.Stmt.move d q →
x_1 = v →
x_2 = T →
(match x, x_1, x_2 with
| Turing.TM1.Stmt.move d q, v, T => h_1 d q v T
| Turing.TM1.Stmt.write a q, v, T => h_2 a q v T
| Turing.TM1.Stmt.load s q, v, T => h_3 s q v T
| Turing.TM1.Stmt.branch p q₁ q₂, v, T => h_4 p q₁ q₂ v T
| Turing.TM1.Stmt.goto l, v, T => h_5 l v T
| Turing.TM1.Stmt.halt, v, T => h_6 v T) ≍
h_1 d q v T
abbrev Turing.TM1.Stmt.ctorElimType E1 #
{Γ : Type u_1} →
{Λ : Type u_2} →
{σ : Type u_3} →
{motive : Turing.TM1.Stmt Γ Λ σ → Sort u} →
ℕ →
Sort
(max 1 u (imax (max (u_1 + 1) (u_3 + 1)) (max (max (u_1 + 1) (u_2 + 1)) (u_3 + 1)) u)
(imax (max (u_1 + 1) (u_3 + 1)) (max (max (u_1 + 1) (u_2 + 1)) (u_3 + 1))
(max (max (u_1 + 1) (u_2 + 1)) (u_3 + 1)) u)
(imax (max (max (u_1 + 1) (u_2 + 1)) (u_3 + 1)) u))
theorem Turing.TM1to0.trCfg.match_1.congr_eq_1 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} [inst : Inhabited Γ] (motive : Turing.TM1.Cfg Γ Λ σ → Sort u_4)
(x : Turing.TM1.Cfg Γ Λ σ)
(h_1 : (l : Option Λ) → (v : σ) → (T : Turing.Tape Γ) → motive { l := l, var := v, Tape := T }) (l : Option Λ) (v : σ)
(T : Turing.Tape Γ),
x = { l := l, var := v, Tape := T } →
(match x with
| { l := l, var := v, Tape := T } => h_1 l v T) ≍
h_1 l v T
theorem Turing.TM1.Stmt.goto.injEq E0 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} (a a_1 : Γ → σ → Λ),
(Turing.TM1.Stmt.goto a = Turing.TM1.Stmt.goto a_1) = (a = a_1)
theorem Turing.TM0.step.match_1.congr_eq_1 E1 #
∀ {Γ : Type u_1} (motive : Turing.TM0.Stmt Γ → Sort u_2) (a : Turing.TM0.Stmt Γ)
(h_1 : (d : Turing.Dir) → motive (Turing.TM0.Stmt.move d)) (h_2 : (a : Γ) → motive (Turing.TM0.Stmt.write a))
(d : Turing.Dir),
a = Turing.TM0.Stmt.move d →
(match a with
| Turing.TM0.Stmt.move d => h_1 d
| Turing.TM0.Stmt.write a => h_2 a) ≍
h_1 d
theorem Turing.TM0to1.Λ'.act.inj E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {a : Turing.TM0.Stmt Γ} {a_1 : Λ} {a_2 : Turing.TM0.Stmt Γ} {a_3 : Λ},
Turing.TM0to1.Λ'.act a a_1 = Turing.TM0to1.Λ'.act a_2 a_3 → a = a_2 ∧ a_1 = a_3
theorem Turing.TM0to1.tr.match_3.congr_eq_1 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} (motive : Turing.TM0to1.Λ' Γ Λ → Sort u_3) (x : Turing.TM0to1.Λ' Γ Λ)
(h_1 : (q : Λ) → motive (Turing.TM0to1.Λ'.normal q))
(h_2 : (d : Turing.Dir) → (q : Λ) → motive (Turing.TM0to1.Λ'.act (Turing.TM0.Stmt.move d) q))
(h_3 : (a : Γ) → (q : Λ) → motive (Turing.TM0to1.Λ'.act (Turing.TM0.Stmt.write a) q)) (q : Λ),
x = Turing.TM0to1.Λ'.normal q →
(match x with
| Turing.TM0to1.Λ'.normal q => h_1 q
| Turing.TM0to1.Λ'.act (Turing.TM0.Stmt.move d) q => h_2 d q
| Turing.TM0to1.Λ'.act (Turing.TM0.Stmt.write a) q => h_3 a q) ≍
h_1 q
theorem Turing.TM0.Cfg.mk.injEq E0 #
∀ {Γ : Type u_1} {Λ : Type u_2} [inst : Inhabited Γ] (q : Λ) (Tape : Turing.Tape Γ) (q_1 : Λ) (Tape_1 : Turing.Tape Γ),
({ q := q, Tape := Tape } = { q := q_1, Tape := Tape_1 }) = (q = q_1 ∧ Tape = Tape_1)
theorem Turing.TM0.Stmt.write.inj E1 #
∀ {Γ : Type u_1} {a a_1 : Γ}, Turing.TM0.Stmt.write a = Turing.TM0.Stmt.write a_1 → a = a_1
theorem Turing.TM1to1.tr.match_1.congr_eq_1 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} (motive : Turing.TM1to1.Λ' Γ Λ σ → Sort u_4) (x : Turing.TM1to1.Λ' Γ Λ σ)
(h_1 : (l : Λ) → motive (Turing.TM1to1.Λ'.normal l))
(h_2 : (a : Γ) → (q : Turing.TM1.Stmt Γ Λ σ) → motive (Turing.TM1to1.Λ'.write a q)) (l : Λ),
x = Turing.TM1to1.Λ'.normal l →
(match x with
| Turing.TM1to1.Λ'.normal l => h_1 l
| Turing.TM1to1.Λ'.write a q => h_2 a q) ≍
h_1 l
theorem Turing.TM0.step.match_5.congr_eq_1 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} [inst : Inhabited Γ] (motive : Turing.TM0.Cfg Γ Λ → Sort u_3) (x : Turing.TM0.Cfg Γ Λ)
(h_1 : (q : Λ) → (T : Turing.Tape Γ) → motive { q := q, Tape := T }) (q : Λ) (T : Turing.Tape Γ),
x = { q := q, Tape := T } →
(match x with
| { q := q, Tape := T } => h_1 q T) ≍
h_1 q T
theorem Turing.TM1.stepAux.match_1.congr_eq_4 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} [inst : Inhabited Γ]
(motive : Turing.TM1.Stmt Γ Λ σ → σ → Turing.Tape Γ → Sort u_4) (x : Turing.TM1.Stmt Γ Λ σ) (x_1 : σ)
(x_2 : Turing.Tape Γ)
(h_1 :
(d : Turing.Dir) →
(q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → (T : Turing.Tape Γ) → motive (Turing.TM1.Stmt.move d q) v T)
(h_2 :
(a : Γ → σ → Γ) →
(q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → (T : Turing.Tape Γ) → motive (Turing.TM1.Stmt.write a q) v T)
(h_3 :
(s : Γ → σ → σ) →
(q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → (T : Turing.Tape Γ) → motive (Turing.TM1.Stmt.load s q) v T)
(h_4 :
(p : Γ → σ → Bool) →
(q₁ q₂ : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → (T : Turing.Tape Γ) → motive (Turing.TM1.Stmt.branch p q₁ q₂) v T)
(h_5 : (l : Γ → σ → Λ) → (v : σ) → (T : Turing.Tape Γ) → motive (Turing.TM1.Stmt.goto l) v T)
(h_6 : (v : σ) → (T : Turing.Tape Γ) → motive Turing.TM1.Stmt.halt v T) (p : Γ → σ → Bool)
(q₁ q₂ : Turing.TM1.Stmt Γ Λ σ) (v : σ) (T : Turing.Tape Γ),
x = Turing.TM1.Stmt.branch p q₁ q₂ →
x_1 = v →
x_2 = T →
(match x, x_1, x_2 with
| Turing.TM1.Stmt.move d q, v, T => h_1 d q v T
| Turing.TM1.Stmt.write a q, v, T => h_2 a q v T
| Turing.TM1.Stmt.load s q, v, T => h_3 s q v T
| Turing.TM1.Stmt.branch p q₁ q₂, v, T => h_4 p q₁ q₂ v T
| Turing.TM1.Stmt.goto l, v, T => h_5 l v T
| Turing.TM1.Stmt.halt, v, T => h_6 v T) ≍
h_4 p q₁ q₂ v T
theorem Turing.TM1.Stmt.load.injEq E0 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} (a : Γ → σ → σ) (a_1 : Turing.TM1.Stmt Γ Λ σ) (a_2 : Γ → σ → σ)
(a_3 : Turing.TM1.Stmt Γ Λ σ), (Turing.TM1.Stmt.load a a_1 = Turing.TM1.Stmt.load a_2 a_3) = (a = a_2 ∧ a_1 = a_3)
theorem Turing.TM1.stepAux.match_1.congr_eq_2 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} [inst : Inhabited Γ]
(motive : Turing.TM1.Stmt Γ Λ σ → σ → Turing.Tape Γ → Sort u_4) (x : Turing.TM1.Stmt Γ Λ σ) (x_1 : σ)
(x_2 : Turing.Tape Γ)
(h_1 :
(d : Turing.Dir) →
(q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → (T : Turing.Tape Γ) → motive (Turing.TM1.Stmt.move d q) v T)
(h_2 :
(a : Γ → σ → Γ) →
(q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → (T : Turing.Tape Γ) → motive (Turing.TM1.Stmt.write a q) v T)
(h_3 :
(s : Γ → σ → σ) →
(q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → (T : Turing.Tape Γ) → motive (Turing.TM1.Stmt.load s q) v T)
(h_4 :
(p : Γ → σ → Bool) →
(q₁ q₂ : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → (T : Turing.Tape Γ) → motive (Turing.TM1.Stmt.branch p q₁ q₂) v T)
(h_5 : (l : Γ → σ → Λ) → (v : σ) → (T : Turing.Tape Γ) → motive (Turing.TM1.Stmt.goto l) v T)
(h_6 : (v : σ) → (T : Turing.Tape Γ) → motive Turing.TM1.Stmt.halt v T) (a : Γ → σ → Γ) (q : Turing.TM1.Stmt Γ Λ σ)
(v : σ) (T : Turing.Tape Γ),
x = Turing.TM1.Stmt.write a q →
x_1 = v →
x_2 = T →
(match x, x_1, x_2 with
| Turing.TM1.Stmt.move d q, v, T => h_1 d q v T
| Turing.TM1.Stmt.write a q, v, T => h_2 a q v T
| Turing.TM1.Stmt.load s q, v, T => h_3 s q v T
| Turing.TM1.Stmt.branch p q₁ q₂, v, T => h_4 p q₁ q₂ v T
| Turing.TM1.Stmt.goto l, v, T => h_5 l v T
| Turing.TM1.Stmt.halt, v, T => h_6 v T) ≍
h_2 a q v T
theorem Turing.TM1.stmts₁.match_1.congr_eq_2 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} (motive : Turing.TM1.Stmt Γ Λ σ → Sort u_4) (x : Turing.TM1.Stmt Γ Λ σ)
(h_1 :
(Q : Turing.TM1.Stmt Γ Λ σ) →
(a : Turing.Dir) → (q : Turing.TM1.Stmt Γ Λ σ) → Q = Turing.TM1.Stmt.move a q → motive (Turing.TM1.Stmt.move a q))
(h_2 :
(Q : Turing.TM1.Stmt Γ Λ σ) →
(a : Γ → σ → Γ) →
(q : Turing.TM1.Stmt Γ Λ σ) → Q = Turing.TM1.Stmt.write a q → motive (Turing.TM1.Stmt.write a q))
(h_3 :
(Q : Turing.TM1.Stmt Γ Λ σ) →
(a : Γ → σ → σ) → (q : Turing.TM1.Stmt Γ Λ σ) → Q = Turing.TM1.Stmt.load a q → motive (Turing.TM1.Stmt.load a q))
(h_4 :
(Q : Turing.TM1.Stmt Γ Λ σ) →
(a : Γ → σ → Bool) →
(q₁ q₂ : Turing.TM1.Stmt Γ Λ σ) → Q = Turing.TM1.Stmt.branch a q₁ q₂ → motive (Turing.TM1.Stmt.branch a q₁ q₂))
(h_5 : (Q : Turing.TM1.Stmt Γ Λ σ) → motive Q) (a : Γ → σ → Γ) (q : Turing.TM1.Stmt Γ Λ σ),
x = Turing.TM1.Stmt.write a q →
(match x with
| Q@h:(Turing.TM1.Stmt.move a q) => h_1 Q a q h
| Q@h:(Turing.TM1.Stmt.write a q) => h_2 Q a q h
| Q@h:(Turing.TM1.Stmt.load a q) => h_3 Q a q h
| Q@h:(Turing.TM1.Stmt.branch a q₁ q₂) => h_4 Q a q₁ q₂ h
| Q => h_5 Q) ≍
h_2 (Turing.TM1.Stmt.write a q) a q ⋯
theorem Turing.TM1to1.write.match_1.congr_eq_2 E1 #
∀ {Γ : Type u_3} {Λ : Type u_2} {σ : Type u_1}
(motive : List Bool → Turing.TM1.Stmt Bool (Turing.TM1to1.Λ' Γ Λ σ) σ → Sort u_4) (x : List Bool)
(x_1 : Turing.TM1.Stmt Bool (Turing.TM1to1.Λ' Γ Λ σ) σ)
(h_1 : (q : Turing.TM1.Stmt Bool (Turing.TM1to1.Λ' Γ Λ σ) σ) → motive [] q)
(h_2 : (a : Bool) → (l : List Bool) → (q : Turing.TM1.Stmt Bool (Turing.TM1to1.Λ' Γ Λ σ) σ) → motive (a :: l) q)
(a : Bool) (l : List Bool) (q : Turing.TM1.Stmt Bool (Turing.TM1to1.Λ' Γ Λ σ) σ),
x = a :: l →
x_1 = q →
(match x, x_1 with
| [], q => h_1 q
| a :: l, q => h_2 a l q) ≍
h_2 a l q
theorem Turing.TM0.Stmt.write.injEq E0 #
∀ {Γ : Type u_1} (a a_1 : Γ), (Turing.TM0.Stmt.write a = Turing.TM0.Stmt.write a_1) = (a = a_1)
theorem Turing.TM1to0.tr.match_1.congr_eq_1 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} (M : Λ → Turing.TM1.Stmt Γ Λ σ)
(motive : Turing.TM1to0.Λ' M → Γ → Sort u_4) (x : Turing.TM1to0.Λ' M) (x_1 : Γ)
(h_1 : (snd : σ) → (x : Γ) → motive (none, snd) x)
(h_2 : (q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → (s : Γ) → motive (some q, v) s) (snd : σ) (x_2 : Γ),
x = (none, snd) →
x_1 = x_2 →
(match x, x_1 with
| (none, snd), x => h_1 snd x
| (some q, v), s => h_2 q v s) ≍
h_1 snd x_2
theorem Turing.TM1.Stmt.write.inj E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} {a : Γ → σ → Γ} {a_1 : Turing.TM1.Stmt Γ Λ σ} {a_2 : Γ → σ → Γ}
{a_3 : Turing.TM1.Stmt Γ Λ σ}, Turing.TM1.Stmt.write a a_1 = Turing.TM1.Stmt.write a_2 a_3 → a = a_2 ∧ a_1 = a_3
theorem Turing.TM1to0.trAux.match_1.congr_eq_3 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} (motive : Turing.TM1.Stmt Γ Λ σ → σ → Sort u_4)
(x : Turing.TM1.Stmt Γ Λ σ) (x_1 : σ)
(h_1 : (d : Turing.Dir) → (q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → motive (Turing.TM1.Stmt.move d q) v)
(h_2 : (a : Γ → σ → Γ) → (q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → motive (Turing.TM1.Stmt.write a q) v)
(h_3 : (a : Γ → σ → σ) → (q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → motive (Turing.TM1.Stmt.load a q) v)
(h_4 : (p : Γ → σ → Bool) → (q₁ q₂ : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → motive (Turing.TM1.Stmt.branch p q₁ q₂) v)
(h_5 : (l : Γ → σ → Λ) → (v : σ) → motive (Turing.TM1.Stmt.goto l) v) (h_6 : (v : σ) → motive Turing.TM1.Stmt.halt v)
(a : Γ → σ → σ) (q : Turing.TM1.Stmt Γ Λ σ) (v : σ),
x = Turing.TM1.Stmt.load a q →
x_1 = v →
(match x, x_1 with
| Turing.TM1.Stmt.move d q, v => h_1 d q v
| Turing.TM1.Stmt.write a q, v => h_2 a q v
| Turing.TM1.Stmt.load a q, v => h_3 a q v
| Turing.TM1.Stmt.branch p q₁ q₂, v => h_4 p q₁ q₂ v
| Turing.TM1.Stmt.goto l, v => h_5 l v
| Turing.TM1.Stmt.halt, v => h_6 v) ≍
h_3 a q v
theorem Turing.TM1.stepAux.match_1.congr_eq_6 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} [inst : Inhabited Γ]
(motive : Turing.TM1.Stmt Γ Λ σ → σ → Turing.Tape Γ → Sort u_4) (x : Turing.TM1.Stmt Γ Λ σ) (x_1 : σ)
(x_2 : Turing.Tape Γ)
(h_1 :
(d : Turing.Dir) →
(q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → (T : Turing.Tape Γ) → motive (Turing.TM1.Stmt.move d q) v T)
(h_2 :
(a : Γ → σ → Γ) →
(q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → (T : Turing.Tape Γ) → motive (Turing.TM1.Stmt.write a q) v T)
(h_3 :
(s : Γ → σ → σ) →
(q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → (T : Turing.Tape Γ) → motive (Turing.TM1.Stmt.load s q) v T)
(h_4 :
(p : Γ → σ → Bool) →
(q₁ q₂ : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → (T : Turing.Tape Γ) → motive (Turing.TM1.Stmt.branch p q₁ q₂) v T)
(h_5 : (l : Γ → σ → Λ) → (v : σ) → (T : Turing.Tape Γ) → motive (Turing.TM1.Stmt.goto l) v T)
(h_6 : (v : σ) → (T : Turing.Tape Γ) → motive Turing.TM1.Stmt.halt v T) (v : σ) (T : Turing.Tape Γ),
x = Turing.TM1.Stmt.halt →
x_1 = v →
x_2 = T →
(match x, x_1, x_2 with
| Turing.TM1.Stmt.move d q, v, T => h_1 d q v T
| Turing.TM1.Stmt.write a q, v, T => h_2 a q v T
| Turing.TM1.Stmt.load s q, v, T => h_3 s q v T
| Turing.TM1.Stmt.branch p q₁ q₂, v, T => h_4 p q₁ q₂ v T
| Turing.TM1.Stmt.goto l, v, T => h_5 l v T
| Turing.TM1.Stmt.halt, v, T => h_6 v T) ≍
h_6 v T
theorem Turing.TM1.SupportsStmt.match_1.congr_eq_5 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} (motive : Turing.TM1.Stmt Γ Λ σ → Sort u_4) (x : Turing.TM1.Stmt Γ Λ σ)
(h_1 : (a : Turing.Dir) → (q : Turing.TM1.Stmt Γ Λ σ) → motive (Turing.TM1.Stmt.move a q))
(h_2 : (a : Γ → σ → Γ) → (q : Turing.TM1.Stmt Γ Λ σ) → motive (Turing.TM1.Stmt.write a q))
(h_3 : (a : Γ → σ → σ) → (q : Turing.TM1.Stmt Γ Λ σ) → motive (Turing.TM1.Stmt.load a q))
(h_4 : (a : Γ → σ → Bool) → (q₁ q₂ : Turing.TM1.Stmt Γ Λ σ) → motive (Turing.TM1.Stmt.branch a q₁ q₂))
(h_5 : (l : Γ → σ → Λ) → motive (Turing.TM1.Stmt.goto l)) (h_6 : Unit → motive Turing.TM1.Stmt.halt) (l : Γ → σ → Λ),
x = Turing.TM1.Stmt.goto l →
(match x with
| Turing.TM1.Stmt.move a q => h_1 a q
| Turing.TM1.Stmt.write a q => h_2 a q
| Turing.TM1.Stmt.load a q => h_3 a q
| Turing.TM1.Stmt.branch a q₁ q₂ => h_4 a q₁ q₂
| Turing.TM1.Stmt.goto l => h_5 l
| Turing.TM1.Stmt.halt => h_6 ()) ≍
h_5 l
theorem Turing.TM1to0.trAux.match_1.congr_eq_1 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} (motive : Turing.TM1.Stmt Γ Λ σ → σ → Sort u_4)
(x : Turing.TM1.Stmt Γ Λ σ) (x_1 : σ)
(h_1 : (d : Turing.Dir) → (q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → motive (Turing.TM1.Stmt.move d q) v)
(h_2 : (a : Γ → σ → Γ) → (q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → motive (Turing.TM1.Stmt.write a q) v)
(h_3 : (a : Γ → σ → σ) → (q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → motive (Turing.TM1.Stmt.load a q) v)
(h_4 : (p : Γ → σ → Bool) → (q₁ q₂ : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → motive (Turing.TM1.Stmt.branch p q₁ q₂) v)
(h_5 : (l : Γ → σ → Λ) → (v : σ) → motive (Turing.TM1.Stmt.goto l) v) (h_6 : (v : σ) → motive Turing.TM1.Stmt.halt v)
(d : Turing.Dir) (q : Turing.TM1.Stmt Γ Λ σ) (v : σ),
x = Turing.TM1.Stmt.move d q →
x_1 = v →
(match x, x_1 with
| Turing.TM1.Stmt.move d q, v => h_1 d q v
| Turing.TM1.Stmt.write a q, v => h_2 a q v
| Turing.TM1.Stmt.load a q, v => h_3 a q v
| Turing.TM1.Stmt.branch p q₁ q₂, v => h_4 p q₁ q₂ v
| Turing.TM1.Stmt.goto l, v => h_5 l v
| Turing.TM1.Stmt.halt, v => h_6 v) ≍
h_1 d q v
theorem Turing.TM1to0.trAux.match_1.congr_eq_4 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} (motive : Turing.TM1.Stmt Γ Λ σ → σ → Sort u_4)
(x : Turing.TM1.Stmt Γ Λ σ) (x_1 : σ)
(h_1 : (d : Turing.Dir) → (q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → motive (Turing.TM1.Stmt.move d q) v)
(h_2 : (a : Γ → σ → Γ) → (q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → motive (Turing.TM1.Stmt.write a q) v)
(h_3 : (a : Γ → σ → σ) → (q : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → motive (Turing.TM1.Stmt.load a q) v)
(h_4 : (p : Γ → σ → Bool) → (q₁ q₂ : Turing.TM1.Stmt Γ Λ σ) → (v : σ) → motive (Turing.TM1.Stmt.branch p q₁ q₂) v)
(h_5 : (l : Γ → σ → Λ) → (v : σ) → motive (Turing.TM1.Stmt.goto l) v) (h_6 : (v : σ) → motive Turing.TM1.Stmt.halt v)
(p : Γ → σ → Bool) (q₁ q₂ : Turing.TM1.Stmt Γ Λ σ) (v : σ),
x = Turing.TM1.Stmt.branch p q₁ q₂ →
x_1 = v →
(match x, x_1 with
| Turing.TM1.Stmt.move d q, v => h_1 d q v
| Turing.TM1.Stmt.write a q, v => h_2 a q v
| Turing.TM1.Stmt.load a q, v => h_3 a q v
| Turing.TM1.Stmt.branch p q₁ q₂, v => h_4 p q₁ q₂ v
| Turing.TM1.Stmt.goto l, v => h_5 l v
| Turing.TM1.Stmt.halt, v => h_6 v) ≍
h_4 p q₁ q₂ v
theorem Turing.TM1.step.match_1.congr_eq_2 E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} [inst : Inhabited Γ] (motive : Turing.TM1.Cfg Γ Λ σ → Sort u_4)
(x : Turing.TM1.Cfg Γ Λ σ) (h_1 : (var : σ) → (Tape : Turing.Tape Γ) → motive { l := none, var := var, Tape := Tape })
(h_2 : (l : Λ) → (v : σ) → (T : Turing.Tape Γ) → motive { l := some l, var := v, Tape := T }) (l : Λ) (v : σ)
(T : Turing.Tape Γ),
x = { l := some l, var := v, Tape := T } →
(match x with
| { l := none, var := var, Tape := Tape } => h_1 var Tape
| { l := some l, var := v, Tape := T } => h_2 l v T) ≍
h_2 l v T
theorem Turing.TM1.Stmt.branch.injEq E0 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} (a : Γ → σ → Bool) (a_1 a_2 : Turing.TM1.Stmt Γ Λ σ) (a_3 : Γ → σ → Bool)
(a_4 a_5 : Turing.TM1.Stmt Γ Λ σ),
(Turing.TM1.Stmt.branch a a_1 a_2 = Turing.TM1.Stmt.branch a_3 a_4 a_5) = (a = a_3 ∧ a_1 = a_4 ∧ a_2 = a_5)
theorem Turing.TM1.Cfg.mk.inj E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} {inst : Inhabited Γ} {l : Option Λ} {var : σ} {Tape : Turing.Tape Γ}
{l_1 : Option Λ} {var_1 : σ} {Tape_1 : Turing.Tape Γ},
{ l := l, var := var, Tape := Tape } = { l := l_1, var := var_1, Tape := Tape_1 } →
l = l_1 ∧ var = var_1 ∧ Tape = Tape_1
inductive Turing.TM0.Stmt E1 #
Type u_1 → Type u_1
A Turing machine "statement" is just a command to either move left or right, or write a symbol on the tape.
ctor Turing.TM0.Stmt.move E0 #
{Γ : Type u_1} → Turing.Dir → Turing.TM0.Stmt Γ
ctor Turing.TM0.Stmt.write E0 #
{Γ : Type u_1} → Γ → Turing.TM0.Stmt Γ
instance Turing.TM0.Stmt.inhabited E0 #
(Γ : Type u_1) → [Inhabited Γ] → Inhabited (Turing.TM0.Stmt Γ)
def Turing.TM0.Machine E3 #
Type u_1 → (Λ : Type u_2) → [Inhabited Λ] → Type (max (max u_1 u_2) u_1 u_2)
A Post-Turing machine with symbol type Γ and label type Λ
is a function which, given the current state q : Λ and
the tape head a : Γ, either halts (returns none) or returns
a new state q' : Λ and a Stmt describing what to do,
either a move left or right, or a write command.
Both Λ and Γ are required to be inhabited; the default value
for Γ is the "blank" tape value, and the default value of Λ is
the initial state.
instance Turing.TM0.instInhabitedMachine E0 #
(Γ : Type u_1) → (Λ : Type u_2) → [inst : Inhabited Λ] → Inhabited (Turing.TM0.Machine Γ Λ)
structure Turing.TM0.Cfg E1 #
(Γ : Type u_1) → Type u_2 → [Inhabited Γ] → Type (max u_1 u_2)
The configuration state of a Turing machine during operation
consists of a label (machine state), and a tape.
The tape is represented in the form (a, L, R), meaning the tape looks like L.rev ++ [a] ++ R
with the machine currently reading the a. The lists are
automatically extended with blanks as the machine moves around.
ctor Turing.TM0.Cfg.mk E0 #
{Γ : Type u_1} → {Λ : Type u_2} → [inst : Inhabited Γ] → Λ → Turing.Tape Γ → Turing.TM0.Cfg Γ Λ
abbrev Turing.TM0.Cfg.q E1 #
{Γ : Type u_1} → {Λ : Type u_2} → [inst : Inhabited Γ] → Turing.TM0.Cfg Γ Λ → Λ
The current machine state.
abbrev Turing.TM0.Cfg.Tape E1 #
{Γ : Type u_1} → {Λ : Type u_2} → [inst : Inhabited Γ] → Turing.TM0.Cfg Γ Λ → Turing.Tape Γ
The current state of the tape: current symbol, left and right parts.
instance Turing.TM0.Cfg.inhabited E0 #
{Γ : Type u_1} → {Λ : Type u_2} → [Inhabited Λ] → [inst : Inhabited Γ] → Inhabited (Turing.TM0.Cfg Γ Λ)
def Turing.TM0.step E1 #
{Γ : Type u_1} →
{Λ : Type u_2} →
[inst : Inhabited Λ] →
[inst_1 : Inhabited Γ] → Turing.TM0.Machine Γ Λ → Turing.TM0.Cfg Γ Λ → Option (Turing.TM0.Cfg Γ Λ)
Execution semantics of the Turing machine.
def Turing.TM0.Reaches E1 #
{Γ : Type u_1} →
{Λ : Type u_2} →
[inst : Inhabited Λ] →
[inst_1 : Inhabited Γ] → Turing.TM0.Machine Γ Λ → Turing.TM0.Cfg Γ Λ → Turing.TM0.Cfg Γ Λ → Prop
The statement Reaches M s₁ s₂ means that s₂ is obtained
starting from s₁ after a finite number of steps.
def Turing.TM0.init E1 #
{Γ : Type u_1} → {Λ : Type u_2} → [Inhabited Λ] → [inst : Inhabited Γ] → List Γ → Turing.TM0.Cfg Γ Λ
The initial configuration.
def Turing.TM0.eval E1 #
{Γ : Type u_1} →
{Λ : Type u_2} →
[inst : Inhabited Λ] → [inst_1 : Inhabited Γ] → Turing.TM0.Machine Γ Λ → List Γ → Part (Turing.ListBlank Γ)
Evaluate a Turing machine on initial input to a final state, if it terminates.
def Turing.TM0.Supports E1 #
{Γ : Type u_1} → {Λ : Type u_2} → [inst : Inhabited Λ] → Turing.TM0.Machine Γ Λ → Set Λ → Prop
The raw definition of a Turing machine does not require that
Γ and Λ are finite, and in practice we will be interested
in the infinite Λ case. We recover instead a notion of
"effectively finite" Turing machines, which only make use of a
finite subset of their states. We say that a set S ⊆ Λ
supports a Turing machine M if S is closed under the
transition function and contains the initial state.
theorem Turing.TM0.step_supports E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} [inst : Inhabited Λ] [inst_1 : Inhabited Γ] (M : Turing.TM0.Machine Γ Λ) {S : Set Λ},
Turing.TM0.Supports M S → ∀ {c c' : Turing.TM0.Cfg Γ Λ}, c' ∈ Turing.TM0.step M c → c.q ∈ S → c'.q ∈ S
theorem Turing.TM0.univ_supports E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} [inst : Inhabited Λ] (M : Turing.TM0.Machine Γ Λ), Turing.TM0.Supports M Set.univ
def Turing.TM0.Stmt.map E1 #
{Γ : Type u_1} →
[inst : Inhabited Γ] →
{Γ' : Type u_2} → [inst_1 : Inhabited Γ'] → Turing.PointedMap Γ Γ' → Turing.TM0.Stmt Γ → Turing.TM0.Stmt Γ'
Map a TM statement across a function. This does nothing to move statements and maps the write values.
def Turing.TM0.Cfg.map E1 #
{Γ : Type u_1} →
[inst : Inhabited Γ] →
{Γ' : Type u_2} →
[inst_1 : Inhabited Γ'] →
{Λ : Type u_3} → {Λ' : Type u_4} → Turing.PointedMap Γ Γ' → (Λ → Λ') → Turing.TM0.Cfg Γ Λ → Turing.TM0.Cfg Γ' Λ'
Map a configuration across a function, given f : Γ → Γ' a map of the alphabets and
g : Λ → Λ' a map of the machine states.
def Turing.TM0.Machine.map E1 #
{Γ : Type u_1} →
[inst : Inhabited Γ] →
{Γ' : Type u_2} →
[inst_1 : Inhabited Γ'] →
{Λ : Type u_3} →
[inst_2 : Inhabited Λ] →
{Λ' : Type u_4} →
[inst_3 : Inhabited Λ'] →
Turing.TM0.Machine Γ Λ →
Turing.PointedMap Γ Γ' → Turing.PointedMap Γ' Γ → (Λ → Λ') → (Λ' → Λ) → Turing.TM0.Machine Γ' Λ'
Because the state transition function uses the alphabet and machine states in both the input
and output, to map a machine from one alphabet and machine state space to another we need functions
in both directions, essentially an Equiv without the laws.
theorem Turing.TM0.Machine.map_step E0 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] {Γ' : Type u_2} [inst_1 : Inhabited Γ'] {Λ : Type u_3} [inst_2 : Inhabited Λ]
{Λ' : Type u_4} [inst_3 : Inhabited Λ'] (M : Turing.TM0.Machine Γ Λ) (f₁ : Turing.PointedMap Γ Γ')
(f₂ : Turing.PointedMap Γ' Γ) (g₁ : Λ → Λ') (g₂ : Λ' → Λ) {S : Set Λ},
Function.RightInverse f₁.f f₂.f →
(∀ q ∈ S, g₂ (g₁ q) = q) →
∀ (c : Turing.TM0.Cfg Γ Λ),
c.q ∈ S →
Option.map (Turing.TM0.Cfg.map f₁ g₁) (Turing.TM0.step M c) =
Turing.TM0.step (M.map f₁ f₂ g₁ g₂) (Turing.TM0.Cfg.map f₁ g₁ c)
theorem Turing.TM0.map_init E0 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] {Γ' : Type u_2} [inst_1 : Inhabited Γ'] {Λ : Type u_3} [inst_2 : Inhabited Λ]
{Λ' : Type u_4} [inst_3 : Inhabited Λ'] (f₁ : Turing.PointedMap Γ Γ') (g₁ : Turing.PointedMap Λ Λ') (l : List Γ),
Turing.TM0.Cfg.map f₁ g₁.f (Turing.TM0.init l) = Turing.TM0.init (List.map f₁.f l)
theorem Turing.TM0.Machine.map_respects E0 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] {Γ' : Type u_2} [inst_1 : Inhabited Γ'] {Λ : Type u_3} [inst_2 : Inhabited Λ]
{Λ' : Type u_4} [inst_3 : Inhabited Λ'] (M : Turing.TM0.Machine Γ Λ) (f₁ : Turing.PointedMap Γ Γ')
(f₂ : Turing.PointedMap Γ' Γ) (g₁ : Turing.PointedMap Λ Λ') (g₂ : Λ' → Λ) {S : Set Λ},
Turing.TM0.Supports M S →
Function.RightInverse f₁.f f₂.f →
(∀ q ∈ S, g₂ (g₁.f q) = q) →
StateTransition.Respects (Turing.TM0.step M) (Turing.TM0.step (M.map f₁ f₂ g₁.f g₂)) fun a b ↦
a.q ∈ S ∧ Turing.TM0.Cfg.map f₁ g₁.f a = b
inductive Turing.TM1.Stmt E1 #
Type u_1 → Type u_2 → Type u_3 → Type (max (max u_1 u_2) u_3)
The TM1 model is a simplification and extension of TM0
(Post-Turing model) in the direction of Wang B-machines. The machine's
internal state is extended with a (finite) store σ of variables
that may be accessed and updated at any time.
A machine is given by a Λ indexed set of procedures or functions.
Each function has a body which is a Stmt, which can either be a
move or write command, a branch (if statement based on the
current tape value), a load (set the variable value),
a goto (call another function), or halt. Note that here
most statements do not have labels; goto commands can only
go to a new function. All commands have access to the variable value
and current tape value.
ctor Turing.TM1.Stmt.move E0 #
{Γ : Type u_1} → {Λ : Type u_2} → {σ : Type u_3} → Turing.Dir → Turing.TM1.Stmt Γ Λ σ → Turing.TM1.Stmt Γ Λ σ
ctor Turing.TM1.Stmt.write E0 #
{Γ : Type u_1} → {Λ : Type u_2} → {σ : Type u_3} → (Γ → σ → Γ) → Turing.TM1.Stmt Γ Λ σ → Turing.TM1.Stmt Γ Λ σ
ctor Turing.TM1.Stmt.load E0 #
{Γ : Type u_1} → {Λ : Type u_2} → {σ : Type u_3} → (Γ → σ → σ) → Turing.TM1.Stmt Γ Λ σ → Turing.TM1.Stmt Γ Λ σ
ctor Turing.TM1.Stmt.branch E0 #
{Γ : Type u_1} →
{Λ : Type u_2} →
{σ : Type u_3} → (Γ → σ → Bool) → Turing.TM1.Stmt Γ Λ σ → Turing.TM1.Stmt Γ Λ σ → Turing.TM1.Stmt Γ Λ σ
ctor Turing.TM1.Stmt.goto E0 #
{Γ : Type u_1} → {Λ : Type u_2} → {σ : Type u_3} → (Γ → σ → Λ) → Turing.TM1.Stmt Γ Λ σ
ctor Turing.TM1.Stmt.halt E0 #
{Γ : Type u_1} → {Λ : Type u_2} → {σ : Type u_3} → Turing.TM1.Stmt Γ Λ σ
instance Turing.TM1.Stmt.inhabited E0 #
(Γ : Type u_1) → (Λ : Type u_2) → (σ : Type u_3) → Inhabited (Turing.TM1.Stmt Γ Λ σ)
structure Turing.TM1.Cfg E1 #
(Γ : Type u_1) → Type u_2 → Type u_3 → [Inhabited Γ] → Type (max (max u_1 u_2) u_3)
The configuration of a TM1 machine is given by the currently evaluating statement, the variable store value, and the tape.
ctor Turing.TM1.Cfg.mk E0 #
{Γ : Type u_1} →
{Λ : Type u_2} → {σ : Type u_3} → [inst : Inhabited Γ] → Option Λ → σ → Turing.Tape Γ → Turing.TM1.Cfg Γ Λ σ
abbrev Turing.TM1.Cfg.l E1 #
{Γ : Type u_1} → {Λ : Type u_2} → {σ : Type u_3} → [inst : Inhabited Γ] → Turing.TM1.Cfg Γ Λ σ → Option Λ
The statement (if any) which is currently evaluated
abbrev Turing.TM1.Cfg.var E1 #
{Γ : Type u_1} → {Λ : Type u_2} → {σ : Type u_3} → [inst : Inhabited Γ] → Turing.TM1.Cfg Γ Λ σ → σ
The current value of the variable store
abbrev Turing.TM1.Cfg.Tape E1 #
{Γ : Type u_1} → {Λ : Type u_2} → {σ : Type u_3} → [inst : Inhabited Γ] → Turing.TM1.Cfg Γ Λ σ → Turing.Tape Γ
The current state of the tape
instance Turing.TM1.Cfg.inhabited E0 #
(Γ : Type u_1) →
(Λ : Type u_2) → (σ : Type u_3) → [inst : Inhabited Γ] → [Inhabited σ] → Inhabited (Turing.TM1.Cfg Γ Λ σ)
def Turing.TM1.stepAux E0 #
{Γ : Type u_1} →
{Λ : Type u_2} →
{σ : Type u_3} → [inst : Inhabited Γ] → Turing.TM1.Stmt Γ Λ σ → σ → Turing.Tape Γ → Turing.TM1.Cfg Γ Λ σ
The semantics of TM1 evaluation.
def Turing.TM1.step E1 #
{Γ : Type u_1} →
{Λ : Type u_2} →
{σ : Type u_3} →
[inst : Inhabited Γ] → (Λ → Turing.TM1.Stmt Γ Λ σ) → Turing.TM1.Cfg Γ Λ σ → Option (Turing.TM1.Cfg Γ Λ σ)
The state transition function.
def Turing.TM1.SupportsStmt E1 #
{Γ : Type u_1} → {Λ : Type u_2} → {σ : Type u_3} → Finset Λ → Turing.TM1.Stmt Γ Λ σ → Prop
A set S of labels supports the statement q if all the goto
statements in q refer only to other functions in S.
def Turing.TM1.stmts₁ E1 #
{Γ : Type u_1} → {Λ : Type u_2} → {σ : Type u_3} → Turing.TM1.Stmt Γ Λ σ → Finset (Turing.TM1.Stmt Γ Λ σ)
The subterm closure of a statement.
theorem Turing.TM1.stmts₁_self E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} {q : Turing.TM1.Stmt Γ Λ σ}, q ∈ Turing.TM1.stmts₁ q
theorem Turing.TM1.stmts₁_trans E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} {q₁ q₂ : Turing.TM1.Stmt Γ Λ σ},
q₁ ∈ Turing.TM1.stmts₁ q₂ → Turing.TM1.stmts₁ q₁ ⊆ Turing.TM1.stmts₁ q₂
theorem Turing.TM1.stmts₁_supportsStmt_mono E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} {S : Finset Λ} {q₁ q₂ : Turing.TM1.Stmt Γ Λ σ},
q₁ ∈ Turing.TM1.stmts₁ q₂ → Turing.TM1.SupportsStmt S q₂ → Turing.TM1.SupportsStmt S q₁
def Turing.TM1.stmts E1 #
{Γ : Type u_1} →
{Λ : Type u_2} → {σ : Type u_3} → (Λ → Turing.TM1.Stmt Γ Λ σ) → Finset Λ → Finset (Option (Turing.TM1.Stmt Γ Λ σ))
The set of all statements in a Turing machine, plus one extra value none representing the
halt state. This is used in the TM1 to TM0 reduction.
theorem Turing.TM1.stmts_trans E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} {M : Λ → Turing.TM1.Stmt Γ Λ σ} {S : Finset Λ}
{q₁ q₂ : Turing.TM1.Stmt Γ Λ σ},
q₁ ∈ Turing.TM1.stmts₁ q₂ → some q₂ ∈ Turing.TM1.stmts M S → some q₁ ∈ Turing.TM1.stmts M S
def Turing.TM1.Supports E1 #
{Γ : Type u_1} → {Λ : Type u_2} → {σ : Type u_3} → [Inhabited Λ] → (Λ → Turing.TM1.Stmt Γ Λ σ) → Finset Λ → Prop
A set S of labels supports machine M if all the goto
statements in the functions in S refer only to other functions
in S.
theorem Turing.TM1.stmts_supportsStmt E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} [inst : Inhabited Λ] {M : Λ → Turing.TM1.Stmt Γ Λ σ} {S : Finset Λ}
{q : Turing.TM1.Stmt Γ Λ σ}, Turing.TM1.Supports M S → some q ∈ Turing.TM1.stmts M S → Turing.TM1.SupportsStmt S q
theorem Turing.TM1.step_supports E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} [inst : Inhabited Λ] [inst_1 : Inhabited Γ]
(M : Λ → Turing.TM1.Stmt Γ Λ σ) {S : Finset Λ},
Turing.TM1.Supports M S →
∀ {c c' : Turing.TM1.Cfg Γ Λ σ}, c' ∈ Turing.TM1.step M c → c.l ∈ Finset.insertNone S → c'.l ∈ Finset.insertNone S
def Turing.TM1.init E1 #
{Γ : Type u_1} →
{Λ : Type u_2} → {σ : Type u_3} → [Inhabited Λ] → [inst : Inhabited Γ] → [Inhabited σ] → List Γ → Turing.TM1.Cfg Γ Λ σ
The initial state, given a finite input that is placed on the tape starting at the TM head and going to the right.
def Turing.TM1.eval E1 #
{Γ : Type u_1} →
{Λ : Type u_2} →
{σ : Type u_3} →
[Inhabited Λ] →
[inst : Inhabited Γ] → [Inhabited σ] → (Λ → Turing.TM1.Stmt Γ Λ σ) → List Γ → Part (Turing.ListBlank Γ)
Evaluate a TM to completion, resulting in an output list on the tape (with an indeterminate number of blanks on the end).
def Turing.TM1to0.Λ' E1 #
{Γ : Type u_1} → {Λ : Type u_2} → {σ : Type u_3} → (Λ → Turing.TM1.Stmt Γ Λ σ) → Type (max (max (max u_3 u_2) u_1) u_3)
The base machine state space is a pair of an Option Stmt₁ representing the current program
to be executed, or none for the halt state, and a σ which is the local state (stored in the TM,
not the tape). Because there are an infinite number of programs, this state space is infinite, but
for a finitely supported TM1 machine and a finite type σ, only finitely many of these states are
reachable.
instance Turing.TM1to0.instInhabitedΛ' E0 #
{Γ : Type u_1} →
{Λ : Type u_2} →
[Inhabited Λ] → {σ : Type u_3} → [Inhabited σ] → (M : Λ → Turing.TM1.Stmt Γ Λ σ) → Inhabited (Turing.TM1to0.Λ' M)
def Turing.TM1to0.trAux E0 #
{Γ : Type u_1} →
{Λ : Type u_2} →
{σ : Type u_3} →
(M : Λ → Turing.TM1.Stmt Γ Λ σ) → Γ → Turing.TM1.Stmt Γ Λ σ → σ → Turing.TM1to0.Λ' M × Turing.TM0.Stmt Γ
The core TM1 → TM0 translation function. Here s is the current value on the tape, and the
Stmt₁ is the TM1 statement to translate, with local state v : σ. We evaluate all regular
instructions recursively until we reach either a move or write command, or a goto; in the
latter case we emit a dummy write s step and transition to the new target location.
def Turing.TM1to0.tr E1 #
{Γ : Type u_1} →
{Λ : Type u_2} →
[inst : Inhabited Λ] →
{σ : Type u_3} →
[inst_1 : Inhabited σ] → (M : Λ → Turing.TM1.Stmt Γ Λ σ) → Turing.TM0.Machine Γ (Turing.TM1to0.Λ' M)
The translated TM0 machine (given the TM1 machine input).
def Turing.TM1to0.trCfg E1 #
{Γ : Type u_1} →
{Λ : Type u_2} →
{σ : Type u_3} →
(M : Λ → Turing.TM1.Stmt Γ Λ σ) →
[inst : Inhabited Γ] → Turing.TM1.Cfg Γ Λ σ → Turing.TM0.Cfg Γ (Turing.TM1to0.Λ' M)
Translate configurations from TM1 to TM0.
theorem Turing.TM1to0.tr_respects E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} [inst : Inhabited Λ] {σ : Type u_3} [inst_1 : Inhabited σ]
(M : Λ → Turing.TM1.Stmt Γ Λ σ) [inst_2 : Inhabited Γ],
StateTransition.Respects (Turing.TM1.step M) (Turing.TM0.step (Turing.TM1to0.tr M)) fun c₁ c₂ ↦
Turing.TM1to0.trCfg M c₁ = c₂
theorem Turing.TM1to0.tr_eval E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} [inst : Inhabited Λ] {σ : Type u_3} [inst_1 : Inhabited σ]
(M : Λ → Turing.TM1.Stmt Γ Λ σ) [inst_2 : Inhabited Γ] (l : List Γ),
Turing.TM0.eval (Turing.TM1to0.tr M) l = Turing.TM1.eval M l
def Turing.TM1to0.trStmts E1 #
{Γ : Type u_1} →
{Λ : Type u_2} →
{σ : Type u_3} → (M : Λ → Turing.TM1.Stmt Γ Λ σ) → [Fintype σ] → Finset Λ → Finset (Turing.TM1to0.Λ' M)
Given a finite set of accessible Λ machine states, there is a finite set of accessible
machine states in the target (even though the type Λ' is infinite).
theorem Turing.TM1to0.tr_supports E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} [inst : Inhabited Λ] {σ : Type u_3} [inst_1 : Inhabited σ]
(M : Λ → Turing.TM1.Stmt Γ Λ σ) [inst_2 : Fintype σ] {S : Finset Λ},
Turing.TM1.Supports M S → Turing.TM0.Supports (Turing.TM1to0.tr M) ↑(Turing.TM1to0.trStmts M S)
theorem Turing.TM1to1.exists_enc_dec E1 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] [Finite Γ],
∃ n enc dec, enc default = List.Vector.replicate n false ∧ ∀ (a : Γ), dec (enc a) = a
inductive Turing.TM1to1.Λ' E1 #
Type u_1 → Type u_2 → Type u_3 → Type (max (max u_1 u_2) u_3)
The configuration state of the TM.
ctor Turing.TM1to1.Λ'.normal E0 #
{Γ : Type u_1} → {Λ : Type u_2} → {σ : Type u_3} → Λ → Turing.TM1to1.Λ' Γ Λ σ
ctor Turing.TM1to1.Λ'.write E0 #
{Γ : Type u_1} → {Λ : Type u_2} → {σ : Type u_3} → Γ → Turing.TM1.Stmt Γ Λ σ → Turing.TM1to1.Λ' Γ Λ σ
instance Turing.TM1to1.instInhabitedΛ' E0 #
{Γ : Type u_1} → {Λ : Type u_2} → {σ : Type u_3} → [Inhabited Λ] → Inhabited (Turing.TM1to1.Λ' Γ Λ σ)
def Turing.TM1to1.readAux E0 #
{Γ : Type u_1} →
{Λ : Type u_2} →
{σ : Type u_3} →
(n : ℕ) →
(List.Vector Bool n → Turing.TM1.Stmt Bool (Turing.TM1to1.Λ' Γ Λ σ) σ) →
Turing.TM1.Stmt Bool (Turing.TM1to1.Λ' Γ Λ σ) σ
Read a vector of length n from the tape.
def Turing.TM1to1.move E1 #
{Γ : Type u_1} →
{Λ : Type u_2} →
{σ : Type u_3} →
ℕ → Turing.Dir → Turing.TM1.Stmt Bool (Turing.TM1to1.Λ' Γ Λ σ) σ → Turing.TM1.Stmt Bool (Turing.TM1to1.Λ' Γ Λ σ) σ
A move left or right corresponds to n moves across the super-cell.
def Turing.TM1to1.read E1 #
{Γ : Type u_1} →
{Λ : Type u_2} →
{σ : Type u_3} →
{n : ℕ} →
(List.Vector Bool n → Γ) →
(Γ → Turing.TM1.Stmt Bool (Turing.TM1to1.Λ' Γ Λ σ) σ) → Turing.TM1.Stmt Bool (Turing.TM1to1.Λ' Γ Λ σ) σ
To read a symbol from the tape, we use readAux to traverse the symbol,
then return to the original position with n moves to the left.
def Turing.TM1to1.write E1 #
{Γ : Type u_1} →
{Λ : Type u_2} →
{σ : Type u_3} →
List Bool → Turing.TM1.Stmt Bool (Turing.TM1to1.Λ' Γ Λ σ) σ → Turing.TM1.Stmt Bool (Turing.TM1to1.Λ' Γ Λ σ) σ
Write a list of Bools on the tape.
def Turing.TM1to1.trNormal E1 #
{Γ : Type u_1} →
{Λ : Type u_2} →
{σ : Type u_3} →
{n : ℕ} → (List.Vector Bool n → Γ) → Turing.TM1.Stmt Γ Λ σ → Turing.TM1.Stmt Bool (Turing.TM1to1.Λ' Γ Λ σ) σ
Translate a normal instruction. For the write command, we use a goto indirection so that
we can access the current value of the tape.
theorem Turing.TM1to1.stepAux_move E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} {n : ℕ} (d : Turing.Dir)
(q : Turing.TM1.Stmt Bool (Turing.TM1to1.Λ' Γ Λ σ) σ) (v : σ) (T : Turing.Tape Bool),
Turing.TM1.stepAux (Turing.TM1to1.move n d q) v T = Turing.TM1.stepAux q v ((Turing.Tape.move d)^[n] T)
theorem Turing.TM1to1.supportsStmt_move E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} {n : ℕ} {S : Finset (Turing.TM1to1.Λ' Γ Λ σ)} {d : Turing.Dir}
{q : Turing.TM1.Stmt Bool (Turing.TM1to1.Λ' Γ Λ σ) σ},
Turing.TM1.SupportsStmt S (Turing.TM1to1.move n d q) = Turing.TM1.SupportsStmt S q
theorem Turing.TM1to1.supportsStmt_write E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} {S : Finset (Turing.TM1to1.Λ' Γ Λ σ)} {l : List Bool}
{q : Turing.TM1.Stmt Bool (Turing.TM1to1.Λ' Γ Λ σ) σ},
Turing.TM1.SupportsStmt S (Turing.TM1to1.write l q) = Turing.TM1.SupportsStmt S q
theorem Turing.TM1to1.supportsStmt_read E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} {n : ℕ} (dec : List.Vector Bool n → Γ)
{S : Finset (Turing.TM1to1.Λ' Γ Λ σ)} {f : Γ → Turing.TM1.Stmt Bool (Turing.TM1to1.Λ' Γ Λ σ) σ},
(∀ (a : Γ), Turing.TM1.SupportsStmt S (f a)) → Turing.TM1.SupportsStmt S (Turing.TM1to1.read dec f)
def Turing.TM1to1.trTape' E1 #
{Γ : Type u_1} →
{n : ℕ} →
{enc : Γ → List.Vector Bool n} →
[inst : Inhabited Γ] →
enc default = List.Vector.replicate n false → Turing.ListBlank Γ → Turing.ListBlank Γ → Turing.Tape Bool
The low level tape corresponding to the given tape over alphabet Γ.
def Turing.TM1to1.trTape E1 #
{Γ : Type u_1} →
{n : ℕ} →
{enc : Γ → List.Vector Bool n} →
[inst : Inhabited Γ] → enc default = List.Vector.replicate n false → Turing.Tape Γ → Turing.Tape Bool
The low level tape corresponding to the given tape over alphabet Γ.
theorem Turing.TM1to1.trTape_mk' E1 #
∀ {Γ : Type u_1} {n : ℕ} {enc : Γ → List.Vector Bool n} [inst : Inhabited Γ]
(enc0 : enc default = List.Vector.replicate n false) (L R : Turing.ListBlank Γ),
Turing.TM1to1.trTape enc0 (Turing.Tape.mk' L R) = Turing.TM1to1.trTape' enc0 L R
def Turing.TM1to1.tr E1 #
{Γ : Type u_1} →
{Λ : Type u_2} →
{σ : Type u_3} →
{n : ℕ} →
(Γ → List.Vector Bool n) →
(List.Vector Bool n → Γ) →
(Λ → Turing.TM1.Stmt Γ Λ σ) → Turing.TM1to1.Λ' Γ Λ σ → Turing.TM1.Stmt Bool (Turing.TM1to1.Λ' Γ Λ σ) σ
The top level program.
def Turing.TM1to1.trCfg E1 #
{Γ : Type u_1} →
{Λ : Type u_2} →
{σ : Type u_3} →
{n : ℕ} →
(enc : Γ → List.Vector Bool n) →
[inst : Inhabited Γ] →
enc default = List.Vector.replicate n false →
Turing.TM1.Cfg Γ Λ σ → Turing.TM1.Cfg Bool (Turing.TM1to1.Λ' Γ Λ σ) σ
The machine configuration translation.
theorem Turing.TM1to1.trTape'_move_left E1 #
∀ {Γ : Type u_1} {n : ℕ} {enc : Γ → List.Vector Bool n} [inst : Inhabited Γ]
(enc0 : enc default = List.Vector.replicate n false) (L R : Turing.ListBlank Γ),
(Turing.Tape.move Turing.Dir.left)^[n] (Turing.TM1to1.trTape' enc0 L R) =
Turing.TM1to1.trTape' enc0 L.tail (Turing.ListBlank.cons L.head R)
theorem Turing.TM1to1.trTape'_move_right E1 #
∀ {Γ : Type u_1} {n : ℕ} {enc : Γ → List.Vector Bool n} [inst : Inhabited Γ]
(enc0 : enc default = List.Vector.replicate n false) (L R : Turing.ListBlank Γ),
(Turing.Tape.move Turing.Dir.right)^[n] (Turing.TM1to1.trTape' enc0 L R) =
Turing.TM1to1.trTape' enc0 (Turing.ListBlank.cons R.head L) R.tail
theorem Turing.TM1to1.stepAux_write E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} {n : ℕ} {enc : Γ → List.Vector Bool n} [inst : Inhabited Γ]
(enc0 : enc default = List.Vector.replicate n false) (q : Turing.TM1.Stmt Bool (Turing.TM1to1.Λ' Γ Λ σ) σ) (v : σ)
(a b : Γ) (L R : Turing.ListBlank Γ),
Turing.TM1.stepAux (Turing.TM1to1.write (enc a).toList q) v
(Turing.TM1to1.trTape' enc0 L (Turing.ListBlank.cons b R)) =
Turing.TM1.stepAux q v (Turing.TM1to1.trTape' enc0 (Turing.ListBlank.cons a L) R)
theorem Turing.TM1to1.stepAux_read E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} {n : ℕ} {enc : Γ → List.Vector Bool n} (dec : List.Vector Bool n → Γ)
[inst : Inhabited Γ] (enc0 : enc default = List.Vector.replicate n false),
(∀ (a : Γ), dec (enc a) = a) →
∀ (f : Γ → Turing.TM1.Stmt Bool (Turing.TM1to1.Λ' Γ Λ σ) σ) (v : σ) (L R : Turing.ListBlank Γ),
Turing.TM1.stepAux (Turing.TM1to1.read dec f) v (Turing.TM1to1.trTape' enc0 L R) =
Turing.TM1.stepAux (f R.head) v (Turing.TM1to1.trTape' enc0 L R)
theorem Turing.TM1to1.tr_respects E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} {n : ℕ} {enc : Γ → List.Vector Bool n} (dec : List.Vector Bool n → Γ)
(M : Λ → Turing.TM1.Stmt Γ Λ σ) [inst : Inhabited Γ] {enc0 : enc default = List.Vector.replicate n false},
(∀ (a : Γ), dec (enc a) = a) →
StateTransition.Respects (Turing.TM1.step M) (Turing.TM1.step (Turing.TM1to1.tr enc dec M)) fun c₁ c₂ ↦
Turing.TM1to1.trCfg enc enc0 c₁ = c₂
def Turing.TM1to1.writes E1 #
{Γ : Type u_1} → {Λ : Type u_2} → {σ : Type u_3} → [Fintype Γ] → Turing.TM1.Stmt Γ Λ σ → Finset (Turing.TM1to1.Λ' Γ Λ σ)
The set of accessible Λ'.write machine states.
def Turing.TM1to1.trSupp E1 #
{Γ : Type u_1} →
{Λ : Type u_2} →
{σ : Type u_3} → (Λ → Turing.TM1.Stmt Γ Λ σ) → [Fintype Γ] → Finset Λ → Finset (Turing.TM1to1.Λ' Γ Λ σ)
The set of accessible machine states, assuming that the input machine is supported on S,
are the normal states embedded from S, plus all write states accessible from these states.
theorem Turing.TM1to1.tr_supports E1 #
∀ {Γ : Type u_1} {Λ : Type u_2} {σ : Type u_3} {n : ℕ} (enc : Γ → List.Vector Bool n) (dec : List.Vector Bool n → Γ)
(M : Λ → Turing.TM1.Stmt Γ Λ σ) [inst : Fintype Γ] [inst_1 : Inhabited Λ] {S : Finset Λ},
Turing.TM1.Supports M S → Turing.TM1.Supports (Turing.TM1to1.tr enc dec M) (Turing.TM1to1.trSupp M S)
inductive Turing.TM0to1.Λ' E1 #
Type u_1 → Type u_2 → Type (max u_1 u_2)
The machine states for a TM1 emulating a TM0 machine. States of the TM0 machine are embedded
as normal q states, but the actual operation is split into two parts, a jump to act s q
followed by the action and a jump to the next normal state.
ctor Turing.TM0to1.Λ'.normal E0 #
{Γ : Type u_1} → {Λ : Type u_2} → Λ → Turing.TM0to1.Λ' Γ Λ
ctor Turing.TM0to1.Λ'.act E0 #
{Γ : Type u_1} → {Λ : Type u_2} → Turing.TM0.Stmt Γ → Λ → Turing.TM0to1.Λ' Γ Λ
instance Turing.TM0to1.instInhabitedΛ' E0 #
{Γ : Type u_1} → {Λ : Type u_2} → [Inhabited Λ] → Inhabited (Turing.TM0to1.Λ' Γ Λ)
def Turing.TM0to1.tr E1 #
{Γ : Type u_1} →
{Λ : Type u_2} →
[inst : Inhabited Λ] → Turing.TM0.Machine Γ Λ → Turing.TM0to1.Λ' Γ Λ → Turing.TM1.Stmt Γ (Turing.TM0to1.Λ' Γ Λ) Unit
The program.
def Turing.TM0to1.trCfg E1 #
{Γ : Type u_1} →
[inst : Inhabited Γ] →
{Λ : Type u_2} →
[inst_1 : Inhabited Λ] →
Turing.TM0.Machine Γ Λ → Turing.TM0.Cfg Γ Λ → Turing.TM1.Cfg Γ (Turing.TM0to1.Λ' Γ Λ) Unit
The configuration translation.
theorem Turing.TM0to1.tr_respects E1 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] {Λ : Type u_2} [inst_1 : Inhabited Λ] (M : Turing.TM0.Machine Γ Λ),
StateTransition.Respects (Turing.TM0.step M) (Turing.TM1.step (Turing.TM0to1.tr M)) fun a b ↦
Turing.TM0to1.trCfg M a = b