Γ : Type u_3
inst✝² : Inhabited Γ
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
n : ℕ
enc : Γ → Vector Bool n
dec : Vector Bool n → Γ
enc0 : enc default = Vector.replicate n false
M : Λ → Stmt₁
encdec : ∀ (a : Γ), dec (enc a) = a
f : Γ → Stmt Bool Λ' σ
v : σ
L R : ListBlank Γ
⊢ ∀ (f : Vector Bool n → Stmt Bool Λ' σ),
    stepAux (readAux n f) v (trTape' enc0 L R) =
      stepAux (f (enc (ListBlank.head R))) v (trTape' enc0 (ListBlank.cons (ListBlank.head R) L) (ListBlank.tail R))
Γ : Type u_3
inst✝² : Inhabited Γ
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
n : ℕ
enc : Γ → Vector Bool n
dec : Vector Bool n → Γ
enc0 : enc default = Vector.replicate n false
M : Λ → Stmt₁
encdec : ∀ (a : Γ), dec (enc a) = a
f : Γ → Stmt Bool Λ' σ
v : σ
L R : ListBlank Γ
⊢ stepAux (read dec f) v (trTape' enc0 L R) = stepAux (f (ListBlank.head R)) v (trTape' enc0 L R)
suffices ∀ f, stepAux (readAux n f) v (trTape' enc0 L R) =
    stepAux (f (enc R.head)) v (trTape' enc0 (L.cons R.head) R.tail) by
  rw [read, this, stepAux_move, encdec, trTape'_move_left enc0]
  simp only [ListBlank.head_cons, ListBlank.cons_head_tail, ListBlank.tail_cons]
case intro.intro
Γ : Type u_3
inst✝² : Inhabited Γ
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
n : ℕ
enc : Γ → Vector Bool n
dec : Vector Bool n → Γ
enc0 : enc default = Vector.replicate n false
M : Λ → Stmt₁
encdec : ∀ (a : Γ), dec (enc a) = a
f : Γ → Stmt Bool Λ' σ
v : σ
L : ListBlank Γ
a : Γ
R : ListBlank Γ
⊢ ∀ (f : Vector Bool n → Stmt Bool Λ' σ),
    stepAux (readAux n f) v (trTape' enc0 L (ListBlank.cons a R)) =
      stepAux (f (enc (ListBlank.head (ListBlank.cons a R)))) v
        (trTape' enc0 (ListBlank.cons (ListBlank.head (ListBlank.cons a R)) L) (ListBlank.tail (ListBlank.cons a R)))
Γ : Type u_3
inst✝² : Inhabited Γ
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
n : ℕ
enc : Γ → Vector Bool n
dec : Vector Bool n → Γ
enc0 : enc default = Vector.replicate n false
M : Λ → Stmt₁
encdec : ∀ (a : Γ), dec (enc a) = a
f : Γ → Stmt Bool Λ' σ
v : σ
L R : ListBlank Γ
⊢ ∀ (f : Vector Bool n → Stmt Bool Λ' σ),
    stepAux (readAux n f) v (trTape' enc0 L R) =
      stepAux (f (enc (ListBlank.head R))) v (trTape' enc0 (ListBlank.cons (ListBlank.head R) L) (ListBlank.tail R))
obtain ⟨a, R, rfl⟩ := R.exists_cons
case intro.intro
Γ : Type u_3
inst✝² : Inhabited Γ
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
n : ℕ
enc : Γ → Vector Bool n
dec : Vector Bool n → Γ
enc0 : enc default = Vector.replicate n false
M : Λ → Stmt₁
encdec : ∀ (a : Γ), dec (enc a) = a
f : Γ → Stmt Bool Λ' σ
v : σ
L : ListBlank Γ
a : Γ
R : ListBlank Γ
⊢ ∀ (f : Vector Bool n → Stmt Bool Λ' σ),
    stepAux (readAux n f) v
        (Tape.mk'
          (ListBlank.bind L (fun x => List.reverse (Vector.toList (enc x)))
            (_ : ∃ n_1, (fun x => List.reverse (Vector.toList (enc x))) default = List.replicate n_1 default))
          (ListBlank.append (Vector.toList (enc a))
            (ListBlank.bind R (fun x => Vector.toList (enc x))
              (_ : ∃ n_1, (fun x => Vector.toList (enc x)) default = List.replicate n_1 default)))) =
      stepAux (f (enc a)) v
        (Tape.mk'
          (ListBlank.append (List.reverse (Vector.toList (enc a)))
            (ListBlank.bind L (fun x => List.reverse (Vector.toList (enc x)))
              (_ : ∃ n_1, (fun x => List.reverse (Vector.toList (enc x))) default = List.replicate n_1 default)))
          (ListBlank.bind R (fun x => Vector.toList (enc x))
            (_ : ∃ n_1, (fun x => Vector.toList (enc x)) default = List.replicate n_1 default)))
case intro.intro
Γ : Type u_3
inst✝² : Inhabited Γ
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
n : ℕ
enc : Γ → Vector Bool n
dec : Vector Bool n → Γ
enc0 : enc default = Vector.replicate n false
M : Λ → Stmt₁
encdec : ∀ (a : Γ), dec (enc a) = a
f : Γ → Stmt Bool Λ' σ
v : σ
L : ListBlank Γ
a : Γ
R : ListBlank Γ
⊢ ∀ (f : Vector Bool n → Stmt Bool Λ' σ),
    stepAux (readAux n f) v (trTape' enc0 L (ListBlank.cons a R)) =
      stepAux (f (enc (ListBlank.head (ListBlank.cons a R)))) v
        (trTape' enc0 (ListBlank.cons (ListBlank.head (ListBlank.cons a R)) L) (ListBlank.tail (ListBlank.cons a R)))
simp only [ListBlank.head_cons, ListBlank.tail_cons, trTape', ListBlank.cons_bind,
  ListBlank.append_assoc]
case intro.intro
Γ : Type u_3
inst✝² : Inhabited Γ
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
n : ℕ
enc : Γ → Vector Bool n
dec : Vector Bool n → Γ
enc0 : enc default = Vector.replicate n false
M : Λ → Stmt₁
encdec : ∀ (a : Γ), dec (enc a) = a
f : Γ → Stmt Bool Λ' σ
v : σ
L : ListBlank Γ
a : Γ
R : ListBlank Γ
⊢ ∀ (i : ℕ) (f : Vector Bool i → Stmt Bool Λ' σ) (L' R' : ListBlank Bool) (l₁ l₂ : List Bool) (h : List.length l₂ = i),
    stepAux (readAux i f) v (Tape.mk' (ListBlank.append l₁ L') (ListBlank.append l₂ R')) =
      stepAux (f { val := l₂, property := h }) v (Tape.mk' (ListBlank.append (List.reverseAux l₂ l₁) L') R')
case intro.intro
Γ : Type u_3
inst✝² : Inhabited Γ
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
n : ℕ
enc : Γ → Vector Bool n
dec : Vector Bool n → Γ
enc0 : enc default = Vector.replicate n false
M : Λ → Stmt₁
encdec : ∀ (a : Γ), dec (enc a) = a
f : Γ → Stmt Bool Λ' σ
v : σ
L : ListBlank Γ
a : Γ
R : ListBlank Γ
⊢ ∀ (f : Vector Bool n → Stmt Bool Λ' σ),
    stepAux (readAux n f) v
        (Tape.mk'
          (ListBlank.bind L (fun x => List.reverse (Vector.toList (enc x)))
            (_ : ∃ n_1, (fun x => List.reverse (Vector.toList (enc x))) default = List.replicate n_1 default))
          (ListBlank.append (Vector.toList (enc a))
            (ListBlank.bind R (fun x => Vector.toList (enc x))
              (_ : ∃ n_1, (fun x => Vector.toList (enc x)) default = List.replicate n_1 default)))) =
      stepAux (f (enc a)) v
        (Tape.mk'
          (ListBlank.append (List.reverse (Vector.toList (enc a)))
            (ListBlank.bind L (fun x => List.reverse (Vector.toList (enc x)))
              (_ : ∃ n_1, (fun x => List.reverse (Vector.toList (enc x))) default = List.replicate n_1 default)))
          (ListBlank.bind R (fun x => Vector.toList (enc x))
            (_ : ∃ n_1, (fun x => Vector.toList (enc x)) default = List.replicate n_1 default)))
suffices ∀ i f L' R' l₁ l₂ h,
    stepAux (readAux i f) v (Tape.mk' (ListBlank.append l₁ L') (ListBlank.append l₂ R')) =
    stepAux (f ⟨l₂, h⟩) v (Tape.mk' (ListBlank.append (l₂.reverseAux l₁) L') R') by
  intro f
  exact this n f (L.bind (fun x => (enc x).1.reverse) _)
    (R.bind (fun x => (enc x).1) _) [] _ (enc a).2
case intro.intro
Γ : Type u_3
inst✝² : Inhabited Γ
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
n : ℕ
enc : Γ → Vector Bool n
dec : Vector Bool n → Γ
enc0 : enc default = Vector.replicate n false
M : Λ → Stmt₁
encdec : ∀ (a : Γ), dec (enc a) = a
v : σ
⊢ ∀ (i : ℕ) (f : Vector Bool i → Stmt Bool Λ' σ) (L' R' : ListBlank Bool) (l₁ l₂ : List Bool) (h : List.length l₂ = i),
    stepAux (readAux i f) v (Tape.mk' (ListBlank.append l₁ L') (ListBlank.append l₂ R')) =
      stepAux (f { val := l₂, property := h }) v (Tape.mk' (ListBlank.append (List.reverseAux l₂ l₁) L') R')
case intro.intro
Γ : Type u_3
inst✝² : Inhabited Γ
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
n : ℕ
enc : Γ → Vector Bool n
dec : Vector Bool n → Γ
enc0 : enc default = Vector.replicate n false
M : Λ → Stmt₁
encdec : ∀ (a : Γ), dec (enc a) = a
f : Γ → Stmt Bool Λ' σ
v : σ
L : ListBlank Γ
a : Γ
R : ListBlank Γ
⊢ ∀ (i : ℕ) (f : Vector Bool i → Stmt Bool Λ' σ) (L' R' : ListBlank Bool) (l₁ l₂ : List Bool) (h : List.length l₂ = i),
    stepAux (readAux i f) v (Tape.mk' (ListBlank.append l₁ L') (ListBlank.append l₂ R')) =
      stepAux (f { val := l₂, property := h }) v (Tape.mk' (ListBlank.append (List.reverseAux l₂ l₁) L') R')
clear f L a R
case intro.intro
Γ : Type u_3
inst✝² : Inhabited Γ
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
n : ℕ
enc : Γ → Vector Bool n
dec : Vector Bool n → Γ
enc0 : enc default = Vector.replicate n false
M : Λ → Stmt₁
encdec : ∀ (a : Γ), dec (enc a) = a
v : σ
i : ℕ
f : Vector Bool i → Stmt Bool Λ' σ
L' R' : ListBlank Bool
l₁ l₂ : List Bool
h✝ : List.length l₂ = i
⊢ stepAux (readAux i f) v (Tape.mk' (ListBlank.append l₁ L') (ListBlank.append l₂ R')) =
    stepAux (f { val := l₂, property := h✝ }) v (Tape.mk' (ListBlank.append (List.reverseAux l₂ l₁) L') R')
case intro.intro
Γ : Type u_3
inst✝² : Inhabited Γ
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
n : ℕ
enc : Γ → Vector Bool n
dec : Vector Bool n → Γ
enc0 : enc default = Vector.replicate n false
M : Λ → Stmt₁
encdec : ∀ (a : Γ), dec (enc a) = a
v : σ
⊢ ∀ (i : ℕ) (f : Vector Bool i → Stmt Bool Λ' σ) (L' R' : ListBlank Bool) (l₁ l₂ : List Bool) (h : List.length l₂ = i),
    stepAux (readAux i f) v (Tape.mk' (ListBlank.append l₁ L') (ListBlank.append l₂ R')) =
      stepAux (f { val := l₂, property := h }) v (Tape.mk' (ListBlank.append (List.reverseAux l₂ l₁) L') R')
intro i f L' R' l₁ l₂ _
case intro.intro
Γ : Type u_3
inst✝² : Inhabited Γ
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
n : ℕ
enc : Γ → Vector Bool n
dec : Vector Bool n → Γ
enc0 : enc default = Vector.replicate n false
M : Λ → Stmt₁
encdec : ∀ (a : Γ), dec (enc a) = a
v : σ
L' R' : ListBlank Bool
l₁ l₂ : List Bool
f : Vector Bool (List.length l₂) → Stmt Bool Λ' σ
⊢ stepAux (readAux (List.length l₂) f) v (Tape.mk' (ListBlank.append l₁ L') (ListBlank.append l₂ R')) =
    stepAux (f { val := l₂, property := (_ : List.length l₂ = List.length l₂) }) v
      (Tape.mk' (ListBlank.append (List.reverseAux l₂ l₁) L') R')
case intro.intro
Γ : Type u_3
inst✝² : Inhabited Γ
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
n : ℕ
enc : Γ → Vector Bool n
dec : Vector Bool n → Γ
enc0 : enc default = Vector.replicate n false
M : Λ → Stmt₁
encdec : ∀ (a : Γ), dec (enc a) = a
v : σ
i : ℕ
f : Vector Bool i → Stmt Bool Λ' σ
L' R' : ListBlank Bool
l₁ l₂ : List Bool
h✝ : List.length l₂ = i
⊢ stepAux (readAux i f) v (Tape.mk' (ListBlank.append l₁ L') (ListBlank.append l₂ R')) =
    stepAux (f { val := l₂, property := h✝ }) v (Tape.mk' (ListBlank.append (List.reverseAux l₂ l₁) L') R')
subst i
case intro.intro.nil
Γ : Type u_3
inst✝² : Inhabited Γ
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
n : ℕ
enc : Γ → Vector Bool n
dec : Vector Bool n → Γ
enc0 : enc default = Vector.replicate n false
M : Λ → Stmt₁
encdec : ∀ (a : Γ), dec (enc a) = a
v : σ
L' R' : ListBlank Bool
l₁✝ l₂ : List Bool
f✝ : Vector Bool (List.length l₂) → Stmt Bool Λ' σ
l₁ : List Bool
f : Vector Bool (List.length []) → Stmt Bool Λ' σ
⊢ stepAux (readAux (List.length []) f) v (Tape.mk' (ListBlank.append l₁ L') (ListBlank.append [] R')) =
    stepAux (f { val := [], property := (_ : List.length [] = List.length []) }) v
      (Tape.mk' (ListBlank.append (List.reverseAux [] l₁) L') R')

case intro.intro.cons
Γ : Type u_3
inst✝² : Inhabited Γ
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
n : ℕ
enc : Γ → Vector Bool n
dec : Vector Bool n → Γ
enc0 : enc default = Vector.replicate n false
M : Λ → Stmt₁
encdec : ∀ (a : Γ), dec (enc a) = a
v : σ
L' R' : ListBlank Bool
l₁✝ l₂✝ : List Bool
f✝ : Vector Bool (List.length l₂✝) → Stmt Bool Λ' σ
a : Bool
l₂ : List Bool
IH :
  ∀ (l₁ : List Bool) (f : Vector Bool (List.length l₂) → Stmt Bool Λ' σ),
    stepAux (readAux (List.length l₂) f) v (Tape.mk' (ListBlank.append l₁ L') (ListBlank.append l₂ R')) =
      stepAux (f { val := l₂, property := (_ : List.length l₂ = List.length l₂) }) v
        (Tape.mk' (ListBlank.append (List.reverseAux l₂ l₁) L') R')
l₁ : List Bool
f : Vector Bool (List.length (a :: l₂)) → Stmt Bool Λ' σ
⊢ stepAux (readAux (List.length (a :: l₂)) f) v (Tape.mk' (ListBlank.append l₁ L') (ListBlank.append (a :: l₂) R')) =
    stepAux (f { val := a :: l₂, property := (_ : List.length (a :: l₂) = List.length (a :: l₂)) }) v
      (Tape.mk' (ListBlank.append (List.reverseAux (a :: l₂) l₁) L') R')
case intro.intro
Γ : Type u_3
inst✝² : Inhabited Γ
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
n : ℕ
enc : Γ → Vector Bool n
dec : Vector Bool n → Γ
enc0 : enc default = Vector.replicate n false
M : Λ → Stmt₁
encdec : ∀ (a : Γ), dec (enc a) = a
v : σ
L' R' : ListBlank Bool
l₁ l₂ : List Bool
f : Vector Bool (List.length l₂) → Stmt Bool Λ' σ
⊢ stepAux (readAux (List.length l₂) f) v (Tape.mk' (ListBlank.append l₁ L') (ListBlank.append l₂ R')) =
    stepAux (f { val := l₂, property := (_ : List.length l₂ = List.length l₂) }) v
      (Tape.mk' (ListBlank.append (List.reverseAux l₂ l₁) L') R')
induction' l₂ with a l₂ IH generalizing l₁
Γ : Type u_3
inst✝² : Inhabited Γ
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
n : ℕ
enc : Γ → Vector Bool n
dec : Vector Bool n → Γ
enc0 : enc default = Vector.replicate n false
M : Λ → Stmt₁
encdec : ∀ (a : Γ), dec (enc a) = a
v : σ
L' R' : ListBlank Bool
l₁✝ l₂✝ : List Bool
f✝ : Vector Bool (List.length l₂✝) → Stmt Bool Λ' σ
a : Bool
l₂ : List Bool
IH :
  ∀ (l₁ : List Bool) (f : Vector Bool (List.length l₂) → Stmt Bool Λ' σ),
    stepAux (readAux (List.length l₂) f) v (Tape.mk' (ListBlank.append l₁ L') (ListBlank.append l₂ R')) =
      stepAux (f { val := l₂, property := (_ : List.length l₂ = List.length l₂) }) v
        (Tape.mk' (ListBlank.append (List.reverseAux l₂ l₁) L') R')
l₁ : List Bool
f : Vector Bool (List.length (a :: l₂)) → Stmt Bool Λ' σ
⊢ stepAux (readAux (List.length (a :: l₂)) f) v (Tape.mk' (ListBlank.append l₁ L') (ListBlank.append (a :: l₂) R')) =
    stepAux (readAux (List.length l₂) fun v => f (a ::ᵥ v)) v
      (Tape.mk' (ListBlank.cons a (ListBlank.append l₁ L')) (ListBlank.append l₂ R'))

Γ : Type u_3
inst✝² : Inhabited Γ
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
n : ℕ
enc : Γ → Vector Bool n
dec : Vector Bool n → Γ
enc0 : enc default = Vector.replicate n false
M : Λ → Stmt₁
encdec : ∀ (a : Γ), dec (enc a) = a
v : σ
L' R' : ListBlank Bool
l₁✝ l₂✝ : List Bool
f✝ : Vector Bool (List.length l₂✝) → Stmt Bool Λ' σ
a : Bool
l₂ : List Bool
IH :
  ∀ (l₁ : List Bool) (f : Vector Bool (List.length l₂) → Stmt Bool Λ' σ),
    stepAux (readAux (List.length l₂) f) v (Tape.mk' (ListBlank.append l₁ L') (ListBlank.append l₂ R')) =
      stepAux (f { val := l₂, property := (_ : List.length l₂ = List.length l₂) }) v
        (Tape.mk' (ListBlank.append (List.reverseAux l₂ l₁) L') R')
l₁ : List Bool
f : Vector Bool (List.length (a :: l₂)) → Stmt Bool Λ' σ
⊢ stepAux (readAux (List.length l₂) fun v => f (a ::ᵥ v)) v
      (Tape.mk' (ListBlank.cons a (ListBlank.append l₁ L')) (ListBlank.append l₂ R')) =
    stepAux (f { val := a :: l₂, property := (_ : List.length (a :: l₂) = List.length (a :: l₂)) }) v
      (Tape.mk' (ListBlank.append (List.reverseAux (a :: l₂) l₁) L') R')
case intro.intro.cons
Γ : Type u_3
inst✝² : Inhabited Γ
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
n : ℕ
enc : Γ → Vector Bool n
dec : Vector Bool n → Γ
enc0 : enc default = Vector.replicate n false
M : Λ → Stmt₁
encdec : ∀ (a : Γ), dec (enc a) = a
v : σ
L' R' : ListBlank Bool
l₁✝ l₂✝ : List Bool
f✝ : Vector Bool (List.length l₂✝) → Stmt Bool Λ' σ
a : Bool
l₂ : List Bool
IH :
  ∀ (l₁ : List Bool) (f : Vector Bool (List.length l₂) → Stmt Bool Λ' σ),
    stepAux (readAux (List.length l₂) f) v (Tape.mk' (ListBlank.append l₁ L') (ListBlank.append l₂ R')) =
      stepAux (f { val := l₂, property := (_ : List.length l₂ = List.length l₂) }) v
        (Tape.mk' (ListBlank.append (List.reverseAux l₂ l₁) L') R')
l₁ : List Bool
f : Vector Bool (List.length (a :: l₂)) → Stmt Bool Λ' σ
⊢ stepAux (readAux (List.length (a :: l₂)) f) v (Tape.mk' (ListBlank.append l₁ L') (ListBlank.append (a :: l₂) R')) =
    stepAux (f { val := a :: l₂, property := (_ : List.length (a :: l₂) = List.length (a :: l₂)) }) v
      (Tape.mk' (ListBlank.append (List.reverseAux (a :: l₂) l₁) L') R')
trans
  stepAux (readAux l₂.length fun v ↦ f (a ::ᵥ v)) v
    (Tape.mk' ((L'.append l₁).cons a) (R'.append l₂))
Γ : Type u_3
inst✝² : Inhabited Γ
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
n : ℕ
enc : Γ → Vector Bool n
dec : Vector Bool n → Γ
enc0 : enc default = Vector.replicate n false
M : Λ → Stmt₁
encdec : ∀ (a : Γ), dec (enc a) = a
v : σ
L' R' : ListBlank Bool
l₁✝ l₂✝ : List Bool
f✝ : Vector Bool (List.length l₂✝) → Stmt Bool Λ' σ
a : Bool
l₂ : List Bool
IH :
  ∀ (l₁ : List Bool) (f : Vector Bool (List.length l₂) → Stmt Bool Λ' σ),
    stepAux (readAux (List.length l₂) f) v (Tape.mk' (ListBlank.append l₁ L') (ListBlank.append l₂ R')) =
      stepAux (f { val := l₂, property := (_ : List.length l₂ = List.length l₂) }) v
        (Tape.mk' (ListBlank.append (List.reverseAux l₂ l₁) L') R')
l₁ : List Bool
f : Vector Bool (List.length (a :: l₂)) → Stmt Bool Λ' σ
⊢ stepAux (f (a ::ᵥ { val := l₂, property := (_ : List.length l₂ = List.length l₂) })) v
      (Tape.mk' (ListBlank.append (List.reverseAux l₂ (a :: l₁)) L') R') =
    stepAux (f { val := a :: l₂, property := (_ : List.length (a :: l₂) = List.length (a :: l₂)) }) v
      (Tape.mk' (ListBlank.append (List.reverseAux (a :: l₂) l₁) L') R')
Γ : Type u_3
inst✝² : Inhabited Γ
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
n : ℕ
enc : Γ → Vector Bool n
dec : Vector Bool n → Γ
enc0 : enc default = Vector.replicate n false
M : Λ → Stmt₁
encdec : ∀ (a : Γ), dec (enc a) = a
v : σ
L' R' : ListBlank Bool
l₁✝ l₂✝ : List Bool
f✝ : Vector Bool (List.length l₂✝) → Stmt Bool Λ' σ
a : Bool
l₂ : List Bool
IH :
  ∀ (l₁ : List Bool) (f : Vector Bool (List.length l₂) → Stmt Bool Λ' σ),
    stepAux (readAux (List.length l₂) f) v (Tape.mk' (ListBlank.append l₁ L') (ListBlank.append l₂ R')) =
      stepAux (f { val := l₂, property := (_ : List.length l₂ = List.length l₂) }) v
        (Tape.mk' (ListBlank.append (List.reverseAux l₂ l₁) L') R')
l₁ : List Bool
f : Vector Bool (List.length (a :: l₂)) → Stmt Bool Λ' σ
⊢ stepAux (readAux (List.length l₂) fun v => f (a ::ᵥ v)) v
      (Tape.mk' (ListBlank.cons a (ListBlank.append l₁ L')) (ListBlank.append l₂ R')) =
    stepAux (f { val := a :: l₂, property := (_ : List.length (a :: l₂) = List.length (a :: l₂)) }) v
      (Tape.mk' (ListBlank.append (List.reverseAux (a :: l₂) l₁) L') R')
rw [← ListBlank.append, IH]
no goals
Γ : Type u_3
inst✝² : Inhabited Γ
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
n : ℕ
enc : Γ → Vector Bool n
dec : Vector Bool n → Γ
enc0 : enc default = Vector.replicate n false
M : Λ → Stmt₁
encdec : ∀ (a : Γ), dec (enc a) = a
v : σ
L' R' : ListBlank Bool
l₁✝ l₂✝ : List Bool
f✝ : Vector Bool (List.length l₂✝) → Stmt Bool Λ' σ
a : Bool
l₂ : List Bool
IH :
  ∀ (l₁ : List Bool) (f : Vector Bool (List.length l₂) → Stmt Bool Λ' σ),
    stepAux (readAux (List.length l₂) f) v (Tape.mk' (ListBlank.append l₁ L') (ListBlank.append l₂ R')) =
      stepAux (f { val := l₂, property := (_ : List.length l₂ = List.length l₂) }) v
        (Tape.mk' (ListBlank.append (List.reverseAux l₂ l₁) L') R')
l₁ : List Bool
f : Vector Bool (List.length (a :: l₂)) → Stmt Bool Λ' σ
⊢ stepAux (f (a ::ᵥ { val := l₂, property := (_ : List.length l₂ = List.length l₂) })) v
      (Tape.mk' (ListBlank.append (List.reverseAux l₂ (a :: l₁)) L') R') =
    stepAux (f { val := a :: l₂, property := (_ : List.length (a :: l₂) = List.length (a :: l₂)) }) v
      (Tape.mk' (ListBlank.append (List.reverseAux (a :: l₂) l₁) L') R')
rfl
Γ : Type u_3
inst✝² : Inhabited Γ
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
n : ℕ
enc : Γ → Vector Bool n
dec : Vector Bool n → Γ
enc0 : enc default = Vector.replicate n false
M : Λ → Stmt₁
encdec : ∀ (a : Γ), dec (enc a) = a
f : Γ → Stmt Bool Λ' σ
v : σ
L R : ListBlank Γ
this :
  ∀ (f : Vector Bool n → Stmt Bool Λ' σ),
    stepAux (readAux n f) v (trTape' enc0 L R) =
      stepAux (f (enc (ListBlank.head R))) v (trTape' enc0 (ListBlank.cons (ListBlank.head R) L) (ListBlank.tail R))
⊢ stepAux (f (ListBlank.head R)) v
      (trTape' enc0 (ListBlank.tail (ListBlank.cons (ListBlank.head R) L))
        (ListBlank.cons (ListBlank.head (ListBlank.cons (ListBlank.head R) L)) (ListBlank.tail R))) =
    stepAux (f (ListBlank.head R)) v (trTape' enc0 L R)
Γ : Type u_3
inst✝² : Inhabited Γ
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
n : ℕ
enc : Γ → Vector Bool n
dec : Vector Bool n → Γ
enc0 : enc default = Vector.replicate n false
M : Λ → Stmt₁
encdec : ∀ (a : Γ), dec (enc a) = a
f : Γ → Stmt Bool Λ' σ
v : σ
L R : ListBlank Γ
this :
  ∀ (f : Vector Bool n → Stmt Bool Λ' σ),
    stepAux (readAux n f) v (trTape' enc0 L R) =
      stepAux (f (enc (ListBlank.head R))) v (trTape' enc0 (ListBlank.cons (ListBlank.head R) L) (ListBlank.tail R))
⊢ stepAux (read dec f) v (trTape' enc0 L R) = stepAux (f (ListBlank.head R)) v (trTape' enc0 L R)
rw [read, this, stepAux_move, encdec, trTape'_move_left enc0]
no goals
Γ : Type u_3
inst✝² : Inhabited Γ
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
n : ℕ
enc : Γ → Vector Bool n
dec : Vector Bool n → Γ
enc0 : enc default = Vector.replicate n false
M : Λ → Stmt₁
encdec : ∀ (a : Γ), dec (enc a) = a
f : Γ → Stmt Bool Λ' σ
v : σ
L R : ListBlank Γ
this :
  ∀ (f : Vector Bool n → Stmt Bool Λ' σ),
    stepAux (readAux n f) v (trTape' enc0 L R) =
      stepAux (f (enc (ListBlank.head R))) v (trTape' enc0 (ListBlank.cons (ListBlank.head R) L) (ListBlank.tail R))
⊢ stepAux (f (ListBlank.head R)) v
      (trTape' enc0 (ListBlank.tail (ListBlank.cons (ListBlank.head R) L))
        (ListBlank.cons (ListBlank.head (ListBlank.cons (ListBlank.head R) L)) (ListBlank.tail R))) =
    stepAux (f (ListBlank.head R)) v (trTape' enc0 L R)
simp only [ListBlank.head_cons, ListBlank.cons_head_tail, ListBlank.tail_cons]
Γ : Type u_3
inst✝² : Inhabited Γ
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
n : ℕ
enc : Γ → Vector Bool n
dec : Vector Bool n → Γ
enc0 : enc default = Vector.replicate n false
M : Λ → Stmt₁
encdec : ∀ (a : Γ), dec (enc a) = a
f✝ : Γ → Stmt Bool Λ' σ
v : σ
L : ListBlank Γ
a : Γ
R : ListBlank Γ
this :
  ∀ (i : ℕ) (f : Vector Bool i → Stmt Bool Λ' σ) (L' R' : ListBlank Bool) (l₁ l₂ : List Bool) (h : List.length l₂ = i),
    stepAux (readAux i f) v (Tape.mk' (ListBlank.append l₁ L') (ListBlank.append l₂ R')) =
      stepAux (f { val := l₂, property := h }) v (Tape.mk' (ListBlank.append (List.reverseAux l₂ l₁) L') R')
f : Vector Bool n → Stmt Bool Λ' σ
⊢ stepAux (readAux n f) v
      (Tape.mk'
        (ListBlank.bind L (fun x => List.reverse (Vector.toList (enc x)))
          (_ : ∃ n_1, (fun x => List.reverse (Vector.toList (enc x))) default = List.replicate n_1 default))
        (ListBlank.append (Vector.toList (enc a))
          (ListBlank.bind R (fun x => Vector.toList (enc x))
            (_ : ∃ n_1, (fun x => Vector.toList (enc x)) default = List.replicate n_1 default)))) =
    stepAux (f (enc a)) v
      (Tape.mk'
        (ListBlank.append (List.reverse (Vector.toList (enc a)))
          (ListBlank.bind L (fun x => List.reverse (Vector.toList (enc x)))
            (_ : ∃ n_1, (fun x => List.reverse (Vector.toList (enc x))) default = List.replicate n_1 default)))
        (ListBlank.bind R (fun x => Vector.toList (enc x))
          (_ : ∃ n_1, (fun x => Vector.toList (enc x)) default = List.replicate n_1 default)))
Γ : Type u_3
inst✝² : Inhabited Γ
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
n : ℕ
enc : Γ → Vector Bool n
dec : Vector Bool n → Γ
enc0 : enc default = Vector.replicate n false
M : Λ → Stmt₁
encdec : ∀ (a : Γ), dec (enc a) = a
f : Γ → Stmt Bool Λ' σ
v : σ
L : ListBlank Γ
a : Γ
R : ListBlank Γ
this :
  ∀ (i : ℕ) (f : Vector Bool i → Stmt Bool Λ' σ) (L' R' : ListBlank Bool) (l₁ l₂ : List Bool) (h : List.length l₂ = i),
    stepAux (readAux i f) v (Tape.mk' (ListBlank.append l₁ L') (ListBlank.append l₂ R')) =
      stepAux (f { val := l₂, property := h }) v (Tape.mk' (ListBlank.append (List.reverseAux l₂ l₁) L') R')
⊢ ∀ (f : Vector Bool n → Stmt Bool Λ' σ),
    stepAux (readAux n f) v
        (Tape.mk'
          (ListBlank.bind L (fun x => List.reverse (Vector.toList (enc x)))
            (_ : ∃ n_1, (fun x => List.reverse (Vector.toList (enc x))) default = List.replicate n_1 default))
          (ListBlank.append (Vector.toList (enc a))
            (ListBlank.bind R (fun x => Vector.toList (enc x))
              (_ : ∃ n_1, (fun x => Vector.toList (enc x)) default = List.replicate n_1 default)))) =
      stepAux (f (enc a)) v
        (Tape.mk'
          (ListBlank.append (List.reverse (Vector.toList (enc a)))
            (ListBlank.bind L (fun x => List.reverse (Vector.toList (enc x)))
              (_ : ∃ n_1, (fun x => List.reverse (Vector.toList (enc x))) default = List.replicate n_1 default)))
          (ListBlank.bind R (fun x => Vector.toList (enc x))
            (_ : ∃ n_1, (fun x => Vector.toList (enc x)) default = List.replicate n_1 default)))
intro f
no goals
Γ : Type u_3
inst✝² : Inhabited Γ
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
n : ℕ
enc : Γ → Vector Bool n
dec : Vector Bool n → Γ
enc0 : enc default = Vector.replicate n false
M : Λ → Stmt₁
encdec : ∀ (a : Γ), dec (enc a) = a
f✝ : Γ → Stmt Bool Λ' σ
v : σ
L : ListBlank Γ
a : Γ
R : ListBlank Γ
this :
  ∀ (i : ℕ) (f : Vector Bool i → Stmt Bool Λ' σ) (L' R' : ListBlank Bool) (l₁ l₂ : List Bool) (h : List.length l₂ = i),
    stepAux (readAux i f) v (Tape.mk' (ListBlank.append l₁ L') (ListBlank.append l₂ R')) =
      stepAux (f { val := l₂, property := h }) v (Tape.mk' (ListBlank.append (List.reverseAux l₂ l₁) L') R')
f : Vector Bool n → Stmt Bool Λ' σ
⊢ stepAux (readAux n f) v
      (Tape.mk'
        (ListBlank.bind L (fun x => List.reverse (Vector.toList (enc x)))
          (_ : ∃ n_1, (fun x => List.reverse (Vector.toList (enc x))) default = List.replicate n_1 default))
        (ListBlank.append (Vector.toList (enc a))
          (ListBlank.bind R (fun x => Vector.toList (enc x))
            (_ : ∃ n_1, (fun x => Vector.toList (enc x)) default = List.replicate n_1 default)))) =
    stepAux (f (enc a)) v
      (Tape.mk'
        (ListBlank.append (List.reverse (Vector.toList (enc a)))
          (ListBlank.bind L (fun x => List.reverse (Vector.toList (enc x)))
            (_ : ∃ n_1, (fun x => List.reverse (Vector.toList (enc x))) default = List.replicate n_1 default)))
        (ListBlank.bind R (fun x => Vector.toList (enc x))
          (_ : ∃ n_1, (fun x => Vector.toList (enc x)) default = List.replicate n_1 default)))
exact this n f (L.bind (fun x => (enc x).1.reverse) _)
  (R.bind (fun x => (enc x).1) _) [] _ (enc a).2
no goals
case intro.intro.nil
Γ : Type u_3
inst✝² : Inhabited Γ
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
n : ℕ
enc : Γ → Vector Bool n
dec : Vector Bool n → Γ
enc0 : enc default = Vector.replicate n false
M : Λ → Stmt₁
encdec : ∀ (a : Γ), dec (enc a) = a
v : σ
L' R' : ListBlank Bool
l₁✝ l₂ : List Bool
f✝ : Vector Bool (List.length l₂) → Stmt Bool Λ' σ
l₁ : List Bool
f : Vector Bool (List.length []) → Stmt Bool Λ' σ
⊢ stepAux (readAux (List.length []) f) v (Tape.mk' (ListBlank.append l₁ L') (ListBlank.append [] R')) =
    stepAux (f { val := [], property := (_ : List.length [] = List.length []) }) v
      (Tape.mk' (ListBlank.append (List.reverseAux [] l₁) L') R')
rfl
Γ : Type u_3
inst✝² : Inhabited Γ
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
n : ℕ
enc : Γ → Vector Bool n
dec : Vector Bool n → Γ
enc0 : enc default = Vector.replicate n false
M : Λ → Stmt₁
encdec : ∀ (a : Γ), dec (enc a) = a
v : σ
L' R' : ListBlank Bool
l₁✝ l₂✝ : List Bool
f✝ : Vector Bool (List.length l₂✝) → Stmt Bool Λ' σ
a : Bool
l₂ : List Bool
IH :
  ∀ (l₁ : List Bool) (f : Vector Bool (List.length l₂) → Stmt Bool Λ' σ),
    stepAux (readAux (List.length l₂) f) v (Tape.mk' (ListBlank.append l₁ L') (ListBlank.append l₂ R')) =
      stepAux (f { val := l₂, property := (_ : List.length l₂ = List.length l₂) }) v
        (Tape.mk' (ListBlank.append (List.reverseAux l₂ l₁) L') R')
l₁ : List Bool
f : Vector Bool (List.length (a :: l₂)) → Stmt Bool Λ' σ
⊢ (bif ListBlank.head (ListBlank.cons a (ListBlank.append l₂ R')) then
      stepAux (readAux (List.length l₂) fun v => f (true ::ᵥ v)) v
        (Tape.move Dir.right (Tape.mk' (ListBlank.append l₁ L') (ListBlank.cons a (ListBlank.append l₂ R'))))
    else
      stepAux (readAux (List.length l₂) fun v => f (false ::ᵥ v)) v
        (Tape.move Dir.right (Tape.mk' (ListBlank.append l₁ L') (ListBlank.cons a (ListBlank.append l₂ R'))))) =
    stepAux (readAux (List.length l₂) fun v => f (a ::ᵥ v)) v
      (Tape.mk' (ListBlank.cons a (ListBlank.append l₁ L')) (ListBlank.append l₂ R'))
Γ : Type u_3
inst✝² : Inhabited Γ
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
n : ℕ
enc : Γ → Vector Bool n
dec : Vector Bool n → Γ
enc0 : enc default = Vector.replicate n false
M : Λ → Stmt₁
encdec : ∀ (a : Γ), dec (enc a) = a
v : σ
L' R' : ListBlank Bool
l₁✝ l₂✝ : List Bool
f✝ : Vector Bool (List.length l₂✝) → Stmt Bool Λ' σ
a : Bool
l₂ : List Bool
IH :
  ∀ (l₁ : List Bool) (f : Vector Bool (List.length l₂) → Stmt Bool Λ' σ),
    stepAux (readAux (List.length l₂) f) v (Tape.mk' (ListBlank.append l₁ L') (ListBlank.append l₂ R')) =
      stepAux (f { val := l₂, property := (_ : List.length l₂ = List.length l₂) }) v
        (Tape.mk' (ListBlank.append (List.reverseAux l₂ l₁) L') R')
l₁ : List Bool
f : Vector Bool (List.length (a :: l₂)) → Stmt Bool Λ' σ
⊢ stepAux (readAux (List.length (a :: l₂)) f) v (Tape.mk' (ListBlank.append l₁ L') (ListBlank.append (a :: l₂) R')) =
    stepAux (readAux (List.length l₂) fun v => f (a ::ᵥ v)) v
      (Tape.mk' (ListBlank.cons a (ListBlank.append l₁ L')) (ListBlank.append l₂ R'))
dsimp [readAux, stepAux]
Γ : Type u_3
inst✝² : Inhabited Γ
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
n : ℕ
enc : Γ → Vector Bool n
dec : Vector Bool n → Γ
enc0 : enc default = Vector.replicate n false
M : Λ → Stmt₁
encdec : ∀ (a : Γ), dec (enc a) = a
v : σ
L' R' : ListBlank Bool
l₁✝ l₂✝ : List Bool
f✝ : Vector Bool (List.length l₂✝) → Stmt Bool Λ' σ
a : Bool
l₂ : List Bool
IH :
  ∀ (l₁ : List Bool) (f : Vector Bool (List.length l₂) → Stmt Bool Λ' σ),
    stepAux (readAux (List.length l₂) f) v (Tape.mk' (ListBlank.append l₁ L') (ListBlank.append l₂ R')) =
      stepAux (f { val := l₂, property := (_ : List.length l₂ = List.length l₂) }) v
        (Tape.mk' (ListBlank.append (List.reverseAux l₂ l₁) L') R')
l₁ : List Bool
f : Vector Bool (List.length (a :: l₂)) → Stmt Bool Λ' σ
⊢ (bif a then
      stepAux (readAux (List.length l₂) fun v => f (true ::ᵥ v)) v
        (Tape.mk' (ListBlank.cons a (ListBlank.append l₁ L')) (ListBlank.append l₂ R'))
    else
      stepAux (readAux (List.length l₂) fun v => f (false ::ᵥ v)) v
        (Tape.mk' (ListBlank.cons a (ListBlank.append l₁ L')) (ListBlank.append l₂ R'))) =
    stepAux (readAux (List.length l₂) fun v => f (a ::ᵥ v)) v
      (Tape.mk' (ListBlank.cons a (ListBlank.append l₁ L')) (ListBlank.append l₂ R'))
Γ : Type u_3
inst✝² : Inhabited Γ
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
n : ℕ
enc : Γ → Vector Bool n
dec : Vector Bool n → Γ
enc0 : enc default = Vector.replicate n false
M : Λ → Stmt₁
encdec : ∀ (a : Γ), dec (enc a) = a
v : σ
L' R' : ListBlank Bool
l₁✝ l₂✝ : List Bool
f✝ : Vector Bool (List.length l₂✝) → Stmt Bool Λ' σ
a : Bool
l₂ : List Bool
IH :
  ∀ (l₁ : List Bool) (f : Vector Bool (List.length l₂) → Stmt Bool Λ' σ),
    stepAux (readAux (List.length l₂) f) v (Tape.mk' (ListBlank.append l₁ L') (ListBlank.append l₂ R')) =
      stepAux (f { val := l₂, property := (_ : List.length l₂ = List.length l₂) }) v
        (Tape.mk' (ListBlank.append (List.reverseAux l₂ l₁) L') R')
l₁ : List Bool
f : Vector Bool (List.length (a :: l₂)) → Stmt Bool Λ' σ
⊢ (bif ListBlank.head (ListBlank.cons a (ListBlank.append l₂ R')) then
      stepAux (readAux (List.length l₂) fun v => f (true ::ᵥ v)) v
        (Tape.move Dir.right (Tape.mk' (ListBlank.append l₁ L') (ListBlank.cons a (ListBlank.append l₂ R'))))
    else
      stepAux (readAux (List.length l₂) fun v => f (false ::ᵥ v)) v
        (Tape.move Dir.right (Tape.mk' (ListBlank.append l₁ L') (ListBlank.cons a (ListBlank.append l₂ R'))))) =
    stepAux (readAux (List.length l₂) fun v => f (a ::ᵥ v)) v
      (Tape.mk' (ListBlank.cons a (ListBlank.append l₁ L')) (ListBlank.append l₂ R'))
simp
no goals
Γ : Type u_3
inst✝² : Inhabited Γ
Λ : Type u_2
inst✝¹ : Inhabited Λ
σ : Type u_1
inst✝ : Inhabited σ
n : ℕ
enc : Γ → Vector Bool n
dec : Vector Bool n → Γ
enc0 : enc default = Vector.replicate n false
M : Λ → Stmt₁
encdec : ∀ (a : Γ), dec (enc a) = a
v : σ
L' R' : ListBlank Bool
l₁✝ l₂✝ : List Bool
f✝ : Vector Bool (List.length l₂✝) → Stmt Bool Λ' σ
a : Bool
l₂ : List Bool
IH :
  ∀ (l₁ : List Bool) (f : Vector Bool (List.length l₂) → Stmt Bool Λ' σ),
    stepAux (readAux (List.length l₂) f) v (Tape.mk' (ListBlank.append l₁ L') (ListBlank.append l₂ R')) =
      stepAux (f { val := l₂, property := (_ : List.length l₂ = List.length l₂) }) v
        (Tape.mk' (ListBlank.append (List.reverseAux l₂ l₁) L') R')
l₁ : List Bool
f : Vector Bool (List.length (a :: l₂)) → Stmt Bool Λ' σ
⊢ (bif a then
      stepAux (readAux (List.length l₂) fun v => f (true ::ᵥ v)) v
        (Tape.mk' (ListBlank.cons a (ListBlank.append l₁ L')) (ListBlank.append l₂ R'))
    else
      stepAux (readAux (List.length l₂) fun v => f (false ::ᵥ v)) v
        (Tape.mk' (ListBlank.cons a (ListBlank.append l₁ L')) (ListBlank.append l₂ R'))) =
    stepAux (readAux (List.length l₂) fun v => f (a ::ᵥ v)) v
      (Tape.mk' (ListBlank.cons a (ListBlank.append l₁ L')) (ListBlank.append l₂ R'))
cases a <;> rfl