l3lab/ntp-mathlib huggingface dataset:
/-- **Mazur-Ulam Theorem**: if `f` is an isometric bijection between two normed vector spaces
over `ℝ`, then `x ↦ f x - f 0` is a linear isometry equivalence. -/
def toRealLinearIsometryEquiv (f : E ≃ᵢ F) : E ≃ₗᵢ[ℝ] F :=
  (f.trans (IsometryEquiv.addRight (f 0)).symm).toRealLinearIsometryEquivOfMapZero
    (by 

Proof state:
E : Type u_1
PE : Type u_2
F : Type u_3
PF : Type u_4
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : NormedSpace ℝ E
inst✝⁵ : MetricSpace PE
inst✝⁴ : NormedAddTorsor E PE
inst✝³ : NormedAddCommGroup F
inst✝² : NormedSpace ℝ F
inst✝¹ : MetricSpace PF
inst✝ : NormedAddTorsor F PF
f : E ≃ᵢ F
⊢ (IsometryEquiv.trans f (IsometryEquiv.symm (addRight (f 0)))) 0 = 0

Next tactic:
simpa only [sub_eq_add_neg] using sub_self (f 0)
/-- **Mazur-Ulam Theorem**: if `f` is an isometric bijection between two normed add-torsors over
normed vector spaces over `ℝ`, then `f` is an affine isometry equivalence. -/
def toRealAffineIsometryEquiv (f : PE ≃ᵢ PF) : PE ≃ᵃⁱ[ℝ] PF :=
  AffineIsometryEquiv.mk' f
    ((vaddConst (Classical.arbitrary PE)).trans <|
        f.trans (vaddConst (f <| Classical.arbitrary PE)).symm).toRealLinearIsometryEquiv
    (Classical.arbitrary PE) fun p => by 

Proof state:
E : Type u_1
PE : Type u_2
F : Type u_3
PF : Type u_4
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : NormedSpace ℝ E
inst✝⁵ : MetricSpace PE
inst✝⁴ : NormedAddTorsor E PE
inst✝³ : NormedAddCommGroup F
inst✝² : NormedSpace ℝ F
inst✝¹ : MetricSpace PF
inst✝ : NormedAddTorsor F PF
f : PE ≃ᵢ PF
p : PE
⊢ f p =
    (toRealLinearIsometryEquiv
          (IsometryEquiv.trans (vaddConst (Classical.arbitrary PE))
            (IsometryEquiv.trans f (IsometryEquiv.symm (vaddConst (f (Classical.arbitrary PE)))))))
        (p -ᵥ Classical.arbitrary PE) +ᵥ
      f (Classical.arbitrary PE)

Next tactic:
simp
@[simp]
theorem coe_toRealAffineIsometryEquiv (f : PE ≃ᵢ PF) :
    f.toRealAffineIsometryEquiv.toIsometryEquiv = f := by
  

Proof state:
E : Type u_1
PE : Type u_2
F : Type u_3
PF : Type u_4
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : NormedSpace ℝ E
inst✝⁵ : MetricSpace PE
inst✝⁴ : NormedAddTorsor E PE
inst✝³ : NormedAddCommGroup F
inst✝² : NormedSpace ℝ F
inst✝¹ : MetricSpace PF
inst✝ : NormedAddTorsor F PF
f : PE ≃ᵢ PF
⊢ toIsometryEquiv (toRealAffineIsometryEquiv f) = f

Next tactic:
ext
@[simp]
theorem coe_toRealAffineIsometryEquiv (f : PE ≃ᵢ PF) :
    f.toRealAffineIsometryEquiv.toIsometryEquiv = f := by
  ext
  

Proof state:
case H
E : Type u_1
PE : Type u_2
F : Type u_3
PF : Type u_4
inst✝⁷ : NormedAddCommGroup E
inst✝⁶ : NormedSpace ℝ E
inst✝⁵ : MetricSpace PE
inst✝⁴ : NormedAddTorsor E PE
inst✝³ : NormedAddCommGroup F
inst✝² : NormedSpace ℝ F
inst✝¹ : MetricSpace PF
inst✝ : NormedAddTorsor F PF
f : PE ≃ᵢ PF
x✝ : PE
⊢ (toIsometryEquiv (toRealAffineIsometryEquiv f)) x✝ = f x✝

Next tactic:
rfl
@[simp]
theorem cons_val_succ (x : α) (u : Fin m → α) (i : Fin m) : vecCons x u i.succ = u i := by
  

Proof state:
α : Type u
m n o : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
x : α
u : Fin m → α
i : Fin m
⊢ vecCons x u (Fin.succ i) = u i

Next tactic:
simp [vecCons]
@[simp]
theorem cons_val_succ' {i : ℕ} (h : i.succ < m.succ) (x : α) (u : Fin m → α) :
    vecCons x u ⟨i.succ, h⟩ = u ⟨i, Nat.lt_of_succ_lt_succ h⟩ := by
  

Proof state:
α : Type u
m n o : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
i : ℕ
h : Nat.succ i < Nat.succ m
x : α
u : Fin m → α
⊢ vecCons x u { val := Nat.succ i, isLt := h } = u { val := i, isLt := (_ : i < m) }

Next tactic:
simp only [vecCons, Fin.cons, Fin.cases_succ']
@[simp]
theorem tail_cons (x : α) (u : Fin m → α) : vecTail (vecCons x u) = u := by
  

Proof state:
α : Type u
m n o : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
x : α
u : Fin m → α
⊢ vecTail (vecCons x u) = u

Next tactic:
ext
@[simp]
theorem tail_cons (x : α) (u : Fin m → α) : vecTail (vecCons x u) = u := by
  ext
  

Proof state:
case h
α : Type u
m n o : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
x : α
u : Fin m → α
x✝ : Fin m
⊢ vecTail (vecCons x u) x✝ = u x✝

Next tactic:
simp [vecTail]
@[simp]
theorem range_cons (x : α) (u : Fin n → α) : Set.range (vecCons x u) = {x} ∪ Set.range u :=
  Set.ext fun y => by 

Proof state:
α : Type u
m n o : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
x : α
u : Fin n → α
y : α
⊢ y ∈ Set.range (vecCons x u) ↔ y ∈ {x} ∪ Set.range u

Next tactic:
simp [Fin.exists_fin_succ, eq_comm]
theorem range_cons_empty (x : α) (u : Fin 0 → α) : Set.range (Matrix.vecCons x u) = {x} := by
  

Proof state:
α : Type u
m n o : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
x : α
u : Fin 0 → α
⊢ Set.range (vecCons x u) = {x}

Next tactic:
rw [range_cons, range_empty, Set.union_empty]
theorem range_cons_cons_empty (x y : α) (u : Fin 0 → α) :
    Set.range (vecCons x <| vecCons y u) = {x, y} := by
  

Proof state:
α : Type u
m n o : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
x y : α
u : Fin 0 → α
⊢ Set.range (vecCons x (vecCons y u)) = {x, y}

Next tactic:
rw [range_cons, range_cons_empty, Set.singleton_union]
@[simp]
theorem cons_val_fin_one (x : α) (u : Fin 0 → α) : ∀ (i : Fin 1), vecCons x u i = x := by
  

Proof state:
α : Type u
m n o : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
x : α
u : Fin 0 → α
⊢ ∀ (i : Fin 1), vecCons x u i = x

Next tactic:
rw [Fin.forall_fin_one]
@[simp]
theorem cons_val_fin_one (x : α) (u : Fin 0 → α) : ∀ (i : Fin 1), vecCons x u i = x := by
  rw [Fin.forall_fin_one]
  

Proof state:
α : Type u
m n o : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
x : α
u : Fin 0 → α
⊢ vecCons x u 0 = x

Next tactic:
rfl
theorem vecAppend_eq_ite {α : Type*} {o : ℕ} (ho : o = m + n) (u : Fin m → α) (v : Fin n → α) :
    vecAppend ho u v = fun i : Fin o =>
      if h : (i : ℕ) < m then u ⟨i, h⟩
      else v ⟨(i : ℕ) - m, (tsub_lt_iff_left (le_of_not_lt h)).2 (ho ▸ i.2)⟩ := by
  

Proof state:
α✝ : Type u
m n o✝ : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
α : Type u_4
o : ℕ
ho : o = m + n
u : Fin m → α
v : Fin n → α
⊢ vecAppend ho u v = fun i =>
    if h : ↑i < m then u { val := ↑i, isLt := h } else v { val := ↑i - m, isLt := (_ : ↑i - m < n) }

Next tactic:
ext i
theorem vecAppend_eq_ite {α : Type*} {o : ℕ} (ho : o = m + n) (u : Fin m → α) (v : Fin n → α) :
    vecAppend ho u v = fun i : Fin o =>
      if h : (i : ℕ) < m then u ⟨i, h⟩
      else v ⟨(i : ℕ) - m, (tsub_lt_iff_left (le_of_not_lt h)).2 (ho ▸ i.2)⟩ := by
  ext i
  

Proof state:
case h
α✝ : Type u
m n o✝ : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
α : Type u_4
o : ℕ
ho : o = m + n
u : Fin m → α
v : Fin n → α
i : Fin o
⊢ vecAppend ho u v i = if h : ↑i < m then u { val := ↑i, isLt := h } else v { val := ↑i - m, isLt := (_ : ↑i - m < n) }

Next tactic:
rw [vecAppend, Fin.append, Function.comp_apply, Fin.addCases]
theorem vecAppend_eq_ite {α : Type*} {o : ℕ} (ho : o = m + n) (u : Fin m → α) (v : Fin n → α) :
    vecAppend ho u v = fun i : Fin o =>
      if h : (i : ℕ) < m then u ⟨i, h⟩
      else v ⟨(i : ℕ) - m, (tsub_lt_iff_left (le_of_not_lt h)).2 (ho ▸ i.2)⟩ := by
  ext i
  rw [vecAppend, Fin.append, Function.comp_apply, Fin.addCases]
  

Proof state:
case h
α✝ : Type u
m n o✝ : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
α : Type u_4
o : ℕ
ho : o = m + n
u : Fin m → α
v : Fin n → α
i : Fin o
⊢ (if hi : ↑(Fin.cast ho i) < m then
      (_ : Fin.castAdd n (Fin.castLT (Fin.cast ho i) hi) = Fin.cast ho i) ▸ u (Fin.castLT (Fin.cast ho i) hi)
    else
      (_ :
          Fin.natAdd m (Fin.subNat m (Fin.cast (_ : m + n = n + m) (Fin.cast ho i)) (_ : m ≤ ↑(Fin.cast ho i))) =
            Fin.cast ho i) ▸
        v (Fin.subNat m (Fin.cast (_ : m + n = n + m) (Fin.cast ho i)) (_ : m ≤ ↑(Fin.cast ho i)))) =
    if h : ↑i < m then u { val := ↑i, isLt := h } else v { val := ↑i - m, isLt := (_ : ↑i - m < n) }

Next tactic:
congr with hi
theorem vecAppend_eq_ite {α : Type*} {o : ℕ} (ho : o = m + n) (u : Fin m → α) (v : Fin n → α) :
    vecAppend ho u v = fun i : Fin o =>
      if h : (i : ℕ) < m then u ⟨i, h⟩
      else v ⟨(i : ℕ) - m, (tsub_lt_iff_left (le_of_not_lt h)).2 (ho ▸ i.2)⟩ := by
  ext i
  rw [vecAppend, Fin.append, Function.comp_apply, Fin.addCases]
  congr with hi
  

Proof state:
case h.e_e.h
α✝ : Type u
m n o✝ : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
α : Type u_4
o : ℕ
ho : o = m + n
u : Fin m → α
v : Fin n → α
i : Fin o
hi : ¬↑(Fin.cast ho i) < m
⊢ (_ :
        Fin.natAdd m (Fin.subNat m (Fin.cast (_ : m + n = n + m) (Fin.cast ho i)) (_ : m ≤ ↑(Fin.cast ho i))) =
          Fin.cast ho i) ▸
      v (Fin.subNat m (Fin.cast (_ : m + n = n + m) (Fin.cast ho i)) (_ : m ≤ ↑(Fin.cast ho i))) =
    v { val := ↑i - m, isLt := (_ : ↑i - m < n) }

Next tactic:
simp only [eq_rec_constant]
theorem vecAppend_eq_ite {α : Type*} {o : ℕ} (ho : o = m + n) (u : Fin m → α) (v : Fin n → α) :
    vecAppend ho u v = fun i : Fin o =>
      if h : (i : ℕ) < m then u ⟨i, h⟩
      else v ⟨(i : ℕ) - m, (tsub_lt_iff_left (le_of_not_lt h)).2 (ho ▸ i.2)⟩ := by
  ext i
  rw [vecAppend, Fin.append, Function.comp_apply, Fin.addCases]
  congr with hi
  simp only [eq_rec_constant]
  

Proof state:
case h.e_e.h
α✝ : Type u
m n o✝ : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
α : Type u_4
o : ℕ
ho : o = m + n
u : Fin m → α
v : Fin n → α
i : Fin o
hi : ¬↑(Fin.cast ho i) < m
⊢ v (Fin.subNat m (Fin.cast (_ : m + n = n + m) (Fin.cast ho i)) (_ : m ≤ ↑(Fin.cast ho i))) =
    v { val := ↑i - m, isLt := (_ : ↑i - m < n) }

Next tactic:
rfl
@[simp]
theorem empty_vecAppend (v : Fin n → α) : vecAppend (zero_add _).symm ![] v = v := by
  

Proof state:
α : Type u
m n o : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
v : Fin n → α
⊢ vecAppend (_ : n = 0 + n) ![] v = v

Next tactic:
ext
@[simp]
theorem empty_vecAppend (v : Fin n → α) : vecAppend (zero_add _).symm ![] v = v := by
  ext
  

Proof state:
case h
α : Type u
m n o : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
v : Fin n → α
x✝ : Fin n
⊢ vecAppend (_ : n = 0 + n) ![] v x✝ = v x✝

Next tactic:
simp [vecAppend_eq_ite]
@[simp]
theorem cons_vecAppend (ho : o + 1 = m + 1 + n) (x : α) (u : Fin m → α) (v : Fin n → α) :
    vecAppend ho (vecCons x u) v = vecCons x (vecAppend (by
      

Proof state:
α : Type u
m n o : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
ho : o + 1 = m + 1 + n
x : α
u : Fin m → α
v : Fin n → α
⊢ o = m + n

Next tactic:
rwa [add_assoc, add_comm 1, ← add_assoc, add_right_cancel_iff] at ho
@[simp]
theorem cons_vecAppend (ho : o + 1 = m + 1 + n) (x : α) (u : Fin m → α) (v : Fin n → α) :
    vecAppend ho (vecCons x u) v = vecCons x (vecAppend (by
      rwa [add_assoc, add_comm 1, ← add_assoc, add_right_cancel_iff] at ho) u v) := by
  

Proof state:
α : Type u
m n o : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
ho : o + 1 = m + 1 + n
x : α
u : Fin m → α
v : Fin n → α
⊢ vecAppend ho (vecCons x u) v = vecCons x (vecAppend (_ : o = m + n) u v)

Next tactic:
ext i
@[simp]
theorem cons_vecAppend (ho : o + 1 = m + 1 + n) (x : α) (u : Fin m → α) (v : Fin n → α) :
    vecAppend ho (vecCons x u) v = vecCons x (vecAppend (by
      rwa [add_assoc, add_comm 1, ← add_assoc, add_right_cancel_iff] at ho) u v) := by
  ext i
  

Proof state:
case h
α : Type u
m n o : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
ho : o + 1 = m + 1 + n
x : α
u : Fin m → α
v : Fin n → α
i : Fin (o + 1)
⊢ vecAppend ho (vecCons x u) v i = vecCons x (vecAppend (_ : o = m + n) u v) i

Next tactic:
simp_rw [vecAppend_eq_ite]
@[simp]
theorem cons_vecAppend (ho : o + 1 = m + 1 + n) (x : α) (u : Fin m → α) (v : Fin n → α) :
    vecAppend ho (vecCons x u) v = vecCons x (vecAppend (by
      rwa [add_assoc, add_comm 1, ← add_assoc, add_right_cancel_iff] at ho) u v) := by
  ext i
  simp_rw [vecAppend_eq_ite]
  

Proof state:
case h
α : Type u
m n o : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
ho : o + 1 = m + 1 + n
x : α
u : Fin m → α
v : Fin n → α
i : Fin (o + 1)
⊢ (if h : ↑i < m + 1 then vecCons x u { val := ↑i, isLt := h }
    else v { val := ↑i - (m + 1), isLt := (_ : ↑i - (m + 1) < n) }) =
    vecCons x
      (fun i => if h : ↑i < m then u { val := ↑i, isLt := h } else v { val := ↑i - m, isLt := (_ : ↑i - m < n) }) i

Next tactic:
split_ifs with h
@[simp]
theorem cons_vecAppend (ho : o + 1 = m + 1 + n) (x : α) (u : Fin m → α) (v : Fin n → α) :
    vecAppend ho (vecCons x u) v = vecCons x (vecAppend (by
      rwa [add_assoc, add_comm 1, ← add_assoc, add_right_cancel_iff] at ho) u v) := by
  ext i
  simp_rw [vecAppend_eq_ite]
  split_ifs with h
  · 

Proof state:
case pos
α : Type u
m n o : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
ho : o + 1 = m + 1 + n
x : α
u : Fin m → α
v : Fin n → α
i : Fin (o + 1)
h : ↑i < m + 1
⊢ vecCons x u { val := ↑i, isLt := h } =
    vecCons x
      (fun i => if h : ↑i < m then u { val := ↑i, isLt := h } else v { val := ↑i - m, isLt := (_ : ↑i - m < n) }) i

Next tactic:
rcases i with ⟨⟨⟩ | i, hi⟩
@[simp]
theorem cons_vecAppend (ho : o + 1 = m + 1 + n) (x : α) (u : Fin m → α) (v : Fin n → α) :
    vecAppend ho (vecCons x u) v = vecCons x (vecAppend (by
      rwa [add_assoc, add_comm 1, ← add_assoc, add_right_cancel_iff] at ho) u v) := by
  ext i
  simp_rw [vecAppend_eq_ite]
  split_ifs with h
  · rcases i with ⟨⟨⟩ | i, hi⟩
    · 

Proof state:
case pos.mk.zero
α : Type u
m n o : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
ho : o + 1 = m + 1 + n
x : α
u : Fin m → α
v : Fin n → α
hi : Nat.zero < o + 1
h : ↑{ val := Nat.zero, isLt := hi } < m + 1
⊢ vecCons x u { val := ↑{ val := Nat.zero, isLt := hi }, isLt := h } =
    vecCons x
      (fun i => if h : ↑i < m then u { val := ↑i, isLt := h } else v { val := ↑i - m, isLt := (_ : ↑i - m < n) })
      { val := Nat.zero, isLt := hi }

Next tactic:
simp
@[simp]
theorem cons_vecAppend (ho : o + 1 = m + 1 + n) (x : α) (u : Fin m → α) (v : Fin n → α) :
    vecAppend ho (vecCons x u) v = vecCons x (vecAppend (by
      rwa [add_assoc, add_comm 1, ← add_assoc, add_right_cancel_iff] at ho) u v) := by
  ext i
  simp_rw [vecAppend_eq_ite]
  split_ifs with h
  · rcases i with ⟨⟨⟩ | i, hi⟩
    · simp
    · 

Proof state:
case pos.mk.succ
α : Type u
m n o : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
ho : o + 1 = m + 1 + n
x : α
u : Fin m → α
v : Fin n → α
i : ℕ
hi : Nat.succ i < o + 1
h : ↑{ val := Nat.succ i, isLt := hi } < m + 1
⊢ vecCons x u { val := ↑{ val := Nat.succ i, isLt := hi }, isLt := h } =
    vecCons x
      (fun i => if h : ↑i < m then u { val := ↑i, isLt := h } else v { val := ↑i - m, isLt := (_ : ↑i - m < n) })
      { val := Nat.succ i, isLt := hi }

Next tactic:
simp only [Nat.succ_eq_add_one, add_lt_add_iff_right, Fin.val_mk] at h
@[simp]
theorem cons_vecAppend (ho : o + 1 = m + 1 + n) (x : α) (u : Fin m → α) (v : Fin n → α) :
    vecAppend ho (vecCons x u) v = vecCons x (vecAppend (by
      rwa [add_assoc, add_comm 1, ← add_assoc, add_right_cancel_iff] at ho) u v) := by
  ext i
  simp_rw [vecAppend_eq_ite]
  split_ifs with h
  · rcases i with ⟨⟨⟩ | i, hi⟩
    · simp
    · simp only [Nat.succ_eq_add_one, add_lt_add_iff_right, Fin.val_mk] at h
      

Proof state:
case pos.mk.succ
α : Type u
m n o : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
ho : o + 1 = m + 1 + n
x : α
u : Fin m → α
v : Fin n → α
i : ℕ
hi : Nat.succ i < o + 1
h✝ : ↑{ val := Nat.succ i, isLt := hi } < m + 1
h : i < m
⊢ vecCons x u { val := ↑{ val := Nat.succ i, isLt := hi }, isLt := h✝ } =
    vecCons x
      (fun i => if h : ↑i < m then u { val := ↑i, isLt := h } else v { val := ↑i - m, isLt := (_ : ↑i - m < n) })
      { val := Nat.succ i, isLt := hi }

Next tactic:
simp [h]
@[simp]
theorem cons_vecAppend (ho : o + 1 = m + 1 + n) (x : α) (u : Fin m → α) (v : Fin n → α) :
    vecAppend ho (vecCons x u) v = vecCons x (vecAppend (by
      rwa [add_assoc, add_comm 1, ← add_assoc, add_right_cancel_iff] at ho) u v) := by
  ext i
  simp_rw [vecAppend_eq_ite]
  split_ifs with h
  · rcases i with ⟨⟨⟩ | i, hi⟩
    · simp
    · simp only [Nat.succ_eq_add_one, add_lt_add_iff_right, Fin.val_mk] at h
      simp [h]
  · 

Proof state:
case neg
α : Type u
m n o : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
ho : o + 1 = m + 1 + n
x : α
u : Fin m → α
v : Fin n → α
i : Fin (o + 1)
h : ¬↑i < m + 1
⊢ v { val := ↑i - (m + 1), isLt := (_ : ↑i - (m + 1) < n) } =
    vecCons x
      (fun i => if h : ↑i < m then u { val := ↑i, isLt := h } else v { val := ↑i - m, isLt := (_ : ↑i - m < n) }) i

Next tactic:
rcases i with ⟨⟨⟩ | i, hi⟩
@[simp]
theorem cons_vecAppend (ho : o + 1 = m + 1 + n) (x : α) (u : Fin m → α) (v : Fin n → α) :
    vecAppend ho (vecCons x u) v = vecCons x (vecAppend (by
      rwa [add_assoc, add_comm 1, ← add_assoc, add_right_cancel_iff] at ho) u v) := by
  ext i
  simp_rw [vecAppend_eq_ite]
  split_ifs with h
  · rcases i with ⟨⟨⟩ | i, hi⟩
    · simp
    · simp only [Nat.succ_eq_add_one, add_lt_add_iff_right, Fin.val_mk] at h
      simp [h]
  · rcases i with ⟨⟨⟩ | i, hi⟩
    · 

Proof state:
case neg.mk.zero
α : Type u
m n o : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
ho : o + 1 = m + 1 + n
x : α
u : Fin m → α
v : Fin n → α
hi : Nat.zero < o + 1
h : ¬↑{ val := Nat.zero, isLt := hi } < m + 1
⊢ v
      { val := ↑{ val := Nat.zero, isLt := hi } - (m + 1),
        isLt := (_ : ↑{ val := Nat.zero, isLt := hi } - (m + 1) < n) } =
    vecCons x
      (fun i => if h : ↑i < m then u { val := ↑i, isLt := h } else v { val := ↑i - m, isLt := (_ : ↑i - m < n) })
      { val := Nat.zero, isLt := hi }

Next tactic:
simp at h
@[simp]
theorem cons_vecAppend (ho : o + 1 = m + 1 + n) (x : α) (u : Fin m → α) (v : Fin n → α) :
    vecAppend ho (vecCons x u) v = vecCons x (vecAppend (by
      rwa [add_assoc, add_comm 1, ← add_assoc, add_right_cancel_iff] at ho) u v) := by
  ext i
  simp_rw [vecAppend_eq_ite]
  split_ifs with h
  · rcases i with ⟨⟨⟩ | i, hi⟩
    · simp
    · simp only [Nat.succ_eq_add_one, add_lt_add_iff_right, Fin.val_mk] at h
      simp [h]
  · rcases i with ⟨⟨⟩ | i, hi⟩
    · simp at h
    · 

Proof state:
case neg.mk.succ
α : Type u
m n o : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
ho : o + 1 = m + 1 + n
x : α
u : Fin m → α
v : Fin n → α
i : ℕ
hi : Nat.succ i < o + 1
h : ¬↑{ val := Nat.succ i, isLt := hi } < m + 1
⊢ v
      { val := ↑{ val := Nat.succ i, isLt := hi } - (m + 1),
        isLt := (_ : ↑{ val := Nat.succ i, isLt := hi } - (m + 1) < n) } =
    vecCons x
      (fun i => if h : ↑i < m then u { val := ↑i, isLt := h } else v { val := ↑i - m, isLt := (_ : ↑i - m < n) })
      { val := Nat.succ i, isLt := hi }

Next tactic:
rw [not_lt, Fin.val_mk, Nat.succ_eq_add_one, add_le_add_iff_right] at h
@[simp]
theorem cons_vecAppend (ho : o + 1 = m + 1 + n) (x : α) (u : Fin m → α) (v : Fin n → α) :
    vecAppend ho (vecCons x u) v = vecCons x (vecAppend (by
      rwa [add_assoc, add_comm 1, ← add_assoc, add_right_cancel_iff] at ho) u v) := by
  ext i
  simp_rw [vecAppend_eq_ite]
  split_ifs with h
  · rcases i with ⟨⟨⟩ | i, hi⟩
    · simp
    · simp only [Nat.succ_eq_add_one, add_lt_add_iff_right, Fin.val_mk] at h
      simp [h]
  · rcases i with ⟨⟨⟩ | i, hi⟩
    · simp at h
    · rw [not_lt, Fin.val_mk, Nat.succ_eq_add_one, add_le_add_iff_right] at h
      

Proof state:
case neg.mk.succ
α : Type u
m n o : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
ho : o + 1 = m + 1 + n
x : α
u : Fin m → α
v : Fin n → α
i : ℕ
hi : Nat.succ i < o + 1
h✝ : ¬↑{ val := Nat.succ i, isLt := hi } < m + 1
h : m ≤ i
⊢ v
      { val := ↑{ val := Nat.succ i, isLt := hi } - (m + 1),
        isLt := (_ : ↑{ val := Nat.succ i, isLt := hi } - (m + 1) < n) } =
    vecCons x
      (fun i => if h : ↑i < m then u { val := ↑i, isLt := h } else v { val := ↑i - m, isLt := (_ : ↑i - m < n) })
      { val := Nat.succ i, isLt := hi }

Next tactic:
simp [h, not_lt.2 h]
theorem vecAlt0_vecAppend (v : Fin n → α) : vecAlt0 rfl (vecAppend rfl v v) = v ∘ bit0 := by
  

Proof state:
α : Type u
m n o : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
v : Fin n → α
⊢ vecAlt0 (_ : n + n = n + n) (vecAppend (_ : n + n = n + n) v v) = v ∘ bit0

Next tactic:
ext i
theorem vecAlt0_vecAppend (v : Fin n → α) : vecAlt0 rfl (vecAppend rfl v v) = v ∘ bit0 := by
  ext i
  

Proof state:
case h
α : Type u
m n o : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
v : Fin n → α
i : Fin n
⊢ vecAlt0 (_ : n + n = n + n) (vecAppend (_ : n + n = n + n) v v) i = (v ∘ bit0) i

Next tactic:
simp_rw [Function.comp, bit0, vecAlt0, vecAppend_eq_ite]
theorem vecAlt0_vecAppend (v : Fin n → α) : vecAlt0 rfl (vecAppend rfl v v) = v ∘ bit0 := by
  ext i
  simp_rw [Function.comp, bit0, vecAlt0, vecAppend_eq_ite]
  

Proof state:
case h
α : Type u
m n o : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
v : Fin n → α
i : Fin n
⊢ (if h : ↑i + ↑i < n then v { val := ↑i + ↑i, isLt := (_ : ↑{ val := ↑i + ↑i, isLt := (_ : ↑i + ↑i < n + n) } < n) }
    else v { val := ↑i + ↑i - n, isLt := (_ : ↑{ val := ↑i + ↑i, isLt := (_ : ↑i + ↑i < n + n) } - n < n) }) =
    v (i + i)

Next tactic:
split_ifs with h
theorem vecAlt0_vecAppend (v : Fin n → α) : vecAlt0 rfl (vecAppend rfl v v) = v ∘ bit0 := by
  ext i
  simp_rw [Function.comp, bit0, vecAlt0, vecAppend_eq_ite]
  split_ifs with h <;> 

Proof state:
case pos
α : Type u
m n o : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
v : Fin n → α
i : Fin n
h : ↑i + ↑i < n
⊢ v { val := ↑i + ↑i, isLt := (_ : ↑{ val := ↑i + ↑i, isLt := (_ : ↑i + ↑i < n + n) } < n) } = v (i + i)

Next tactic:
congr
theorem vecAlt0_vecAppend (v : Fin n → α) : vecAlt0 rfl (vecAppend rfl v v) = v ∘ bit0 := by
  ext i
  simp_rw [Function.comp, bit0, vecAlt0, vecAppend_eq_ite]
  split_ifs with h <;> 

Proof state:
case neg
α : Type u
m n o : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
v : Fin n → α
i : Fin n
h : ¬↑i + ↑i < n
⊢ v { val := ↑i + ↑i - n, isLt := (_ : ↑{ val := ↑i + ↑i, isLt := (_ : ↑i + ↑i < n + n) } - n < n) } = v (i + i)

Next tactic:
congr
theorem vecAlt0_vecAppend (v : Fin n → α) : vecAlt0 rfl (vecAppend rfl v v) = v ∘ bit0 := by
  ext i
  simp_rw [Function.comp, bit0, vecAlt0, vecAppend_eq_ite]
  split_ifs with h <;> congr
  · 

Proof state:
case pos.e_a.e_val
α : Type u
m n o : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
v : Fin n → α
i : Fin n
h : ↑i + ↑i < n
⊢ ↑i + ↑i = (↑i + ↑i) % n

Next tactic:
rw [Fin.val_mk] at h
theorem vecAlt0_vecAppend (v : Fin n → α) : vecAlt0 rfl (vecAppend rfl v v) = v ∘ bit0 := by
  ext i
  simp_rw [Function.comp, bit0, vecAlt0, vecAppend_eq_ite]
  split_ifs with h <;> congr
  · rw [Fin.val_mk] at h
    

Proof state:
case pos.e_a.e_val
α : Type u
m n o : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
v : Fin n → α
i : Fin n
h : ↑i + ↑i < n
⊢ ↑i + ↑i = (↑i + ↑i) % n

Next tactic:
exact (Nat.mod_eq_of_lt h).symm
theorem vecAlt0_vecAppend (v : Fin n → α) : vecAlt0 rfl (vecAppend rfl v v) = v ∘ bit0 := by
  ext i
  simp_rw [Function.comp, bit0, vecAlt0, vecAppend_eq_ite]
  split_ifs with h <;> congr
  · rw [Fin.val_mk] at h
    exact (Nat.mod_eq_of_lt h).symm
  · 

Proof state:
case neg.e_a.e_val
α : Type u
m n o : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
v : Fin n → α
i : Fin n
h : ¬↑i + ↑i < n
⊢ ↑i + ↑i - n = (↑i + ↑i) % n

Next tactic:
rw [Fin.val_mk, not_lt] at h
theorem vecAlt0_vecAppend (v : Fin n → α) : vecAlt0 rfl (vecAppend rfl v v) = v ∘ bit0 := by
  ext i
  simp_rw [Function.comp, bit0, vecAlt0, vecAppend_eq_ite]
  split_ifs with h <;> congr
  · rw [Fin.val_mk] at h
    exact (Nat.mod_eq_of_lt h).symm
  · rw [Fin.val_mk, not_lt] at h
    

Proof state:
case neg.e_a.e_val
α : Type u
m n o : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
v : Fin n → α
i : Fin n
h : n ≤ ↑i + ↑i
⊢ ↑i + ↑i - n = (↑i + ↑i) % n

Next tactic:
simp only [Fin.ext_iff, Fin.val_add, Fin.val_mk, Nat.mod_eq_sub_mod h]
theorem vecAlt0_vecAppend (v : Fin n → α) : vecAlt0 rfl (vecAppend rfl v v) = v ∘ bit0 := by
  ext i
  simp_rw [Function.comp, bit0, vecAlt0, vecAppend_eq_ite]
  split_ifs with h <;> congr
  · rw [Fin.val_mk] at h
    exact (Nat.mod_eq_of_lt h).symm
  · rw [Fin.val_mk, not_lt] at h
    simp only [Fin.ext_iff, Fin.val_add, Fin.val_mk, Nat.mod_eq_sub_mod h]
    

Proof state:
case neg.e_a.e_val
α : Type u
m n o : ℕ
m' : Type u_1
n' : Type u_2
o' : Type u_3
v : Fin n → α
i : Fin n
h : n ≤ ↑i + ↑i
⊢ ↑i + ↑i - n = (↑i + ↑i - n) % n

Next tactic:
refine' (Nat.mod_eq_of_lt _).symm