Imports
module
public import BusyBeaver.Basic
import Mathlib.Tactic.Ring@[expose] public sectionopen Mathlib Relation Nat Turing BusyBeavernamespace BusyBeaver.PairStack-- ============================================================================
-- Section 1: Tape & List Algebra Helpers
-- ============================================================================
variable {Γ Λ : Type*} [Inhabited Γ] [Inhabited Λ]theorem pow_zero_list (u : List (Fin 2)) : u ^ (0 : Nat) = [] := rfltheorem pow_succ_list (u : List (Fin 2)) (n : Nat) : u ^ (n + 1) = u ++ u ^ n := rfltheorem nil_append_list (l : List (Fin 2)) : ([] : List (Fin 2)) ++ l = l := rfltheorem cons_append_list (x : Fin 2) (xs ys : List (Fin 2)) :
(x :: xs) ++ ys = x :: (xs ++ ys) := rfltheorem append_nil_list (l : List (Fin 2)) : l ++ [] = l := List.append_nil lattribute [scoped simp]
pow_zero_list
pow_succ_list
nil_append_list
cons_append_list
append_nil_list
listblank_append_nil
listblank_append_cons
zero_cons_default
ListBlank.head_default
ListBlank.tail_defaultomit [Inhabited Γ] in
theorem list_pow_add (l : List Γ) (n m : Nat) : l^(n + m) = l^n ++ l^m :=
BusyBeaver.list_pow_add l n mtheorem listblank_append_right_assoc (l₁ l₂ : List Γ) (s : ListBlank Γ) :
(l₁ ++ l₂) +> s = l₁ +> (l₂ +> s) := Γ:Type u_1inst✝:Inhabited Γl₁:List Γl₂:List Γs:ListBlank Γ⊢ (l₁ ++ l₂) +> s = l₁ +> l₂ +> s
induction l₁ with
Γ:Type u_1inst✝:Inhabited Γl₂:List Γs:ListBlank Γ⊢ ([] ++ l₂) +> s = [] +> l₂ +> s All goals completed! 🐙
Γ:Type u_1inst✝:Inhabited Γl₂:List Γs:ListBlank Γx:Γxs:List Γih:(xs ++ l₂) +> s = xs +> l₂ +> s⊢ (x :: xs ++ l₂) +> s = (x :: xs) +> l₂ +> s
All goals completed! 🐙theorem listblank_eq_one_cons_tail {Z : ListBlank (Fin 2)} (hZ : Z.head = 1) :
Z = (1 : Fin 2) >> Z.tail := Z:ListBlank (Fin 2)hZ:Z.head = 1⊢ Z = 1 >> Z.tail
All goals completed! 🐙@[simp] theorem zeros_append_default (n : ℕ) :
(([0] : List (Fin 2)) ^ n) +> (default : ListBlank (Fin 2)) = default := by n:ℕ⊢ [0] ^ n +> default = default
induction n with
| zero => zero ⊢ [0] ^ 0 +> default = default rfl All goals completed! 🐙
| succ k ih => succ k:ℕih:[0] ^ k +> default = default⊢ [0] ^ (k + 1) +> default = default
simp only [pow_succ_list, cons_append_list, nil_append_list, listblank_append_cons,
ih, zero_cons_default] All goals completed! 🐙
Increment the primary coordinate of the top stack element (or push (0, 0) if empty).
def bumpHead : List (ℕ × ℕ) → List (ℕ × ℕ)
| [] => [(0, 0)]
| (a, b) :: L => (a + 1, b) :: L
Increment the primary coordinate of the top stack element n times.
def bumpN : ℕ → List (ℕ × ℕ) → List (ℕ × ℕ)
| 0, L => L
| n + 1, L => bumpHead (bumpN n L)
Ensure a stack is non-empty by appending (0, 0) if empty.
def ensureNonEmpty : List (ℕ × ℕ) → List (ℕ × ℕ)
| [] => [(0, 0)]
| p :: R => p :: R@[simp] theorem bumpN_zero (L : List (ℕ × ℕ)) : bumpN 0 L = L := rfl@[simp] theorem bumpN_succ (n : ℕ) (L : List (ℕ × ℕ)) :
bumpN (n + 1) L = bumpHead (bumpN n L) := rfltheorem bumpHead_ne_nil (L : List (ℕ × ℕ)) : bumpHead L ≠ [] := by L:List (ℕ × ℕ)⊢ bumpHead L ≠ []
rcases L with _ | ⟨⟨a, b⟩, L'⟩ nil ⊢ bumpHead [] ≠ []cons L':List (ℕ × ℕ)a:ℕb:ℕ⊢ bumpHead ((a, b) :: L') ≠ [] <;> nil ⊢ bumpHead [] ≠ []cons L':List (ℕ × ℕ)a:ℕb:ℕ⊢ bumpHead ((a, b) :: L') ≠ [] simp [bumpHead] All goals completed! 🐙theorem bumpN_succ_ne_nil (n : ℕ) (L : List (ℕ × ℕ)) : bumpN (n + 1) L ≠ [] := by n:ℕL:List (ℕ × ℕ)⊢ bumpN (n + 1) L ≠ []
simp only [bumpN_succ] n:ℕL:List (ℕ × ℕ)⊢ bumpHead (bumpN n L) ≠ []; exact bumpHead_ne_nil (bumpN n L) All goals completed! 🐙theorem ensureNonEmpty_ne_nil (R : List (ℕ × ℕ)) : ensureNonEmpty R ≠ [] := by R:List (ℕ × ℕ)⊢ ensureNonEmpty R ≠ []
rcases R with _ | ⟨p, R'⟩ nil ⊢ ensureNonEmpty [] ≠ []cons p:ℕ × ℕR':List (ℕ × ℕ)⊢ ensureNonEmpty (p :: R') ≠ [] <;> nil ⊢ ensureNonEmpty [] ≠ []cons p:ℕ × ℕR':List (ℕ × ℕ)⊢ ensureNonEmpty (p :: R') ≠ [] simp [ensureNonEmpty] All goals completed! 🐙
Generic parametric left stack encoding:
encLeft ((a, b) :: L) = encLeft L <+ (sSym ^ (sep + b % maxSep)) <+ (dSym ^ (stride * a + offset)).
def encLeftParam (dSym sSym : Fin 2) (stride offset sep maxSep : ℕ) :
List (ℕ × ℕ) → ListBlank (Fin 2)
| [] => default
| (a, b) :: L =>
(encLeftParam dSym sSym stride offset sep maxSep L <+
(([sSym] : List (Fin 2)) ^ (sep + b % maxSep))) <+
(([dSym] : List (Fin 2)) ^ (stride * a + offset))
Generic parametric right stack encoding:
encRight ((d, b) :: R) = (dSym ^ (stride * d + offset)) +> ((sSym ^ (sep + b % maxSep)) +> encRight R).
def encRightParam (dSym sSym : Fin 2) (stride offset sep maxSep : ℕ) :
List (ℕ × ℕ) → ListBlank (Fin 2)
| [] => default
| (d, b) :: R =>
(([dSym] : List (Fin 2)) ^ (stride * d + offset)) +>
((([sSym] : List (Fin 2)) ^ (sep + b % maxSep)) +>
encRightParam dSym sSym stride offset sep maxSep R)@[simp] theorem encLeftParam_nil (dSym sSym : Fin 2) (stride offset sep maxSep : ℕ) :
encLeftParam dSym sSym stride offset sep maxSep [] = default := rfl@[simp] theorem encRightParam_nil (dSym sSym : Fin 2) (stride offset sep maxSep : ℕ) :
encRightParam dSym sSym stride offset sep maxSep [] = default := rfl@[simp] theorem encLeftParam_cons (dSym sSym : Fin 2) (stride offset sep maxSep a b : ℕ)
(L : List (ℕ × ℕ)) :
encLeftParam dSym sSym stride offset sep maxSep ((a, b) :: L) =
(encLeftParam dSym sSym stride offset sep maxSep L <+
(([sSym] : List (Fin 2)) ^ (sep + b % maxSep))) <+
(([dSym] : List (Fin 2)) ^ (stride * a + offset)) := rfl@[simp] theorem encRightParam_cons (dSym sSym : Fin 2) (stride offset sep maxSep d b : ℕ)
(R : List (ℕ × ℕ)) :
encRightParam dSym sSym stride offset sep maxSep ((d, b) :: R) =
(([dSym] : List (Fin 2)) ^ (stride * d + offset)) +>
((([sSym] : List (Fin 2)) ^ (sep + b % maxSep)) +>
encRightParam dSym sSym stride offset sep maxSep R) := rfl-- ============================================================================
-- Section 4: Head & Successor Theorems
-- ============================================================================
theorem encLeftParam_head (dSym sSym : Fin 2) (stride offset sep maxSep : ℕ)
(h_offset : offset > 0) (a b : ℕ) (L : List (ℕ × ℕ)) :
(encLeftParam dSym sSym stride offset sep maxSep ((a, b) :: L)).head = dSym := by dSym:Fin 2sSym:Fin 2stride:ℕoffset:ℕsep:ℕmaxSep:ℕh_offset:offset > 0a:ℕb:ℕL:List (ℕ × ℕ)⊢ (encLeftParam dSym sSym stride offset sep maxSep ((a, b) :: L)).head = dSym
obtain ⟨off', rfl⟩ := Nat.exists_eq_succ_of_ne_zero (ne_of_gt h_offset) dSym:Fin 2sSym:Fin 2stride:ℕsep:ℕmaxSep:ℕa:ℕb:ℕL:List (ℕ × ℕ)off':ℕh_offset:off'.succ > 0⊢ (encLeftParam dSym sSym stride off'.succ sep maxSep ((a, b) :: L)).head = dSym
rw [encLeftParam_cons, dSym:Fin 2sSym:Fin 2stride:ℕsep:ℕmaxSep:ℕa:ℕb:ℕL:List (ℕ × ℕ)off':ℕh_offset:off'.succ > 0⊢ ([dSym] ^ (stride * a + off'.succ) +>
[sSym] ^ (sep + b % maxSep) +> encLeftParam dSym sSym stride off'.succ sep maxSep L).head =
dSym show stride * a + (off' + 1) = (stride * a + off') + 1 by dSym:Fin 2sSym:Fin 2stride:ℕoffset:ℕsep:ℕmaxSep:ℕh_offset:offset > 0a:ℕb:ℕL:List (ℕ × ℕ)⊢ (encLeftParam dSym sSym stride offset sep maxSep ((a, b) :: L)).head = dSym omega All goals completed! 🐙,
pow_succ_list, dSym:Fin 2sSym:Fin 2stride:ℕsep:ℕmaxSep:ℕa:ℕb:ℕL:List (ℕ × ℕ)off':ℕh_offset:off'.succ > 0⊢ (([dSym] ++ [dSym] ^ (stride * a + off')) +>
[sSym] ^ (sep + b % maxSep) +> encLeftParam dSym sSym stride off'.succ sep maxSep L).head =
dSym cons_append_list dSym:Fin 2sSym:Fin 2stride:ℕsep:ℕmaxSep:ℕa:ℕb:ℕL:List (ℕ × ℕ)off':ℕh_offset:off'.succ > 0⊢ ((dSym :: ([] ++ [dSym] ^ (stride * a + off'))) +>
[sSym] ^ (sep + b % maxSep) +> encLeftParam dSym sSym stride off'.succ sep maxSep L).head =
dSym] dSym:Fin 2sSym:Fin 2stride:ℕsep:ℕmaxSep:ℕa:ℕb:ℕL:List (ℕ × ℕ)off':ℕh_offset:off'.succ > 0⊢ ((dSym :: ([] ++ [dSym] ^ (stride * a + off'))) +>
[sSym] ^ (sep + b % maxSep) +> encLeftParam dSym sSym stride off'.succ sep maxSep L).head =
dSym
simp only [listblank_append_cons, Turing.ListBlank.head_cons] All goals completed! 🐙theorem encRightParam_head (dSym sSym : Fin 2) (stride offset sep maxSep : ℕ)
(h_offset : offset > 0) (d b : ℕ) (R : List (ℕ × ℕ)) :
(encRightParam dSym sSym stride offset sep maxSep ((d, b) :: R)).head = dSym := by dSym:Fin 2sSym:Fin 2stride:ℕoffset:ℕsep:ℕmaxSep:ℕh_offset:offset > 0d:ℕb:ℕR:List (ℕ × ℕ)⊢ (encRightParam dSym sSym stride offset sep maxSep ((d, b) :: R)).head = dSym
obtain ⟨off', rfl⟩ := Nat.exists_eq_succ_of_ne_zero (ne_of_gt h_offset) dSym:Fin 2sSym:Fin 2stride:ℕsep:ℕmaxSep:ℕd:ℕb:ℕR:List (ℕ × ℕ)off':ℕh_offset:off'.succ > 0⊢ (encRightParam dSym sSym stride off'.succ sep maxSep ((d, b) :: R)).head = dSym
rw [encRightParam_cons, dSym:Fin 2sSym:Fin 2stride:ℕsep:ℕmaxSep:ℕd:ℕb:ℕR:List (ℕ × ℕ)off':ℕh_offset:off'.succ > 0⊢ ([dSym] ^ (stride * d + off'.succ) +>
[sSym] ^ (sep + b % maxSep) +> encRightParam dSym sSym stride off'.succ sep maxSep R).head =
dSym show stride * d + (off' + 1) = (stride * d + off') + 1 by dSym:Fin 2sSym:Fin 2stride:ℕoffset:ℕsep:ℕmaxSep:ℕh_offset:offset > 0d:ℕb:ℕR:List (ℕ × ℕ)⊢ (encRightParam dSym sSym stride offset sep maxSep ((d, b) :: R)).head = dSym omega All goals completed! 🐙,
pow_succ_list, dSym:Fin 2sSym:Fin 2stride:ℕsep:ℕmaxSep:ℕd:ℕb:ℕR:List (ℕ × ℕ)off':ℕh_offset:off'.succ > 0⊢ (([dSym] ++ [dSym] ^ (stride * d + off')) +>
[sSym] ^ (sep + b % maxSep) +> encRightParam dSym sSym stride off'.succ sep maxSep R).head =
dSym cons_append_list dSym:Fin 2sSym:Fin 2stride:ℕsep:ℕmaxSep:ℕd:ℕb:ℕR:List (ℕ × ℕ)off':ℕh_offset:off'.succ > 0⊢ ((dSym :: ([] ++ [dSym] ^ (stride * d + off'))) +>
[sSym] ^ (sep + b % maxSep) +> encRightParam dSym sSym stride off'.succ sep maxSep R).head =
dSym] dSym:Fin 2sSym:Fin 2stride:ℕsep:ℕmaxSep:ℕd:ℕb:ℕR:List (ℕ × ℕ)off':ℕh_offset:off'.succ > 0⊢ ((dSym :: ([] ++ [dSym] ^ (stride * d + off'))) +>
[sSym] ^ (sep + b % maxSep) +> encRightParam dSym sSym stride off'.succ sep maxSep R).head =
dSym
simp only [listblank_append_cons, Turing.ListBlank.head_cons] All goals completed! 🐙theorem encLeftParam_succ (dSym sSym : Fin 2) (stride offset sep maxSep : ℕ)
(a b : ℕ) (L : List (ℕ × ℕ)) :
encLeftParam dSym sSym stride offset sep maxSep ((a + 1, b) :: L) =
(([dSym] : List (Fin 2)) ^ stride) +>
encLeftParam dSym sSym stride offset sep maxSep ((a, b) :: L) := by dSym:Fin 2sSym:Fin 2stride:ℕoffset:ℕsep:ℕmaxSep:ℕa:ℕb:ℕL:List (ℕ × ℕ)⊢ encLeftParam dSym sSym stride offset sep maxSep ((a + 1, b) :: L) =
[dSym] ^ stride +> encLeftParam dSym sSym stride offset sep maxSep ((a, b) :: L)
simp only [encLeftParam_cons] dSym:Fin 2sSym:Fin 2stride:ℕoffset:ℕsep:ℕmaxSep:ℕa:ℕb:ℕL:List (ℕ × ℕ)⊢ [dSym] ^ (stride * (a + 1) + offset) +>
[sSym] ^ (sep + b % maxSep) +> encLeftParam dSym sSym stride offset sep maxSep L =
[dSym] ^ stride +>
[dSym] ^ (stride * a + offset) +> [sSym] ^ (sep + b % maxSep) +> encLeftParam dSym sSym stride offset sep maxSep L
rw [show stride * (a + 1) + offset = stride + (stride * a + offset) by dSym:Fin 2sSym:Fin 2stride:ℕoffset:ℕsep:ℕmaxSep:ℕa:ℕb:ℕL:List (ℕ × ℕ)⊢ encLeftParam dSym sSym stride offset sep maxSep ((a + 1, b) :: L) =
[dSym] ^ stride +> encLeftParam dSym sSym stride offset sep maxSep ((a, b) :: L) ring All goals completed! 🐙,
list_pow_add, dSym:Fin 2sSym:Fin 2stride:ℕoffset:ℕsep:ℕmaxSep:ℕa:ℕb:ℕL:List (ℕ × ℕ)⊢ ([dSym] ^ stride ++ [dSym] ^ (stride * a + offset)) +>
[sSym] ^ (sep + b % maxSep) +> encLeftParam dSym sSym stride offset sep maxSep L =
[dSym] ^ stride +>
[dSym] ^ (stride * a + offset) +> [sSym] ^ (sep + b % maxSep) +> encLeftParam dSym sSym stride offset sep maxSep L listblank_append_right_assoc dSym:Fin 2sSym:Fin 2stride:ℕoffset:ℕsep:ℕmaxSep:ℕa:ℕb:ℕL:List (ℕ × ℕ)⊢ [dSym] ^ stride +>
[dSym] ^ (stride * a + offset) +> [sSym] ^ (sep + b % maxSep) +> encLeftParam dSym sSym stride offset sep maxSep L =
[dSym] ^ stride +>
[dSym] ^ (stride * a + offset) +> [sSym] ^ (sep + b % maxSep) +> encLeftParam dSym sSym stride offset sep maxSep L] All goals completed! 🐙theorem encRightParam_succ (dSym sSym : Fin 2) (stride offset sep maxSep : ℕ)
(d b : ℕ) (R : List (ℕ × ℕ)) :
encRightParam dSym sSym stride offset sep maxSep ((d + 1, b) :: R) =
(([dSym] : List (Fin 2)) ^ stride) +>
encRightParam dSym sSym stride offset sep maxSep ((d, b) :: R) := by dSym:Fin 2sSym:Fin 2stride:ℕoffset:ℕsep:ℕmaxSep:ℕd:ℕb:ℕR:List (ℕ × ℕ)⊢ encRightParam dSym sSym stride offset sep maxSep ((d + 1, b) :: R) =
[dSym] ^ stride +> encRightParam dSym sSym stride offset sep maxSep ((d, b) :: R)
simp only [encRightParam_cons] dSym:Fin 2sSym:Fin 2stride:ℕoffset:ℕsep:ℕmaxSep:ℕd:ℕb:ℕR:List (ℕ × ℕ)⊢ [dSym] ^ (stride * (d + 1) + offset) +>
[sSym] ^ (sep + b % maxSep) +> encRightParam dSym sSym stride offset sep maxSep R =
[dSym] ^ stride +>
[dSym] ^ (stride * d + offset) +> [sSym] ^ (sep + b % maxSep) +> encRightParam dSym sSym stride offset sep maxSep R
rw [show stride * (d + 1) + offset = stride + (stride * d + offset) by dSym:Fin 2sSym:Fin 2stride:ℕoffset:ℕsep:ℕmaxSep:ℕd:ℕb:ℕR:List (ℕ × ℕ)⊢ encRightParam dSym sSym stride offset sep maxSep ((d + 1, b) :: R) =
[dSym] ^ stride +> encRightParam dSym sSym stride offset sep maxSep ((d, b) :: R) ring All goals completed! 🐙,
list_pow_add, dSym:Fin 2sSym:Fin 2stride:ℕoffset:ℕsep:ℕmaxSep:ℕd:ℕb:ℕR:List (ℕ × ℕ)⊢ ([dSym] ^ stride ++ [dSym] ^ (stride * d + offset)) +>
[sSym] ^ (sep + b % maxSep) +> encRightParam dSym sSym stride offset sep maxSep R =
[dSym] ^ stride +>
[dSym] ^ (stride * d + offset) +> [sSym] ^ (sep + b % maxSep) +> encRightParam dSym sSym stride offset sep maxSep R listblank_append_right_assoc dSym:Fin 2sSym:Fin 2stride:ℕoffset:ℕsep:ℕmaxSep:ℕd:ℕb:ℕR:List (ℕ × ℕ)⊢ [dSym] ^ stride +>
[dSym] ^ (stride * d + offset) +>
[sSym] ^ (sep + b % maxSep) +> encRightParam dSym sSym stride offset sep maxSep R =
[dSym] ^ stride +>
[dSym] ^ (stride * d + offset) +> [sSym] ^ (sep + b % maxSep) +> encRightParam dSym sSym stride offset sep maxSep R] All goals completed! 🐙theorem encLeftParam_cons_dSym (dSym : Fin 2) (sep maxSep : ℕ)
(L : List (ℕ × ℕ)) :
dSym >> encLeftParam dSym 0 1 1 sep maxSep L =
encLeftParam dSym 0 1 1 sep maxSep (bumpHead L) := by dSym:Fin 2sep:ℕmaxSep:ℕL:List (ℕ × ℕ)⊢ dSym >> encLeftParam dSym 0 1 1 sep maxSep L = encLeftParam dSym 0 1 1 sep maxSep (bumpHead L)
rcases L with _ | ⟨⟨a, b⟩, L'⟩ nil dSym:Fin 2sep:ℕmaxSep:ℕ⊢ dSym >> encLeftParam dSym 0 1 1 sep maxSep [] = encLeftParam dSym 0 1 1 sep maxSep (bumpHead [])cons dSym:Fin 2sep:ℕmaxSep:ℕL':List (ℕ × ℕ)a:ℕb:ℕ⊢ dSym >> encLeftParam dSym 0 1 1 sep maxSep ((a, b) :: L') = encLeftParam dSym 0 1 1 sep maxSep (bumpHead ((a, b) :: L'))
· nil dSym:Fin 2sep:ℕmaxSep:ℕ⊢ dSym >> encLeftParam dSym 0 1 1 sep maxSep [] = encLeftParam dSym 0 1 1 sep maxSep (bumpHead []) simp [bumpHead, encLeftParam, zeros_append_default] All goals completed! 🐙
· cons dSym:Fin 2sep:ℕmaxSep:ℕL':List (ℕ × ℕ)a:ℕb:ℕ⊢ dSym >> encLeftParam dSym 0 1 1 sep maxSep ((a, b) :: L') = encLeftParam dSym 0 1 1 sep maxSep (bumpHead ((a, b) :: L')) have h := encLeftParam_succ dSym 0 1 1 sep maxSep a b L' cons dSym:Fin 2sep:ℕmaxSep:ℕL':List (ℕ × ℕ)a:ℕb:ℕh:encLeftParam dSym 0 1 1 sep maxSep ((a + 1, b) :: L') = [dSym] ^ 1 +> encLeftParam dSym 0 1 1 sep maxSep ((a, b) :: L')⊢ dSym >> encLeftParam dSym 0 1 1 sep maxSep ((a, b) :: L') = encLeftParam dSym 0 1 1 sep maxSep (bumpHead ((a, b) :: L'))
simp only [show (([dSym] : List (Fin 2)) ^ 1) = [dSym] by rfl,
listblank_append_cons, listblank_append_nil] at h cons dSym:Fin 2sep:ℕmaxSep:ℕL':List (ℕ × ℕ)a:ℕb:ℕh:encLeftParam dSym 0 1 1 sep maxSep ((a + 1, b) :: L') = dSym >> encLeftParam dSym 0 1 1 sep maxSep ((a, b) :: L')⊢ dSym >> encLeftParam dSym 0 1 1 sep maxSep ((a, b) :: L') = encLeftParam dSym 0 1 1 sep maxSep (bumpHead ((a, b) :: L'))
exact h.symm All goals completed! 🐙theorem encRightParam_cons_dSym (dSym : Fin 2) (sep maxSep : ℕ)
(R : List (ℕ × ℕ)) :
dSym >> encRightParam dSym 0 1 1 sep maxSep R =
encRightParam dSym 0 1 1 sep maxSep (bumpHead R) := by dSym:Fin 2sep:ℕmaxSep:ℕR:List (ℕ × ℕ)⊢ dSym >> encRightParam dSym 0 1 1 sep maxSep R = encRightParam dSym 0 1 1 sep maxSep (bumpHead R)
rcases R with _ | ⟨⟨d, b⟩, R'⟩ nil dSym:Fin 2sep:ℕmaxSep:ℕ⊢ dSym >> encRightParam dSym 0 1 1 sep maxSep [] = encRightParam dSym 0 1 1 sep maxSep (bumpHead [])cons dSym:Fin 2sep:ℕmaxSep:ℕR':List (ℕ × ℕ)d:ℕb:ℕ⊢ dSym >> encRightParam dSym 0 1 1 sep maxSep ((d, b) :: R') =
encRightParam dSym 0 1 1 sep maxSep (bumpHead ((d, b) :: R'))
· nil dSym:Fin 2sep:ℕmaxSep:ℕ⊢ dSym >> encRightParam dSym 0 1 1 sep maxSep [] = encRightParam dSym 0 1 1 sep maxSep (bumpHead []) simp [bumpHead, encRightParam, zeros_append_default] All goals completed! 🐙
· cons dSym:Fin 2sep:ℕmaxSep:ℕR':List (ℕ × ℕ)d:ℕb:ℕ⊢ dSym >> encRightParam dSym 0 1 1 sep maxSep ((d, b) :: R') =
encRightParam dSym 0 1 1 sep maxSep (bumpHead ((d, b) :: R')) have h := encRightParam_succ dSym 0 1 1 sep maxSep d b R' cons dSym:Fin 2sep:ℕmaxSep:ℕR':List (ℕ × ℕ)d:ℕb:ℕh:encRightParam dSym 0 1 1 sep maxSep ((d + 1, b) :: R') =
[dSym] ^ 1 +> encRightParam dSym 0 1 1 sep maxSep ((d, b) :: R')⊢ dSym >> encRightParam dSym 0 1 1 sep maxSep ((d, b) :: R') =
encRightParam dSym 0 1 1 sep maxSep (bumpHead ((d, b) :: R'))
simp only [show (([dSym] : List (Fin 2)) ^ 1) = [dSym] by rfl,
listblank_append_cons, listblank_append_nil] at h cons dSym:Fin 2sep:ℕmaxSep:ℕR':List (ℕ × ℕ)d:ℕb:ℕh:encRightParam dSym 0 1 1 sep maxSep ((d + 1, b) :: R') = dSym >> encRightParam dSym 0 1 1 sep maxSep ((d, b) :: R')⊢ dSym >> encRightParam dSym 0 1 1 sep maxSep ((d, b) :: R') =
encRightParam dSym 0 1 1 sep maxSep (bumpHead ((d, b) :: R'))
exact h.symm All goals completed! 🐙theorem encLeftParam_bumpN (dSym : Fin 2) (sep maxSep : ℕ)
(n : ℕ) (L : List (ℕ × ℕ)) :
(([dSym] : List (Fin 2)) ^ n) +> encLeftParam dSym 0 1 1 sep maxSep L =
encLeftParam dSym 0 1 1 sep maxSep (bumpN n L) := by dSym:Fin 2sep:ℕmaxSep:ℕn:ℕL:List (ℕ × ℕ)⊢ [dSym] ^ n +> encLeftParam dSym 0 1 1 sep maxSep L = encLeftParam dSym 0 1 1 sep maxSep (bumpN n L)
induction n with
| zero => zero dSym:Fin 2sep:ℕmaxSep:ℕL:List (ℕ × ℕ)⊢ [dSym] ^ 0 +> encLeftParam dSym 0 1 1 sep maxSep L = encLeftParam dSym 0 1 1 sep maxSep (bumpN 0 L) rfl All goals completed! 🐙
| succ k ih => succ dSym:Fin 2sep:ℕmaxSep:ℕL:List (ℕ × ℕ)k:ℕih:[dSym] ^ k +> encLeftParam dSym 0 1 1 sep maxSep L = encLeftParam dSym 0 1 1 sep maxSep (bumpN k L)⊢ [dSym] ^ (k + 1) +> encLeftParam dSym 0 1 1 sep maxSep L = encLeftParam dSym 0 1 1 sep maxSep (bumpN (k + 1) L)
simp only [pow_succ_list, cons_append_list, nil_append_list,
listblank_append_cons, ih, bumpN, encLeftParam_cons_dSym] All goals completed! 🐙theorem encRightParam_bumpN (dSym : Fin 2) (sep maxSep : ℕ)
(n : ℕ) (R : List (ℕ × ℕ)) :
(([dSym] : List (Fin 2)) ^ n) +> encRightParam dSym 0 1 1 sep maxSep R =
encRightParam dSym 0 1 1 sep maxSep (bumpN n R) := by dSym:Fin 2sep:ℕmaxSep:ℕn:ℕR:List (ℕ × ℕ)⊢ [dSym] ^ n +> encRightParam dSym 0 1 1 sep maxSep R = encRightParam dSym 0 1 1 sep maxSep (bumpN n R)
induction n with
| zero => zero dSym:Fin 2sep:ℕmaxSep:ℕR:List (ℕ × ℕ)⊢ [dSym] ^ 0 +> encRightParam dSym 0 1 1 sep maxSep R = encRightParam dSym 0 1 1 sep maxSep (bumpN 0 R) rfl All goals completed! 🐙
| succ k ih => succ dSym:Fin 2sep:ℕmaxSep:ℕR:List (ℕ × ℕ)k:ℕih:[dSym] ^ k +> encRightParam dSym 0 1 1 sep maxSep R = encRightParam dSym 0 1 1 sep maxSep (bumpN k R)⊢ [dSym] ^ (k + 1) +> encRightParam dSym 0 1 1 sep maxSep R = encRightParam dSym 0 1 1 sep maxSep (bumpN (k + 1) R)
simp only [pow_succ_list, cons_append_list, nil_append_list,
listblank_append_cons, ih, bumpN, encRightParam_cons_dSym] All goals completed! 🐙-- ============================================================================
-- Section 5: Modulo & Canonical Shorthands
-- ============================================================================
theorem mod2_cases (b : ℕ) : b % 2 = 0 ∨ b % 2 = 1 := by b:ℕ⊢ b % 2 = 0 ∨ b % 2 = 1 omega All goals completed! 🐙theorem mod3_cases (b : ℕ) : b % 3 = 0 ∨ b % 3 = 1 ∨ b % 3 = 2 := by b:ℕ⊢ b % 3 = 0 ∨ b % 3 = 1 ∨ b % 3 = 2 omega All goals completed! 🐙theorem mod4_cases (b : ℕ) : b % 4 = 0 ∨ b % 4 = 1 ∨ b % 4 = 2 ∨ b % 4 = 3 := by b:ℕ⊢ b % 4 = 0 ∨ b % 4 = 1 ∨ b % 4 = 2 ∨ b % 4 = 3 omega All goals completed! 🐙theorem encLeftParam_mod (dSym sSym : Fin 2) (stride offset sep maxSep : ℕ)
(a b : ℕ) (L : List (ℕ × ℕ)) :
encLeftParam dSym sSym stride offset sep maxSep ((a, b) :: L) =
encLeftParam dSym sSym stride offset sep maxSep ((a, b % maxSep) :: L) := by dSym:Fin 2sSym:Fin 2stride:ℕoffset:ℕsep:ℕmaxSep:ℕa:ℕb:ℕL:List (ℕ × ℕ)⊢ encLeftParam dSym sSym stride offset sep maxSep ((a, b) :: L) =
encLeftParam dSym sSym stride offset sep maxSep ((a, b % maxSep) :: L)
simp only [encLeftParam_cons, Nat.mod_mod] All goals completed! 🐙theorem encRightParam_mod (dSym sSym : Fin 2) (stride offset sep maxSep : ℕ)
(d b : ℕ) (R : List (ℕ × ℕ)) :
encRightParam dSym sSym stride offset sep maxSep ((d, b) :: R) =
encRightParam dSym sSym stride offset sep maxSep ((d, b % maxSep) :: R) := by dSym:Fin 2sSym:Fin 2stride:ℕoffset:ℕsep:ℕmaxSep:ℕd:ℕb:ℕR:List (ℕ × ℕ)⊢ encRightParam dSym sSym stride offset sep maxSep ((d, b) :: R) =
encRightParam dSym sSym stride offset sep maxSep ((d, b % maxSep) :: R)
simp only [encRightParam_cons, Nat.mod_mod] All goals completed! 🐙
Normalize a stack by reducing second coordinates modulo maxSep.
def normStack (maxSep : ℕ) : List (ℕ × ℕ) → List (ℕ × ℕ) :=
List.map (fun p => (p.1, p.2 % maxSep))
Predicate: every element's secondary coordinate is strictly bounded by maxSep.
def AllSep (maxSep : ℕ) (L : List (ℕ × ℕ)) : Prop :=
∀ p ∈ L, p.2 < maxSeptheorem encLeftParam_norm (dSym sSym : Fin 2) (stride offset sep maxSep : ℕ)
(L : List (ℕ × ℕ)) :
encLeftParam dSym sSym stride offset sep maxSep (normStack maxSep L) =
encLeftParam dSym sSym stride offset sep maxSep L := by dSym:Fin 2sSym:Fin 2stride:ℕoffset:ℕsep:ℕmaxSep:ℕL:List (ℕ × ℕ)⊢ encLeftParam dSym sSym stride offset sep maxSep (normStack maxSep L) = encLeftParam dSym sSym stride offset sep maxSep L
induction L with
| nil => nil dSym:Fin 2sSym:Fin 2stride:ℕoffset:ℕsep:ℕmaxSep:ℕ⊢ encLeftParam dSym sSym stride offset sep maxSep (normStack maxSep []) =
encLeftParam dSym sSym stride offset sep maxSep [] rfl All goals completed! 🐙
| cons p L' ih => cons dSym:Fin 2sSym:Fin 2stride:ℕoffset:ℕsep:ℕmaxSep:ℕp:ℕ × ℕL':List (ℕ × ℕ)ih:encLeftParam dSym sSym stride offset sep maxSep (normStack maxSep L') =
encLeftParam dSym sSym stride offset sep maxSep L'⊢ encLeftParam dSym sSym stride offset sep maxSep (normStack maxSep (p :: L')) =
encLeftParam dSym sSym stride offset sep maxSep (p :: L')
rcases p with ⟨a, b⟩ cons dSym:Fin 2sSym:Fin 2stride:ℕoffset:ℕsep:ℕmaxSep:ℕL':List (ℕ × ℕ)ih:encLeftParam dSym sSym stride offset sep maxSep (normStack maxSep L') =
encLeftParam dSym sSym stride offset sep maxSep L'a:ℕb:ℕ⊢ encLeftParam dSym sSym stride offset sep maxSep (normStack maxSep ((a, b) :: L')) =
encLeftParam dSym sSym stride offset sep maxSep ((a, b) :: L')
change encLeftParam dSym sSym stride offset sep maxSep
((a, b % maxSep) :: normStack maxSep L') =
encLeftParam dSym sSym stride offset sep maxSep ((a, b) :: L') cons dSym:Fin 2sSym:Fin 2stride:ℕoffset:ℕsep:ℕmaxSep:ℕL':List (ℕ × ℕ)ih:encLeftParam dSym sSym stride offset sep maxSep (normStack maxSep L') =
encLeftParam dSym sSym stride offset sep maxSep L'a:ℕb:ℕ⊢ encLeftParam dSym sSym stride offset sep maxSep ((a, b % maxSep) :: normStack maxSep L') =
encLeftParam dSym sSym stride offset sep maxSep ((a, b) :: L')
simp only [encLeftParam_cons, Nat.mod_mod, ih] All goals completed! 🐙theorem encRightParam_norm (dSym sSym : Fin 2) (stride offset sep maxSep : ℕ)
(R : List (ℕ × ℕ)) :
encRightParam dSym sSym stride offset sep maxSep (normStack maxSep R) =
encRightParam dSym sSym stride offset sep maxSep R := by dSym:Fin 2sSym:Fin 2stride:ℕoffset:ℕsep:ℕmaxSep:ℕR:List (ℕ × ℕ)⊢ encRightParam dSym sSym stride offset sep maxSep (normStack maxSep R) =
encRightParam dSym sSym stride offset sep maxSep R
induction R with
| nil => nil dSym:Fin 2sSym:Fin 2stride:ℕoffset:ℕsep:ℕmaxSep:ℕ⊢ encRightParam dSym sSym stride offset sep maxSep (normStack maxSep []) =
encRightParam dSym sSym stride offset sep maxSep [] rfl All goals completed! 🐙
| cons p R' ih => cons dSym:Fin 2sSym:Fin 2stride:ℕoffset:ℕsep:ℕmaxSep:ℕp:ℕ × ℕR':List (ℕ × ℕ)ih:encRightParam dSym sSym stride offset sep maxSep (normStack maxSep R') =
encRightParam dSym sSym stride offset sep maxSep R'⊢ encRightParam dSym sSym stride offset sep maxSep (normStack maxSep (p :: R')) =
encRightParam dSym sSym stride offset sep maxSep (p :: R')
rcases p with ⟨d, b⟩ cons dSym:Fin 2sSym:Fin 2stride:ℕoffset:ℕsep:ℕmaxSep:ℕR':List (ℕ × ℕ)ih:encRightParam dSym sSym stride offset sep maxSep (normStack maxSep R') =
encRightParam dSym sSym stride offset sep maxSep R'd:ℕb:ℕ⊢ encRightParam dSym sSym stride offset sep maxSep (normStack maxSep ((d, b) :: R')) =
encRightParam dSym sSym stride offset sep maxSep ((d, b) :: R')
change encRightParam dSym sSym stride offset sep maxSep
((d, b % maxSep) :: normStack maxSep R') =
encRightParam dSym sSym stride offset sep maxSep ((d, b) :: R') cons dSym:Fin 2sSym:Fin 2stride:ℕoffset:ℕsep:ℕmaxSep:ℕR':List (ℕ × ℕ)ih:encRightParam dSym sSym stride offset sep maxSep (normStack maxSep R') =
encRightParam dSym sSym stride offset sep maxSep R'd:ℕb:ℕ⊢ encRightParam dSym sSym stride offset sep maxSep ((d, b % maxSep) :: normStack maxSep R') =
encRightParam dSym sSym stride offset sep maxSep ((d, b) :: R')
simp only [encRightParam_cons, Nat.mod_mod, ih] All goals completed! 🐙theorem allSep_normStack (maxSep : ℕ) (h_pos : maxSep > 0) (L : List (ℕ × ℕ)) :
AllSep maxSep (normStack maxSep L) := by maxSep:ℕh_pos:maxSep > 0L:List (ℕ × ℕ)⊢ AllSep maxSep (normStack maxSep L)
intro p hp maxSep:ℕh_pos:maxSep > 0L:List (ℕ × ℕ)p:ℕ × ℕhp:p ∈ normStack maxSep L⊢ p.2 < maxSep
rcases List.mem_map.mp hp with ⟨q, _, rfl⟩ maxSep:ℕh_pos:maxSep > 0L:List (ℕ × ℕ)q:ℕ × ℕleft✝:q ∈ Lhp:(q.1, q.2 % maxSep) ∈ normStack maxSep L⊢ (q.1, q.2 % maxSep).2 < maxSep
exact Nat.mod_lt q.2 h_pos All goals completed! 🐙-- ============================================================================
-- Section 7: View Combinators
-- ============================================================================
theorem applyView_id_nil (s : ListBlank Γ) :
applyView (.id []) s = s :=
rfltheorem applyView_id_cons (x : Γ) (xs : List Γ) (s : ListBlank Γ) :
applyView (.id (x :: xs)) s = (x :: xs) +> s :=
rfltheorem applyView_tail_nil (s : ListBlank Γ) :
applyView (.tail []) s = s.tail :=
rfltheorem applyView_tail_cons (x : Γ) (xs : List Γ) (s : ListBlank Γ) :
applyView (.tail (x :: xs)) s = (x :: xs) +> s.tail :=
rfltheorem applyView_tail_one (enc : List (ℕ × ℕ) → ListBlank (Fin 2))
(h_head : ∀ d b R, (enc ((d, b) :: R)).head = 1)
(h_nil : applyView (.tail [1]) (enc []) = enc (ensureNonEmpty []))
(R : List (ℕ × ℕ)) :
applyView (.tail [1]) (enc R) = enc (ensureNonEmpty R) := by enc:List (ℕ × ℕ) → ListBlank (Fin 2)h_head:∀ (d b : ℕ) (R : List (ℕ × ℕ)), (enc ((d, b) :: R)).head = 1h_nil:applyView (HalfTapeView.tail [1]) (enc []) = enc (ensureNonEmpty [])R:List (ℕ × ℕ)⊢ applyView (HalfTapeView.tail [1]) (enc R) = enc (ensureNonEmpty R)
rcases R with _ | ⟨⟨d, b⟩, R'⟩ nil enc:List (ℕ × ℕ) → ListBlank (Fin 2)h_head:∀ (d b : ℕ) (R : List (ℕ × ℕ)), (enc ((d, b) :: R)).head = 1h_nil:applyView (HalfTapeView.tail [1]) (enc []) = enc (ensureNonEmpty [])⊢ applyView (HalfTapeView.tail [1]) (enc []) = enc (ensureNonEmpty [])cons enc:List (ℕ × ℕ) → ListBlank (Fin 2)h_head:∀ (d b : ℕ) (R : List (ℕ × ℕ)), (enc ((d, b) :: R)).head = 1h_nil:applyView (HalfTapeView.tail [1]) (enc []) = enc (ensureNonEmpty [])R':List (ℕ × ℕ)d:ℕb:ℕ⊢ applyView (HalfTapeView.tail [1]) (enc ((d, b) :: R')) = enc (ensureNonEmpty ((d, b) :: R'))
· nil enc:List (ℕ × ℕ) → ListBlank (Fin 2)h_head:∀ (d b : ℕ) (R : List (ℕ × ℕ)), (enc ((d, b) :: R)).head = 1h_nil:applyView (HalfTapeView.tail [1]) (enc []) = enc (ensureNonEmpty [])⊢ applyView (HalfTapeView.tail [1]) (enc []) = enc (ensureNonEmpty []) exact h_nil All goals completed! 🐙
· cons enc:List (ℕ × ℕ) → ListBlank (Fin 2)h_head:∀ (d b : ℕ) (R : List (ℕ × ℕ)), (enc ((d, b) :: R)).head = 1h_nil:applyView (HalfTapeView.tail [1]) (enc []) = enc (ensureNonEmpty [])R':List (ℕ × ℕ)d:ℕb:ℕ⊢ applyView (HalfTapeView.tail [1]) (enc ((d, b) :: R')) = enc (ensureNonEmpty ((d, b) :: R')) simp only [applyView, listblank_append_cons, listblank_append_nil, ensureNonEmpty] cons enc:List (ℕ × ℕ) → ListBlank (Fin 2)h_head:∀ (d b : ℕ) (R : List (ℕ × ℕ)), (enc ((d, b) :: R)).head = 1h_nil:applyView (HalfTapeView.tail [1]) (enc []) = enc (ensureNonEmpty [])R':List (ℕ × ℕ)d:ℕb:ℕ⊢ 1 >> (enc ((d, b) :: R')).tail = enc ((d, b) :: R')
exact (listblank_eq_one_cons_tail (h_head d b R')).symm All goals completed! 🐙theorem applyView_tail_zero_one (enc : List (ℕ × ℕ) → ListBlank (Fin 2))
(h_head : ∀ d b R, (enc ((d, b) :: R)).head = 1)
(h_nil : applyView (.tail [0, 1]) (enc []) = (0 : Fin 2) >> enc (ensureNonEmpty []))
(R : List (ℕ × ℕ)) :
applyView (.tail [0, 1]) (enc R) = (0 : Fin 2) >> enc (ensureNonEmpty R) := by enc:List (ℕ × ℕ) → ListBlank (Fin 2)h_head:∀ (d b : ℕ) (R : List (ℕ × ℕ)), (enc ((d, b) :: R)).head = 1h_nil:applyView (HalfTapeView.tail [0, 1]) (enc []) = 0 >> enc (ensureNonEmpty [])R:List (ℕ × ℕ)⊢ applyView (HalfTapeView.tail [0, 1]) (enc R) = 0 >> enc (ensureNonEmpty R)
rcases R with _ | ⟨⟨d, b⟩, R'⟩ nil enc:List (ℕ × ℕ) → ListBlank (Fin 2)h_head:∀ (d b : ℕ) (R : List (ℕ × ℕ)), (enc ((d, b) :: R)).head = 1h_nil:applyView (HalfTapeView.tail [0, 1]) (enc []) = 0 >> enc (ensureNonEmpty [])⊢ applyView (HalfTapeView.tail [0, 1]) (enc []) = 0 >> enc (ensureNonEmpty [])cons enc:List (ℕ × ℕ) → ListBlank (Fin 2)h_head:∀ (d b : ℕ) (R : List (ℕ × ℕ)), (enc ((d, b) :: R)).head = 1h_nil:applyView (HalfTapeView.tail [0, 1]) (enc []) = 0 >> enc (ensureNonEmpty [])R':List (ℕ × ℕ)d:ℕb:ℕ⊢ applyView (HalfTapeView.tail [0, 1]) (enc ((d, b) :: R')) = 0 >> enc (ensureNonEmpty ((d, b) :: R'))
· nil enc:List (ℕ × ℕ) → ListBlank (Fin 2)h_head:∀ (d b : ℕ) (R : List (ℕ × ℕ)), (enc ((d, b) :: R)).head = 1h_nil:applyView (HalfTapeView.tail [0, 1]) (enc []) = 0 >> enc (ensureNonEmpty [])⊢ applyView (HalfTapeView.tail [0, 1]) (enc []) = 0 >> enc (ensureNonEmpty []) exact h_nil All goals completed! 🐙
· cons enc:List (ℕ × ℕ) → ListBlank (Fin 2)h_head:∀ (d b : ℕ) (R : List (ℕ × ℕ)), (enc ((d, b) :: R)).head = 1h_nil:applyView (HalfTapeView.tail [0, 1]) (enc []) = 0 >> enc (ensureNonEmpty [])R':List (ℕ × ℕ)d:ℕb:ℕ⊢ applyView (HalfTapeView.tail [0, 1]) (enc ((d, b) :: R')) = 0 >> enc (ensureNonEmpty ((d, b) :: R')) simp only [applyView, listblank_append_cons, listblank_append_nil, ensureNonEmpty] cons enc:List (ℕ × ℕ) → ListBlank (Fin 2)h_head:∀ (d b : ℕ) (R : List (ℕ × ℕ)), (enc ((d, b) :: R)).head = 1h_nil:applyView (HalfTapeView.tail [0, 1]) (enc []) = 0 >> enc (ensureNonEmpty [])R':List (ℕ × ℕ)d:ℕb:ℕ⊢ 0 >> 1 >> (enc ((d, b) :: R')).tail = 0 >> enc ((d, b) :: R')
exact congrArg (ListBlank.cons 0) (listblank_eq_one_cons_tail (h_head d b R')).symm All goals completed! 🐙theorem applyView_tail_one_one (enc : List (ℕ × ℕ) → ListBlank (Fin 2))
(h_head : ∀ d b R, (enc ((d, b) :: R)).head = 1)
(h_nil : applyView (.tail [1, 1]) (enc []) = (1 : Fin 2) >> enc (ensureNonEmpty []))
(R : List (ℕ × ℕ)) :
applyView (.tail [1, 1]) (enc R) = (1 : Fin 2) >> enc (ensureNonEmpty R) := by enc:List (ℕ × ℕ) → ListBlank (Fin 2)h_head:∀ (d b : ℕ) (R : List (ℕ × ℕ)), (enc ((d, b) :: R)).head = 1h_nil:applyView (HalfTapeView.tail [1, 1]) (enc []) = 1 >> enc (ensureNonEmpty [])R:List (ℕ × ℕ)⊢ applyView (HalfTapeView.tail [1, 1]) (enc R) = 1 >> enc (ensureNonEmpty R)
rcases R with _ | ⟨⟨d, b⟩, R'⟩ nil enc:List (ℕ × ℕ) → ListBlank (Fin 2)h_head:∀ (d b : ℕ) (R : List (ℕ × ℕ)), (enc ((d, b) :: R)).head = 1h_nil:applyView (HalfTapeView.tail [1, 1]) (enc []) = 1 >> enc (ensureNonEmpty [])⊢ applyView (HalfTapeView.tail [1, 1]) (enc []) = 1 >> enc (ensureNonEmpty [])cons enc:List (ℕ × ℕ) → ListBlank (Fin 2)h_head:∀ (d b : ℕ) (R : List (ℕ × ℕ)), (enc ((d, b) :: R)).head = 1h_nil:applyView (HalfTapeView.tail [1, 1]) (enc []) = 1 >> enc (ensureNonEmpty [])R':List (ℕ × ℕ)d:ℕb:ℕ⊢ applyView (HalfTapeView.tail [1, 1]) (enc ((d, b) :: R')) = 1 >> enc (ensureNonEmpty ((d, b) :: R'))
· nil enc:List (ℕ × ℕ) → ListBlank (Fin 2)h_head:∀ (d b : ℕ) (R : List (ℕ × ℕ)), (enc ((d, b) :: R)).head = 1h_nil:applyView (HalfTapeView.tail [1, 1]) (enc []) = 1 >> enc (ensureNonEmpty [])⊢ applyView (HalfTapeView.tail [1, 1]) (enc []) = 1 >> enc (ensureNonEmpty []) exact h_nil All goals completed! 🐙
· cons enc:List (ℕ × ℕ) → ListBlank (Fin 2)h_head:∀ (d b : ℕ) (R : List (ℕ × ℕ)), (enc ((d, b) :: R)).head = 1h_nil:applyView (HalfTapeView.tail [1, 1]) (enc []) = 1 >> enc (ensureNonEmpty [])R':List (ℕ × ℕ)d:ℕb:ℕ⊢ applyView (HalfTapeView.tail [1, 1]) (enc ((d, b) :: R')) = 1 >> enc (ensureNonEmpty ((d, b) :: R')) simp only [applyView, listblank_append_cons, listblank_append_nil, ensureNonEmpty] cons enc:List (ℕ × ℕ) → ListBlank (Fin 2)h_head:∀ (d b : ℕ) (R : List (ℕ × ℕ)), (enc ((d, b) :: R)).head = 1h_nil:applyView (HalfTapeView.tail [1, 1]) (enc []) = 1 >> enc (ensureNonEmpty [])R':List (ℕ × ℕ)d:ℕb:ℕ⊢ 1 >> 1 >> (enc ((d, b) :: R')).tail = 1 >> enc ((d, b) :: R')
exact congrArg (ListBlank.cons 1) (listblank_eq_one_cons_tail (h_head d b R')).symm All goals completed! 🐙-- ============================================================================
-- Section 8: Block Encoding Audit Helper
-- ============================================================================
theorem blockEncodingParam
(strideL offsetL sepL maxSepL strideR offsetR sepR maxSepR : ℕ)
(h_sL : strideL > 0) (h_oL : offsetL > 0) (h_sepL : sepL > 0)
(h_m1L : 1 ≤ maxSepL) (h_m2L : maxSepL ≤ 4)
(h_sR : strideR > 0) (h_oR : offsetR > 0) (h_sepR : sepR > 0)
(h_m1R : 1 ≤ maxSepR) (h_m2R : maxSepR ≤ 4)
(dSym sSym : Fin 2) :
∃ strideL' offsetL' sepL' maxSepL' strideR' offsetR' sepR' maxSepR' : ℕ,
strideL' > 0 ∧ offsetL' > 0 ∧ sepL' > 0 ∧ 1 ≤ maxSepL' ∧ maxSepL' ≤ 4 ∧
strideR' > 0 ∧ offsetR' > 0 ∧ sepR' > 0 ∧ 1 ≤ maxSepR' ∧ maxSepR' ≤ 4 ∧
(∀ a (b : StackTuple 1) L, encLeftParam dSym sSym strideL offsetL sepL maxSepL ((a, b) :: L) =
(encLeftParam dSym sSym strideL offsetL sepL maxSepL L <+
(([sSym] : List (Fin 2)) ^ (stackSepLen sepL' maxSepL' b))) <+
(([dSym] : List (Fin 2)) ^ (strideL' * a + offsetL'))) ∧
(∀ d (b : StackTuple 1) R,
encRightParam dSym sSym strideR offsetR sepR maxSepR ((d, b) :: R) =
(([dSym] : List (Fin 2)) ^ (strideR' * d + offsetR')) +>
((([sSym] : List (Fin 2)) ^ (stackSepLen sepR' maxSepR' b)) +>
encRightParam dSym sSym strideR offsetR sepR maxSepR R)) :=
⟨strideL, offsetL, sepL, maxSepL, strideR, offsetR, sepR, maxSepR,
h_sL, h_oL, h_sepL, h_m1L, h_m2L,
h_sR, h_oR, h_sepR, h_m1R, h_m2R,
fun _ _ _ => rfl, fun _ _ _ => rfl⟩
Lift a 1-digit stack List ℕ to a 2-digit stack List (ℕ × ℕ) by appending 0 second
components.
def liftPairList : List ℕ → List (ℕ × ℕ)
| [] => []
| x :: xs => (x, 0) :: liftPairList xs@[simp] theorem map_fst_liftPairList : ∀ L1 : List ℕ, (liftPairList L1).map Prod.fst = L1
| [] => rfl
| _ :: xs => congrArg (_ :: ·) (map_fst_liftPairList xs)
Canonical proposition package for 1-digit stack cryptids on 2-symbol machines (Fin 2).
def OneDigitStackCryptidProp {Λ : Type*} [Inhabited Λ]
(target_tm : Machine (Fin 2) Λ)
(StackMode : Type)
(encLeft1 encRight1 : List ℕ → ListBlank (Fin 2))
(evalStackCfg1 : StackMode → List ℕ → List ℕ → Cfg (Fin 2) Λ)
(IsInStackSystem1 : Cfg (Fin 2) Λ → Prop) : Prop :=
encLeft1 [] = default ∧
encRight1 [] = default ∧
(∀ a L, (encLeft1 (a :: L)).head = (1 : Fin 2)) ∧
(∀ d R, (encRight1 (d :: R)).head = (1 : Fin 2)) ∧
(∃ t : ListBlank (Fin 2), t.head = (1 : Fin 2) ∧ ∀ L : List ℕ, encLeft1 L ≠ t) ∧
(∃ t : ListBlank (Fin 2), t.head = (1 : Fin 2) ∧ ∀ R : List ℕ, encRight1 R ≠ t) ∧
(∃ strideL offsetL sepL strideR offsetR sepR : ℕ,
strideL > 0 ∧ offsetL > 0 ∧ sepL > 0 ∧
strideR > 0 ∧ offsetR > 0 ∧ sepR > 0 ∧
(∀ a L, encLeft1 (a :: L) = (encLeft1 L <+ (([0] : List (Fin 2)) ^ sepL)) <+
(([1] : List (Fin 2)) ^ (strideL * a + offsetL))) ∧
(∀ d R, encRight1 (d :: R) = (([1] : List (Fin 2)) ^ (strideR * d + offsetR)) +>
((([0] : List (Fin 2)) ^ sepR) +> encRight1 R))) ∧
(∃ modes : List StackMode, modes.length ≤ 6 ∧ ∀ m : StackMode, m ∈ modes) ∧
IsValidStackModes encLeft1 encRight1 evalStackCfg1 ∧
(∀ cfg, IsInStackSystem1 cfg ↔ ∃ m L R, cfg = evalStackCfg1 m L R) ∧
(∀ m L R, IsInStackSystem1 (evalStackCfg1 m L R)) ∧
(∃ cfg₀, ((init []) [target_tm]⊢⁺ cfg₀) ∧ IsInStackSystem1 cfg₀) ∧
(∀ cfg, IsInStackSystem1 cfg →
∃ cfg', (cfg [target_tm]⊢⁺ cfg') ∧
(IsInStackSystem1 cfg' ∨ (step target_tm cfg').isNone))
Universal lift theorem from 1-digit stack cryptid to 2-digit IsStackCryptid.
theorem lift_one_digit_prop {Λ : Type*} [Inhabited Λ]
(target_tm : Machine (Fin 2) Λ)
(StackMode : Type)
(encLeft1 encRight1 : List ℕ → ListBlank (Fin 2))
(evalStackCfg1 : StackMode → List ℕ → List ℕ → Cfg (Fin 2) Λ)
(IsInStackSystem1 : Cfg (Fin 2) Λ → Prop)
(h : OneDigitStackCryptidProp target_tm StackMode encLeft1 encRight1
evalStackCfg1 IsInStackSystem1) :
IsStackCryptid target_tm := by Λ:Type u_3inst✝:Inhabited Λtarget_tm:Machine (Fin 2) ΛStackMode:TypeencLeft1:List ℕ → ListBlank (Fin 2)encRight1:List ℕ → ListBlank (Fin 2)evalStackCfg1:StackMode → List ℕ → List ℕ → Cfg (Fin 2) ΛIsInStackSystem1:Cfg (Fin 2) Λ → Proph:OneDigitStackCryptidProp target_tm StackMode encLeft1 encRight1 evalStackCfg1 IsInStackSystem1⊢ IsStackCryptid target_tm
refine ⟨StackMode, 1, 0,
fun (L : List (ℕ × ℕ)) => encLeft1 (L.map Prod.fst),
fun (R : List (ℕ × ℕ)) => encRight1 (R.map Prod.fst),
fun (m : StackMode) (L R : List (ℕ × ℕ)) =>
evalStackCfg1 m (L.map Prod.fst) (R.map Prod.fst),
fun (cfg : Cfg (Fin 2) Λ) => ∃ (m : StackMode) (L R : List (ℕ × ℕ)),
cfg = evalStackCfg1 m (L.map Prod.fst) (R.map Prod.fst),
?_⟩ Λ:Type u_3inst✝:Inhabited Λtarget_tm:Machine (Fin 2) ΛStackMode:TypeencLeft1:List ℕ → ListBlank (Fin 2)encRight1:List ℕ → ListBlank (Fin 2)evalStackCfg1:StackMode → List ℕ → List ℕ → Cfg (Fin 2) ΛIsInStackSystem1:Cfg (Fin 2) Λ → Proph:OneDigitStackCryptidProp target_tm StackMode encLeft1 encRight1 evalStackCfg1 IsInStackSystem1⊢ IsValidStackPolarity 1 0 ∧
(fun L ↦ encLeft1 (List.map Prod.fst L)) [] = default ∧
(fun R ↦ encRight1 (List.map Prod.fst R)) [] = default ∧
(∀ (a : ℕ) (b : rec ℕ (fun x ih ↦ ℕ × ih) 0) (L : List (StackTuple (0 + 2))),
((fun L ↦ encLeft1 (List.map Prod.fst L)) ((a, b) :: L)).head = 1) ∧
(∀ (d : ℕ) (b : rec ℕ (fun x ih ↦ ℕ × ih) 0) (R : List (StackTuple (0 + 2))),
((fun R ↦ encRight1 (List.map Prod.fst R)) ((d, b) :: R)).head = 1) ∧
(∃ t, t.head = 1 ∧ ∀ (L : List (StackTuple (0 + 2))), (fun L ↦ encLeft1 (List.map Prod.fst L)) L ≠ t) ∧
(∃ t, t.head = 1 ∧ ∀ (R : List (StackTuple (0 + 2))), (fun R ↦ encRight1 (List.map Prod.fst R)) R ≠ t) ∧
(∃ strideL offsetL sepL maxSepL strideR offsetR sepR maxSepR,
strideL > 0 ∧
offsetL > 0 ∧
sepL > 0 ∧
1 ≤ maxSepL ∧
maxSepL ≤ 4 ∧
strideR > 0 ∧
offsetR > 0 ∧
sepR > 0 ∧
1 ≤ maxSepR ∧
maxSepR ≤ 4 ∧
(∀ (a : ℕ) (b : rec ℕ (fun x ih ↦ ℕ × ih) 0) (L : List (StackTuple (0 + 2))),
(fun L ↦ encLeft1 (List.map Prod.fst L)) ((a, b) :: L) =
[1] ^ (strideL * a + offsetL) +>
[0] ^ stackSepLen sepL maxSepL b +>
(fun L ↦ encLeft1 (List.map Prod.fst L)) L) ∧
∀ (d : ℕ) (b : rec ℕ (fun x ih ↦ ℕ × ih) 0) (R : List (StackTuple (0 + 2))),
(fun R ↦ encRight1 (List.map Prod.fst R)) ((d, b) :: R) =
[1] ^ (strideR * d + offsetR) +>
[0] ^ stackSepLen sepR maxSepR b +>
(fun R ↦ encRight1 (List.map Prod.fst R)) R) ∧
(∃ modes, modes.length ≤ 6 ∧ ∀ (m : StackMode), m ∈ modes) ∧
(IsValidStackModes (fun L ↦ encLeft1 (List.map Prod.fst L)) (fun R ↦ encRight1 (List.map Prod.fst R))
fun m L R ↦ evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) ∧
(∀ (cfg : Cfg (Fin (0 + 2)) Λ),
(fun cfg ↦ ∃ m L R, cfg = evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) cfg ↔
∃ m L R,
cfg = (fun m L R ↦ evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) m L R) ∧
(∀ (m : StackMode) (L R : List (StackTuple (0 + 2))),
(fun cfg ↦ ∃ m L R, cfg = evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R))
((fun m L R ↦ evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) m L R)) ∧
(∃ cfg₀,
(init [] [target_tm]⊢⁺ cfg₀) ∧
(fun cfg ↦ ∃ m L R, cfg = evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R))
cfg₀) ∧
∀ (cfg : Cfg (Fin (0 + 2)) Λ),
(fun cfg ↦ ∃ m L R, cfg = evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) cfg →
∃ cfg',
(cfg [target_tm]⊢⁺ cfg') ∧
((fun cfg ↦
∃ m L R, cfg = evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R))
cfg' ∨
(step target_tm cfg').isNone = true)
rcases h with ⟨hnilL, hnilR, hheadL, hheadR, ⟨tL, htL, hnsL⟩, ⟨tR, htR, hnsR⟩,
⟨sL, oL, sepL, sR, oR, sepR, hsL, hoL, hsepL, hsR, hoR, hsepR, hblkL, hblkR⟩,
hmodes, hvalid1, hiff1, _, ⟨cfg₀, hinit0, hsys0⟩, hclosed1⟩ Λ:Type u_3inst✝:Inhabited Λtarget_tm:Machine (Fin 2) ΛStackMode:TypeencLeft1:List ℕ → ListBlank (Fin 2)encRight1:List ℕ → ListBlank (Fin 2)evalStackCfg1:StackMode → List ℕ → List ℕ → Cfg (Fin 2) ΛIsInStackSystem1:Cfg (Fin 2) Λ → ProphnilL:encLeft1 [] = defaulthnilR:encRight1 [] = defaulthheadL:∀ (a : ℕ) (L : List ℕ), (encLeft1 (a :: L)).head = 1hheadR:∀ (d : ℕ) (R : List ℕ), (encRight1 (d :: R)).head = 1tL:ListBlank (Fin 2)htL:tL.head = 1hnsL:∀ (L : List ℕ), encLeft1 L ≠ tLtR:ListBlank (Fin 2)htR:tR.head = 1hnsR:∀ (R : List ℕ), encRight1 R ≠ tRsL:ℕoL:ℕsepL:ℕsR:ℕoR:ℕsepR:ℕhsL:sL > 0hoL:oL > 0hsepL:sepL > 0hsR:sR > 0hoR:oR > 0hsepR:sepR > 0hblkL:∀ (a : ℕ) (L : List ℕ), encLeft1 (a :: L) = [1] ^ (sL * a + oL) +> [0] ^ sepL +> encLeft1 LhblkR:∀ (d : ℕ) (R : List ℕ), encRight1 (d :: R) = [1] ^ (sR * d + oR) +> [0] ^ sepR +> encRight1 Rhmodes:∃ modes, modes.length ≤ 6 ∧ ∀ (m : StackMode), m ∈ modeshvalid1:IsValidStackModes encLeft1 encRight1 evalStackCfg1hiff1:∀ (cfg : Cfg (Fin 2) Λ), IsInStackSystem1 cfg ↔ ∃ m L R, cfg = evalStackCfg1 m L Rleft✝:∀ (m : StackMode) (L R : List ℕ), IsInStackSystem1 (evalStackCfg1 m L R)hclosed1:∀ (cfg : Cfg (Fin 2) Λ),
IsInStackSystem1 cfg →
∃ cfg', (cfg [target_tm]⊢⁺ cfg') ∧ (IsInStackSystem1 cfg' ∨ (step target_tm cfg').isNone = true)cfg₀:Cfg (Fin 2) Λhinit0:init [] [target_tm]⊢⁺ cfg₀hsys0:IsInStackSystem1 cfg₀⊢ IsValidStackPolarity 1 0 ∧
(fun L ↦ encLeft1 (List.map Prod.fst L)) [] = default ∧
(fun R ↦ encRight1 (List.map Prod.fst R)) [] = default ∧
(∀ (a : ℕ) (b : rec ℕ (fun x ih ↦ ℕ × ih) 0) (L : List (StackTuple (0 + 2))),
((fun L ↦ encLeft1 (List.map Prod.fst L)) ((a, b) :: L)).head = 1) ∧
(∀ (d : ℕ) (b : rec ℕ (fun x ih ↦ ℕ × ih) 0) (R : List (StackTuple (0 + 2))),
((fun R ↦ encRight1 (List.map Prod.fst R)) ((d, b) :: R)).head = 1) ∧
(∃ t, t.head = 1 ∧ ∀ (L : List (StackTuple (0 + 2))), (fun L ↦ encLeft1 (List.map Prod.fst L)) L ≠ t) ∧
(∃ t, t.head = 1 ∧ ∀ (R : List (StackTuple (0 + 2))), (fun R ↦ encRight1 (List.map Prod.fst R)) R ≠ t) ∧
(∃ strideL offsetL sepL maxSepL strideR offsetR sepR maxSepR,
strideL > 0 ∧
offsetL > 0 ∧
sepL > 0 ∧
1 ≤ maxSepL ∧
maxSepL ≤ 4 ∧
strideR > 0 ∧
offsetR > 0 ∧
sepR > 0 ∧
1 ≤ maxSepR ∧
maxSepR ≤ 4 ∧
(∀ (a : ℕ) (b : rec ℕ (fun x ih ↦ ℕ × ih) 0) (L : List (StackTuple (0 + 2))),
(fun L ↦ encLeft1 (List.map Prod.fst L)) ((a, b) :: L) =
[1] ^ (strideL * a + offsetL) +>
[0] ^ stackSepLen sepL maxSepL b +>
(fun L ↦ encLeft1 (List.map Prod.fst L)) L) ∧
∀ (d : ℕ) (b : rec ℕ (fun x ih ↦ ℕ × ih) 0) (R : List (StackTuple (0 + 2))),
(fun R ↦ encRight1 (List.map Prod.fst R)) ((d, b) :: R) =
[1] ^ (strideR * d + offsetR) +>
[0] ^ stackSepLen sepR maxSepR b +>
(fun R ↦ encRight1 (List.map Prod.fst R)) R) ∧
(∃ modes, modes.length ≤ 6 ∧ ∀ (m : StackMode), m ∈ modes) ∧
(IsValidStackModes (fun L ↦ encLeft1 (List.map Prod.fst L)) (fun R ↦ encRight1 (List.map Prod.fst R))
fun m L R ↦ evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) ∧
(∀ (cfg : Cfg (Fin (0 + 2)) Λ),
(fun cfg ↦ ∃ m L R, cfg = evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) cfg ↔
∃ m L R,
cfg = (fun m L R ↦ evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) m L R) ∧
(∀ (m : StackMode) (L R : List (StackTuple (0 + 2))),
(fun cfg ↦ ∃ m L R, cfg = evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R))
((fun m L R ↦ evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) m L R)) ∧
(∃ cfg₀,
(init [] [target_tm]⊢⁺ cfg₀) ∧
(fun cfg ↦ ∃ m L R, cfg = evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R))
cfg₀) ∧
∀ (cfg : Cfg (Fin (0 + 2)) Λ),
(fun cfg ↦ ∃ m L R, cfg = evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) cfg →
∃ cfg',
(cfg [target_tm]⊢⁺ cfg') ∧
((fun cfg ↦
∃ m L R, cfg = evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R))
cfg' ∨
(step target_tm cfg').isNone = true)
refine ⟨Or.inl ⟨rfl, rfl⟩, hnilL, hnilR,
fun a _ L => hheadL a (L.map Prod.fst),
fun d _ R => hheadR d (R.map Prod.fst),
⟨tL, htL, fun L => hnsL (L.map Prod.fst)⟩,
⟨tR, htR, fun R => hnsR (R.map Prod.fst)⟩,
⟨sL, oL, sepL, 1, sR, oR, sepR, 1,
hsL, hoL, hsepL, le_refl 1, by Λ:Type u_3inst✝:Inhabited Λtarget_tm:Machine (Fin 2) ΛStackMode:TypeencLeft1:List ℕ → ListBlank (Fin 2)encRight1:List ℕ → ListBlank (Fin 2)evalStackCfg1:StackMode → List ℕ → List ℕ → Cfg (Fin 2) ΛIsInStackSystem1:Cfg (Fin 2) Λ → ProphnilL:encLeft1 [] = defaulthnilR:encRight1 [] = defaulthheadL:∀ (a : ℕ) (L : List ℕ), (encLeft1 (a :: L)).head = 1hheadR:∀ (d : ℕ) (R : List ℕ), (encRight1 (d :: R)).head = 1tL:ListBlank (Fin 2)htL:tL.head = 1hnsL:∀ (L : List ℕ), encLeft1 L ≠ tLtR:ListBlank (Fin 2)htR:tR.head = 1hnsR:∀ (R : List ℕ), encRight1 R ≠ tRsL:ℕoL:ℕsepL:ℕsR:ℕoR:ℕsepR:ℕhsL:sL > 0hoL:oL > 0hsepL:sepL > 0hsR:sR > 0hoR:oR > 0hsepR:sepR > 0hblkL:∀ (a : ℕ) (L : List ℕ), encLeft1 (a :: L) = [1] ^ (sL * a + oL) +> [0] ^ sepL +> encLeft1 LhblkR:∀ (d : ℕ) (R : List ℕ), encRight1 (d :: R) = [1] ^ (sR * d + oR) +> [0] ^ sepR +> encRight1 Rhmodes:∃ modes, modes.length ≤ 6 ∧ ∀ (m : StackMode), m ∈ modeshvalid1:IsValidStackModes encLeft1 encRight1 evalStackCfg1hiff1:∀ (cfg : Cfg (Fin 2) Λ), IsInStackSystem1 cfg ↔ ∃ m L R, cfg = evalStackCfg1 m L Rleft✝:∀ (m : StackMode) (L R : List ℕ), IsInStackSystem1 (evalStackCfg1 m L R)hclosed1:∀ (cfg : Cfg (Fin 2) Λ),
IsInStackSystem1 cfg →
∃ cfg', (cfg [target_tm]⊢⁺ cfg') ∧ (IsInStackSystem1 cfg' ∨ (step target_tm cfg').isNone = true)cfg₀:Cfg (Fin 2) Λhinit0:init [] [target_tm]⊢⁺ cfg₀hsys0:IsInStackSystem1 cfg₀⊢ 1 ≤ 4 decide All goals completed! 🐙,
hsR, hoR, hsepR, le_refl 1, by Λ:Type u_3inst✝:Inhabited Λtarget_tm:Machine (Fin 2) ΛStackMode:TypeencLeft1:List ℕ → ListBlank (Fin 2)encRight1:List ℕ → ListBlank (Fin 2)evalStackCfg1:StackMode → List ℕ → List ℕ → Cfg (Fin 2) ΛIsInStackSystem1:Cfg (Fin 2) Λ → ProphnilL:encLeft1 [] = defaulthnilR:encRight1 [] = defaulthheadL:∀ (a : ℕ) (L : List ℕ), (encLeft1 (a :: L)).head = 1hheadR:∀ (d : ℕ) (R : List ℕ), (encRight1 (d :: R)).head = 1tL:ListBlank (Fin 2)htL:tL.head = 1hnsL:∀ (L : List ℕ), encLeft1 L ≠ tLtR:ListBlank (Fin 2)htR:tR.head = 1hnsR:∀ (R : List ℕ), encRight1 R ≠ tRsL:ℕoL:ℕsepL:ℕsR:ℕoR:ℕsepR:ℕhsL:sL > 0hoL:oL > 0hsepL:sepL > 0hsR:sR > 0hoR:oR > 0hsepR:sepR > 0hblkL:∀ (a : ℕ) (L : List ℕ), encLeft1 (a :: L) = [1] ^ (sL * a + oL) +> [0] ^ sepL +> encLeft1 LhblkR:∀ (d : ℕ) (R : List ℕ), encRight1 (d :: R) = [1] ^ (sR * d + oR) +> [0] ^ sepR +> encRight1 Rhmodes:∃ modes, modes.length ≤ 6 ∧ ∀ (m : StackMode), m ∈ modeshvalid1:IsValidStackModes encLeft1 encRight1 evalStackCfg1hiff1:∀ (cfg : Cfg (Fin 2) Λ), IsInStackSystem1 cfg ↔ ∃ m L R, cfg = evalStackCfg1 m L Rleft✝:∀ (m : StackMode) (L R : List ℕ), IsInStackSystem1 (evalStackCfg1 m L R)hclosed1:∀ (cfg : Cfg (Fin 2) Λ),
IsInStackSystem1 cfg →
∃ cfg', (cfg [target_tm]⊢⁺ cfg') ∧ (IsInStackSystem1 cfg' ∨ (step target_tm cfg').isNone = true)cfg₀:Cfg (Fin 2) Λhinit0:init [] [target_tm]⊢⁺ cfg₀hsys0:IsInStackSystem1 cfg₀⊢ 1 ≤ 4 decide All goals completed! 🐙,
fun a b L => by Λ:Type u_3inst✝:Inhabited Λtarget_tm:Machine (Fin 2) ΛStackMode:TypeencLeft1:List ℕ → ListBlank (Fin 2)encRight1:List ℕ → ListBlank (Fin 2)evalStackCfg1:StackMode → List ℕ → List ℕ → Cfg (Fin 2) ΛIsInStackSystem1:Cfg (Fin 2) Λ → ProphnilL:encLeft1 [] = defaulthnilR:encRight1 [] = defaulthheadL:∀ (a : ℕ) (L : List ℕ), (encLeft1 (a :: L)).head = 1hheadR:∀ (d : ℕ) (R : List ℕ), (encRight1 (d :: R)).head = 1tL:ListBlank (Fin 2)htL:tL.head = 1hnsL:∀ (L : List ℕ), encLeft1 L ≠ tLtR:ListBlank (Fin 2)htR:tR.head = 1hnsR:∀ (R : List ℕ), encRight1 R ≠ tRsL:ℕoL:ℕsepL:ℕsR:ℕoR:ℕsepR:ℕhsL:sL > 0hoL:oL > 0hsepL:sepL > 0hsR:sR > 0hoR:oR > 0hsepR:sepR > 0hblkL:∀ (a : ℕ) (L : List ℕ), encLeft1 (a :: L) = [1] ^ (sL * a + oL) +> [0] ^ sepL +> encLeft1 LhblkR:∀ (d : ℕ) (R : List ℕ), encRight1 (d :: R) = [1] ^ (sR * d + oR) +> [0] ^ sepR +> encRight1 Rhmodes:∃ modes, modes.length ≤ 6 ∧ ∀ (m : StackMode), m ∈ modeshvalid1:IsValidStackModes encLeft1 encRight1 evalStackCfg1hiff1:∀ (cfg : Cfg (Fin 2) Λ), IsInStackSystem1 cfg ↔ ∃ m L R, cfg = evalStackCfg1 m L Rleft✝:∀ (m : StackMode) (L R : List ℕ), IsInStackSystem1 (evalStackCfg1 m L R)hclosed1:∀ (cfg : Cfg (Fin 2) Λ),
IsInStackSystem1 cfg →
∃ cfg', (cfg [target_tm]⊢⁺ cfg') ∧ (IsInStackSystem1 cfg' ∨ (step target_tm cfg').isNone = true)cfg₀:Cfg (Fin 2) Λhinit0:init [] [target_tm]⊢⁺ cfg₀hsys0:IsInStackSystem1 cfg₀a:ℕb:rec ℕ (fun x ih ↦ ℕ × ih) 0L:List (StackTuple (0 + 2))⊢ (fun L ↦ encLeft1 (List.map Prod.fst L)) ((a, b) :: L) =
[1] ^ (sL * a + oL) +> [0] ^ stackSepLen sepL 1 b +> (fun L ↦ encLeft1 (List.map Prod.fst L)) L simpa [Nat.mod_one] using hblkL a (L.map Prod.fst) All goals completed! 🐙,
fun d b R => by Λ:Type u_3inst✝:Inhabited Λtarget_tm:Machine (Fin 2) ΛStackMode:TypeencLeft1:List ℕ → ListBlank (Fin 2)encRight1:List ℕ → ListBlank (Fin 2)evalStackCfg1:StackMode → List ℕ → List ℕ → Cfg (Fin 2) ΛIsInStackSystem1:Cfg (Fin 2) Λ → ProphnilL:encLeft1 [] = defaulthnilR:encRight1 [] = defaulthheadL:∀ (a : ℕ) (L : List ℕ), (encLeft1 (a :: L)).head = 1hheadR:∀ (d : ℕ) (R : List ℕ), (encRight1 (d :: R)).head = 1tL:ListBlank (Fin 2)htL:tL.head = 1hnsL:∀ (L : List ℕ), encLeft1 L ≠ tLtR:ListBlank (Fin 2)htR:tR.head = 1hnsR:∀ (R : List ℕ), encRight1 R ≠ tRsL:ℕoL:ℕsepL:ℕsR:ℕoR:ℕsepR:ℕhsL:sL > 0hoL:oL > 0hsepL:sepL > 0hsR:sR > 0hoR:oR > 0hsepR:sepR > 0hblkL:∀ (a : ℕ) (L : List ℕ), encLeft1 (a :: L) = [1] ^ (sL * a + oL) +> [0] ^ sepL +> encLeft1 LhblkR:∀ (d : ℕ) (R : List ℕ), encRight1 (d :: R) = [1] ^ (sR * d + oR) +> [0] ^ sepR +> encRight1 Rhmodes:∃ modes, modes.length ≤ 6 ∧ ∀ (m : StackMode), m ∈ modeshvalid1:IsValidStackModes encLeft1 encRight1 evalStackCfg1hiff1:∀ (cfg : Cfg (Fin 2) Λ), IsInStackSystem1 cfg ↔ ∃ m L R, cfg = evalStackCfg1 m L Rleft✝:∀ (m : StackMode) (L R : List ℕ), IsInStackSystem1 (evalStackCfg1 m L R)hclosed1:∀ (cfg : Cfg (Fin 2) Λ),
IsInStackSystem1 cfg →
∃ cfg', (cfg [target_tm]⊢⁺ cfg') ∧ (IsInStackSystem1 cfg' ∨ (step target_tm cfg').isNone = true)cfg₀:Cfg (Fin 2) Λhinit0:init [] [target_tm]⊢⁺ cfg₀hsys0:IsInStackSystem1 cfg₀d:ℕb:rec ℕ (fun x ih ↦ ℕ × ih) 0R:List (StackTuple (0 + 2))⊢ (fun R ↦ encRight1 (List.map Prod.fst R)) ((d, b) :: R) =
[1] ^ (sR * d + oR) +> [0] ^ stackSepLen sepR 1 b +> (fun R ↦ encRight1 (List.map Prod.fst R)) R simpa [Nat.mod_one] using hblkR d (R.map Prod.fst) All goals completed! 🐙⟩,
hmodes,
fun m => ?_,
fun _ => Iff.rfl,
fun m L R => ⟨m, L, R, rfl⟩,
?_,
?_⟩
· refine_1 Λ:Type u_3inst✝:Inhabited Λtarget_tm:Machine (Fin 2) ΛStackMode:TypeencLeft1:List ℕ → ListBlank (Fin 2)encRight1:List ℕ → ListBlank (Fin 2)evalStackCfg1:StackMode → List ℕ → List ℕ → Cfg (Fin 2) ΛIsInStackSystem1:Cfg (Fin 2) Λ → ProphnilL:encLeft1 [] = defaulthnilR:encRight1 [] = defaulthheadL:∀ (a : ℕ) (L : List ℕ), (encLeft1 (a :: L)).head = 1hheadR:∀ (d : ℕ) (R : List ℕ), (encRight1 (d :: R)).head = 1tL:ListBlank (Fin 2)htL:tL.head = 1hnsL:∀ (L : List ℕ), encLeft1 L ≠ tLtR:ListBlank (Fin 2)htR:tR.head = 1hnsR:∀ (R : List ℕ), encRight1 R ≠ tRsL:ℕoL:ℕsepL:ℕsR:ℕoR:ℕsepR:ℕhsL:sL > 0hoL:oL > 0hsepL:sepL > 0hsR:sR > 0hoR:oR > 0hsepR:sepR > 0hblkL:∀ (a : ℕ) (L : List ℕ), encLeft1 (a :: L) = [1] ^ (sL * a + oL) +> [0] ^ sepL +> encLeft1 LhblkR:∀ (d : ℕ) (R : List ℕ), encRight1 (d :: R) = [1] ^ (sR * d + oR) +> [0] ^ sepR +> encRight1 Rhmodes:∃ modes, modes.length ≤ 6 ∧ ∀ (m : StackMode), m ∈ modeshvalid1:IsValidStackModes encLeft1 encRight1 evalStackCfg1hiff1:∀ (cfg : Cfg (Fin 2) Λ), IsInStackSystem1 cfg ↔ ∃ m L R, cfg = evalStackCfg1 m L Rleft✝:∀ (m : StackMode) (L R : List ℕ), IsInStackSystem1 (evalStackCfg1 m L R)hclosed1:∀ (cfg : Cfg (Fin 2) Λ),
IsInStackSystem1 cfg →
∃ cfg', (cfg [target_tm]⊢⁺ cfg') ∧ (IsInStackSystem1 cfg' ∨ (step target_tm cfg').isNone = true)cfg₀:Cfg (Fin 2) Λhinit0:init [] [target_tm]⊢⁺ cfg₀hsys0:IsInStackSystem1 cfg₀m:StackMode⊢ ∃ q vL vR,
HalfTapeView.casesOn vL List.length List.length ≤ 8 ∧
HalfTapeView.casesOn vR List.length List.length ≤ 8 ∧
((∀ (L R : List (StackTuple (0 + 2))),
(fun m L R ↦ evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) m L R =
{ q := some q,
tape :=
{ head := 0, left := applyView vL ((fun L ↦ encLeft1 (List.map Prod.fst L)) L),
right := applyView vR ((fun R ↦ encRight1 (List.map Prod.fst R)) R) } }) ∨
(∀ (L R : List (StackTuple (0 + 2))),
(fun m L R ↦ evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) m L R =
Cfg.headLeft q (applyView vL ((fun L ↦ encLeft1 (List.map Prod.fst L)) L))
(applyView vR ((fun R ↦ encRight1 (List.map Prod.fst R)) R))) ∨
∀ (L R : List (StackTuple (0 + 2))),
(fun m L R ↦ evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) m L R =
Cfg.headRight q (applyView vL ((fun L ↦ encLeft1 (List.map Prod.fst L)) L))
(applyView vR ((fun R ↦ encRight1 (List.map Prod.fst R)) R))) rcases hvalid1 m with ⟨q, vL, vR, hl, hr, h1 | h2 | h3⟩ refine_1.inl Λ:Type u_3inst✝:Inhabited Λtarget_tm:Machine (Fin 2) ΛStackMode:TypeencLeft1:List ℕ → ListBlank (Fin 2)encRight1:List ℕ → ListBlank (Fin 2)evalStackCfg1:StackMode → List ℕ → List ℕ → Cfg (Fin 2) ΛIsInStackSystem1:Cfg (Fin 2) Λ → ProphnilL:encLeft1 [] = defaulthnilR:encRight1 [] = defaulthheadL:∀ (a : ℕ) (L : List ℕ), (encLeft1 (a :: L)).head = 1hheadR:∀ (d : ℕ) (R : List ℕ), (encRight1 (d :: R)).head = 1tL:ListBlank (Fin 2)htL:tL.head = 1hnsL:∀ (L : List ℕ), encLeft1 L ≠ tLtR:ListBlank (Fin 2)htR:tR.head = 1hnsR:∀ (R : List ℕ), encRight1 R ≠ tRsL:ℕoL:ℕsepL:ℕsR:ℕoR:ℕsepR:ℕhsL:sL > 0hoL:oL > 0hsepL:sepL > 0hsR:sR > 0hoR:oR > 0hsepR:sepR > 0hblkL:∀ (a : ℕ) (L : List ℕ), encLeft1 (a :: L) = [1] ^ (sL * a + oL) +> [0] ^ sepL +> encLeft1 LhblkR:∀ (d : ℕ) (R : List ℕ), encRight1 (d :: R) = [1] ^ (sR * d + oR) +> [0] ^ sepR +> encRight1 Rhmodes:∃ modes, modes.length ≤ 6 ∧ ∀ (m : StackMode), m ∈ modeshvalid1:IsValidStackModes encLeft1 encRight1 evalStackCfg1hiff1:∀ (cfg : Cfg (Fin 2) Λ), IsInStackSystem1 cfg ↔ ∃ m L R, cfg = evalStackCfg1 m L Rleft✝:∀ (m : StackMode) (L R : List ℕ), IsInStackSystem1 (evalStackCfg1 m L R)hclosed1:∀ (cfg : Cfg (Fin 2) Λ),
IsInStackSystem1 cfg →
∃ cfg', (cfg [target_tm]⊢⁺ cfg') ∧ (IsInStackSystem1 cfg' ∨ (step target_tm cfg').isNone = true)cfg₀:Cfg (Fin 2) Λhinit0:init [] [target_tm]⊢⁺ cfg₀hsys0:IsInStackSystem1 cfg₀m:StackModeq:ΛvL:HalfTapeView (Fin 2)vR:HalfTapeView (Fin 2)hl:HalfTapeView.casesOn vL List.length List.length ≤ 8hr:HalfTapeView.casesOn vR List.length List.length ≤ 8h1:∀ (L R : List ℕ),
evalStackCfg1 m L R =
{ q := some q, tape := { head := 0, left := applyView vL (encLeft1 L), right := applyView vR (encRight1 R) } }⊢ ∃ q vL vR,
HalfTapeView.casesOn vL List.length List.length ≤ 8 ∧
HalfTapeView.casesOn vR List.length List.length ≤ 8 ∧
((∀ (L R : List (StackTuple (0 + 2))),
(fun m L R ↦ evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) m L R =
{ q := some q,
tape :=
{ head := 0, left := applyView vL ((fun L ↦ encLeft1 (List.map Prod.fst L)) L),
right := applyView vR ((fun R ↦ encRight1 (List.map Prod.fst R)) R) } }) ∨
(∀ (L R : List (StackTuple (0 + 2))),
(fun m L R ↦ evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) m L R =
Cfg.headLeft q (applyView vL ((fun L ↦ encLeft1 (List.map Prod.fst L)) L))
(applyView vR ((fun R ↦ encRight1 (List.map Prod.fst R)) R))) ∨
∀ (L R : List (StackTuple (0 + 2))),
(fun m L R ↦ evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) m L R =
Cfg.headRight q (applyView vL ((fun L ↦ encLeft1 (List.map Prod.fst L)) L))
(applyView vR ((fun R ↦ encRight1 (List.map Prod.fst R)) R)))refine_1.inr.inl Λ:Type u_3inst✝:Inhabited Λtarget_tm:Machine (Fin 2) ΛStackMode:TypeencLeft1:List ℕ → ListBlank (Fin 2)encRight1:List ℕ → ListBlank (Fin 2)evalStackCfg1:StackMode → List ℕ → List ℕ → Cfg (Fin 2) ΛIsInStackSystem1:Cfg (Fin 2) Λ → ProphnilL:encLeft1 [] = defaulthnilR:encRight1 [] = defaulthheadL:∀ (a : ℕ) (L : List ℕ), (encLeft1 (a :: L)).head = 1hheadR:∀ (d : ℕ) (R : List ℕ), (encRight1 (d :: R)).head = 1tL:ListBlank (Fin 2)htL:tL.head = 1hnsL:∀ (L : List ℕ), encLeft1 L ≠ tLtR:ListBlank (Fin 2)htR:tR.head = 1hnsR:∀ (R : List ℕ), encRight1 R ≠ tRsL:ℕoL:ℕsepL:ℕsR:ℕoR:ℕsepR:ℕhsL:sL > 0hoL:oL > 0hsepL:sepL > 0hsR:sR > 0hoR:oR > 0hsepR:sepR > 0hblkL:∀ (a : ℕ) (L : List ℕ), encLeft1 (a :: L) = [1] ^ (sL * a + oL) +> [0] ^ sepL +> encLeft1 LhblkR:∀ (d : ℕ) (R : List ℕ), encRight1 (d :: R) = [1] ^ (sR * d + oR) +> [0] ^ sepR +> encRight1 Rhmodes:∃ modes, modes.length ≤ 6 ∧ ∀ (m : StackMode), m ∈ modeshvalid1:IsValidStackModes encLeft1 encRight1 evalStackCfg1hiff1:∀ (cfg : Cfg (Fin 2) Λ), IsInStackSystem1 cfg ↔ ∃ m L R, cfg = evalStackCfg1 m L Rleft✝:∀ (m : StackMode) (L R : List ℕ), IsInStackSystem1 (evalStackCfg1 m L R)hclosed1:∀ (cfg : Cfg (Fin 2) Λ),
IsInStackSystem1 cfg →
∃ cfg', (cfg [target_tm]⊢⁺ cfg') ∧ (IsInStackSystem1 cfg' ∨ (step target_tm cfg').isNone = true)cfg₀:Cfg (Fin 2) Λhinit0:init [] [target_tm]⊢⁺ cfg₀hsys0:IsInStackSystem1 cfg₀m:StackModeq:ΛvL:HalfTapeView (Fin 2)vR:HalfTapeView (Fin 2)hl:HalfTapeView.casesOn vL List.length List.length ≤ 8hr:HalfTapeView.casesOn vR List.length List.length ≤ 8h2:∀ (L R : List ℕ), evalStackCfg1 m L R = Cfg.headLeft q (applyView vL (encLeft1 L)) (applyView vR (encRight1 R))⊢ ∃ q vL vR,
HalfTapeView.casesOn vL List.length List.length ≤ 8 ∧
HalfTapeView.casesOn vR List.length List.length ≤ 8 ∧
((∀ (L R : List (StackTuple (0 + 2))),
(fun m L R ↦ evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) m L R =
{ q := some q,
tape :=
{ head := 0, left := applyView vL ((fun L ↦ encLeft1 (List.map Prod.fst L)) L),
right := applyView vR ((fun R ↦ encRight1 (List.map Prod.fst R)) R) } }) ∨
(∀ (L R : List (StackTuple (0 + 2))),
(fun m L R ↦ evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) m L R =
Cfg.headLeft q (applyView vL ((fun L ↦ encLeft1 (List.map Prod.fst L)) L))
(applyView vR ((fun R ↦ encRight1 (List.map Prod.fst R)) R))) ∨
∀ (L R : List (StackTuple (0 + 2))),
(fun m L R ↦ evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) m L R =
Cfg.headRight q (applyView vL ((fun L ↦ encLeft1 (List.map Prod.fst L)) L))
(applyView vR ((fun R ↦ encRight1 (List.map Prod.fst R)) R)))refine_1.inr.inr Λ:Type u_3inst✝:Inhabited Λtarget_tm:Machine (Fin 2) ΛStackMode:TypeencLeft1:List ℕ → ListBlank (Fin 2)encRight1:List ℕ → ListBlank (Fin 2)evalStackCfg1:StackMode → List ℕ → List ℕ → Cfg (Fin 2) ΛIsInStackSystem1:Cfg (Fin 2) Λ → ProphnilL:encLeft1 [] = defaulthnilR:encRight1 [] = defaulthheadL:∀ (a : ℕ) (L : List ℕ), (encLeft1 (a :: L)).head = 1hheadR:∀ (d : ℕ) (R : List ℕ), (encRight1 (d :: R)).head = 1tL:ListBlank (Fin 2)htL:tL.head = 1hnsL:∀ (L : List ℕ), encLeft1 L ≠ tLtR:ListBlank (Fin 2)htR:tR.head = 1hnsR:∀ (R : List ℕ), encRight1 R ≠ tRsL:ℕoL:ℕsepL:ℕsR:ℕoR:ℕsepR:ℕhsL:sL > 0hoL:oL > 0hsepL:sepL > 0hsR:sR > 0hoR:oR > 0hsepR:sepR > 0hblkL:∀ (a : ℕ) (L : List ℕ), encLeft1 (a :: L) = [1] ^ (sL * a + oL) +> [0] ^ sepL +> encLeft1 LhblkR:∀ (d : ℕ) (R : List ℕ), encRight1 (d :: R) = [1] ^ (sR * d + oR) +> [0] ^ sepR +> encRight1 Rhmodes:∃ modes, modes.length ≤ 6 ∧ ∀ (m : StackMode), m ∈ modeshvalid1:IsValidStackModes encLeft1 encRight1 evalStackCfg1hiff1:∀ (cfg : Cfg (Fin 2) Λ), IsInStackSystem1 cfg ↔ ∃ m L R, cfg = evalStackCfg1 m L Rleft✝:∀ (m : StackMode) (L R : List ℕ), IsInStackSystem1 (evalStackCfg1 m L R)hclosed1:∀ (cfg : Cfg (Fin 2) Λ),
IsInStackSystem1 cfg →
∃ cfg', (cfg [target_tm]⊢⁺ cfg') ∧ (IsInStackSystem1 cfg' ∨ (step target_tm cfg').isNone = true)cfg₀:Cfg (Fin 2) Λhinit0:init [] [target_tm]⊢⁺ cfg₀hsys0:IsInStackSystem1 cfg₀m:StackModeq:ΛvL:HalfTapeView (Fin 2)vR:HalfTapeView (Fin 2)hl:HalfTapeView.casesOn vL List.length List.length ≤ 8hr:HalfTapeView.casesOn vR List.length List.length ≤ 8h3:∀ (L R : List ℕ), evalStackCfg1 m L R = Cfg.headRight q (applyView vL (encLeft1 L)) (applyView vR (encRight1 R))⊢ ∃ q vL vR,
HalfTapeView.casesOn vL List.length List.length ≤ 8 ∧
HalfTapeView.casesOn vR List.length List.length ≤ 8 ∧
((∀ (L R : List (StackTuple (0 + 2))),
(fun m L R ↦ evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) m L R =
{ q := some q,
tape :=
{ head := 0, left := applyView vL ((fun L ↦ encLeft1 (List.map Prod.fst L)) L),
right := applyView vR ((fun R ↦ encRight1 (List.map Prod.fst R)) R) } }) ∨
(∀ (L R : List (StackTuple (0 + 2))),
(fun m L R ↦ evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) m L R =
Cfg.headLeft q (applyView vL ((fun L ↦ encLeft1 (List.map Prod.fst L)) L))
(applyView vR ((fun R ↦ encRight1 (List.map Prod.fst R)) R))) ∨
∀ (L R : List (StackTuple (0 + 2))),
(fun m L R ↦ evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) m L R =
Cfg.headRight q (applyView vL ((fun L ↦ encLeft1 (List.map Prod.fst L)) L))
(applyView vR ((fun R ↦ encRight1 (List.map Prod.fst R)) R)))
· refine_1.inl Λ:Type u_3inst✝:Inhabited Λtarget_tm:Machine (Fin 2) ΛStackMode:TypeencLeft1:List ℕ → ListBlank (Fin 2)encRight1:List ℕ → ListBlank (Fin 2)evalStackCfg1:StackMode → List ℕ → List ℕ → Cfg (Fin 2) ΛIsInStackSystem1:Cfg (Fin 2) Λ → ProphnilL:encLeft1 [] = defaulthnilR:encRight1 [] = defaulthheadL:∀ (a : ℕ) (L : List ℕ), (encLeft1 (a :: L)).head = 1hheadR:∀ (d : ℕ) (R : List ℕ), (encRight1 (d :: R)).head = 1tL:ListBlank (Fin 2)htL:tL.head = 1hnsL:∀ (L : List ℕ), encLeft1 L ≠ tLtR:ListBlank (Fin 2)htR:tR.head = 1hnsR:∀ (R : List ℕ), encRight1 R ≠ tRsL:ℕoL:ℕsepL:ℕsR:ℕoR:ℕsepR:ℕhsL:sL > 0hoL:oL > 0hsepL:sepL > 0hsR:sR > 0hoR:oR > 0hsepR:sepR > 0hblkL:∀ (a : ℕ) (L : List ℕ), encLeft1 (a :: L) = [1] ^ (sL * a + oL) +> [0] ^ sepL +> encLeft1 LhblkR:∀ (d : ℕ) (R : List ℕ), encRight1 (d :: R) = [1] ^ (sR * d + oR) +> [0] ^ sepR +> encRight1 Rhmodes:∃ modes, modes.length ≤ 6 ∧ ∀ (m : StackMode), m ∈ modeshvalid1:IsValidStackModes encLeft1 encRight1 evalStackCfg1hiff1:∀ (cfg : Cfg (Fin 2) Λ), IsInStackSystem1 cfg ↔ ∃ m L R, cfg = evalStackCfg1 m L Rleft✝:∀ (m : StackMode) (L R : List ℕ), IsInStackSystem1 (evalStackCfg1 m L R)hclosed1:∀ (cfg : Cfg (Fin 2) Λ),
IsInStackSystem1 cfg →
∃ cfg', (cfg [target_tm]⊢⁺ cfg') ∧ (IsInStackSystem1 cfg' ∨ (step target_tm cfg').isNone = true)cfg₀:Cfg (Fin 2) Λhinit0:init [] [target_tm]⊢⁺ cfg₀hsys0:IsInStackSystem1 cfg₀m:StackModeq:ΛvL:HalfTapeView (Fin 2)vR:HalfTapeView (Fin 2)hl:HalfTapeView.casesOn vL List.length List.length ≤ 8hr:HalfTapeView.casesOn vR List.length List.length ≤ 8h1:∀ (L R : List ℕ),
evalStackCfg1 m L R =
{ q := some q, tape := { head := 0, left := applyView vL (encLeft1 L), right := applyView vR (encRight1 R) } }⊢ ∃ q vL vR,
HalfTapeView.casesOn vL List.length List.length ≤ 8 ∧
HalfTapeView.casesOn vR List.length List.length ≤ 8 ∧
((∀ (L R : List (StackTuple (0 + 2))),
(fun m L R ↦ evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) m L R =
{ q := some q,
tape :=
{ head := 0, left := applyView vL ((fun L ↦ encLeft1 (List.map Prod.fst L)) L),
right := applyView vR ((fun R ↦ encRight1 (List.map Prod.fst R)) R) } }) ∨
(∀ (L R : List (StackTuple (0 + 2))),
(fun m L R ↦ evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) m L R =
Cfg.headLeft q (applyView vL ((fun L ↦ encLeft1 (List.map Prod.fst L)) L))
(applyView vR ((fun R ↦ encRight1 (List.map Prod.fst R)) R))) ∨
∀ (L R : List (StackTuple (0 + 2))),
(fun m L R ↦ evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) m L R =
Cfg.headRight q (applyView vL ((fun L ↦ encLeft1 (List.map Prod.fst L)) L))
(applyView vR ((fun R ↦ encRight1 (List.map Prod.fst R)) R))) exact ⟨q, vL, vR, hl, hr, Or.inl (fun L R => h1 (L.map Prod.fst) (R.map Prod.fst))⟩ All goals completed! 🐙
· refine_1.inr.inl Λ:Type u_3inst✝:Inhabited Λtarget_tm:Machine (Fin 2) ΛStackMode:TypeencLeft1:List ℕ → ListBlank (Fin 2)encRight1:List ℕ → ListBlank (Fin 2)evalStackCfg1:StackMode → List ℕ → List ℕ → Cfg (Fin 2) ΛIsInStackSystem1:Cfg (Fin 2) Λ → ProphnilL:encLeft1 [] = defaulthnilR:encRight1 [] = defaulthheadL:∀ (a : ℕ) (L : List ℕ), (encLeft1 (a :: L)).head = 1hheadR:∀ (d : ℕ) (R : List ℕ), (encRight1 (d :: R)).head = 1tL:ListBlank (Fin 2)htL:tL.head = 1hnsL:∀ (L : List ℕ), encLeft1 L ≠ tLtR:ListBlank (Fin 2)htR:tR.head = 1hnsR:∀ (R : List ℕ), encRight1 R ≠ tRsL:ℕoL:ℕsepL:ℕsR:ℕoR:ℕsepR:ℕhsL:sL > 0hoL:oL > 0hsepL:sepL > 0hsR:sR > 0hoR:oR > 0hsepR:sepR > 0hblkL:∀ (a : ℕ) (L : List ℕ), encLeft1 (a :: L) = [1] ^ (sL * a + oL) +> [0] ^ sepL +> encLeft1 LhblkR:∀ (d : ℕ) (R : List ℕ), encRight1 (d :: R) = [1] ^ (sR * d + oR) +> [0] ^ sepR +> encRight1 Rhmodes:∃ modes, modes.length ≤ 6 ∧ ∀ (m : StackMode), m ∈ modeshvalid1:IsValidStackModes encLeft1 encRight1 evalStackCfg1hiff1:∀ (cfg : Cfg (Fin 2) Λ), IsInStackSystem1 cfg ↔ ∃ m L R, cfg = evalStackCfg1 m L Rleft✝:∀ (m : StackMode) (L R : List ℕ), IsInStackSystem1 (evalStackCfg1 m L R)hclosed1:∀ (cfg : Cfg (Fin 2) Λ),
IsInStackSystem1 cfg →
∃ cfg', (cfg [target_tm]⊢⁺ cfg') ∧ (IsInStackSystem1 cfg' ∨ (step target_tm cfg').isNone = true)cfg₀:Cfg (Fin 2) Λhinit0:init [] [target_tm]⊢⁺ cfg₀hsys0:IsInStackSystem1 cfg₀m:StackModeq:ΛvL:HalfTapeView (Fin 2)vR:HalfTapeView (Fin 2)hl:HalfTapeView.casesOn vL List.length List.length ≤ 8hr:HalfTapeView.casesOn vR List.length List.length ≤ 8h2:∀ (L R : List ℕ), evalStackCfg1 m L R = Cfg.headLeft q (applyView vL (encLeft1 L)) (applyView vR (encRight1 R))⊢ ∃ q vL vR,
HalfTapeView.casesOn vL List.length List.length ≤ 8 ∧
HalfTapeView.casesOn vR List.length List.length ≤ 8 ∧
((∀ (L R : List (StackTuple (0 + 2))),
(fun m L R ↦ evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) m L R =
{ q := some q,
tape :=
{ head := 0, left := applyView vL ((fun L ↦ encLeft1 (List.map Prod.fst L)) L),
right := applyView vR ((fun R ↦ encRight1 (List.map Prod.fst R)) R) } }) ∨
(∀ (L R : List (StackTuple (0 + 2))),
(fun m L R ↦ evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) m L R =
Cfg.headLeft q (applyView vL ((fun L ↦ encLeft1 (List.map Prod.fst L)) L))
(applyView vR ((fun R ↦ encRight1 (List.map Prod.fst R)) R))) ∨
∀ (L R : List (StackTuple (0 + 2))),
(fun m L R ↦ evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) m L R =
Cfg.headRight q (applyView vL ((fun L ↦ encLeft1 (List.map Prod.fst L)) L))
(applyView vR ((fun R ↦ encRight1 (List.map Prod.fst R)) R))) exact ⟨q, vL, vR, hl, hr, Or.inr (Or.inl (fun L R => h2 (L.map Prod.fst) (R.map Prod.fst)))⟩ All goals completed! 🐙
· refine_1.inr.inr Λ:Type u_3inst✝:Inhabited Λtarget_tm:Machine (Fin 2) ΛStackMode:TypeencLeft1:List ℕ → ListBlank (Fin 2)encRight1:List ℕ → ListBlank (Fin 2)evalStackCfg1:StackMode → List ℕ → List ℕ → Cfg (Fin 2) ΛIsInStackSystem1:Cfg (Fin 2) Λ → ProphnilL:encLeft1 [] = defaulthnilR:encRight1 [] = defaulthheadL:∀ (a : ℕ) (L : List ℕ), (encLeft1 (a :: L)).head = 1hheadR:∀ (d : ℕ) (R : List ℕ), (encRight1 (d :: R)).head = 1tL:ListBlank (Fin 2)htL:tL.head = 1hnsL:∀ (L : List ℕ), encLeft1 L ≠ tLtR:ListBlank (Fin 2)htR:tR.head = 1hnsR:∀ (R : List ℕ), encRight1 R ≠ tRsL:ℕoL:ℕsepL:ℕsR:ℕoR:ℕsepR:ℕhsL:sL > 0hoL:oL > 0hsepL:sepL > 0hsR:sR > 0hoR:oR > 0hsepR:sepR > 0hblkL:∀ (a : ℕ) (L : List ℕ), encLeft1 (a :: L) = [1] ^ (sL * a + oL) +> [0] ^ sepL +> encLeft1 LhblkR:∀ (d : ℕ) (R : List ℕ), encRight1 (d :: R) = [1] ^ (sR * d + oR) +> [0] ^ sepR +> encRight1 Rhmodes:∃ modes, modes.length ≤ 6 ∧ ∀ (m : StackMode), m ∈ modeshvalid1:IsValidStackModes encLeft1 encRight1 evalStackCfg1hiff1:∀ (cfg : Cfg (Fin 2) Λ), IsInStackSystem1 cfg ↔ ∃ m L R, cfg = evalStackCfg1 m L Rleft✝:∀ (m : StackMode) (L R : List ℕ), IsInStackSystem1 (evalStackCfg1 m L R)hclosed1:∀ (cfg : Cfg (Fin 2) Λ),
IsInStackSystem1 cfg →
∃ cfg', (cfg [target_tm]⊢⁺ cfg') ∧ (IsInStackSystem1 cfg' ∨ (step target_tm cfg').isNone = true)cfg₀:Cfg (Fin 2) Λhinit0:init [] [target_tm]⊢⁺ cfg₀hsys0:IsInStackSystem1 cfg₀m:StackModeq:ΛvL:HalfTapeView (Fin 2)vR:HalfTapeView (Fin 2)hl:HalfTapeView.casesOn vL List.length List.length ≤ 8hr:HalfTapeView.casesOn vR List.length List.length ≤ 8h3:∀ (L R : List ℕ), evalStackCfg1 m L R = Cfg.headRight q (applyView vL (encLeft1 L)) (applyView vR (encRight1 R))⊢ ∃ q vL vR,
HalfTapeView.casesOn vL List.length List.length ≤ 8 ∧
HalfTapeView.casesOn vR List.length List.length ≤ 8 ∧
((∀ (L R : List (StackTuple (0 + 2))),
(fun m L R ↦ evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) m L R =
{ q := some q,
tape :=
{ head := 0, left := applyView vL ((fun L ↦ encLeft1 (List.map Prod.fst L)) L),
right := applyView vR ((fun R ↦ encRight1 (List.map Prod.fst R)) R) } }) ∨
(∀ (L R : List (StackTuple (0 + 2))),
(fun m L R ↦ evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) m L R =
Cfg.headLeft q (applyView vL ((fun L ↦ encLeft1 (List.map Prod.fst L)) L))
(applyView vR ((fun R ↦ encRight1 (List.map Prod.fst R)) R))) ∨
∀ (L R : List (StackTuple (0 + 2))),
(fun m L R ↦ evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) m L R =
Cfg.headRight q (applyView vL ((fun L ↦ encLeft1 (List.map Prod.fst L)) L))
(applyView vR ((fun R ↦ encRight1 (List.map Prod.fst R)) R))) exact ⟨q, vL, vR, hl, hr, Or.inr (Or.inr (fun L R => h3 (L.map Prod.fst) (R.map Prod.fst)))⟩ All goals completed! 🐙
· refine_2 Λ:Type u_3inst✝:Inhabited Λtarget_tm:Machine (Fin 2) ΛStackMode:TypeencLeft1:List ℕ → ListBlank (Fin 2)encRight1:List ℕ → ListBlank (Fin 2)evalStackCfg1:StackMode → List ℕ → List ℕ → Cfg (Fin 2) ΛIsInStackSystem1:Cfg (Fin 2) Λ → ProphnilL:encLeft1 [] = defaulthnilR:encRight1 [] = defaulthheadL:∀ (a : ℕ) (L : List ℕ), (encLeft1 (a :: L)).head = 1hheadR:∀ (d : ℕ) (R : List ℕ), (encRight1 (d :: R)).head = 1tL:ListBlank (Fin 2)htL:tL.head = 1hnsL:∀ (L : List ℕ), encLeft1 L ≠ tLtR:ListBlank (Fin 2)htR:tR.head = 1hnsR:∀ (R : List ℕ), encRight1 R ≠ tRsL:ℕoL:ℕsepL:ℕsR:ℕoR:ℕsepR:ℕhsL:sL > 0hoL:oL > 0hsepL:sepL > 0hsR:sR > 0hoR:oR > 0hsepR:sepR > 0hblkL:∀ (a : ℕ) (L : List ℕ), encLeft1 (a :: L) = [1] ^ (sL * a + oL) +> [0] ^ sepL +> encLeft1 LhblkR:∀ (d : ℕ) (R : List ℕ), encRight1 (d :: R) = [1] ^ (sR * d + oR) +> [0] ^ sepR +> encRight1 Rhmodes:∃ modes, modes.length ≤ 6 ∧ ∀ (m : StackMode), m ∈ modeshvalid1:IsValidStackModes encLeft1 encRight1 evalStackCfg1hiff1:∀ (cfg : Cfg (Fin 2) Λ), IsInStackSystem1 cfg ↔ ∃ m L R, cfg = evalStackCfg1 m L Rleft✝:∀ (m : StackMode) (L R : List ℕ), IsInStackSystem1 (evalStackCfg1 m L R)hclosed1:∀ (cfg : Cfg (Fin 2) Λ),
IsInStackSystem1 cfg →
∃ cfg', (cfg [target_tm]⊢⁺ cfg') ∧ (IsInStackSystem1 cfg' ∨ (step target_tm cfg').isNone = true)cfg₀:Cfg (Fin 2) Λhinit0:init [] [target_tm]⊢⁺ cfg₀hsys0:IsInStackSystem1 cfg₀⊢ ∃ cfg₀,
(init [] [target_tm]⊢⁺ cfg₀) ∧
(fun cfg ↦ ∃ m L R, cfg = evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) cfg₀ rcases (hiff1 cfg₀).mp hsys0 with ⟨m, L1, R1, hcfg0⟩ refine_2 Λ:Type u_3inst✝:Inhabited Λtarget_tm:Machine (Fin 2) ΛStackMode:TypeencLeft1:List ℕ → ListBlank (Fin 2)encRight1:List ℕ → ListBlank (Fin 2)evalStackCfg1:StackMode → List ℕ → List ℕ → Cfg (Fin 2) ΛIsInStackSystem1:Cfg (Fin 2) Λ → ProphnilL:encLeft1 [] = defaulthnilR:encRight1 [] = defaulthheadL:∀ (a : ℕ) (L : List ℕ), (encLeft1 (a :: L)).head = 1hheadR:∀ (d : ℕ) (R : List ℕ), (encRight1 (d :: R)).head = 1tL:ListBlank (Fin 2)htL:tL.head = 1hnsL:∀ (L : List ℕ), encLeft1 L ≠ tLtR:ListBlank (Fin 2)htR:tR.head = 1hnsR:∀ (R : List ℕ), encRight1 R ≠ tRsL:ℕoL:ℕsepL:ℕsR:ℕoR:ℕsepR:ℕhsL:sL > 0hoL:oL > 0hsepL:sepL > 0hsR:sR > 0hoR:oR > 0hsepR:sepR > 0hblkL:∀ (a : ℕ) (L : List ℕ), encLeft1 (a :: L) = [1] ^ (sL * a + oL) +> [0] ^ sepL +> encLeft1 LhblkR:∀ (d : ℕ) (R : List ℕ), encRight1 (d :: R) = [1] ^ (sR * d + oR) +> [0] ^ sepR +> encRight1 Rhmodes:∃ modes, modes.length ≤ 6 ∧ ∀ (m : StackMode), m ∈ modeshvalid1:IsValidStackModes encLeft1 encRight1 evalStackCfg1hiff1:∀ (cfg : Cfg (Fin 2) Λ), IsInStackSystem1 cfg ↔ ∃ m L R, cfg = evalStackCfg1 m L Rleft✝:∀ (m : StackMode) (L R : List ℕ), IsInStackSystem1 (evalStackCfg1 m L R)hclosed1:∀ (cfg : Cfg (Fin 2) Λ),
IsInStackSystem1 cfg →
∃ cfg', (cfg [target_tm]⊢⁺ cfg') ∧ (IsInStackSystem1 cfg' ∨ (step target_tm cfg').isNone = true)cfg₀:Cfg (Fin 2) Λhinit0:init [] [target_tm]⊢⁺ cfg₀hsys0:IsInStackSystem1 cfg₀m:StackModeL1:List ℕR1:List ℕhcfg0:cfg₀ = evalStackCfg1 m L1 R1⊢ ∃ cfg₀,
(init [] [target_tm]⊢⁺ cfg₀) ∧
(fun cfg ↦ ∃ m L R, cfg = evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) cfg₀
refine ⟨cfg₀, hinit0, m, liftPairList L1, liftPairList R1, ?_⟩ refine_2 Λ:Type u_3inst✝:Inhabited Λtarget_tm:Machine (Fin 2) ΛStackMode:TypeencLeft1:List ℕ → ListBlank (Fin 2)encRight1:List ℕ → ListBlank (Fin 2)evalStackCfg1:StackMode → List ℕ → List ℕ → Cfg (Fin 2) ΛIsInStackSystem1:Cfg (Fin 2) Λ → ProphnilL:encLeft1 [] = defaulthnilR:encRight1 [] = defaulthheadL:∀ (a : ℕ) (L : List ℕ), (encLeft1 (a :: L)).head = 1hheadR:∀ (d : ℕ) (R : List ℕ), (encRight1 (d :: R)).head = 1tL:ListBlank (Fin 2)htL:tL.head = 1hnsL:∀ (L : List ℕ), encLeft1 L ≠ tLtR:ListBlank (Fin 2)htR:tR.head = 1hnsR:∀ (R : List ℕ), encRight1 R ≠ tRsL:ℕoL:ℕsepL:ℕsR:ℕoR:ℕsepR:ℕhsL:sL > 0hoL:oL > 0hsepL:sepL > 0hsR:sR > 0hoR:oR > 0hsepR:sepR > 0hblkL:∀ (a : ℕ) (L : List ℕ), encLeft1 (a :: L) = [1] ^ (sL * a + oL) +> [0] ^ sepL +> encLeft1 LhblkR:∀ (d : ℕ) (R : List ℕ), encRight1 (d :: R) = [1] ^ (sR * d + oR) +> [0] ^ sepR +> encRight1 Rhmodes:∃ modes, modes.length ≤ 6 ∧ ∀ (m : StackMode), m ∈ modeshvalid1:IsValidStackModes encLeft1 encRight1 evalStackCfg1hiff1:∀ (cfg : Cfg (Fin 2) Λ), IsInStackSystem1 cfg ↔ ∃ m L R, cfg = evalStackCfg1 m L Rleft✝:∀ (m : StackMode) (L R : List ℕ), IsInStackSystem1 (evalStackCfg1 m L R)hclosed1:∀ (cfg : Cfg (Fin 2) Λ),
IsInStackSystem1 cfg →
∃ cfg', (cfg [target_tm]⊢⁺ cfg') ∧ (IsInStackSystem1 cfg' ∨ (step target_tm cfg').isNone = true)cfg₀:Cfg (Fin 2) Λhinit0:init [] [target_tm]⊢⁺ cfg₀hsys0:IsInStackSystem1 cfg₀m:StackModeL1:List ℕR1:List ℕhcfg0:cfg₀ = evalStackCfg1 m L1 R1⊢ cfg₀ = evalStackCfg1 m (List.map Prod.fst (liftPairList L1)) (List.map Prod.fst (liftPairList R1))
try dsimp refine_2 Λ:Type u_3inst✝:Inhabited Λtarget_tm:Machine (Fin 2) ΛStackMode:TypeencLeft1:List ℕ → ListBlank (Fin 2)encRight1:List ℕ → ListBlank (Fin 2)evalStackCfg1:StackMode → List ℕ → List ℕ → Cfg (Fin 2) ΛIsInStackSystem1:Cfg (Fin 2) Λ → ProphnilL:encLeft1 [] = defaulthnilR:encRight1 [] = defaulthheadL:∀ (a : ℕ) (L : List ℕ), (encLeft1 (a :: L)).head = 1hheadR:∀ (d : ℕ) (R : List ℕ), (encRight1 (d :: R)).head = 1tL:ListBlank (Fin 2)htL:tL.head = 1hnsL:∀ (L : List ℕ), encLeft1 L ≠ tLtR:ListBlank (Fin 2)htR:tR.head = 1hnsR:∀ (R : List ℕ), encRight1 R ≠ tRsL:ℕoL:ℕsepL:ℕsR:ℕoR:ℕsepR:ℕhsL:sL > 0hoL:oL > 0hsepL:sepL > 0hsR:sR > 0hoR:oR > 0hsepR:sepR > 0hblkL:∀ (a : ℕ) (L : List ℕ), encLeft1 (a :: L) = [1] ^ (sL * a + oL) +> [0] ^ sepL +> encLeft1 LhblkR:∀ (d : ℕ) (R : List ℕ), encRight1 (d :: R) = [1] ^ (sR * d + oR) +> [0] ^ sepR +> encRight1 Rhmodes:∃ modes, modes.length ≤ 6 ∧ ∀ (m : StackMode), m ∈ modeshvalid1:IsValidStackModes encLeft1 encRight1 evalStackCfg1hiff1:∀ (cfg : Cfg (Fin 2) Λ), IsInStackSystem1 cfg ↔ ∃ m L R, cfg = evalStackCfg1 m L Rleft✝:∀ (m : StackMode) (L R : List ℕ), IsInStackSystem1 (evalStackCfg1 m L R)hclosed1:∀ (cfg : Cfg (Fin 2) Λ),
IsInStackSystem1 cfg →
∃ cfg', (cfg [target_tm]⊢⁺ cfg') ∧ (IsInStackSystem1 cfg' ∨ (step target_tm cfg').isNone = true)cfg₀:Cfg (Fin 2) Λhinit0:init [] [target_tm]⊢⁺ cfg₀hsys0:IsInStackSystem1 cfg₀m:StackModeL1:List ℕR1:List ℕhcfg0:cfg₀ = evalStackCfg1 m L1 R1⊢ cfg₀ = evalStackCfg1 m (List.map Prod.fst (liftPairList L1)) (List.map Prod.fst (liftPairList R1))
rw [map_fst_liftPairList, refine_2 Λ:Type u_3inst✝:Inhabited Λtarget_tm:Machine (Fin 2) ΛStackMode:TypeencLeft1:List ℕ → ListBlank (Fin 2)encRight1:List ℕ → ListBlank (Fin 2)evalStackCfg1:StackMode → List ℕ → List ℕ → Cfg (Fin 2) ΛIsInStackSystem1:Cfg (Fin 2) Λ → ProphnilL:encLeft1 [] = defaulthnilR:encRight1 [] = defaulthheadL:∀ (a : ℕ) (L : List ℕ), (encLeft1 (a :: L)).head = 1hheadR:∀ (d : ℕ) (R : List ℕ), (encRight1 (d :: R)).head = 1tL:ListBlank (Fin 2)htL:tL.head = 1hnsL:∀ (L : List ℕ), encLeft1 L ≠ tLtR:ListBlank (Fin 2)htR:tR.head = 1hnsR:∀ (R : List ℕ), encRight1 R ≠ tRsL:ℕoL:ℕsepL:ℕsR:ℕoR:ℕsepR:ℕhsL:sL > 0hoL:oL > 0hsepL:sepL > 0hsR:sR > 0hoR:oR > 0hsepR:sepR > 0hblkL:∀ (a : ℕ) (L : List ℕ), encLeft1 (a :: L) = [1] ^ (sL * a + oL) +> [0] ^ sepL +> encLeft1 LhblkR:∀ (d : ℕ) (R : List ℕ), encRight1 (d :: R) = [1] ^ (sR * d + oR) +> [0] ^ sepR +> encRight1 Rhmodes:∃ modes, modes.length ≤ 6 ∧ ∀ (m : StackMode), m ∈ modeshvalid1:IsValidStackModes encLeft1 encRight1 evalStackCfg1hiff1:∀ (cfg : Cfg (Fin 2) Λ), IsInStackSystem1 cfg ↔ ∃ m L R, cfg = evalStackCfg1 m L Rleft✝:∀ (m : StackMode) (L R : List ℕ), IsInStackSystem1 (evalStackCfg1 m L R)hclosed1:∀ (cfg : Cfg (Fin 2) Λ),
IsInStackSystem1 cfg →
∃ cfg', (cfg [target_tm]⊢⁺ cfg') ∧ (IsInStackSystem1 cfg' ∨ (step target_tm cfg').isNone = true)cfg₀:Cfg (Fin 2) Λhinit0:init [] [target_tm]⊢⁺ cfg₀hsys0:IsInStackSystem1 cfg₀m:StackModeL1:List ℕR1:List ℕhcfg0:cfg₀ = evalStackCfg1 m L1 R1⊢ cfg₀ = evalStackCfg1 m L1 (List.map Prod.fst (liftPairList R1)) map_fst_liftPairList refine_2 Λ:Type u_3inst✝:Inhabited Λtarget_tm:Machine (Fin 2) ΛStackMode:TypeencLeft1:List ℕ → ListBlank (Fin 2)encRight1:List ℕ → ListBlank (Fin 2)evalStackCfg1:StackMode → List ℕ → List ℕ → Cfg (Fin 2) ΛIsInStackSystem1:Cfg (Fin 2) Λ → ProphnilL:encLeft1 [] = defaulthnilR:encRight1 [] = defaulthheadL:∀ (a : ℕ) (L : List ℕ), (encLeft1 (a :: L)).head = 1hheadR:∀ (d : ℕ) (R : List ℕ), (encRight1 (d :: R)).head = 1tL:ListBlank (Fin 2)htL:tL.head = 1hnsL:∀ (L : List ℕ), encLeft1 L ≠ tLtR:ListBlank (Fin 2)htR:tR.head = 1hnsR:∀ (R : List ℕ), encRight1 R ≠ tRsL:ℕoL:ℕsepL:ℕsR:ℕoR:ℕsepR:ℕhsL:sL > 0hoL:oL > 0hsepL:sepL > 0hsR:sR > 0hoR:oR > 0hsepR:sepR > 0hblkL:∀ (a : ℕ) (L : List ℕ), encLeft1 (a :: L) = [1] ^ (sL * a + oL) +> [0] ^ sepL +> encLeft1 LhblkR:∀ (d : ℕ) (R : List ℕ), encRight1 (d :: R) = [1] ^ (sR * d + oR) +> [0] ^ sepR +> encRight1 Rhmodes:∃ modes, modes.length ≤ 6 ∧ ∀ (m : StackMode), m ∈ modeshvalid1:IsValidStackModes encLeft1 encRight1 evalStackCfg1hiff1:∀ (cfg : Cfg (Fin 2) Λ), IsInStackSystem1 cfg ↔ ∃ m L R, cfg = evalStackCfg1 m L Rleft✝:∀ (m : StackMode) (L R : List ℕ), IsInStackSystem1 (evalStackCfg1 m L R)hclosed1:∀ (cfg : Cfg (Fin 2) Λ),
IsInStackSystem1 cfg →
∃ cfg', (cfg [target_tm]⊢⁺ cfg') ∧ (IsInStackSystem1 cfg' ∨ (step target_tm cfg').isNone = true)cfg₀:Cfg (Fin 2) Λhinit0:init [] [target_tm]⊢⁺ cfg₀hsys0:IsInStackSystem1 cfg₀m:StackModeL1:List ℕR1:List ℕhcfg0:cfg₀ = evalStackCfg1 m L1 R1⊢ cfg₀ = evalStackCfg1 m L1 R1] refine_2 Λ:Type u_3inst✝:Inhabited Λtarget_tm:Machine (Fin 2) ΛStackMode:TypeencLeft1:List ℕ → ListBlank (Fin 2)encRight1:List ℕ → ListBlank (Fin 2)evalStackCfg1:StackMode → List ℕ → List ℕ → Cfg (Fin 2) ΛIsInStackSystem1:Cfg (Fin 2) Λ → ProphnilL:encLeft1 [] = defaulthnilR:encRight1 [] = defaulthheadL:∀ (a : ℕ) (L : List ℕ), (encLeft1 (a :: L)).head = 1hheadR:∀ (d : ℕ) (R : List ℕ), (encRight1 (d :: R)).head = 1tL:ListBlank (Fin 2)htL:tL.head = 1hnsL:∀ (L : List ℕ), encLeft1 L ≠ tLtR:ListBlank (Fin 2)htR:tR.head = 1hnsR:∀ (R : List ℕ), encRight1 R ≠ tRsL:ℕoL:ℕsepL:ℕsR:ℕoR:ℕsepR:ℕhsL:sL > 0hoL:oL > 0hsepL:sepL > 0hsR:sR > 0hoR:oR > 0hsepR:sepR > 0hblkL:∀ (a : ℕ) (L : List ℕ), encLeft1 (a :: L) = [1] ^ (sL * a + oL) +> [0] ^ sepL +> encLeft1 LhblkR:∀ (d : ℕ) (R : List ℕ), encRight1 (d :: R) = [1] ^ (sR * d + oR) +> [0] ^ sepR +> encRight1 Rhmodes:∃ modes, modes.length ≤ 6 ∧ ∀ (m : StackMode), m ∈ modeshvalid1:IsValidStackModes encLeft1 encRight1 evalStackCfg1hiff1:∀ (cfg : Cfg (Fin 2) Λ), IsInStackSystem1 cfg ↔ ∃ m L R, cfg = evalStackCfg1 m L Rleft✝:∀ (m : StackMode) (L R : List ℕ), IsInStackSystem1 (evalStackCfg1 m L R)hclosed1:∀ (cfg : Cfg (Fin 2) Λ),
IsInStackSystem1 cfg →
∃ cfg', (cfg [target_tm]⊢⁺ cfg') ∧ (IsInStackSystem1 cfg' ∨ (step target_tm cfg').isNone = true)cfg₀:Cfg (Fin 2) Λhinit0:init [] [target_tm]⊢⁺ cfg₀hsys0:IsInStackSystem1 cfg₀m:StackModeL1:List ℕR1:List ℕhcfg0:cfg₀ = evalStackCfg1 m L1 R1⊢ cfg₀ = evalStackCfg1 m L1 R1
exact hcfg0 All goals completed! 🐙
· refine_3 Λ:Type u_3inst✝:Inhabited Λtarget_tm:Machine (Fin 2) ΛStackMode:TypeencLeft1:List ℕ → ListBlank (Fin 2)encRight1:List ℕ → ListBlank (Fin 2)evalStackCfg1:StackMode → List ℕ → List ℕ → Cfg (Fin 2) ΛIsInStackSystem1:Cfg (Fin 2) Λ → ProphnilL:encLeft1 [] = defaulthnilR:encRight1 [] = defaulthheadL:∀ (a : ℕ) (L : List ℕ), (encLeft1 (a :: L)).head = 1hheadR:∀ (d : ℕ) (R : List ℕ), (encRight1 (d :: R)).head = 1tL:ListBlank (Fin 2)htL:tL.head = 1hnsL:∀ (L : List ℕ), encLeft1 L ≠ tLtR:ListBlank (Fin 2)htR:tR.head = 1hnsR:∀ (R : List ℕ), encRight1 R ≠ tRsL:ℕoL:ℕsepL:ℕsR:ℕoR:ℕsepR:ℕhsL:sL > 0hoL:oL > 0hsepL:sepL > 0hsR:sR > 0hoR:oR > 0hsepR:sepR > 0hblkL:∀ (a : ℕ) (L : List ℕ), encLeft1 (a :: L) = [1] ^ (sL * a + oL) +> [0] ^ sepL +> encLeft1 LhblkR:∀ (d : ℕ) (R : List ℕ), encRight1 (d :: R) = [1] ^ (sR * d + oR) +> [0] ^ sepR +> encRight1 Rhmodes:∃ modes, modes.length ≤ 6 ∧ ∀ (m : StackMode), m ∈ modeshvalid1:IsValidStackModes encLeft1 encRight1 evalStackCfg1hiff1:∀ (cfg : Cfg (Fin 2) Λ), IsInStackSystem1 cfg ↔ ∃ m L R, cfg = evalStackCfg1 m L Rleft✝:∀ (m : StackMode) (L R : List ℕ), IsInStackSystem1 (evalStackCfg1 m L R)hclosed1:∀ (cfg : Cfg (Fin 2) Λ),
IsInStackSystem1 cfg →
∃ cfg', (cfg [target_tm]⊢⁺ cfg') ∧ (IsInStackSystem1 cfg' ∨ (step target_tm cfg').isNone = true)cfg₀:Cfg (Fin 2) Λhinit0:init [] [target_tm]⊢⁺ cfg₀hsys0:IsInStackSystem1 cfg₀⊢ ∀ (cfg : Cfg (Fin (0 + 2)) Λ),
(fun cfg ↦ ∃ m L R, cfg = evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) cfg →
∃ cfg',
(cfg [target_tm]⊢⁺ cfg') ∧
((fun cfg ↦ ∃ m L R, cfg = evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) cfg' ∨
(step target_tm cfg').isNone = true) intro cfg ⟨m, L, R, hcfg⟩ refine_3 Λ:Type u_3inst✝:Inhabited Λtarget_tm:Machine (Fin 2) ΛStackMode:TypeencLeft1:List ℕ → ListBlank (Fin 2)encRight1:List ℕ → ListBlank (Fin 2)evalStackCfg1:StackMode → List ℕ → List ℕ → Cfg (Fin 2) ΛIsInStackSystem1:Cfg (Fin 2) Λ → ProphnilL:encLeft1 [] = defaulthnilR:encRight1 [] = defaulthheadL:∀ (a : ℕ) (L : List ℕ), (encLeft1 (a :: L)).head = 1hheadR:∀ (d : ℕ) (R : List ℕ), (encRight1 (d :: R)).head = 1tL:ListBlank (Fin 2)htL:tL.head = 1hnsL:∀ (L : List ℕ), encLeft1 L ≠ tLtR:ListBlank (Fin 2)htR:tR.head = 1hnsR:∀ (R : List ℕ), encRight1 R ≠ tRsL:ℕoL:ℕsepL:ℕsR:ℕoR:ℕsepR:ℕhsL:sL > 0hoL:oL > 0hsepL:sepL > 0hsR:sR > 0hoR:oR > 0hsepR:sepR > 0hblkL:∀ (a : ℕ) (L : List ℕ), encLeft1 (a :: L) = [1] ^ (sL * a + oL) +> [0] ^ sepL +> encLeft1 LhblkR:∀ (d : ℕ) (R : List ℕ), encRight1 (d :: R) = [1] ^ (sR * d + oR) +> [0] ^ sepR +> encRight1 Rhmodes:∃ modes, modes.length ≤ 6 ∧ ∀ (m : StackMode), m ∈ modeshvalid1:IsValidStackModes encLeft1 encRight1 evalStackCfg1hiff1:∀ (cfg : Cfg (Fin 2) Λ), IsInStackSystem1 cfg ↔ ∃ m L R, cfg = evalStackCfg1 m L Rleft✝:∀ (m : StackMode) (L R : List ℕ), IsInStackSystem1 (evalStackCfg1 m L R)hclosed1:∀ (cfg : Cfg (Fin 2) Λ),
IsInStackSystem1 cfg →
∃ cfg', (cfg [target_tm]⊢⁺ cfg') ∧ (IsInStackSystem1 cfg' ∨ (step target_tm cfg').isNone = true)cfg₀:Cfg (Fin 2) Λhinit0:init [] [target_tm]⊢⁺ cfg₀hsys0:IsInStackSystem1 cfg₀cfg:Cfg (Fin (0 + 2)) Λm:StackModeL:List (ℕ × ℕ)R:List (ℕ × ℕ)hcfg:cfg = evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)⊢ ∃ cfg',
(cfg [target_tm]⊢⁺ cfg') ∧
((fun cfg ↦ ∃ m L R, cfg = evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) cfg' ∨
(step target_tm cfg').isNone = true)
have hsys1 : IsInStackSystem1 cfg := (hiff1 cfg).mpr ⟨m, L.map Prod.fst, R.map Prod.fst, hcfg⟩ refine_3 Λ:Type u_3inst✝:Inhabited Λtarget_tm:Machine (Fin 2) ΛStackMode:TypeencLeft1:List ℕ → ListBlank (Fin 2)encRight1:List ℕ → ListBlank (Fin 2)evalStackCfg1:StackMode → List ℕ → List ℕ → Cfg (Fin 2) ΛIsInStackSystem1:Cfg (Fin 2) Λ → ProphnilL:encLeft1 [] = defaulthnilR:encRight1 [] = defaulthheadL:∀ (a : ℕ) (L : List ℕ), (encLeft1 (a :: L)).head = 1hheadR:∀ (d : ℕ) (R : List ℕ), (encRight1 (d :: R)).head = 1tL:ListBlank (Fin 2)htL:tL.head = 1hnsL:∀ (L : List ℕ), encLeft1 L ≠ tLtR:ListBlank (Fin 2)htR:tR.head = 1hnsR:∀ (R : List ℕ), encRight1 R ≠ tRsL:ℕoL:ℕsepL:ℕsR:ℕoR:ℕsepR:ℕhsL:sL > 0hoL:oL > 0hsepL:sepL > 0hsR:sR > 0hoR:oR > 0hsepR:sepR > 0hblkL:∀ (a : ℕ) (L : List ℕ), encLeft1 (a :: L) = [1] ^ (sL * a + oL) +> [0] ^ sepL +> encLeft1 LhblkR:∀ (d : ℕ) (R : List ℕ), encRight1 (d :: R) = [1] ^ (sR * d + oR) +> [0] ^ sepR +> encRight1 Rhmodes:∃ modes, modes.length ≤ 6 ∧ ∀ (m : StackMode), m ∈ modeshvalid1:IsValidStackModes encLeft1 encRight1 evalStackCfg1hiff1:∀ (cfg : Cfg (Fin 2) Λ), IsInStackSystem1 cfg ↔ ∃ m L R, cfg = evalStackCfg1 m L Rleft✝:∀ (m : StackMode) (L R : List ℕ), IsInStackSystem1 (evalStackCfg1 m L R)hclosed1:∀ (cfg : Cfg (Fin 2) Λ),
IsInStackSystem1 cfg →
∃ cfg', (cfg [target_tm]⊢⁺ cfg') ∧ (IsInStackSystem1 cfg' ∨ (step target_tm cfg').isNone = true)cfg₀:Cfg (Fin 2) Λhinit0:init [] [target_tm]⊢⁺ cfg₀hsys0:IsInStackSystem1 cfg₀cfg:Cfg (Fin (0 + 2)) Λm:StackModeL:List (ℕ × ℕ)R:List (ℕ × ℕ)hcfg:cfg = evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)hsys1:IsInStackSystem1 cfg⊢ ∃ cfg',
(cfg [target_tm]⊢⁺ cfg') ∧
((fun cfg ↦ ∃ m L R, cfg = evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) cfg' ∨
(step target_tm cfg').isNone = true)
rcases hclosed1 cfg hsys1 with ⟨cfg', hstep, hnext | hhalt⟩ refine_3.inl Λ:Type u_3inst✝:Inhabited Λtarget_tm:Machine (Fin 2) ΛStackMode:TypeencLeft1:List ℕ → ListBlank (Fin 2)encRight1:List ℕ → ListBlank (Fin 2)evalStackCfg1:StackMode → List ℕ → List ℕ → Cfg (Fin 2) ΛIsInStackSystem1:Cfg (Fin 2) Λ → ProphnilL:encLeft1 [] = defaulthnilR:encRight1 [] = defaulthheadL:∀ (a : ℕ) (L : List ℕ), (encLeft1 (a :: L)).head = 1hheadR:∀ (d : ℕ) (R : List ℕ), (encRight1 (d :: R)).head = 1tL:ListBlank (Fin 2)htL:tL.head = 1hnsL:∀ (L : List ℕ), encLeft1 L ≠ tLtR:ListBlank (Fin 2)htR:tR.head = 1hnsR:∀ (R : List ℕ), encRight1 R ≠ tRsL:ℕoL:ℕsepL:ℕsR:ℕoR:ℕsepR:ℕhsL:sL > 0hoL:oL > 0hsepL:sepL > 0hsR:sR > 0hoR:oR > 0hsepR:sepR > 0hblkL:∀ (a : ℕ) (L : List ℕ), encLeft1 (a :: L) = [1] ^ (sL * a + oL) +> [0] ^ sepL +> encLeft1 LhblkR:∀ (d : ℕ) (R : List ℕ), encRight1 (d :: R) = [1] ^ (sR * d + oR) +> [0] ^ sepR +> encRight1 Rhmodes:∃ modes, modes.length ≤ 6 ∧ ∀ (m : StackMode), m ∈ modeshvalid1:IsValidStackModes encLeft1 encRight1 evalStackCfg1hiff1:∀ (cfg : Cfg (Fin 2) Λ), IsInStackSystem1 cfg ↔ ∃ m L R, cfg = evalStackCfg1 m L Rleft✝:∀ (m : StackMode) (L R : List ℕ), IsInStackSystem1 (evalStackCfg1 m L R)hclosed1:∀ (cfg : Cfg (Fin 2) Λ),
IsInStackSystem1 cfg →
∃ cfg', (cfg [target_tm]⊢⁺ cfg') ∧ (IsInStackSystem1 cfg' ∨ (step target_tm cfg').isNone = true)cfg₀:Cfg (Fin 2) Λhinit0:init [] [target_tm]⊢⁺ cfg₀hsys0:IsInStackSystem1 cfg₀cfg:Cfg (Fin (0 + 2)) Λm:StackModeL:List (ℕ × ℕ)R:List (ℕ × ℕ)hcfg:cfg = evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)hsys1:IsInStackSystem1 cfgcfg':Cfg (Fin 2) Λhstep:cfg [target_tm]⊢⁺ cfg'hnext:IsInStackSystem1 cfg'⊢ ∃ cfg',
(cfg [target_tm]⊢⁺ cfg') ∧
((fun cfg ↦ ∃ m L R, cfg = evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) cfg' ∨
(step target_tm cfg').isNone = true)refine_3.inr Λ:Type u_3inst✝:Inhabited Λtarget_tm:Machine (Fin 2) ΛStackMode:TypeencLeft1:List ℕ → ListBlank (Fin 2)encRight1:List ℕ → ListBlank (Fin 2)evalStackCfg1:StackMode → List ℕ → List ℕ → Cfg (Fin 2) ΛIsInStackSystem1:Cfg (Fin 2) Λ → ProphnilL:encLeft1 [] = defaulthnilR:encRight1 [] = defaulthheadL:∀ (a : ℕ) (L : List ℕ), (encLeft1 (a :: L)).head = 1hheadR:∀ (d : ℕ) (R : List ℕ), (encRight1 (d :: R)).head = 1tL:ListBlank (Fin 2)htL:tL.head = 1hnsL:∀ (L : List ℕ), encLeft1 L ≠ tLtR:ListBlank (Fin 2)htR:tR.head = 1hnsR:∀ (R : List ℕ), encRight1 R ≠ tRsL:ℕoL:ℕsepL:ℕsR:ℕoR:ℕsepR:ℕhsL:sL > 0hoL:oL > 0hsepL:sepL > 0hsR:sR > 0hoR:oR > 0hsepR:sepR > 0hblkL:∀ (a : ℕ) (L : List ℕ), encLeft1 (a :: L) = [1] ^ (sL * a + oL) +> [0] ^ sepL +> encLeft1 LhblkR:∀ (d : ℕ) (R : List ℕ), encRight1 (d :: R) = [1] ^ (sR * d + oR) +> [0] ^ sepR +> encRight1 Rhmodes:∃ modes, modes.length ≤ 6 ∧ ∀ (m : StackMode), m ∈ modeshvalid1:IsValidStackModes encLeft1 encRight1 evalStackCfg1hiff1:∀ (cfg : Cfg (Fin 2) Λ), IsInStackSystem1 cfg ↔ ∃ m L R, cfg = evalStackCfg1 m L Rleft✝:∀ (m : StackMode) (L R : List ℕ), IsInStackSystem1 (evalStackCfg1 m L R)hclosed1:∀ (cfg : Cfg (Fin 2) Λ),
IsInStackSystem1 cfg →
∃ cfg', (cfg [target_tm]⊢⁺ cfg') ∧ (IsInStackSystem1 cfg' ∨ (step target_tm cfg').isNone = true)cfg₀:Cfg (Fin 2) Λhinit0:init [] [target_tm]⊢⁺ cfg₀hsys0:IsInStackSystem1 cfg₀cfg:Cfg (Fin (0 + 2)) Λm:StackModeL:List (ℕ × ℕ)R:List (ℕ × ℕ)hcfg:cfg = evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)hsys1:IsInStackSystem1 cfgcfg':Cfg (Fin 2) Λhstep:cfg [target_tm]⊢⁺ cfg'hhalt:(step target_tm cfg').isNone = true⊢ ∃ cfg',
(cfg [target_tm]⊢⁺ cfg') ∧
((fun cfg ↦ ∃ m L R, cfg = evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) cfg' ∨
(step target_tm cfg').isNone = true)
· refine_3.inl Λ:Type u_3inst✝:Inhabited Λtarget_tm:Machine (Fin 2) ΛStackMode:TypeencLeft1:List ℕ → ListBlank (Fin 2)encRight1:List ℕ → ListBlank (Fin 2)evalStackCfg1:StackMode → List ℕ → List ℕ → Cfg (Fin 2) ΛIsInStackSystem1:Cfg (Fin 2) Λ → ProphnilL:encLeft1 [] = defaulthnilR:encRight1 [] = defaulthheadL:∀ (a : ℕ) (L : List ℕ), (encLeft1 (a :: L)).head = 1hheadR:∀ (d : ℕ) (R : List ℕ), (encRight1 (d :: R)).head = 1tL:ListBlank (Fin 2)htL:tL.head = 1hnsL:∀ (L : List ℕ), encLeft1 L ≠ tLtR:ListBlank (Fin 2)htR:tR.head = 1hnsR:∀ (R : List ℕ), encRight1 R ≠ tRsL:ℕoL:ℕsepL:ℕsR:ℕoR:ℕsepR:ℕhsL:sL > 0hoL:oL > 0hsepL:sepL > 0hsR:sR > 0hoR:oR > 0hsepR:sepR > 0hblkL:∀ (a : ℕ) (L : List ℕ), encLeft1 (a :: L) = [1] ^ (sL * a + oL) +> [0] ^ sepL +> encLeft1 LhblkR:∀ (d : ℕ) (R : List ℕ), encRight1 (d :: R) = [1] ^ (sR * d + oR) +> [0] ^ sepR +> encRight1 Rhmodes:∃ modes, modes.length ≤ 6 ∧ ∀ (m : StackMode), m ∈ modeshvalid1:IsValidStackModes encLeft1 encRight1 evalStackCfg1hiff1:∀ (cfg : Cfg (Fin 2) Λ), IsInStackSystem1 cfg ↔ ∃ m L R, cfg = evalStackCfg1 m L Rleft✝:∀ (m : StackMode) (L R : List ℕ), IsInStackSystem1 (evalStackCfg1 m L R)hclosed1:∀ (cfg : Cfg (Fin 2) Λ),
IsInStackSystem1 cfg →
∃ cfg', (cfg [target_tm]⊢⁺ cfg') ∧ (IsInStackSystem1 cfg' ∨ (step target_tm cfg').isNone = true)cfg₀:Cfg (Fin 2) Λhinit0:init [] [target_tm]⊢⁺ cfg₀hsys0:IsInStackSystem1 cfg₀cfg:Cfg (Fin (0 + 2)) Λm:StackModeL:List (ℕ × ℕ)R:List (ℕ × ℕ)hcfg:cfg = evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)hsys1:IsInStackSystem1 cfgcfg':Cfg (Fin 2) Λhstep:cfg [target_tm]⊢⁺ cfg'hnext:IsInStackSystem1 cfg'⊢ ∃ cfg',
(cfg [target_tm]⊢⁺ cfg') ∧
((fun cfg ↦ ∃ m L R, cfg = evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) cfg' ∨
(step target_tm cfg').isNone = true) rcases (hiff1 cfg').mp hnext with ⟨m', L1', R1', hcfg'⟩ refine_3.inl Λ:Type u_3inst✝:Inhabited Λtarget_tm:Machine (Fin 2) ΛStackMode:TypeencLeft1:List ℕ → ListBlank (Fin 2)encRight1:List ℕ → ListBlank (Fin 2)evalStackCfg1:StackMode → List ℕ → List ℕ → Cfg (Fin 2) ΛIsInStackSystem1:Cfg (Fin 2) Λ → ProphnilL:encLeft1 [] = defaulthnilR:encRight1 [] = defaulthheadL:∀ (a : ℕ) (L : List ℕ), (encLeft1 (a :: L)).head = 1hheadR:∀ (d : ℕ) (R : List ℕ), (encRight1 (d :: R)).head = 1tL:ListBlank (Fin 2)htL:tL.head = 1hnsL:∀ (L : List ℕ), encLeft1 L ≠ tLtR:ListBlank (Fin 2)htR:tR.head = 1hnsR:∀ (R : List ℕ), encRight1 R ≠ tRsL:ℕoL:ℕsepL:ℕsR:ℕoR:ℕsepR:ℕhsL:sL > 0hoL:oL > 0hsepL:sepL > 0hsR:sR > 0hoR:oR > 0hsepR:sepR > 0hblkL:∀ (a : ℕ) (L : List ℕ), encLeft1 (a :: L) = [1] ^ (sL * a + oL) +> [0] ^ sepL +> encLeft1 LhblkR:∀ (d : ℕ) (R : List ℕ), encRight1 (d :: R) = [1] ^ (sR * d + oR) +> [0] ^ sepR +> encRight1 Rhmodes:∃ modes, modes.length ≤ 6 ∧ ∀ (m : StackMode), m ∈ modeshvalid1:IsValidStackModes encLeft1 encRight1 evalStackCfg1hiff1:∀ (cfg : Cfg (Fin 2) Λ), IsInStackSystem1 cfg ↔ ∃ m L R, cfg = evalStackCfg1 m L Rleft✝:∀ (m : StackMode) (L R : List ℕ), IsInStackSystem1 (evalStackCfg1 m L R)hclosed1:∀ (cfg : Cfg (Fin 2) Λ),
IsInStackSystem1 cfg →
∃ cfg', (cfg [target_tm]⊢⁺ cfg') ∧ (IsInStackSystem1 cfg' ∨ (step target_tm cfg').isNone = true)cfg₀:Cfg (Fin 2) Λhinit0:init [] [target_tm]⊢⁺ cfg₀hsys0:IsInStackSystem1 cfg₀cfg:Cfg (Fin (0 + 2)) Λm:StackModeL:List (ℕ × ℕ)R:List (ℕ × ℕ)hcfg:cfg = evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)hsys1:IsInStackSystem1 cfgcfg':Cfg (Fin 2) Λhstep:cfg [target_tm]⊢⁺ cfg'hnext:IsInStackSystem1 cfg'm':StackModeL1':List ℕR1':List ℕhcfg':cfg' = evalStackCfg1 m' L1' R1'⊢ ∃ cfg',
(cfg [target_tm]⊢⁺ cfg') ∧
((fun cfg ↦ ∃ m L R, cfg = evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) cfg' ∨
(step target_tm cfg').isNone = true)
refine ⟨cfg', hstep, Or.inl ⟨m', liftPairList L1', liftPairList R1', ?_⟩⟩ refine_3.inl Λ:Type u_3inst✝:Inhabited Λtarget_tm:Machine (Fin 2) ΛStackMode:TypeencLeft1:List ℕ → ListBlank (Fin 2)encRight1:List ℕ → ListBlank (Fin 2)evalStackCfg1:StackMode → List ℕ → List ℕ → Cfg (Fin 2) ΛIsInStackSystem1:Cfg (Fin 2) Λ → ProphnilL:encLeft1 [] = defaulthnilR:encRight1 [] = defaulthheadL:∀ (a : ℕ) (L : List ℕ), (encLeft1 (a :: L)).head = 1hheadR:∀ (d : ℕ) (R : List ℕ), (encRight1 (d :: R)).head = 1tL:ListBlank (Fin 2)htL:tL.head = 1hnsL:∀ (L : List ℕ), encLeft1 L ≠ tLtR:ListBlank (Fin 2)htR:tR.head = 1hnsR:∀ (R : List ℕ), encRight1 R ≠ tRsL:ℕoL:ℕsepL:ℕsR:ℕoR:ℕsepR:ℕhsL:sL > 0hoL:oL > 0hsepL:sepL > 0hsR:sR > 0hoR:oR > 0hsepR:sepR > 0hblkL:∀ (a : ℕ) (L : List ℕ), encLeft1 (a :: L) = [1] ^ (sL * a + oL) +> [0] ^ sepL +> encLeft1 LhblkR:∀ (d : ℕ) (R : List ℕ), encRight1 (d :: R) = [1] ^ (sR * d + oR) +> [0] ^ sepR +> encRight1 Rhmodes:∃ modes, modes.length ≤ 6 ∧ ∀ (m : StackMode), m ∈ modeshvalid1:IsValidStackModes encLeft1 encRight1 evalStackCfg1hiff1:∀ (cfg : Cfg (Fin 2) Λ), IsInStackSystem1 cfg ↔ ∃ m L R, cfg = evalStackCfg1 m L Rleft✝:∀ (m : StackMode) (L R : List ℕ), IsInStackSystem1 (evalStackCfg1 m L R)hclosed1:∀ (cfg : Cfg (Fin 2) Λ),
IsInStackSystem1 cfg →
∃ cfg', (cfg [target_tm]⊢⁺ cfg') ∧ (IsInStackSystem1 cfg' ∨ (step target_tm cfg').isNone = true)cfg₀:Cfg (Fin 2) Λhinit0:init [] [target_tm]⊢⁺ cfg₀hsys0:IsInStackSystem1 cfg₀cfg:Cfg (Fin (0 + 2)) Λm:StackModeL:List (ℕ × ℕ)R:List (ℕ × ℕ)hcfg:cfg = evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)hsys1:IsInStackSystem1 cfgcfg':Cfg (Fin 2) Λhstep:cfg [target_tm]⊢⁺ cfg'hnext:IsInStackSystem1 cfg'm':StackModeL1':List ℕR1':List ℕhcfg':cfg' = evalStackCfg1 m' L1' R1'⊢ cfg' = evalStackCfg1 m' (List.map Prod.fst (liftPairList L1')) (List.map Prod.fst (liftPairList R1'))
try dsimp refine_3.inl Λ:Type u_3inst✝:Inhabited Λtarget_tm:Machine (Fin 2) ΛStackMode:TypeencLeft1:List ℕ → ListBlank (Fin 2)encRight1:List ℕ → ListBlank (Fin 2)evalStackCfg1:StackMode → List ℕ → List ℕ → Cfg (Fin 2) ΛIsInStackSystem1:Cfg (Fin 2) Λ → ProphnilL:encLeft1 [] = defaulthnilR:encRight1 [] = defaulthheadL:∀ (a : ℕ) (L : List ℕ), (encLeft1 (a :: L)).head = 1hheadR:∀ (d : ℕ) (R : List ℕ), (encRight1 (d :: R)).head = 1tL:ListBlank (Fin 2)htL:tL.head = 1hnsL:∀ (L : List ℕ), encLeft1 L ≠ tLtR:ListBlank (Fin 2)htR:tR.head = 1hnsR:∀ (R : List ℕ), encRight1 R ≠ tRsL:ℕoL:ℕsepL:ℕsR:ℕoR:ℕsepR:ℕhsL:sL > 0hoL:oL > 0hsepL:sepL > 0hsR:sR > 0hoR:oR > 0hsepR:sepR > 0hblkL:∀ (a : ℕ) (L : List ℕ), encLeft1 (a :: L) = [1] ^ (sL * a + oL) +> [0] ^ sepL +> encLeft1 LhblkR:∀ (d : ℕ) (R : List ℕ), encRight1 (d :: R) = [1] ^ (sR * d + oR) +> [0] ^ sepR +> encRight1 Rhmodes:∃ modes, modes.length ≤ 6 ∧ ∀ (m : StackMode), m ∈ modeshvalid1:IsValidStackModes encLeft1 encRight1 evalStackCfg1hiff1:∀ (cfg : Cfg (Fin 2) Λ), IsInStackSystem1 cfg ↔ ∃ m L R, cfg = evalStackCfg1 m L Rleft✝:∀ (m : StackMode) (L R : List ℕ), IsInStackSystem1 (evalStackCfg1 m L R)hclosed1:∀ (cfg : Cfg (Fin 2) Λ),
IsInStackSystem1 cfg →
∃ cfg', (cfg [target_tm]⊢⁺ cfg') ∧ (IsInStackSystem1 cfg' ∨ (step target_tm cfg').isNone = true)cfg₀:Cfg (Fin 2) Λhinit0:init [] [target_tm]⊢⁺ cfg₀hsys0:IsInStackSystem1 cfg₀cfg:Cfg (Fin (0 + 2)) Λm:StackModeL:List (ℕ × ℕ)R:List (ℕ × ℕ)hcfg:cfg = evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)hsys1:IsInStackSystem1 cfgcfg':Cfg (Fin 2) Λhstep:cfg [target_tm]⊢⁺ cfg'hnext:IsInStackSystem1 cfg'm':StackModeL1':List ℕR1':List ℕhcfg':cfg' = evalStackCfg1 m' L1' R1'⊢ cfg' = evalStackCfg1 m' (List.map Prod.fst (liftPairList L1')) (List.map Prod.fst (liftPairList R1'))
rw [map_fst_liftPairList, refine_3.inl Λ:Type u_3inst✝:Inhabited Λtarget_tm:Machine (Fin 2) ΛStackMode:TypeencLeft1:List ℕ → ListBlank (Fin 2)encRight1:List ℕ → ListBlank (Fin 2)evalStackCfg1:StackMode → List ℕ → List ℕ → Cfg (Fin 2) ΛIsInStackSystem1:Cfg (Fin 2) Λ → ProphnilL:encLeft1 [] = defaulthnilR:encRight1 [] = defaulthheadL:∀ (a : ℕ) (L : List ℕ), (encLeft1 (a :: L)).head = 1hheadR:∀ (d : ℕ) (R : List ℕ), (encRight1 (d :: R)).head = 1tL:ListBlank (Fin 2)htL:tL.head = 1hnsL:∀ (L : List ℕ), encLeft1 L ≠ tLtR:ListBlank (Fin 2)htR:tR.head = 1hnsR:∀ (R : List ℕ), encRight1 R ≠ tRsL:ℕoL:ℕsepL:ℕsR:ℕoR:ℕsepR:ℕhsL:sL > 0hoL:oL > 0hsepL:sepL > 0hsR:sR > 0hoR:oR > 0hsepR:sepR > 0hblkL:∀ (a : ℕ) (L : List ℕ), encLeft1 (a :: L) = [1] ^ (sL * a + oL) +> [0] ^ sepL +> encLeft1 LhblkR:∀ (d : ℕ) (R : List ℕ), encRight1 (d :: R) = [1] ^ (sR * d + oR) +> [0] ^ sepR +> encRight1 Rhmodes:∃ modes, modes.length ≤ 6 ∧ ∀ (m : StackMode), m ∈ modeshvalid1:IsValidStackModes encLeft1 encRight1 evalStackCfg1hiff1:∀ (cfg : Cfg (Fin 2) Λ), IsInStackSystem1 cfg ↔ ∃ m L R, cfg = evalStackCfg1 m L Rleft✝:∀ (m : StackMode) (L R : List ℕ), IsInStackSystem1 (evalStackCfg1 m L R)hclosed1:∀ (cfg : Cfg (Fin 2) Λ),
IsInStackSystem1 cfg →
∃ cfg', (cfg [target_tm]⊢⁺ cfg') ∧ (IsInStackSystem1 cfg' ∨ (step target_tm cfg').isNone = true)cfg₀:Cfg (Fin 2) Λhinit0:init [] [target_tm]⊢⁺ cfg₀hsys0:IsInStackSystem1 cfg₀cfg:Cfg (Fin (0 + 2)) Λm:StackModeL:List (ℕ × ℕ)R:List (ℕ × ℕ)hcfg:cfg = evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)hsys1:IsInStackSystem1 cfgcfg':Cfg (Fin 2) Λhstep:cfg [target_tm]⊢⁺ cfg'hnext:IsInStackSystem1 cfg'm':StackModeL1':List ℕR1':List ℕhcfg':cfg' = evalStackCfg1 m' L1' R1'⊢ cfg' = evalStackCfg1 m' L1' (List.map Prod.fst (liftPairList R1')) map_fst_liftPairList refine_3.inl Λ:Type u_3inst✝:Inhabited Λtarget_tm:Machine (Fin 2) ΛStackMode:TypeencLeft1:List ℕ → ListBlank (Fin 2)encRight1:List ℕ → ListBlank (Fin 2)evalStackCfg1:StackMode → List ℕ → List ℕ → Cfg (Fin 2) ΛIsInStackSystem1:Cfg (Fin 2) Λ → ProphnilL:encLeft1 [] = defaulthnilR:encRight1 [] = defaulthheadL:∀ (a : ℕ) (L : List ℕ), (encLeft1 (a :: L)).head = 1hheadR:∀ (d : ℕ) (R : List ℕ), (encRight1 (d :: R)).head = 1tL:ListBlank (Fin 2)htL:tL.head = 1hnsL:∀ (L : List ℕ), encLeft1 L ≠ tLtR:ListBlank (Fin 2)htR:tR.head = 1hnsR:∀ (R : List ℕ), encRight1 R ≠ tRsL:ℕoL:ℕsepL:ℕsR:ℕoR:ℕsepR:ℕhsL:sL > 0hoL:oL > 0hsepL:sepL > 0hsR:sR > 0hoR:oR > 0hsepR:sepR > 0hblkL:∀ (a : ℕ) (L : List ℕ), encLeft1 (a :: L) = [1] ^ (sL * a + oL) +> [0] ^ sepL +> encLeft1 LhblkR:∀ (d : ℕ) (R : List ℕ), encRight1 (d :: R) = [1] ^ (sR * d + oR) +> [0] ^ sepR +> encRight1 Rhmodes:∃ modes, modes.length ≤ 6 ∧ ∀ (m : StackMode), m ∈ modeshvalid1:IsValidStackModes encLeft1 encRight1 evalStackCfg1hiff1:∀ (cfg : Cfg (Fin 2) Λ), IsInStackSystem1 cfg ↔ ∃ m L R, cfg = evalStackCfg1 m L Rleft✝:∀ (m : StackMode) (L R : List ℕ), IsInStackSystem1 (evalStackCfg1 m L R)hclosed1:∀ (cfg : Cfg (Fin 2) Λ),
IsInStackSystem1 cfg →
∃ cfg', (cfg [target_tm]⊢⁺ cfg') ∧ (IsInStackSystem1 cfg' ∨ (step target_tm cfg').isNone = true)cfg₀:Cfg (Fin 2) Λhinit0:init [] [target_tm]⊢⁺ cfg₀hsys0:IsInStackSystem1 cfg₀cfg:Cfg (Fin (0 + 2)) Λm:StackModeL:List (ℕ × ℕ)R:List (ℕ × ℕ)hcfg:cfg = evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)hsys1:IsInStackSystem1 cfgcfg':Cfg (Fin 2) Λhstep:cfg [target_tm]⊢⁺ cfg'hnext:IsInStackSystem1 cfg'm':StackModeL1':List ℕR1':List ℕhcfg':cfg' = evalStackCfg1 m' L1' R1'⊢ cfg' = evalStackCfg1 m' L1' R1'] refine_3.inl Λ:Type u_3inst✝:Inhabited Λtarget_tm:Machine (Fin 2) ΛStackMode:TypeencLeft1:List ℕ → ListBlank (Fin 2)encRight1:List ℕ → ListBlank (Fin 2)evalStackCfg1:StackMode → List ℕ → List ℕ → Cfg (Fin 2) ΛIsInStackSystem1:Cfg (Fin 2) Λ → ProphnilL:encLeft1 [] = defaulthnilR:encRight1 [] = defaulthheadL:∀ (a : ℕ) (L : List ℕ), (encLeft1 (a :: L)).head = 1hheadR:∀ (d : ℕ) (R : List ℕ), (encRight1 (d :: R)).head = 1tL:ListBlank (Fin 2)htL:tL.head = 1hnsL:∀ (L : List ℕ), encLeft1 L ≠ tLtR:ListBlank (Fin 2)htR:tR.head = 1hnsR:∀ (R : List ℕ), encRight1 R ≠ tRsL:ℕoL:ℕsepL:ℕsR:ℕoR:ℕsepR:ℕhsL:sL > 0hoL:oL > 0hsepL:sepL > 0hsR:sR > 0hoR:oR > 0hsepR:sepR > 0hblkL:∀ (a : ℕ) (L : List ℕ), encLeft1 (a :: L) = [1] ^ (sL * a + oL) +> [0] ^ sepL +> encLeft1 LhblkR:∀ (d : ℕ) (R : List ℕ), encRight1 (d :: R) = [1] ^ (sR * d + oR) +> [0] ^ sepR +> encRight1 Rhmodes:∃ modes, modes.length ≤ 6 ∧ ∀ (m : StackMode), m ∈ modeshvalid1:IsValidStackModes encLeft1 encRight1 evalStackCfg1hiff1:∀ (cfg : Cfg (Fin 2) Λ), IsInStackSystem1 cfg ↔ ∃ m L R, cfg = evalStackCfg1 m L Rleft✝:∀ (m : StackMode) (L R : List ℕ), IsInStackSystem1 (evalStackCfg1 m L R)hclosed1:∀ (cfg : Cfg (Fin 2) Λ),
IsInStackSystem1 cfg →
∃ cfg', (cfg [target_tm]⊢⁺ cfg') ∧ (IsInStackSystem1 cfg' ∨ (step target_tm cfg').isNone = true)cfg₀:Cfg (Fin 2) Λhinit0:init [] [target_tm]⊢⁺ cfg₀hsys0:IsInStackSystem1 cfg₀cfg:Cfg (Fin (0 + 2)) Λm:StackModeL:List (ℕ × ℕ)R:List (ℕ × ℕ)hcfg:cfg = evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)hsys1:IsInStackSystem1 cfgcfg':Cfg (Fin 2) Λhstep:cfg [target_tm]⊢⁺ cfg'hnext:IsInStackSystem1 cfg'm':StackModeL1':List ℕR1':List ℕhcfg':cfg' = evalStackCfg1 m' L1' R1'⊢ cfg' = evalStackCfg1 m' L1' R1'
exact hcfg' All goals completed! 🐙
· refine_3.inr Λ:Type u_3inst✝:Inhabited Λtarget_tm:Machine (Fin 2) ΛStackMode:TypeencLeft1:List ℕ → ListBlank (Fin 2)encRight1:List ℕ → ListBlank (Fin 2)evalStackCfg1:StackMode → List ℕ → List ℕ → Cfg (Fin 2) ΛIsInStackSystem1:Cfg (Fin 2) Λ → ProphnilL:encLeft1 [] = defaulthnilR:encRight1 [] = defaulthheadL:∀ (a : ℕ) (L : List ℕ), (encLeft1 (a :: L)).head = 1hheadR:∀ (d : ℕ) (R : List ℕ), (encRight1 (d :: R)).head = 1tL:ListBlank (Fin 2)htL:tL.head = 1hnsL:∀ (L : List ℕ), encLeft1 L ≠ tLtR:ListBlank (Fin 2)htR:tR.head = 1hnsR:∀ (R : List ℕ), encRight1 R ≠ tRsL:ℕoL:ℕsepL:ℕsR:ℕoR:ℕsepR:ℕhsL:sL > 0hoL:oL > 0hsepL:sepL > 0hsR:sR > 0hoR:oR > 0hsepR:sepR > 0hblkL:∀ (a : ℕ) (L : List ℕ), encLeft1 (a :: L) = [1] ^ (sL * a + oL) +> [0] ^ sepL +> encLeft1 LhblkR:∀ (d : ℕ) (R : List ℕ), encRight1 (d :: R) = [1] ^ (sR * d + oR) +> [0] ^ sepR +> encRight1 Rhmodes:∃ modes, modes.length ≤ 6 ∧ ∀ (m : StackMode), m ∈ modeshvalid1:IsValidStackModes encLeft1 encRight1 evalStackCfg1hiff1:∀ (cfg : Cfg (Fin 2) Λ), IsInStackSystem1 cfg ↔ ∃ m L R, cfg = evalStackCfg1 m L Rleft✝:∀ (m : StackMode) (L R : List ℕ), IsInStackSystem1 (evalStackCfg1 m L R)hclosed1:∀ (cfg : Cfg (Fin 2) Λ),
IsInStackSystem1 cfg →
∃ cfg', (cfg [target_tm]⊢⁺ cfg') ∧ (IsInStackSystem1 cfg' ∨ (step target_tm cfg').isNone = true)cfg₀:Cfg (Fin 2) Λhinit0:init [] [target_tm]⊢⁺ cfg₀hsys0:IsInStackSystem1 cfg₀cfg:Cfg (Fin (0 + 2)) Λm:StackModeL:List (ℕ × ℕ)R:List (ℕ × ℕ)hcfg:cfg = evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)hsys1:IsInStackSystem1 cfgcfg':Cfg (Fin 2) Λhstep:cfg [target_tm]⊢⁺ cfg'hhalt:(step target_tm cfg').isNone = true⊢ ∃ cfg',
(cfg [target_tm]⊢⁺ cfg') ∧
((fun cfg ↦ ∃ m L R, cfg = evalStackCfg1 m (List.map Prod.fst L) (List.map Prod.fst R)) cfg' ∨
(step target_tm cfg').isNone = true) exact ⟨cfg', hstep, Or.inr hhalt⟩ All goals completed! 🐙end BusyBeaver.PairStack