l3lab/ntp-mathlib huggingface dataset:
instance (m : Type u → Type v) [Monad m] [LawfulMonad m] : LawfulMonad (OptionT m) :=
  LawfulMonad.mk'
    (id_map := by
      intros; apply OptionT.ext; simp only [OptionT.run_map]
      rw [map_congr, id_map]
      intro a; cases a <;> rfl)
    (bind_assoc := by
      intros; apply OptionT.ext; 

Proof state:
case h
m : Type u → Type v
inst✝¹ : Monad m
inst✝ : LawfulMonad m
α✝ β✝ γ✝ : Type u
x✝ : OptionT m α✝
f✝ : α✝ → OptionT m β✝
g✝ : β✝ → OptionT m γ✝
⊢ OptionT.run (x✝ >>= f✝ >>= g✝) = OptionT.run (x✝ >>= fun x => f✝ x >>= g✝)

Next tactic:
simp only [OptionT.run_bind, bind_assoc]
instance (m : Type u → Type v) [Monad m] [LawfulMonad m] : LawfulMonad (OptionT m) :=
  LawfulMonad.mk'
    (id_map := by
      intros; apply OptionT.ext; simp only [OptionT.run_map]
      rw [map_congr, id_map]
      intro a; cases a <;> rfl)
    (bind_assoc := by
      intros; apply OptionT.ext; simp only [OptionT.run_bind, bind_assoc]
      

Proof state:
case h
m : Type u → Type v
inst✝¹ : Monad m
inst✝ : LawfulMonad m
α✝ β✝ γ✝ : Type u
x✝ : OptionT m α✝
f✝ : α✝ → OptionT m β✝
g✝ : β✝ → OptionT m γ✝
⊢ (do
      let x ← OptionT.run x✝
      let x ←
        match x with
          | some a => OptionT.run (f✝ a)
          | none => pure none
      match x with
        | some a => OptionT.run (g✝ a)
        | none => pure none) =
    do
    let x ← OptionT.run x✝
    match x with
      | some a => do
        let x ← OptionT.run (f✝ a)
        match x with
          | some a => OptionT.run (g✝ a)
          | none => pure none
      | none => pure none

Next tactic:
rw [bind_congr]
instance (m : Type u → Type v) [Monad m] [LawfulMonad m] : LawfulMonad (OptionT m) :=
  LawfulMonad.mk'
    (id_map := by
      intros; apply OptionT.ext; simp only [OptionT.run_map]
      rw [map_congr, id_map]
      intro a; cases a <;> rfl)
    (bind_assoc := by
      intros; apply OptionT.ext; simp only [OptionT.run_bind, bind_assoc]
      rw [bind_congr]
      

Proof state:
case h
m : Type u → Type v
inst✝¹ : Monad m
inst✝ : LawfulMonad m
α✝ β✝ γ✝ : Type u
x✝ : OptionT m α✝
f✝ : α✝ → OptionT m β✝
g✝ : β✝ → OptionT m γ✝
⊢ ∀ (a : Option α✝),
    (do
        let x ←
          match a with
            | some a => OptionT.run (f✝ a)
            | none => pure none
        match x with
          | some a => OptionT.run (g✝ a)
          | none => pure none) =
      match a with
      | some a => do
        let x ← OptionT.run (f✝ a)
        match x with
          | some a => OptionT.run (g✝ a)
          | none => pure none
      | none => pure none

Next tactic:
intro a
instance (m : Type u → Type v) [Monad m] [LawfulMonad m] : LawfulMonad (OptionT m) :=
  LawfulMonad.mk'
    (id_map := by
      intros; apply OptionT.ext; simp only [OptionT.run_map]
      rw [map_congr, id_map]
      intro a; cases a <;> rfl)
    (bind_assoc := by
      intros; apply OptionT.ext; simp only [OptionT.run_bind, bind_assoc]
      rw [bind_congr]
      intro a; 

Proof state:
case h
m : Type u → Type v
inst✝¹ : Monad m
inst✝ : LawfulMonad m
α✝ β✝ γ✝ : Type u
x✝ : OptionT m α✝
f✝ : α✝ → OptionT m β✝
g✝ : β✝ → OptionT m γ✝
a : Option α✝
⊢ (do
      let x ←
        match a with
          | some a => OptionT.run (f✝ a)
          | none => pure none
      match x with
        | some a => OptionT.run (g✝ a)
        | none => pure none) =
    match a with
    | some a => do
      let x ← OptionT.run (f✝ a)
      match x with
        | some a => OptionT.run (g✝ a)
        | none => pure none
    | none => pure none

Next tactic:
cases a
instance (m : Type u → Type v) [Monad m] [LawfulMonad m] : LawfulMonad (OptionT m) :=
  LawfulMonad.mk'
    (id_map := by
      intros; apply OptionT.ext; simp only [OptionT.run_map]
      rw [map_congr, id_map]
      intro a; cases a <;> rfl)
    (bind_assoc := by
      intros; apply OptionT.ext; simp only [OptionT.run_bind, bind_assoc]
      rw [bind_congr]
      intro a; cases a <;> 

Proof state:
case h.none
m : Type u → Type v
inst✝¹ : Monad m
inst✝ : LawfulMonad m
α✝ β✝ γ✝ : Type u
x✝ : OptionT m α✝
f✝ : α✝ → OptionT m β✝
g✝ : β✝ → OptionT m γ✝
⊢ (do
      let x ←
        match none with
          | some a => OptionT.run (f✝ a)
          | none => pure none
      match x with
        | some a => OptionT.run (g✝ a)
        | none => pure none) =
    match none with
    | some a => do
      let x ← OptionT.run (f✝ a)
      match x with
        | some a => OptionT.run (g✝ a)
        | none => pure none
    | none => pure none

Next tactic:
simp
instance (m : Type u → Type v) [Monad m] [LawfulMonad m] : LawfulMonad (OptionT m) :=
  LawfulMonad.mk'
    (id_map := by
      intros; apply OptionT.ext; simp only [OptionT.run_map]
      rw [map_congr, id_map]
      intro a; cases a <;> rfl)
    (bind_assoc := by
      intros; apply OptionT.ext; simp only [OptionT.run_bind, bind_assoc]
      rw [bind_congr]
      intro a; cases a <;> 

Proof state:
case h.some
m : Type u → Type v
inst✝¹ : Monad m
inst✝ : LawfulMonad m
α✝ β✝ γ✝ : Type u
x✝ : OptionT m α✝
f✝ : α✝ → OptionT m β✝
g✝ : β✝ → OptionT m γ✝
val✝ : α✝
⊢ (do
      let x ←
        match some val✝ with
          | some a => OptionT.run (f✝ a)
          | none => pure none
      match x with
        | some a => OptionT.run (g✝ a)
        | none => pure none) =
    match some val✝ with
    | some a => do
      let x ← OptionT.run (f✝ a)
      match x with
        | some a => OptionT.run (g✝ a)
        | none => pure none
    | none => pure none

Next tactic:
simp
/-- The vector cons operation -/
@[match_pattern]
def cons (a : α) (v : Vector3 α n) : Vector3 α (succ n) := fun i => by
  

Proof state:
α : Type u_1
m n : ℕ
a : α
v : Vector3 α n
i : Fin2 (succ n)
⊢ α

Next tactic:
refine' i.cases' _ _
/-- The vector cons operation -/
@[match_pattern]
def cons (a : α) (v : Vector3 α n) : Vector3 α (succ n) := fun i => by
  refine' i.cases' _ _
  

Proof state:
case refine'_1
α : Type u_1
m n : ℕ
a : α
v : Vector3 α n
i : Fin2 (succ n)
⊢ α
case refine'_2 α : Type u_1 m n : ℕ a : α v : Vector3 α n i : Fin2 (succ n) ⊢ Fin2 n → α

Next tactic:
exact a
/-- The vector cons operation -/
@[match_pattern]
def cons (a : α) (v : Vector3 α n) : Vector3 α (succ n) := fun i => by
  refine' i.cases' _ _
  exact a
  

Proof state:
case refine'_2
α : Type u_1
m n : ℕ
a : α
v : Vector3 α n
i : Fin2 (succ n)
⊢ Fin2 n → α

Next tactic:
exact v
/-- Eliminator for an empty vector. -/
@[elab_as_elim]  -- porting note: add `elab_as_elim`
def nilElim {C : Vector3 α 0 → Sort u} (H : C []) (v : Vector3 α 0) : C v := by
  

Proof state:
α : Type u_1
m n : ℕ
C : Vector3 α 0 → Sort u
H : C []
v : Vector3 α 0
⊢ C v

Next tactic:
rw [eq_nil v]
/-- Eliminator for an empty vector. -/
@[elab_as_elim]  -- porting note: add `elab_as_elim`
def nilElim {C : Vector3 α 0 → Sort u} (H : C []) (v : Vector3 α 0) : C v := by
  rw [eq_nil v]; 

Proof state:
α : Type u_1
m n : ℕ
C : Vector3 α 0 → Sort u
H : C []
v : Vector3 α 0
⊢ C []

Next tactic:
apply H
/-- Recursion principle for a nonempty vector. -/
@[elab_as_elim]  -- porting note: add `elab_as_elim`
def consElim {C : Vector3 α (succ n) → Sort u} (H : ∀ (a : α) (t : Vector3 α n), C (a :: t))
    (v : Vector3 α (succ n)) : C v := by 

Proof state:
α : Type u_1
m n : ℕ
C : Vector3 α (succ n) → Sort u
H : (a : α) → (t : Vector3 α n) → C (a :: t)
v : Vector3 α (succ n)
⊢ C v

Next tactic:
rw [← cons_head_tail v]
/-- Recursion principle for a nonempty vector. -/
@[elab_as_elim]  -- porting note: add `elab_as_elim`
def consElim {C : Vector3 α (succ n) → Sort u} (H : ∀ (a : α) (t : Vector3 α n), C (a :: t))
    (v : Vector3 α (succ n)) : C v := by rw [← cons_head_tail v]; 

Proof state:
α : Type u_1
m n : ℕ
C : Vector3 α (succ n) → Sort u
H : (a : α) → (t : Vector3 α n) → C (a :: t)
v : Vector3 α (succ n)
⊢ C (head v :: tail v)

Next tactic:
apply H
@[simp]
theorem append_left :
    ∀ {m} (i : Fin2 m) (v : Vector3 α m) {n} (w : Vector3 α n), (v +-+ w) (left n i) = v i
  | _, @fz m, v, n, w => v.consElim fun a _t => by 

Proof state:
α : Type u_1
m✝ n✝ m : ℕ
v : Vector3 α (succ m)
n : ℕ
w : Vector3 α n
a : α
_t : Vector3 α m
⊢ ((a :: _t) +-+ w) (left n fz) = (a :: _t) fz

Next tactic:
simp [*, left]
@[simp]
theorem append_left :
    ∀ {m} (i : Fin2 m) (v : Vector3 α m) {n} (w : Vector3 α n), (v +-+ w) (left n i) = v i
  | _, @fz m, v, n, w => v.consElim fun a _t => by simp [*, left]
  | _, @fs m i, v, n, w => v.consElim fun _a t => by 

Proof state:
α : Type u_1
m✝ n✝ m : ℕ
i : Fin2 m
v : Vector3 α (succ m)
n : ℕ
w : Vector3 α n
_a : α
t : Vector3 α m
⊢ ((_a :: t) +-+ w) (left n (fs i)) = (_a :: t) (fs i)

Next tactic:
simp [append_left, left]
@[simp]
theorem append_add :
    ∀ {m} (v : Vector3 α m) {n} (w : Vector3 α n) (i : Fin2 n), (v +-+ w) (add i m) = w i
  | 0, v, n, w, i => rfl
  | succ m, v, n, w, i => v.consElim fun _a t => by 

Proof state:
α : Type u_1
m✝ n✝ m : ℕ
v : Vector3 α (succ m)
n : ℕ
w : Vector3 α n
i : Fin2 n
_a : α
t : Vector3 α m
⊢ ((_a :: t) +-+ w) (add i (succ m)) = w i

Next tactic:
simp [append_add, add]
@[simp]
theorem insert_fz (a : α) (v : Vector3 α n) : insert a v fz = a :: v := by
  

Proof state:
α : Type u_1
m n : ℕ
a : α
v : Vector3 α n
⊢ insert a v fz = a :: v

Next tactic:
refine' funext fun j => j.cases' _ _
@[simp]
theorem insert_fz (a : α) (v : Vector3 α n) : insert a v fz = a :: v := by
  refine' funext fun j => j.cases' _ _ <;> 

Proof state:
case refine'_1
α : Type u_1
m n : ℕ
a : α
v : Vector3 α n
j : Fin2 (succ n)
⊢ insert a v fz fz = (a :: v) fz

Next tactic:
intros
@[simp]
theorem insert_fz (a : α) (v : Vector3 α n) : insert a v fz = a :: v := by
  refine' funext fun j => j.cases' _ _ <;> 

Proof state:
case refine'_2
α : Type u_1
m n : ℕ
a : α
v : Vector3 α n
j : Fin2 (succ n)
⊢ ∀ (n_1 : Fin2 n), insert a v fz (fs n_1) = (a :: v) (fs n_1)

Next tactic:
intros
@[simp]
theorem insert_fz (a : α) (v : Vector3 α n) : insert a v fz = a :: v := by
  refine' funext fun j => j.cases' _ _ <;> intros <;> 

Proof state:
case refine'_1
α : Type u_1
m n : ℕ
a : α
v : Vector3 α n
j : Fin2 (succ n)
⊢ insert a v fz fz = (a :: v) fz

Next tactic:
rfl
@[simp]
theorem insert_fz (a : α) (v : Vector3 α n) : insert a v fz = a :: v := by
  refine' funext fun j => j.cases' _ _ <;> intros <;> 

Proof state:
case refine'_2
α : Type u_1
m n : ℕ
a : α
v : Vector3 α n
j : Fin2 (succ n)
n✝ : Fin2 n
⊢ insert a v fz (fs n✝) = (a :: v) (fs n✝)

Next tactic:
rfl
@[simp]
theorem insert_fs (a : α) (b : α) (v : Vector3 α n) (i : Fin2 (succ n)) :
    insert a (b :: v) (fs i) = b :: insert a v i :=
  funext fun j => by
    

Proof state:
α : Type u_1
m n : ℕ
a b : α
v : Vector3 α n
i : Fin2 (succ n)
j : Fin2 (succ (succ n))
⊢ insert a (b :: v) (fs i) j = (b :: insert a v i) j

Next tactic:
refine' j.cases' _ fun j => _
@[simp]
theorem insert_fs (a : α) (b : α) (v : Vector3 α n) (i : Fin2 (succ n)) :
    insert a (b :: v) (fs i) = b :: insert a v i :=
  funext fun j => by
    refine' j.cases' _ fun j => _ <;> 

Proof state:
case refine'_1
α : Type u_1
m n : ℕ
a b : α
v : Vector3 α n
i : Fin2 (succ n)
j : Fin2 (succ (succ n))
⊢ insert a (b :: v) (fs i) fz = (b :: insert a v i) fz

Next tactic:
simp [insert, insertPerm]
@[simp]
theorem insert_fs (a : α) (b : α) (v : Vector3 α n) (i : Fin2 (succ n)) :
    insert a (b :: v) (fs i) = b :: insert a v i :=
  funext fun j => by
    refine' j.cases' _ fun j => _ <;> 

Proof state:
case refine'_2
α : Type u_1
m n : ℕ
a b : α
v : Vector3 α n
i : Fin2 (succ n)
j✝ : Fin2 (succ (succ n))
j : Fin2 (n + 1)
⊢ insert a (b :: v) (fs i) (fs j) = (b :: insert a v i) (fs j)

Next tactic:
simp [insert, insertPerm]
@[simp]
theorem insert_fs (a : α) (b : α) (v : Vector3 α n) (i : Fin2 (succ n)) :
    insert a (b :: v) (fs i) = b :: insert a v i :=
  funext fun j => by
    refine' j.cases' _ fun j => _ <;> simp [insert, insertPerm]
    

Proof state:
case refine'_2
α : Type u_1
m n : ℕ
a b : α
v : Vector3 α n
i : Fin2 (succ n)
j✝ : Fin2 (succ (succ n))
j : Fin2 (n + 1)
⊢ (a :: b :: v)
      (match insertPerm i j with
      | fz => fz
      | fs k => fs (fs k)) =
    (a :: v) (insertPerm i j)

Next tactic:
refine' Fin2.cases' _ _ (insertPerm i j)
@[simp]
theorem insert_fs (a : α) (b : α) (v : Vector3 α n) (i : Fin2 (succ n)) :
    insert a (b :: v) (fs i) = b :: insert a v i :=
  funext fun j => by
    refine' j.cases' _ fun j => _ <;> simp [insert, insertPerm]
    refine' Fin2.cases' _ _ (insertPerm i j) <;> 

Proof state:
case refine'_2.refine'_1
α : Type u_1
m n : ℕ
a b : α
v : Vector3 α n
i : Fin2 (succ n)
j✝ : Fin2 (succ (succ n))
j : Fin2 (n + 1)
⊢ (a :: b :: v)
      (match fz with
      | fz => fz
      | fs k => fs (fs k)) =
    (a :: v) fz

Next tactic:
simp [insertPerm]
@[simp]
theorem insert_fs (a : α) (b : α) (v : Vector3 α n) (i : Fin2 (succ n)) :
    insert a (b :: v) (fs i) = b :: insert a v i :=
  funext fun j => by
    refine' j.cases' _ fun j => _ <;> simp [insert, insertPerm]
    refine' Fin2.cases' _ _ (insertPerm i j) <;> 

Proof state:
case refine'_2.refine'_2
α : Type u_1
m n : ℕ
a b : α
v : Vector3 α n
i : Fin2 (succ n)
j✝ : Fin2 (succ (succ n))
j : Fin2 (n + 1)
⊢ ∀ (n_1 : Fin2 n),
    (a :: b :: v)
        (match fs n_1 with
        | fz => fz
        | fs k => fs (fs k)) =
      (a :: v) (fs n_1)

Next tactic:
simp [insertPerm]
theorem append_insert (a : α) (t : Vector3 α m) (v : Vector3 α n) (i : Fin2 (succ n))
    (e : succ n + m = succ (n + m)) :
    insert a (t +-+ v) (Eq.recOn e (i.add m)) = Eq.recOn e (t +-+ insert a v i) := by
  

Proof state:
α : Type u_1
m n : ℕ
a : α
t : Vector3 α m
v : Vector3 α n
i : Fin2 (succ n)
e : succ n + m = succ (n + m)
⊢ insert a (t +-+ v) (Eq.recOn e (add i m)) = Eq.recOn e (t +-+ insert a v i)

Next tactic:
refine' Vector3.recOn t (fun e => _) (@fun k b t IH _ => _) e
theorem append_insert (a : α) (t : Vector3 α m) (v : Vector3 α n) (i : Fin2 (succ n))
    (e : succ n + m = succ (n + m)) :
    insert a (t +-+ v) (Eq.recOn e (i.add m)) = Eq.recOn e (t +-+ insert a v i) := by
  refine' Vector3.recOn t (fun e => _) (@fun k b t IH _ => _) e; 

Proof state:
case refine'_1
α : Type u_1
m n : ℕ
a : α
t : Vector3 α m
v : Vector3 α n
i : Fin2 (succ n)
e✝ : succ n + m = succ (n + m)
e : succ n + 0 = succ (n + 0)
⊢ insert a ([] +-+ v) (Eq.recOn e (add i 0)) = Eq.recOn e ([] +-+ insert a v i)
case refine'_2
α : Type u_1
m n : ℕ
a : α
t✝ : Vector3 α m
v : Vector3 α n
i : Fin2 (succ n)
e : succ n + m = succ (n + m)
k : ℕ
b : α
t : Vector3 α k
IH : ∀ (x : succ n + k = succ (n + k)), insert a (t +-+ v) (Eq.recOn x (add i k)) = Eq.recOn x (t +-+ insert a v i)
x✝ : succ n + succ k = succ (n + succ k)
⊢ insert a ((b :: t) +-+ v) (Eq.recOn x✝ (add i (succ k))) = Eq.recOn x✝ ((b :: t) +-+ insert a v i)

Next tactic:
rfl
theorem append_insert (a : α) (t : Vector3 α m) (v : Vector3 α n) (i : Fin2 (succ n))
    (e : succ n + m = succ (n + m)) :
    insert a (t +-+ v) (Eq.recOn e (i.add m)) = Eq.recOn e (t +-+ insert a v i) := by
  refine' Vector3.recOn t (fun e => _) (@fun k b t IH _ => _) e; rfl
  

Proof state:
case refine'_2
α : Type u_1
m n : ℕ
a : α
t✝ : Vector3 α m
v : Vector3 α n
i : Fin2 (succ n)
e : succ n + m = succ (n + m)
k : ℕ
b : α
t : Vector3 α k
IH : ∀ (x : succ n + k = succ (n + k)), insert a (t +-+ v) (Eq.recOn x (add i k)) = Eq.recOn x (t +-+ insert a v i)
x✝ : succ n + succ k = succ (n + succ k)
⊢ insert a ((b :: t) +-+ v) (Eq.recOn x✝ (add i (succ k))) = Eq.recOn x✝ ((b :: t) +-+ insert a v i)

Next tactic:
have e' := succ_add n k
theorem append_insert (a : α) (t : Vector3 α m) (v : Vector3 α n) (i : Fin2 (succ n))
    (e : succ n + m = succ (n + m)) :
    insert a (t +-+ v) (Eq.recOn e (i.add m)) = Eq.recOn e (t +-+ insert a v i) := by
  refine' Vector3.recOn t (fun e => _) (@fun k b t IH _ => _) e; rfl
  have e' := succ_add n k
  

Proof state:
case refine'_2
α : Type u_1
m n : ℕ
a : α
t✝ : Vector3 α m
v : Vector3 α n
i : Fin2 (succ n)
e : succ n + m = succ (n + m)
k : ℕ
b : α
t : Vector3 α k
IH : ∀ (x : succ n + k = succ (n + k)), insert a (t +-+ v) (Eq.recOn x (add i k)) = Eq.recOn x (t +-+ insert a v i)
x✝ : succ n + succ k = succ (n + succ k)
e' : succ n + k = succ (n + k)
⊢ insert a ((b :: t) +-+ v) (Eq.recOn x✝ (add i (succ k))) = Eq.recOn x✝ ((b :: t) +-+ insert a v i)

Next tactic:
change
    insert a (b :: t +-+ v) (Eq.recOn (congr_arg succ e') (fs (add i k))) =
      Eq.recOn (congr_arg succ e') (b :: t +-+ insert a v i)
theorem append_insert (a : α) (t : Vector3 α m) (v : Vector3 α n) (i : Fin2 (succ n))
    (e : succ n + m = succ (n + m)) :
    insert a (t +-+ v) (Eq.recOn e (i.add m)) = Eq.recOn e (t +-+ insert a v i) := by
  refine' Vector3.recOn t (fun e => _) (@fun k b t IH _ => _) e; rfl
  have e' := succ_add n k
  change
    insert a (b :: t +-+ v) (Eq.recOn (congr_arg succ e') (fs (add i k))) =
      Eq.recOn (congr_arg succ e') (b :: t +-+ insert a v i)
  

Proof state:
case refine'_2
α : Type u_1
m n : ℕ
a : α
t✝ : Vector3 α m
v : Vector3 α n
i : Fin2 (succ n)
e : succ n + m = succ (n + m)
k : ℕ
b : α
t : Vector3 α k
IH : ∀ (x : succ n + k = succ (n + k)), insert a (t +-+ v) (Eq.recOn x (add i k)) = Eq.recOn x (t +-+ insert a v i)
x✝ : succ n + succ k = succ (n + succ k)
e' : succ n + k = succ (n + k)
⊢ insert a (b :: t +-+ v) (Eq.recOn (_ : succ (succ n + k) = succ (succ (n + k))) (fs (add i k))) =
    Eq.recOn (_ : succ (succ n + k) = succ (succ (n + k))) (b :: t +-+ insert a v i)

Next tactic:
rw [←
    (Eq.recOn e' rfl :
      fs (Eq.recOn e' (i.add k) : Fin2 (succ (n + k))) =
        Eq.recOn (congr_arg succ e') (fs (i.add k)))]
theorem append_insert (a : α) (t : Vector3 α m) (v : Vector3 α n) (i : Fin2 (succ n))
    (e : succ n + m = succ (n + m)) :
    insert a (t +-+ v) (Eq.recOn e (i.add m)) = Eq.recOn e (t +-+ insert a v i) := by
  refine' Vector3.recOn t (fun e => _) (@fun k b t IH _ => _) e; rfl
  have e' := succ_add n k
  change
    insert a (b :: t +-+ v) (Eq.recOn (congr_arg succ e') (fs (add i k))) =
      Eq.recOn (congr_arg succ e') (b :: t +-+ insert a v i)
  rw [←
    (Eq.recOn e' rfl :
      fs (Eq.recOn e' (i.add k) : Fin2 (succ (n + k))) =
        Eq.recOn (congr_arg succ e') (fs (i.add k)))]
  

Proof state:
case refine'_2
α : Type u_1
m n : ℕ
a : α
t✝ : Vector3 α m
v : Vector3 α n
i : Fin2 (succ n)
e : succ n + m = succ (n + m)
k : ℕ
b : α
t : Vector3 α k
IH : ∀ (x : succ n + k = succ (n + k)), insert a (t +-+ v) (Eq.recOn x (add i k)) = Eq.recOn x (t +-+ insert a v i)
x✝ : succ n + succ k = succ (n + succ k)
e' : succ n + k = succ (n + k)
⊢ insert a (b :: t +-+ v) (fs (Eq.recOn e' (add i k))) =
    Eq.recOn (_ : succ (succ n + k) = succ (succ (n + k))) (b :: t +-+ insert a v i)

Next tactic:
simp
theorem append_insert (a : α) (t : Vector3 α m) (v : Vector3 α n) (i : Fin2 (succ n))
    (e : succ n + m = succ (n + m)) :
    insert a (t +-+ v) (Eq.recOn e (i.add m)) = Eq.recOn e (t +-+ insert a v i) := by
  refine' Vector3.recOn t (fun e => _) (@fun k b t IH _ => _) e; rfl
  have e' := succ_add n k
  change
    insert a (b :: t +-+ v) (Eq.recOn (congr_arg succ e') (fs (add i k))) =
      Eq.recOn (congr_arg succ e') (b :: t +-+ insert a v i)
  rw [←
    (Eq.recOn e' rfl :
      fs (Eq.recOn e' (i.add k) : Fin2 (succ (n + k))) =
        Eq.recOn (congr_arg succ e') (fs (i.add k)))]
  simp; 

Proof state:
case refine'_2
α : Type u_1
m n : ℕ
a : α
t✝ : Vector3 α m
v : Vector3 α n
i : Fin2 (succ n)
e : succ n + m = succ (n + m)
k : ℕ
b : α
t : Vector3 α k
IH : ∀ (x : succ n + k = succ (n + k)), insert a (t +-+ v) (Eq.recOn x (add i k)) = Eq.recOn x (t +-+ insert a v i)
x✝ : succ n + succ k = succ (n + succ k)
e' : succ n + k = succ (n + k)
⊢ (b :: insert a (t +-+ v) (e' ▸ add i k)) = (_ : succ (succ n + k) = succ (succ (n + k))) ▸ b :: t +-+ insert a v i

Next tactic:
rw [IH]
theorem append_insert (a : α) (t : Vector3 α m) (v : Vector3 α n) (i : Fin2 (succ n))
    (e : succ n + m = succ (n + m)) :
    insert a (t +-+ v) (Eq.recOn e (i.add m)) = Eq.recOn e (t +-+ insert a v i) := by
  refine' Vector3.recOn t (fun e => _) (@fun k b t IH _ => _) e; rfl
  have e' := succ_add n k
  change
    insert a (b :: t +-+ v) (Eq.recOn (congr_arg succ e') (fs (add i k))) =
      Eq.recOn (congr_arg succ e') (b :: t +-+ insert a v i)
  rw [←
    (Eq.recOn e' rfl :
      fs (Eq.recOn e' (i.add k) : Fin2 (succ (n + k))) =
        Eq.recOn (congr_arg succ e') (fs (i.add k)))]
  simp; rw [IH]; 

Proof state:
case refine'_2
α : Type u_1
m n : ℕ
a : α
t✝ : Vector3 α m
v : Vector3 α n
i : Fin2 (succ n)
e : succ n + m = succ (n + m)
k : ℕ
b : α
t : Vector3 α k
IH : ∀ (x : succ n + k = succ (n + k)), insert a (t +-+ v) (Eq.recOn x (add i k)) = Eq.recOn x (t +-+ insert a v i)
x✝ : succ n + succ k = succ (n + succ k)
e' : succ n + k = succ (n + k)
⊢ (b :: Eq.recOn e' (t +-+ insert a v i)) = (_ : succ (succ n + k) = succ (succ (n + k))) ▸ b :: t +-+ insert a v i

Next tactic:
exact Eq.recOn e' rfl
theorem exists_vector_zero (f : Vector3 α 0 → Prop) : Exists f ↔ f [] :=
  ⟨fun ⟨v, fv⟩ => by 

Proof state:
α : Type u_1
m n : ℕ
f : Vector3 α 0 → Prop
x✝ : Exists f
v : Vector3 α 0
fv : f v
⊢ f []

Next tactic:
rw [← eq_nil v]
theorem exists_vector_zero (f : Vector3 α 0 → Prop) : Exists f ↔ f [] :=
  ⟨fun ⟨v, fv⟩ => by rw [← eq_nil v]; 

Proof state:
α : Type u_1
m n : ℕ
f : Vector3 α 0 → Prop
x✝ : Exists f
v : Vector3 α 0
fv : f v
⊢ f v

Next tactic:
exact fv
theorem exists_vector_succ (f : Vector3 α (succ n) → Prop) : Exists f ↔ ∃ x v, f (x :: v) :=
  ⟨fun ⟨v, fv⟩ => ⟨_, _, by 

Proof state:
α : Type u_1
m n : ℕ
f : Vector3 α (succ n) → Prop
x✝ : Exists f
v : Vector3 α (succ n)
fv : f v
⊢ f (?m.40464 f x✝ v fv :: ?m.40465 f x✝ v fv)

Next tactic:
rw [cons_head_tail v]
theorem exists_vector_succ (f : Vector3 α (succ n) → Prop) : Exists f ↔ ∃ x v, f (x :: v) :=
  ⟨fun ⟨v, fv⟩ => ⟨_, _, by rw [cons_head_tail v]; 

Proof state:
α : Type u_1
m n : ℕ
f : Vector3 α (succ n) → Prop
x✝ : Exists f
v : Vector3 α (succ n)
fv : f v
⊢ f v

Next tactic:
exact fv
theorem vectorAllP_iff_forall (p : α → Prop) (v : Vector3 α n) :
    VectorAllP p v ↔ ∀ i, p (v i) := by
  

Proof state:
α : Type u_1
m n : ℕ
p : α → Prop
v : Vector3 α n
⊢ VectorAllP p v ↔ ∀ (i : Fin2 n), p (v i)

Next tactic:
refine' v.recOn _ _
theorem vectorAllP_iff_forall (p : α → Prop) (v : Vector3 α n) :
    VectorAllP p v ↔ ∀ i, p (v i) := by
  refine' v.recOn _ _
  · 

Proof state:
case refine'_1
α : Type u_1
m n : ℕ
p : α → Prop
v : Vector3 α n
⊢ VectorAllP p [] ↔ ∀ (i : Fin2 0), p []

Next tactic:
exact ⟨fun _ => Fin2.elim0, fun _ => trivial⟩
theorem vectorAllP_iff_forall (p : α → Prop) (v : Vector3 α n) :
    VectorAllP p v ↔ ∀ i, p (v i) := by
  refine' v.recOn _ _
  · exact ⟨fun _ => Fin2.elim0, fun _ => trivial⟩
  · 

Proof state:
case refine'_2
α : Type u_1
m n : ℕ
p : α → Prop
v : Vector3 α n
⊢ ∀ {n : ℕ} (a : α) (w : Vector3 α n),
    (VectorAllP p w ↔ ∀ (i : Fin2 n), p (w i)) → (VectorAllP p (a :: w) ↔ ∀ (i : Fin2 (succ n)), p ((a :: w) i))

Next tactic:
simp only [vectorAllP_cons]
theorem vectorAllP_iff_forall (p : α → Prop) (v : Vector3 α n) :
    VectorAllP p v ↔ ∀ i, p (v i) := by
  refine' v.recOn _ _
  · exact ⟨fun _ => Fin2.elim0, fun _ => trivial⟩
  · simp only [vectorAllP_cons]
    

Proof state:
case refine'_2
α : Type u_1
m n : ℕ
p : α → Prop
v : Vector3 α n
⊢ ∀ {n : ℕ} (a : α) (w : Vector3 α n),
    (VectorAllP p w ↔ ∀ (i : Fin2 n), p (w i)) → (p a ∧ VectorAllP p w ↔ ∀ (i : Fin2 (succ n)), p ((a :: w) i))

Next tactic:
refine' fun {n} a v IH =>
      (and_congr_right fun _ => IH).trans
        ⟨fun ⟨pa, h⟩ i => by
          refine' i.cases' _ _
          exacts [pa, h], fun h => ⟨_, fun i => _⟩⟩
theorem vectorAllP_iff_forall (p : α → Prop) (v : Vector3 α n) :
    VectorAllP p v ↔ ∀ i, p (v i) := by
  refine' v.recOn _ _
  · exact ⟨fun _ => Fin2.elim0, fun _ => trivial⟩
  · simp only [vectorAllP_cons]
    refine' fun {n} a v IH =>
      (and_congr_right fun _ => IH).trans
        ⟨fun ⟨pa, h⟩ i => by
          

Proof state:
α : Type u_1
m n✝ : ℕ
p : α → Prop
v✝ : Vector3 α n✝
n : ℕ
a : α
v : Vector3 α n
IH : VectorAllP p v ↔ ∀ (i : Fin2 n), p (v i)
x✝ : p a ∧ ∀ (i : Fin2 n), p (v i)
i : Fin2 (succ n)
pa : p a
h : ∀ (i : Fin2 n), p (v i)
⊢ p ((a :: v) i)

Next tactic:
refine' i.cases' _ _