Eine aufbereitete Darstellung der Quelle

 
     
 
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung


Quelle  Operations.lean   Sprache: Lean

 

/-
Copyright (c) 2019 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel, Floris van Doorn
-/

module

public import Mathlib.Analysis.Calculus.ContDiff.Comp
public import Mathlib.Analysis.Calculus.Deriv.Inverse
public import Mathlib.Topology.OpenPartialHomeomorph.IsImage

import Mathlib.Analysis.Calculus.FDeriv.OfCompLeft

/-!
# Higher differentiability of usual operations

We prove that the usual operations (addition, multiplication, difference, and
so on) preserve `C^n` functions.

## Notation

We use the notation `E [×n]→L[��] F` for the space of continuous multilinear maps on `E^n` with
values in `F`. This is the space in which the `n`-th derivative of a function from `E` to `F` lives.

In this file, we denote `WithTop ℕ∞` with `ℕ∞ω`, `(⊤ : ℕ∞) : ℕ∞ω` with `∞` and `⊤ : ℕ∞ω` with `ω`.

## Tags

derivative, differentiability, higher derivative, `C^n`, multilinear, Taylor series, formal series
-/


@[expose] public section

open scoped NNReal Nat ContDiff

universe u uE uF uG

attribute [local instance 1001]
  NormedAddCommGroup.toAddCommGroup AddCommGroup.toAddCommMonoid

open Set Fin Filter Function

open scoped Topology

variable {�� : Type*} [NontriviallyNormedField ��]
  {E : Type uE} [NormedAddCommGroup E] [NormedSpace �� E] {F : Type uF}
  [NormedAddCommGroup F] [NormedSpace �� F] {G : Type uG} [NormedAddCommGroup G] [NormedSpace �� G]
  {X : Type*} [NormedAddCommGroup X] [NormedSpace �� X] {s t : Set E} {f : E → F}
  {g : F → G} {x x₀ : E} {b : E × F → G} {m n : ℕ∞ω} {p : E → FormalMultilinearSeries �� E F}

/-!
### Smoothness of functions `f : E → Π i, F' i`
-/


section Pi

