l3lab/ntp-mathlib huggingface dataset:
/-- **Hahn-Banach theorem** for continuous linear functions over `𝕜` satisfying `IsROrC 𝕜`. -/
theorem exists_extension_norm_eq (p : Subspace 𝕜 E) (f : p →L[𝕜] 𝕜) :
    ∃ g : E →L[𝕜] 𝕜, (∀ x : p, g x = f x) ∧ ‖g‖ = ‖f‖ := by
  letI : Module ℝ E := RestrictScalars.module ℝ 𝕜 E
  letI : IsScalarTower ℝ 𝕜 E := RestrictScalars.isScalarTower _ _ _
  letI : NormedSpace ℝ E := NormedSpace.restrictScalars _ 𝕜 _
  -- Let `fr: p →L[ℝ] ℝ` be the real part of `f`.
  let fr := reClm.comp (f.restrictScalars ℝ)
  -- Use the real version to get a norm-preserving extension of `fr`, which
  -- we'll call `g : E →L[ℝ] ℝ`.
  rcases Real.exists_extension_norm_eq (p.restrictScalars ℝ) fr with ⟨g, ⟨hextends, hnormeq⟩⟩
  -- Now `g` can be extended to the `E →L[𝕜] 𝕜` we need.
  refine' ⟨g.extendTo𝕜, _⟩
  -- It is an extension of `f`.
  have h : ∀ x : p, g.extendTo𝕜 x = f x := by
    intro x
    -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
    erw [ContinuousLinearMap.extendTo𝕜_apply, ← Submodule.coe_smul, hextends, hextends]
    have : (fr x : 𝕜) - I * ↑(fr (I • x)) = (re (f x) : 𝕜) - (I : 𝕜) * re (f ((I : 𝕜) • x)) := by
      rfl
    -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
    erw [this]
    

Proof state:
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
E : Type u_2
F : Type u_3
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : NormedSpace 𝕜 F
p : Subspace 𝕜 E
f : ↥p →L[𝕜] 𝕜
this✝² : Module ℝ E := RestrictScalars.module ℝ 𝕜 E
this✝¹ : IsScalarTower ℝ 𝕜 E := RestrictScalars.isScalarTower ℝ 𝕜 E
this✝ : NormedSpace ℝ E := NormedSpace.restrictScalars ℝ 𝕜 E
fr : ↥p →L[ℝ] ℝ := ContinuousLinearMap.comp reClm (ContinuousLinearMap.restrictScalars ℝ f)
g : E →L[ℝ] ℝ
hextends : ∀ (x : ↥(Submodule.restrictScalars ℝ p)), g ↑x = fr x
hnormeq : ‖g‖ = ‖fr‖
x : ↥p
this : ↑(fr x) - I * ↑(fr (I • x)) = ↑(re (f x)) - I * ↑(re (f (I • x)))
⊢ ↑(re (f x)) - I * ↑(re (f (I • x))) = f x

Next tactic:
apply ext
/-- **Hahn-Banach theorem** for continuous linear functions over `𝕜` satisfying `IsROrC 𝕜`. -/
theorem exists_extension_norm_eq (p : Subspace 𝕜 E) (f : p →L[𝕜] 𝕜) :
    ∃ g : E →L[𝕜] 𝕜, (∀ x : p, g x = f x) ∧ ‖g‖ = ‖f‖ := by
  letI : Module ℝ E := RestrictScalars.module ℝ 𝕜 E
  letI : IsScalarTower ℝ 𝕜 E := RestrictScalars.isScalarTower _ _ _
  letI : NormedSpace ℝ E := NormedSpace.restrictScalars _ 𝕜 _
  -- Let `fr: p →L[ℝ] ℝ` be the real part of `f`.
  let fr := reClm.comp (f.restrictScalars ℝ)
  -- Use the real version to get a norm-preserving extension of `fr`, which
  -- we'll call `g : E →L[ℝ] ℝ`.
  rcases Real.exists_extension_norm_eq (p.restrictScalars ℝ) fr with ⟨g, ⟨hextends, hnormeq⟩⟩
  -- Now `g` can be extended to the `E →L[𝕜] 𝕜` we need.
  refine' ⟨g.extendTo𝕜, _⟩
  -- It is an extension of `f`.
  have h : ∀ x : p, g.extendTo𝕜 x = f x := by
    intro x
    -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
    erw [ContinuousLinearMap.extendTo𝕜_apply, ← Submodule.coe_smul, hextends, hextends]
    have : (fr x : 𝕜) - I * ↑(fr (I • x)) = (re (f x) : 𝕜) - (I : 𝕜) * re (f ((I : 𝕜) • x)) := by
      rfl
    -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
    erw [this]
    apply ext
    · 

