Skip to content

Commit 2b405ca

Browse files
authored
chore: delete sigma-finite trim wrappers (incl. ForMathlib library) (#24)
The two local lemmas asserting `SigmaFinite (μ.trim hm)` for finite `μ` are now redundant: mathlib provides `isFiniteMeasure_trim` as an instance, and `IsFiniteMeasure.toSigmaFinite` chains automatically. Verified empirically that `inferInstance` finds `SigmaFinite (μ.trim hm)` at every former call site without help. Deleted: - ForMathlib/MeasureTheory/Measure/TrimInstances.lean (the `sigmaFinite_trim` wrapper, body `inferInstance`) - Exchangeability/Probability/CondExpBasic.lean (`sigmaFinite_trim_of_le`, body `(inferInstance : IsFiniteMeasure _).toSigmaFinite`) Replaced 5 call sites with `inferInstance`: - Exchangeability/Probability/CondExp.lean: 3 sites (lines 333, 359, 611); also dropped the `export MeasureTheory.Measure (sigmaFinite_trim)` line and the corresponding module-docstring entries. - Exchangeability/Probability/CondIndep/KallenbergIndicator.lean:100 - Exchangeability/DeFinetti/ViaL2/AlphaIicCE.lean:287 - Exchangeability/DeFinetti/ViaMartingale/FutureFiltration.lean:111 (the local `sigmaFinite_trim_tailSigma` lemma is now `inferInstance` too) Touches local API/export shape: - Removed `import ForMathlib.MeasureTheory.Measure.TrimInstances` from CondExp.lean. - Removed `ForMathlib.lean` (was a single-line root that imported only the deleted file). - Removed the `[[lean_lib]] name = "ForMathlib"` section and `"ForMathlib"` from `defaultTargets` in `lakefile.toml`. Project now has only one lean_lib (`Exchangeability`). The `ForMathlib` directory was a staging area for upstreaming candidates (per PR #13's blueprint). It is no longer needed — the only file it contained has been superseded by mathlib instance inference. Net -80 lines, 3 files deleted, build down from 3531 to 3528 jobs.
1 parent 9d14638 commit 2b405ca

8 files changed

Lines changed: 10 additions & 90 deletions

File tree

Exchangeability/DeFinetti/ViaL2/AlphaIicCE.lean

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,7 @@ lemma alphaIicCE_right_continuous_at
283283
have hm_le : TailSigma.tailSigma X ≤ (inferInstance : MeasurableSpace Ω) :=
284284
TailSigma.tailSigma_le X hX_meas
285285
haveI h_fact : Fact (TailSigma.tailSigma X ≤ (inferInstance : MeasurableSpace Ω)) := ⟨hm_le⟩
286-
haveI h_sf : SigmaFinite (μ.trim hm_le) :=
287-
Exchangeability.Probability.sigmaFinite_trim μ hm_le
286+
haveI h_sf : SigmaFinite (μ.trim hm_le) := inferInstance
288287

289288
-- Step 1: Get decreasing rational sequence u_n → t with u_n > t
290289
obtain ⟨u, u_anti, u_gt, u_tendsto⟩ := Real.exists_seq_rat_strictAnti_tendsto t

Exchangeability/DeFinetti/ViaMartingale/FutureFiltration.lean

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,8 @@ case requires manual construction of spanning sets and is a mathlib gap. -/
105105
lemma sigmaFinite_trim_tailSigma {Ω α : Type*} {m₀ : MeasurableSpace Ω} [MeasurableSpace α]
106106
{μ : @Measure Ω m₀} [IsFiniteMeasure μ]
107107
(X : ℕ → Ω → α) (hX : ∀ n, Measurable (X n)) :
108-
SigmaFinite (μ.trim (tailSigma_le X hX)) := by
109-
classical
110-
-- Use the infrastructure from CondExp.lean
111-
exact Exchangeability.Probability.sigmaFinite_trim μ (tailSigma_le X hX)
108+
SigmaFinite (μ.trim (tailSigma_le X hX)) :=
109+
inferInstance
112110

113111
/-! ### Helper lemmas for futureFiltration properties -/
114112

Exchangeability/Probability/CondExp.lean

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ Authors: Cameron Freer
66
import Exchangeability.Probability.CondExpBasic
77
import Exchangeability.Probability.CondProb
88
import Exchangeability.Probability.IntegrationHelpers
9-
import ForMathlib.MeasureTheory.Measure.TrimInstances
109
import Mathlib.Probability.Independence.Basic
1110
import Mathlib.Probability.Independence.Conditional
1211
import Mathlib.Probability.Martingale.Basic
@@ -65,10 +64,6 @@ This file centralizes these patterns to keep the main proofs clean and maintaina
6564
- **Purpose**: Avoids typeclass metavariable issues in `μ[f | m]`
6665
- **Used in**: ViaMartingale finite-future sigma algebras
6766
68-
- **`sigmaFinite_trim`**: Trimmed measure is sigma-finite (when base is finite)
69-
- **Used in**: ViaMartingale, multiple sub-σ-algebra constructions
70-
- **Note**: `isFiniteMeasure_trim` is now in mathlib as an instance
71-
7267
## Design Philosophy
7368
7469
**Extract patterns that:**
@@ -299,19 +294,6 @@ lemma condExp_indicator_mul_indicator_of_condIndep
299294
These wrappers provide explicit instance management for conditional expectations
300295
with sub-σ-algebras, working around Lean 4 typeclass inference issues. -/
301296

302-
/-! ### SigmaFinite instances for trimmed measures
303-
304-
When working with conditional expectations on sub-σ-algebras, we need `SigmaFinite (μ.trim hm)`.
305-
For probability measures (or finite measures), this follows from showing the trimmed measure
306-
is still finite.
307-
308-
These lemmas are now in `ForMathlib.MeasureTheory.Measure.TrimInstances` and re-exported here
309-
for backward compatibility. -/
310-
311-
-- Re-export from ForMathlib for backward compatibility
312-
-- Note: isFiniteMeasure_trim is now in mathlib (as an instance), only sigmaFinite_trim is local
313-
export MeasureTheory.Measure (sigmaFinite_trim)
314-
315297
/-! ### Stable conditional expectation wrapper
316298
317299
This wrapper manages typeclass instances to avoid metavariable issues
@@ -330,7 +312,7 @@ def condExpWith {Ω : Type*} {m₀ : MeasurableSpace Ω}
330312
classical
331313
haveI : IsFiniteMeasure μ := inferInstance
332314
-- IsFiniteMeasure (μ.trim _hm) is now automatic via mathlib instance
333-
haveI : SigmaFinite (μ.trim _hm) := sigmaFinite_trim μ _hm
315+
haveI : SigmaFinite (μ.trim _hm) := inferInstance
334316
exact μ[f | m]
335317

336318
/-! ### Bridge lemma for indicator factorization
@@ -356,7 +338,7 @@ lemma condexp_indicator_inter_bridge
356338
μ[B.indicator (fun _ => (1 : ℝ)) | m]) := by
357339
classical
358340
-- Install trimmed instances (IsFiniteMeasure is automatic via mathlib)
359-
haveI : SigmaFinite (μ.trim hm) := sigmaFinite_trim μ hm
341+
haveI : SigmaFinite (μ.trim hm) := inferInstance
360342
-- Forward to the proven lemma
361343
exact condExp_indicator_mul_indicator_of_condIndep hm hmF hmH hCI hA hB
362344

@@ -608,7 +590,7 @@ lemma condExp_mul_pullout {Ω : Type*} {m₀ : MeasurableSpace Ω} {μ : Measure
608590
have hg_bound : ∀ᵐ ω ∂μ, ‖g ω‖ ≤ C := ae_of_all μ fun ω => (Real.norm_eq_abs _).le.trans (hC ω)
609591

610592
-- Provide typeclass instances explicitly (IsFiniteMeasure is automatic via mathlib)
611-
haveI : SigmaFinite (μ.trim hm) := sigmaFinite_trim μ hm
593+
haveI : SigmaFinite (μ.trim hm) := inferInstance
612594

613595
-- Now condExp_stronglyMeasurable_mul_of_bound can resolve instances
614596
have h := condExp_stronglyMeasurable_mul_of_bound hm hg_strong hf C hg_bound

Exchangeability/Probability/CondExpBasic.lean

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ improve compilation speed.
1717
1818
## Main components
1919
20-
### σ-Finiteness
21-
- `sigmaFinite_trim_of_le`: Trimmed measure inherits σ-finiteness from finite measures
22-
2320
### Indicators
2421
- `indicator_iUnion_tsum_of_pairwise_disjoint`: Union of disjoint indicators equals their sum
2522
@@ -40,14 +37,6 @@ to work with multiple measurable space structures (e.g., for trimmed measures).
4037
section variable `[MeasurableSpace Ω]` unused for those lemmas, requiring `set_option
4138
linter.unusedSectionVars false`. -/
4239

43-
set_option linter.unusedSectionVars false in
44-
/-- If `μ` is finite, then any trim of `μ` is σ-finite. -/
45-
@[nolint unusedArguments]
46-
lemma sigmaFinite_trim_of_le {m m₀ : MeasurableSpace Ω}
47-
(μ : Measure Ω) [IsFiniteMeasure μ] (hm : m ≤ m₀) :
48-
SigmaFinite (μ.trim hm) :=
49-
(inferInstance : IsFiniteMeasure (μ.trim hm)).toSigmaFinite
50-
5140
set_option linter.unusedSectionVars false in
5241
/-- For pairwise disjoint sets, the indicator of the union equals
5342
the pointwise `tsum` of indicators (for ℝ-valued constants). -/

Exchangeability/Probability/CondIndep/KallenbergIndicator.lean

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,9 @@ lemma condIndep_indicator_of_dropInfoY
9696
obtain ⟨S, hS_meas, rfl⟩ := hs
9797
exact hS_meas.preimage (hZ.prodMk hW)
9898

99-
-- SigmaFinite instance for trim (needed for condExp lemmas)
100-
haveI hσZW : SigmaFinite (μ.trim hmZW_le) := sigmaFinite_trim_of_le μ hmZW_le
99+
-- SigmaFinite instance for trim (needed for condExp lemmas); provided automatically
100+
-- via mathlib's `isFiniteMeasure_trim` instance + `IsFiniteMeasure.toSigmaFinite`.
101+
haveI hσZW : SigmaFinite (μ.trim hmZW_le) := inferInstance
101102

102103
-- Integrability of indicators (bounded by 1)
103104
have hIndA_int : Integrable indA μ := (integrable_const 1).indicator (hA.preimage hY)

ForMathlib.lean

Lines changed: 0 additions & 1 deletion
This file was deleted.

ForMathlib/MeasureTheory/Measure/TrimInstances.lean

Lines changed: 0 additions & 45 deletions
This file was deleted.

lakefile.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "exchangeability"
22
version = "0.1.0"
3-
defaultTargets = ["Exchangeability", "ForMathlib"]
3+
defaultTargets = ["Exchangeability"]
44

55
[[require]]
66
name = "mathlib"
@@ -11,8 +11,5 @@ rev = "v4.30.0-rc2"
1111
name = "checkdecls"
1212
git = "https://github.com/PatrickMassot/checkdecls.git"
1313

14-
[[lean_lib]]
15-
name = "ForMathlib"
16-
1714
[[lean_lib]]
1815
name = "Exchangeability"

0 commit comments

Comments
 (0)