l3lab/ntp-mathlib huggingface dataset:
theorem orthonormal_empty : Orthonormal 𝕜 (fun x => x : (∅ : Set E) → E) := by
  classical!
  

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
ι : Type u_4
dec_ι : DecidableEq ι
em✝ : (a : Prop) → Decidable a
⊢ Orthonormal 𝕜 fun x => ↑x

Next tactic:
simp [orthonormal_subtype_iff_ite]
theorem orthonormal_iUnion_of_directed {η : Type*} {s : η → Set E} (hs : Directed (· ⊆ ·) s)
    (h : ∀ i, Orthonormal 𝕜 (fun x => x : s i → E)) :
    Orthonormal 𝕜 (fun x => x : (⋃ i, s i) → E) := by
  

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
ι : Type u_4
dec_ι : DecidableEq ι
η : Type u_5
s : η → Set E
hs : Directed (fun x x_1 => x ⊆ x_1) s
h : ∀ (i : η), Orthonormal 𝕜 fun x => ↑x
⊢ Orthonormal 𝕜 fun x => ↑x

Next tactic:
classical!
theorem orthonormal_iUnion_of_directed {η : Type*} {s : η → Set E} (hs : Directed (· ⊆ ·) s)
    (h : ∀ i, Orthonormal 𝕜 (fun x => x : s i → E)) :
    Orthonormal 𝕜 (fun x => x : (⋃ i, s i) → E) := by
  classical!
  

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
ι : Type u_4
dec_ι : DecidableEq ι
η : Type u_5
s : η → Set E
hs : Directed (fun x x_1 => x ⊆ x_1) s
h : ∀ (i : η), Orthonormal 𝕜 fun x => ↑x
em✝ : (a : Prop) → Decidable a
⊢ Orthonormal 𝕜 fun x => ↑x

Next tactic:
rw [orthonormal_subtype_iff_ite]
theorem orthonormal_iUnion_of_directed {η : Type*} {s : η → Set E} (hs : Directed (· ⊆ ·) s)
    (h : ∀ i, Orthonormal 𝕜 (fun x => x : s i → E)) :
    Orthonormal 𝕜 (fun x => x : (⋃ i, s i) → E) := by
  classical!
  rw [orthonormal_subtype_iff_ite]
  

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
ι : Type u_4
dec_ι : DecidableEq ι
η : Type u_5
s : η → Set E
hs : Directed (fun x x_1 => x ⊆ x_1) s
h : ∀ (i : η), Orthonormal 𝕜 fun x => ↑x
em✝ : (a : Prop) → Decidable a
⊢ ∀ v ∈ ⋃ i, s i, ∀ w ∈ ⋃ i, s i, inner v w = if v = w then 1 else 0

Next tactic:
rintro x ⟨_, ⟨i, rfl⟩, hxi⟩ y ⟨_, ⟨j, rfl⟩, hyj⟩
theorem orthonormal_iUnion_of_directed {η : Type*} {s : η → Set E} (hs : Directed (· ⊆ ·) s)
    (h : ∀ i, Orthonormal 𝕜 (fun x => x : s i → E)) :
    Orthonormal 𝕜 (fun x => x : (⋃ i, s i) → E) := by
  classical!
  rw [orthonormal_subtype_iff_ite]
  rintro x ⟨_, ⟨i, rfl⟩, hxi⟩ y ⟨_, ⟨j, rfl⟩, hyj⟩
  

Proof state:
case intro.intro.intro.intro.intro.intro
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
ι : Type u_4
dec_ι : DecidableEq ι
η : Type u_5
s : η → Set E
hs : Directed (fun x x_1 => x ⊆ x_1) s
h : ∀ (i : η), Orthonormal 𝕜 fun x => ↑x
em✝ : (a : Prop) → Decidable a
x : E
i : η
hxi : x ∈ (fun i => s i) i
y : E
j : η
hyj : y ∈ (fun i => s i) j
⊢ inner x y = if x = y then 1 else 0