Proof state:
case hre
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
E : Type u_2
F : Type u_3
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : NormedSpace 𝕜 F
p : Subspace 𝕜 E
f : ↥p →L[𝕜] 𝕜
this✝² : Module ℝ E := RestrictScalars.module ℝ 𝕜 E
this✝¹ : IsScalarTower ℝ 𝕜 E := RestrictScalars.isScalarTower ℝ 𝕜 E
this✝ : NormedSpace ℝ E := NormedSpace.restrictScalars ℝ 𝕜 E
fr : ↥p →L[ℝ] ℝ := ContinuousLinearMap.comp reClm (ContinuousLinearMap.restrictScalars ℝ f)
g : E →L[ℝ] ℝ
hextends : ∀ (x : ↥(Submodule.restrictScalars ℝ p)), g ↑x = fr x
hnormeq : ‖g‖ = ‖fr‖
x : ↥p
this : ↑(fr x) - I * ↑(fr (I • x)) = ↑(re (f x)) - I * ↑(re (f (I • x)))
⊢ re (↑(re (f x)) - I * ↑(re (f (I • x)))) = re (f x)

Next tactic:
simp only [add_zero, Algebra.id.smul_eq_mul, I_re, ofReal_im, AddMonoidHom.map_add, zero_sub,
        I_im', zero_mul, ofReal_re, eq_self_iff_true, sub_zero, mul_neg, ofReal_neg,
        mul_re, mul_zero, sub_neg_eq_add, ContinuousLinearMap.map_smul]
/-- **Hahn-Banach theorem** for continuous linear functions over `𝕜` satisfying `IsROrC 𝕜`. -/
theorem exists_extension_norm_eq (p : Subspace 𝕜 E) (f : p →L[𝕜] 𝕜) :
    ∃ g : E →L[𝕜] 𝕜, (∀ x : p, g x = f x) ∧ ‖g‖ = ‖f‖ := by
  letI : Module ℝ E := RestrictScalars.module ℝ 𝕜 E
  letI : IsScalarTower ℝ 𝕜 E := RestrictScalars.isScalarTower _ _ _
  letI : NormedSpace ℝ E := NormedSpace.restrictScalars _ 𝕜 _
  -- Let `fr: p →L[ℝ] ℝ` be the real part of `f`.
  let fr := reClm.comp (f.restrictScalars ℝ)
  -- Use the real version to get a norm-preserving extension of `fr`, which
  -- we'll call `g : E →L[ℝ] ℝ`.
  rcases Real.exists_extension_norm_eq (p.restrictScalars ℝ) fr with ⟨g, ⟨hextends, hnormeq⟩⟩
  -- Now `g` can be extended to the `E →L[𝕜] 𝕜` we need.
  refine' ⟨g.extendTo𝕜, _⟩
  -- It is an extension of `f`.
  have h : ∀ x : p, g.extendTo𝕜 x = f x := by
    intro x
    -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
    erw [ContinuousLinearMap.extendTo𝕜_apply, ← Submodule.coe_smul, hextends, hextends]
    have : (fr x : 𝕜) - I * ↑(fr (I • x)) = (re (f x) : 𝕜) - (I : 𝕜) * re (f ((I : 𝕜) • x)) := by
      rfl
    -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
    erw [this]
    apply ext
    · simp only [add_zero, Algebra.id.smul_eq_mul, I_re, ofReal_im, AddMonoidHom.map_add, zero_sub,
        I_im', zero_mul, ofReal_re, eq_self_iff_true, sub_zero, mul_neg, ofReal_neg,
        mul_re, mul_zero, sub_neg_eq_add, ContinuousLinearMap.map_smul]
    · 

Proof state:
case him
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
E : Type u_2
F : Type u_3
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : NormedSpace 𝕜 F
p : Subspace 𝕜 E
f : ↥p →L[𝕜] 𝕜
this✝² : Module ℝ E := RestrictScalars.module ℝ 𝕜 E
this✝¹ : IsScalarTower ℝ 𝕜 E := RestrictScalars.isScalarTower ℝ 𝕜 E
this✝ : NormedSpace ℝ E := NormedSpace.restrictScalars ℝ 𝕜 E
fr : ↥p →L[ℝ] ℝ := ContinuousLinearMap.comp reClm (ContinuousLinearMap.restrictScalars ℝ f)
g : E →L[ℝ] ℝ
hextends : ∀ (x : ↥(Submodule.restrictScalars ℝ p)), g ↑x = fr x
hnormeq : ‖g‖ = ‖fr‖
x : ↥p
this : ↑(fr x) - I * ↑(fr (I • x)) = ↑(re (f x)) - I * ↑(re (f (I • x)))
⊢ im (↑(re (f x)) - I * ↑(re (f (I • x)))) = im (f x)

