Imports
/-
Copyright (c) 2026 Google LLC. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
-/
module
public import BusyBeaver.Basic
public import BusyBeaver.Calculi.Counter
import Mathlib.Data.List.Basic
import Mathlib.Data.Nat.Basic
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.Ring@[expose] public sectionopen Mathlib Relation Nat Turing BusyBeavernamespace BusyBeaver.WordRunStackvariable {Γ : Type*} [Inhabited Γ]theorem append_assoc_blank (u v : List Γ) (lb : ListBlank Γ) :
(u ++ v) +> lb = u +> (v +> lb) := Γ:Type u_1inst✝:Inhabited Γu:List Γv:List Γlb:ListBlank Γ⊢ (u ++ v) +> lb = u +> v +> lb
induction u with
Γ:Type u_1inst✝:Inhabited Γv:List Γlb:ListBlank Γ⊢ ([] ++ v) +> lb = [] +> v +> lb All goals completed! 🐙
Γ:Type u_1inst✝:Inhabited Γv:List Γlb:ListBlank Γx:Γxs:List Γih:(xs ++ v) +> lb = xs +> v +> lb⊢ (x :: xs ++ v) +> lb = (x :: xs) +> v +> lb All goals completed! 🐙theorem nth_cons_zero (x : Γ) (t : ListBlank Γ) : (x >> t).nth 0 = x := Γ:Type u_1inst✝:Inhabited Γx:Γt:ListBlank Γ⊢ (x >> t).nth 0 = x
All goals completed! 🐙theorem nth_cons_succ (x : Γ) (t : ListBlank Γ) (i : ℕ) : (x >> t).nth (i + 1) = t.nth i := by Γ:Type u_1inst✝:Inhabited Γx:Γt:ListBlank Γi:ℕ⊢ (x >> t).nth (i + 1) = t.nth i
rw [ListBlank.nth_succ, Γ:Type u_1inst✝:Inhabited Γx:Γt:ListBlank Γi:ℕ⊢ (x >> t).tail.nth i = t.nth i ListBlank.tail_cons Γ:Type u_1inst✝:Inhabited Γx:Γt:ListBlank Γi:ℕ⊢ t.nth i = t.nth i] All goals completed! 🐙theorem nth_cons_one (x : Γ) (t : ListBlank Γ) : (x >> t).nth 1 = t.nth 0 :=
nth_cons_succ x t 0theorem nth_cons_two (x : Γ) (t : ListBlank Γ) : (x >> t).nth 2 = t.nth 1 :=
nth_cons_succ x t 1theorem nth_cons_three (x : Γ) (t : ListBlank Γ) : (x >> t).nth 3 = t.nth 2 :=
nth_cons_succ x t 2theorem nth_cons_four (x : Γ) (t : ListBlank Γ) : (x >> t).nth 4 = t.nth 3 :=
nth_cons_succ x t 3theorem nth_default : ∀ i : ℕ, (default : ListBlank Γ).nth i = default
| 0 => Γ:Type u_1inst✝:Inhabited Γ⊢ default.nth 0 = default by Γ:Type u_1inst✝:Inhabited Γ⊢ default.nth 0 = default
rw [ListBlank.nth_zero Γ:Type u_1inst✝:Inhabited Γ⊢ default.head = default] Γ:Type u_1inst✝:Inhabited Γ⊢ default.head = default
exact ListBlank.head_mk [] All goals completed! 🐙
| i + 1 => Γ:Type u_1inst✝:Inhabited Γi:ℕ⊢ default.nth (i + 1) = default by Γ:Type u_1inst✝:Inhabited Γi:ℕ⊢ default.nth (i + 1) = default
rw [ListBlank.nth_succ Γ:Type u_1inst✝:Inhabited Γi:ℕ⊢ default.tail.nth i = default] Γ:Type u_1inst✝:Inhabited Γi:ℕ⊢ default.tail.nth i = default
have htail : (default : ListBlank Γ).tail = default := ListBlank.tail_mk [] Γ:Type u_1inst✝:Inhabited Γi:ℕhtail:default.tail = default⊢ default.tail.nth i = default
rw [htail Γ:Type u_1inst✝:Inhabited Γi:ℕhtail:default.tail = default⊢ default.nth i = default] Γ:Type u_1inst✝:Inhabited Γi:ℕhtail:default.tail = default⊢ default.nth i = default
exact nth_default i All goals completed! 🐙
Extracts the first n symbols of a ListBlank Γ.
def takeBlank {Γ : Type*} [Inhabited Γ] : ℕ → ListBlank Γ → List Γ
| 0, _ => []
| n + 1, lb => lb.head :: takeBlank n lb.tailtheorem takeBlank_length : ∀ (n : ℕ) (lb : ListBlank Γ), (takeBlank n lb).length = n
| 0, _ => rfl
| n + 1, lb => Γ:Type u_1inst✝:Inhabited Γn:ℕlb:ListBlank Γ⊢ (takeBlank (n + 1) lb).length = n + 1 by Γ:Type u_1inst✝:Inhabited Γn:ℕlb:ListBlank Γ⊢ (takeBlank (n + 1) lb).length = n + 1
simp only [takeBlank, List.length_cons, takeBlank_length n lb.tail] All goals completed! 🐙theorem nth_takeBlank_append_of_lt :
∀ (n : ℕ) (lb : ListBlank Γ) (v : List Γ) (t : ListBlank Γ) (i : ℕ), i < n →
((takeBlank n lb ++ v) +> t).nth i = lb.nth i
| 0, _, _, _, _, h => nomatch h
| n + 1, lb, v, t, 0, _ => Γ:Type u_1inst✝:Inhabited Γn:ℕlb:ListBlank Γv:List Γt:ListBlank Γx✝:0 < n + 1⊢ ((takeBlank (n + 1) lb ++ v) +> t).nth 0 = lb.nth 0 by Γ:Type u_1inst✝:Inhabited Γn:ℕlb:ListBlank Γv:List Γt:ListBlank Γx✝:0 < n + 1⊢ ((takeBlank (n + 1) lb ++ v) +> t).nth 0 = lb.nth 0
simp only [takeBlank, List.cons_append, ListBlank.append] Γ:Type u_1inst✝:Inhabited Γn:ℕlb:ListBlank Γv:List Γt:ListBlank Γx✝:0 < n + 1⊢ (lb.head >> (takeBlank n lb.tail ++ v) +> t).nth 0 = lb.nth 0
rw [nth_cons_zero, Γ:Type u_1inst✝:Inhabited Γn:ℕlb:ListBlank Γv:List Γt:ListBlank Γx✝:0 < n + 1⊢ lb.head = lb.nth 0 ListBlank.nth_zero Γ:Type u_1inst✝:Inhabited Γn:ℕlb:ListBlank Γv:List Γt:ListBlank Γx✝:0 < n + 1⊢ lb.head = lb.head] All goals completed! 🐙
| n + 1, lb, v, t, i + 1, h => Γ:Type u_1inst✝:Inhabited Γn:ℕlb:ListBlank Γv:List Γt:ListBlank Γi:ℕh:i + 1 < n + 1⊢ ((takeBlank (n + 1) lb ++ v) +> t).nth (i + 1) = lb.nth (i + 1) by Γ:Type u_1inst✝:Inhabited Γn:ℕlb:ListBlank Γv:List Γt:ListBlank Γi:ℕh:i + 1 < n + 1⊢ ((takeBlank (n + 1) lb ++ v) +> t).nth (i + 1) = lb.nth (i + 1)
simp only [takeBlank, List.cons_append, ListBlank.append] Γ:Type u_1inst✝:Inhabited Γn:ℕlb:ListBlank Γv:List Γt:ListBlank Γi:ℕh:i + 1 < n + 1⊢ (lb.head >> (takeBlank n lb.tail ++ v) +> t).nth (i + 1) = lb.nth (i + 1)
rw [nth_cons_succ, Γ:Type u_1inst✝:Inhabited Γn:ℕlb:ListBlank Γv:List Γt:ListBlank Γi:ℕh:i + 1 < n + 1⊢ ((takeBlank n lb.tail ++ v) +> t).nth i = lb.nth (i + 1) ListBlank.nth_succ Γ:Type u_1inst✝:Inhabited Γn:ℕlb:ListBlank Γv:List Γt:ListBlank Γi:ℕh:i + 1 < n + 1⊢ ((takeBlank n lb.tail ++ v) +> t).nth i = lb.tail.nth i] Γ:Type u_1inst✝:Inhabited Γn:ℕlb:ListBlank Γv:List Γt:ListBlank Γi:ℕh:i + 1 < n + 1⊢ ((takeBlank n lb.tail ++ v) +> t).nth i = lb.tail.nth i
exact nth_takeBlank_append_of_lt n lb.tail v t i (Nat.lt_of_succ_lt_succ h) All goals completed! 🐙theorem nth_takeBlank_append_add :
∀ (n : ℕ) (lb : ListBlank Γ) (v : List Γ) (t : ListBlank Γ) (j : ℕ),
((takeBlank n lb ++ v) +> t).nth (n + j) = (v +> t).nth j
| 0, _, _, _, _ => Γ:Type u_1inst✝:Inhabited Γx✝³:ListBlank Γx✝²:List Γx✝¹:ListBlank Γx✝:ℕ⊢ ((takeBlank 0 x✝³ ++ x✝²) +> x✝¹).nth (0 + x✝) = (x✝² +> x✝¹).nth x✝ by Γ:Type u_1inst✝:Inhabited Γx✝³:ListBlank Γx✝²:List Γx✝¹:ListBlank Γx✝:ℕ⊢ ((takeBlank 0 x✝³ ++ x✝²) +> x✝¹).nth (0 + x✝) = (x✝² +> x✝¹).nth x✝ simp only [takeBlank, List.nil_append, Nat.zero_add] All goals completed! 🐙
| n + 1, lb, v, t, j => Γ:Type u_1inst✝:Inhabited Γn:ℕlb:ListBlank Γv:List Γt:ListBlank Γj:ℕ⊢ ((takeBlank (n + 1) lb ++ v) +> t).nth (n + 1 + j) = (v +> t).nth j by Γ:Type u_1inst✝:Inhabited Γn:ℕlb:ListBlank Γv:List Γt:ListBlank Γj:ℕ⊢ ((takeBlank (n + 1) lb ++ v) +> t).nth (n + 1 + j) = (v +> t).nth j
simp only [takeBlank, List.cons_append, ListBlank.append] Γ:Type u_1inst✝:Inhabited Γn:ℕlb:ListBlank Γv:List Γt:ListBlank Γj:ℕ⊢ (lb.head >> (takeBlank n lb.tail ++ v) +> t).nth (n + 1 + j) = (v +> t).nth j
rw [Nat.succ_add, Γ:Type u_1inst✝:Inhabited Γn:ℕlb:ListBlank Γv:List Γt:ListBlank Γj:ℕ⊢ (lb.head >> (takeBlank n lb.tail ++ v) +> t).nth (n + j).succ = (v +> t).nth j nth_cons_succ Γ:Type u_1inst✝:Inhabited Γn:ℕlb:ListBlank Γv:List Γt:ListBlank Γj:ℕ⊢ ((takeBlank n lb.tail ++ v) +> t).nth (n + j) = (v +> t).nth j] Γ:Type u_1inst✝:Inhabited Γn:ℕlb:ListBlank Γv:List Γt:ListBlank Γj:ℕ⊢ ((takeBlank n lb.tail ++ v) +> t).nth (n + j) = (v +> t).nth j
exact nth_takeBlank_append_add n lb.tail v t j All goals completed! 🐙theorem nth_append_of_lt :
∀ (v : List Γ) (t : ListBlank Γ) (j : ℕ), j < v.length → (v +> t).nth j = v.getD j default
| [], _, _, h => nomatch h
| x :: v, t, 0, _ => Γ:Type u_1inst✝:Inhabited Γx:Γv:List Γt:ListBlank Γx✝:0 < (x :: v).length⊢ ((x :: v) +> t).nth 0 = (x :: v).getD 0 default by Γ:Type u_1inst✝:Inhabited Γx:Γv:List Γt:ListBlank Γx✝:0 < (x :: v).length⊢ ((x :: v) +> t).nth 0 = (x :: v).getD 0 default
simp only [ListBlank.append, List.getD_cons_zero] Γ:Type u_1inst✝:Inhabited Γx:Γv:List Γt:ListBlank Γx✝:0 < (x :: v).length⊢ (x >> v +> t).nth 0 = x
exact nth_cons_zero x (v +> t) All goals completed! 🐙
| x :: v, t, j + 1, h => Γ:Type u_1inst✝:Inhabited Γx:Γv:List Γt:ListBlank Γj:ℕh:j + 1 < (x :: v).length⊢ ((x :: v) +> t).nth (j + 1) = (x :: v).getD (j + 1) default by Γ:Type u_1inst✝:Inhabited Γx:Γv:List Γt:ListBlank Γj:ℕh:j + 1 < (x :: v).length⊢ ((x :: v) +> t).nth (j + 1) = (x :: v).getD (j + 1) default
simp only [ListBlank.append, List.getD_cons_succ] Γ:Type u_1inst✝:Inhabited Γx:Γv:List Γt:ListBlank Γj:ℕh:j + 1 < (x :: v).length⊢ (x >> v +> t).nth (j + 1) = v.getD j default
rw [nth_cons_succ Γ:Type u_1inst✝:Inhabited Γx:Γv:List Γt:ListBlank Γj:ℕh:j + 1 < (x :: v).length⊢ (v +> t).nth j = v.getD j default] Γ:Type u_1inst✝:Inhabited Γx:Γv:List Γt:ListBlank Γj:ℕh:j + 1 < (x :: v).length⊢ (v +> t).nth j = v.getD j default
exact nth_append_of_lt v t j (Nat.lt_of_succ_lt_succ h) All goals completed! 🐙def NoFactor (pat : List Γ) (t : ListBlank Γ) : Prop :=
∀ i : ℕ, ¬ ∀ j : ℕ, j < pat.length → t.nth (i + j) = pat.getD j defaulttheorem noFactor_default (pat : List Γ) (j : ℕ) (hj : j < pat.length)
(hne : pat.getD j default ≠ default) : NoFactor pat (default : ListBlank Γ) := by Γ:Type u_1inst✝:Inhabited Γpat:List Γj:ℕhj:j < pat.lengthhne:pat.getD j default ≠ default⊢ NoFactor pat default
intro i h Γ:Type u_1inst✝:Inhabited Γpat:List Γj:ℕhj:j < pat.lengthhne:pat.getD j default ≠ defaulti:ℕh:∀ j < pat.length, default.nth (i + j) = pat.getD j default⊢ False
exact hne ((h j hj).symm.trans (nth_default (i + j))) All goals completed! 🐙theorem noFactor_cons_of_nth_ne (pat : List Γ) (x : Γ) (t : ListBlank Γ) (ht : NoFactor pat t)
(j : ℕ) (hj : j < pat.length) (hne : (x >> t).nth j ≠ pat.getD j default) :
NoFactor pat (x >> t) := by Γ:Type u_1inst✝:Inhabited Γpat:List Γx:Γt:ListBlank Γht:NoFactor pat tj:ℕhj:j < pat.lengthhne:(x >> t).nth j ≠ pat.getD j default⊢ NoFactor pat (x >> t)
intro i h Γ:Type u_1inst✝:Inhabited Γpat:List Γx:Γt:ListBlank Γht:NoFactor pat tj:ℕhj:j < pat.lengthhne:(x >> t).nth j ≠ pat.getD j defaulti:ℕh:∀ j < pat.length, (x >> t).nth (i + j) = pat.getD j default⊢ False
cases i with
| zero => zero Γ:Type u_1inst✝:Inhabited Γpat:List Γx:Γt:ListBlank Γht:NoFactor pat tj:ℕhj:j < pat.lengthhne:(x >> t).nth j ≠ pat.getD j defaulth:∀ j < pat.length, (x >> t).nth (0 + j) = pat.getD j default⊢ False exact hne (by Γ:Type u_1inst✝:Inhabited Γpat:List Γx:Γt:ListBlank Γht:NoFactor pat tj:ℕhj:j < pat.lengthhne:(x >> t).nth j ≠ pat.getD j defaulth:∀ j < pat.length, (x >> t).nth (0 + j) = pat.getD j default⊢ (x >> t).nth j = pat.getD j default simpa using h j hj All goals completed! 🐙)
| succ i => succ Γ:Type u_1inst✝:Inhabited Γpat:List Γx:Γt:ListBlank Γht:NoFactor pat tj:ℕhj:j < pat.lengthhne:(x >> t).nth j ≠ pat.getD j defaulti:ℕh:∀ j < pat.length, (x >> t).nth (i + 1 + j) = pat.getD j default⊢ False
apply ht i succ Γ:Type u_1inst✝:Inhabited Γpat:List Γx:Γt:ListBlank Γht:NoFactor pat tj:ℕhj:j < pat.lengthhne:(x >> t).nth j ≠ pat.getD j defaulti:ℕh:∀ j < pat.length, (x >> t).nth (i + 1 + j) = pat.getD j default⊢ ∀ j < pat.length, t.nth (i + j) = pat.getD j default
intro j' hj' succ Γ:Type u_1inst✝:Inhabited Γpat:List Γx:Γt:ListBlank Γht:NoFactor pat tj:ℕhj:j < pat.lengthhne:(x >> t).nth j ≠ pat.getD j defaulti:ℕh:∀ j < pat.length, (x >> t).nth (i + 1 + j) = pat.getD j defaultj':ℕhj':j' < pat.length⊢ t.nth (i + j') = pat.getD j' default
have := h j' hj' succ Γ:Type u_1inst✝:Inhabited Γpat:List Γx:Γt:ListBlank Γht:NoFactor pat tj:ℕhj:j < pat.lengthhne:(x >> t).nth j ≠ pat.getD j defaulti:ℕh:∀ j < pat.length, (x >> t).nth (i + 1 + j) = pat.getD j defaultj':ℕhj':j' < pat.lengththis:(x >> t).nth (i + 1 + j') = pat.getD j' default⊢ t.nth (i + j') = pat.getD j' default
rwa [Nat.succ_add, nth_cons_succ] at this All goals completed! 🐙theorem isNowhereDenseFamily_of_noFactor {S : Type*} (Valid : S → Prop) (enc : S → ListBlank Γ)
(pat : List Γ) (hforb : ∀ s, Valid s → NoFactor pat (enc s)) :
IsNowhereDenseFamily Valid enc := by Γ:Type u_1inst✝:Inhabited ΓS:Type u_2Valid:S → Propenc:S → ListBlank Γpat:List Γhforb:∀ (s : S), Valid s → NoFactor pat (enc s)⊢ IsNowhereDenseFamily Valid enc
intro s hs n Γ:Type u_1inst✝:Inhabited ΓS:Type u_2Valid:S → Propenc:S → ListBlank Γpat:List Γhforb:∀ (s : S), Valid s → NoFactor pat (enc s)s:Shs:Valid sn:ℕ⊢ ∃ bad, (∀ i < n, bad.nth i = (enc s).nth i) ∧ ∀ (s' : S), Valid s' → enc s' ≠ bad
refine ⟨(takeBlank n (enc s) ++ pat) +> default, ?_, ?_⟩ refine_1 Γ:Type u_1inst✝:Inhabited ΓS:Type u_2Valid:S → Propenc:S → ListBlank Γpat:List Γhforb:∀ (s : S), Valid s → NoFactor pat (enc s)s:Shs:Valid sn:ℕ⊢ ∀ i < n, ((takeBlank n (enc s) ++ pat) +> default).nth i = (enc s).nth irefine_2 Γ:Type u_1inst✝:Inhabited ΓS:Type u_2Valid:S → Propenc:S → ListBlank Γpat:List Γhforb:∀ (s : S), Valid s → NoFactor pat (enc s)s:Shs:Valid sn:ℕ⊢ ∀ (s' : S), Valid s' → enc s' ≠ (takeBlank n (enc s) ++ pat) +> default
· refine_1 Γ:Type u_1inst✝:Inhabited ΓS:Type u_2Valid:S → Propenc:S → ListBlank Γpat:List Γhforb:∀ (s : S), Valid s → NoFactor pat (enc s)s:Shs:Valid sn:ℕ⊢ ∀ i < n, ((takeBlank n (enc s) ++ pat) +> default).nth i = (enc s).nth i intro i hi refine_1 Γ:Type u_1inst✝:Inhabited ΓS:Type u_2Valid:S → Propenc:S → ListBlank Γpat:List Γhforb:∀ (s : S), Valid s → NoFactor pat (enc s)s:Shs:Valid sn:ℕi:ℕhi:i < n⊢ ((takeBlank n (enc s) ++ pat) +> default).nth i = (enc s).nth i
exact nth_takeBlank_append_of_lt n _ pat default i hi All goals completed! 🐙
· refine_2 Γ:Type u_1inst✝:Inhabited ΓS:Type u_2Valid:S → Propenc:S → ListBlank Γpat:List Γhforb:∀ (s : S), Valid s → NoFactor pat (enc s)s:Shs:Valid sn:ℕ⊢ ∀ (s' : S), Valid s' → enc s' ≠ (takeBlank n (enc s) ++ pat) +> default intro s' hs' heq refine_2 Γ:Type u_1inst✝:Inhabited ΓS:Type u_2Valid:S → Propenc:S → ListBlank Γpat:List Γhforb:∀ (s : S), Valid s → NoFactor pat (enc s)s:Shs:Valid sn:ℕs':Shs':Valid s'heq:enc s' = (takeBlank n (enc s) ++ pat) +> default⊢ False
apply hforb s' hs' n refine_2 Γ:Type u_1inst✝:Inhabited ΓS:Type u_2Valid:S → Propenc:S → ListBlank Γpat:List Γhforb:∀ (s : S), Valid s → NoFactor pat (enc s)s:Shs:Valid sn:ℕs':Shs':Valid s'heq:enc s' = (takeBlank n (enc s) ++ pat) +> default⊢ ∀ j < pat.length, (enc s').nth (n + j) = pat.getD j default
intro j hj refine_2 Γ:Type u_1inst✝:Inhabited ΓS:Type u_2Valid:S → Propenc:S → ListBlank Γpat:List Γhforb:∀ (s : S), Valid s → NoFactor pat (enc s)s:Shs:Valid sn:ℕs':Shs':Valid s'heq:enc s' = (takeBlank n (enc s) ++ pat) +> defaultj:ℕhj:j < pat.length⊢ (enc s').nth (n + j) = pat.getD j default
rw [heq, refine_2 Γ:Type u_1inst✝:Inhabited ΓS:Type u_2Valid:S → Propenc:S → ListBlank Γpat:List Γhforb:∀ (s : S), Valid s → NoFactor pat (enc s)s:Shs:Valid sn:ℕs':Shs':Valid s'heq:enc s' = (takeBlank n (enc s) ++ pat) +> defaultj:ℕhj:j < pat.length⊢ ((takeBlank n (enc s) ++ pat) +> default).nth (n + j) = pat.getD j default nth_takeBlank_append_add, refine_2 Γ:Type u_1inst✝:Inhabited ΓS:Type u_2Valid:S → Propenc:S → ListBlank Γpat:List Γhforb:∀ (s : S), Valid s → NoFactor pat (enc s)s:Shs:Valid sn:ℕs':Shs':Valid s'heq:enc s' = (takeBlank n (enc s) ++ pat) +> defaultj:ℕhj:j < pat.length⊢ (pat +> default).nth j = pat.getD j default nth_append_of_lt pat default j hj refine_2 Γ:Type u_1inst✝:Inhabited ΓS:Type u_2Valid:S → Propenc:S → ListBlank Γpat:List Γhforb:∀ (s : S), Valid s → NoFactor pat (enc s)s:Shs:Valid sn:ℕs':Shs':Valid s'heq:enc s' = (takeBlank n (enc s) ++ pat) +> defaultj:ℕhj:j < pat.length⊢ pat.getD j default = pat.getD j default] All goals completed! 🐙theorem isNowhereDenseHalf_of_noFactor {S : Type*} (Valid : S → Prop)
(segs : S → List (SegRegionKind Γ)) (pat : List Γ)
(hforb : ∀ s, Valid s → NoFactor pat (evalSegmentedHalf (segs s))) :
IsNowhereDenseHalf Valid segs :=
isNowhereDenseFamily_of_noFactor Valid (fun s => evalSegmentedHalf (segs s)) pat hforb
Word-List Encoders & SegModeSpec Helpers (PairStackSeg)
Encodes a list of tokens xs : List α onto tail : ListBlank Γ via word map w.
def encWordsTail {Γ α : Type*} [Inhabited Γ] (w : α → List Γ) (tail : ListBlank Γ) :
List α → ListBlank Γ
| [] => tail
| x :: xs => w x +> encWordsTail w tail xs
Encodes a list of tokens xs : List α onto the blank half-tape default.
def encWords {Γ α : Type*} [Inhabited Γ] (w : α → List Γ) (xs : List α) : ListBlank Γ :=
encWordsTail w default xs@[simp] theorem encWordsTail_nil {Γ α : Type*} [Inhabited Γ]
(w : α → List Γ) (tail : ListBlank Γ) :
encWordsTail w tail [] = tail :=
rfl@[simp] theorem encWordsTail_cons {Γ α : Type*} [Inhabited Γ]
(w : α → List Γ) (tail : ListBlank Γ) (x : α) (xs : List α) :
encWordsTail w tail (x :: xs) = w x +> encWordsTail w tail xs :=
rfl@[simp] theorem encWords_nil {Γ α : Type*} [Inhabited Γ] (w : α → List Γ) :
encWords w [] = default :=
rfl@[simp] theorem encWords_cons {Γ α : Type*} [Inhabited Γ]
(w : α → List Γ) (x : α) (xs : List α) :
encWords w (x :: xs) = w x +> encWords w xs :=
rfl
Bridge from evalSegRegion (.finWord (xs.map w)) +> tail to encWordsTail w tail xs.
theorem evalSegRegion_finWord_map {Γ α : Type*} [Inhabited Γ]
(w : α → List Γ) :
∀ (xs : List α) (tail : ListBlank Γ),
evalSegRegion (.finWord (xs.map w)) +> tail = encWordsTail w tail xs
| [], tail => Γ:Type u_2α:Type u_3inst✝:Inhabited Γw:α → List Γtail:ListBlank Γ⊢ evalSegRegion (SegRegionKind.finWord (List.map w [])) +> tail = encWordsTail w tail [] by Γ:Type u_2α:Type u_3inst✝:Inhabited Γw:α → List Γtail:ListBlank Γ⊢ evalSegRegion (SegRegionKind.finWord (List.map w [])) +> tail = encWordsTail w tail [] simp [evalSegRegion, encWordsTail] All goals completed! 🐙
| x :: xs, tail => Γ:Type u_2α:Type u_3inst✝:Inhabited Γw:α → List Γx:αxs:List αtail:ListBlank Γ⊢ evalSegRegion (SegRegionKind.finWord (List.map w (x :: xs))) +> tail = encWordsTail w tail (x :: xs) by Γ:Type u_2α:Type u_3inst✝:Inhabited Γw:α → List Γx:αxs:List αtail:ListBlank Γ⊢ evalSegRegion (SegRegionKind.finWord (List.map w (x :: xs))) +> tail = encWordsTail w tail (x :: xs)
simp only [List.map_cons, evalSegRegion, encWordsTail] Γ:Type u_2α:Type u_3inst✝:Inhabited Γw:α → List Γx:αxs:List αtail:ListBlank Γ⊢ (w x ++ evalSegRegion (SegRegionKind.finWord (List.map w xs))) +> tail = w x +> encWordsTail w tail xs
rw [append_assoc_blank, Γ:Type u_2α:Type u_3inst✝:Inhabited Γw:α → List Γx:αxs:List αtail:ListBlank Γ⊢ w x +> evalSegRegion (SegRegionKind.finWord (List.map w xs)) +> tail = w x +> encWordsTail w tail xs evalSegRegion_finWord_map w xs tail Γ:Type u_2α:Type u_3inst✝:Inhabited Γw:α → List Γx:αxs:List αtail:ListBlank Γ⊢ w x +> encWordsTail w tail xs = w x +> encWordsTail w tail xs] All goals completed! 🐙
Bridge from evalSegmentedHalf [.finWord (xs.map w)] to encWords w xs.
theorem evalSegmentedHalf_finWord_map {Γ α : Type*} [Inhabited Γ]
(w : α → List Γ) (xs : List α) :
evalSegmentedHalf [.finWord (xs.map w)] = encWords w xs := by Γ:Type u_2α:Type u_3inst✝:Inhabited Γw:α → List Γxs:List α⊢ evalSegmentedHalf [SegRegionKind.finWord (List.map w xs)] = encWords w xs
simp only [evalSegmentedHalf, encWords] Γ:Type u_2α:Type u_3inst✝:Inhabited Γw:α → List Γxs:List α⊢ evalSegRegion (SegRegionKind.finWord (List.map w xs)) +> default = encWordsTail w default xs
exact evalSegRegion_finWord_map w xs default All goals completed! 🐙
Bridge from evalSegmentedHalf [.finWord (xs.map w), .gadget base] to encWordsTail.
theorem evalSegmentedHalf_finWord_gadget {Γ α : Type*} [Inhabited Γ]
(w : α → List Γ) (base : List Γ) (xs : List α) :
evalSegmentedHalf [.finWord (xs.map w), .gadget base] =
encWordsTail w (base +> default) xs := by Γ:Type u_2α:Type u_3inst✝:Inhabited Γw:α → List Γbase:List Γxs:List α⊢ evalSegmentedHalf [SegRegionKind.finWord (List.map w xs), SegRegionKind.gadget base] =
encWordsTail w (base +> default) xs
simp only [evalSegmentedHalf, evalSegRegion] Γ:Type u_2α:Type u_3inst✝:Inhabited Γw:α → List Γbase:List Γxs:List α⊢ evalSegRegion (SegRegionKind.finWord (List.map w xs)) +> base +> default = encWordsTail w (base +> default) xs
exact evalSegRegion_finWord_map w xs (base +> default) All goals completed! 🐙Head orientation for a segmented mode descriptor.
inductive SegHeadDir
| left
| right
deriving DecidableEq
Table entry describing the TM state, head orientation, and left/right HalfTapeViews
for a segmented mode m : Mode.
structure SegModeSpec (Γ Λ : Type*) where
q : Λ
dir : SegHeadDir
vL : HalfTapeView Γ := .id []
vR : HalfTapeView Γ := .id []
SegStepOut M ValidSeg evalCfg c: from c, machine M advances in ⊢⁺ either to
evalCfg s' for some valid s' (ValidSeg s'), or to a halting configuration.
def SegStepOut {Γ Λ SegState : Type*} [Inhabited Γ] [Inhabited Λ]
(M : Machine Γ Λ) (ValidSeg : SegState → Prop) (evalCfg : SegState → Cfg Γ Λ)
(c : Cfg Γ Λ) : Prop :=
∃ cfg', (c [M]⊢⁺ cfg') ∧
((∃ s', ValidSeg s' ∧ cfg' = evalCfg s') ∨ (BusyBeaver.step M cfg').isNone)
Close SegStepOut by stepping in ⊢⁺ to evalCfg s' for a valid state s'.
theorem SegStepOut.step {Γ Λ SegState : Type*} [Inhabited Γ] [Inhabited Λ]
{M : Machine Γ Λ} {ValidSeg : SegState → Prop} {evalCfg : SegState → Cfg Γ Λ}
{c : Cfg Γ Λ} {s' : SegState} (hs' : ValidSeg s') (h : c [M]⊢⁺ evalCfg s') :
SegStepOut M ValidSeg evalCfg c :=
⟨evalCfg s', h, Or.inl ⟨s', hs', rfl⟩⟩
Close SegStepOut by stepping in ⊢⁺ to a halting configuration cfg_h.
theorem SegStepOut.halt {Γ Λ SegState : Type*} [Inhabited Γ] [Inhabited Λ]
{M : Machine Γ Λ} {ValidSeg : SegState → Prop} {evalCfg : SegState → Cfg Γ Λ}
{c cfg_h : Cfg Γ Λ} (h : c [M]⊢⁺ cfg_h) (hhalt : (BusyBeaver.step M cfg_h).isNone) :
SegStepOut M ValidSeg evalCfg c :=
⟨cfg_h, h, Or.inr hhalt⟩
Transport IsNowhereDenseFamily along a pointwise description of evaluated segments.
theorem isNowhereDenseHalf_of_family {S : Type*} {Valid : S → Prop}
{segs : S → List (SegRegionKind Γ)} {enc : S → ListBlank Γ}
(heq : ∀ s, evalSegmentedHalf (segs s) = enc s) (h : IsNowhereDenseFamily Valid enc) :
IsNowhereDenseHalf Valid segs := by Γ:Type u_1inst✝:Inhabited ΓS:Type u_2Valid:S → Propsegs:S → List (SegRegionKind Γ)enc:S → ListBlank Γheq:∀ (s : S), evalSegmentedHalf (segs s) = enc sh:IsNowhereDenseFamily Valid enc⊢ IsNowhereDenseHalf Valid segs
unfold IsNowhereDenseHalf Γ:Type u_1inst✝:Inhabited ΓS:Type u_2Valid:S → Propsegs:S → List (SegRegionKind Γ)enc:S → ListBlank Γheq:∀ (s : S), evalSegmentedHalf (segs s) = enc sh:IsNowhereDenseFamily Valid enc⊢ IsNowhereDenseFamily Valid fun s ↦ evalSegmentedHalf (segs s)
rw [show (fun s => evalSegmentedHalf (segs s)) = enc from funext heq Γ:Type u_1inst✝:Inhabited ΓS:Type u_2Valid:S → Propsegs:S → List (SegRegionKind Γ)enc:S → ListBlank Γheq:∀ (s : S), evalSegmentedHalf (segs s) = enc sh:IsNowhereDenseFamily Valid enc⊢ IsNowhereDenseFamily Valid enc] Γ:Type u_1inst✝:Inhabited ΓS:Type u_2Valid:S → Propsegs:S → List (SegRegionKind Γ)enc:S → ListBlank Γheq:∀ (s : S), evalSegmentedHalf (segs s) = enc sh:IsNowhereDenseFamily Valid enc⊢ IsNowhereDenseFamily Valid enc
exact h All goals completed! 🐙
Decidable n-step window checker from (ls +> l) {{q}}> (rs +> r) to
(ls' +> l) {{q'}}> (rs' +> r).
def checkHeadRight {Γ Λ : Type*} [DecidableEq Γ] [DecidableEq Λ] [Inhabited Γ] [Inhabited Λ]
(bL bR : Bool) (M : Machine Γ Λ) (n : ℕ)
(q : Λ) (ls rs : List Γ) (q' : Λ) (ls' rs' : List Γ) : Bool :=
match rs with
| [] =>
if !bR then false
else
match rs' with
| a' :: rs₀' =>
Counter.multiStepWindow bL true M n ⟨q, default, ls, []⟩ ==
some ⟨q', a', ls', rs₀'⟩
| [] =>
Counter.multiStepWindow bL true M n ⟨q, default, ls, []⟩ ==
some ⟨q', default, ls', []⟩
| a :: rs₀ =>
match rs' with
| a' :: rs₀' =>
Counter.multiStepWindow bL bR M n ⟨q, a, ls, rs₀⟩ == some ⟨q', a', ls', rs₀'⟩
| [] =>
if bR then
Counter.multiStepWindow bL true M n ⟨q, a, ls, rs₀⟩ ==
some ⟨q', default, ls', []⟩
else
match n with
| 0 => false
| m + 1 =>
match Counter.multiStepWindow bL false M m ⟨q, a, ls, rs₀⟩ with
| some ⟨q₀, x, ls₀, []⟩ =>
match M q₀ x with
| some (some q₁, Stmt.write w Dir.right) =>
(q₁ == q') && (Counter.pushWindow bL w ls₀ == ls')
| _ => false
| _ => falseprivate theorem evalWindow_eq_headRight_cons {Γ Λ : Type*} [Inhabited Γ] [Inhabited Λ]
(l r : ListBlank Γ) (q : Λ) (a : Γ) (ls rs₀ : List Γ) :
Counter.evalWindow l r ⟨q, a, ls, rs₀⟩ = (ls +> l) {{q}}> ((a :: rs₀) +> r) := by Γ:Type u_2Λ:Type u_3inst✝¹:Inhabited Γinst✝:Inhabited Λl:ListBlank Γr:ListBlank Γq:Λa:Γls:List Γrs₀:List Γ⊢ Counter.evalWindow l r { q := q, cur := a, l := ls, r := rs₀ } = (ls +> l) {{q}}> (a :: rs₀) +> r
simp [Counter.evalWindow] All goals completed! 🐙private theorem evalWindow_eq_headRight_nil {Γ Λ : Type*} [Inhabited Γ] [Inhabited Λ]
(l : ListBlank Γ) (q : Λ) (ls : List Γ) :
Counter.evalWindow l default ⟨q, default, ls, []⟩ = (ls +> l) {{q}}> ([] +> default) := by Γ:Type u_2Λ:Type u_3inst✝¹:Inhabited Γinst✝:Inhabited Λl:ListBlank Γq:Λls:List Γ⊢ Counter.evalWindow l default { q := q, cur := default, l := ls, r := [] } = (ls +> l) {{q}}> [] +> default
have hd : (default : ListBlank Γ).head = default := rfl Γ:Type u_2Λ:Type u_3inst✝¹:Inhabited Γinst✝:Inhabited Λl:ListBlank Γq:Λls:List Γhd:default.head = default⊢ Counter.evalWindow l default { q := q, cur := default, l := ls, r := [] } = (ls +> l) {{q}}> [] +> default
have tl : (default : ListBlank Γ).tail = default := rfl Γ:Type u_2Λ:Type u_3inst✝¹:Inhabited Γinst✝:Inhabited Λl:ListBlank Γq:Λls:List Γhd:default.head = defaulttl:default.tail = default⊢ Counter.evalWindow l default { q := q, cur := default, l := ls, r := [] } = (ls +> l) {{q}}> [] +> default
simp [Counter.evalWindow, hd, tl] All goals completed! 🐙
Soundness of checkHeadRight.
theorem checkHeadRight_sound {Γ Λ : Type*} [DecidableEq Γ] [DecidableEq Λ]
[Inhabited Γ] [Inhabited Λ]
{bL bR : Bool} {M : Machine Γ Λ}
(n : ℕ) (q : Λ) (ls rs : List Γ) (q' : Λ) (ls' rs' : List Γ)
(l r : ListBlank Γ)
(hL : bL = true → l = default) (hR : bR = true → r = default)
(h : checkHeadRight bL bR M n q ls rs q' ls' rs' = true) :
((ls +> l) {{q}}> (rs +> r)) [M]⊢^{n} ((ls' +> l) {{q'}}> (rs' +> r)) := by Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λn:ℕq:Λls:List Γrs:List Γq':Λls':List Γrs':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulth:checkHeadRight bL bR M n q ls rs q' ls' rs' = true⊢ ((ls +> l) {{q}}> rs +> r) [M]⊢^{n} (ls' +> l) {{q'}}> rs' +> r
unfold checkHeadRight at h Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λn:ℕq:Λls:List Γrs:List Γq':Λls':List Γrs':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulth:(match rs with
| [] =>
if (!bR) = true then false
else
match rs' with
| a' :: rs₀' =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := a', l := ls', r := rs₀' }
| [] =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := default, l := ls', r := [] }
| a :: rs₀ =>
match rs' with
| a' :: rs₀' =>
Counter.multiStepWindow bL bR M n { q := q, cur := a, l := ls, r := rs₀ } ==
some { q := q', cur := a', l := ls', r := rs₀' }
| [] =>
if bR = true then
Counter.multiStepWindow bL true M n { q := q, cur := a, l := ls, r := rs₀ } ==
some { q := q', cur := default, l := ls', r := [] }
else
match n with
| 0 => false
| m.succ =>
match Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } with
| some { q := q₀, cur := x, l := ls₀, r := [] } =>
match M q₀ x with
| some (some q₁, { symbol := w, dir := Dir.right }) => q₁ == q' && Counter.pushWindow bL w ls₀ == ls'
| x => false
| x => false) =
true⊢ ((ls +> l) {{q}}> rs +> r) [M]⊢^{n} (ls' +> l) {{q'}}> rs' +> r
cases rs with
| nil => nil Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λn:ℕq:Λls:List Γq':Λls':List Γrs':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulth:(match [] with
| [] =>
if (!bR) = true then false
else
match rs' with
| a' :: rs₀' =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := a', l := ls', r := rs₀' }
| [] =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := default, l := ls', r := [] }
| a :: rs₀ =>
match rs' with
| a' :: rs₀' =>
Counter.multiStepWindow bL bR M n { q := q, cur := a, l := ls, r := rs₀ } ==
some { q := q', cur := a', l := ls', r := rs₀' }
| [] =>
if bR = true then
Counter.multiStepWindow bL true M n { q := q, cur := a, l := ls, r := rs₀ } ==
some { q := q', cur := default, l := ls', r := [] }
else
match n with
| 0 => false
| m.succ =>
match Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } with
| some { q := q₀, cur := x, l := ls₀, r := [] } =>
match M q₀ x with
| some (some q₁, { symbol := w, dir := Dir.right }) => q₁ == q' && Counter.pushWindow bL w ls₀ == ls'
| x => false
| x => false) =
true⊢ ((ls +> l) {{q}}> [] +> r) [M]⊢^{n} (ls' +> l) {{q'}}> rs' +> r
cases hbR : bR with
| false => nil.false Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λn:ℕq:Λls:List Γq':Λls':List Γrs':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulth:(match [] with
| [] =>
if (!bR) = true then false
else
match rs' with
| a' :: rs₀' =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := a', l := ls', r := rs₀' }
| [] =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := default, l := ls', r := [] }
| a :: rs₀ =>
match rs' with
| a' :: rs₀' =>
Counter.multiStepWindow bL bR M n { q := q, cur := a, l := ls, r := rs₀ } ==
some { q := q', cur := a', l := ls', r := rs₀' }
| [] =>
if bR = true then
Counter.multiStepWindow bL true M n { q := q, cur := a, l := ls, r := rs₀ } ==
some { q := q', cur := default, l := ls', r := [] }
else
match n with
| 0 => false
| m.succ =>
match Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } with
| some { q := q₀, cur := x, l := ls₀, r := [] } =>
match M q₀ x with
| some (some q₁, { symbol := w, dir := Dir.right }) => q₁ == q' && Counter.pushWindow bL w ls₀ == ls'
| x => false
| x => false) =
truehbR:bR = false⊢ ((ls +> l) {{q}}> [] +> r) [M]⊢^{n} (ls' +> l) {{q'}}> rs' +> r simp [hbR] at h All goals completed! 🐙
| true => nil.true Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λn:ℕq:Λls:List Γq':Λls':List Γrs':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulth:(match [] with
| [] =>
if (!bR) = true then false
else
match rs' with
| a' :: rs₀' =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := a', l := ls', r := rs₀' }
| [] =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := default, l := ls', r := [] }
| a :: rs₀ =>
match rs' with
| a' :: rs₀' =>
Counter.multiStepWindow bL bR M n { q := q, cur := a, l := ls, r := rs₀ } ==
some { q := q', cur := a', l := ls', r := rs₀' }
| [] =>
if bR = true then
Counter.multiStepWindow bL true M n { q := q, cur := a, l := ls, r := rs₀ } ==
some { q := q', cur := default, l := ls', r := [] }
else
match n with
| 0 => false
| m.succ =>
match Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } with
| some { q := q₀, cur := x, l := ls₀, r := [] } =>
match M q₀ x with
| some (some q₁, { symbol := w, dir := Dir.right }) => q₁ == q' && Counter.pushWindow bL w ls₀ == ls'
| x => false
| x => false) =
truehbR:bR = true⊢ ((ls +> l) {{q}}> [] +> r) [M]⊢^{n} (ls' +> l) {{q'}}> rs' +> r
simp only [hbR, Bool.not_true, Bool.false_eq_true, ↓reduceIte] at h nil.true Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λn:ℕq:Λls:List Γq':Λls':List Γrs':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulthbR:bR = trueh:(match rs' with
| a' :: rs₀' =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := a', l := ls', r := rs₀' }
| [] =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := default, l := ls', r := [] }) =
true⊢ ((ls +> l) {{q}}> [] +> r) [M]⊢^{n} (ls' +> l) {{q'}}> rs' +> r
have hr_def := hR hbR nil.true Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λn:ℕq:Λls:List Γq':Λls':List Γrs':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulthbR:bR = trueh:(match rs' with
| a' :: rs₀' =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := a', l := ls', r := rs₀' }
| [] =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := default, l := ls', r := [] }) =
truehr_def:r = default⊢ ((ls +> l) {{q}}> [] +> r) [M]⊢^{n} (ls' +> l) {{q'}}> rs' +> r
subst hr_def nil.true Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λn:ℕq:Λls:List Γq':Λls':List Γrs':List Γl:ListBlank ΓhL:bL = true → l = defaulthbR:bR = trueh:(match rs' with
| a' :: rs₀' =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := a', l := ls', r := rs₀' }
| [] =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := default, l := ls', r := [] }) =
truehR:bR = true → default = default⊢ ((ls +> l) {{q}}> [] +> default) [M]⊢^{n} (ls' +> l) {{q'}}> rs' +> default
cases rs' with
| cons a' rs₀' => nil.true.cons Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λn:ℕq:Λls:List Γq':Λls':List Γl:ListBlank ΓhL:bL = true → l = defaulthbR:bR = truehR:bR = true → default = defaulta':Γrs₀':List Γh:(match a' :: rs₀' with
| a' :: rs₀' =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := a', l := ls', r := rs₀' }
| [] =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := default, l := ls', r := [] }) =
true⊢ ((ls +> l) {{q}}> [] +> default) [M]⊢^{n} (ls' +> l) {{q'}}> (a' :: rs₀') +> default
have hms := eq_of_beq h nil.true.cons Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λn:ℕq:Λls:List Γq':Λls':List Γl:ListBlank ΓhL:bL = true → l = defaulthbR:bR = truehR:bR = true → default = defaulta':Γrs₀':List Γh:(match a' :: rs₀' with
| a' :: rs₀' =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := a', l := ls', r := rs₀' }
| [] =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := default, l := ls', r := [] }) =
truehms:Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } =
some { q := q', cur := a', l := ls', r := rs₀' }⊢ ((ls +> l) {{q}}> [] +> default) [M]⊢^{n} (ls' +> l) {{q'}}> (a' :: rs₀') +> default
have hsnd := Counter.multiStepWindow_sound l default hL (fun _ => rfl) n _ _ hms nil.true.cons Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λn:ℕq:Λls:List Γq':Λls':List Γl:ListBlank ΓhL:bL = true → l = defaulthbR:bR = truehR:bR = true → default = defaulta':Γrs₀':List Γh:(match a' :: rs₀' with
| a' :: rs₀' =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := a', l := ls', r := rs₀' }
| [] =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := default, l := ls', r := [] }) =
truehms:Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } =
some { q := q', cur := a', l := ls', r := rs₀' }hsnd:Counter.evalWindow l default { q := q, cur := default, l := ls, r := [] } [M]⊢^{n}
Counter.evalWindow l default { q := q', cur := a', l := ls', r := rs₀' }⊢ ((ls +> l) {{q}}> [] +> default) [M]⊢^{n} (ls' +> l) {{q'}}> (a' :: rs₀') +> default
rwa [evalWindow_eq_headRight_nil, evalWindow_eq_headRight_cons] at hsnd All goals completed! 🐙
| nil => nil.true.nil Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λn:ℕq:Λls:List Γq':Λls':List Γl:ListBlank ΓhL:bL = true → l = defaulthbR:bR = truehR:bR = true → default = defaulth:(match [] with
| a' :: rs₀' =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := a', l := ls', r := rs₀' }
| [] =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := default, l := ls', r := [] }) =
true⊢ ((ls +> l) {{q}}> [] +> default) [M]⊢^{n} (ls' +> l) {{q'}}> [] +> default
have hms := eq_of_beq h nil.true.nil Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λn:ℕq:Λls:List Γq':Λls':List Γl:ListBlank ΓhL:bL = true → l = defaulthbR:bR = truehR:bR = true → default = defaulth:(match [] with
| a' :: rs₀' =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := a', l := ls', r := rs₀' }
| [] =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := default, l := ls', r := [] }) =
truehms:Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } =
some { q := q', cur := default, l := ls', r := [] }⊢ ((ls +> l) {{q}}> [] +> default) [M]⊢^{n} (ls' +> l) {{q'}}> [] +> default
have hsnd := Counter.multiStepWindow_sound l default hL (fun _ => rfl) n _ _ hms nil.true.nil Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λn:ℕq:Λls:List Γq':Λls':List Γl:ListBlank ΓhL:bL = true → l = defaulthbR:bR = truehR:bR = true → default = defaulth:(match [] with
| a' :: rs₀' =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := a', l := ls', r := rs₀' }
| [] =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := default, l := ls', r := [] }) =
truehms:Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } =
some { q := q', cur := default, l := ls', r := [] }hsnd:Counter.evalWindow l default { q := q, cur := default, l := ls, r := [] } [M]⊢^{n}
Counter.evalWindow l default { q := q', cur := default, l := ls', r := [] }⊢ ((ls +> l) {{q}}> [] +> default) [M]⊢^{n} (ls' +> l) {{q'}}> [] +> default
rwa [evalWindow_eq_headRight_nil, evalWindow_eq_headRight_nil] at hsnd All goals completed! 🐙
| cons a rs₀ => cons Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λn:ℕq:Λls:List Γq':Λls':List Γrs':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulta:Γrs₀:List Γh:(match a :: rs₀ with
| [] =>
if (!bR) = true then false
else
match rs' with
| a' :: rs₀' =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := a', l := ls', r := rs₀' }
| [] =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := default, l := ls', r := [] }
| a :: rs₀ =>
match rs' with
| a' :: rs₀' =>
Counter.multiStepWindow bL bR M n { q := q, cur := a, l := ls, r := rs₀ } ==
some { q := q', cur := a', l := ls', r := rs₀' }
| [] =>
if bR = true then
Counter.multiStepWindow bL true M n { q := q, cur := a, l := ls, r := rs₀ } ==
some { q := q', cur := default, l := ls', r := [] }
else
match n with
| 0 => false
| m.succ =>
match Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } with
| some { q := q₀, cur := x, l := ls₀, r := [] } =>
match M q₀ x with
| some (some q₁, { symbol := w, dir := Dir.right }) => q₁ == q' && Counter.pushWindow bL w ls₀ == ls'
| x => false
| x => false) =
true⊢ ((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{n} (ls' +> l) {{q'}}> rs' +> r
cases rs' with
| cons a' rs₀' => cons.cons Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λn:ℕq:Λls:List Γq':Λls':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulta:Γrs₀:List Γa':Γrs₀':List Γh:(match a :: rs₀ with
| [] =>
if (!bR) = true then false
else
match a' :: rs₀' with
| a' :: rs₀' =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := a', l := ls', r := rs₀' }
| [] =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := default, l := ls', r := [] }
| a :: rs₀ =>
match a' :: rs₀' with
| a' :: rs₀' =>
Counter.multiStepWindow bL bR M n { q := q, cur := a, l := ls, r := rs₀ } ==
some { q := q', cur := a', l := ls', r := rs₀' }
| [] =>
if bR = true then
Counter.multiStepWindow bL true M n { q := q, cur := a, l := ls, r := rs₀ } ==
some { q := q', cur := default, l := ls', r := [] }
else
match n with
| 0 => false
| m.succ =>
match Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } with
| some { q := q₀, cur := x, l := ls₀, r := [] } =>
match M q₀ x with
| some (some q₁, { symbol := w, dir := Dir.right }) => q₁ == q' && Counter.pushWindow bL w ls₀ == ls'
| x => false
| x => false) =
true⊢ ((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{n} (ls' +> l) {{q'}}> (a' :: rs₀') +> r
have hms := eq_of_beq h cons.cons Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λn:ℕq:Λls:List Γq':Λls':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulta:Γrs₀:List Γa':Γrs₀':List Γh:(match a :: rs₀ with
| [] =>
if (!bR) = true then false
else
match a' :: rs₀' with
| a' :: rs₀' =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := a', l := ls', r := rs₀' }
| [] =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := default, l := ls', r := [] }
| a :: rs₀ =>
match a' :: rs₀' with
| a' :: rs₀' =>
Counter.multiStepWindow bL bR M n { q := q, cur := a, l := ls, r := rs₀ } ==
some { q := q', cur := a', l := ls', r := rs₀' }
| [] =>
if bR = true then
Counter.multiStepWindow bL true M n { q := q, cur := a, l := ls, r := rs₀ } ==
some { q := q', cur := default, l := ls', r := [] }
else
match n with
| 0 => false
| m.succ =>
match Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } with
| some { q := q₀, cur := x, l := ls₀, r := [] } =>
match M q₀ x with
| some (some q₁, { symbol := w, dir := Dir.right }) => q₁ == q' && Counter.pushWindow bL w ls₀ == ls'
| x => false
| x => false) =
truehms:Counter.multiStepWindow bL bR M n { q := q, cur := a, l := ls, r := rs₀ } =
some { q := q', cur := a', l := ls', r := rs₀' }⊢ ((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{n} (ls' +> l) {{q'}}> (a' :: rs₀') +> r
have hsnd := Counter.multiStepWindow_sound l r hL hR n _ _ hms cons.cons Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λn:ℕq:Λls:List Γq':Λls':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulta:Γrs₀:List Γa':Γrs₀':List Γh:(match a :: rs₀ with
| [] =>
if (!bR) = true then false
else
match a' :: rs₀' with
| a' :: rs₀' =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := a', l := ls', r := rs₀' }
| [] =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := default, l := ls', r := [] }
| a :: rs₀ =>
match a' :: rs₀' with
| a' :: rs₀' =>
Counter.multiStepWindow bL bR M n { q := q, cur := a, l := ls, r := rs₀ } ==
some { q := q', cur := a', l := ls', r := rs₀' }
| [] =>
if bR = true then
Counter.multiStepWindow bL true M n { q := q, cur := a, l := ls, r := rs₀ } ==
some { q := q', cur := default, l := ls', r := [] }
else
match n with
| 0 => false
| m.succ =>
match Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } with
| some { q := q₀, cur := x, l := ls₀, r := [] } =>
match M q₀ x with
| some (some q₁, { symbol := w, dir := Dir.right }) => q₁ == q' && Counter.pushWindow bL w ls₀ == ls'
| x => false
| x => false) =
truehms:Counter.multiStepWindow bL bR M n { q := q, cur := a, l := ls, r := rs₀ } =
some { q := q', cur := a', l := ls', r := rs₀' }hsnd:Counter.evalWindow l r { q := q, cur := a, l := ls, r := rs₀ } [M]⊢^{n}
Counter.evalWindow l r { q := q', cur := a', l := ls', r := rs₀' }⊢ ((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{n} (ls' +> l) {{q'}}> (a' :: rs₀') +> r
rwa [evalWindow_eq_headRight_cons, evalWindow_eq_headRight_cons] at hsnd All goals completed! 🐙
| nil => cons.nil Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λn:ℕq:Λls:List Γq':Λls':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulta:Γrs₀:List Γh:(match a :: rs₀ with
| [] =>
if (!bR) = true then false
else
match [] with
| a' :: rs₀' =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := a', l := ls', r := rs₀' }
| [] =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := default, l := ls', r := [] }
| a :: rs₀ =>
match [] with
| a' :: rs₀' =>
Counter.multiStepWindow bL bR M n { q := q, cur := a, l := ls, r := rs₀ } ==
some { q := q', cur := a', l := ls', r := rs₀' }
| [] =>
if bR = true then
Counter.multiStepWindow bL true M n { q := q, cur := a, l := ls, r := rs₀ } ==
some { q := q', cur := default, l := ls', r := [] }
else
match n with
| 0 => false
| m.succ =>
match Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } with
| some { q := q₀, cur := x, l := ls₀, r := [] } =>
match M q₀ x with
| some (some q₁, { symbol := w, dir := Dir.right }) => q₁ == q' && Counter.pushWindow bL w ls₀ == ls'
| x => false
| x => false) =
true⊢ ((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{n} (ls' +> l) {{q'}}> [] +> r
cases hbR : bR with
| true => cons.nil.true Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λn:ℕq:Λls:List Γq':Λls':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulta:Γrs₀:List Γh:(match a :: rs₀ with
| [] =>
if (!bR) = true then false
else
match [] with
| a' :: rs₀' =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := a', l := ls', r := rs₀' }
| [] =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := default, l := ls', r := [] }
| a :: rs₀ =>
match [] with
| a' :: rs₀' =>
Counter.multiStepWindow bL bR M n { q := q, cur := a, l := ls, r := rs₀ } ==
some { q := q', cur := a', l := ls', r := rs₀' }
| [] =>
if bR = true then
Counter.multiStepWindow bL true M n { q := q, cur := a, l := ls, r := rs₀ } ==
some { q := q', cur := default, l := ls', r := [] }
else
match n with
| 0 => false
| m.succ =>
match Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } with
| some { q := q₀, cur := x, l := ls₀, r := [] } =>
match M q₀ x with
| some (some q₁, { symbol := w, dir := Dir.right }) => q₁ == q' && Counter.pushWindow bL w ls₀ == ls'
| x => false
| x => false) =
truehbR:bR = true⊢ ((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{n} (ls' +> l) {{q'}}> [] +> r
simp only [hbR, ↓reduceIte] at h cons.nil.true Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λn:ℕq:Λls:List Γq':Λls':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulta:Γrs₀:List ΓhbR:bR = trueh:(Counter.multiStepWindow bL true M n { q := q, cur := a, l := ls, r := rs₀ } ==
some { q := q', cur := default, l := ls', r := [] }) =
true⊢ ((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{n} (ls' +> l) {{q'}}> [] +> r
have hr_def := hR hbR cons.nil.true Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λn:ℕq:Λls:List Γq':Λls':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulta:Γrs₀:List ΓhbR:bR = trueh:(Counter.multiStepWindow bL true M n { q := q, cur := a, l := ls, r := rs₀ } ==
some { q := q', cur := default, l := ls', r := [] }) =
truehr_def:r = default⊢ ((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{n} (ls' +> l) {{q'}}> [] +> r
subst hr_def cons.nil.true Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λn:ℕq:Λls:List Γq':Λls':List Γl:ListBlank ΓhL:bL = true → l = defaulta:Γrs₀:List ΓhbR:bR = trueh:(Counter.multiStepWindow bL true M n { q := q, cur := a, l := ls, r := rs₀ } ==
some { q := q', cur := default, l := ls', r := [] }) =
truehR:bR = true → default = default⊢ ((ls +> l) {{q}}> (a :: rs₀) +> default) [M]⊢^{n} (ls' +> l) {{q'}}> [] +> default
have hms := eq_of_beq h cons.nil.true Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λn:ℕq:Λls:List Γq':Λls':List Γl:ListBlank ΓhL:bL = true → l = defaulta:Γrs₀:List ΓhbR:bR = trueh:(Counter.multiStepWindow bL true M n { q := q, cur := a, l := ls, r := rs₀ } ==
some { q := q', cur := default, l := ls', r := [] }) =
truehR:bR = true → default = defaulthms:Counter.multiStepWindow bL true M n { q := q, cur := a, l := ls, r := rs₀ } =
some { q := q', cur := default, l := ls', r := [] }⊢ ((ls +> l) {{q}}> (a :: rs₀) +> default) [M]⊢^{n} (ls' +> l) {{q'}}> [] +> default
have hsnd := Counter.multiStepWindow_sound l default hL (fun _ => rfl) n _ _ hms cons.nil.true Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λn:ℕq:Λls:List Γq':Λls':List Γl:ListBlank ΓhL:bL = true → l = defaulta:Γrs₀:List ΓhbR:bR = trueh:(Counter.multiStepWindow bL true M n { q := q, cur := a, l := ls, r := rs₀ } ==
some { q := q', cur := default, l := ls', r := [] }) =
truehR:bR = true → default = defaulthms:Counter.multiStepWindow bL true M n { q := q, cur := a, l := ls, r := rs₀ } =
some { q := q', cur := default, l := ls', r := [] }hsnd:Counter.evalWindow l default { q := q, cur := a, l := ls, r := rs₀ } [M]⊢^{n}
Counter.evalWindow l default { q := q', cur := default, l := ls', r := [] }⊢ ((ls +> l) {{q}}> (a :: rs₀) +> default) [M]⊢^{n} (ls' +> l) {{q'}}> [] +> default
rwa [evalWindow_eq_headRight_cons, evalWindow_eq_headRight_nil] at hsnd All goals completed! 🐙
| false => cons.nil.false Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λn:ℕq:Λls:List Γq':Λls':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulta:Γrs₀:List Γh:(match a :: rs₀ with
| [] =>
if (!bR) = true then false
else
match [] with
| a' :: rs₀' =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := a', l := ls', r := rs₀' }
| [] =>
Counter.multiStepWindow bL true M n { q := q, cur := default, l := ls, r := [] } ==
some { q := q', cur := default, l := ls', r := [] }
| a :: rs₀ =>
match [] with
| a' :: rs₀' =>
Counter.multiStepWindow bL bR M n { q := q, cur := a, l := ls, r := rs₀ } ==
some { q := q', cur := a', l := ls', r := rs₀' }
| [] =>
if bR = true then
Counter.multiStepWindow bL true M n { q := q, cur := a, l := ls, r := rs₀ } ==
some { q := q', cur := default, l := ls', r := [] }
else
match n with
| 0 => false
| m.succ =>
match Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } with
| some { q := q₀, cur := x, l := ls₀, r := [] } =>
match M q₀ x with
| some (some q₁, { symbol := w, dir := Dir.right }) => q₁ == q' && Counter.pushWindow bL w ls₀ == ls'
| x => false
| x => false) =
truehbR:bR = false⊢ ((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{n} (ls' +> l) {{q'}}> [] +> r
simp only [hbR, Bool.false_eq_true, ↓reduceIte] at h cons.nil.false Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λn:ℕq:Λls:List Γq':Λls':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulta:Γrs₀:List ΓhbR:bR = falseh:(match n with
| 0 => false
| m.succ =>
match Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } with
| some { q := q₀, cur := x, l := ls₀, r := [] } =>
match M q₀ x with
| some (some q₁, { symbol := w, dir := Dir.right }) => q₁ == q' && Counter.pushWindow bL w ls₀ == ls'
| x => false
| x => false) =
true⊢ ((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{n} (ls' +> l) {{q'}}> [] +> r
cases n with
| zero => cons.nil.false.zero Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λq:Λls:List Γq':Λls':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulta:Γrs₀:List ΓhbR:bR = falseh:(match 0 with
| 0 => false
| m.succ =>
match Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } with
| some { q := q₀, cur := x, l := ls₀, r := [] } =>
match M q₀ x with
| some (some q₁, { symbol := w, dir := Dir.right }) => q₁ == q' && Counter.pushWindow bL w ls₀ == ls'
| x => false
| x => false) =
true⊢ ((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{0} (ls' +> l) {{q'}}> [] +> r nomatch h All goals completed! 🐙
| succ m => cons.nil.false.succ Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λq:Λls:List Γq':Λls':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulta:Γrs₀:List ΓhbR:bR = falsem:ℕh:(match m + 1 with
| 0 => false
| m.succ =>
match Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } with
| some { q := q₀, cur := x, l := ls₀, r := [] } =>
match M q₀ x with
| some (some q₁, { symbol := w, dir := Dir.right }) => q₁ == q' && Counter.pushWindow bL w ls₀ == ls'
| x => false
| x => false) =
true⊢ ((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{m + 1} (ls' +> l) {{q'}}> [] +> r
dsimp only at h cons.nil.false.succ Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λq:Λls:List Γq':Λls':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulta:Γrs₀:List ΓhbR:bR = falsem:ℕh:(match Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } with
| some { q := q₀, cur := x, l := ls₀, r := [] } =>
match M q₀ x with
| some (some q₁, { symbol := w, dir := Dir.right }) => q₁ == q' && Counter.pushWindow bL w ls₀ == ls'
| x => false
| x => false) =
true⊢ ((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{m + 1} (ls' +> l) {{q'}}> [] +> r
split at h h_1 Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λq:Λls:List Γq':Λls':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulta:Γrs₀:List ΓhbR:bR = falsem:ℕx✝¹:Option (Counter.CCfg Γ Λ)q₀✝:Λx✝:Γls₀✝:List Γheq✝:Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } =
some { q := q₀✝, cur := x✝, l := ls₀✝, r := [] }h:(match M q₀✝ x✝ with
| some (some q₁, { symbol := w, dir := Dir.right }) => q₁ == q' && Counter.pushWindow bL w ls₀✝ == ls'
| x => false) =
true⊢ ((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{m + 1} (ls' +> l) {{q'}}> [] +> rh_2 Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λq:Λls:List Γq':Λls':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulta:Γrs₀:List ΓhbR:bR = falsem:ℕx✝¹:Option (Counter.CCfg Γ Λ)x✝:∀ (q₀ : Λ) (x : Γ) (ls₀ : List Γ),
Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } =
some { q := q₀, cur := x, l := ls₀, r := [] } →
Falseh:false = true⊢ ((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{m + 1} (ls' +> l) {{q'}}> [] +> r
· h_1 Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λq:Λls:List Γq':Λls':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulta:Γrs₀:List ΓhbR:bR = falsem:ℕx✝¹:Option (Counter.CCfg Γ Λ)q₀✝:Λx✝:Γls₀✝:List Γheq✝:Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } =
some { q := q₀✝, cur := x✝, l := ls₀✝, r := [] }h:(match M q₀✝ x✝ with
| some (some q₁, { symbol := w, dir := Dir.right }) => q₁ == q' && Counter.pushWindow bL w ls₀✝ == ls'
| x => false) =
true⊢ ((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{m + 1} (ls' +> l) {{q'}}> [] +> r next val q₀ x ls₀ hms => Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λq:Λls:List Γq':Λls':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulta:Γrs₀:List ΓhbR:bR = falsem:ℕval:Option (Counter.CCfg Γ Λ)q₀:Λx:Γls₀:List Γhms:Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } =
some { q := q₀✝, cur := x✝, l := ls₀✝, r := [] }h:(match M q₀✝ x✝ with
| some (some q₁, { symbol := w, dir := Dir.right }) => q₁ == q' && Counter.pushWindow bL w ls₀✝ == ls'
| x => false) =
true⊢ ((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{m + 1} (ls' +> l) {{q'}}> [] +> r
split at h h_1 Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λq:Λls:List Γq':Λls':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulta:Γrs₀:List ΓhbR:bR = falsem:ℕval:Option (Counter.CCfg Γ Λ)q₀:Λx:Γls₀:List Γhms:Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } =
some { q := q₀✝, cur := x✝, l := ls₀✝, r := [] }x✝:Option (Option Λ × Stmt Γ)q₁✝:Λw✝:Γheq✝:M q₀ x = some (some q₁✝, { symbol := w✝, dir := Dir.right })h:(q₁✝ == q' && Counter.pushWindow bL w✝ ls₀ == ls') = true⊢ ((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{m + 1} (ls' +> l) {{q'}}> [] +> rh_2 Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λq:Λls:List Γq':Λls':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulta:Γrs₀:List ΓhbR:bR = falsem:ℕval:Option (Counter.CCfg Γ Λ)q₀:Λx:Γls₀:List Γhms:Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } =
some { q := q₀✝, cur := x✝, l := ls₀✝, r := [] }x✝¹:Option (Option Λ × Stmt Γ)x✝:∀ (q₁ : Λ) (w : Γ), M q₀ x = some (some q₁, { symbol := w, dir := Dir.right }) → Falseh:false = true⊢ ((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{m + 1} (ls' +> l) {{q'}}> [] +> r
· h_1 Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λq:Λls:List Γq':Λls':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulta:Γrs₀:List ΓhbR:bR = falsem:ℕval:Option (Counter.CCfg Γ Λ)q₀:Λx:Γls₀:List Γhms:Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } =
some { q := q₀✝, cur := x✝, l := ls₀✝, r := [] }x✝:Option (Option Λ × Stmt Γ)q₁✝:Λw✝:Γheq✝:M q₀ x = some (some q₁✝, { symbol := w✝, dir := Dir.right })h:(q₁✝ == q' && Counter.pushWindow bL w✝ ls₀ == ls') = true⊢ ((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{m + 1} (ls' +> l) {{q'}}> [] +> r next htm q_opt stmt => Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λq:Λls:List Γq':Λls':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulta:Γrs₀:List ΓhbR:bR = falsem:ℕval:Option (Counter.CCfg Γ Λ)q₀:Λx:Γls₀:List Γhms:Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } =
some { q := q₀✝, cur := x✝, l := ls₀✝, r := [] }x✝:Option (Option Λ × Stmt Γ)htm:Λq_opt:Γstmt:M q₀ x = some (some q₁✝, { symbol := w✝, dir := Dir.right })h:(q₁✝ == q' && Counter.pushWindow bL w✝ ls₀ == ls') = true⊢ ((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{m + 1} (ls' +> l) {{q'}}> [] +> r
simp only [Bool.and_eq_true, beq_iff_eq] at h Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λq:Λls:List Γq':Λls':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulta:Γrs₀:List ΓhbR:bR = falsem:ℕval:Option (Counter.CCfg Γ Λ)q₀:Λx:Γls₀:List Γhms:Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } =
some { q := q₀✝, cur := x✝, l := ls₀✝, r := [] }x✝:Option (Option Λ × Stmt Γ)htm:Λq_opt:Γstmt:M q₀ x = some (some q₁✝, { symbol := w✝, dir := Dir.right })h:htm = q' ∧ Counter.pushWindow bL q_opt ls₀ = ls'⊢ ((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{m + 1} (ls' +> l) {{q'}}> [] +> r
rcases h with ⟨rfl, hpush⟩ Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λq:Λls:List Γls':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulta:Γrs₀:List ΓhbR:bR = falsem:ℕval:Option (Counter.CCfg Γ Λ)q₀:Λx:Γls₀:List Γhms:Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } =
some { q := q₀✝, cur := x✝, l := ls₀✝, r := [] }x✝:Option (Option Λ × Stmt Γ)htm:Λq_opt:Γstmt:M q₀ x = some (some q₁✝, { symbol := w✝, dir := Dir.right })hpush:Counter.pushWindow bL q_opt ls₀ = ls'⊢ ((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{m + 1} (ls' +> l) {{htm}}> [] +> r
have hsnd := Counter.multiStepWindow_sound l r hL
(by Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λq:Λls:List Γls':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulta:Γrs₀:List ΓhbR:bR = falsem:ℕval:Option (Counter.CCfg Γ Λ)q₀:Λx:Γls₀:List Γhms:Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } =
some { q := q₀✝, cur := x✝, l := ls₀✝, r := [] }x✝:Option (Option Λ × Stmt Γ)htm:Λq_opt:Γstmt:M q₀ x = some (some q₁✝, { symbol := w✝, dir := Dir.right })hpush:Counter.pushWindow bL q_opt ls₀ = ls'⊢ false = true → r = default intro hc Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λq:Λls:List Γls':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulta:Γrs₀:List ΓhbR:bR = falsem:ℕval:Option (Counter.CCfg Γ Λ)q₀:Λx:Γls₀:List Γhms:Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } =
some { q := q₀✝, cur := x✝, l := ls₀✝, r := [] }x✝:Option (Option Λ × Stmt Γ)htm:Λq_opt:Γstmt:M q₀ x = some (some q₁✝, { symbol := w✝, dir := Dir.right })hpush:Counter.pushWindow bL q_opt ls₀ = ls'hc:false = true⊢ r = default; contradiction All goals completed! 🐙) m _ _ hms Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λq:Λls:List Γls':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulta:Γrs₀:List ΓhbR:bR = falsem:ℕval:Option (Counter.CCfg Γ Λ)q₀:Λx:Γls₀:List Γhms:Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } =
some { q := q₀✝, cur := x✝, l := ls₀✝, r := [] }x✝:Option (Option Λ × Stmt Γ)htm:Λq_opt:Γstmt:M q₀ x = some (some q₁✝, { symbol := w✝, dir := Dir.right })hpush:Counter.pushWindow bL q_opt ls₀ = ls'hsnd:Counter.evalWindow l r { q := q, cur := a, l := ls, r := rs₀ } [M]⊢^{m}
Counter.evalWindow l r { q := q₀, cur := x, l := ls₀, r := [] }⊢ ((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{m + 1} (ls' +> l) {{htm}}> [] +> r
rw [evalWindow_eq_headRight_cons, Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λq:Λls:List Γls':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulta:Γrs₀:List ΓhbR:bR = falsem:ℕval:Option (Counter.CCfg Γ Λ)q₀:Λx:Γls₀:List Γhms:Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } =
some { q := q₀✝, cur := x✝, l := ls₀✝, r := [] }x✝:Option (Option Λ × Stmt Γ)htm:Λq_opt:Γstmt:M q₀ x = some (some q₁✝, { symbol := w✝, dir := Dir.right })hpush:Counter.pushWindow bL q_opt ls₀ = ls'hsnd:((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{m} Counter.evalWindow l r { q := q₀, cur := x, l := ls₀, r := [] }⊢ ((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{m + 1} (ls' +> l) {{htm}}> [] +> r
evalWindow_eq_headRight_cons Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λq:Λls:List Γls':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulta:Γrs₀:List ΓhbR:bR = falsem:ℕval:Option (Counter.CCfg Γ Λ)q₀:Λx:Γls₀:List Γhms:Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } =
some { q := q₀✝, cur := x✝, l := ls₀✝, r := [] }x✝:Option (Option Λ × Stmt Γ)htm:Λq_opt:Γstmt:M q₀ x = some (some q₁✝, { symbol := w✝, dir := Dir.right })hpush:Counter.pushWindow bL q_opt ls₀ = ls'hsnd:((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{m} (ls₀ +> l) {{q₀}}> [x] +> r⊢ ((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{m + 1} (ls' +> l) {{htm}}> [] +> r] at hsnd Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λq:Λls:List Γls':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulta:Γrs₀:List ΓhbR:bR = falsem:ℕval:Option (Counter.CCfg Γ Λ)q₀:Λx:Γls₀:List Γhms:Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } =
some { q := q₀✝, cur := x✝, l := ls₀✝, r := [] }x✝:Option (Option Λ × Stmt Γ)htm:Λq_opt:Γstmt:M q₀ x = some (some q₁✝, { symbol := w✝, dir := Dir.right })hpush:Counter.pushWindow bL q_opt ls₀ = ls'hsnd:((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{m} (ls₀ +> l) {{q₀}}> [x] +> r⊢ ((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{m + 1} (ls' +> l) {{htm}}> [] +> r
have hstep1 : (((ls₀ +> l) {{q₀}}> ([x] +> r)) [M]⊢
((ls' +> l) {{htm}}> ([] +> r))) := by Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λn:ℕq:Λls:List Γrs:List Γq':Λls':List Γrs':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulth:checkHeadRight bL bR M n q ls rs q' ls' rs' = true⊢ ((ls +> l) {{q}}> rs +> r) [M]⊢^{n} (ls' +> l) {{q'}}> rs' +> r
rw [← hpush, Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λq:Λls:List Γls':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulta:Γrs₀:List ΓhbR:bR = falsem:ℕval:Option (Counter.CCfg Γ Λ)q₀:Λx:Γls₀:List Γhms:Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } =
some { q := q₀✝, cur := x✝, l := ls₀✝, r := [] }x✝:Option (Option Λ × Stmt Γ)htm:Λq_opt:Γstmt:M q₀ x = some (some q₁✝, { symbol := w✝, dir := Dir.right })hpush:Counter.pushWindow bL q_opt ls₀ = ls'hsnd:((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{m} (ls₀ +> l) {{q₀}}> [x] +> r⊢ ((ls₀ +> l) {{q₀}}> [x] +> r) [M]⊢ (Counter.pushWindow bL q_opt ls₀ +> l) {{htm}}> [] +> r Counter.pushWindow_append q_opt ls₀ l hL Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λq:Λls:List Γls':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulta:Γrs₀:List ΓhbR:bR = falsem:ℕval:Option (Counter.CCfg Γ Λ)q₀:Λx:Γls₀:List Γhms:Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } =
some { q := q₀✝, cur := x✝, l := ls₀✝, r := [] }x✝:Option (Option Λ × Stmt Γ)htm:Λq_opt:Γstmt:M q₀ x = some (some q₁✝, { symbol := w✝, dir := Dir.right })hpush:Counter.pushWindow bL q_opt ls₀ = ls'hsnd:((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{m} (ls₀ +> l) {{q₀}}> [x] +> r⊢ ((ls₀ +> l) {{q₀}}> [x] +> r) [M]⊢ (q_opt >> ls₀ +> l) {{htm}}> [] +> r] Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λq:Λls:List Γls':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulta:Γrs₀:List ΓhbR:bR = falsem:ℕval:Option (Counter.CCfg Γ Λ)q₀:Λx:Γls₀:List Γhms:Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } =
some { q := q₀✝, cur := x✝, l := ls₀✝, r := [] }x✝:Option (Option Λ × Stmt Γ)htm:Λq_opt:Γstmt:M q₀ x = some (some q₁✝, { symbol := w✝, dir := Dir.right })hpush:Counter.pushWindow bL q_opt ls₀ = ls'hsnd:((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{m} (ls₀ +> l) {{q₀}}> [x] +> r⊢ ((ls₀ +> l) {{q₀}}> [x] +> r) [M]⊢ (q_opt >> ls₀ +> l) {{htm}}> [] +> r
simp [step, stmt, Turing.Tape.write, Turing.Tape.move] Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λq:Λls:List Γls':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulta:Γrs₀:List ΓhbR:bR = falsem:ℕval:Option (Counter.CCfg Γ Λ)q₀:Λx:Γls₀:List Γhms:Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } =
some { q := q₀✝, cur := x✝, l := ls₀✝, r := [] }x✝:Option (Option Λ × Stmt Γ)htm:Λq_opt:Γstmt:M q₀ x = some (some q₁✝, { symbol := w✝, dir := Dir.right })hpush:Counter.pushWindow bL q_opt ls₀ = ls'hsnd:((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{m} (ls₀ +> l) {{q₀}}> [x] +> rhstep1:((ls₀ +> l) {{q₀}}> [x] +> r) [M]⊢ (ls' +> l) {{htm}}> [] +> r⊢ ((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{m + 1} (ls' +> l) {{htm}}> [] +> r
exact Counter.multiStep_trans M _ _ _ m 1 hsnd hstep1 All goals completed! 🐙
· h_2 Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λq:Λls:List Γq':Λls':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulta:Γrs₀:List ΓhbR:bR = falsem:ℕval:Option (Counter.CCfg Γ Λ)q₀:Λx:Γls₀:List Γhms:Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } =
some { q := q₀✝, cur := x✝, l := ls₀✝, r := [] }x✝¹:Option (Option Λ × Stmt Γ)x✝:∀ (q₁ : Λ) (w : Γ), M q₀ x = some (some q₁, { symbol := w, dir := Dir.right }) → Falseh:false = true⊢ ((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{m + 1} (ls' +> l) {{q'}}> [] +> r nomatch h All goals completed! 🐙
· h_2 Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛbL:BoolbR:BoolM:Machine Γ Λq:Λls:List Γq':Λls':List Γl:ListBlank Γr:ListBlank ΓhL:bL = true → l = defaulthR:bR = true → r = defaulta:Γrs₀:List ΓhbR:bR = falsem:ℕx✝¹:Option (Counter.CCfg Γ Λ)x✝:∀ (q₀ : Λ) (x : Γ) (ls₀ : List Γ),
Counter.multiStepWindow bL false M m { q := q, cur := a, l := ls, r := rs₀ } =
some { q := q₀, cur := x, l := ls₀, r := [] } →
Falseh:false = true⊢ ((ls +> l) {{q}}> (a :: rs₀) +> r) [M]⊢^{m + 1} (ls' +> l) {{q'}}> [] +> r nomatch h All goals completed! 🐙Inductive rightward word-run transducer walk.
theorem walkWordRight {Γ Λ : Type*} [DecidableEq Γ] [DecidableEq Λ]
[Inhabited Γ] [Inhabited Λ]
{M : Machine Γ Λ} (s : ℕ) (q : Λ) (pL u pR v : List Γ)
(hbody : checkHeadRight false false M s q pL (pR ++ v) q (pL ++ u) pR = true) :
∀ (k : ℕ) (l r : ListBlank Γ),
((pL +> l) {{q}}> (pR +> ((v ^ k) +> r))) [M]⊢^{s * k}
((pL +> ((u ^ k) +> l)) {{q}}> (pR +> r))
| 0, l, r => Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q pL (pR ++ v) q (pL ++ u) pR = truel:ListBlank Γr:ListBlank Γ⊢ ((pL +> l) {{q}}> pR +> v ^ 0 +> r) [M]⊢^{s * 0} (pL +> u ^ 0 +> l) {{q}}> pR +> r by Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q pL (pR ++ v) q (pL ++ u) pR = truel:ListBlank Γr:ListBlank Γ⊢ ((pL +> l) {{q}}> pR +> v ^ 0 +> r) [M]⊢^{s * 0} (pL +> u ^ 0 +> l) {{q}}> pR +> r simp All goals completed! 🐙
| k + 1, l, r => Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q pL (pR ++ v) q (pL ++ u) pR = truek:ℕl:ListBlank Γr:ListBlank Γ⊢ ((pL +> l) {{q}}> pR +> v ^ (k + 1) +> r) [M]⊢^{s * (k + 1)} (pL +> u ^ (k + 1) +> l) {{q}}> pR +> r by Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q pL (pR ++ v) q (pL ++ u) pR = truek:ℕl:ListBlank Γr:ListBlank Γ⊢ ((pL +> l) {{q}}> pR +> v ^ (k + 1) +> r) [M]⊢^{s * (k + 1)} (pL +> u ^ (k + 1) +> l) {{q}}> pR +> r
rw [Counter.pow_succ_list, Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q pL (pR ++ v) q (pL ++ u) pR = truek:ℕl:ListBlank Γr:ListBlank Γ⊢ ((pL +> l) {{q}}> pR +> (v ++ v ^ k) +> r) [M]⊢^{s * (k + 1)} (pL +> u ^ (k + 1) +> l) {{q}}> pR +> r append_assoc_blank v (v ^ k) r, Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q pL (pR ++ v) q (pL ++ u) pR = truek:ℕl:ListBlank Γr:ListBlank Γ⊢ ((pL +> l) {{q}}> pR +> v +> v ^ k +> r) [M]⊢^{s * (k + 1)} (pL +> u ^ (k + 1) +> l) {{q}}> pR +> r
← append_assoc_blank pR v ((v ^ k) +> r) Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q pL (pR ++ v) q (pL ++ u) pR = truek:ℕl:ListBlank Γr:ListBlank Γ⊢ ((pL +> l) {{q}}> (pR ++ v) +> v ^ k +> r) [M]⊢^{s * (k + 1)} (pL +> u ^ (k + 1) +> l) {{q}}> pR +> r] Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q pL (pR ++ v) q (pL ++ u) pR = truek:ℕl:ListBlank Γr:ListBlank Γ⊢ ((pL +> l) {{q}}> (pR ++ v) +> v ^ k +> r) [M]⊢^{s * (k + 1)} (pL +> u ^ (k + 1) +> l) {{q}}> pR +> r
have h1 := @checkHeadRight_sound Γ Λ _ _ _ _ false false M s q pL (pR ++ v) q (pL ++ u) pR
l ((v ^ k) +> r) (by Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q pL (pR ++ v) q (pL ++ u) pR = truek:ℕl:ListBlank Γr:ListBlank Γ⊢ false = true → l = default intro hc Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q pL (pR ++ v) q (pL ++ u) pR = truek:ℕl:ListBlank Γr:ListBlank Γhc:false = true⊢ l = default; contradiction All goals completed! 🐙) (by Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q pL (pR ++ v) q (pL ++ u) pR = truek:ℕl:ListBlank Γr:ListBlank Γ⊢ false = true → v ^ k +> r = default intro hc Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q pL (pR ++ v) q (pL ++ u) pR = truek:ℕl:ListBlank Γr:ListBlank Γhc:false = true⊢ v ^ k +> r = default; contradiction All goals completed! 🐙) hbody Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q pL (pR ++ v) q (pL ++ u) pR = truek:ℕl:ListBlank Γr:ListBlank Γh1:((pL +> l) {{q}}> (pR ++ v) +> v ^ k +> r) [M]⊢^{s} ((pL ++ u) +> l) {{q}}> pR +> v ^ k +> r⊢ ((pL +> l) {{q}}> (pR ++ v) +> v ^ k +> r) [M]⊢^{s * (k + 1)} (pL +> u ^ (k + 1) +> l) {{q}}> pR +> r
rw [append_assoc_blank pL u l Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q pL (pR ++ v) q (pL ++ u) pR = truek:ℕl:ListBlank Γr:ListBlank Γh1:((pL +> l) {{q}}> (pR ++ v) +> v ^ k +> r) [M]⊢^{s} (pL +> u +> l) {{q}}> pR +> v ^ k +> r⊢ ((pL +> l) {{q}}> (pR ++ v) +> v ^ k +> r) [M]⊢^{s * (k + 1)} (pL +> u ^ (k + 1) +> l) {{q}}> pR +> r] at h1 Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q pL (pR ++ v) q (pL ++ u) pR = truek:ℕl:ListBlank Γr:ListBlank Γh1:((pL +> l) {{q}}> (pR ++ v) +> v ^ k +> r) [M]⊢^{s} (pL +> u +> l) {{q}}> pR +> v ^ k +> r⊢ ((pL +> l) {{q}}> (pR ++ v) +> v ^ k +> r) [M]⊢^{s * (k + 1)} (pL +> u ^ (k + 1) +> l) {{q}}> pR +> r
have h2 := walkWordRight s q pL u pR v hbody k (u +> l) r Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q pL (pR ++ v) q (pL ++ u) pR = truek:ℕl:ListBlank Γr:ListBlank Γh1:((pL +> l) {{q}}> (pR ++ v) +> v ^ k +> r) [M]⊢^{s} (pL +> u +> l) {{q}}> pR +> v ^ k +> rh2:((pL +> u +> l) {{q}}> pR +> v ^ k +> r) [M]⊢^{s * k} (pL +> u ^ k +> u +> l) {{q}}> pR +> r⊢ ((pL +> l) {{q}}> (pR ++ v) +> v ^ k +> r) [M]⊢^{s * (k + 1)} (pL +> u ^ (k + 1) +> l) {{q}}> pR +> r
rw [← append_assoc_blank (u ^ k) u l, Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q pL (pR ++ v) q (pL ++ u) pR = truek:ℕl:ListBlank Γr:ListBlank Γh1:((pL +> l) {{q}}> (pR ++ v) +> v ^ k +> r) [M]⊢^{s} (pL +> u +> l) {{q}}> pR +> v ^ k +> rh2:((pL +> u +> l) {{q}}> pR +> v ^ k +> r) [M]⊢^{s * k} (pL +> (u ^ k ++ u) +> l) {{q}}> pR +> r⊢ ((pL +> l) {{q}}> (pR ++ v) +> v ^ k +> r) [M]⊢^{s * (k + 1)} (pL +> u ^ (k + 1) +> l) {{q}}> pR +> r ← Counter.pow_succ_right Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q pL (pR ++ v) q (pL ++ u) pR = truek:ℕl:ListBlank Γr:ListBlank Γh1:((pL +> l) {{q}}> (pR ++ v) +> v ^ k +> r) [M]⊢^{s} (pL +> u +> l) {{q}}> pR +> v ^ k +> rh2:((pL +> u +> l) {{q}}> pR +> v ^ k +> r) [M]⊢^{s * k} (pL +> u ^ (k + 1) +> l) {{q}}> pR +> r⊢ ((pL +> l) {{q}}> (pR ++ v) +> v ^ k +> r) [M]⊢^{s * (k + 1)} (pL +> u ^ (k + 1) +> l) {{q}}> pR +> r] at h2 Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q pL (pR ++ v) q (pL ++ u) pR = truek:ℕl:ListBlank Γr:ListBlank Γh1:((pL +> l) {{q}}> (pR ++ v) +> v ^ k +> r) [M]⊢^{s} (pL +> u +> l) {{q}}> pR +> v ^ k +> rh2:((pL +> u +> l) {{q}}> pR +> v ^ k +> r) [M]⊢^{s * k} (pL +> u ^ (k + 1) +> l) {{q}}> pR +> r⊢ ((pL +> l) {{q}}> (pR ++ v) +> v ^ k +> r) [M]⊢^{s * (k + 1)} (pL +> u ^ (k + 1) +> l) {{q}}> pR +> r
rw [show s * (k + 1) = s + s * k by Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q pL (pR ++ v) q (pL ++ u) pR = truek:ℕl:ListBlank Γr:ListBlank Γ⊢ ((pL +> l) {{q}}> pR +> v ^ (k + 1) +> r) [M]⊢^{s * (k + 1)} (pL +> u ^ (k + 1) +> l) {{q}}> pR +> r ring All goals completed! 🐙] Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q pL (pR ++ v) q (pL ++ u) pR = truek:ℕl:ListBlank Γr:ListBlank Γh1:((pL +> l) {{q}}> (pR ++ v) +> v ^ k +> r) [M]⊢^{s} (pL +> u +> l) {{q}}> pR +> v ^ k +> rh2:((pL +> u +> l) {{q}}> pR +> v ^ k +> r) [M]⊢^{s * k} (pL +> u ^ (k + 1) +> l) {{q}}> pR +> r⊢ ((pL +> l) {{q}}> (pR ++ v) +> v ^ k +> r) [M]⊢^{s + s * k} (pL +> u ^ (k + 1) +> l) {{q}}> pR +> r
exact Counter.multiStep_trans M _ _ _ s (s * k) h1 h2 All goals completed! 🐙Inductive leftward word-run transducer walk.
theorem walkWordLeft {Γ Λ : Type*} [DecidableEq Γ] [DecidableEq Λ]
[Inhabited Γ] [Inhabited Λ]
{M : Machine Γ Λ} (s : ℕ) (q : Λ) (pL u pR v : List Γ)
(hbody : checkHeadRight false false M s q (pL ++ u) pR q pL (pR ++ v) = true) :
∀ (k : ℕ) (l r : ListBlank Γ),
((pL +> ((u ^ k) +> l)) {{q}}> (pR +> r)) [M]⊢^{s * k}
((pL +> l) {{q}}> (pR +> ((v ^ k) +> r)))
| 0, l, r => Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q (pL ++ u) pR q pL (pR ++ v) = truel:ListBlank Γr:ListBlank Γ⊢ ((pL +> u ^ 0 +> l) {{q}}> pR +> r) [M]⊢^{s * 0} (pL +> l) {{q}}> pR +> v ^ 0 +> r by Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q (pL ++ u) pR q pL (pR ++ v) = truel:ListBlank Γr:ListBlank Γ⊢ ((pL +> u ^ 0 +> l) {{q}}> pR +> r) [M]⊢^{s * 0} (pL +> l) {{q}}> pR +> v ^ 0 +> r simp All goals completed! 🐙
| k + 1, l, r => Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q (pL ++ u) pR q pL (pR ++ v) = truek:ℕl:ListBlank Γr:ListBlank Γ⊢ ((pL +> u ^ (k + 1) +> l) {{q}}> pR +> r) [M]⊢^{s * (k + 1)} (pL +> l) {{q}}> pR +> v ^ (k + 1) +> r by Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q (pL ++ u) pR q pL (pR ++ v) = truek:ℕl:ListBlank Γr:ListBlank Γ⊢ ((pL +> u ^ (k + 1) +> l) {{q}}> pR +> r) [M]⊢^{s * (k + 1)} (pL +> l) {{q}}> pR +> v ^ (k + 1) +> r
rw [Counter.pow_succ_list, Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q (pL ++ u) pR q pL (pR ++ v) = truek:ℕl:ListBlank Γr:ListBlank Γ⊢ ((pL +> (u ++ u ^ k) +> l) {{q}}> pR +> r) [M]⊢^{s * (k + 1)} (pL +> l) {{q}}> pR +> v ^ (k + 1) +> r append_assoc_blank u (u ^ k) l, Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q (pL ++ u) pR q pL (pR ++ v) = truek:ℕl:ListBlank Γr:ListBlank Γ⊢ ((pL +> u +> u ^ k +> l) {{q}}> pR +> r) [M]⊢^{s * (k + 1)} (pL +> l) {{q}}> pR +> v ^ (k + 1) +> r
← append_assoc_blank pL u ((u ^ k) +> l) Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q (pL ++ u) pR q pL (pR ++ v) = truek:ℕl:ListBlank Γr:ListBlank Γ⊢ (((pL ++ u) +> u ^ k +> l) {{q}}> pR +> r) [M]⊢^{s * (k + 1)} (pL +> l) {{q}}> pR +> v ^ (k + 1) +> r] Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q (pL ++ u) pR q pL (pR ++ v) = truek:ℕl:ListBlank Γr:ListBlank Γ⊢ (((pL ++ u) +> u ^ k +> l) {{q}}> pR +> r) [M]⊢^{s * (k + 1)} (pL +> l) {{q}}> pR +> v ^ (k + 1) +> r
have h1 := @checkHeadRight_sound Γ Λ _ _ _ _ false false M s q (pL ++ u) pR q pL (pR ++ v)
((u ^ k) +> l) r (by Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q (pL ++ u) pR q pL (pR ++ v) = truek:ℕl:ListBlank Γr:ListBlank Γ⊢ false = true → u ^ k +> l = default intro hc Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q (pL ++ u) pR q pL (pR ++ v) = truek:ℕl:ListBlank Γr:ListBlank Γhc:false = true⊢ u ^ k +> l = default; contradiction All goals completed! 🐙) (by Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q (pL ++ u) pR q pL (pR ++ v) = truek:ℕl:ListBlank Γr:ListBlank Γ⊢ false = true → r = default intro hc Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q (pL ++ u) pR q pL (pR ++ v) = truek:ℕl:ListBlank Γr:ListBlank Γhc:false = true⊢ r = default; contradiction All goals completed! 🐙) hbody Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q (pL ++ u) pR q pL (pR ++ v) = truek:ℕl:ListBlank Γr:ListBlank Γh1:(((pL ++ u) +> u ^ k +> l) {{q}}> pR +> r) [M]⊢^{s} (pL +> u ^ k +> l) {{q}}> (pR ++ v) +> r⊢ (((pL ++ u) +> u ^ k +> l) {{q}}> pR +> r) [M]⊢^{s * (k + 1)} (pL +> l) {{q}}> pR +> v ^ (k + 1) +> r
rw [append_assoc_blank pR v r Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q (pL ++ u) pR q pL (pR ++ v) = truek:ℕl:ListBlank Γr:ListBlank Γh1:(((pL ++ u) +> u ^ k +> l) {{q}}> pR +> r) [M]⊢^{s} (pL +> u ^ k +> l) {{q}}> pR +> v +> r⊢ (((pL ++ u) +> u ^ k +> l) {{q}}> pR +> r) [M]⊢^{s * (k + 1)} (pL +> l) {{q}}> pR +> v ^ (k + 1) +> r] at h1 Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q (pL ++ u) pR q pL (pR ++ v) = truek:ℕl:ListBlank Γr:ListBlank Γh1:(((pL ++ u) +> u ^ k +> l) {{q}}> pR +> r) [M]⊢^{s} (pL +> u ^ k +> l) {{q}}> pR +> v +> r⊢ (((pL ++ u) +> u ^ k +> l) {{q}}> pR +> r) [M]⊢^{s * (k + 1)} (pL +> l) {{q}}> pR +> v ^ (k + 1) +> r
have h2 := walkWordLeft s q pL u pR v hbody k l (v +> r) Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q (pL ++ u) pR q pL (pR ++ v) = truek:ℕl:ListBlank Γr:ListBlank Γh1:(((pL ++ u) +> u ^ k +> l) {{q}}> pR +> r) [M]⊢^{s} (pL +> u ^ k +> l) {{q}}> pR +> v +> rh2:((pL +> u ^ k +> l) {{q}}> pR +> v +> r) [M]⊢^{s * k} (pL +> l) {{q}}> pR +> v ^ k +> v +> r⊢ (((pL ++ u) +> u ^ k +> l) {{q}}> pR +> r) [M]⊢^{s * (k + 1)} (pL +> l) {{q}}> pR +> v ^ (k + 1) +> r
rw [← append_assoc_blank (v ^ k) v r, Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q (pL ++ u) pR q pL (pR ++ v) = truek:ℕl:ListBlank Γr:ListBlank Γh1:(((pL ++ u) +> u ^ k +> l) {{q}}> pR +> r) [M]⊢^{s} (pL +> u ^ k +> l) {{q}}> pR +> v +> rh2:((pL +> u ^ k +> l) {{q}}> pR +> v +> r) [M]⊢^{s * k} (pL +> l) {{q}}> pR +> (v ^ k ++ v) +> r⊢ (((pL ++ u) +> u ^ k +> l) {{q}}> pR +> r) [M]⊢^{s * (k + 1)} (pL +> l) {{q}}> pR +> v ^ (k + 1) +> r ← Counter.pow_succ_right Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q (pL ++ u) pR q pL (pR ++ v) = truek:ℕl:ListBlank Γr:ListBlank Γh1:(((pL ++ u) +> u ^ k +> l) {{q}}> pR +> r) [M]⊢^{s} (pL +> u ^ k +> l) {{q}}> pR +> v +> rh2:((pL +> u ^ k +> l) {{q}}> pR +> v +> r) [M]⊢^{s * k} (pL +> l) {{q}}> pR +> v ^ (k + 1) +> r⊢ (((pL ++ u) +> u ^ k +> l) {{q}}> pR +> r) [M]⊢^{s * (k + 1)} (pL +> l) {{q}}> pR +> v ^ (k + 1) +> r] at h2 Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q (pL ++ u) pR q pL (pR ++ v) = truek:ℕl:ListBlank Γr:ListBlank Γh1:(((pL ++ u) +> u ^ k +> l) {{q}}> pR +> r) [M]⊢^{s} (pL +> u ^ k +> l) {{q}}> pR +> v +> rh2:((pL +> u ^ k +> l) {{q}}> pR +> v +> r) [M]⊢^{s * k} (pL +> l) {{q}}> pR +> v ^ (k + 1) +> r⊢ (((pL ++ u) +> u ^ k +> l) {{q}}> pR +> r) [M]⊢^{s * (k + 1)} (pL +> l) {{q}}> pR +> v ^ (k + 1) +> r
rw [show s * (k + 1) = s + s * k by Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q (pL ++ u) pR q pL (pR ++ v) = truek:ℕl:ListBlank Γr:ListBlank Γ⊢ ((pL +> u ^ (k + 1) +> l) {{q}}> pR +> r) [M]⊢^{s * (k + 1)} (pL +> l) {{q}}> pR +> v ^ (k + 1) +> r ring All goals completed! 🐙] Γ:Type u_2Λ:Type u_3inst✝³:DecidableEq Γinst✝²:DecidableEq Λinst✝¹:Inhabited Γinst✝:Inhabited ΛM:Machine Γ Λs:ℕq:ΛpL:List Γu:List ΓpR:List Γv:List Γhbody:checkHeadRight false false M s q (pL ++ u) pR q pL (pR ++ v) = truek:ℕl:ListBlank Γr:ListBlank Γh1:(((pL ++ u) +> u ^ k +> l) {{q}}> pR +> r) [M]⊢^{s} (pL +> u ^ k +> l) {{q}}> pR +> v +> rh2:((pL +> u ^ k +> l) {{q}}> pR +> v +> r) [M]⊢^{s * k} (pL +> l) {{q}}> pR +> v ^ (k + 1) +> r⊢ (((pL ++ u) +> u ^ k +> l) {{q}}> pR +> r) [M]⊢^{s + s * k} (pL +> l) {{q}}> pR +> v ^ (k + 1) +> r
exact Counter.multiStep_trans M _ _ _ s (s * k) h1 h2 All goals completed! 🐙end BusyBeaver.WordRunStack