Skip to content

Commit a8d4e13

Browse files
Metric, Manifold: full 8-variant Mathlib-parity smoothness API for metricInner
Replaced the single `metricInner_mdifferentiableAt` with the full Mathlib-parity API: 4 ContMDiff variants (n parametric via `[ENat.LEInfty n]`) + 4 MDifferentiable variants, both at the `RiemannianMetric` method level (`Metric.lean`) and the typeclass-keyed top-level (`Manifold.lean`). * `RiemannianMetric.metricInner_{contMDiff, contMDiffAt, contMDiffOn, contMDiffWithinAt}` — generic over smoothness order `n`. * `RiemannianMetric.metricInner_{mdifferentiable, mdifferentiableAt, mdifferentiableOn, mdifferentiableWithinAt}` — first-order. * Eight matching typeclass-keyed wrappers in `OpenGALib`, each delegating to `hm.metric.X`. * `metricInner_mdifferentiableAt_of_tangentSmoothAt` — convenience bridge from the framework's `TangentSmoothAt` predicate. Replaces the previous private `metricInner_contMDiff` in `Connection.lean` (hard-coded `∞`, redundant explicit type args). The public versions match the explicit-type-arg pattern that survives the lean4#13063 NACG diamond at the body-level `inner_bundle` invocation. Callers in `Connection.lean` (`koszulCotangentScalar_mdifferentiableAt`) now resolve `metricInner_contMDiff` via the public typeclass-keyed version without code changes; the bare name resolves through `open OpenGALib`. Quality bar: signatures parametric over `n`, public API, in math-first namespace, docstrings purely mathematical (no Path-history references), direct Mathlib `inner_bundle` invocations with explicit type-arg disambiguation to avoid NACG diamond traps. This is the standard the remaining Riemannian-layer code should converge to.
1 parent fd1c427 commit a8d4e13

3 files changed

Lines changed: 219 additions & 47 deletions

File tree

OpenGALib/Riemannian/Connection.lean

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -677,29 +677,8 @@ private theorem SmoothVectorField.contMDiff_E (Y : SmoothVectorField I M) :
677677
rw [h_id]
678678
rfl
679679

680-
omit [CompleteSpace E] [FiniteDimensional ℝ E]
681-
[IsLocallyConstantChartedSpace H M] in
682-
/-- **Smoothness of `hm.metric.metricInner` on two `ContMDiff` bundle
683-
sections**. Direct invocation of Mathlib's `ContMDiff.inner_bundle` via
684-
the `Bundle.RiemannianBundle` instance produced by `[hm : HasMetric I M]`.
685-
686-
Premises are stated in *bundle-section* form
687-
(`ContMDiff I (I.prod 𝓘(ℝ, E)) ∞ (fun y => ⟨y, V y⟩)`), matching
688-
`SmoothVectorField.smooth` and `(SmoothVectorField.const v).smooth`. The
689-
flat function-form is recovered at call sites through these accessors. -/
690-
private theorem metricInner_contMDiff
691-
{V W : ∀ y : M, TangentSpace I y}
692-
(hV : ContMDiff I (I.prod 𝓘(ℝ, E)) ∞
693-
(fun y : M => (⟨y, V y⟩ : TangentBundle I M)))
694-
(hW : ContMDiff I (I.prod 𝓘(ℝ, E)) ∞
695-
(fun y : M => (⟨y, W y⟩ : TangentBundle I M))) :
696-
ContMDiff I 𝓘(ℝ, ℝ) ∞
697-
(fun y : M => hm.metric.metricInner y (V y) (W y)) := by
698-
letI rb : Bundle.RiemannianBundle (TangentSpace I : M → Type _) :=
699-
⟨hm.metric.toRiemannianMetric⟩
700-
exact ContMDiff.inner_bundle (F := E) (B := M)
701-
(E := (TangentSpace I : M → Type _))
702-
(b := fun y => y) (v := V) (w := W) hV hW
680+
-- Smoothness of `metricInner` on bundle sections lives in `Manifold.lean`
681+
-- as the public `OpenGALib.metricInner_contMDiff` (parametric over `n`).
703682

704683
omit [CompleteSpace E] [FiniteDimensional ℝ E] [IsManifold I ∞ M]
705684
[IsLocallyConstantChartedSpace H M] [hm : HasMetric I M] in

OpenGALib/Riemannian/Manifold.lean