Next tactic:
simp only [Algebra.id.smul_eq_mul, I_re, ofReal_im, AddMonoidHom.map_add, zero_sub, I_im',
        zero_mul, ofReal_re, mul_neg, mul_im, zero_add, ofReal_neg, mul_re,
        sub_neg_eq_add, ContinuousLinearMap.map_smul]
/-- **Hahn-Banach theorem** for continuous linear functions over `𝕜` satisfying `IsROrC 𝕜`. -/
theorem exists_extension_norm_eq (p : Subspace 𝕜 E) (f : p →L[𝕜] 𝕜) :
    ∃ g : E →L[𝕜] 𝕜, (∀ x : p, g x = f x) ∧ ‖g‖ = ‖f‖ := by
  letI : Module ℝ E := RestrictScalars.module ℝ 𝕜 E
  letI : IsScalarTower ℝ 𝕜 E := RestrictScalars.isScalarTower _ _ _
  letI : NormedSpace ℝ E := NormedSpace.restrictScalars _ 𝕜 _
  -- Let `fr: p →L[ℝ] ℝ` be the real part of `f`.
  let fr := reClm.comp (f.restrictScalars ℝ)
  -- Use the real version to get a norm-preserving extension of `fr`, which
  -- we'll call `g : E →L[ℝ] ℝ`.
  rcases Real.exists_extension_norm_eq (p.restrictScalars ℝ) fr with ⟨g, ⟨hextends, hnormeq⟩⟩
  -- Now `g` can be extended to the `E →L[𝕜] 𝕜` we need.
  refine' ⟨g.extendTo𝕜, _⟩
  -- It is an extension of `f`.
  have h : ∀ x : p, g.extendTo𝕜 x = f x := by
    intro x
    -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
    erw [ContinuousLinearMap.extendTo𝕜_apply, ← Submodule.coe_smul, hextends, hextends]
    have : (fr x : 𝕜) - I * ↑(fr (I • x)) = (re (f x) : 𝕜) - (I : 𝕜) * re (f ((I : 𝕜) • x)) := by
      rfl
    -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
    erw [this]
    apply ext
    · simp only [add_zero, Algebra.id.smul_eq_mul, I_re, ofReal_im, AddMonoidHom.map_add, zero_sub,
        I_im', zero_mul, ofReal_re, eq_self_iff_true, sub_zero, mul_neg, ofReal_neg,
        mul_re, mul_zero, sub_neg_eq_add, ContinuousLinearMap.map_smul]
    · simp only [Algebra.id.smul_eq_mul, I_re, ofReal_im, AddMonoidHom.map_add, zero_sub, I_im',
        zero_mul, ofReal_re, mul_neg, mul_im, zero_add, ofReal_neg, mul_re,
        sub_neg_eq_add, ContinuousLinearMap.map_smul]
  -- And we derive the equality of the norms by bounding on both sides.
  

Proof state:
case intro.intro
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
E : Type u_2
F : Type u_3
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : NormedSpace 𝕜 F
p : Subspace 𝕜 E
f : ↥p →L[𝕜] 𝕜
this✝¹ : Module ℝ E := RestrictScalars.module ℝ 𝕜 E
this✝ : IsScalarTower ℝ 𝕜 E := RestrictScalars.isScalarTower ℝ 𝕜 E
this : NormedSpace ℝ E := NormedSpace.restrictScalars ℝ 𝕜 E
fr : ↥p →L[ℝ] ℝ := ContinuousLinearMap.comp reClm (ContinuousLinearMap.restrictScalars ℝ f)
g : E →L[ℝ] ℝ
hextends : ∀ (x : ↥(Submodule.restrictScalars ℝ p)), g ↑x = fr x
hnormeq : ‖g‖ = ‖fr‖
h : ∀ (x : ↥p), (ContinuousLinearMap.extendTo𝕜 g) ↑x = f x
⊢ (∀ (x : ↥p), (ContinuousLinearMap.extendTo𝕜 g) ↑x = f x) ∧ ‖ContinuousLinearMap.extendTo𝕜 g‖ = ‖f‖

