Skip to content

Commit

Permalink
feat: the line derivative is measurable (#7055)
Browse files Browse the repository at this point in the history
Last prerequisite for Rademacher theorem in #7003.

Along the way, we weaken the second-countability assumptions for strong measurability of the derivative and the right derivative.
  • Loading branch information
sgouezel committed Sep 15, 2023
1 parent 518115d commit ee0f4af
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 17 deletions.
1 change: 1 addition & 0 deletions Mathlib.lean
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ import Mathlib.Analysis.Calculus.IteratedDeriv
import Mathlib.Analysis.Calculus.LHopital
import Mathlib.Analysis.Calculus.LagrangeMultipliers
import Mathlib.Analysis.Calculus.LineDeriv.Basic
import Mathlib.Analysis.Calculus.LineDeriv.Measurable
import Mathlib.Analysis.Calculus.LocalExtr.Basic
import Mathlib.Analysis.Calculus.LocalExtr.Polynomial
import Mathlib.Analysis.Calculus.LocalExtr.Rolle
Expand Down
68 changes: 51 additions & 17 deletions Mathlib/Analysis/Calculus/FDeriv/Measurable.lean
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel, Yury Kudryashov
-/
import Mathlib.Analysis.Calculus.Deriv.Basic
import Mathlib.Analysis.Calculus.Deriv.Slope
import Mathlib.MeasureTheory.Constructions.BorelSpace.ContinuousLinearMap
import Mathlib.MeasureTheory.Function.StronglyMeasurable.Basic

Expand Down Expand Up @@ -82,8 +83,7 @@ set_option linter.uppercaseLean3 false -- A B D

noncomputable section

open Set Metric Asymptotics Filter ContinuousLinearMap MeasureTheory
open TopologicalSpace (SecondCountableTopology)
open Set Metric Asymptotics Filter ContinuousLinearMap MeasureTheory TopologicalSpace
open scoped Topology

namespace ContinuousLinearMap
Expand Down Expand Up @@ -436,9 +436,12 @@ theorem measurable_deriv [MeasurableSpace 𝕜] [OpensMeasurableSpace 𝕜] [Mea
#align measurable_deriv measurable_deriv

theorem stronglyMeasurable_deriv [MeasurableSpace 𝕜] [OpensMeasurableSpace 𝕜]
[SecondCountableTopology F] (f : 𝕜 → F) : StronglyMeasurable (deriv f) := by
[h : SecondCountableTopologyEither 𝕜 F] (f : 𝕜 → F) : StronglyMeasurable (deriv f) := by
borelize F
exact (measurable_deriv f).stronglyMeasurable
rcases h.out with h𝕜|hF
· exact stronglyMeasurable_iff_measurable_separable.2
⟨measurable_deriv f, isSeparable_range_deriv _⟩
· exact (measurable_deriv f).stronglyMeasurable
#align strongly_measurable_deriv stronglyMeasurable_deriv

theorem aemeasurable_deriv [MeasurableSpace 𝕜] [OpensMeasurableSpace 𝕜] [MeasurableSpace F]
Expand All @@ -447,7 +450,8 @@ theorem aemeasurable_deriv [MeasurableSpace 𝕜] [OpensMeasurableSpace 𝕜] [M
#align ae_measurable_deriv aemeasurable_deriv

theorem aestronglyMeasurable_deriv [MeasurableSpace 𝕜] [OpensMeasurableSpace 𝕜]
[SecondCountableTopology F] (f : 𝕜 → F) (μ : Measure 𝕜) : AEStronglyMeasurable (deriv f) μ :=
[SecondCountableTopologyEither 𝕜 F] (f : 𝕜 → F) (μ : Measure 𝕜) :
AEStronglyMeasurable (deriv f) μ :=
(stronglyMeasurable_deriv f).aestronglyMeasurable
#align ae_strongly_measurable_deriv aestronglyMeasurable_deriv

Expand Down Expand Up @@ -786,18 +790,33 @@ theorem measurable_derivWithin_Ici [MeasurableSpace F] [BorelSpace F] :
((measurableSet_of_differentiableWithinAt_Ici _).compl.inter (MeasurableSet.const _))
#align measurable_deriv_within_Ici measurable_derivWithin_Ici

theorem stronglyMeasurable_derivWithin_Ici [SecondCountableTopology F] :
StronglyMeasurable fun x => derivWithin f (Ici x) x := by
theorem stronglyMeasurable_derivWithin_Ici :
StronglyMeasurable (fun x derivWithin f (Ici x) x) := by
borelize F
exact (measurable_derivWithin_Ici f).stronglyMeasurable
apply stronglyMeasurable_iff_measurable_separable.2 ⟨measurable_derivWithin_Ici f, ?_⟩
obtain ⟨t, t_count, ht⟩ : ∃ t : Set ℝ, t.Countable ∧ Dense t := exists_countable_dense ℝ
suffices H : range (fun x ↦ derivWithin f (Ici x) x) ⊆ closure (Submodule.span ℝ (f '' t)) from
IsSeparable.mono (t_count.image f).isSeparable.span.closure H
rintro - ⟨x, rfl⟩
suffices H' : range (fun y ↦ derivWithin f (Ici x) y) ⊆ closure (Submodule.span ℝ (f '' t)) from
H' (mem_range_self _)
apply range_derivWithin_subset_closure_span_image
calc Ici x
= closure (Ioi x ∩ closure t) := by simp [dense_iff_closure_eq.1 ht]
_ ⊆ closure (closure (Ioi x ∩ t)) := by
apply closure_mono
simpa [inter_comm] using (isOpen_Ioi (a := x)).closure_inter (s := t)
_ ⊆ closure (Ici x ∩ t) := by
rw [closure_closure]
exact closure_mono (inter_subset_inter_left _ Ioi_subset_Ici_self)
#align strongly_measurable_deriv_within_Ici stronglyMeasurable_derivWithin_Ici

theorem aemeasurable_derivWithin_Ici [MeasurableSpace F] [BorelSpace F] (μ : Measure ℝ) :
AEMeasurable (fun x => derivWithin f (Ici x) x) μ :=
(measurable_derivWithin_Ici f).aemeasurable
#align ae_measurable_deriv_within_Ici aemeasurable_derivWithin_Ici

theorem aestronglyMeasurable_derivWithin_Ici [SecondCountableTopology F] (μ : Measure ℝ) :
theorem aestronglyMeasurable_derivWithin_Ici (μ : Measure ℝ) :
AEStronglyMeasurable (fun x => derivWithin f (Ici x) x) μ :=
(stronglyMeasurable_derivWithin_Ici f).aestronglyMeasurable
#align ae_strongly_measurable_deriv_within_Ici aestronglyMeasurable_derivWithin_Ici
Expand All @@ -815,18 +834,17 @@ theorem measurable_derivWithin_Ioi [MeasurableSpace F] [BorelSpace F] :
simpa [derivWithin_Ioi_eq_Ici] using measurable_derivWithin_Ici f
#align measurable_deriv_within_Ioi measurable_derivWithin_Ioi

theorem stronglyMeasurable_derivWithin_Ioi [SecondCountableTopology F] :
StronglyMeasurable fun x => derivWithin f (Ioi x) x := by
borelize F
exact (measurable_derivWithin_Ioi f).stronglyMeasurable
theorem stronglyMeasurable_derivWithin_Ioi :
StronglyMeasurable (fun x ↦ derivWithin f (Ioi x) x) := by
simpa [derivWithin_Ioi_eq_Ici] using stronglyMeasurable_derivWithin_Ici f
#align strongly_measurable_deriv_within_Ioi stronglyMeasurable_derivWithin_Ioi

theorem aemeasurable_derivWithin_Ioi [MeasurableSpace F] [BorelSpace F] (μ : Measure ℝ) :
AEMeasurable (fun x => derivWithin f (Ioi x) x) μ :=
(measurable_derivWithin_Ioi f).aemeasurable
#align ae_measurable_deriv_within_Ioi aemeasurable_derivWithin_Ioi

theorem aestronglyMeasurable_derivWithin_Ioi [SecondCountableTopology F] (μ : Measure ℝ) :
theorem aestronglyMeasurable_derivWithin_Ioi (μ : Measure ℝ) :
AEStronglyMeasurable (fun x => derivWithin f (Ioi x) x) μ :=
(stronglyMeasurable_derivWithin_Ioi f).aestronglyMeasurable
#align ae_strongly_measurable_deriv_within_Ioi aestronglyMeasurable_derivWithin_Ioi
Expand Down Expand Up @@ -986,11 +1004,27 @@ theorem measurable_deriv_with_param [LocallyCompactSpace 𝕜] [MeasurableSpace
simpa only [fderiv_deriv] using measurable_fderiv_apply_const_with_param 𝕜 hf 1

theorem stronglyMeasurable_deriv_with_param [LocallyCompactSpace 𝕜] [MeasurableSpace 𝕜]
[OpensMeasurableSpace 𝕜] [SecondCountableTopology F]
[OpensMeasurableSpace 𝕜] [h : SecondCountableTopologyEither α F]
{f : α → 𝕜 → F} (hf : Continuous f.uncurry) :
StronglyMeasurable (fun (p : α × 𝕜) ↦ deriv (f p.1) p.2) := by
borelize F
exact (measurable_deriv_with_param hf).stronglyMeasurable
rcases h.out with hα|hF
· have : ProperSpace 𝕜 := properSpace_of_locallyCompactSpace 𝕜
apply stronglyMeasurable_iff_measurable_separable.2 ⟨measurable_deriv_with_param hf, ?_⟩
have : range (fun (p : α × 𝕜) ↦ deriv (f p.1) p.2)
⊆ closure (Submodule.span 𝕜 (range f.uncurry)) := by
rintro - ⟨p, rfl⟩
have A : deriv (f p.1) p.2 ∈ closure (Submodule.span 𝕜 (range (f p.1))) := by
rw [← image_univ]
apply range_deriv_subset_closure_span_image _ dense_univ (mem_range_self _)
have B : range (f p.1) ⊆ range (f.uncurry) := by
rintro - ⟨x, rfl⟩
exact mem_range_self (p.1, x)
exact closure_mono (Submodule.span_mono B) A
apply (IsSeparable.span _).closure.mono this
rw [← image_univ]
exact (isSeparable_of_separableSpace univ).image hf
· exact (measurable_deriv_with_param hf).stronglyMeasurable

theorem aemeasurable_deriv_with_param [LocallyCompactSpace 𝕜] [MeasurableSpace 𝕜]
[OpensMeasurableSpace 𝕜] [MeasurableSpace F]
Expand All @@ -999,7 +1033,7 @@ theorem aemeasurable_deriv_with_param [LocallyCompactSpace 𝕜] [MeasurableSpac
(measurable_deriv_with_param hf).aemeasurable

theorem aestronglyMeasurable_deriv_with_param [LocallyCompactSpace 𝕜] [MeasurableSpace 𝕜]
[OpensMeasurableSpace 𝕜] [SecondCountableTopology F]
[OpensMeasurableSpace 𝕜] [SecondCountableTopologyEither α F]
{f : α → 𝕜 → F} (hf : Continuous f.uncurry) (μ : Measure (α × 𝕜)) :
AEStronglyMeasurable (fun (p : α × 𝕜) ↦ deriv (f p.1) p.2) μ :=
(stronglyMeasurable_deriv_with_param hf).aestronglyMeasurable
Expand Down
109 changes: 109 additions & 0 deletions Mathlib/Analysis/Calculus/LineDeriv/Measurable.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/-
Copyright (c) 2023 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel
-/
import Mathlib.Analysis.Calculus.LineDeriv.Basic
import Mathlib.Analysis.Calculus.FDeriv.Measurable

/-! # Measurability of the line derivative
We prove in `measurable_lineDeriv` that the line derivative of a function (with respect to a
locally compact scalar field) is measurable, provided the function is continuous.
In `measurable_lineDeriv_uncurry`, assuming additionally that the source space is second countable,
we show that `(x, v) ↦ lineDeriv 𝕜 f x v` is also measurable.
An assumption such as continuity is necessary, as otherwise one could alternate in a non-measurable
way between differentiable and non-differentiable functions along the various lines
directed by `v`.
-/

open MeasureTheory
open TopologicalSpace (SecondCountableTopology)

variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] [LocallyCompactSpace 𝕜]
{E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] [MeasurableSpace E] [OpensMeasurableSpace E]
{F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] [CompleteSpace F]
{f : E → F} {v : E}

/-!
Measurability of the line derivative `lineDeriv 𝕜 f x v` with respect to a fixed direction `v`.
-/

theorem measurableSet_lineDifferentiableAt (hf : Continuous f) :
MeasurableSet {x : E | LineDifferentiableAt 𝕜 f x v} := by
borelize 𝕜
let g : E → 𝕜 → F := fun x t ↦ f (x + t • v)
have hg : Continuous g.uncurry := by apply hf.comp; continuity
exact measurable_prod_mk_right (measurableSet_of_differentiableAt_with_param 𝕜 hg)

theorem measurable_lineDeriv [MeasurableSpace F] [BorelSpace F]
(hf : Continuous f) : Measurable (fun x ↦ lineDeriv 𝕜 f x v) := by
borelize 𝕜
let g : E → 𝕜 → F := fun x t ↦ f (x + t • v)
have hg : Continuous g.uncurry := by apply hf.comp; continuity
exact (measurable_deriv_with_param hg).comp measurable_prod_mk_right

theorem stronglyMeasurable_lineDeriv [SecondCountableTopologyEither E F] (hf : Continuous f) :
StronglyMeasurable (fun x ↦ lineDeriv 𝕜 f x v) := by
borelize 𝕜
let g : E → 𝕜 → F := fun x t ↦ f (x + t • v)
have hg : Continuous g.uncurry := by apply hf.comp; continuity
exact (stronglyMeasurable_deriv_with_param hg).comp_measurable measurable_prod_mk_right

theorem aemeasurable_lineDeriv [MeasurableSpace F] [BorelSpace F]
(hf : Continuous f) (μ : Measure E) :
AEMeasurable (fun x ↦ lineDeriv 𝕜 f x v) μ :=
(measurable_lineDeriv hf).aemeasurable

theorem aestronglyMeasurable_lineDeriv [SecondCountableTopologyEither E F]
(hf : Continuous f) (μ : Measure E) :
AEStronglyMeasurable (fun x ↦ lineDeriv 𝕜 f x v) μ :=
(stronglyMeasurable_lineDeriv hf).aestronglyMeasurable

/-!
Measurability of the line derivative `lineDeriv 𝕜 f x v` when varying both `x` and `v`. For this,
we need an additional second countability assumption on `E` to make sure that open sets are
measurable in `E × E`.
-/

variable [SecondCountableTopology E]

theorem measurableSet_lineDifferentiableAt_uncurry (hf : Continuous f) :
MeasurableSet {p : E × E | LineDifferentiableAt 𝕜 f p.1 p.2} := by
borelize 𝕜
let g : (E × E) → 𝕜 → F := fun p t ↦ f (p.1 + t • p.2)
have : Continuous g.uncurry :=
hf.comp <| (continuous_fst.comp continuous_fst).add
<| continuous_snd.smul (continuous_snd.comp continuous_fst)
have M_meas : MeasurableSet {q : (E × E) × 𝕜 | DifferentiableAt 𝕜 (g q.1) q.2} :=
measurableSet_of_differentiableAt_with_param 𝕜 this
exact measurable_prod_mk_right M_meas

theorem measurable_lineDeriv_uncurry [MeasurableSpace F] [BorelSpace F]
(hf : Continuous f) : Measurable (fun (p : E × E) ↦ lineDeriv 𝕜 f p.1 p.2) := by
borelize 𝕜
let g : (E × E) → 𝕜 → F := fun p t ↦ f (p.1 + t • p.2)
have : Continuous g.uncurry :=
hf.comp <| (continuous_fst.comp continuous_fst).add
<| continuous_snd.smul (continuous_snd.comp continuous_fst)
exact (measurable_deriv_with_param this).comp measurable_prod_mk_right

theorem stronglyMeasurable_lineDeriv_uncurry (hf : Continuous f) :
StronglyMeasurable (fun (p : E × E) ↦ lineDeriv 𝕜 f p.1 p.2) := by
borelize 𝕜
let g : (E × E) → 𝕜 → F := fun p t ↦ f (p.1 + t • p.2)
have : Continuous g.uncurry :=
hf.comp <| (continuous_fst.comp continuous_fst).add
<| continuous_snd.smul (continuous_snd.comp continuous_fst)
exact (stronglyMeasurable_deriv_with_param this).comp_measurable measurable_prod_mk_right

theorem aemeasurable_lineDeriv_uncurry [MeasurableSpace F] [BorelSpace F]
(hf : Continuous f) (μ : Measure (E × E)) :
AEMeasurable (fun (p : E × E) ↦ lineDeriv 𝕜 f p.1 p.2) μ :=
(measurable_lineDeriv_uncurry hf).aemeasurable

theorem aestronglyMeasurable_lineDeriv_uncurry (hf : Continuous f) (μ : Measure (E × E)) :
AEStronglyMeasurable (fun (p : E × E) ↦ lineDeriv 𝕜 f p.1 p.2) μ :=
(stronglyMeasurable_lineDeriv_uncurry hf).aestronglyMeasurable

0 comments on commit ee0f4af

Please sign in to comment.