import PoincareLib.Geometry.RicciFlow.ReducedGeometry.ReducedVolume.Regularity.Lipschitz.ChartLipschitz import PoincareLib.Geometry.RicciFlow.ReducedGeometry.ReducedVolume.Measure.Calibration.NullTransport import Mathlib.Analysis.Calculus.Rademacher /-! # Rademacher regularity for calibrated metric volume Fixed-chart Lipschitz representatives are differentiable outside a null set for any selected smooth metric. Local null transport is assembled using second countability, with no exceptional time parameter or positive-dimension assumption. -/ set_option autoImplicit false open MeasureTheory Set Filter open scoped Manifold ContDiff Bundle Topology NNReal ENNReal universe u namespace PoincareMT.ReducedVolume variable {n : β„•} {M : Type u} [TopologicalSpace M] [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓑 n) ∞ M] [T3Space M] [SecondCountableTopology M] [MeasurableSpace M] [BorelSpace M] set_option backward.isDefEq.respectTransparency false in /-- Coordinate local Lipschitz regularity gives actual differentiability almost everywhere. -/ theorem calibratedMetricVolume_nondifferentiability_eq_zero (g : RiemannianMetric n M) {f : M β†’ ℝ} (hf : βˆ€ q : M, βˆƒ S : Set (EuclideanSpace ℝ (Fin n)), IsOpen S ∧ extChartAt (𝓑 n) q q ∈ S ∧ S βŠ† (extChartAt (𝓑 n) q).target ∧ βˆƒ K : ℝβ‰₯0, LipschitzOnWith K (f ∘ (extChartAt (𝓑 n) q).symm) S) : calibratedMetricVolume g {q | Β¬ MDifferentiableAt (𝓑 n) (π“˜(ℝ, ℝ)) f q} = 0 := by apply measure_null_of_locally_null intro q _hq obtain ⟨S, hSopen, hqS, _hStarget, K, hLip⟩ := hf q obtain ⟨r, hr, _hrtarget, C, hchart⟩ := inverseChart_local_lipschitz g q let e := extChartAt (𝓑 n) q let U := S ∩ Metric.ball (e q) r have hUopen : IsOpen U := hSopen.inter Metric.isOpen_ball have hqU : e q ∈ U := ⟨hqS, Metric.mem_ball_self hr⟩ let B := {y | y ∈ U ∧ Β¬ DifferentiableAt ℝ (f ∘ e.symm) y} have hBnull : volume B = 0 := by have hgood : βˆ€α΅ y βˆ‚volume, y ∈ U β†’ DifferentiableAt ℝ (f ∘ e.symm) y := by filter_upwards [LipschitzOnWith.ae_differentiableWithinAt_of_mem (ΞΌ := volume) (hLip.mono (show U βŠ† S from inter_subset_left))] with y hy hyU exact (hy hyU).differentiableAt (hUopen.mem_nhds hyU) simpa only [Classical.not_imp] using ae_iff.mp hgood have himage : calibratedMetricVolume g (e.symm '' B) = 0 := calibratedMetricVolume_image_eq_zero_of_lipschitz g (fun _ hy ↦ hy.1.2) hBnull hchart let V := e.source ∩ e ⁻¹' U have hV : V ∈ 𝓝 q := inter_mem (extChartAt_source_mem_nhds (I := 𝓑 n) q) ((continuousAt_extChartAt (I := 𝓑 n) q).preimage_mem_nhds (hUopen.mem_nhds hqU)) refine ⟨V ∩ {x | Β¬ MDifferentiableAt (𝓑 n) (π“˜(ℝ, ℝ)) f x}, inter_mem (mem_nhdsWithin_of_mem_nhds hV) self_mem_nhdsWithin, ?_⟩ apply measure_mono_null _ himage intro x hx refine ⟨e x, ⟨hx.1.2, ?_⟩, e.left_inv hx.1.1⟩ intro hdiff apply hx.2 apply (mdifferentiableAt_iff_source_of_mem_source (I := 𝓑 n) (I' := π“˜(ℝ, ℝ)) (f := f) (x := q) (by simpa only [← extChartAt_source (𝓑 n)] using hx.1.1)).mpr simpa only [modelWithCornersSelf_coe, range_id, mdifferentiableWithinAt_univ] using hdiff.mdifferentiableAt end PoincareMT.ReducedVolume