Next tactic:
refine' ⟨h, le_antisymm _ _⟩
/-- **Hahn-Banach theorem** for continuous linear functions over `𝕜` satisfying `IsROrC 𝕜`. -/
theorem exists_extension_norm_eq (p : Subspace 𝕜 E) (f : p →L[𝕜] 𝕜) :
    ∃ g : E →L[𝕜] 𝕜, (∀ x : p, g x = f x) ∧ ‖g‖ = ‖f‖ := by
  letI : Module ℝ E := RestrictScalars.module ℝ 𝕜 E
  letI : IsScalarTower ℝ 𝕜 E := RestrictScalars.isScalarTower _ _ _
  letI : NormedSpace ℝ E := NormedSpace.restrictScalars _ 𝕜 _
  -- Let `fr: p →L[ℝ] ℝ` be the real part of `f`.
  let fr := reClm.comp (f.restrictScalars ℝ)
  -- Use the real version to get a norm-preserving extension of `fr`, which
  -- we'll call `g : E →L[ℝ] ℝ`.
  rcases Real.exists_extension_norm_eq (p.restrictScalars ℝ) fr with ⟨g, ⟨hextends, hnormeq⟩⟩
  -- Now `g` can be extended to the `E →L[𝕜] 𝕜` we need.
  refine' ⟨g.extendTo𝕜, _⟩
  -- It is an extension of `f`.
  have h : ∀ x : p, g.extendTo𝕜 x = f x := by
    intro x
    -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
    erw [ContinuousLinearMap.extendTo𝕜_apply, ← Submodule.coe_smul, hextends, hextends]
    have : (fr x : 𝕜) - I * ↑(fr (I • x)) = (re (f x) : 𝕜) - (I : 𝕜) * re (f ((I : 𝕜) • x)) := by
      rfl
    -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
    erw [this]
    apply ext
    · simp only [add_zero, Algebra.id.smul_eq_mul, I_re, ofReal_im, AddMonoidHom.map_add, zero_sub,
        I_im', zero_mul, ofReal_re, eq_self_iff_true, sub_zero, mul_neg, ofReal_neg,
        mul_re, mul_zero, sub_neg_eq_add, ContinuousLinearMap.map_smul]
    · simp only [Algebra.id.smul_eq_mul, I_re, ofReal_im, AddMonoidHom.map_add, zero_sub, I_im',
        zero_mul, ofReal_re, mul_neg, mul_im, zero_add, ofReal_neg, mul_re,
        sub_neg_eq_add, ContinuousLinearMap.map_smul]
  -- And we derive the equality of the norms by bounding on both sides.
  refine' ⟨h, le_antisymm _ _⟩
  · 

Proof state:
case intro.intro.refine'_1
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
E : Type u_2
F : Type u_3
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : NormedSpace 𝕜 F
p : Subspace 𝕜 E
f : ↥p →L[𝕜] 𝕜
this✝¹ : Module ℝ E := RestrictScalars.module ℝ 𝕜 E
this✝ : IsScalarTower ℝ 𝕜 E := RestrictScalars.isScalarTower ℝ 𝕜 E
this : NormedSpace ℝ E := NormedSpace.restrictScalars ℝ 𝕜 E
fr : ↥p →L[ℝ] ℝ := ContinuousLinearMap.comp reClm (ContinuousLinearMap.restrictScalars ℝ f)
g : E →L[ℝ] ℝ
hextends : ∀ (x : ↥(Submodule.restrictScalars ℝ p)), g ↑x = fr x
hnormeq : ‖g‖ = ‖fr‖
h : ∀ (x : ↥p), (ContinuousLinearMap.extendTo𝕜 g) ↑x = f x
⊢ ‖ContinuousLinearMap.extendTo𝕜 g‖ ≤ ‖f‖

Next tactic:
calc
      ‖g.extendTo𝕜‖ = ‖g‖ := g.norm_extendTo𝕜
      _ = ‖fr‖ := hnormeq
      _ ≤ ‖reClm‖ * ‖f‖ := (ContinuousLinearMap.op_norm_comp_le _ _)
      _ = ‖f‖ := by rw [reClm_norm, one_mul]