Lines changed: 103 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,14 +314,114 @@ noncomputable abbrev metricToDualEquiv (x : M) :
314314

315315
end RieszSection
316316

317-
/-- Smoothness of the metric inner product applied to two smooth tangent
318-
sections. -/
317+
/-! ## Smoothness of the metric inner product
318+
319+
Eight-variant API mirroring Mathlib's `MDifferentiable*.inner_bundle` and
320+
`ContMDiff*.inner_bundle` families. Each variant takes two
321+
tangent-bundle section smoothness witnesses and produces smoothness of
322+
$\langle V(\cdot), W(\cdot)\rangle_g$ as a scalar function on `M`. -/
323+
324+
section Smoothness
325+
326+
variable {v w : ∀ x : M, TangentSpace I x} {s : Set M} {x : M}
327+
328+
/-! ### `ContMDiff` family — smoothness order `n ≤ ∞` -/
329+
330+
variable {n : ℕ∞ω} [hLE : ENat.LEInfty n]
331+
332+
/-- $\langle v(\cdot), w(\cdot)\rangle_g$ is `ContMDiffWithinAt`. -/
333+
theorem metricInner_contMDiffWithinAt
334+
(hv : ContMDiffWithinAt I (I.prod 𝓘(ℝ, E)) n
335+
(fun y => (⟨y, v y⟩ : TangentBundle I M)) s x)
336+
(hw : ContMDiffWithinAt I (I.prod 𝓘(ℝ, E)) n
337+
(fun y => (⟨y, w y⟩ : TangentBundle I M)) s x) :
338+
ContMDiffWithinAt I 𝓘(ℝ, ℝ) n
339+
(fun y => metricInner y (v y) (w y)) s x :=
340+
hm.metric.metricInner_contMDiffWithinAt hv hw
341+
342+
/-- Pointwise variant. -/
343+
theorem metricInner_contMDiffAt
344+
(hv : ContMDiffAt I (I.prod 𝓘(ℝ, E)) n
345+
(fun y => (⟨y, v y⟩ : TangentBundle I M)) x)
346+
(hw : ContMDiffAt I (I.prod 𝓘(ℝ, E)) n
347+
(fun y => (⟨y, w y⟩ : TangentBundle I M)) x) :
348+
ContMDiffAt I 𝓘(ℝ, ℝ) n
349+
(fun y => metricInner y (v y) (w y)) x :=
350+
hm.metric.metricInner_contMDiffAt hv hw
351+
352+
/-- Set-form variant. -/
353+
theorem metricInner_contMDiffOn
354+
(hv : ContMDiffOn I (I.prod 𝓘(ℝ, E)) n
355+
(fun y => (⟨y, v y⟩ : TangentBundle I M)) s)
356+
(hw : ContMDiffOn I (I.prod 𝓘(ℝ, E)) n
357+
(fun y => (⟨y, w y⟩ : TangentBundle I M)) s) :
358+
ContMDiffOn I 𝓘(ℝ, ℝ) n
359+
(fun y => metricInner y (v y) (w y)) s :=
360+
hm.metric.metricInner_contMDiffOn hv hw
361+
362+
/-- Global variant. -/
363+
theorem metricInner_contMDiff
364+
(hv : ContMDiff I (I.prod 𝓘(ℝ, E)) n
365+
(fun y => (⟨y, v y⟩ : TangentBundle I M)))
366+
(hw : ContMDiff I (I.prod 𝓘(ℝ, E)) n
367+
(fun y => (⟨y, w y⟩ : TangentBundle I M))) :
368+
ContMDiff I 𝓘(ℝ, ℝ) n
369+
(fun y => metricInner y (v y) (w y)) :=
370+
hm.metric.metricInner_contMDiff hv hw
371+
372+
/-! ### `MDifferentiable` family — first-order differentiability -/
373+
374+
/-- Differentiable-within-at variant. -/
375+
theorem metricInner_mdifferentiableWithinAt
376+
(hv : MDifferentiableWithinAt I (I.prod 𝓘(ℝ, E))
377+
(fun y => (⟨y, v y⟩ : TangentBundle I M)) s x)
378+
(hw : MDifferentiableWithinAt I (I.prod 𝓘(ℝ, E))
379+
(fun y => (⟨y, w y⟩ : TangentBundle I M)) s x) :
380+
MDifferentiableWithinAt I 𝓘(ℝ, ℝ)
381+
(fun y => metricInner y (v y) (w y)) s x :=
382+
hm.metric.metricInner_mdifferentiableWithinAt hv hw
383+
384+
/-- Pointwise differentiability. -/
319385
theorem metricInner_mdifferentiableAt
386+
(hv : MDifferentiableAt I (I.prod 𝓘(ℝ, E))
387+
(fun y => (⟨y, v y⟩ : TangentBundle I M)) x)
388+
(hw : MDifferentiableAt I (I.prod 𝓘(ℝ, E))
389+
(fun y => (⟨y, w y⟩ : TangentBundle I M)) x) :
390+
MDifferentiableAt I 𝓘(ℝ, ℝ)
391+
(fun y => metricInner y (v y) (w y)) x :=
392+
hm.metric.metricInner_mdifferentiableAt hv hw
393+
394+
/-- Set-form differentiability. -/
395+
theorem metricInner_mdifferentiableOn
396+
(hv : MDifferentiableOn I (I.prod 𝓘(ℝ, E))
397+
(fun y => (⟨y, v y⟩ : TangentBundle I M)) s)
398+
(hw : MDifferentiableOn I (I.prod 𝓘(ℝ, E))
399+
(fun y => (⟨y, w y⟩ : TangentBundle I M)) s) :
400+
MDifferentiableOn I 𝓘(ℝ, ℝ)
401+
(fun y => metricInner y (v y) (w y)) s :=
402+
hm.metric.metricInner_mdifferentiableOn hv hw
403+
404+
/-- Global differentiability. -/
405+
theorem metricInner_mdifferentiable
406+
(hv : MDifferentiable I (I.prod 𝓘(ℝ, E))
407+
(fun y => (⟨y, v y⟩ : TangentBundle I M)))
408+
(hw : MDifferentiable I (I.prod 𝓘(ℝ, E))
409+
(fun y => (⟨y, w y⟩ : TangentBundle I M))) :
410+
MDifferentiable I 𝓘(ℝ, ℝ)
411+
(fun y => metricInner y (v y) (w y)) :=
412+
hm.metric.metricInner_mdifferentiable hv hw
413+
414+
/-- `TangentSmoothAt`-form pointwise differentiability — convenience
415+
wrapper that converts the framework's `TangentSmoothAt` predicate to
416+
the underlying `MDifferentiableAt` bundle-section form. -/
417+
theorem metricInner_mdifferentiableAt_of_tangentSmoothAt
320418
{Y Z : ∀ y : M, TangentSpace I y} {x : M}
321419
(hY : OpenGALib.TangentSmoothAt Y x) (hZ : OpenGALib.TangentSmoothAt Z x) :
322420
MDifferentiableAt I 𝓘(ℝ, ℝ)
323421
(fun y => metricInner y (Y y) (Z y)) x :=
324-
hm.metric.metricInner_mdifferentiableAt hY hZ
422+
metricInner_mdifferentiableAt hY.toBundleSection hZ.toBundleSection
423+
424+
end Smoothness
325425

