l3lab/ntp-mathlib huggingface dataset:
/-- Characterization of minimizers in the projection on a subspace, in the real case.
Let `u` be a point in a real inner product space, and let `K` be a nonempty subspace.
Then point `v` minimizes the distance `‖u - v‖` over points in `K` if and only if
for all `w ∈ K`, `⟪u - v, w⟫ = 0` (i.e., `u - v` is orthogonal to the subspace `K`).
This is superceded by `norm_eq_iInf_iff_inner_eq_zero` that gives the same conclusion over
any `IsROrC` field.
-/
theorem norm_eq_iInf_iff_real_inner_eq_zero (K : Submodule ℝ F) {u : F} {v : F} (hv : v ∈ K) :
    (‖u - v‖ = ⨅ w : (↑K : Set F), ‖u - w‖) ↔ ∀ w ∈ K, ⟪u - v, w⟫_ℝ = 0 :=
  Iff.intro
    (by
      intro h
      have h : ∀ w ∈ K, ⟪u - v, w - v⟫_ℝ ≤ 0 := by
        rwa [norm_eq_iInf_iff_real_inner_le_zero] at h
        exacts [K.convex, hv]
      intro w hw
      have le : ⟪u - v, w⟫_ℝ ≤ 0
      let w' := w + v
      have : w' ∈ K := Submodule.add_mem _ hw hv
      have h₁ := h w' this
      have h₂ : w' - v = w
      simp only [add_neg_cancel_right, sub_eq_add_neg]
      rw [h₂] at h₁
      exact h₁
      have ge : ⟪u - v, w⟫_ℝ ≥ 0
      let w'' := -w + v
      have : w'' ∈ K := Submodule.add_mem _ (Submodule.neg_mem _ hw) hv
      have h₁ := h w'' this
      have h₂ : w'' - v = -w
      

Proof state:
case h₂
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : NormedAddCommGroup F
inst✝¹ : InnerProductSpace 𝕜 E
inst✝ : InnerProductSpace ℝ F
K✝ : Submodule 𝕜 E
K : Submodule ℝ F
u v : F
hv : v ∈ K
h✝ : ‖u - v‖ = ⨅ w, ‖u - ↑w‖
h : ∀ w ∈ K, inner (u - v) (w - v) ≤ 0
w : F
hw : w ∈ K
le : inner (u - v) w ≤ 0
w'' : F := -w + v
this : w'' ∈ K
h₁ : inner (u - v) (w'' - v) ≤ 0
⊢ w'' - v = -w
case ge
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : NormedAddCommGroup F
inst✝¹ : InnerProductSpace 𝕜 E
inst✝ : InnerProductSpace ℝ F
K✝ : Submodule 𝕜 E
K : Submodule ℝ F
u v : F
hv : v ∈ K
h✝ : ‖u - v‖ = ⨅ w, ‖u - ↑w‖
h : ∀ w ∈ K, inner (u - v) (w - v) ≤ 0
w : F
hw : w ∈ K
le : inner (u - v) w ≤ 0
w'' : F := -w + v
this : w'' ∈ K
h₁ : inner (u - v) (w'' - v) ≤ 0
h₂ : w'' - v = -w
⊢ inner (u - v) w ≥ 0
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : NormedAddCommGroup F
inst✝¹ : InnerProductSpace 𝕜 E
inst✝ : InnerProductSpace ℝ F
K✝ : Submodule 𝕜 E
K : Submodule ℝ F
u v : F
hv : v ∈ K
h✝ : ‖u - v‖ = ⨅ w, ‖u - ↑w‖
h : ∀ w ∈ K, inner (u - v) (w - v) ≤ 0
w : F
hw : w ∈ K
le : inner (u - v) w ≤ 0
ge : inner (u - v) w ≥ 0
⊢ inner (u - v) w = 0

Next tactic:
simp only [neg_inj, add_neg_cancel_right, sub_eq_add_neg]
/-- Characterization of minimizers in the projection on a subspace, in the real case.
Let `u` be a point in a real inner product space, and let `K` be a nonempty subspace.
Then point `v` minimizes the distance `‖u - v‖` over points in `K` if and only if
for all `w ∈ K`, `⟪u - v, w⟫ = 0` (i.e., `u - v` is orthogonal to the subspace `K`).
This is superceded by `norm_eq_iInf_iff_inner_eq_zero` that gives the same conclusion over
any `IsROrC` field.
-/
theorem norm_eq_iInf_iff_real_inner_eq_zero (K : Submodule ℝ F) {u : F} {v : F} (hv : v ∈ K) :
    (‖u - v‖ = ⨅ w : (↑K : Set F), ‖u - w‖) ↔ ∀ w ∈ K, ⟪u - v, w⟫_ℝ = 0 :=
  Iff.intro
    (by
      intro h
      have h : ∀ w ∈ K, ⟪u - v, w - v⟫_ℝ ≤ 0 := by
        rwa [norm_eq_iInf_iff_real_inner_le_zero] at h
        exacts [K.convex, hv]
      intro w hw
      have le : ⟪u - v, w⟫_ℝ ≤ 0
      let w' := w + v
      have : w' ∈ K := Submodule.add_mem _ hw hv
      have h₁ := h w' this
      have h₂ : w' - v = w
      simp only [add_neg_cancel_right, sub_eq_add_neg]
      rw [h₂] at h₁
      exact h₁
      have ge : ⟪u - v, w⟫_ℝ ≥ 0
      let w'' := -w + v
      have : w'' ∈ K := Submodule.add_mem _ (Submodule.neg_mem _ hw) hv
      have h₁ := h w'' this
      have h₂ : w'' - v = -w
      simp only [neg_inj, add_neg_cancel_right, sub_eq_add_neg]
      

Proof state:
case ge
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : NormedAddCommGroup F
inst✝¹ : InnerProductSpace 𝕜 E
inst✝ : InnerProductSpace ℝ F
K✝ : Submodule 𝕜 E
K : Submodule ℝ F
u v : F
hv : v ∈ K
h✝ : ‖u - v‖ = ⨅ w, ‖u - ↑w‖
h : ∀ w ∈ K, inner (u - v) (w - v) ≤ 0
w : F
hw : w ∈ K
le : inner (u - v) w ≤ 0
w'' : F := -w + v
this : w'' ∈ K
h₁ : inner (u - v) (w'' - v) ≤ 0
h₂ : w'' - v = -w
⊢ inner (u - v) w ≥ 0
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : NormedAddCommGroup F
inst✝¹ : InnerProductSpace 𝕜 E
inst✝ : InnerProductSpace ℝ F
K✝ : Submodule 𝕜 E
K : Submodule ℝ F
u v : F
hv : v ∈ K
h✝ : ‖u - v‖ = ⨅ w, ‖u - ↑w‖
h : ∀ w ∈ K, inner (u - v) (w - v) ≤ 0
w : F
hw : w ∈ K
le : inner (u - v) w ≤ 0
ge : inner (u - v) w ≥ 0
⊢ inner (u - v) w = 0

Next tactic:
rw [h₂, inner_neg_right] at h₁
/-- Characterization of minimizers in the projection on a subspace, in the real case.
Let `u` be a point in a real inner product space, and let `K` be a nonempty subspace.
Then point `v` minimizes the distance `‖u - v‖` over points in `K` if and only if
for all `w ∈ K`, `⟪u - v, w⟫ = 0` (i.e., `u - v` is orthogonal to the subspace `K`).
This is superceded by `norm_eq_iInf_iff_inner_eq_zero` that gives the same conclusion over
any `IsROrC` field.
-/
theorem norm_eq_iInf_iff_real_inner_eq_zero (K : Submodule ℝ F) {u : F} {v : F} (hv : v ∈ K) :
    (‖u - v‖ = ⨅ w : (↑K : Set F), ‖u - w‖) ↔ ∀ w ∈ K, ⟪u - v, w⟫_ℝ = 0 :=
  Iff.intro
    (by
      intro h
      have h : ∀ w ∈ K, ⟪u - v, w - v⟫_ℝ ≤ 0 := by
        rwa [norm_eq_iInf_iff_real_inner_le_zero] at h
        exacts [K.convex, hv]
      intro w hw
      have le : ⟪u - v, w⟫_ℝ ≤ 0
      let w' := w + v
      have : w' ∈ K := Submodule.add_mem _ hw hv
      have h₁ := h w' this
      have h₂ : w' - v = w
      simp only [add_neg_cancel_right, sub_eq_add_neg]
      rw [h₂] at h₁
      exact h₁
      have ge : ⟪u - v, w⟫_ℝ ≥ 0
      let w'' := -w + v
      have : w'' ∈ K := Submodule.add_mem _ (Submodule.neg_mem _ hw) hv
      have h₁ := h w'' this
      have h₂ : w'' - v = -w
      simp only [neg_inj, add_neg_cancel_right, sub_eq_add_neg]
      rw [h₂, inner_neg_right] at h₁
      

Proof state:
case ge
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : NormedAddCommGroup F
inst✝¹ : InnerProductSpace 𝕜 E
inst✝ : InnerProductSpace ℝ F
K✝ : Submodule 𝕜 E
K : Submodule ℝ F
u v : F
hv : v ∈ K
h✝ : ‖u - v‖ = ⨅ w, ‖u - ↑w‖
h : ∀ w ∈ K, inner (u - v) (w - v) ≤ 0
w : F
hw : w ∈ K
le : inner (u - v) w ≤ 0
w'' : F := -w + v
this : w'' ∈ K
h₁ : -inner (u - v) w ≤ 0
h₂ : w'' - v = -w
⊢ inner (u - v) w ≥ 0
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : NormedAddCommGroup F
inst✝¹ : InnerProductSpace 𝕜 E
inst✝ : InnerProductSpace ℝ F
K✝ : Submodule 𝕜 E
K : Submodule ℝ F
u v : F
hv : v ∈ K
h✝ : ‖u - v‖ = ⨅ w, ‖u - ↑w‖
h : ∀ w ∈ K, inner (u - v) (w - v) ≤ 0
w : F
hw : w ∈ K
le : inner (u - v) w ≤ 0
ge : inner (u - v) w ≥ 0
⊢ inner (u - v) w = 0

Next tactic:
linarith
/-- Characterization of minimizers in the projection on a subspace, in the real case.
Let `u` be a point in a real inner product space, and let `K` be a nonempty subspace.
Then point `v` minimizes the distance `‖u - v‖` over points in `K` if and only if
for all `w ∈ K`, `⟪u - v, w⟫ = 0` (i.e., `u - v` is orthogonal to the subspace `K`).
This is superceded by `norm_eq_iInf_iff_inner_eq_zero` that gives the same conclusion over
any `IsROrC` field.
-/
theorem norm_eq_iInf_iff_real_inner_eq_zero (K : Submodule ℝ F) {u : F} {v : F} (hv : v ∈ K) :
    (‖u - v‖ = ⨅ w : (↑K : Set F), ‖u - w‖) ↔ ∀ w ∈ K, ⟪u - v, w⟫_ℝ = 0 :=
  Iff.intro
    (by
      intro h
      have h : ∀ w ∈ K, ⟪u - v, w - v⟫_ℝ ≤ 0 := by
        rwa [norm_eq_iInf_iff_real_inner_le_zero] at h
        exacts [K.convex, hv]
      intro w hw
      have le : ⟪u - v, w⟫_ℝ ≤ 0
      let w' := w + v
      have : w' ∈ K := Submodule.add_mem _ hw hv
      have h₁ := h w' this
      have h₂ : w' - v = w
      simp only [add_neg_cancel_right, sub_eq_add_neg]
      rw [h₂] at h₁
      exact h₁
      have ge : ⟪u - v, w⟫_ℝ ≥ 0
      let w'' := -w + v
      have : w'' ∈ K := Submodule.add_mem _ (Submodule.neg_mem _ hw) hv
      have h₁ := h w'' this
      have h₂ : w'' - v = -w
      simp only [neg_inj, add_neg_cancel_right, sub_eq_add_neg]
      rw [h₂, inner_neg_right] at h₁
      linarith
      

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : NormedAddCommGroup F
inst✝¹ : InnerProductSpace 𝕜 E
inst✝ : InnerProductSpace ℝ F
K✝ : Submodule 𝕜 E
K : Submodule ℝ F
u v : F
hv : v ∈ K
h✝ : ‖u - v‖ = ⨅ w, ‖u - ↑w‖
h : ∀ w ∈ K, inner (u - v) (w - v) ≤ 0
w : F
hw : w ∈ K
le : inner (u - v) w ≤ 0
ge : inner (u - v) w ≥ 0
⊢ inner (u - v) w = 0

Next tactic:
exact le_antisymm le ge
/-- Characterization of minimizers in the projection on a subspace, in the real case.
Let `u` be a point in a real inner product space, and let `K` be a nonempty subspace.
Then point `v` minimizes the distance `‖u - v‖` over points in `K` if and only if
for all `w ∈ K`, `⟪u - v, w⟫ = 0` (i.e., `u - v` is orthogonal to the subspace `K`).
This is superceded by `norm_eq_iInf_iff_inner_eq_zero` that gives the same conclusion over
any `IsROrC` field.
-/
theorem norm_eq_iInf_iff_real_inner_eq_zero (K : Submodule ℝ F) {u : F} {v : F} (hv : v ∈ K) :
    (‖u - v‖ = ⨅ w : (↑K : Set F), ‖u - w‖) ↔ ∀ w ∈ K, ⟪u - v, w⟫_ℝ = 0 :=
  Iff.intro
    (by
      intro h
      have h : ∀ w ∈ K, ⟪u - v, w - v⟫_ℝ ≤ 0 := by
        rwa [norm_eq_iInf_iff_real_inner_le_zero] at h
        exacts [K.convex, hv]
      intro w hw
      have le : ⟪u - v, w⟫_ℝ ≤ 0
      let w' := w + v
      have : w' ∈ K := Submodule.add_mem _ hw hv
      have h₁ := h w' this
      have h₂ : w' - v = w
      simp only [add_neg_cancel_right, sub_eq_add_neg]
      rw [h₂] at h₁
      exact h₁
      have ge : ⟪u - v, w⟫_ℝ ≥ 0
      let w'' := -w + v
      have : w'' ∈ K := Submodule.add_mem _ (Submodule.neg_mem _ hw) hv
      have h₁ := h w'' this
      have h₂ : w'' - v = -w
      simp only [neg_inj, add_neg_cancel_right, sub_eq_add_neg]
      rw [h₂, inner_neg_right] at h₁
      linarith
      exact le_antisymm le ge)
    (by
      

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : NormedAddCommGroup F
inst✝¹ : InnerProductSpace 𝕜 E
inst✝ : InnerProductSpace ℝ F
K✝ : Submodule 𝕜 E
K : Submodule ℝ F
u v : F
hv : v ∈ K
⊢ (∀ w ∈ K, inner (u - v) w = 0) → ‖u - v‖ = ⨅ w, ‖u - ↑w‖

Next tactic:
intro h
/-- Characterization of minimizers in the projection on a subspace, in the real case.
Let `u` be a point in a real inner product space, and let `K` be a nonempty subspace.
Then point `v` minimizes the distance `‖u - v‖` over points in `K` if and only if
for all `w ∈ K`, `⟪u - v, w⟫ = 0` (i.e., `u - v` is orthogonal to the subspace `K`).
This is superceded by `norm_eq_iInf_iff_inner_eq_zero` that gives the same conclusion over
any `IsROrC` field.
-/
theorem norm_eq_iInf_iff_real_inner_eq_zero (K : Submodule ℝ F) {u : F} {v : F} (hv : v ∈ K) :
    (‖u - v‖ = ⨅ w : (↑K : Set F), ‖u - w‖) ↔ ∀ w ∈ K, ⟪u - v, w⟫_ℝ = 0 :=
  Iff.intro
    (by
      intro h
      have h : ∀ w ∈ K, ⟪u - v, w - v⟫_ℝ ≤ 0 := by
        rwa [norm_eq_iInf_iff_real_inner_le_zero] at h
        exacts [K.convex, hv]
      intro w hw
      have le : ⟪u - v, w⟫_ℝ ≤ 0
      let w' := w + v
      have : w' ∈ K := Submodule.add_mem _ hw hv
      have h₁ := h w' this
      have h₂ : w' - v = w
      simp only [add_neg_cancel_right, sub_eq_add_neg]
      rw [h₂] at h₁
      exact h₁
      have ge : ⟪u - v, w⟫_ℝ ≥ 0
      let w'' := -w + v
      have : w'' ∈ K := Submodule.add_mem _ (Submodule.neg_mem _ hw) hv
      have h₁ := h w'' this
      have h₂ : w'' - v = -w
      simp only [neg_inj, add_neg_cancel_right, sub_eq_add_neg]
      rw [h₂, inner_neg_right] at h₁
      linarith
      exact le_antisymm le ge)
    (by
      intro h
      

Proof state:
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : NormedAddCommGroup F
inst✝¹ : InnerProductSpace 𝕜 E
inst✝ : InnerProductSpace ℝ F
K✝ : Submodule 𝕜 E
K : Submodule ℝ F
u v : F
hv : v ∈ K
h : ∀ w ∈ K, inner (u - v) w = 0
⊢ ‖u - v‖ = ⨅ w, ‖u - ↑w‖

Next tactic:
have : ∀ w ∈ K, ⟪u - v, w - v⟫_ℝ ≤ 0
/-- Characterization of minimizers in the projection on a subspace, in the real case.
Let `u` be a point in a real inner product space, and let `K` be a nonempty subspace.
Then point `v` minimizes the distance `‖u - v‖` over points in `K` if and only if
for all `w ∈ K`, `⟪u - v, w⟫ = 0` (i.e., `u - v` is orthogonal to the subspace `K`).
This is superceded by `norm_eq_iInf_iff_inner_eq_zero` that gives the same conclusion over
any `IsROrC` field.
-/
theorem norm_eq_iInf_iff_real_inner_eq_zero (K : Submodule ℝ F) {u : F} {v : F} (hv : v ∈ K) :
    (‖u - v‖ = ⨅ w : (↑K : Set F), ‖u - w‖) ↔ ∀ w ∈ K, ⟪u - v, w⟫_ℝ = 0 :=
  Iff.intro
    (by
      intro h
      have h : ∀ w ∈ K, ⟪u - v, w - v⟫_ℝ ≤ 0 := by
        rwa [norm_eq_iInf_iff_real_inner_le_zero] at h
        exacts [K.convex, hv]
      intro w hw
      have le : ⟪u - v, w⟫_ℝ ≤ 0
      let w' := w + v
      have : w' ∈ K := Submodule.add_mem _ hw hv
      have h₁ := h w' this
      have h₂ : w' - v = w
      simp only [add_neg_cancel_right, sub_eq_add_neg]
      rw [h₂] at h₁
      exact h₁
      have ge : ⟪u - v, w⟫_ℝ ≥ 0
      let w'' := -w + v
      have : w'' ∈ K := Submodule.add_mem _ (Submodule.neg_mem _ hw) hv
      have h₁ := h w'' this
      have h₂ : w'' - v = -w
      simp only [neg_inj, add_neg_cancel_right, sub_eq_add_neg]
      rw [h₂, inner_neg_right] at h₁
      linarith
      exact le_antisymm le ge)
    (by
      intro h
      have : ∀ w ∈ K, ⟪u - v, w - v⟫_ℝ ≤ 0
      

Proof state:
case this
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : NormedAddCommGroup F
inst✝¹ : InnerProductSpace 𝕜 E
inst✝ : InnerProductSpace ℝ F
K✝ : Submodule 𝕜 E
K : Submodule ℝ F
u v : F
hv : v ∈ K
h : ∀ w ∈ K, inner (u - v) w = 0
⊢ ∀ w ∈ K, inner (u - v) (w - v) ≤ 0
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : NormedAddCommGroup F
inst✝¹ : InnerProductSpace 𝕜 E
inst✝ : InnerProductSpace ℝ F
K✝ : Submodule 𝕜 E
K : Submodule ℝ F
u v : F
hv : v ∈ K
h : ∀ w ∈ K, inner (u - v) w = 0
this : ∀ w ∈ K, inner (u - v) (w - v) ≤ 0
⊢ ‖u - v‖ = ⨅ w, ‖u - ↑w‖

Next tactic:
intro w hw
/-- Characterization of minimizers in the projection on a subspace, in the real case.
Let `u` be a point in a real inner product space, and let `K` be a nonempty subspace.
Then point `v` minimizes the distance `‖u - v‖` over points in `K` if and only if
for all `w ∈ K`, `⟪u - v, w⟫ = 0` (i.e., `u - v` is orthogonal to the subspace `K`).
This is superceded by `norm_eq_iInf_iff_inner_eq_zero` that gives the same conclusion over
any `IsROrC` field.
-/
theorem norm_eq_iInf_iff_real_inner_eq_zero (K : Submodule ℝ F) {u : F} {v : F} (hv : v ∈ K) :
    (‖u - v‖ = ⨅ w : (↑K : Set F), ‖u - w‖) ↔ ∀ w ∈ K, ⟪u - v, w⟫_ℝ = 0 :=
  Iff.intro
    (by
      intro h
      have h : ∀ w ∈ K, ⟪u - v, w - v⟫_ℝ ≤ 0 := by
        rwa [norm_eq_iInf_iff_real_inner_le_zero] at h
        exacts [K.convex, hv]
      intro w hw
      have le : ⟪u - v, w⟫_ℝ ≤ 0
      let w' := w + v
      have : w' ∈ K := Submodule.add_mem _ hw hv
      have h₁ := h w' this
      have h₂ : w' - v = w
      simp only [add_neg_cancel_right, sub_eq_add_neg]
      rw [h₂] at h₁
      exact h₁
      have ge : ⟪u - v, w⟫_ℝ ≥ 0
      let w'' := -w + v
      have : w'' ∈ K := Submodule.add_mem _ (Submodule.neg_mem _ hw) hv
      have h₁ := h w'' this
      have h₂ : w'' - v = -w
      simp only [neg_inj, add_neg_cancel_right, sub_eq_add_neg]
      rw [h₂, inner_neg_right] at h₁
      linarith
      exact le_antisymm le ge)
    (by
      intro h
      have : ∀ w ∈ K, ⟪u - v, w - v⟫_ℝ ≤ 0
      intro w hw
      

Proof state:
case this
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : NormedAddCommGroup F
inst✝¹ : InnerProductSpace 𝕜 E
inst✝ : InnerProductSpace ℝ F
K✝ : Submodule 𝕜 E
K : Submodule ℝ F
u v : F
hv : v ∈ K
h : ∀ w ∈ K, inner (u - v) w = 0
w : F
hw : w ∈ K
⊢ inner (u - v) (w - v) ≤ 0
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : NormedAddCommGroup F
inst✝¹ : InnerProductSpace 𝕜 E
inst✝ : InnerProductSpace ℝ F
K✝ : Submodule 𝕜 E
K : Submodule ℝ F
u v : F
hv : v ∈ K
h : ∀ w ∈ K, inner (u - v) w = 0
this : ∀ w ∈ K, inner (u - v) (w - v) ≤ 0
⊢ ‖u - v‖ = ⨅ w, ‖u - ↑w‖

Next tactic:
let w' := w - v
/-- Characterization of minimizers in the projection on a subspace, in the real case.
Let `u` be a point in a real inner product space, and let `K` be a nonempty subspace.
Then point `v` minimizes the distance `‖u - v‖` over points in `K` if and only if
for all `w ∈ K`, `⟪u - v, w⟫ = 0` (i.e., `u - v` is orthogonal to the subspace `K`).
This is superceded by `norm_eq_iInf_iff_inner_eq_zero` that gives the same conclusion over
any `IsROrC` field.
-/
theorem norm_eq_iInf_iff_real_inner_eq_zero (K : Submodule ℝ F) {u : F} {v : F} (hv : v ∈ K) :
    (‖u - v‖ = ⨅ w : (↑K : Set F), ‖u - w‖) ↔ ∀ w ∈ K, ⟪u - v, w⟫_ℝ = 0 :=
  Iff.intro
    (by
      intro h
      have h : ∀ w ∈ K, ⟪u - v, w - v⟫_ℝ ≤ 0 := by
        rwa [norm_eq_iInf_iff_real_inner_le_zero] at h
        exacts [K.convex, hv]
      intro w hw
      have le : ⟪u - v, w⟫_ℝ ≤ 0
      let w' := w + v
      have : w' ∈ K := Submodule.add_mem _ hw hv
      have h₁ := h w' this
      have h₂ : w' - v = w
      simp only [add_neg_cancel_right, sub_eq_add_neg]
      rw [h₂] at h₁
      exact h₁
      have ge : ⟪u - v, w⟫_ℝ ≥ 0
      let w'' := -w + v
      have : w'' ∈ K := Submodule.add_mem _ (Submodule.neg_mem _ hw) hv
      have h₁ := h w'' this
      have h₂ : w'' - v = -w
      simp only [neg_inj, add_neg_cancel_right, sub_eq_add_neg]
      rw [h₂, inner_neg_right] at h₁
      linarith
      exact le_antisymm le ge)
    (by
      intro h
      have : ∀ w ∈ K, ⟪u - v, w - v⟫_ℝ ≤ 0
      intro w hw
      let w' := w - v
      

Proof state:
case this
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : NormedAddCommGroup F
inst✝¹ : InnerProductSpace 𝕜 E
inst✝ : InnerProductSpace ℝ F
K✝ : Submodule 𝕜 E
K : Submodule ℝ F
u v : F
hv : v ∈ K
h : ∀ w ∈ K, inner (u - v) w = 0
w : F
hw : w ∈ K
w' : F := w - v
⊢ inner (u - v) (w - v) ≤ 0
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : NormedAddCommGroup F
inst✝¹ : InnerProductSpace 𝕜 E
inst✝ : InnerProductSpace ℝ F
K✝ : Submodule 𝕜 E
K : Submodule ℝ F
u v : F
hv : v ∈ K
h : ∀ w ∈ K, inner (u - v) w = 0
this : ∀ w ∈ K, inner (u - v) (w - v) ≤ 0
⊢ ‖u - v‖ = ⨅ w, ‖u - ↑w‖

Next tactic:
have : w' ∈ K := Submodule.sub_mem _ hw hv
/-- Characterization of minimizers in the projection on a subspace, in the real case.
Let `u` be a point in a real inner product space, and let `K` be a nonempty subspace.
Then point `v` minimizes the distance `‖u - v‖` over points in `K` if and only if
for all `w ∈ K`, `⟪u - v, w⟫ = 0` (i.e., `u - v` is orthogonal to the subspace `K`).
This is superceded by `norm_eq_iInf_iff_inner_eq_zero` that gives the same conclusion over
any `IsROrC` field.
-/
theorem norm_eq_iInf_iff_real_inner_eq_zero (K : Submodule ℝ F) {u : F} {v : F} (hv : v ∈ K) :
    (‖u - v‖ = ⨅ w : (↑K : Set F), ‖u - w‖) ↔ ∀ w ∈ K, ⟪u - v, w⟫_ℝ = 0 :=
  Iff.intro
    (by
      intro h
      have h : ∀ w ∈ K, ⟪u - v, w - v⟫_ℝ ≤ 0 := by
        rwa [norm_eq_iInf_iff_real_inner_le_zero] at h
        exacts [K.convex, hv]
      intro w hw
      have le : ⟪u - v, w⟫_ℝ ≤ 0
      let w' := w + v
      have : w' ∈ K := Submodule.add_mem _ hw hv
      have h₁ := h w' this
      have h₂ : w' - v = w
      simp only [add_neg_cancel_right, sub_eq_add_neg]
      rw [h₂] at h₁
      exact h₁
      have ge : ⟪u - v, w⟫_ℝ ≥ 0
      let w'' := -w + v
      have : w'' ∈ K := Submodule.add_mem _ (Submodule.neg_mem _ hw) hv
      have h₁ := h w'' this
      have h₂ : w'' - v = -w
      simp only [neg_inj, add_neg_cancel_right, sub_eq_add_neg]
      rw [h₂, inner_neg_right] at h₁
      linarith
      exact le_antisymm le ge)
    (by
      intro h
      have : ∀ w ∈ K, ⟪u - v, w - v⟫_ℝ ≤ 0
      intro w hw
      let w' := w - v
      have : w' ∈ K := Submodule.sub_mem _ hw hv
      

Proof state:
case this
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : NormedAddCommGroup F
inst✝¹ : InnerProductSpace 𝕜 E
inst✝ : InnerProductSpace ℝ F
K✝ : Submodule 𝕜 E
K : Submodule ℝ F
u v : F
hv : v ∈ K
h : ∀ w ∈ K, inner (u - v) w = 0
w : F
hw : w ∈ K
w' : F := w - v
this : w' ∈ K
⊢ inner (u - v) (w - v) ≤ 0
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : NormedAddCommGroup F
inst✝¹ : InnerProductSpace 𝕜 E
inst✝ : InnerProductSpace ℝ F
K✝ : Submodule 𝕜 E
K : Submodule ℝ F
u v : F
hv : v ∈ K
h : ∀ w ∈ K, inner (u - v) w = 0
this : ∀ w ∈ K, inner (u - v) (w - v) ≤ 0
⊢ ‖u - v‖ = ⨅ w, ‖u - ↑w‖

Next tactic:
have h₁ := h w' this
/-- Characterization of minimizers in the projection on a subspace, in the real case.
Let `u` be a point in a real inner product space, and let `K` be a nonempty subspace.
Then point `v` minimizes the distance `‖u - v‖` over points in `K` if and only if
for all `w ∈ K`, `⟪u - v, w⟫ = 0` (i.e., `u - v` is orthogonal to the subspace `K`).
This is superceded by `norm_eq_iInf_iff_inner_eq_zero` that gives the same conclusion over
any `IsROrC` field.
-/
theorem norm_eq_iInf_iff_real_inner_eq_zero (K : Submodule ℝ F) {u : F} {v : F} (hv : v ∈ K) :
    (‖u - v‖ = ⨅ w : (↑K : Set F), ‖u - w‖) ↔ ∀ w ∈ K, ⟪u - v, w⟫_ℝ = 0 :=
  Iff.intro
    (by
      intro h
      have h : ∀ w ∈ K, ⟪u - v, w - v⟫_ℝ ≤ 0 := by
        rwa [norm_eq_iInf_iff_real_inner_le_zero] at h
        exacts [K.convex, hv]
      intro w hw
      have le : ⟪u - v, w⟫_ℝ ≤ 0
      let w' := w + v
      have : w' ∈ K := Submodule.add_mem _ hw hv
      have h₁ := h w' this
      have h₂ : w' - v = w
      simp only [add_neg_cancel_right, sub_eq_add_neg]
      rw [h₂] at h₁
      exact h₁
      have ge : ⟪u - v, w⟫_ℝ ≥ 0
      let w'' := -w + v
      have : w'' ∈ K := Submodule.add_mem _ (Submodule.neg_mem _ hw) hv
      have h₁ := h w'' this
      have h₂ : w'' - v = -w
      simp only [neg_inj, add_neg_cancel_right, sub_eq_add_neg]
      rw [h₂, inner_neg_right] at h₁
      linarith
      exact le_antisymm le ge)
    (by
      intro h
      have : ∀ w ∈ K, ⟪u - v, w - v⟫_ℝ ≤ 0
      intro w hw
      let w' := w - v
      have : w' ∈ K := Submodule.sub_mem _ hw hv
      have h₁ := h w' this
      

Proof state:
case this
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : NormedAddCommGroup F
inst✝¹ : InnerProductSpace 𝕜 E
inst✝ : InnerProductSpace ℝ F
K✝ : Submodule 𝕜 E
K : Submodule ℝ F
u v : F
hv : v ∈ K
h : ∀ w ∈ K, inner (u - v) w = 0
w : F
hw : w ∈ K
w' : F := w - v
this : w' ∈ K
h₁ : inner (u - v) w' = 0
⊢ inner (u - v) (w - v) ≤ 0
𝕜 : Type u_1
E : Type u_2
F : Type u_3
inst✝⁴ : IsROrC 𝕜
inst✝³ : NormedAddCommGroup E
inst✝² : NormedAddCommGroup F
inst✝¹ : InnerProductSpace 𝕜 E
inst✝ : InnerProductSpace ℝ F
K✝ : Submodule 𝕜 E
K : Submodule ℝ F
u v : F
hv : v ∈ K
h : ∀ w ∈ K, inner (u - v) w = 0
this : ∀ w ∈ K, inner (u - v) (w - v) ≤ 0
⊢ ‖u - v‖ = ⨅ w, ‖u - ↑w‖

Next tactic:
exact le_of_eq h₁