/-- **Hahn-Banach theorem** for continuous linear functions over `𝕜` satisfying `IsROrC 𝕜`. -/
theorem exists_extension_norm_eq (p : Subspace 𝕜 E) (f : p →L[𝕜] 𝕜) :
    ∃ g : E →L[𝕜] 𝕜, (∀ x : p, g x = f x) ∧ ‖g‖ = ‖f‖ := by
  letI : Module ℝ E := RestrictScalars.module ℝ 𝕜 E
  letI : IsScalarTower ℝ 𝕜 E := RestrictScalars.isScalarTower _ _ _
  letI : NormedSpace ℝ E := NormedSpace.restrictScalars _ 𝕜 _
  -- Let `fr: p →L[ℝ] ℝ` be the real part of `f`.
  let fr := reClm.comp (f.restrictScalars ℝ)
  -- Use the real version to get a norm-preserving extension of `fr`, which
  -- we'll call `g : E →L[ℝ] ℝ`.
  rcases Real.exists_extension_norm_eq (p.restrictScalars ℝ) fr with ⟨g, ⟨hextends, hnormeq⟩⟩
  -- Now `g` can be extended to the `E →L[𝕜] 𝕜` we need.
  refine' ⟨g.extendTo𝕜, _⟩
  -- It is an extension of `f`.
  have h : ∀ x : p, g.extendTo𝕜 x = f x := by
    intro x
    -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
    erw [ContinuousLinearMap.extendTo𝕜_apply, ← Submodule.coe_smul, hextends, hextends]
    have : (fr x : 𝕜) - I * ↑(fr (I • x)) = (re (f x) : 𝕜) - (I : 𝕜) * re (f ((I : 𝕜) • x)) := by
      rfl
    -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
    erw [this]
    apply ext
    · simp only [add_zero, Algebra.id.smul_eq_mul, I_re, ofReal_im, AddMonoidHom.map_add, zero_sub,
        I_im', zero_mul, ofReal_re, eq_self_iff_true, sub_zero, mul_neg, ofReal_neg,
        mul_re, mul_zero, sub_neg_eq_add, ContinuousLinearMap.map_smul]
    · simp only [Algebra.id.smul_eq_mul, I_re, ofReal_im, AddMonoidHom.map_add, zero_sub, I_im',
        zero_mul, ofReal_re, mul_neg, mul_im, zero_add, ofReal_neg, mul_re,
        sub_neg_eq_add, ContinuousLinearMap.map_smul]
  -- And we derive the equality of the norms by bounding on both sides.
  refine' ⟨h, le_antisymm _ _⟩
  · calc
      ‖g.extendTo𝕜‖ = ‖g‖ := g.norm_extendTo𝕜
      _ = ‖fr‖ := hnormeq
      _ ≤ ‖reClm‖ * ‖f‖ := (ContinuousLinearMap.op_norm_comp_le _ _)
      _ = ‖f‖ := by 

Proof state:
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
E : Type u_2
F : Type u_3
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : NormedSpace 𝕜 F
p : Subspace 𝕜 E
f : ↥p →L[𝕜] 𝕜
this✝¹ : Module ℝ E := RestrictScalars.module ℝ 𝕜 E
this✝ : IsScalarTower ℝ 𝕜 E := RestrictScalars.isScalarTower ℝ 𝕜 E
this : NormedSpace ℝ E := NormedSpace.restrictScalars ℝ 𝕜 E
fr : ↥p →L[ℝ] ℝ := ContinuousLinearMap.comp reClm (ContinuousLinearMap.restrictScalars ℝ f)
g : E →L[ℝ] ℝ
hextends : ∀ (x : ↥(Submodule.restrictScalars ℝ p)), g ↑x = fr x
hnormeq : ‖g‖ = ‖fr‖
h : ∀ (x : ↥p), (ContinuousLinearMap.extendTo𝕜 g) ↑x = f x
⊢ ‖reClm‖ * ‖f‖ = ‖f‖