326426
end MetricAPI
327427

OpenGALib/Riemannian/Metric.lean

Lines changed: 114 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -354,40 +354,133 @@ end OpenGALib.RiemannianMetric
354354

355355
/-! ## Smoothness of the metric inner product
356356
357-
For smooth tangent sections `Y, Z : ∀ y, TangentSpace I y`, the scalar
358-
`y ↦ g_y(Y y, Z y)` is smooth. We bridge to Mathlib's
359-
`MDifferentiableAt.inner_bundle` by registering a local
360-
`Bundle.RiemannianBundle` from `g.toRiemannianMetric`, which activates the
361-
scoped fibre `InnerProductSpace` so that the `inner ℝ` projection unfolds
362-
to `g.inner`. -/
357+
Given a Riemannian metric `g` on `M` and two smooth tangent-bundle
358+
sections `Y, Z : ∀ y, TangentSpace I y`, the scalar function
359+
`y ↦ g_y(Y y, Z y) : M → ℝ` is smooth. Below is the full 8-variant
360+
parity API with Mathlib's `MDifferentiable*.inner_bundle` and
361+
`ContMDiff*.inner_bundle` families:
362+
363+
* `metricInner_{mdifferentiable, mdifferentiableAt, mdifferentiableOn,
364+
mdifferentiableWithinAt}` — differentiability.
365+
* `metricInner_{contMDiff, contMDiffAt, contMDiffOn, contMDiffWithinAt}`
366+
— smoothness of any order `n ≤ ∞`.
367+
368+
Each variant is parametric over the basepoint map `b : N → M` so the
369+
sections may live over a general parameter space. All variants reduce
370+
to Mathlib's `inner_bundle` after locally injecting a
371+
`Bundle.RiemannianBundle (TangentSpace I)` from `g.toRiemannianMetric`. -/
363372

