l3lab/ntp-mathlib huggingface dataset:
theorem closure_sup_closure (x y : α) : c (c x ⊔ c y) = c (x ⊔ y) := by
  

Proof state:
α : Type u_1
ι : Sort u_2
κ : ι → Sort u_3
inst✝ : SemilatticeSup α
c : ClosureOperator α
x y : α
⊢ c (c x ⊔ c y) = c (x ⊔ y)

Next tactic:
rw [closure_sup_closure_left, closure_sup_closure_right]
/-- Define a closure operator from a predicate that's preserved under infima. -/
@[simps!]
def ofCompletePred (p : α → Prop) (hsinf : ∀ s, (∀ a ∈ s, p a) → p (sInf s)) : ClosureOperator α :=
  ofPred (fun a ↦ ⨅ b : {b // a ≤ b ∧ p b}, b) p
    (fun a ↦ by 

Proof state:
α : Type u_1
ι : Sort u_2
κ : ι → Sort u_3
inst✝ : CompleteLattice α
c : ClosureOperator α
p✝ p : α → Prop
hsinf : ∀ (s : Set α), (∀ a ∈ s, p a) → p (sInf s)
a : α
⊢ a ≤ (fun a => ⨅ b, ↑b) a

Next tactic:
simp [forall_swap]
@[ext]
theorem ext : ∀ l₁ l₂ : LowerAdjoint u, (l₁ : α → β) = (l₂ : α → β) → l₁ = l₂
  | ⟨l₁, _⟩, ⟨l₂, _⟩, h => by
    

Proof state:
α : Type u_1
ι : Sort u_2
κ : ι → Sort u_3
β : Type u_4
inst✝¹ : Preorder α
inst✝ : Preorder β
u : β → α
l : LowerAdjoint u
l₁ : α → β
gc'✝¹ : GaloisConnection l₁ u
l₂ : α → β
gc'✝ : GaloisConnection l₂ u
h : { toFun := l₁, gc' := gc'✝¹ }.toFun = { toFun := l₂, gc' := gc'✝ }.toFun
⊢ { toFun := l₁, gc' := gc'✝¹ } = { toFun := l₂, gc' := gc'✝ }

Next tactic:
congr
theorem mem_iff (s : Set β) (x : β) : x ∈ l s ↔ ∀ S : α, s ⊆ S → x ∈ S := by
  

Proof state:
α : Type u_1
ι : Sort u_2
κ : ι → Sort u_3
β : Type u_4
inst✝ : SetLike α β
l : LowerAdjoint SetLike.coe
s : Set β
x : β
⊢ x ∈ toFun l s ↔ ∀ (S : α), s ⊆ ↑S → x ∈ S

Next tactic:
simp_rw [← SetLike.mem_coe, ← Set.singleton_subset_iff, ← l.le_iff_subset]
theorem mem_iff (s : Set β) (x : β) : x ∈ l s ↔ ∀ S : α, s ⊆ S → x ∈ S := by
  simp_rw [← SetLike.mem_coe, ← Set.singleton_subset_iff, ← l.le_iff_subset]
  

Proof state:
α : Type u_1
ι : Sort u_2
κ : ι → Sort u_3
β : Type u_4
inst✝ : SetLike α β
l : LowerAdjoint SetLike.coe
s : Set β
x : β
⊢ toFun l {x} ≤ toFun l s ↔ ∀ (S : α), toFun l s ≤ S → toFun l {x} ≤ S

Next tactic:
exact ⟨fun h S => h.trans, fun h => h _ le_rfl⟩
theorem closure_union_closure (x y : α) : l (l x ∪ l y) = l (x ∪ y) := by
  

Proof state:
α : Type u_1
ι : Sort u_2
κ : ι → Sort u_3
β : Type u_4
inst✝ : SetLike α β
l : LowerAdjoint SetLike.coe
x y : α
⊢ toFun l (↑(toFun l ↑x) ∪ ↑(toFun l ↑y)) = toFun l (↑x ∪ ↑y)

Next tactic:
rw [closure_union_closure_right, closure_union_closure_left]
/-- The Galois insertion associated to a closure operator can be used to reconstruct the closure
operator.
Note that the inverse in the opposite direction does not hold in general. -/
@[simp]
theorem closureOperator_gi_self [PartialOrder α] (c : ClosureOperator α) :
    c.gi.gc.closureOperator = c := by
  

Proof state:
α : Type u_1
ι : Sort u_2
κ : ι → Sort u_3
β : Type u_4
inst✝ : PartialOrder α
c : ClosureOperator α
⊢ GaloisConnection.closureOperator (_ : GaloisConnection (ClosureOperator.toCloseds c) Subtype.val) = c

Next tactic:
ext x
/-- The Galois insertion associated to a closure operator can be used to reconstruct the closure
operator.
Note that the inverse in the opposite direction does not hold in general. -/
@[simp]
theorem closureOperator_gi_self [PartialOrder α] (c : ClosureOperator α) :
    c.gi.gc.closureOperator = c := by
  ext x
  

Proof state:
case a.h
α : Type u_1
ι : Sort u_2
κ : ι → Sort u_3
β : Type u_4
inst✝ : PartialOrder α
c : ClosureOperator α
x : α
⊢ (GaloisConnection.closureOperator (_ : GaloisConnection (ClosureOperator.toCloseds c) Subtype.val)) x = c x

Next tactic:
rfl
protected theorem DifferentiableAt.inversion (hc : DifferentiableAt ℝ c a)
    (hR : DifferentiableAt ℝ R a) (hx : DifferentiableAt ℝ x a) (hne : x a ≠ c a) :
    DifferentiableAt ℝ (fun a ↦ inversion (c a) (R a) (x a)) a := by
  

Proof state:
E : Type u_1
F : Type u_2
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
c x : E → F
R : E → ℝ
s : Set E
a : E
n : ℕ∞
hc : DifferentiableAt ℝ c a
hR : DifferentiableAt ℝ R a
hx : DifferentiableAt ℝ x a
hne : x a ≠ c a
⊢ DifferentiableAt ℝ (fun a => inversion (c a) (R a) (x a)) a

Next tactic:
rw [← differentiableWithinAt_univ] at *
protected theorem DifferentiableAt.inversion (hc : DifferentiableAt ℝ c a)
    (hR : DifferentiableAt ℝ R a) (hx : DifferentiableAt ℝ x a) (hne : x a ≠ c a) :
    DifferentiableAt ℝ (fun a ↦ inversion (c a) (R a) (x a)) a := by
  rw [← differentiableWithinAt_univ] at *
  

Proof state:
E : Type u_1
F : Type u_2
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
c x : E → F
R : E → ℝ
s : Set E
a : E
n : ℕ∞
hc : DifferentiableWithinAt ℝ c univ a
hR : DifferentiableWithinAt ℝ R univ a
hx : DifferentiableWithinAt ℝ x univ a
hne : x a ≠ c a
⊢ DifferentiableWithinAt ℝ (fun a => inversion (c a) (R a) (x a)) univ a

Next tactic:
exact hc.inversion hR hx hne
/-- Formula for the Fréchet derivative of `EuclideanGeometry.inversion c R`. -/
theorem hasFDerivAt_inversion (hx : x ≠ c) :
    HasFDerivAt (inversion c R)
      ((R / dist x c) ^ 2 • (reflection (ℝ ∙ (x - c))ᗮ : F →L[ℝ] F)) x := by
  

Proof state:
E : Type u_1
F : Type u_2
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
a b c d x y z : F
r R : ℝ
hx : x ≠ c
⊢ HasFDerivAt (inversion c R)
    ((R / dist x c) ^ 2 • ↑(ContinuousLinearEquiv.mk (reflection (Submodule.span ℝ {x - c})ᗮ).toLinearEquiv)) x

Next tactic:
rcases add_left_surjective c x with ⟨x, rfl⟩
/-- Formula for the Fréchet derivative of `EuclideanGeometry.inversion c R`. -/
theorem hasFDerivAt_inversion (hx : x ≠ c) :
    HasFDerivAt (inversion c R)
      ((R / dist x c) ^ 2 • (reflection (ℝ ∙ (x - c))ᗮ : F →L[ℝ] F)) x := by
  rcases add_left_surjective c x with ⟨x, rfl⟩
  

Proof state:
case intro
E : Type u_1
F : Type u_2
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
a b c d y z : F
r R : ℝ
x : F
hx : (fun x => c + x) x ≠ c
⊢ HasFDerivAt (inversion c R)
    ((R / dist ((fun x => c + x) x) c) ^ 2 •
      ↑(ContinuousLinearEquiv.mk (reflection (Submodule.span ℝ {(fun x => c + x) x - c})ᗮ).toLinearEquiv))
    ((fun x => c + x) x)

Next tactic:
have : HasFDerivAt (inversion c R) (_ : F →L[ℝ] F) (c + x) := by
    simp (config := { unfoldPartialApp := true }) only [inversion]
    simp_rw [dist_eq_norm, div_pow, div_eq_mul_inv]
    have A := (hasFDerivAt_id (𝕜 := ℝ) (c + x)).sub_const c
    have B := ((hasDerivAt_inv <| by simpa using hx).comp_hasFDerivAt _ A.norm_sq).const_mul
      (R ^ 2)
    exact (B.smul A).add_const c
/-- Formula for the Fréchet derivative of `EuclideanGeometry.inversion c R`. -/
theorem hasFDerivAt_inversion (hx : x ≠ c) :
    HasFDerivAt (inversion c R)
      ((R / dist x c) ^ 2 • (reflection (ℝ ∙ (x - c))ᗮ : F →L[ℝ] F)) x := by
  rcases add_left_surjective c x with ⟨x, rfl⟩
  have : HasFDerivAt (inversion c R) (_ : F →L[ℝ] F) (c + x) := by
    

Proof state:
E : Type u_1
F : Type u_2
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
a b c d y z : F
r R : ℝ
x : F
hx : (fun x => c + x) x ≠ c
⊢ HasFDerivAt (inversion c R) ?m.24810 (c + x)

Next tactic:
simp (config := { unfoldPartialApp := true }) only [inversion]
/-- Formula for the Fréchet derivative of `EuclideanGeometry.inversion c R`. -/
theorem hasFDerivAt_inversion (hx : x ≠ c) :
    HasFDerivAt (inversion c R)
      ((R / dist x c) ^ 2 • (reflection (ℝ ∙ (x - c))ᗮ : F →L[ℝ] F)) x := by
  rcases add_left_surjective c x with ⟨x, rfl⟩
  have : HasFDerivAt (inversion c R) (_ : F →L[ℝ] F) (c + x) := by
    simp (config := { unfoldPartialApp := true }) only [inversion]
    

Proof state:
E : Type u_1
F : Type u_2
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
a b c d y z : F
r R : ℝ
x : F
hx : (fun x => c + x) x ≠ c
⊢ HasFDerivAt (fun x => (R / dist x c) ^ 2 • (x -ᵥ c) +ᵥ c) ?m.24810 (c + x)

Next tactic:
simp_rw [dist_eq_norm, div_pow, div_eq_mul_inv]
/-- Formula for the Fréchet derivative of `EuclideanGeometry.inversion c R`. -/
theorem hasFDerivAt_inversion (hx : x ≠ c) :
    HasFDerivAt (inversion c R)
      ((R / dist x c) ^ 2 • (reflection (ℝ ∙ (x - c))ᗮ : F →L[ℝ] F)) x := by
  rcases add_left_surjective c x with ⟨x, rfl⟩
  have : HasFDerivAt (inversion c R) (_ : F →L[ℝ] F) (c + x) := by
    simp (config := { unfoldPartialApp := true }) only [inversion]
    simp_rw [dist_eq_norm, div_pow, div_eq_mul_inv]
    

Proof state:
E : Type u_1
F : Type u_2
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
a b c d y z : F
r R : ℝ
x : F
hx : (fun x => c + x) x ≠ c
⊢ HasFDerivAt (fun x => (R ^ 2 * (‖x - c‖ ^ 2)⁻¹) • (x -ᵥ c) +ᵥ c) ?m.24810 (c + x)

Next tactic:
have A := (hasFDerivAt_id (𝕜 := ℝ) (c + x)).sub_const c
/-- Formula for the Fréchet derivative of `EuclideanGeometry.inversion c R`. -/
theorem hasFDerivAt_inversion (hx : x ≠ c) :
    HasFDerivAt (inversion c R)
      ((R / dist x c) ^ 2 • (reflection (ℝ ∙ (x - c))ᗮ : F →L[ℝ] F)) x := by
  rcases add_left_surjective c x with ⟨x, rfl⟩
  have : HasFDerivAt (inversion c R) (_ : F →L[ℝ] F) (c + x) := by
    simp (config := { unfoldPartialApp := true }) only [inversion]
    simp_rw [dist_eq_norm, div_pow, div_eq_mul_inv]
    have A := (hasFDerivAt_id (𝕜 := ℝ) (c + x)).sub_const c
    

Proof state:
E : Type u_1
F : Type u_2
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
a b c d y z : F
r R : ℝ
x : F
hx : (fun x => c + x) x ≠ c
A : HasFDerivAt (fun x => _root_.id x - c) (ContinuousLinearMap.id ℝ F) (c + x)
⊢ HasFDerivAt (fun x => (R ^ 2 * (‖x - c‖ ^ 2)⁻¹) • (x -ᵥ c) +ᵥ c) ?m.24810 (c + x)

Next tactic:
have B := ((hasDerivAt_inv <| by simpa using hx).comp_hasFDerivAt _ A.norm_sq).const_mul
      (R ^ 2)
/-- Formula for the Fréchet derivative of `EuclideanGeometry.inversion c R`. -/
theorem hasFDerivAt_inversion (hx : x ≠ c) :
    HasFDerivAt (inversion c R)
      ((R / dist x c) ^ 2 • (reflection (ℝ ∙ (x - c))ᗮ : F →L[ℝ] F)) x := by
  rcases add_left_surjective c x with ⟨x, rfl⟩
  have : HasFDerivAt (inversion c R) (_ : F →L[ℝ] F) (c + x) := by
    simp (config := { unfoldPartialApp := true }) only [inversion]
    simp_rw [dist_eq_norm, div_pow, div_eq_mul_inv]
    have A := (hasFDerivAt_id (𝕜 := ℝ) (c + x)).sub_const c
    have B := ((hasDerivAt_inv <| by 

Proof state:
E : Type u_1
F : Type u_2
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
a b c d y z : F
r R : ℝ
x : F
hx : (fun x => c + x) x ≠ c
A : HasFDerivAt (fun x => _root_.id x - c) (ContinuousLinearMap.id ℝ F) (c + x)
⊢ ‖_root_.id (c + x) - c‖ ^ 2 ≠ 0

Next tactic:
simpa using hx
/-- Formula for the Fréchet derivative of `EuclideanGeometry.inversion c R`. -/
theorem hasFDerivAt_inversion (hx : x ≠ c) :
    HasFDerivAt (inversion c R)
      ((R / dist x c) ^ 2 • (reflection (ℝ ∙ (x - c))ᗮ : F →L[ℝ] F)) x := by
  rcases add_left_surjective c x with ⟨x, rfl⟩
  have : HasFDerivAt (inversion c R) (_ : F →L[ℝ] F) (c + x) := by
    simp (config := { unfoldPartialApp := true }) only [inversion]
    simp_rw [dist_eq_norm, div_pow, div_eq_mul_inv]
    have A := (hasFDerivAt_id (𝕜 := ℝ) (c + x)).sub_const c
    have B := ((hasDerivAt_inv <| by simpa using hx).comp_hasFDerivAt _ A.norm_sq).const_mul
      (R ^ 2)
    

Proof state:
E : Type u_1
F : Type u_2
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
a b c d y z : F
r R : ℝ
x : F
hx : (fun x => c + x) x ≠ c
A : HasFDerivAt (fun x => _root_.id x - c) (ContinuousLinearMap.id ℝ F) (c + x)
B :
  HasFDerivAt (fun y => R ^ 2 * ((fun y => y⁻¹) ∘ fun x => ‖_root_.id x - c‖ ^ 2) y)
    (R ^ 2 •
      -((‖_root_.id (c + x) - c‖ ^ 2) ^ 2)⁻¹ •
        2 • ContinuousLinearMap.comp ((innerSL ℝ) (_root_.id (c + x) - c)) (ContinuousLinearMap.id ℝ F))
    (c + x)
⊢ HasFDerivAt (fun x => (R ^ 2 * (‖x - c‖ ^ 2)⁻¹) • (x -ᵥ c) +ᵥ c) ?m.24810 (c + x)

Next tactic:
exact (B.smul A).add_const c
/-- Formula for the Fréchet derivative of `EuclideanGeometry.inversion c R`. -/
theorem hasFDerivAt_inversion (hx : x ≠ c) :
    HasFDerivAt (inversion c R)
      ((R / dist x c) ^ 2 • (reflection (ℝ ∙ (x - c))ᗮ : F →L[ℝ] F)) x := by
  rcases add_left_surjective c x with ⟨x, rfl⟩
  have : HasFDerivAt (inversion c R) (_ : F →L[ℝ] F) (c + x) := by
    simp (config := { unfoldPartialApp := true }) only [inversion]
    simp_rw [dist_eq_norm, div_pow, div_eq_mul_inv]
    have A := (hasFDerivAt_id (𝕜 := ℝ) (c + x)).sub_const c
    have B := ((hasDerivAt_inv <| by simpa using hx).comp_hasFDerivAt _ A.norm_sq).const_mul
      (R ^ 2)
    exact (B.smul A).add_const c
  

Proof state:
case intro
E : Type u_1
F : Type u_2
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
a b c d y z : F
r R : ℝ
x : F
hx : (fun x => c + x) x ≠ c
this :
  HasFDerivAt (inversion c R)
    ((R ^ 2 * ((fun y => y⁻¹) ∘ fun x => ‖_root_.id x - c‖ ^ 2) (c + x)) • ContinuousLinearMap.id ℝ F +
      ContinuousLinearMap.smulRight
        (R ^ 2 •
          -((‖_root_.id (c + x) - c‖ ^ 2) ^ 2)⁻¹ •
            2 • ContinuousLinearMap.comp ((innerSL ℝ) (_root_.id (c + x) - c)) (ContinuousLinearMap.id ℝ F))
        (_root_.id (c + x) - c))
    (c + x)
⊢ HasFDerivAt (inversion c R)
    ((R / dist ((fun x => c + x) x) c) ^ 2 •
      ↑(ContinuousLinearEquiv.mk (reflection (Submodule.span ℝ {(fun x => c + x) x - c})ᗮ).toLinearEquiv))
    ((fun x => c + x) x)

Next tactic:
refine this.congr_fderiv (LinearMap.ext_on_codisjoint
    (Submodule.isCompl_orthogonal_of_completeSpace (K := ℝ ∙ x)).codisjoint
    (LinearMap.eqOn_span' ?_) fun y hy ↦ ?_)
/-- Formula for the Fréchet derivative of `EuclideanGeometry.inversion c R`. -/
theorem hasFDerivAt_inversion (hx : x ≠ c) :
    HasFDerivAt (inversion c R)
      ((R / dist x c) ^ 2 • (reflection (ℝ ∙ (x - c))ᗮ : F →L[ℝ] F)) x := by
  rcases add_left_surjective c x with ⟨x, rfl⟩
  have : HasFDerivAt (inversion c R) (_ : F →L[ℝ] F) (c + x) := by
    simp (config := { unfoldPartialApp := true }) only [inversion]
    simp_rw [dist_eq_norm, div_pow, div_eq_mul_inv]
    have A := (hasFDerivAt_id (𝕜 := ℝ) (c + x)).sub_const c
    have B := ((hasDerivAt_inv <| by simpa using hx).comp_hasFDerivAt _ A.norm_sq).const_mul
      (R ^ 2)
    exact (B.smul A).add_const c
  refine this.congr_fderiv (LinearMap.ext_on_codisjoint
    (Submodule.isCompl_orthogonal_of_completeSpace (K := ℝ ∙ x)).codisjoint
    (LinearMap.eqOn_span' ?_) fun y hy ↦ ?_)
  · 

Proof state:
case intro.refine_1
E : Type u_1
F : Type u_2
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
a b c d y z : F
r R : ℝ
x : F
hx : (fun x => c + x) x ≠ c
this :
  HasFDerivAt (inversion c R)
    ((R ^ 2 * ((fun y => y⁻¹) ∘ fun x => ‖_root_.id x - c‖ ^ 2) (c + x)) • ContinuousLinearMap.id ℝ F +
      ContinuousLinearMap.smulRight
        (R ^ 2 •
          -((‖_root_.id (c + x) - c‖ ^ 2) ^ 2)⁻¹ •
            2 • ContinuousLinearMap.comp ((innerSL ℝ) (_root_.id (c + x) - c)) (ContinuousLinearMap.id ℝ F))
        (_root_.id (c + x) - c))
    (c + x)
⊢ EqOn
    ⇑((R ^ 2 * ((fun y => y⁻¹) ∘ fun x => ‖_root_.id x - c‖ ^ 2) (c + x)) • ContinuousLinearMap.id ℝ F +
        ContinuousLinearMap.smulRight
          (R ^ 2 •
            -((‖_root_.id (c + x) - c‖ ^ 2) ^ 2)⁻¹ •
              2 • ContinuousLinearMap.comp ((innerSL ℝ) (_root_.id (c + x) - c)) (ContinuousLinearMap.id ℝ F))
          (_root_.id (c + x) - c))
    ⇑((R / dist ((fun x => c + x) x) c) ^ 2 •
        ↑(ContinuousLinearEquiv.mk (reflection (Submodule.span ℝ {(fun x => c + x) x - c})ᗮ).toLinearEquiv))
    {x}

Next tactic:
have : ((‖x‖ ^ 2) ^ 2)⁻¹ * (‖x‖ ^ 2) = (‖x‖ ^ 2)⁻¹ := by
      rw [← div_eq_inv_mul, sq (‖x‖ ^ 2), div_self_mul_self']
/-- Formula for the Fréchet derivative of `EuclideanGeometry.inversion c R`. -/
theorem hasFDerivAt_inversion (hx : x ≠ c) :
    HasFDerivAt (inversion c R)
      ((R / dist x c) ^ 2 • (reflection (ℝ ∙ (x - c))ᗮ : F →L[ℝ] F)) x := by
  rcases add_left_surjective c x with ⟨x, rfl⟩
  have : HasFDerivAt (inversion c R) (_ : F →L[ℝ] F) (c + x) := by
    simp (config := { unfoldPartialApp := true }) only [inversion]
    simp_rw [dist_eq_norm, div_pow, div_eq_mul_inv]
    have A := (hasFDerivAt_id (𝕜 := ℝ) (c + x)).sub_const c
    have B := ((hasDerivAt_inv <| by simpa using hx).comp_hasFDerivAt _ A.norm_sq).const_mul
      (R ^ 2)
    exact (B.smul A).add_const c
  refine this.congr_fderiv (LinearMap.ext_on_codisjoint
    (Submodule.isCompl_orthogonal_of_completeSpace (K := ℝ ∙ x)).codisjoint
    (LinearMap.eqOn_span' ?_) fun y hy ↦ ?_)
  · have : ((‖x‖ ^ 2) ^ 2)⁻¹ * (‖x‖ ^ 2) = (‖x‖ ^ 2)⁻¹ := by
      

Proof state:
E : Type u_1
F : Type u_2
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
a b c d y z : F
r R : ℝ
x : F
hx : (fun x => c + x) x ≠ c
this :
  HasFDerivAt (inversion c R)
    ((R ^ 2 * ((fun y => y⁻¹) ∘ fun x => ‖_root_.id x - c‖ ^ 2) (c + x)) • ContinuousLinearMap.id ℝ F +
      ContinuousLinearMap.smulRight
        (R ^ 2 •
          -((‖_root_.id (c + x) - c‖ ^ 2) ^ 2)⁻¹ •
            2 • ContinuousLinearMap.comp ((innerSL ℝ) (_root_.id (c + x) - c)) (ContinuousLinearMap.id ℝ F))
        (_root_.id (c + x) - c))
    (c + x)
⊢ ((‖x‖ ^ 2) ^ 2)⁻¹ * ‖x‖ ^ 2 = (‖x‖ ^ 2)⁻¹

Next tactic:
rw [← div_eq_inv_mul, sq (‖x‖ ^ 2), div_self_mul_self']
/-- Formula for the Fréchet derivative of `EuclideanGeometry.inversion c R`. -/
theorem hasFDerivAt_inversion (hx : x ≠ c) :
    HasFDerivAt (inversion c R)
      ((R / dist x c) ^ 2 • (reflection (ℝ ∙ (x - c))ᗮ : F →L[ℝ] F)) x := by
  rcases add_left_surjective c x with ⟨x, rfl⟩
  have : HasFDerivAt (inversion c R) (_ : F →L[ℝ] F) (c + x) := by
    simp (config := { unfoldPartialApp := true }) only [inversion]
    simp_rw [dist_eq_norm, div_pow, div_eq_mul_inv]
    have A := (hasFDerivAt_id (𝕜 := ℝ) (c + x)).sub_const c
    have B := ((hasDerivAt_inv <| by simpa using hx).comp_hasFDerivAt _ A.norm_sq).const_mul
      (R ^ 2)
    exact (B.smul A).add_const c
  refine this.congr_fderiv (LinearMap.ext_on_codisjoint
    (Submodule.isCompl_orthogonal_of_completeSpace (K := ℝ ∙ x)).codisjoint
    (LinearMap.eqOn_span' ?_) fun y hy ↦ ?_)
  · have : ((‖x‖ ^ 2) ^ 2)⁻¹ * (‖x‖ ^ 2) = (‖x‖ ^ 2)⁻¹ := by
      rw [← div_eq_inv_mul, sq (‖x‖ ^ 2), div_self_mul_self']
    

Proof state:
case intro.refine_1
E : Type u_1
F : Type u_2
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
a b c d y z : F
r R : ℝ
x : F
hx : (fun x => c + x) x ≠ c
this✝ :
  HasFDerivAt (inversion c R)
    ((R ^ 2 * ((fun y => y⁻¹) ∘ fun x => ‖_root_.id x - c‖ ^ 2) (c + x)) • ContinuousLinearMap.id ℝ F +
      ContinuousLinearMap.smulRight
        (R ^ 2 •
          -((‖_root_.id (c + x) - c‖ ^ 2) ^ 2)⁻¹ •
            2 • ContinuousLinearMap.comp ((innerSL ℝ) (_root_.id (c + x) - c)) (ContinuousLinearMap.id ℝ F))
        (_root_.id (c + x) - c))
    (c + x)
this : ((‖x‖ ^ 2) ^ 2)⁻¹ * ‖x‖ ^ 2 = (‖x‖ ^ 2)⁻¹
⊢ EqOn
    ⇑((R ^ 2 * ((fun y => y⁻¹) ∘ fun x => ‖_root_.id x - c‖ ^ 2) (c + x)) • ContinuousLinearMap.id ℝ F +
        ContinuousLinearMap.smulRight
          (R ^ 2 •
            -((‖_root_.id (c + x) - c‖ ^ 2) ^ 2)⁻¹ •
              2 • ContinuousLinearMap.comp ((innerSL ℝ) (_root_.id (c + x) - c)) (ContinuousLinearMap.id ℝ F))
          (_root_.id (c + x) - c))
    ⇑((R / dist ((fun x => c + x) x) c) ^ 2 •
        ↑(ContinuousLinearEquiv.mk (reflection (Submodule.span ℝ {(fun x => c + x) x - c})ᗮ).toLinearEquiv))
    {x}

Next tactic:
simp [reflection_orthogonalComplement_singleton_eq_neg, real_inner_self_eq_norm_sq,
      two_mul, this, div_eq_mul_inv, mul_add, add_smul, mul_pow]
/-- Formula for the Fréchet derivative of `EuclideanGeometry.inversion c R`. -/
theorem hasFDerivAt_inversion (hx : x ≠ c) :
    HasFDerivAt (inversion c R)
      ((R / dist x c) ^ 2 • (reflection (ℝ ∙ (x - c))ᗮ : F →L[ℝ] F)) x := by
  rcases add_left_surjective c x with ⟨x, rfl⟩
  have : HasFDerivAt (inversion c R) (_ : F →L[ℝ] F) (c + x) := by
    simp (config := { unfoldPartialApp := true }) only [inversion]
    simp_rw [dist_eq_norm, div_pow, div_eq_mul_inv]
    have A := (hasFDerivAt_id (𝕜 := ℝ) (c + x)).sub_const c
    have B := ((hasDerivAt_inv <| by simpa using hx).comp_hasFDerivAt _ A.norm_sq).const_mul
      (R ^ 2)
    exact (B.smul A).add_const c
  refine this.congr_fderiv (LinearMap.ext_on_codisjoint
    (Submodule.isCompl_orthogonal_of_completeSpace (K := ℝ ∙ x)).codisjoint
    (LinearMap.eqOn_span' ?_) fun y hy ↦ ?_)
  · have : ((‖x‖ ^ 2) ^ 2)⁻¹ * (‖x‖ ^ 2) = (‖x‖ ^ 2)⁻¹ := by
      rw [← div_eq_inv_mul, sq (‖x‖ ^ 2), div_self_mul_self']
    simp [reflection_orthogonalComplement_singleton_eq_neg, real_inner_self_eq_norm_sq,
      two_mul, this, div_eq_mul_inv, mul_add, add_smul, mul_pow]
  · 

Proof state:
case intro.refine_2
E : Type u_1
F : Type u_2
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
a b c d y✝ z : F
r R : ℝ
x : F
hx : (fun x => c + x) x ≠ c
this :
  HasFDerivAt (inversion c R)
    ((R ^ 2 * ((fun y => y⁻¹) ∘ fun x => ‖_root_.id x - c‖ ^ 2) (c + x)) • ContinuousLinearMap.id ℝ F +
      ContinuousLinearMap.smulRight
        (R ^ 2 •
          -((‖_root_.id (c + x) - c‖ ^ 2) ^ 2)⁻¹ •
            2 • ContinuousLinearMap.comp ((innerSL ℝ) (_root_.id (c + x) - c)) (ContinuousLinearMap.id ℝ F))
        (_root_.id (c + x) - c))
    (c + x)
y : F
hy : y ∈ ↑(Submodule.span ℝ {x})ᗮ
⊢ ((R ^ 2 * ((fun y => y⁻¹) ∘ fun x => ‖_root_.id x - c‖ ^ 2) (c + x)) • ContinuousLinearMap.id ℝ F +
        ContinuousLinearMap.smulRight
          (R ^ 2 •
            -((‖_root_.id (c + x) - c‖ ^ 2) ^ 2)⁻¹ •
              2 • ContinuousLinearMap.comp ((innerSL ℝ) (_root_.id (c + x) - c)) (ContinuousLinearMap.id ℝ F))
          (_root_.id (c + x) - c))
      y =
    ((R / dist ((fun x => c + x) x) c) ^ 2 •
        ↑(ContinuousLinearEquiv.mk (reflection (Submodule.span ℝ {(fun x => c + x) x - c})ᗮ).toLinearEquiv))
      y

Next tactic:
simp [Submodule.mem_orthogonal_singleton_iff_inner_right.1 hy,
      reflection_mem_subspace_eq_self hy, div_eq_mul_inv, mul_pow]
theorem ext {α : Sort*} : ∀ {s t : Setoid α},
    (∀ a b, @Setoid.r α s a b ↔ @Setoid.r α t a b) → s = t
  | ⟨r, _⟩, ⟨p, _⟩, Eq =>
  by 

Proof state:
α✝ : Sort u_1
β : Sort u_2
α : Sort u_3
r : α → α → Prop
iseqv✝¹ : Equivalence r
p : α → α → Prop
iseqv✝ : Equivalence p
Eq : ∀ (a b : α), Setoid.r a b ↔ Setoid.r a b
⊢ { r := r, iseqv := iseqv✝¹ } = { r := p, iseqv := iseqv✝ }

Next tactic:
have : r = p := funext fun a ↦ funext fun b ↦ propext <| Eq a b
theorem ext {α : Sort*} : ∀ {s t : Setoid α},
    (∀ a b, @Setoid.r α s a b ↔ @Setoid.r α t a b) → s = t
  | ⟨r, _⟩, ⟨p, _⟩, Eq =>
  by have : r = p := funext fun a ↦ funext fun b ↦ propext <| Eq a b
     

Proof state:
α✝ : Sort u_1
β : Sort u_2
α : Sort u_3
r : α → α → Prop
iseqv✝¹ : Equivalence r
p : α → α → Prop
iseqv✝ : Equivalence p
Eq : ∀ (a b : α), Setoid.r a b ↔ Setoid.r a b
this : r = p
⊢ { r := r, iseqv := iseqv✝¹ } = { r := p, iseqv := iseqv✝ }

Next tactic:
subst this
theorem ext {α : Sort*} : ∀ {s t : Setoid α},
    (∀ a b, @Setoid.r α s a b ↔ @Setoid.r α t a b) → s = t
  | ⟨r, _⟩, ⟨p, _⟩, Eq =>
  by have : r = p := funext fun a ↦ funext fun b ↦ propext <| Eq a b
     subst this
     

Proof state:
α✝ : Sort u_1
β : Sort u_2
α : Sort u_3
r : α → α → Prop
iseqv✝¹ iseqv✝ : Equivalence r
Eq : ∀ (a b : α), Setoid.r a b ↔ Setoid.r a b
⊢ { r := r, iseqv := iseqv✝¹ } = { r := r, iseqv := iseqv✝ }

Next tactic:
rfl