variable {ι ι' : Type*} [Fintype ι] [Fintype ι'] {F' : ι → Type*} [∀ i, NormedAddCommGroup (F' i)]
  [∀ i, NormedSpace �� (F' i)] {φ : ∀ i, E → F' i} {p' : ∀ i, E → FormalMultilinearSeries �� E (F' i)}
  {Φ : E → ∀ i, F' i} {P' : E → FormalMultilinearSeries �� E (∀ i, F' i)}

theorem hasFTaylorSeriesUpToOn_pi {n : ℕ∞ω} :
    HasFTaylorSeriesUpToOn n (fun x i => φ i x)
        (fun x m => ContinuousMultilinearMap.pi fun i => p' i x m) s ↔
      ∀ i, HasFTaylorSeriesUpToOn n (φ i) (p' i) s := by
  set pr := @ContinuousLinearMap.proj �� _ ι F' _ _ _
  set L : ∀ m : ℕ, (∀ i, E [×m]→L[��] F' i) ≃ₗᵢ[��] E [×m]→L[��] ∀ i, F' i := fun m =>
    ContinuousMultilinearMap.piₗᵢ _ _
  refine ⟨fun h i => ?_, fun h => ⟨fun x hx => ?_, ?_, ?_⟩⟩
  · exact h.continuousLinearMap_comp (pr i)
  · ext1 i
    exact (h i).zero_eq x hx
  · intro m hm x hx
    exact (L m).hasFDerivAt.comp_hasFDerivWithinAt x <|
      hasFDerivWithinAt_pi.2 fun i => (h i).fderivWithin m hm x hx
  · intro m hm
    exact (L m).continuous.comp_continuousOn <| continuousOn_pi.2 fun i => (h i).cont m hm

@[simp]
theorem hasFTaylorSeriesUpToOn_pi' {n : ℕ∞ω} :
    HasFTaylorSeriesUpToOn n Φ P' s ↔
      ∀ i, HasFTaylorSeriesUpToOn n (fun x => Φ x i)
        (fun x m => (@ContinuousLinearMap.proj �� _ ι F' _ _ _ i).compContinuousMultilinearMap
          (P' x m)) s := by
  convert! hasFTaylorSeriesUpToOn_pi (�� := ��) (φ := fun i x ↦ Φ x i); ext; rfl

theorem contDiffWithinAt_pi :
    ContDiffWithinAt �� n Φ s x ↔ ∀ i, ContDiffWithinAt �� n (fun x => Φ x i) s x := by
  set pr := @ContinuousLinearMap.proj �� _ ι F' _ _ _
  refine ⟨fun h i => h.continuousLinearMap_comp (pr i), fun h ↦ ?_⟩
  match n with
  | ω =>
    choose u hux p hp h'p using h
    refine ⟨⋂ i, u i, Filter.iInter_mem.2 hux, _,
      hasFTaylorSeriesUpToOn_pi.2 fun i => (hp i).mono <| iInter_subset _ _, fun m ↦ ?_⟩
    set L : (∀ i, E [×m]→L[��] F' i) ≃ₗᵢ[��] E [×m]→L[��] ∀ i, F' i :=
      ContinuousMultilinearMap.piₗᵢ _ _
    change AnalyticOn �� (fun x ↦ L (fun i ↦ p i x m)) (⋂ i, u i)
    apply (L.analyticOnNhd univ).comp_analyticOn ?_ (mapsTo_univ _ _)
    exact AnalyticOn.pi (fun i ↦ (h'p i m).mono (iInter_subset _ _))
  | (n : ℕ∞) =>
    intro m hm
    choose u hux p hp using fun i => h i m hm
    exact ⟨⋂ i, u i, Filter.iInter_mem.2 hux, _,
      hasFTaylorSeriesUpToOn_pi.2 fun i => (hp i).mono <| iInter_subset _ _⟩

theorem contDiffOn_pi : ContDiffOn �� n Φ s ↔ ∀ i, ContDiffOn �� n (fun x => Φ x i) s :=
  ⟨fun h _ x hx => contDiffWithinAt_pi.1 (h x hx) _, fun h x hx =>
    contDiffWithinAt_pi.2 fun i => h i x hx⟩

theorem contDiffAt_pi : ContDiffAt �� n Φ x ↔ ∀ i, ContDiffAt �� n (fun x => Φ x i) x :=
  contDiffWithinAt_pi

theorem contDiff_pi : ContDiff �� n Φ ↔ ∀ i, ContDiff �� n fun x => Φ x i := by
  simp only [← contDiffOn_univ, contDiffOn_pi]

@[fun_prop]
theorem contDiff_pi' (hΦ : ∀ i, ContDiff �� n fun x => Φ x i) : ContDiff �� n Φ :=
  contDiff_pi.2 hΦ

@[fun_prop]
theorem contDiffOn_pi' (hΦ : ∀ i, ContDiffOn �� n (fun x => Φ x i) s) : ContDiffOn �� n Φ s :=
  contDiffOn_pi.2 hΦ

@[fun_prop]
theorem contDiffAt_pi' (hΦ : ∀ i, ContDiffAt �� n (fun x => Φ x i) x) : ContDiffAt �� n Φ x :=
  contDiffAt_pi.2 hΦ

theorem contDiff_update [DecidableEq ι] (k : ℕ∞ω) (x : ∀ i, F' i) (i : ι) :
    ContDiff �� k (update x i) := by
  rw [contDiff_pi]
  intro j
  dsimp [Function.update]
  split_ifs with h
  · subst h
    exact contDiff_id
  · exact contDiff_const

variable (F') in
theorem contDiff_single [DecidableEq ι] (k : ℕ∞ω) (i : ι) :
    ContDiff �� k (Pi.single i : F' i → ∀ i, F' i) :=
  contDiff_update k 0 i

variable (�� F')

@[fun_prop]
theorem contDiff_apply (i : ι) : ContDiff �� n fun (f : Π i, F' i) => f i :=
  contDiff_pi.mp contDiff_id i

@[fun_prop]
theorem contDiffAt_apply (i : ι) (f : Π i, F' i) : ContDiffAt �� n (fun (f : Π i, F' i) => f i) f :=
  (contDiff_apply �� F' i).contDiffAt

@[fun_prop]
theorem contDiffWithinAt_apply (i : ι) (s : Set (Π i, F' i)) (f : Π i, F' i) :
    ContDiffWithinAt �� n (fun (f : Π i, F' i) => f i) s f :=
  (contDiffAt_apply �� F' i f).contDiffWithinAt

@[fun_prop]
theorem contDiffOn_apply (i : ι) (s : Set (Π i, F' i)) :
    ContDiffOn �� n (fun (f : Π i, F' i) => f i) s :=
  (contDiff_apply �� F' i).contDiffOn

theorem contDiff_apply_apply (i : ι) (j : ι') : ContDiff �� n fun f : ι → ι' → E => f i j :=
  contDiff_pi.mp (contDiff_apply �� _ i) j

end Pi

/-! ### Sum of two functions -/

section Add

theorem HasFTaylorSeriesUpToOn.add {n : ℕ∞ω} {q g} (hf : HasFTaylorSeriesUpToOn n f p s)
    (hg : HasFTaylorSeriesUpToOn n g q s) : HasFTaylorSeriesUpToOn n (f + g) (p + q) s := by
  exact HasFTaylorSeriesUpToOn.continuousLinearMap_comp
    (ContinuousLinearMap.fst �� F F + .snd �� F F) (hf.prodMk hg)

-- The sum is smooth.
@[fun_prop]
theorem contDiff_add : ContDiff �� n fun p : F × F => p.1 + p.2 :=
  (IsBoundedLinearMap.fst.add IsBoundedLinearMap.snd).contDiff

/-- The sum of two `C^n` functions within a set at a point is `C^n` within this set
at this point. -/

@[fun_prop]
theorem ContDiffWithinAt.add {s : Set E} {f g : E → F} (hf : ContDiffWithinAt �� n f s x)
    (hg : ContDiffWithinAt �� n g s x) : ContDiffWithinAt �� n (fun x => f x + g x) s x :=
  contDiff_add.contDiffWithinAt.comp x (hf.prodMk hg) (mapsTo_univ ..)

/-- The sum of two `C^n` functions at a point is `C^n` at this point. -/
@[fun_prop]
theorem ContDiffAt.add {f g : E → F} (hf : ContDiffAt �� n f x) (hg : ContDiffAt �� n g x) :
    ContDiffAt �� n (fun x => f x + g x) x := by
  rw [← contDiffWithinAt_univ] at *; exact hf.add hg

/-- The sum of two `C^n` functions is `C^n`. -/
@[fun_prop]
theorem ContDiff.add {f g : E → F} (hf : ContDiff �� n f) (hg : ContDiff �� n g) :
    ContDiff �� n fun x => f x + g x :=
  contDiff_add.comp (hf.prodMk hg)

/-- The sum of two `C^n` functions on a domain is `C^n`. -/
@[fun_prop]
theorem ContDiffOn.add {s : Set E} {f g : E → F} (hf : ContDiffOn �� n f s)
    (hg : ContDiffOn �� n g s) : ContDiffOn �� n (fun x => f x + g x) s := fun x hx =>
  (hf x hx).add (hg x hx)

variable {i : ℕ}

/--
The iterated derivative of the sum of two functions is the sum of the iterated derivatives.
-/

@[to_fun] theorem iteratedFDerivWithin_add_apply {f g : E → F} (hf : ContDiffWithinAt �� i f s x)
    (hg : ContDiffWithinAt �� i g s x) (hu : UniqueDiffOn �� s) (hx : x ∈ s) :
    iteratedFDerivWithin �� i (f + g) s x =
      iteratedFDerivWithin �� i f s x + iteratedFDerivWithin �� i g s x := by
  have := (hf.eventually (by simp)).and (hg.eventually (by simp))
  obtain ⟨t, ht, hxt, h⟩ := mem_nhdsWithin.mp this
  have hft : ContDiffOn �� i f (s ∩ t) := fun a ha ↦ (h (by simp_all)).1.mono inter_subset_left
  have hgt : ContDiffOn �� i g (s ∩ t) := fun a ha ↦ (h (by simp_all)).2.mono inter_subset_left
  have hut : UniqueDiffOn �� (s ∩ t) := hu.inter ht
  have H : s ∩ t =ᶠ[�� x] s :=
    inter_eventuallyEqSet_left.mpr (eventually_of_mem (ht.mem_nhds hxt) (fun _ h _ ↦ h))
  rw [← iteratedFDerivWithin_congr_set H, ← iteratedFDerivWithin_congr_set H,
    ← iteratedFDerivWithin_congr_set H]
  exact .symm (((hft.ftaylorSeriesWithin hut).add
      (hgt.ftaylorSeriesWithin hut)).eq_iteratedFDerivWithin_of_uniqueDiffOn le_rfl hut ⟨hx, hxt⟩)

@[to_fun] theorem iteratedFDeriv_add_apply {i : ℕ} {f g : E → F}
    (hf : ContDiffAt �� i f x) (hg : ContDiffAt �� i g x) :
    iteratedFDeriv �� i (f + g) x = iteratedFDeriv �� i f x + iteratedFDeriv �� i g x := by
  simp_rw [← iteratedFDerivWithin_univ]
  exact iteratedFDerivWithin_add_apply hf hg uniqueDiffOn_univ (Set.mem_univ _)

@[to_fun] theorem iteratedFDeriv_add {i : ℕ} {f g : E → F} (hf : ContDiff �� i f)
    (hg : ContDiff �� i g) :
    iteratedFDeriv �� i (f + g) = iteratedFDeriv �� i f + iteratedFDeriv �� i g :=
  funext fun _ ↦ iteratedFDeriv_add_apply (ContDiff.contDiffAt hf) (ContDiff.contDiffAt hg)

end Add

/-! ### Negative -/

section Neg

-- The negative is smooth.
@[fun_prop]
theorem contDiff_neg : ContDiff �� n fun p : F => -p :=
  IsBoundedLinearMap.id.neg.contDiff

/-- The negative of a `C^n` function within a domain at a point is `C^n` within this domain at
this point. -/

@[fun_prop]
theorem ContDiffWithinAt.neg {s : Set E} {f : E → F} (hf : ContDiffWithinAt �� n f s x) :
    ContDiffWithinAt �� n (fun x => -f x) s x :=
  contDiff_neg.contDiffWithinAt.comp x hf (mapsTo_univ ..)

/-- The negative of a `C^n` function at a point is `C^n` at this point. -/
@[fun_prop]
theorem ContDiffAt.neg {f : E → F} (hf : ContDiffAt �� n f x) :
    ContDiffAt �� n (fun x => -f x) x := by rw [← contDiffWithinAt_univ] at *; exact hf.neg

/-- The negative of a `C^n` function is `C^n`. -/
@[fun_prop]
theorem ContDiff.neg {f : E → F} (hf : ContDiff �� n f) : ContDiff �� n fun x => -f x :=
  contDiff_neg.comp hf

/-- The negative of a `C^n` function on a domain is `C^n`. -/
@[fun_prop]
theorem ContDiffOn.neg {s : Set E} {f : E → F} (hf : ContDiffOn �� n f s) :
    ContDiffOn �� n (fun x => -f x) s := fun x hx => (hf x hx).neg

variable {i : ℕ}

-- TODO: define `Neg` instance on `ContinuousLinearEquiv`,
-- prove it from `ContinuousLinearEquiv.iteratedFDerivWithin_comp_left`
theorem iteratedFDerivWithin_neg_apply {f : E → F} (hu : UniqueDiffOn �� s) (hx : x ∈ s) :
    iteratedFDerivWithin �� i (-f) s x = -iteratedFDerivWithin �� i f s x := by
  induction i generalizing x with ext h
  | zero => simp
  | succ i hi =>
    calc
      iteratedFDerivWithin �� (i + 1) (-f) s x h =
          fderivWithin �� (iteratedFDerivWithin �� i (-f) s) s x (h 0) (Fin.tail h) :=
        iteratedFDerivWithin_succ_apply_left _
      _ = fderivWithin �� (-iteratedFDerivWithin �� i f s) s x (h 0) (Fin.tail h) := by
        rw [fderivWithin_congr' (@hi) hx, Pi.neg_def]
      _ = -(fderivWithin �� (iteratedFDerivWithin �� i f s) s) x (h 0) (Fin.tail h) := by
        rw [fderivWithin_neg (hu x hx), neg_apply, neg_apply]
      _ = -(iteratedFDerivWithin �� (i + 1) f s) x h := by
        rw [iteratedFDerivWithin_succ_apply_left]

theorem iteratedFDeriv_neg_apply {i : ℕ} {f : E → F} :
    iteratedFDeriv �� i (-f) x = -iteratedFDeriv �� i f x := by
  simp_rw [← iteratedFDerivWithin_univ]
  exact iteratedFDerivWithin_neg_apply uniqueDiffOn_univ (Set.mem_univ _)

theorem iteratedFDeriv_neg {i : ℕ} {f : E → F} :
    iteratedFDeriv �� i (-f) = -iteratedFDeriv �� i f :=
  funext fun _ ↦ iteratedFDeriv_neg_apply

end Neg

/-! ### Subtraction -/

/-- The difference of two `C^n` functions within a set at a point is `C^n` within this set
at this point. -/

@[fun_prop]
theorem ContDiffWithinAt.sub {s : Set E} {f g : E → F} (hf : ContDiffWithinAt �� n f s x)
    (hg : ContDiffWithinAt �� n g s x) : ContDiffWithinAt �� n (fun x => f x - g x) s x := by
  simpa only [sub_eq_add_neg] using hf.add hg.neg

/-- The difference of two `C^n` functions at a point is `C^n` at this point. -/
@[fun_prop]
theorem ContDiffAt.sub {f g : E → F} (hf : ContDiffAt �� n f x) (hg : ContDiffAt �� n g x) :
    ContDiffAt �� n (fun x => f x - g x) x := by simpa only [sub_eq_add_neg] using hf.add hg.neg

/-- The difference of two `C^n` functions on a domain is `C^n`. -/
@[fun_prop]
theorem ContDiffOn.sub {s : Set E} {f g : E → F} (hf : ContDiffOn �� n f s)
    (hg : ContDiffOn �� n g s) : ContDiffOn �� n (fun x => f x - g x) s := by
  simpa only [sub_eq_add_neg] using hf.add hg.neg

/-- The difference of two `C^n` functions is `C^n`. -/
@[fun_prop]
theorem ContDiff.sub {f g : E → F} (hf : ContDiff �� n f) (hg : ContDiff �� n g) :
    ContDiff �� n fun x => f x - g x := by simpa only [sub_eq_add_neg] using hf.add hg.neg

variable {i : ℕ}

/--
The iterated derivative of the difference of two functions is the difference of the iterated
derivatives.
-/

@[to_fun] theorem iteratedFDerivWithin_sub_apply {f g : E → F} (hf : ContDiffWithinAt �� i f s x)
    (hg : ContDiffWithinAt �� i g s x) (hu : UniqueDiffOn �� s) (hx : x ∈ s) :
    iteratedFDerivWithin �� i (f - g) s x =
      iteratedFDerivWithin �� i f s x - iteratedFDerivWithin �� i g s x := by
  rw [sub_eq_add_neg, iteratedFDerivWithin_add_apply hf _ hu hx,
    iteratedFDerivWithin_neg_apply hu hx, sub_eq_add_neg]
  exact hg.neg

/--
The iterated derivative of the difference of two functions is the difference of the iterated
derivatives.
-/

@[to_fun] theorem iteratedFDeriv_sub_apply {i : ℕ} {f g : E → F}
    (hf : ContDiffAt �� i f x) (hg : ContDiffAt �� i g x) :
    iteratedFDeriv �� i (f - g) x = iteratedFDeriv �� i f x - iteratedFDeriv �� i g x := by
  simp_rw [← iteratedFDerivWithin_univ]
  exact iteratedFDerivWithin_sub_apply hf hg uniqueDiffOn_univ (Set.mem_univ _)

/--
The iterated derivative of the difference of two functions is the difference of the iterated
derivatives.
-/

@[to_fun] theorem iteratedFDeriv_sub {i : ℕ} {f g : E → F} (hf : ContDiff �� i f)
    (hg : ContDiff �� i g) :
    iteratedFDeriv �� i (f - g) = iteratedFDeriv �� i f - iteratedFDeriv �� i g :=
  funext fun _ ↦ iteratedFDeriv_sub_apply (ContDiff.contDiffAt hf) (ContDiff.contDiffAt hg)

/-! ### Sum of finitely many functions -/

@[fun_prop]
theorem ContDiffWithinAt.sum {ι : Type*} {f : ι → E → F} {s : Finset ι} {t : Set E} {x : E}
    (h : ∀ i ∈ s, ContDiffWithinAt �� n (fun x => f i x) t x) :
    ContDiffWithinAt �� n (fun x => ∑ i ∈ s, f i x) t x := by
  classical
  induction s using Finset.induction_on with
  | empty => simp [contDiffWithinAt_const]
  | insert i s is IH =>
    simp only [is, Finset.sum_insert, not_false_iff]
    exact (h _ (Finset.mem_insert_self i s)).add
      (IH fun j hj => h _ (Finset.mem_insert_of_mem hj))

@[fun_prop]
theorem ContDiffAt.sum {ι : Type*} {f : ι → E → F} {s : Finset ι} {x : E}
    (h : ∀ i ∈ s, ContDiffAt �� n (fun x => f i x) x) :
    ContDiffAt �� n (fun x => ∑ i ∈ s, f i x) x := by
  rw [← contDiffWithinAt_univ] at *; exact ContDiffWithinAt.sum h

@[fun_prop]
theorem ContDiffOn.sum {ι : Type*} {f : ι → E → F} {s : Finset ι} {t : Set E}
    (h : ∀ i ∈ s, ContDiffOn �� n (fun x => f i x) t) :
    ContDiffOn �� n (fun x => ∑ i ∈ s, f i x) t := fun x hx =>
  ContDiffWithinAt.sum fun i hi => h i hi x hx

@[fun_prop]
theorem ContDiff.sum {ι : Type*} {f : ι → E → F} {s : Finset ι}
    (h : ∀ i ∈ s, ContDiff �� n fun x => f i x) : ContDiff �� n fun x => ∑ i ∈ s, f i x := by
  simp only [← contDiffOn_univ] at *; exact ContDiffOn.sum h

theorem iteratedFDerivWithin_sum_apply {ι : Type*} {f : ι → E → F} {u : Finset ι} {i : ℕ} {x : E}
    (hs : UniqueDiffOn �� s) (hx : x ∈ s) (h : ∀ j ∈ u, ContDiffWithinAt �� i (f j) s x) :
    iteratedFDerivWithin �� i (∑ j ∈ u, f j) s x =
      ∑ j ∈ u, iteratedFDerivWithin �� i (f j) s x := by
  rw [(by aesop : (∑ j ∈ u, f j) = (fun x ↦ ∑ j ∈ u, f j x))]
  induction u using Finset.cons_induction with
  | empty => simp
  | cons a u ha IH =>
    simp only [Finset.mem_cons, forall_eq_or_imp] at h
    simp only [Finset.sum_cons]
    rw [fun_iteratedFDerivWithin_add_apply h.1 (ContDiffWithinAt.sum h.2) hs hx, IH h.2]

theorem iteratedFDerivWithin_fun_sum_apply {ι : Type*} {f : ι → E → F} {u : Finset ι} {i : ℕ}
    {x : E} (hs : UniqueDiffOn �� s) (hx : x ∈ s) (h : ∀ j ∈ u, ContDiffWithinAt �� i (f j) s x) :
    iteratedFDerivWithin �� i (fun z ↦ ∑ j ∈ u, f j z) s x =
      ∑ j ∈ u, iteratedFDerivWithin �� i (f j) s x := by
  convert! iteratedFDerivWithin_sum_apply hs hx h
  rw [Finset.sum_apply]

theorem iteratedFDeriv_sum_apply {ι : Type*} {f : ι → E → F} {u : Finset ι} {n : ℕ} {x : E}
    (h : ∀ j ∈ u, ContDiffAt �� n (f j) x) :
    iteratedFDeriv �� n (∑ j ∈ u, f j) x = ∑ j ∈ u, iteratedFDeriv �� n (f j) x := by
  simp only [← iteratedFDerivWithin_univ]
  apply iteratedFDerivWithin_sum_apply uniqueDiffOn_univ (Set.mem_univ x)
    (h · · |>.contDiffWithinAt)

theorem iteratedFDeriv_fun_sum_apply {ι : Type*} {f : ι → E → F} {u : Finset ι} {n : ℕ} {x : E}
    (h : ∀ j ∈ u, ContDiffAt �� n (f j) x) :
    iteratedFDeriv �� n (fun z ↦ ∑ j ∈ u, f j z) x = ∑ j ∈ u, iteratedFDeriv �� n (f j) x := by
  convert! iteratedFDeriv_sum_apply h
  rw [Finset.sum_apply]

theorem iteratedFDeriv_sum {ι : Type*} {f : ι → E → F} {u : Finset ι} {i : ℕ}
    (h : ∀ j ∈ u, ContDiff �� i (f j)) :
    iteratedFDeriv �� i (∑ j ∈ u, f j ·) = ∑ j ∈ u, iteratedFDeriv �� i (f j) :=
  funext fun x ↦ by simpa [iteratedFDerivWithin_univ] using
    iteratedFDerivWithin_fun_sum_apply uniqueDiffOn_univ (mem_univ x) (h · · |>.contDiffWithinAt)

/-! ### Product of two functions -/

section MulProd

variable {�� ��' ι ��' : Type*} [NormedRing ��] [NormedAlgebra �� ��] [NormedCommRing ��']
  [NormedAlgebra �� ��'] [NormedField ��'] [NormedAlgebra �� ��']

-- The product is smooth.
@[fun_prop]
theorem contDiff_mul : ContDiff �� n fun p : �� × �� => p.1 * p.2 :=
  (ContinuousLinearMap.mul �� ��).isBoundedBilinearMap.contDiff

/-- The product of two `C^n` functions within a set at a point is `C^n` within this set
at this point. -/

@[fun_prop]
theorem ContDiffWithinAt.mul {s : Set E} {f g : E → ��} (hf : ContDiffWithinAt �� n f s x)
    (hg : ContDiffWithinAt �� n g s x) : ContDiffWithinAt �� n (fun x => f x * g x) s x :=
  contDiff_mul.comp_contDiffWithinAt (hf.prodMk hg)

/-- The product of two `C^n` functions at a point is `C^n` at this point. -/
@[fun_prop]
nonrec theorem ContDiffAt.mul {f g : E → ��} (hf : ContDiffAt �� n f x) (hg : ContDiffAt �� n g x) :
    ContDiffAt �� n (fun x => f x * g x) x :=
  hf.mul hg

/-- The product of two `C^n` functions on a domain is `C^n`. -/
@[fun_prop]
theorem ContDiffOn.mul {f g : E → ��} (hf : ContDiffOn �� n f s) (hg : ContDiffOn �� n g s) :
    ContDiffOn �� n (fun x => f x * g x) s := fun x hx => (hf x hx).mul (hg x hx)

/-- The product of two `C^n` functions is `C^n`. -/
@[fun_prop]
theorem ContDiff.mul {f g : E → ��} (hf : ContDiff �� n f) (hg : ContDiff �� n g) :
    ContDiff �� n fun x => f x * g x :=
  contDiff_mul.comp (hf.prodMk hg)

@[fun_prop]
theorem contDiffWithinAt_prod' {t : Finset ι} {f : ι → E → ��'}
    (h : ∀ i ∈ t, ContDiffWithinAt �� n (f i) s x) : ContDiffWithinAt �� n (∏ i ∈ t, f i) s x :=
  Finset.prod_induction f (fun f => ContDiffWithinAt �� n f s x) (fun _ _ => ContDiffWithinAt.mul)
    (contDiffWithinAt_const (c := 1)) h

@[fun_prop]
theorem contDiffWithinAt_prod {t : Finset ι} {f : ι → E → ��'}
    (h : ∀ i ∈ t, ContDiffWithinAt �� n (f i) s x) :
    ContDiffWithinAt �� n (fun y => ∏ i ∈ t, f i y) s x := by
  simpa only [← Finset.prod_apply] using contDiffWithinAt_prod' h

@[fun_prop]
theorem contDiffAt_prod' {t : Finset ι} {f : ι → E → ��'} (h : ∀ i ∈ t, ContDiffAt �� n (f i) x) :
    ContDiffAt �� n (∏ i ∈ t, f i) x :=
  contDiffWithinAt_prod' h

@[fun_prop]
theorem contDiffAt_prod {t : Finset ι} {f : ι → E → ��'} (h : ∀ i ∈ t, ContDiffAt �� n (f i) x) :
    ContDiffAt �� n (fun y => ∏ i ∈ t, f i y) x :=
  contDiffWithinAt_prod h

@[fun_prop]
theorem contDiffOn_prod' {t : Finset ι} {f : ι → E → ��'} (h : ∀ i ∈ t, ContDiffOn �� n (f i) s) :
    ContDiffOn �� n (∏ i ∈ t, f i) s := fun x hx => contDiffWithinAt_prod' fun i hi => h i hi x hx

@[fun_prop]
theorem contDiffOn_prod {t : Finset ι} {f : ι → E → ��'} (h : ∀ i ∈ t, ContDiffOn �� n (f i) s) :
    ContDiffOn �� n (fun y => ∏ i ∈ t, f i y) s := fun x hx =>
  contDiffWithinAt_prod fun i hi => h i hi x hx

@[fun_prop]
theorem contDiff_prod' {t : Finset ι} {f : ι → E → ��'} (h : ∀ i ∈ t, ContDiff �� n (f i)) :
    ContDiff �� n (∏ i ∈ t, f i) :=
  contDiff_iff_contDiffAt.mpr fun _ => contDiffAt_prod' fun i hi => (h i hi).contDiffAt

@[fun_prop]
theorem contDiff_prod {t : Finset ι} {f : ι → E → ��'} (h : ∀ i ∈ t, ContDiff �� n (f i)) :
    ContDiff �� n fun y => ∏ i ∈ t, f i y :=
  contDiff_iff_contDiffAt.mpr fun _ => contDiffAt_prod fun i hi => (h i hi).contDiffAt

@[fun_prop]
theorem ContDiff.pow {f : E → ��} (hf : ContDiff �� n f) : ∀ m : ℕ, ContDiff �� n fun x => f x ^ m
  | 0 => by simpa using contDiff_const
  | m + 1 => by simpa [pow_succ] using (hf.pow m).mul hf

@[fun_prop]
theorem ContDiffWithinAt.pow {f : E → ��} (hf : ContDiffWithinAt �� n f s x) (m : ℕ) :
    ContDiffWithinAt �� n (fun y => f y ^ m) s x :=
  (contDiff_id.pow m).comp_contDiffWithinAt hf

@[fun_prop]
nonrec theorem ContDiffAt.pow {f : E → ��} (hf : ContDiffAt �� n f x) (m : ℕ) :
    ContDiffAt �� n (fun y => f y ^ m) x :=
  hf.pow m

@[fun_prop]
theorem ContDiffOn.pow {f : E → ��} (hf : ContDiffOn �� n f s) (m : ℕ) :
    ContDiffOn �� n (fun y => f y ^ m) s := fun y hy => (hf y hy).pow m

@[fun_prop]
theorem ContDiffWithinAt.div_const {f : E → ��'} {n} (hf : ContDiffWithinAt �� n f s x) (c : ��') :
    ContDiffWithinAt �� n (fun x => f x / c) s x := by
  simpa only [div_eq_mul_inv] using hf.mul contDiffWithinAt_const

@[fun_prop]
nonrec theorem ContDiffAt.div_const {f : E → ��'} {n} (hf : ContDiffAt �� n f x) (c : ��') :
    ContDiffAt �� n (fun x => f x / c) x :=
  hf.div_const c

@[fun_prop]
theorem ContDiffOn.div_const {f : E → ��'} {n} (hf : ContDiffOn �� n f s) (c : ��') :
    ContDiffOn �� n (fun x => f x / c) s := fun x hx => (hf x hx).div_const c

@[fun_prop]
theorem ContDiff.div_const {f : E → ��'} {n} (hf : ContDiff �� n f) (c : ��') :
    ContDiff �� n fun x => f x / c := by simpa only [div_eq_mul_inv] using hf.mul contDiff_const


end MulProd

/-! ### Scalar multiplication -/

section SMul

variable {��' : Type*} [NormedRing ��']
  [NormedAlgebra �� ��'] [Module ��' F] [IsBoundedSMul ��' F] [IsScalarTower �� ��' F]

-- The scalar multiplication is smooth.
@[fun_prop]
theorem contDiff_smul : ContDiff �� n fun p : ��' × F => p.1 • p.2 :=
  isBoundedBilinearMap_smul.contDiff

/-- The scalar multiplication of two `C^n` functions within a set at a point is `C^n` within this
set at this point. -/

@[to_fun (attr := fun_prop)]
theorem ContDiffWithinAt.smul {s : Set E} {f : E → ��'} {g : E → F} (hf : ContDiffWithinAt �� n f s x)
    (hg : ContDiffWithinAt �� n g s x) : ContDiffWithinAt �� n (f • g) s x :=
  contDiff_smul.contDiffWithinAt.comp x (hf.prodMk hg) (mapsTo_univ ..)

/-- The scalar multiplication of two `C^n` functions at a point is `C^n` at this point. -/
@[to_fun (attr := fun_prop)]
theorem ContDiffAt.smul {f : E → ��'} {g : E → F} (hf : ContDiffAt �� n f x)
    (hg : ContDiffAt �� n g x) : ContDiffAt �� n (f • g) x := by
  rw [← contDiffWithinAt_univ] at *; exact hf.smul hg

/-- The scalar multiplication of two `C^n` functions is `C^n`. -/
@[to_fun (attr := fun_prop)]
theorem ContDiff.smul {f : E → ��'} {g : E → F} (hf : ContDiff �� n f) (hg : ContDiff �� n g) :
    ContDiff �� n (f • g) :=
  contDiff_smul.comp (hf.prodMk hg)

/-- The scalar multiplication of two `C^n` functions on a domain is `C^n`. -/
@[to_fun (attr := fun_prop)]
theorem ContDiffOn.smul {s : Set E} {f : E → ��'} {g : E → F} (hf : ContDiffOn �� n f s)
    (hg : ContDiffOn �� n g s) : ContDiffOn �� n (f • g) s := fun x hx =>
  (hf x hx).smul (hg x hx)

end SMul

/-! ### Constant scalar multiplication

TODO: generalize results in this section -- if `c` is a unit (or `R` is a group), then one can
drop `ContDiff*` assumptions in some lemmas about `iteratedFDeriv` and `iteratedFDerivWithin`.
-/


section ConstSMul

variable {R A : Type*} [DistribSMul R F] [SMulCommClass �� R F] [ContinuousConstSMul R F]
  [NormedRing A] [NormedAlgebra �� A] [Module A F] [IsScalarTower �� A F] [IsBoundedSMul A F]

/-- Scalar multiplication is smooth (as a function of the vector variable). -/
@[fun_prop]
theorem contDiff_const_smul (c : R) : ContDiff �� n fun p : F => c • p :=
  (c • ContinuousLinearMap.id �� F).contDiff

/-- Scalar multiplication is smooth (as a function of the scalar variable). -/
@[fun_prop]
theorem contDiff_smul_const (v : F) : ContDiff �� n fun a : A => a • v :=
  ((ContinuousLinearMap.id �� A).smulRight v).contDiff

/-- The scalar multiplication of a constant and a `C^n` function within a set at a point is `C^n`
within this set at this point. -/

@[fun_prop]
theorem ContDiffWithinAt.const_smul {s : Set E} {f : E → F} {x : E} (c : R)
    (hf : ContDiffWithinAt �� n f s x) : ContDiffWithinAt �� n (fun y => c • f y) s x :=
  (contDiff_const_smul c).contDiffAt.comp_contDiffWithinAt x hf

/-- The scalar multiplication of `C^n` function within a set at a point and a constant and is `C^n`
within this set at this point. -/

@[fun_prop]
theorem ContDiffWithinAt.smul_const {s : Set E} {f : E → A} {x : E}
    (hf : ContDiffWithinAt �� n f s x) (v : F) : ContDiffWithinAt �� n (fun y => f y • v) s x :=
  (contDiff_smul_const v).contDiffAt.comp_contDiffWithinAt x hf

/-- The scalar multiplication of a constant and a `C^n` function at a point is `C^n` at this
point. -/

@[fun_prop]
theorem ContDiffAt.const_smul {f : E → F} {x : E} (c : R) (hf : ContDiffAt �� n f x) :
    ContDiffAt �� n (fun y => c • f y) x := by
  rw [← contDiffWithinAt_univ] at *; exact hf.const_smul c

/-- The scalar multiplication of a `C^n` function at a point and a constant is `C^n` at this
point. -/

@[fun_prop]
theorem ContDiffAt.smul_const {f : E → A} {x : E} (hf : ContDiffAt �� n f x) (v : F) :
    ContDiffAt �� n (fun y => f y • v) x := by
  rw [← contDiffWithinAt_univ] at *; exact hf.smul_const v

/-- The scalar multiplication of a constant and a `C^n` function is `C^n`. -/
@[fun_prop]
theorem ContDiff.const_smul {f : E → F} (c : R) (hf : ContDiff �� n f) :
    ContDiff �� n fun y => c • f y :=
  (contDiff_const_smul c).comp hf

/-- The scalar multiplication of a `C^n` function and a constant is `C^n`. -/
@[fun_prop]
theorem ContDiff.smul_const {f : E → A} (hf : ContDiff �� n f) (v : F) :
    ContDiff �� n fun y => f y • v :=
  (contDiff_smul_const v).comp hf

/-- The scalar multiplication of a constant and a `C^n` function on a domain is `C^n`. -/
@[fun_prop]
theorem ContDiffOn.const_smul {s : Set E} {f : E → F} (c : R) (hf : ContDiffOn �� n f s) :
    ContDiffOn �� n (fun y => c • f y) s := fun x hx => (hf x hx).const_smul c

/-- The scalar multiplication of a `C^n` function on a domain and a constant is `C^n`. -/
@[fun_prop]
theorem ContDiffOn.smul_const {s : Set E} {f : E → A} (hf : ContDiffOn �� n f s) (v : F) :
    ContDiffOn �� n (fun y => f y • v) s := fun x hx => (hf x hx).smul_const v

variable {i : ℕ} {a : R} {v : F}

theorem iteratedFDerivWithin_const_smul_apply (hf : ContDiffWithinAt �� i f s x)
    (hu : UniqueDiffOn �� s) (hx : x ∈ s) :
    iteratedFDerivWithin �� i (a • f) s x = a • iteratedFDerivWithin �� i f s x :=
  (a • (1 : F →L[��] F)).iteratedFDerivWithin_comp_left hf hu hx le_rfl

theorem iteratedFDerivWithin_smul_const_apply {f : E → A} (hf : ContDiffWithinAt �� i f s x)
    (hu : UniqueDiffOn �� s) (hx : x ∈ s) :
    iteratedFDerivWithin �� i (fun y ↦ f y • v) s x =
      ((ContinuousLinearMap.id �� A).smulRight v).compContinuousMultilinearMap
        (iteratedFDerivWithin �� i f s x) :=
  (ContinuousLinearMap.id �� A).smulRight v |>.iteratedFDerivWithin_comp_left hf hu hx le_rfl

theorem iteratedFDeriv_const_smul_apply (hf : ContDiffAt �� i f x) :
    iteratedFDeriv �� i (a • f) x = a • iteratedFDeriv �� i f x :=
  (a • (1 : F →L[��] F)).iteratedFDeriv_comp_left hf le_rfl

theorem iteratedFDeriv_const_smul_apply' (hf : ContDiffAt �� i f x) :
    iteratedFDeriv �� i (fun x ↦ a • f x) x = a • iteratedFDeriv �� i f x :=
  iteratedFDeriv_const_smul_apply hf

theorem iteratedFDeriv_smul_const_apply {f : E → A} (hf : ContDiffAt �� i f x) :
    iteratedFDeriv �� i (fun y ↦ f y • v) x =
      ((ContinuousLinearMap.id �� A).smulRight v).compContinuousMultilinearMap
        (iteratedFDeriv �� i f x) :=
  (ContinuousLinearMap.id �� A).smulRight v |>.iteratedFDeriv_comp_left hf le_rfl

theorem iteratedFDeriv_comp_const_smul (a : ��) (hf : ContDiff �� i f) :
    iteratedFDeriv �� i (fun z ↦ f (a • z)) = fun x ↦ a ^ i • iteratedFDeriv �� i f (a • x) := by
  induction i with
  | zero => ext; simp
  | succ i hi =>
    ext v
    rw [iteratedFDeriv_succ_eq_comp_left, iteratedFDeriv_succ_eq_comp_left]
    simp only [Nat.succ_eq_add_one, Nat.cast_add, Nat.cast_one, self_le_add_right, hf.of_le, hi,
      comp_apply, continuousMultilinearCurryLeftEquiv_symm_apply, smul_apply]
    rw [fderiv_fun_const_smul, fderiv_comp_smul, smul_smul, ← pow_succ]
    · simp
    rw [← Function.comp_def (g := (a • ·))]
    apply DifferentiableAt.comp
    · exact hf.contDiffAt.differentiableAt_iteratedFDeriv (Nat.cast_lt.2 i.lt_succ_self)
    · exact differentiableAt_id.const_smul _

end ConstSMul

/-! ### Cartesian product of two functions -/

section prodMap

variable {E' : Type*} [NormedAddCommGroup E'] [NormedSpace �� E']
variable {F' : Type*} [NormedAddCommGroup F'] [NormedSpace �� F']

/-- The product map of two `C^n` functions within a set at a point is `C^n`
within the product set at the product point. -/

@[fun_prop]
theorem ContDiffWithinAt.prodMap' {s : Set E} {t : Set E'} {f : E → F} {g : E' → F'} {p : E × E'}
    (hf : ContDiffWithinAt �� n f s p.1) (hg : ContDiffWithinAt �� n g t p.2) :
    ContDiffWithinAt �� n (Prod.map f g) (s ×ˢ t) p :=
  (hf.comp p contDiffWithinAt_fst (prod_subset_preimage_fst _ _)).prodMk
    (hg.comp p contDiffWithinAt_snd (prod_subset_preimage_snd _ _))

@[fun_prop]
theorem ContDiffWithinAt.prodMap {s : Set E} {t : Set E'} {f : E → F} {g : E' → F'} {x : E} {y : E'}
    (hf : ContDiffWithinAt �� n f s x) (hg : ContDiffWithinAt �� n g t y) :
    ContDiffWithinAt �� n (Prod.map f g) (s ×ˢ t) (x, y) :=
  ContDiffWithinAt.prodMap' hf hg

/-- The product map of two `C^n` functions on a set is `C^n` on the product set. -/
@[fun_prop]
theorem ContDiffOn.prodMap {E' : Type*} [NormedAddCommGroup E'] [NormedSpace �� E'] {F' : Type*}
    [NormedAddCommGroup F'] [NormedSpace �� F'] {s : Set E} {t : Set E'} {f : E → F} {g : E' → F'}
    (hf : ContDiffOn �� n f s) (hg : ContDiffOn �� n g t) : ContDiffOn �� n (Prod.map f g) (s ×ˢ t) :=
  (hf.comp contDiffOn_fst (prod_subset_preimage_fst _ _)).prodMk
    (hg.comp contDiffOn_snd (prod_subset_preimage_snd _ _))

/-- The product map of two `C^n` functions within a set at a point is `C^n`
within the product set at the product point. -/

@[fun_prop]
theorem ContDiffAt.prodMap {f : E → F} {g : E' → F'} {x : E} {y : E'} (hf : ContDiffAt �� n f x)
    (hg : ContDiffAt �� n g y) : ContDiffAt �� n (Prod.map f g) (x, y) := by
  rw [ContDiffAt] at *
  simpa only [univ_prod_univ] using hf.prodMap hg

/-- The product map of two `C^n` functions within a set at a point is `C^n`
within the product set at the product point. -/

@[fun_prop]
theorem ContDiffAt.prodMap' {f : E → F} {g : E' → F'} {p : E × E'} (hf : ContDiffAt �� n f p.1)
    (hg : ContDiffAt �� n g p.2) : ContDiffAt �� n (Prod.map f g) p :=
  hf.prodMap hg

/-- The product map of two `C^n` functions is `C^n`. -/
@[fun_prop]
theorem ContDiff.prodMap {f : E → F} {g : E' → F'} (hf : ContDiff �� n f) (hg : ContDiff �� n g) :
    ContDiff �� n (Prod.map f g) := by
  rw [contDiff_iff_contDiffAt] at *
  exact fun ⟨x, y⟩ => (hf x).prodMap (hg y)

@[fun_prop]
theorem contDiff_prodMk_left (f₀ : F) : ContDiff �� n fun e : E => (e, f₀) :=
  contDiff_id.prodMk contDiff_const

@[fun_prop]
theorem contDiff_prodMk_right (e₀ : E) : ContDiff �� n fun f : F => (e₀, f) :=
  contDiff_const.prodMk contDiff_id

end prodMap

/-!
### Inversion in a complete normed algebra (or more generally with summable geometric series)
-/


section AlgebraInverse

variable (��)
variable {R : Type*} [NormedRing R] [NormedAlgebra �� R]

open NormedRing Ring

/-- In a complete normed algebra, the operation of inversion is `C^n`, for all `n`, at each
invertible element, as it is analytic. -/

@[fun_prop]
theorem contDiffAt_ringInverse [HasSummableGeomSeries R] (x : Rˣ) :
    ContDiffAt �� n Ring.inverse (x : R) := by
  have := AnalyticOnNhd.contDiffOn (analyticOnNhd_inverse (�� := ��) (A := R)) (n := n)
    Units.isOpen.uniqueDiffOn x x.isUnit
  exact this.contDiffAt (Units.isOpen.mem_nhds x.isUnit)

variable {��' : Type*} [NormedField ��'] [NormedAlgebra �� ��']

@[fun_prop]
theorem contDiffAt_inv {x : ��'} (hx : x ≠ 0) {n} : ContDiffAt �� n Inv.inv x := by
  simpa only [Ring.inverse_eq_inv'] using! contDiffAt_ringInverse �� (Units.mk0 x hx)

@[fun_prop]
theorem contDiffOn_inv {n} : ContDiffOn �� n (Inv.inv : ��' → ��') {0}ᶜ := fun _ hx =>
  (contDiffAt_inv �� hx).contDiffWithinAt

variable {��}

@[to_fun (attr := fun_prop)]
theorem ContDiffWithinAt.inv {f : E → ��'} {n} (hf : ContDiffWithinAt �� n f s x) (hx : f x ≠ 0) :
    ContDiffWithinAt �� n f⁻¹ s x :=
  (contDiffAt_inv �� hx).comp_contDiffWithinAt x hf

@[to_fun (attr := fun_prop)]
theorem ContDiffOn.inv {f : E → ��'} (hf : ContDiffOn �� n f s) (h : ∀ x ∈ s, f x ≠ 0) :
    ContDiffOn �� n f⁻¹ s := fun x hx => (hf.contDiffWithinAt hx).inv (h x hx)

@[to_fun (attr := fun_prop)]
nonrec theorem ContDiffAt.inv {f : E → ��'} (hf : ContDiffAt �� n f x) (hx : f x ≠ 0) :
    ContDiffAt �� n f⁻¹ x :=
  hf.inv hx

@[to_fun (attr := fun_prop)]
theorem ContDiff.inv {f : E → ��'} (hf : ContDiff �� n f) (h : ∀ x, f x ≠ 0) :
    ContDiff �� n f⁻¹ := by
  rw [contDiff_iff_contDiffAt]; exact fun x => hf.contDiffAt.inv (h x)

-- TODO: generalize to `f g : E → ��'`
@[to_fun (attr := fun_prop)]
theorem ContDiffWithinAt.div {f g : E → ��} {n} (hf : ContDiffWithinAt �� n f s x)
    (hg : ContDiffWithinAt �� n g s x) (hx : g x ≠ 0) :
    ContDiffWithinAt �� n (f / g) s x := by
  change ContDiffWithinAt �� n (fun x => f x / g x) s x
  simpa only [div_eq_mul_inv] using hf.mul (hg.fun_inv hx)

@[to_fun (attr := fun_prop)]
theorem ContDiffOn.div {f g : E → ��} {n} (hf : ContDiffOn �� n f s)
    (hg : ContDiffOn �� n g s) (h₀ : ∀ x ∈ s, g x ≠ 0) : ContDiffOn �� n (f / g) s := fun x hx =>
  (hf x hx).div (hg x hx) (h₀ x hx)

@[to_fun (attr := fun_prop)]
nonrec theorem ContDiffAt.div {f g : E → ��} {n} (hf : ContDiffAt �� n f x)
    (hg : ContDiffAt �� n g x) (hx : g x ≠ 0) : ContDiffAt �� n (f / g) x :=
  hf.div hg hx

@[to_fun (attr := fun_prop)]
theorem ContDiff.div {f g : E → ��} {n} (hf : ContDiff �� n f) (hg : ContDiff �� n g)
    (h0 : ∀ x, g x ≠ 0) : ContDiff �� n (f / g) := by
  simp only [contDiff_iff_contDiffAt] at *
  exact fun x => (hf x).div (hg x) (h0 x)

end AlgebraInverse

/-! ### Inversion of continuous linear maps between Banach spaces -/

section MapInverse

open ContinuousLinearMap

/-- At a continuous linear equivalence `e : E ≃L[��] F` between Banach spaces, the operation of
inversion is `C^n`, for all `n`. -/

@[fun_prop]
theorem contDiffAt_map_inverse [CompleteSpace E] (e : E ≃L[��] F) :
    ContDiffAt �� n inverse (e : E →L[��] F) := by
  nontriviality E
  -- first, we use the lemma `inverse_eq_ringInverse` to rewrite in terms of `Ring.inverse` in the
  -- ring `E →L[��] E`
  let O₁ : (E →L[��] E) → F →L[��] E := fun f => f.comp (e.symm : F →L[��] E)
  let O₂ : (E →L[��] F) → E →L[��] E := fun f => (e.symm : F →L[��] E).comp f
  have : ContinuousLinearMap.inverse = O₁ ∘ Ring.inverse ∘ O₂ := funext (inverse_eq_ringInverse e)
  rw [this]
  -- `O₁` and `O₂` are `ContDiff`,
  -- so we reduce to proving that `Ring.inverse` is `ContDiff`
  have h₁ : ContDiff �� n O₁ := contDiff_id.clm_comp contDiff_const
  have h₂ : ContDiff �� n O₂ := contDiff_const.clm_comp contDiff_id
  refine h₁.contDiffAt.comp _ (ContDiffAt.comp _ ?_ h₂.contDiffAt)
  convert contDiffAt_ringInverse �� (1 : (E →L[��] E)ˣ)
  simp [O₂, one_def]

/-- At an invertible map `e : M →L[R] M₂` between Banach spaces, the operation of
inversion is `C^n`, for all `n`. -/

theorem ContinuousLinearMap.IsInvertible.contDiffAt_map_inverse [CompleteSpace E] {e : E →L[��] F}
    (he : e.IsInvertible) : ContDiffAt �� n inverse e := by
  rcases he with ⟨M, rfl⟩
  exact _root_.contDiffAt_map_inverse M

end MapInverse

section FunctionInverse

open ContinuousLinearMap

/-- If `f` is a local homeomorphism and the point `a` is in its target,
and if `f` is `n` times continuously differentiable at `f.symm a`,
and if the derivative at `f.symm a` is a continuous linear equivalence,
then `f.symm` is `n` times continuously differentiable at the point `a`.

This is one of the easy parts of the inverse function theorem: it assumes that we already have
an inverse function. -/

theorem OpenPartialHomeomorph.contDiffAt_symm [CompleteSpace E] (f : OpenPartialHomeomorph E F)
    {f₀' : E ≃L[��] F} {a : F} (ha : a ∈ f.target)
    (hf₀' : HasFDerivAt f (f₀' : E →L[��] F) (f.symm a)) (hf : ContDiffAt �� n f (f.symm a)) :
    ContDiffAt �� n f.symm a := by
  match n with
  | ω =>
    apply AnalyticAt.contDiffAt
    exact f.analyticAt_symm ha hf.analyticAt hf₀'.fderiv
  | (n : ℕ∞) =>
    -- We prove this by induction on `n`
    induction n using ENat.nat_induction with
    | zero =>
      apply contDiffAt_zero.2
      exact ⟨f.target, IsOpen.mem_nhds f.open_target ha, f.continuousOn_invFun⟩
    | succ n IH =>
      obtain ⟨f', ⟨u, hu, hff'⟩, hf'⟩ := contDiffAt_succ_iff_hasFDerivAt.mp hf
      apply contDiffAt_succ_iff_hasFDerivAt.2
      -- For showing `n.succ` times continuous differentiability (the main inductive step), it
      -- suffices to produce the derivative and show that it is `n` times continuously
      -- differentiable
      have eq_f₀' : f' (f.symm a) = f₀' := (hff' (f.symm a) (mem_of_mem_nhds hu)).unique hf₀'
      -- This follows by a bootstrapping formula expressing the derivative as a
      -- function of `f` itself
      refine ⟨inverse ∘ f' ∘ f.symm, ?_, ?_⟩
      · -- We first check that the derivative of `f` is that formula
        have h_nhds : { y : E | ∃ e : E ≃L[��] F, ↑e = f' y } ∈ �� (f.symm a) := by
          have hf₀' := f₀'.nhds
          rw [← eq_f₀'] at hf₀'
          exact hf'.continuousAt.preimage_mem_nhds hf₀'
        obtain ⟨t, htu, ht, htf⟩ := mem_nhds_iff.mp (Filter.inter_mem hu h_nhds)
        use f.target ∩ f.symm ⁻¹' t
        refine ⟨IsOpen.mem_nhds ?_ ?_, ?_⟩
        · exact f.isOpen_inter_preimage_symm ht
        · exact mem_inter ha (mem_preimage.mpr htf)
        intro x hx
        obtain ⟨hxu, e, he⟩ := htu hx.2
        have h_deriv : HasFDerivAt f (e : E →L[��] F) (f.symm x) := by
          rw [he]
          exact hff' (f.symm x) hxu
        convert f.hasFDerivAt_symm hx.1 h_deriv
        simp [← he]
      · -- Then we check that the formula, being a composition of `ContDiff` pieces, is
        -- itself `ContDiff`
        have h_deriv₁ : ContDiffAt �� n inverse (f' (f.symm a)) := by
          rw [eq_f₀']
          exact contDiffAt_map_inverse _
        have h_deriv₂ : ContDiffAt �� n f.symm a := by
          refine IH (hf.of_le ?_)
          norm_cast
          exact Nat.le_succ n
        exact (h_deriv₁.comp _ hf').comp _ h_deriv₂
    | top Itop => exact contDiffAt_infty.mpr fun n ↦ Itop n (contDiffAt_infty.mp hf n)

/-- If `f` is an `n` times continuously differentiable homeomorphism,
and if the derivative of `f` at each point is a continuous linear equivalence,
then `f.symm` is `n` times continuously differentiable.

This is one of the easy parts of the inverse function theorem: it assumes that we already have
an inverse function. -/

theorem Homeomorph.contDiff_symm [CompleteSpace E] (f : E ≃ₜ F) {f₀' : E → E ≃L[��] F}
    (hf₀' : ∀ a, HasFDerivAt f (f₀' a : E →L[��] F) a) (hf : ContDiff �� n (f : E → F)) :
    ContDiff �� n (f.symm : F → E) :=
  contDiff_iff_contDiffAt.2 fun x =>
    f.toOpenPartialHomeomorph.contDiffAt_symm (mem_univ x) (hf₀' _) hf.contDiffAt

/-- Let `f` be a local homeomorphism of a nontrivially normed field, let `a` be a point in its
target. if `f` is `n` times continuously differentiable at `f.symm a`, and if the derivative at
`f.symm a` is nonzero, then `f.symm` is `n` times continuously differentiable at the point `a`.

This is one of the easy parts of the inverse function theorem: it assumes that we already have
an inverse function. -/

theorem OpenPartialHomeomorph.contDiffAt_symm_deriv [CompleteSpace ��]
    (f : OpenPartialHomeomorph �� ��) {f₀' a : ��} (h₀ : f₀' ≠ 0) (ha : a ∈ f.target)
    (hf₀' : HasDerivAt f f₀' (f.symm a)) (hf : ContDiffAt �� n f (f.symm a)) :
    ContDiffAt �� n f.symm a :=
  f.contDiffAt_symm ha (hf₀'.hasFDerivAt_equiv h₀) hf

/-- Let `f` be an `n` times continuously differentiable homeomorphism of a nontrivially normed
field.  Suppose that the derivative of `f` is never equal to zero. Then `f.symm` is `n` times
continuously differentiable.

This is one of the easy parts of the inverse function theorem: it assumes that we already have
an inverse function. -/

theorem Homeomorph.contDiff_symm_deriv [CompleteSpace ��] (f : �� ≃ₜ ��) {f' : �� → ��}
    (h₀ : ∀ x, f' x ≠ 0) (hf' : ∀ x, HasDerivAt f (f' x) x) (hf : ContDiff �� n (f : �� → ��)) :
    ContDiff �� n (f.symm : �� → ��) :=
  contDiff_iff_contDiffAt.2 fun x =>
    f.toOpenPartialHomeomorph.contDiffAt_symm_deriv (h₀ _) (mem_univ x) (hf' _) hf.contDiffAt

namespace OpenPartialHomeomorph

variable (��)

/-- Restrict an open partial homeomorphism to the subsets of the source and target
that consist of points `x ∈ f.source`, `y = f x ∈ f.target`
such that `f` is `C^n` at `x` and `f.symm` is `C^n` at `y`.

Note that `n` is a natural number or `ω`, but not `∞`,
because the set of points of `C^∞`-smoothness of `f` is not guaranteed to be open. -/

@[simps! apply symm_apply source target]
def restrContDiff (f : OpenPartialHomeomorph E F) (n : ℕ∞ω) (hn : n ≠ ∞) :
    OpenPartialHomeomorph E F :=
  haveI H : f.IsImage {x | ContDiffAt �� n f x ∧ ContDiffAt �� n f.symm (f x)}
      {y | ContDiffAt �� n f.symm y ∧ ContDiffAt �� n f (f.symm y)} := fun x hx ↦ by
    simp [hx, and_comm]
  H.restr <| isOpen_iff_mem_nhds.2 fun _ ⟨hxs, hxf, hxf'⟩ ↦
    inter_mem (f.open_source.mem_nhds hxs) <| (hxf.eventually hn).and <|
    f.continuousAt hxs (hxf'.eventually hn)

lemma contDiffOn_restrContDiff_source (f : OpenPartialHomeomorph E F) {n : ℕ∞ω}
    (hn : n ≠ ∞) : ContDiffOn �� n f (f.restrContDiff �� n hn).source :=
  fun _x hx ↦ hx.2.1.contDiffWithinAt

lemma contDiffOn_restrContDiff_target (f : OpenPartialHomeomorph E F) {n : ℕ∞ω}
    (hn : n ≠ ∞) : ContDiffOn �� n f.symm (f.restrContDiff �� n hn).target :=
  fun _x hx ↦ hx.2.1.contDiffWithinAt

end OpenPartialHomeomorph

end FunctionInverse

section RestrictScalars

/-!
### Restricting from `ℂ` to `ℝ`, or generally from `��'` to `��`

If a function is `n` times continuously differentiable over `ℂ`, then it is `n` times continuously
differentiable over `ℝ`. In this paragraph, we give variants of this statement, in the general
situation where `ℂ` and `ℝ` are replaced respectively by `��'` and `��` where `��'` is a normed algebra
over `��`.
-/



variable (��)
variable {��' : Type*} [NontriviallyNormedField ��'] [NormedAlgebra �� ��']
variable [NormedSpace ��' E] [IsScalarTower �� ��' E]
variable [NormedSpace ��' F] [IsScalarTower �� ��' F]
variable {p' : E → FormalMultilinearSeries ��' E F}

theorem HasFTaylorSeriesUpToOn.restrictScalars {n : ℕ∞ω}
    (h : HasFTaylorSeriesUpToOn n f p' s) :
    HasFTaylorSeriesUpToOn n f (fun x => (p' x).restrictScalars ��) s where
  zero_eq x hx := h.zero_eq x hx
  fderivWithin m hm x hx :=
    ((ContinuousMultilinearMap.restrictScalarsLinear ��).hasFDerivAt.comp_hasFDerivWithinAt x <|
        (h.fderivWithin m hm x hx).restrictScalars �� :)
  cont m hm := ContinuousMultilinearMap.continuous_restrictScalars.comp_continuousOn (h.cont m hm)

theorem ContDiffWithinAt.restrict_scalars (h : ContDiffWithinAt ��' n f s x) :
    ContDiffWithinAt �� n f s x := by
  match n with
  | ω =>
    obtain ⟨u, u_mem, p', hp', Hp'⟩ := h
    refine ⟨u, u_mem, _, hp'.restrictScalars _, fun i ↦ ?_⟩
    change AnalyticOn �� (fun x ↦ ContinuousMultilinearMap.restrictScalarsLinear �� (p' x i)) u
    apply AnalyticOnNhd.comp_analyticOn _ (Hp' i).restrictScalars (Set.mapsTo_univ _ _)
    exact ContinuousLinearMap.analyticOnNhd _ _
  | (n : ℕ∞) =>
    intro m hm
    rcases h m hm with ⟨u, u_mem, p', hp'⟩
    exact ⟨u, u_mem, _, hp'.restrictScalars _⟩

theorem ContDiffOn.restrict_scalars (h : ContDiffOn ��' n f s) : ContDiffOn �� n f s := fun x hx =>
  (h x hx).restrict_scalars _

theorem ContDiffAt.restrict_scalars (h : ContDiffAt ��' n f x) : ContDiffAt �� n f x :=
  contDiffWithinAt_univ.1 <| h.contDiffWithinAt.restrict_scalars _

theorem ContDiff.restrict_scalars (h : ContDiff ��' n f) : ContDiff �� n f :=
  contDiff_iff_contDiffAt.2 fun _ => h.contDiffAt.restrict_scalars _

end RestrictScalars

Messung
CHZG
9210010097

¤ Dauer der Verarbeitung: 0.9 Sekunden  (vorverarbeitet am  2026-11-24) ¤

*© Formatika GbR, Deutschland







                                                                                                                                                                                                                                                                                                                                                                                                     

 

Neuigkeiten

Aktuelles
Motto des Tages

Open Source Software


Gedichte
Musik
Bilder

Jenseits des Üblichen

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1,188,137
#Domains=863,992