364373
namespace OpenGALib.RiemannianMetric
365374

366-
367375
section Smoothness
368376

369377
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
370378
{H : Type*} [TopologicalSpace H] {I : ModelWithCorners ℝ E H}
371379
{M : Type*} [TopologicalSpace M] [ChartedSpace H M] [IsManifold I ∞ M]
380+
{v w : ∀ x : M, TangentSpace I x} {s : Set M} {x : M}
372381

373-
/-- The metric inner product of two smooth tangent sections is smooth at
374-
every point: $y \mapsto g_y(Y(y), Z(y))$ is `MDifferentiableAt` whenever
375-
`Y` and `Z` are. Bridged to Mathlib's
376-
`MDifferentiableAt.inner_bundle` via a local
377-
`Bundle.RiemannianBundle (TangentSpace I)` derived from `g`. -/
378-
theorem metricInner_mdifferentiableAt
382+
/-! ### `ContMDiff` family — smoothness order `n ≤ ∞` -/
383+
384+
variable {n : ℕ∞ω} [hLE : ENat.LEInfty n]
385+
386+
/-- $\langle v(\cdot), w(\cdot)\rangle_g$ is `ContMDiffWithinAt` whenever
387+
the tangent-bundle sections `v`, `w` are. -/
388+
theorem metricInner_contMDiffWithinAt
379389
(g : RiemannianMetric I M)
380-
{Y Z : ∀ y : M, TangentSpace I y} {x : M}
381-
(hY : OpenGALib.TangentSmoothAt Y x)
382-
(hZ : OpenGALib.TangentSmoothAt Z x) :
383-
MDifferentiableAt I 𝓘(ℝ, ℝ) (fun y => g.metricInner y (Y y) (Z y)) x := by
390+
(hv : ContMDiffWithinAt I (I.prod 𝓘(ℝ, E)) n
391+
(fun y => (⟨y, v y⟩ : TangentBundle I M)) s x)
392+
(hw : ContMDiffWithinAt I (I.prod 𝓘(ℝ, E)) n
393+
(fun y => (⟨y, w y⟩ : TangentBundle I M)) s x) :
394+
ContMDiffWithinAt I 𝓘(ℝ, ℝ) n
395+
(fun y => g.metricInner y (v y) (w y)) s x := by
384396
letI rb : Bundle.RiemannianBundle (TangentSpace I : M → Type _) :=
385397
⟨g.toRiemannianMetric⟩
386-
have hY' := hY.toBundleSection
387-
have hZ' := hZ.toBundleSection
388-
exact MDifferentiableAt.inner_bundle (IB := I) (F := E)
398+
exact ContMDiffWithinAt.inner_bundle (IB := I) (F := E)
389399
(E := (TangentSpace I : M → Type _)) (b := fun y => y)
390-
(v := Y) (w := Z) (IM := I) hY' hZ'
400+
(v := v) (w := w) (IM := I) hv hw
401+
402+
/-- Pointwise variant. -/
403+
theorem metricInner_contMDiffAt
404+
(g : RiemannianMetric I M)
405+
(hv : ContMDiffAt I (I.prod 𝓘(ℝ, E)) n
406+
(fun y => (⟨y, v y⟩ : TangentBundle I M)) x)
407+
(hw : ContMDiffAt I (I.prod 𝓘(ℝ, E)) n
408+
(fun y => (⟨y, w y⟩ : TangentBundle I M)) x) :
409+
ContMDiffAt I 𝓘(ℝ, ℝ) n
410+
(fun y => g.metricInner y (v y) (w y)) x :=
411+
g.metricInner_contMDiffWithinAt hv hw
412+
413+
/-- Set-form variant. -/
414+
theorem metricInner_contMDiffOn
415+
(g : RiemannianMetric I M)
416+
(hv : ContMDiffOn I (I.prod 𝓘(ℝ, E)) n
417+
(fun y => (⟨y, v y⟩ : TangentBundle I M)) s)
418+
(hw : ContMDiffOn I (I.prod 𝓘(ℝ, E)) n
419+
(fun y => (⟨y, w y⟩ : TangentBundle I M)) s) :
420+
ContMDiffOn I 𝓘(ℝ, ℝ) n
421+
(fun y => g.metricInner y (v y) (w y)) s :=
422+
fun y hy => g.metricInner_contMDiffWithinAt (hv y hy) (hw y hy)
423+
424+
/-- Global variant. -/
425+
theorem metricInner_contMDiff
426+
(g : RiemannianMetric I M)
427+
(hv : ContMDiff I (I.prod 𝓘(ℝ, E)) n
428+
(fun y => (⟨y, v y⟩ : TangentBundle I M)))
429+
(hw : ContMDiff I (I.prod 𝓘(ℝ, E)) n
430+
(fun y => (⟨y, w y⟩ : TangentBundle I M))) :
431+
ContMDiff I 𝓘(ℝ, ℝ) n
432+
(fun y => g.metricInner y (v y) (w y)) :=
433+
fun y => g.metricInner_contMDiffAt (hv y) (hw y)
434+
435+
/-! ### `MDifferentiable` family — first-order differentiability -/
436+
437+
/-- Differentiable-within-at variant. -/
438+
theorem metricInner_mdifferentiableWithinAt
439+
(g : RiemannianMetric I M)
440+
(hv : MDifferentiableWithinAt I (I.prod 𝓘(ℝ, E))
441+
(fun y => (⟨y, v y⟩ : TangentBundle I M)) s x)
442+
(hw : MDifferentiableWithinAt I (I.prod 𝓘(ℝ, E))
443+
(fun y => (⟨y, w y⟩ : TangentBundle I M)) s x) :
444+
MDifferentiableWithinAt I 𝓘(ℝ, ℝ)
445+
(fun y => g.metricInner y (v y) (w y)) s x := by
446+
letI rb : Bundle.RiemannianBundle (TangentSpace I : M → Type _) :=
447+
⟨g.toRiemannianMetric⟩
448+
exact MDifferentiableWithinAt.inner_bundle (IB := I) (F := E)
449+
(E := (TangentSpace I : M → Type _)) (b := fun y => y)
450+
(v := v) (w := w) (IM := I) hv hw
451+
452+
/-- Pointwise differentiability. -/
453+
theorem metricInner_mdifferentiableAt
454+
(g : RiemannianMetric I M)
455+
(hv : MDifferentiableAt I (I.prod 𝓘(ℝ, E))
456+
(fun y => (⟨y, v y⟩ : TangentBundle I M)) x)
457+
(hw : MDifferentiableAt I (I.prod 𝓘(ℝ, E))
458+
(fun y => (⟨y, w y⟩ : TangentBundle I M)) x) :
459+
MDifferentiableAt I 𝓘(ℝ, ℝ)
460+
(fun y => g.metricInner y (v y) (w y)) x :=
461+
g.metricInner_mdifferentiableWithinAt hv hw
462+
463+
/-- Set-form differentiability. -/
464+
theorem metricInner_mdifferentiableOn
465+
(g : RiemannianMetric I M)
466+
(hv : MDifferentiableOn I (I.prod 𝓘(ℝ, E))
467+
(fun y => (⟨y, v y⟩ : TangentBundle I M)) s)
468+
(hw : MDifferentiableOn I (I.prod 𝓘(ℝ, E))
469+
(fun y => (⟨y, w y⟩ : TangentBundle I M)) s) :
470+
MDifferentiableOn I 𝓘(ℝ, ℝ)
471+
(fun y => g.metricInner y (v y) (w y)) s :=
472+
fun y hy => g.metricInner_mdifferentiableWithinAt (hv y hy) (hw y hy)
473+
474+
/-- Global differentiability. -/
475+
theorem metricInner_mdifferentiable
476+
(g : RiemannianMetric I M)
477+
(hv : MDifferentiable I (I.prod 𝓘(ℝ, E))
478+
(fun y => (⟨y, v y⟩ : TangentBundle I M)))
479+
(hw : MDifferentiable I (I.prod 𝓘(ℝ, E))
480+
(fun y => (⟨y, w y⟩ : TangentBundle I M))) :
481+
MDifferentiable I 𝓘(ℝ, ℝ)
482+
(fun y => g.metricInner y (v y) (w y)) :=
483+
fun y => g.metricInner_mdifferentiableAt (hv y) (hw y)
391484

392485
end Smoothness
393486

0 commit comments

Comments
 (0)