Next tactic:
obtain ⟨k, hik, hjk⟩ := hs i j
theorem orthonormal_iUnion_of_directed {η : Type*} {s : η → Set E} (hs : Directed (· ⊆ ·) s)
    (h : ∀ i, Orthonormal 𝕜 (fun x => x : s i → E)) :
    Orthonormal 𝕜 (fun x => x : (⋃ i, s i) → E) := by
  classical!
  rw [orthonormal_subtype_iff_ite]
  rintro x ⟨_, ⟨i, rfl⟩, hxi⟩ y ⟨_, ⟨j, rfl⟩, hyj⟩
  obtain ⟨k, hik, hjk⟩ := hs i j
  

Proof state:
case intro.intro.intro.intro.intro.intro.intro.intro
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
ι : Type u_4
dec_ι : DecidableEq ι
η : Type u_5
s : η → Set E
hs : Directed (fun x x_1 => x ⊆ x_1) s
h : ∀ (i : η), Orthonormal 𝕜 fun x => ↑x
em✝ : (a : Prop) → Decidable a
x : E
i : η
hxi : x ∈ (fun i => s i) i
y : E
j : η
hyj : y ∈ (fun i => s i) j
k : η
hik : s i ⊆ s k
hjk : s j ⊆ s k
⊢ inner x y = if x = y then 1 else 0

Next tactic:
have h_orth : Orthonormal 𝕜 (fun x => x : s k → E) := h k
theorem orthonormal_iUnion_of_directed {η : Type*} {s : η → Set E} (hs : Directed (· ⊆ ·) s)
    (h : ∀ i, Orthonormal 𝕜 (fun x => x : s i → E)) :
    Orthonormal 𝕜 (fun x => x : (⋃ i, s i) → E) := by
  classical!
  rw [orthonormal_subtype_iff_ite]
  rintro x ⟨_, ⟨i, rfl⟩, hxi⟩ y ⟨_, ⟨j, rfl⟩, hyj⟩
  obtain ⟨k, hik, hjk⟩ := hs i j
  have h_orth : Orthonormal 𝕜 (fun x => x : s k → E) := h k
  

Proof state:
case intro.intro.intro.intro.intro.intro.intro.intro
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
ι : Type u_4
dec_ι : DecidableEq ι
η : Type u_5
s : η → Set E
hs : Directed (fun x x_1 => x ⊆ x_1) s
h : ∀ (i : η), Orthonormal 𝕜 fun x => ↑x
em✝ : (a : Prop) → Decidable a
x : E
i : η
hxi : x ∈ (fun i => s i) i
y : E
j : η
hyj : y ∈ (fun i => s i) j
k : η
hik : s i ⊆ s k
hjk : s j ⊆ s k
h_orth : Orthonormal 𝕜 fun x => ↑x
⊢ inner x y = if x = y then 1 else 0

Next tactic:
rw [orthonormal_subtype_iff_ite] at h_orth
theorem orthonormal_iUnion_of_directed {η : Type*} {s : η → Set E} (hs : Directed (· ⊆ ·) s)
    (h : ∀ i, Orthonormal 𝕜 (fun x => x : s i → E)) :
    Orthonormal 𝕜 (fun x => x : (⋃ i, s i) → E) := by
  classical!
  rw [orthonormal_subtype_iff_ite]
  rintro x ⟨_, ⟨i, rfl⟩, hxi⟩ y ⟨_, ⟨j, rfl⟩, hyj⟩
  obtain ⟨k, hik, hjk⟩ := hs i j
  have h_orth : Orthonormal 𝕜 (fun x => x : s k → E) := h k
  rw [orthonormal_subtype_iff_ite] at h_orth
  

Proof state:
case intro.intro.intro.intro.intro.intro.intro.intro
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
ι : Type u_4
dec_ι : DecidableEq ι
η : Type u_5
s : η → Set E
hs : Directed (fun x x_1 => x ⊆ x_1) s
h : ∀ (i : η), Orthonormal 𝕜 fun x => ↑x
em✝ : (a : Prop) → Decidable a
x : E
i : η
hxi : x ∈ (fun i => s i) i
y : E
j : η
hyj : y ∈ (fun i => s i) j
k : η
hik : s i ⊆ s k
hjk : s j ⊆ s k
h_orth : ∀ v ∈ s k, ∀ w ∈ s k, inner v w = if v = w then 1 else 0
⊢ inner x y = if x = y then 1 else 0