Next tactic:
rw [reClm_norm, one_mul]
/-- **Hahn-Banach theorem** for continuous linear functions over `𝕜` satisfying `IsROrC 𝕜`. -/
theorem exists_extension_norm_eq (p : Subspace 𝕜 E) (f : p →L[𝕜] 𝕜) :
    ∃ g : E →L[𝕜] 𝕜, (∀ x : p, g x = f x) ∧ ‖g‖ = ‖f‖ := by
  letI : Module ℝ E := RestrictScalars.module ℝ 𝕜 E
  letI : IsScalarTower ℝ 𝕜 E := RestrictScalars.isScalarTower _ _ _
  letI : NormedSpace ℝ E := NormedSpace.restrictScalars _ 𝕜 _
  -- Let `fr: p →L[ℝ] ℝ` be the real part of `f`.
  let fr := reClm.comp (f.restrictScalars ℝ)
  -- Use the real version to get a norm-preserving extension of `fr`, which
  -- we'll call `g : E →L[ℝ] ℝ`.
  rcases Real.exists_extension_norm_eq (p.restrictScalars ℝ) fr with ⟨g, ⟨hextends, hnormeq⟩⟩
  -- Now `g` can be extended to the `E →L[𝕜] 𝕜` we need.
  refine' ⟨g.extendTo𝕜, _⟩
  -- It is an extension of `f`.
  have h : ∀ x : p, g.extendTo𝕜 x = f x := by
    intro x
    -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
    erw [ContinuousLinearMap.extendTo𝕜_apply, ← Submodule.coe_smul, hextends, hextends]
    have : (fr x : 𝕜) - I * ↑(fr (I • x)) = (re (f x) : 𝕜) - (I : 𝕜) * re (f ((I : 𝕜) • x)) := by
      rfl
    -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
    erw [this]
    apply ext
    · simp only [add_zero, Algebra.id.smul_eq_mul, I_re, ofReal_im, AddMonoidHom.map_add, zero_sub,
        I_im', zero_mul, ofReal_re, eq_self_iff_true, sub_zero, mul_neg, ofReal_neg,
        mul_re, mul_zero, sub_neg_eq_add, ContinuousLinearMap.map_smul]
    · simp only [Algebra.id.smul_eq_mul, I_re, ofReal_im, AddMonoidHom.map_add, zero_sub, I_im',
        zero_mul, ofReal_re, mul_neg, mul_im, zero_add, ofReal_neg, mul_re,
        sub_neg_eq_add, ContinuousLinearMap.map_smul]
  -- And we derive the equality of the norms by bounding on both sides.
  refine' ⟨h, le_antisymm _ _⟩
  · calc
      ‖g.extendTo𝕜‖ = ‖g‖ := g.norm_extendTo𝕜
      _ = ‖fr‖ := hnormeq
      _ ≤ ‖reClm‖ * ‖f‖ := (ContinuousLinearMap.op_norm_comp_le _ _)
      _ = ‖f‖ := by rw [reClm_norm, one_mul]
  · 

Proof state:
case intro.intro.refine'_2
𝕜 : Type u_1
inst✝⁴ : IsROrC 𝕜
E : Type u_2
F : Type u_3
inst✝³ : SeminormedAddCommGroup E
inst✝² : NormedSpace 𝕜 E
inst✝¹ : NormedAddCommGroup F
inst✝ : NormedSpace 𝕜 F
p : Subspace 𝕜 E
f : ↥p →L[𝕜] 𝕜
this✝¹ : Module ℝ E := RestrictScalars.module ℝ 𝕜 E
this✝ : IsScalarTower ℝ 𝕜 E := RestrictScalars.isScalarTower ℝ 𝕜 E
this : NormedSpace ℝ E := NormedSpace.restrictScalars ℝ 𝕜 E
fr : ↥p →L[ℝ] ℝ := ContinuousLinearMap.comp reClm (ContinuousLinearMap.restrictScalars ℝ f)
g : E →L[ℝ] ℝ
hextends : ∀ (x : ↥(Submodule.restrictScalars ℝ p)), g ↑x = fr x
hnormeq : ‖g‖ = ‖fr‖
h : ∀ (x : ↥p), (ContinuousLinearMap.extendTo𝕜 g) ↑x = f x
⊢ ‖f‖ ≤ ‖ContinuousLinearMap.extendTo𝕜 g‖

Next tactic:
exact f.op_norm_le_bound g.extendTo𝕜.op_norm_nonneg fun x => h x ▸ g.extendTo𝕜.le_op_norm x
/-- Corollary of the **Hahn-Banach theorem**: if `f : p → F` is a continuous linear map
from a submodule of a normed space `E` over `𝕜`, `𝕜 = ℝ` or `𝕜 = ℂ`,
with a finite dimensional range,
then `f` admits an extension to a continuous linear map `E → F`.

Note that contrary to the case `F = 𝕜`, see `exists_extension_norm_eq`,
we provide no estimates on the norm of the extension.
-/
lemma ContinuousLinearMap.exist_extension_of_finiteDimensional_range {p : Submodule 𝕜 E}
    (f : p →L[𝕜] F) [FiniteDimensional 𝕜 (LinearMap.range f)] :
    ∃ g : E →L[𝕜] F, f = g.comp p.subtypeL := by
  

Proof state:
𝕜 : Type u_1
inst✝⁵ : IsROrC 𝕜
E : Type u_2
F : Type u_3
inst✝⁴ : SeminormedAddCommGroup E
inst✝³ : NormedSpace 𝕜 E
inst✝² : NormedAddCommGroup F
inst✝¹ : NormedSpace 𝕜 F
p : Submodule 𝕜 E
f : ↥p →L[𝕜] F
inst✝ : FiniteDimensional 𝕜 ↥(LinearMap.range f)
⊢ ∃ g, f = comp g (Submodule.subtypeL p)

