The areas / V32. Logic, model theory and computability
Mathlib.Computability.TuringMachine.Tape
129 declarations. Mathlib docs · Source
abbrev Turing.Dir.ctorElimType E1 #
{motive : Turing.Dir → Sort u} → ℕ → Sort (max 1 u)
theorem Turing.Dir.ofNat_ctorIdx E1 #
∀ (x : Turing.Dir), Turing.Dir.ofNat x.ctorIdx = x
def Turing.instInhabitedDir.default E1 #
Turing.Dir
theorem Turing.Tape.nth.match_1.congr_eq_3 E1 #
∀ (motive : ℤ → Sort u_1) (x : ℤ) (h_1 : Unit → motive 0) (h_2 : (n : ℕ) → motive (Int.ofNat n.succ))
(h_3 : (n : ℕ) → motive (Int.negSucc n)) (n : ℕ),
x = Int.negSucc n →
(match x with
| 0 => h_1 ()
| Int.ofNat n.succ => h_2 n
| Int.negSucc n => h_3 n) ≍
h_3 n
def Turing.Dir.ctorIdx E1 #
Turing.Dir → ℕ
theorem Turing.Tape.move.match_1.congr_eq_1 E1 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (motive : Turing.Dir → Turing.Tape Γ → Sort u_2) (x : Turing.Dir)
(x_1 : Turing.Tape Γ)
(h_1 : (a : Γ) → (L R : Turing.ListBlank Γ) → motive Turing.Dir.left { head := a, left := L, right := R })
(h_2 : (a : Γ) → (L R : Turing.ListBlank Γ) → motive Turing.Dir.right { head := a, left := L, right := R }) (a : Γ)
(L R : Turing.ListBlank Γ),
x = Turing.Dir.left →
x_1 = { head := a, left := L, right := R } →
(match x, x_1 with
| Turing.Dir.left, { head := a, left := L, right := R } => h_1 a L R
| Turing.Dir.right, { head := a, left := L, right := R } => h_2 a L R) ≍
h_1 a L R
theorem Turing.ListBlank.append.match_1.congr_eq_2 E1 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (motive : List Γ → Turing.ListBlank Γ → Sort u_2) (x : List Γ)
(x_1 : Turing.ListBlank Γ) (h_1 : (L : Turing.ListBlank Γ) → motive [] L)
(h_2 : (a : Γ) → (l : List Γ) → (L : Turing.ListBlank Γ) → motive (a :: l) L) (a : Γ) (l : List Γ)
(L : Turing.ListBlank Γ),
x = a :: l →
x_1 = L →
(match x, x_1 with
| [], L => h_1 L
| a :: l, L => h_2 a l L) ≍
h_2 a l L
abbrev Turing.Dir.ofNat E1 #
ℕ → Turing.Dir
theorem Turing.Tape.nth.match_1.congr_eq_1 E1 #
∀ (motive : ℤ → Sort u_1) (x : ℤ) (h_1 : Unit → motive 0) (h_2 : (n : ℕ) → motive (Int.ofNat n.succ))
(h_3 : (n : ℕ) → motive (Int.negSucc n)),
x = 0 →
(match x with
| 0 => h_1 ()
| Int.ofNat n.succ => h_2 n
| Int.negSucc n => h_3 n) ≍
h_1 ()
theorem Turing.ListBlank.flatMap.congr_simp E1 #
∀ {Γ : Type u_1} {Γ' : Type u_2} [inst : Inhabited Γ] [inst_1 : Inhabited Γ'] (l l_1 : Turing.ListBlank Γ),
l = l_1 →
∀ (f f_1 : Γ → List Γ') (e_f : f = f_1) (hf : ∃ n, f default = List.replicate n default),
l.flatMap f hf = l_1.flatMap f_1 ⋯
theorem Turing.ListBlank.modifyNth.match_1.congr_eq_2 E1 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (motive : ℕ → Turing.ListBlank Γ → Sort u_2) (x : ℕ) (x_1 : Turing.ListBlank Γ)
(h_1 : (L : Turing.ListBlank Γ) → motive 0 L) (h_2 : (n : ℕ) → (L : Turing.ListBlank Γ) → motive n.succ L) (n : ℕ)
(L : Turing.ListBlank Γ),
x = n.succ →
x_1 = L →
(match x, x_1 with
| 0, L => h_1 L
| n.succ, L => h_2 n L) ≍
h_2 n L
theorem Turing.Tape.mk.injEq E0 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (head : Γ) (left right : Turing.ListBlank Γ) (head_1 : Γ)
(left_1 right_1 : Turing.ListBlank Γ),
({ head := head, left := left, right := right } = { head := head_1, left := left_1, right := right_1 }) =
(head = head_1 ∧ left = left_1 ∧ right = right_1)
theorem Turing.PointedMap.mk.injEq E0 #
∀ {Γ : Type u} {Γ' : Type v} [inst : Inhabited Γ] [inst_1 : Inhabited Γ'] (f : Γ → Γ') (map_pt' : f default = default)
(f_1 : Γ → Γ') (map_pt'_1 : f_1 default = default),
({ f := f, map_pt' := map_pt' } = { f := f_1, map_pt' := map_pt'_1 }) = (f = f_1)
theorem Turing.ListBlank.modifyNth.match_1.congr_eq_1 E1 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (motive : ℕ → Turing.ListBlank Γ → Sort u_2) (x : ℕ) (x_1 : Turing.ListBlank Γ)
(h_1 : (L : Turing.ListBlank Γ) → motive 0 L) (h_2 : (n : ℕ) → (L : Turing.ListBlank Γ) → motive n.succ L)
(L : Turing.ListBlank Γ),
x = 0 →
x_1 = L →
(match x, x_1 with
| 0, L => h_1 L
| n.succ, L => h_2 n L) ≍
h_1 L
def Turing.PointedMap.ctorIdx E1 #
{Γ : Type u} → {Γ' : Type v} → {inst : Inhabited Γ} → {inst_1 : Inhabited Γ'} → Turing.PointedMap Γ Γ' → ℕ
theorem Turing.PointedMap.mk.inj E1 #
∀ {Γ : Type u} {Γ' : Type v} {inst : Inhabited Γ} {inst_1 : Inhabited Γ'} {f : Γ → Γ'} {map_pt' : f default = default}
{f_1 : Γ → Γ'} {map_pt'_1 : f_1 default = default},
{ f := f, map_pt' := map_pt' } = { f := f_1, map_pt' := map_pt'_1 } → f = f_1
theorem Turing.ListBlank.append.match_1.congr_eq_1 E1 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (motive : List Γ → Turing.ListBlank Γ → Sort u_2) (x : List Γ)
(x_1 : Turing.ListBlank Γ) (h_1 : (L : Turing.ListBlank Γ) → motive [] L)
(h_2 : (a : Γ) → (l : List Γ) → (L : Turing.ListBlank Γ) → motive (a :: l) L) (L : Turing.ListBlank Γ),
x = [] →
x_1 = L →
(match x, x_1 with
| [], L => h_1 L
| a :: l, L => h_2 a l L) ≍
h_1 L
theorem Turing.Tape.move.match_1.congr_eq_2 E1 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (motive : Turing.Dir → Turing.Tape Γ → Sort u_2) (x : Turing.Dir)
(x_1 : Turing.Tape Γ)
(h_1 : (a : Γ) → (L R : Turing.ListBlank Γ) → motive Turing.Dir.left { head := a, left := L, right := R })
(h_2 : (a : Γ) → (L R : Turing.ListBlank Γ) → motive Turing.Dir.right { head := a, left := L, right := R }) (a : Γ)
(L R : Turing.ListBlank Γ),
x = Turing.Dir.right →
x_1 = { head := a, left := L, right := R } →
(match x, x_1 with
| Turing.Dir.left, { head := a, left := L, right := R } => h_1 a L R
| Turing.Dir.right, { head := a, left := L, right := R } => h_2 a L R) ≍
h_2 a L R
theorem Turing.Tape.nth.match_1.congr_eq_2 E1 #
∀ (motive : ℤ → Sort u_1) (x : ℤ) (h_1 : Unit → motive 0) (h_2 : (n : ℕ) → motive (Int.ofNat n.succ))
(h_3 : (n : ℕ) → motive (Int.negSucc n)) (n : ℕ),
x = Int.ofNat n.succ →
(match x with
| 0 => h_1 ()
| Int.ofNat n.succ => h_2 n
| Int.negSucc n => h_3 n) ≍
h_2 n
def Turing.Tape.ctorIdx E1 #
{Γ : Type u_1} → {inst : Inhabited Γ} → Turing.Tape Γ → ℕ
theorem Turing.Tape.mk.inj E1 #
∀ {Γ : Type u_1} {inst : Inhabited Γ} {head : Γ} {left right : Turing.ListBlank Γ} {head_1 : Γ}
{left_1 right_1 : Turing.ListBlank Γ},
{ head := head, left := left, right := right } = { head := head_1, left := left_1, right := right_1 } →
head = head_1 ∧ left = left_1 ∧ right = right_1
def Turing.BlankExtends E1 #
{Γ : Type u_1} → [Inhabited Γ] → List Γ → List Γ → Prop
The BlankExtends partial order holds of l₁ and l₂ if l₂ is obtained by adding
blanks (default : Γ) to the end of l₁.
theorem Turing.BlankExtends.refl E1 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (l : List Γ), Turing.BlankExtends l l
theorem Turing.BlankExtends.trans E1 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] {l₁ l₂ l₃ : List Γ},
Turing.BlankExtends l₁ l₂ → Turing.BlankExtends l₂ l₃ → Turing.BlankExtends l₁ l₃
theorem Turing.BlankExtends.below_of_le E1 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] {l l₁ l₂ : List Γ},
Turing.BlankExtends l l₁ → Turing.BlankExtends l l₂ → l₁.length ≤ l₂.length → Turing.BlankExtends l₁ l₂
def Turing.BlankExtends.above E1 #
{Γ : Type u_1} →
[inst : Inhabited Γ] →
{l l₁ l₂ : List Γ} →
Turing.BlankExtends l l₁ →
Turing.BlankExtends l l₂ → { l' // Turing.BlankExtends l₁ l' ∧ Turing.BlankExtends l₂ l' }
Any two extensions by blank l₁,l₂ of l have a common join (which can be taken to be the
longer of l₁ and l₂).
theorem Turing.BlankExtends.above_of_le E1 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] {l l₁ l₂ : List Γ},
Turing.BlankExtends l₁ l → Turing.BlankExtends l₂ l → l₁.length ≤ l₂.length → Turing.BlankExtends l₁ l₂
def Turing.BlankRel E1 #
{Γ : Type u_1} → [Inhabited Γ] → List Γ → List Γ → Prop
BlankRel is the symmetric closure of BlankExtends, turning it into an equivalence
relation. Two lists are related by BlankRel if one extends the other by blanks.
theorem Turing.BlankRel.refl E1 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (l : List Γ), Turing.BlankRel l l
theorem Turing.BlankRel.symm E1 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] {l₁ l₂ : List Γ}, Turing.BlankRel l₁ l₂ → Turing.BlankRel l₂ l₁
theorem Turing.BlankRel.trans E1 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] {l₁ l₂ l₃ : List Γ},
Turing.BlankRel l₁ l₂ → Turing.BlankRel l₂ l₃ → Turing.BlankRel l₁ l₃
def Turing.BlankRel.above E1 #
{Γ : Type u_1} →
[inst : Inhabited Γ] →
{l₁ l₂ : List Γ} → Turing.BlankRel l₁ l₂ → { l // Turing.BlankExtends l₁ l ∧ Turing.BlankExtends l₂ l }
Given two BlankRel lists, there exists (constructively) a common join.
theorem Turing.BlankRel.equivalence E1 #
∀ (Γ : Type u_1) [inst : Inhabited Γ], Equivalence Turing.BlankRel
def Turing.BlankRel.setoid E1 #
(Γ : Type u_1) → [Inhabited Γ] → Setoid (List Γ)
Construct a setoid instance for BlankRel.
def Turing.ListBlank E1 #
(Γ : Type u_1) → [Inhabited Γ] → Type u_1
A ListBlank Γ is a quotient of List Γ by extension by blanks at the end. This is used to
represent half-tapes of a Turing machine, so that we can pretend that the list continues
infinitely with blanks.
instance Turing.ListBlank.inhabited E0 #
{Γ : Type u_1} → [inst : Inhabited Γ] → Inhabited (Turing.ListBlank Γ)
instance Turing.ListBlank.hasEmptyc E0 #
{Γ : Type u_1} → [inst : Inhabited Γ] → EmptyCollection (Turing.ListBlank Γ)
abbrev Turing.ListBlank.liftOn E1 #
{Γ : Type u_1} →
[inst : Inhabited Γ] →
{α : Sort u_2} → Turing.ListBlank Γ → (f : List Γ → α) → (∀ (a b : List Γ), Turing.BlankExtends a b → f a = f b) → α
A modified version of Quotient.liftOn' specialized for ListBlank, with the stronger
precondition BlankExtends instead of BlankRel.
def Turing.ListBlank.mk E1 #
{Γ : Type u_1} → [inst : Inhabited Γ] → List Γ → Turing.ListBlank Γ
The quotient map turning a List into a ListBlank.
theorem Turing.ListBlank.induction_on E1 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] {p : Turing.ListBlank Γ → Prop} (q : Turing.ListBlank Γ),
(∀ (a : List Γ), p (Turing.ListBlank.mk a)) → p q
def Turing.ListBlank.head E1 #
{Γ : Type u_1} → [inst : Inhabited Γ] → Turing.ListBlank Γ → Γ
The head of a ListBlank is well defined.
theorem Turing.ListBlank.head_mk E0 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (l : List Γ), (Turing.ListBlank.mk l).head = l.headI
def Turing.ListBlank.tail E1 #
{Γ : Type u_1} → [inst : Inhabited Γ] → Turing.ListBlank Γ → Turing.ListBlank Γ
The tail of a ListBlank is well defined (up to the tail of blanks).
theorem Turing.ListBlank.tail_mk E0 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (l : List Γ), (Turing.ListBlank.mk l).tail = Turing.ListBlank.mk l.tail
def Turing.ListBlank.cons E1 #
{Γ : Type u_1} → [inst : Inhabited Γ] → Γ → Turing.ListBlank Γ → Turing.ListBlank Γ
We can cons an element onto a ListBlank.
theorem Turing.ListBlank.cons_mk E0 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (a : Γ) (l : List Γ),
Turing.ListBlank.cons a (Turing.ListBlank.mk l) = Turing.ListBlank.mk (a :: l)
theorem Turing.ListBlank.head_cons E0 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (a : Γ) (l : Turing.ListBlank Γ), (Turing.ListBlank.cons a l).head = a
theorem Turing.ListBlank.tail_cons E0 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (a : Γ) (l : Turing.ListBlank Γ), (Turing.ListBlank.cons a l).tail = l
theorem Turing.ListBlank.cons_head_tail E0 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (l : Turing.ListBlank Γ), Turing.ListBlank.cons l.head l.tail = l
The cons and head/tail functions are mutually inverse, unlike in the case of List where
this only holds for nonempty lists.
theorem Turing.ListBlank.exists_cons E1 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (l : Turing.ListBlank Γ), ∃ a l', l = Turing.ListBlank.cons a l'
The cons and head/tail functions are mutually inverse, unlike in the case of List where
this only holds for nonempty lists.
def Turing.ListBlank.nth E1 #
{Γ : Type u_1} → [inst : Inhabited Γ] → Turing.ListBlank Γ → ℕ → Γ
The n-th element of a ListBlank is well defined for all n : ℕ, unlike in a List.
theorem Turing.ListBlank.nth_mk E0 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (l : List Γ) (n : ℕ), (Turing.ListBlank.mk l).nth n = l.getI n
theorem Turing.ListBlank.nth_zero E0 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (l : Turing.ListBlank Γ), l.nth 0 = l.head
theorem Turing.ListBlank.nth_succ E0 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (l : Turing.ListBlank Γ) (n : ℕ), l.nth (n + 1) = l.tail.nth n
theorem Turing.ListBlank.ext_iff E0 #
∀ {Γ : Type u_1} [i : Inhabited Γ] {L₁ L₂ : Turing.ListBlank Γ}, L₁ = L₂ ↔ ∀ (i_1 : ℕ), L₁.nth i_1 = L₂.nth i_1
theorem Turing.ListBlank.ext E1 #
∀ {Γ : Type u_1} [i : Inhabited Γ] {L₁ L₂ : Turing.ListBlank Γ}, (∀ (i_1 : ℕ), L₁.nth i_1 = L₂.nth i_1) → L₁ = L₂
def Turing.ListBlank.modifyNth E1 #
{Γ : Type u_1} → [inst : Inhabited Γ] → (Γ → Γ) → ℕ → Turing.ListBlank Γ → Turing.ListBlank Γ
Apply a function to a value stored at the nth position of the list.
theorem Turing.ListBlank.nth_modifyNth E1 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (f : Γ → Γ) (n i : ℕ) (L : Turing.ListBlank Γ),
(Turing.ListBlank.modifyNth f n L).nth i = if i = n then f (L.nth i) else L.nth i
structure Turing.PointedMap E1 #
(Γ : Type u) → (Γ' : Type v) → [Inhabited Γ] → [Inhabited Γ'] → Type (max u v)
A pointed map of Inhabited types is a map that sends one default value to the other.
ctor Turing.PointedMap.mk E0 #
{Γ : Type u} →
{Γ' : Type v} →
[inst : Inhabited Γ] → [inst_1 : Inhabited Γ'] → (f : Γ → Γ') → f default = default → Turing.PointedMap Γ Γ'
abbrev Turing.PointedMap.f E1 #
{Γ : Type u} → {Γ' : Type v} → [inst : Inhabited Γ] → [inst_1 : Inhabited Γ'] → Turing.PointedMap Γ Γ' → Γ → Γ'
The map underlying this instance.
theorem Turing.PointedMap.map_pt' E0 #
∀ {Γ : Type u} {Γ' : Type v} [inst : Inhabited Γ] [inst_1 : Inhabited Γ'] (self : Turing.PointedMap Γ Γ'),
self.f default = default
instance Turing.instInhabitedPointedMap E0 #
{Γ : Type u_1} → {Γ' : Type u_2} → [inst : Inhabited Γ] → [inst_1 : Inhabited Γ'] → Inhabited (Turing.PointedMap Γ Γ')
instance Turing.instCoeFunPointedMapForall E0 #
{Γ : Type u_1} →
{Γ' : Type u_2} → [inst : Inhabited Γ] → [inst_1 : Inhabited Γ'] → CoeFun (Turing.PointedMap Γ Γ') fun x ↦ Γ → Γ'
theorem Turing.PointedMap.mk_val E0 #
∀ {Γ : Type u_1} {Γ' : Type u_2} [inst : Inhabited Γ] [inst_1 : Inhabited Γ'] (f : Γ → Γ') (pt : f default = default),
{ f := f, map_pt' := pt }.f = f
theorem Turing.PointedMap.map_pt E0 #
∀ {Γ : Type u_1} {Γ' : Type u_2} [inst : Inhabited Γ] [inst_1 : Inhabited Γ'] (f : Turing.PointedMap Γ Γ'),
f.f default = default
theorem Turing.PointedMap.headI_map E0 #
∀ {Γ : Type u_1} {Γ' : Type u_2} [inst : Inhabited Γ] [inst_1 : Inhabited Γ'] (f : Turing.PointedMap Γ Γ') (l : List Γ),
(List.map f.f l).headI = f.f l.headI
def Turing.ListBlank.map E1 #
{Γ : Type u_1} →
{Γ' : Type u_2} →
[inst : Inhabited Γ] → [inst_1 : Inhabited Γ'] → Turing.PointedMap Γ Γ' → Turing.ListBlank Γ → Turing.ListBlank Γ'
The map function on lists is well defined on ListBlanks provided that the map is
pointed.
theorem Turing.ListBlank.map_mk E0 #
∀ {Γ : Type u_1} {Γ' : Type u_2} [inst : Inhabited Γ] [inst_1 : Inhabited Γ'] (f : Turing.PointedMap Γ Γ') (l : List Γ),
Turing.ListBlank.map f (Turing.ListBlank.mk l) = Turing.ListBlank.mk (List.map f.f l)
theorem Turing.ListBlank.head_map E0 #
∀ {Γ : Type u_1} {Γ' : Type u_2} [inst : Inhabited Γ] [inst_1 : Inhabited Γ'] (f : Turing.PointedMap Γ Γ')
(l : Turing.ListBlank Γ), (Turing.ListBlank.map f l).head = f.f l.head
theorem Turing.ListBlank.tail_map E0 #
∀ {Γ : Type u_1} {Γ' : Type u_2} [inst : Inhabited Γ] [inst_1 : Inhabited Γ'] (f : Turing.PointedMap Γ Γ')
(l : Turing.ListBlank Γ), (Turing.ListBlank.map f l).tail = Turing.ListBlank.map f l.tail
theorem Turing.ListBlank.map_cons E0 #
∀ {Γ : Type u_1} {Γ' : Type u_2} [inst : Inhabited Γ] [inst_1 : Inhabited Γ'] (f : Turing.PointedMap Γ Γ')
(l : Turing.ListBlank Γ) (a : Γ),
Turing.ListBlank.map f (Turing.ListBlank.cons a l) = Turing.ListBlank.cons (f.f a) (Turing.ListBlank.map f l)
theorem Turing.ListBlank.nth_map E0 #
∀ {Γ : Type u_1} {Γ' : Type u_2} [inst : Inhabited Γ] [inst_1 : Inhabited Γ'] (f : Turing.PointedMap Γ Γ')
(l : Turing.ListBlank Γ) (n : ℕ), (Turing.ListBlank.map f l).nth n = f.f (l.nth n)
def Turing.proj E1 #
{ι : Type u_1} →
{Γ : ι → Type u_2} → [inst : (i : ι) → Inhabited (Γ i)] → (i : ι) → Turing.PointedMap ((i : ι) → Γ i) (Γ i)
The i-th projection as a pointed map.
theorem Turing.proj_map_nth E1 #
∀ {ι : Type u_1} {Γ : ι → Type u_2} [inst : (i : ι) → Inhabited (Γ i)] (i : ι) (L : Turing.ListBlank ((i : ι) → Γ i))
(n : ℕ), (Turing.ListBlank.map (Turing.proj i) L).nth n = L.nth n i
theorem Turing.ListBlank.map_modifyNth E0 #
∀ {Γ : Type u_1} {Γ' : Type u_2} [inst : Inhabited Γ] [inst_1 : Inhabited Γ'] (F : Turing.PointedMap Γ Γ') (f : Γ → Γ)
(f' : Γ' → Γ'),
(∀ (x : Γ), F.f (f x) = f' (F.f x)) →
∀ (n : ℕ) (L : Turing.ListBlank Γ),
Turing.ListBlank.map F (Turing.ListBlank.modifyNth f n L) =
Turing.ListBlank.modifyNth f' n (Turing.ListBlank.map F L)
def Turing.ListBlank.append E1 #
{Γ : Type u_1} → [inst : Inhabited Γ] → List Γ → Turing.ListBlank Γ → Turing.ListBlank Γ
Append a list on the left side of a ListBlank.
theorem Turing.ListBlank.append_mk E0 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (l₁ l₂ : List Γ),
Turing.ListBlank.append l₁ (Turing.ListBlank.mk l₂) = Turing.ListBlank.mk (l₁ ++ l₂)
theorem Turing.ListBlank.append_assoc E1 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (l₁ l₂ : List Γ) (l₃ : Turing.ListBlank Γ),
Turing.ListBlank.append (l₁ ++ l₂) l₃ = Turing.ListBlank.append l₁ (Turing.ListBlank.append l₂ l₃)
def Turing.ListBlank.flatMap E1 #
{Γ : Type u_1} →
{Γ' : Type u_2} →
[inst : Inhabited Γ] →
[inst_1 : Inhabited Γ'] →
Turing.ListBlank Γ → (f : Γ → List Γ') → (∃ n, f default = List.replicate n default) → Turing.ListBlank Γ'
The flatMap function on lists is well defined on ListBlanks provided that the default
element is sent to a sequence of default elements.
theorem Turing.ListBlank.flatMap_mk E0 #
∀ {Γ : Type u_1} {Γ' : Type u_2} [inst : Inhabited Γ] [inst_1 : Inhabited Γ'] (l : List Γ) (f : Γ → List Γ')
(hf : ∃ n, f default = List.replicate n default),
(Turing.ListBlank.mk l).flatMap f hf = Turing.ListBlank.mk (List.flatMap f l)
theorem Turing.ListBlank.cons_flatMap E0 #
∀ {Γ : Type u_1} {Γ' : Type u_2} [inst : Inhabited Γ] [inst_1 : Inhabited Γ'] (a : Γ) (l : Turing.ListBlank Γ)
(f : Γ → List Γ') (hf : ∃ n, f default = List.replicate n default),
(Turing.ListBlank.cons a l).flatMap f hf = Turing.ListBlank.append (f a) (l.flatMap f hf)
structure Turing.Tape E1 #
(Γ : Type u_1) → [Inhabited Γ] → Type u_1
The tape of a Turing machine is composed of a head element (which we imagine to be the
current position of the head), together with two ListBlanks denoting the portions of the tape
going off to the left and right. When the Turing machine moves right, an element is pulled from the
right side and becomes the new head, while the head element is consed onto the left side.
ctor Turing.Tape.mk E0 #
{Γ : Type u_1} → [inst : Inhabited Γ] → Γ → Turing.ListBlank Γ → Turing.ListBlank Γ → Turing.Tape Γ
abbrev Turing.Tape.head E1 #
{Γ : Type u_1} → [inst : Inhabited Γ] → Turing.Tape Γ → Γ
The current position of the head.
abbrev Turing.Tape.left E1 #
{Γ : Type u_1} → [inst : Inhabited Γ] → Turing.Tape Γ → Turing.ListBlank Γ
The portion of the tape going off to the left.
abbrev Turing.Tape.right E1 #
{Γ : Type u_1} → [inst : Inhabited Γ] → Turing.Tape Γ → Turing.ListBlank Γ
The portion of the tape going off to the right.
instance Turing.Tape.inhabited E0 #
{Γ : Type u_1} → [inst : Inhabited Γ] → Inhabited (Turing.Tape Γ)
inductive Turing.Dir E1 #
Type
A direction for the Turing machine move command, either
left or right.
ctor Turing.Dir.left E0 #
Turing.Dir
ctor Turing.Dir.right E0 #
Turing.Dir
instance Turing.instInhabitedDir E0 #
Inhabited Turing.Dir
instance Turing.instDecidableEqDir E0 #
DecidableEq Turing.Dir
def Turing.Tape.left₀ E1 #
{Γ : Type u_1} → [inst : Inhabited Γ] → Turing.Tape Γ → Turing.ListBlank Γ
The "inclusive" left side of the tape, including both left and head.
def Turing.Tape.right₀ E1 #
{Γ : Type u_1} → [inst : Inhabited Γ] → Turing.Tape Γ → Turing.ListBlank Γ
The "inclusive" right side of the tape, including both right and head.
def Turing.Tape.move E1 #
{Γ : Type u_1} → [inst : Inhabited Γ] → Turing.Dir → Turing.Tape Γ → Turing.Tape Γ
Move the tape in response to a motion of the Turing machine. Note that T.move Dir.left makes
T.left smaller; the Turing machine is moving left and the tape is moving right.
theorem Turing.Tape.move_left_right E0 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (T : Turing.Tape Γ),
Turing.Tape.move Turing.Dir.right (Turing.Tape.move Turing.Dir.left T) = T
theorem Turing.Tape.move_right_left E0 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (T : Turing.Tape Γ),
Turing.Tape.move Turing.Dir.left (Turing.Tape.move Turing.Dir.right T) = T
def Turing.Tape.mk' E1 #
{Γ : Type u_1} → [inst : Inhabited Γ] → Turing.ListBlank Γ → Turing.ListBlank Γ → Turing.Tape Γ
Construct a tape from a left side and an inclusive right side.
theorem Turing.Tape.mk'_left E0 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (L R : Turing.ListBlank Γ), (Turing.Tape.mk' L R).left = L
theorem Turing.Tape.mk'_head E0 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (L R : Turing.ListBlank Γ), (Turing.Tape.mk' L R).head = R.head
theorem Turing.Tape.mk'_right E0 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (L R : Turing.ListBlank Γ), (Turing.Tape.mk' L R).right = R.tail
theorem Turing.Tape.mk'_right₀ E0 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (L R : Turing.ListBlank Γ), (Turing.Tape.mk' L R).right₀ = R
theorem Turing.Tape.mk'_left_right₀ E0 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (T : Turing.Tape Γ), Turing.Tape.mk' T.left T.right₀ = T
theorem Turing.Tape.exists_mk' E1 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (T : Turing.Tape Γ), ∃ L R, T = Turing.Tape.mk' L R
theorem Turing.Tape.move_left_mk' E0 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (L R : Turing.ListBlank Γ),
Turing.Tape.move Turing.Dir.left (Turing.Tape.mk' L R) = Turing.Tape.mk' L.tail (Turing.ListBlank.cons L.head R)
theorem Turing.Tape.move_right_mk' E0 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (L R : Turing.ListBlank Γ),
Turing.Tape.move Turing.Dir.right (Turing.Tape.mk' L R) = Turing.Tape.mk' (Turing.ListBlank.cons R.head L) R.tail
def Turing.Tape.mk₂ E1 #
{Γ : Type u_1} → [inst : Inhabited Γ] → List Γ → List Γ → Turing.Tape Γ
Construct a tape from a left side and an inclusive right side.
def Turing.Tape.mk₁ E1 #
{Γ : Type u_1} → [inst : Inhabited Γ] → List Γ → Turing.Tape Γ
Construct a tape from a list, with the head of the list at the TM head and the rest going to the right.
def Turing.Tape.nth E1 #
{Γ : Type u_1} → [inst : Inhabited Γ] → Turing.Tape Γ → ℤ → Γ
The nth function of a tape is integer-valued, with index 0 being the head, negative indexes
on the left and positive indexes on the right. (Picture a number line.)
theorem Turing.Tape.nth_zero E0 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (T : Turing.Tape Γ), T.nth 0 = T.head
theorem Turing.Tape.right₀_nth E1 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (T : Turing.Tape Γ) (n : ℕ), T.right₀.nth n = T.nth ↑n
theorem Turing.Tape.mk'_nth_nat E0 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (L R : Turing.ListBlank Γ) (n : ℕ), (Turing.Tape.mk' L R).nth ↑n = R.nth n
theorem Turing.Tape.move_left_nth E0 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (T : Turing.Tape Γ) (i : ℤ),
(Turing.Tape.move Turing.Dir.left T).nth i = T.nth (i - 1)
theorem Turing.Tape.move_right_nth E0 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (T : Turing.Tape Γ) (i : ℤ),
(Turing.Tape.move Turing.Dir.right T).nth i = T.nth (i + 1)
theorem Turing.Tape.move_right_n_head E0 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (T : Turing.Tape Γ) (i : ℕ),
((Turing.Tape.move Turing.Dir.right)^[i] T).head = T.nth ↑i
def Turing.Tape.write E1 #
{Γ : Type u_1} → [inst : Inhabited Γ] → Γ → Turing.Tape Γ → Turing.Tape Γ
Replace the current value of the head on the tape.
theorem Turing.Tape.write_self E0 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (T : Turing.Tape Γ), Turing.Tape.write T.head T = T
theorem Turing.Tape.write_nth E0 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (b : Γ) (T : Turing.Tape Γ) {i : ℤ},
(Turing.Tape.write b T).nth i = if i = 0 then b else T.nth i
theorem Turing.Tape.write_mk E0 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (a b : Γ) (L R : Turing.ListBlank Γ),
Turing.Tape.write b { head := a, left := L, right := R } = { head := b, left := L, right := R }
theorem Turing.Tape.write_mk' E0 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (b : Γ) (L R : Turing.ListBlank Γ),
Turing.Tape.write b (Turing.Tape.mk' L R) = Turing.Tape.mk' L (Turing.ListBlank.cons b R.tail)
def Turing.Tape.map E1 #
{Γ : Type u_1} →
{Γ' : Type u_2} →
[inst : Inhabited Γ] → [inst_1 : Inhabited Γ'] → Turing.PointedMap Γ Γ' → Turing.Tape Γ → Turing.Tape Γ'
Apply a pointed map to a tape to change the alphabet.
theorem Turing.Tape.map_fst E0 #
∀ {Γ : Type u_1} {Γ' : Type u_2} [inst : Inhabited Γ] [inst_1 : Inhabited Γ'] (f : Turing.PointedMap Γ Γ')
(T : Turing.Tape Γ), (Turing.Tape.map f T).head = f.f T.head
theorem Turing.Tape.map_write E0 #
∀ {Γ : Type u_1} {Γ' : Type u_2} [inst : Inhabited Γ] [inst_1 : Inhabited Γ'] (f : Turing.PointedMap Γ Γ') (b : Γ)
(T : Turing.Tape Γ), Turing.Tape.map f (Turing.Tape.write b T) = Turing.Tape.write (f.f b) (Turing.Tape.map f T)
theorem Turing.Tape.write_move_right_n E0 #
∀ {Γ : Type u_1} [inst : Inhabited Γ] (f : Γ → Γ) (L R : Turing.ListBlank Γ) (n : ℕ),
Turing.Tape.write (f (R.nth n)) ((Turing.Tape.move Turing.Dir.right)^[n] (Turing.Tape.mk' L R)) =
(Turing.Tape.move Turing.Dir.right)^[n] (Turing.Tape.mk' L (Turing.ListBlank.modifyNth f n R))
theorem Turing.Tape.map_move E0 #
∀ {Γ : Type u_1} {Γ' : Type u_2} [inst : Inhabited Γ] [inst_1 : Inhabited Γ'] (f : Turing.PointedMap Γ Γ')
(T : Turing.Tape Γ) (d : Turing.Dir),
Turing.Tape.map f (Turing.Tape.move d T) = Turing.Tape.move d (Turing.Tape.map f T)
theorem Turing.Tape.map_mk' E0 #
∀ {Γ : Type u_1} {Γ' : Type u_2} [inst : Inhabited Γ] [inst_1 : Inhabited Γ'] (f : Turing.PointedMap Γ Γ')
(L R : Turing.ListBlank Γ),
Turing.Tape.map f (Turing.Tape.mk' L R) = Turing.Tape.mk' (Turing.ListBlank.map f L) (Turing.ListBlank.map f R)
theorem Turing.Tape.map_mk₂ E0 #
∀ {Γ : Type u_1} {Γ' : Type u_2} [inst : Inhabited Γ] [inst_1 : Inhabited Γ'] (f : Turing.PointedMap Γ Γ')
(L R : List Γ), Turing.Tape.map f (Turing.Tape.mk₂ L R) = Turing.Tape.mk₂ (List.map f.f L) (List.map f.f R)
theorem Turing.Tape.map_mk₁ E0 #
∀ {Γ : Type u_1} {Γ' : Type u_2} [inst : Inhabited Γ] [inst_1 : Inhabited Γ'] (f : Turing.PointedMap Γ Γ') (l : List Γ),
Turing.Tape.map f (Turing.Tape.mk₁ l) = Turing.Tape.mk₁ (List.map f.f l)