Next tactic:
exact h_orth x (hik hxi) y (hjk hyj)
theorem orthonormal_sUnion_of_directed {s : Set (Set E)} (hs : DirectedOn (· ⊆ ·) s)
    (h : ∀ a ∈ s, Orthonormal 𝕜 (fun x => ((x : a) : E))) :
    Orthonormal 𝕜 (fun x => x : ⋃₀ s → E) := by
  

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
ι : Type u_4
dec_ι : DecidableEq ι
s : Set (Set E)
hs : DirectedOn (fun x x_1 => x ⊆ x_1) s
h : ∀ a ∈ s, Orthonormal 𝕜 fun x => ↑x
⊢ Orthonormal 𝕜 fun x => ↑x

Next tactic:
rw [Set.sUnion_eq_iUnion]
theorem orthonormal_sUnion_of_directed {s : Set (Set E)} (hs : DirectedOn (· ⊆ ·) s)
    (h : ∀ a ∈ s, Orthonormal 𝕜 (fun x => ((x : a) : E))) :
    Orthonormal 𝕜 (fun x => x : ⋃₀ s → E) := by
  rw [Set.sUnion_eq_iUnion]; 

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
ι : Type u_4
dec_ι : DecidableEq ι
s : Set (Set E)
hs : DirectedOn (fun x x_1 => x ⊆ x_1) s
h : ∀ a ∈ s, Orthonormal 𝕜 fun x => ↑x
⊢ Orthonormal 𝕜 fun x => ↑x