Next tactic:
set b := finBasis 𝕜 (LinearMap.range f)
/-- Corollary of the **Hahn-Banach theorem**: if `f : p → F` is a continuous linear map
from a submodule of a normed space `E` over `𝕜`, `𝕜 = ℝ` or `𝕜 = ℂ`,
with a finite dimensional range,
then `f` admits an extension to a continuous linear map `E → F`.

Note that contrary to the case `F = 𝕜`, see `exists_extension_norm_eq`,
we provide no estimates on the norm of the extension.
-/
lemma ContinuousLinearMap.exist_extension_of_finiteDimensional_range {p : Submodule 𝕜 E}
    (f : p →L[𝕜] F) [FiniteDimensional 𝕜 (LinearMap.range f)] :
    ∃ g : E →L[𝕜] F, f = g.comp p.subtypeL := by
  set b := finBasis 𝕜 (LinearMap.range f)
  

Proof state:
𝕜 : Type u_1
inst✝⁵ : IsROrC 𝕜
E : Type u_2
F : Type u_3
inst✝⁴ : SeminormedAddCommGroup E
inst✝³ : NormedSpace 𝕜 E
inst✝² : NormedAddCommGroup F
inst✝¹ : NormedSpace 𝕜 F
p : Submodule 𝕜 E
f : ↥p →L[𝕜] F
inst✝ : FiniteDimensional 𝕜 ↥(LinearMap.range f)
b : Basis (Fin (finrank 𝕜 ↥(LinearMap.range f))) 𝕜 ↥(LinearMap.range f) := finBasis 𝕜 ↥(LinearMap.range f)
⊢ ∃ g, f = comp g (Submodule.subtypeL p)

Next tactic:
set e := b.equivFunL
/-- Corollary of the **Hahn-Banach theorem**: if `f : p → F` is a continuous linear map
from a submodule of a normed space `E` over `𝕜`, `𝕜 = ℝ` or `𝕜 = ℂ`,
with a finite dimensional range,
then `f` admits an extension to a continuous linear map `E → F`.

Note that contrary to the case `F = 𝕜`, see `exists_extension_norm_eq`,
we provide no estimates on the norm of the extension.
-/
lemma ContinuousLinearMap.exist_extension_of_finiteDimensional_range {p : Submodule 𝕜 E}
    (f : p →L[𝕜] F) [FiniteDimensional 𝕜 (LinearMap.range f)] :
    ∃ g : E →L[𝕜] F, f = g.comp p.subtypeL := by
  set b := finBasis 𝕜 (LinearMap.range f)
  set e := b.equivFunL
  

Proof state:
𝕜 : Type u_1
inst✝⁵ : IsROrC 𝕜
E : Type u_2
F : Type u_3
inst✝⁴ : SeminormedAddCommGroup E
inst✝³ : NormedSpace 𝕜 E
inst✝² : NormedAddCommGroup F
inst✝¹ : NormedSpace 𝕜 F
p : Submodule 𝕜 E
f : ↥p →L[𝕜] F
inst✝ : FiniteDimensional 𝕜 ↥(LinearMap.range f)
b : Basis (Fin (finrank 𝕜 ↥(LinearMap.range f))) 𝕜 ↥(LinearMap.range f) := finBasis 𝕜 ↥(LinearMap.range f)
e : ↥(LinearMap.range f) ≃L[𝕜] Fin (finrank 𝕜 ↥(LinearMap.range f)) → 𝕜 := Basis.equivFunL b
⊢ ∃ g, f = comp g (Submodule.subtypeL p)

Next tactic:
set fi := fun i ↦ (LinearMap.toContinuousLinearMap (b.coord i)).comp
    (f.codRestrict _ <| LinearMap.mem_range_self _)
/-- Corollary of the **Hahn-Banach theorem**: if `f : p → F` is a continuous linear map
from a submodule of a normed space `E` over `𝕜`, `𝕜 = ℝ` or `𝕜 = ℂ`,
with a finite dimensional range,
then `f` admits an extension to a continuous linear map `E → F`.

Note that contrary to the case `F = 𝕜`, see `exists_extension_norm_eq`,
we provide no estimates on the norm of the extension.
-/
lemma ContinuousLinearMap.exist_extension_of_finiteDimensional_range {p : Submodule 𝕜 E}
    (f : p →L[𝕜] F) [FiniteDimensional 𝕜 (LinearMap.range f)] :
    ∃ g : E →L[𝕜] F, f = g.comp p.subtypeL := by
  set b := finBasis 𝕜 (LinearMap.range f)
  set e := b.equivFunL
  set fi := fun i ↦ (LinearMap.toContinuousLinearMap (b.coord i)).comp
    (f.codRestrict _ <| LinearMap.mem_range_self _)
  

Proof state:
𝕜 : Type u_1
inst✝⁵ : IsROrC 𝕜
E : Type u_2
F : Type u_3
inst✝⁴ : SeminormedAddCommGroup E
inst✝³ : NormedSpace 𝕜 E
inst✝² : NormedAddCommGroup F
inst✝¹ : NormedSpace 𝕜 F
p : Submodule 𝕜 E
f : ↥p →L[𝕜] F
inst✝ : FiniteDimensional 𝕜 ↥(LinearMap.range f)
b : Basis (Fin (finrank 𝕜 ↥(LinearMap.range f))) 𝕜 ↥(LinearMap.range f) := finBasis 𝕜 ↥(LinearMap.range f)
e : ↥(LinearMap.range f) ≃L[𝕜] Fin (finrank 𝕜 ↥(LinearMap.range f)) → 𝕜 := Basis.equivFunL b
fi : Fin (finrank 𝕜 ↥(LinearMap.range f)) → ↥p →L[𝕜] 𝕜 :=
  fun i =>
    comp (LinearMap.toContinuousLinearMap (Basis.coord b i))
      (codRestrict f (LinearMap.range f) (_ : ∀ (x : ↥p), f x ∈ LinearMap.range f))
⊢ ∃ g, f = comp g (Submodule.subtypeL p)

Next tactic:
choose gi hgf _ using fun i ↦ exists_extension_norm_eq p (fi i)
/-- Corollary of the **Hahn-Banach theorem**: if `f : p → F` is a continuous linear map
from a submodule of a normed space `E` over `𝕜`, `𝕜 = ℝ` or `𝕜 = ℂ`,
with a finite dimensional range,
then `f` admits an extension to a continuous linear map `E → F`.

Note that contrary to the case `F = 𝕜`, see `exists_extension_norm_eq`,
we provide no estimates on the norm of the extension.
-/
lemma ContinuousLinearMap.exist_extension_of_finiteDimensional_range {p : Submodule 𝕜 E}
    (f : p →L[𝕜] F) [FiniteDimensional 𝕜 (LinearMap.range f)] :
    ∃ g : E →L[𝕜] F, f = g.comp p.subtypeL := by
  set b := finBasis 𝕜 (LinearMap.range f)
  set e := b.equivFunL
  set fi := fun i ↦ (LinearMap.toContinuousLinearMap (b.coord i)).comp
    (f.codRestrict _ <| LinearMap.mem_range_self _)
  choose gi hgf _ using fun i ↦ exists_extension_norm_eq p (fi i)
  

Proof state:
𝕜 : Type u_1
inst✝⁵ : IsROrC 𝕜
E : Type u_2
F : Type u_3
inst✝⁴ : SeminormedAddCommGroup E
inst✝³ : NormedSpace 𝕜 E
inst✝² : NormedAddCommGroup F
inst✝¹ : NormedSpace 𝕜 F
p : Submodule 𝕜 E
f : ↥p →L[𝕜] F
inst✝ : FiniteDimensional 𝕜 ↥(LinearMap.range f)
b : Basis (Fin (finrank 𝕜 ↥(LinearMap.range f))) 𝕜 ↥(LinearMap.range f) := finBasis 𝕜 ↥(LinearMap.range f)
e : ↥(LinearMap.range f) ≃L[𝕜] Fin (finrank 𝕜 ↥(LinearMap.range f)) → 𝕜 := Basis.equivFunL b
fi : Fin (finrank 𝕜 ↥(LinearMap.range f)) → ↥p →L[𝕜] 𝕜 :=
  fun i =>
    comp (LinearMap.toContinuousLinearMap (Basis.coord b i))
      (codRestrict f (LinearMap.range f) (_ : ∀ (x : ↥p), f x ∈ LinearMap.range f))
gi : Fin (finrank 𝕜 ↥(LinearMap.range f)) → E →L[𝕜] 𝕜
hgf : ∀ (i : Fin (finrank 𝕜 ↥(LinearMap.range f))) (x : ↥p), (gi i) ↑x = (fi i) x
✝ : ∀ (i : Fin (finrank 𝕜 ↥(LinearMap.range f))), ‖gi i‖ = ‖fi i‖
⊢ ∃ g, f = comp g (Submodule.subtypeL p)

Next tactic:
use (LinearMap.range f).subtypeL.comp <| e.symm.toContinuousLinearMap.comp (.pi gi)