Next tactic:
exact orthonormal_iUnion_of_directed hs.directed_val (by simpa using h)
theorem orthonormal_sUnion_of_directed {s : Set (Set E)} (hs : DirectedOn (· ⊆ ·) s)
    (h : ∀ a ∈ s, Orthonormal 𝕜 (fun x => ((x : a) : E))) :
    Orthonormal 𝕜 (fun x => x : ⋃₀ s → E) := by
  rw [Set.sUnion_eq_iUnion]; exact orthonormal_iUnion_of_directed hs.directed_val (by 

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
ι : Type u_4
dec_ι : DecidableEq ι
s : Set (Set E)
hs : DirectedOn (fun x x_1 => x ⊆ x_1) s
h : ∀ a ∈ s, Orthonormal 𝕜 fun x => ↑x
⊢ ∀ (i : ↑s), Orthonormal 𝕜 fun x => ↑x

Next tactic:
simpa using h
/-- Given an orthonormal set `v` of vectors in `E`, there exists a maximal orthonormal set
containing it. -/
theorem exists_maximal_orthonormal {s : Set E} (hs : Orthonormal 𝕜 (Subtype.val : s → E)) :
    ∃ (w : _) (_hw : w ⊇ s), Orthonormal 𝕜 (Subtype.val : w → E) ∧
      ∀ (u) (_hu : u ⊇ w), Orthonormal 𝕜 (Subtype.val : u → E) → u = w := by
  

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
ι : Type u_4
dec_ι : DecidableEq ι
s : Set E
hs : Orthonormal 𝕜 Subtype.val
⊢ ∃ w, ∃ (_ : w ⊇ s), Orthonormal 𝕜 Subtype.val ∧ ∀ u ⊇ w, Orthonormal 𝕜 Subtype.val → u = w

Next tactic:
have := zorn_subset_nonempty { b | Orthonormal 𝕜 (Subtype.val : b → E) } ?_ _ hs
/-- Given an orthonormal set `v` of vectors in `E`, there exists a maximal orthonormal set
containing it. -/
theorem exists_maximal_orthonormal {s : Set E} (hs : Orthonormal 𝕜 (Subtype.val : s → E)) :
    ∃ (w : _) (_hw : w ⊇ s), Orthonormal 𝕜 (Subtype.val : w → E) ∧
      ∀ (u) (_hu : u ⊇ w), Orthonormal 𝕜 (Subtype.val : u → E) → u = w := by
  have := zorn_subset_nonempty { b | Orthonormal 𝕜 (Subtype.val : b → E) } ?_ _ hs
  

Proof state:
case refine_2
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
ι : Type u_4
dec_ι : DecidableEq ι
s : Set E
hs : Orthonormal 𝕜 Subtype.val
this : ∃ m ∈ {b | Orthonormal 𝕜 Subtype.val}, s ⊆ m ∧ ∀ a ∈ {b | Orthonormal 𝕜 Subtype.val}, m ⊆ a → a = m
⊢ ∃ w, ∃ (_ : w ⊇ s), Orthonormal 𝕜 Subtype.val ∧ ∀ u ⊇ w, Orthonormal 𝕜 Subtype.val → u = w
case refine_1
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
ι : Type u_4
dec_ι : DecidableEq ι
s : Set E
hs : Orthonormal 𝕜 Subtype.val
⊢ ∀ c ⊆ {b | Orthonormal 𝕜 Subtype.val},
    IsChain (fun x x_1 => x ⊆ x_1) c → Set.Nonempty c → ∃ ub ∈ {b | Orthonormal 𝕜 Subtype.val}, ∀ s ∈ c, s ⊆ ub

Next tactic:
obtain ⟨b, bi, sb, h⟩ := this
/-- Given an orthonormal set `v` of vectors in `E`, there exists a maximal orthonormal set
containing it. -/
theorem exists_maximal_orthonormal {s : Set E} (hs : Orthonormal 𝕜 (Subtype.val : s → E)) :
    ∃ (w : _) (_hw : w ⊇ s), Orthonormal 𝕜 (Subtype.val : w → E) ∧
      ∀ (u) (_hu : u ⊇ w), Orthonormal 𝕜 (Subtype.val : u → E) → u = w := by
  have := zorn_subset_nonempty { b | Orthonormal 𝕜 (Subtype.val : b → E) } ?_ _ hs
  obtain ⟨b, bi, sb, h⟩ := this
  · 

Proof state:
case refine_2.intro.intro.intro
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
ι : Type u_4
dec_ι : DecidableEq ι
s : Set E
hs : Orthonormal 𝕜 Subtype.val
b : Set E
bi : b ∈ {b | Orthonormal 𝕜 Subtype.val}
sb : s ⊆ b
h : ∀ a ∈ {b | Orthonormal 𝕜 Subtype.val}, b ⊆ a → a = b
⊢ ∃ w, ∃ (_ : w ⊇ s), Orthonormal 𝕜 Subtype.val ∧ ∀ u ⊇ w, Orthonormal 𝕜 Subtype.val → u = w

Next tactic:
refine' ⟨b, sb, bi, _⟩
/-- Given an orthonormal set `v` of vectors in `E`, there exists a maximal orthonormal set
containing it. -/
theorem exists_maximal_orthonormal {s : Set E} (hs : Orthonormal 𝕜 (Subtype.val : s → E)) :
    ∃ (w : _) (_hw : w ⊇ s), Orthonormal 𝕜 (Subtype.val : w → E) ∧
      ∀ (u) (_hu : u ⊇ w), Orthonormal 𝕜 (Subtype.val : u → E) → u = w := by
  have := zorn_subset_nonempty { b | Orthonormal 𝕜 (Subtype.val : b → E) } ?_ _ hs
  obtain ⟨b, bi, sb, h⟩ := this
  · refine' ⟨b, sb, bi, _⟩
    

Proof state:
case refine_2.intro.intro.intro
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
ι : Type u_4
dec_ι : DecidableEq ι
s : Set E
hs : Orthonormal 𝕜 Subtype.val
b : Set E
bi : b ∈ {b | Orthonormal 𝕜 Subtype.val}
sb : s ⊆ b
h : ∀ a ∈ {b | Orthonormal 𝕜 Subtype.val}, b ⊆ a → a = b
⊢ ∀ u ⊇ b, Orthonormal 𝕜 Subtype.val → u = b

Next tactic:
exact fun u hus hu => h u hu hus
/-- Given an orthonormal set `v` of vectors in `E`, there exists a maximal orthonormal set
containing it. -/
theorem exists_maximal_orthonormal {s : Set E} (hs : Orthonormal 𝕜 (Subtype.val : s → E)) :
    ∃ (w : _) (_hw : w ⊇ s), Orthonormal 𝕜 (Subtype.val : w → E) ∧
      ∀ (u) (_hu : u ⊇ w), Orthonormal 𝕜 (Subtype.val : u → E) → u = w := by
  have := zorn_subset_nonempty { b | Orthonormal 𝕜 (Subtype.val : b → E) } ?_ _ hs
  obtain ⟨b, bi, sb, h⟩ := this
  · refine' ⟨b, sb, bi, _⟩
    exact fun u hus hu => h u hu hus
  · 

Proof state:
case refine_1
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
ι : Type u_4
dec_ι : DecidableEq ι
s : Set E
hs : Orthonormal 𝕜 Subtype.val
⊢ ∀ c ⊆ {b | Orthonormal 𝕜 Subtype.val},
    IsChain (fun x x_1 => x ⊆ x_1) c → Set.Nonempty c → ∃ ub ∈ {b | Orthonormal 𝕜 Subtype.val}, ∀ s ∈ c, s ⊆ ub

Next tactic:
refine' fun c hc cc _c0 => ⟨⋃₀ c, _, _⟩
/-- Given an orthonormal set `v` of vectors in `E`, there exists a maximal orthonormal set
containing it. -/
theorem exists_maximal_orthonormal {s : Set E} (hs : Orthonormal 𝕜 (Subtype.val : s → E)) :
    ∃ (w : _) (_hw : w ⊇ s), Orthonormal 𝕜 (Subtype.val : w → E) ∧
      ∀ (u) (_hu : u ⊇ w), Orthonormal 𝕜 (Subtype.val : u → E) → u = w := by
  have := zorn_subset_nonempty { b | Orthonormal 𝕜 (Subtype.val : b → E) } ?_ _ hs
  obtain ⟨b, bi, sb, h⟩ := this
  · refine' ⟨b, sb, bi, _⟩
    exact fun u hus hu => h u hu hus
  · refine' fun c hc cc _c0 => ⟨⋃₀ c, _, _⟩
    · 

Proof state:
case refine_1.refine'_1
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
ι : Type u_4
dec_ι : DecidableEq ι
s : Set E
hs : Orthonormal 𝕜 Subtype.val
c : Set (Set E)
hc : c ⊆ {b | Orthonormal 𝕜 Subtype.val}
cc : IsChain (fun x x_1 => x ⊆ x_1) c
_c0 : Set.Nonempty c
⊢ ⋃₀ c ∈ {b | Orthonormal 𝕜 Subtype.val}

Next tactic:
exact orthonormal_sUnion_of_directed cc.directedOn fun x xc => hc xc
/-- Given an orthonormal set `v` of vectors in `E`, there exists a maximal orthonormal set
containing it. -/
theorem exists_maximal_orthonormal {s : Set E} (hs : Orthonormal 𝕜 (Subtype.val : s → E)) :
    ∃ (w : _) (_hw : w ⊇ s), Orthonormal 𝕜 (Subtype.val : w → E) ∧
      ∀ (u) (_hu : u ⊇ w), Orthonormal 𝕜 (Subtype.val : u → E) → u = w := by
  have := zorn_subset_nonempty { b | Orthonormal 𝕜 (Subtype.val : b → E) } ?_ _ hs
  obtain ⟨b, bi, sb, h⟩ := this
  · refine' ⟨b, sb, bi, _⟩
    exact fun u hus hu => h u hu hus
  · refine' fun c hc cc _c0 => ⟨⋃₀ c, _, _⟩
    · exact orthonormal_sUnion_of_directed cc.directedOn fun x xc => hc xc
    · 

Proof state:
case refine_1.refine'_2
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
ι : Type u_4
dec_ι : DecidableEq ι
s : Set E
hs : Orthonormal 𝕜 Subtype.val
c : Set (Set E)
hc : c ⊆ {b | Orthonormal 𝕜 Subtype.val}
cc : IsChain (fun x x_1 => x ⊆ x_1) c
_c0 : Set.Nonempty c
⊢ ∀ s ∈ c, s ⊆ ⋃₀ c

Next tactic:
exact fun _ => Set.subset_sUnion_of_mem
theorem Orthonormal.ne_zero {v : ι → E} (hv : Orthonormal 𝕜 v) (i : ι) : v i ≠ 0 := by
  

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
ι : Type u_4
dec_ι : DecidableEq ι
v : ι → E
hv : Orthonormal 𝕜 v
i : ι
⊢ v i ≠ 0

Next tactic:
have : ‖v i‖ ≠ 0 := by
    rw [hv.1 i]
    norm_num
theorem Orthonormal.ne_zero {v : ι → E} (hv : Orthonormal 𝕜 v) (i : ι) : v i ≠ 0 := by
  have : ‖v i‖ ≠ 0 := by
    

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
ι : Type u_4
dec_ι : DecidableEq ι
v : ι → E
hv : Orthonormal 𝕜 v
i : ι
⊢ ‖v i‖ ≠ 0

Next tactic:
rw [hv.1 i]
theorem Orthonormal.ne_zero {v : ι → E} (hv : Orthonormal 𝕜 v) (i : ι) : v i ≠ 0 := by
  have : ‖v i‖ ≠ 0 := by
    rw [hv.1 i]
    

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
ι : Type u_4
dec_ι : DecidableEq ι
v : ι → E
hv : Orthonormal 𝕜 v
i : ι
⊢ 1 ≠ 0

Next tactic:
norm_num
theorem Orthonormal.ne_zero {v : ι → E} (hv : Orthonormal 𝕜 v) (i : ι) : v i ≠ 0 := by
  have : ‖v i‖ ≠ 0 := by
    rw [hv.1 i]
    norm_num
  

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
ι : Type u_4
dec_ι : DecidableEq ι
v : ι → E
hv : Orthonormal 𝕜 v
i : ι
this : ‖v i‖ ≠ 0
⊢ v i ≠ 0

Next tactic:
simpa using this
theorem inner_self_eq_norm_mul_norm (x : E) : re ⟪x, x⟫ = ‖x‖ * ‖x‖ := by
  

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
x : E
⊢ re (inner x x) = ‖x‖ * ‖x‖

Next tactic:
rw [@norm_eq_sqrt_inner 𝕜, ← sqrt_mul inner_self_nonneg (re ⟪x, x⟫),
    sqrt_mul_self inner_self_nonneg]
theorem inner_self_eq_norm_sq (x : E) : re ⟪x, x⟫ = ‖x‖ ^ 2 := by
  

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
x : E
⊢ re (inner x x) = ‖x‖ ^ 2

Next tactic:
rw [pow_two, inner_self_eq_norm_mul_norm]
theorem real_inner_self_eq_norm_mul_norm (x : F) : ⟪x, x⟫_ℝ = ‖x‖ * ‖x‖ := by
  

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
x : F
⊢ inner x x = ‖x‖ * ‖x‖

Next tactic:
have h := @inner_self_eq_norm_mul_norm ℝ F _ _ _ x
theorem real_inner_self_eq_norm_mul_norm (x : F) : ⟪x, x⟫_ℝ = ‖x‖ * ‖x‖ := by
  have h := @inner_self_eq_norm_mul_norm ℝ F _ _ _ x
  

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
x : F
h : re (inner x x) = ‖x‖ * ‖x‖
⊢ inner x x = ‖x‖ * ‖x‖

Next tactic:
simpa using h
theorem real_inner_self_eq_norm_sq (x : F) : ⟪x, x⟫_ℝ = ‖x‖ ^ 2 := by
  

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
x : F
⊢ inner x x = ‖x‖ ^ 2

Next tactic:
rw [pow_two, real_inner_self_eq_norm_mul_norm]
/-- Expand the square -/
theorem norm_add_sq (x y : E) : ‖x + y‖ ^ 2 = ‖x‖ ^ 2 + 2 * re ⟪x, y⟫ + ‖y‖ ^ 2 := by
  

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
x y : E
⊢ ‖x + y‖ ^ 2 = ‖x‖ ^ 2 + 2 * re (inner x y) + ‖y‖ ^ 2

Next tactic:
repeat' rw [sq (M := ℝ), ← @inner_self_eq_norm_mul_norm 𝕜]
/-- Expand the square -/
theorem norm_add_sq (x y : E) : ‖x + y‖ ^ 2 = ‖x‖ ^ 2 + 2 * re ⟪x, y⟫ + ‖y‖ ^ 2 := by
  repeat' 

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
x y : E
⊢ ‖x + y‖ ^ 2 = ‖x‖ ^ 2 + 2 * re (inner x y) + ‖y‖ ^ 2

Next tactic:
rw [sq (M := ℝ), ← @inner_self_eq_norm_mul_norm 𝕜]
/-- Expand the square -/
theorem norm_add_sq (x y : E) : ‖x + y‖ ^ 2 = ‖x‖ ^ 2 + 2 * re ⟪x, y⟫ + ‖y‖ ^ 2 := by
  repeat' 

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
x y : E
⊢ re (inner (x + y) (x + y)) = ‖x‖ ^ 2 + 2 * re (inner x y) + ‖y‖ ^ 2

Next tactic:
rw [sq (M := ℝ), ← @inner_self_eq_norm_mul_norm 𝕜]
/-- Expand the square -/
theorem norm_add_sq (x y : E) : ‖x + y‖ ^ 2 = ‖x‖ ^ 2 + 2 * re ⟪x, y⟫ + ‖y‖ ^ 2 := by
  repeat' 

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
x y : E
⊢ re (inner (x + y) (x + y)) = re (inner x x) + 2 * re (inner x y) + ‖y‖ ^ 2

Next tactic:
rw [sq (M := ℝ), ← @inner_self_eq_norm_mul_norm 𝕜]
/-- Expand the square -/
theorem norm_add_sq (x y : E) : ‖x + y‖ ^ 2 = ‖x‖ ^ 2 + 2 * re ⟪x, y⟫ + ‖y‖ ^ 2 := by
  repeat' 

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
x y : E
⊢ re (inner (x + y) (x + y)) = re (inner x x) + 2 * re (inner x y) + re (inner y y)

Next tactic:
rw [sq (M := ℝ), ← @inner_self_eq_norm_mul_norm 𝕜]
/-- Expand the square -/
theorem norm_add_sq (x y : E) : ‖x + y‖ ^ 2 = ‖x‖ ^ 2 + 2 * re ⟪x, y⟫ + ‖y‖ ^ 2 := by
  repeat' rw [sq (M := ℝ), ← @inner_self_eq_norm_mul_norm 𝕜]
  

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
x y : E
⊢ re (inner (x + y) (x + y)) = re (inner x x) + 2 * re (inner x y) + re (inner y y)

Next tactic:
rw [inner_add_add_self, two_mul]
/-- Expand the square -/
theorem norm_add_sq (x y : E) : ‖x + y‖ ^ 2 = ‖x‖ ^ 2 + 2 * re ⟪x, y⟫ + ‖y‖ ^ 2 := by
  repeat' rw [sq (M := ℝ), ← @inner_self_eq_norm_mul_norm 𝕜]
  rw [inner_add_add_self, two_mul]
  

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
x y : E
⊢ re (inner x x + inner x y + inner y x + inner y y) =
    re (inner x x) + (re (inner x y) + re (inner x y)) + re (inner y y)

Next tactic:
simp only [add_assoc, add_left_inj, add_right_inj, AddMonoidHom.map_add]
/-- Expand the square -/
theorem norm_add_sq (x y : E) : ‖x + y‖ ^ 2 = ‖x‖ ^ 2 + 2 * re ⟪x, y⟫ + ‖y‖ ^ 2 := by
  repeat' rw [sq (M := ℝ), ← @inner_self_eq_norm_mul_norm 𝕜]
  rw [inner_add_add_self, two_mul]
  simp only [add_assoc, add_left_inj, add_right_inj, AddMonoidHom.map_add]
  

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : InnerProductSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
dec_E : DecidableEq E
x y : E
⊢ re (inner y x) = re (inner x y)

Next tactic:
rw [← inner_conj_symm, conj_re]