Skip to content

chore: autoGolf proof bodies across 61 files (−841 lines)#16

Closed
cameronfreer wants to merge 6 commits into
mainfrom
proof-golfing
Closed

chore: autoGolf proof bodies across 61 files (−841 lines)#16
cameronfreer wants to merge 6 commits into
mainfrom
proof-golfing

Conversation

@cameronfreer

Copy link
Copy Markdown
Owner

Summary

Automated proof golfing via autoGolf.lean --preset power --min-line-reduction 2 --compress-by-exact --inplace, applied across the entire Exchangeability/ tree.

What changed

  • 61 files modified, net −841 lines (340 insertions, 1181 deletions)
  • Collapses multi-step have chains into direct lemma applications
  • Replaces verbose proof terms with shorter tactic sequences
  • Compresses by exact <term> to just <term>
  • All changes are proof-body-only — no API or signature changes

Biggest wins

File Lines saved Heartbeat reduction
Probability/CondExpExtras.lean −211 8.1%
DeFinetti/ViaL2/CesaroConvergence.lean −108
DeFinetti/ViaL2/BlockAverages.lean −62 14.6%
DeFinetti/ViaL2/AlphaConvergence.lean −49 1.1%
DeFinetti/ViaKoopman/KoopmanCommutation.lean −47 19.4%
DeFinetti/ViaL2/MoreL2Helpers.lean −43 1.0%
DeFinetti/L2Helpers.lean −38 4.0%
DeFinetti/ViaL2/DirectingMeasureIntegral.lean −37
Probability/CondIndep/Bounded/Extension.lean −28 2.6%
DeFinetti/ViaMartingale/FutureRectangles.lean −23 11.8%

Commits (6 batches)

  1. 3a800187 — Core, Contractability, DeFinetti top-level, ViaKoopman (22 files, −285)
  2. 55cc5890 — ViaL2 (BlockAverages, AlphaConvergence, etc.) (4 files, −90)
  3. 6ed5220a — DeFinetti remaining (CesaroConvergence, ViaMartingale, etc.) (12 files, −265)
  4. e6f0de29 — Ergodic + Util (6 files, −58)
  5. c4f32a14 — PathSpace + Tail (4 files, −39)
  6. f0c7df73 — Probability (partial) + revert broken KoopmanMeanErgodic (15 files, −104)

Note on KoopmanMeanErgodic

autoGolf incorrectly replaced two proofs in Ergodic/KoopmanMeanErgodic.lean with assumption (which passed its internal check but failed during lake build). Batch 6 reverts that file to its original state.

Files still to process

The following 11 files in Probability/ were not reached by autoGolf (the run was stopped partway through):

  • Probability/Martingale/Convergence.lean (may have been partially processed)
  • Probability/Martingale/Crossings.lean
  • Probability/Martingale/OrderDual.lean
  • Probability/Martingale/Reverse.lean
  • Probability/MartingaleExtras.lean
  • Probability/MeasureKernels.lean
  • Probability/SigmaAlgebraHelpers.lean
  • Probability/TimeReversalCrossing.lean
  • Probability/TripleLawDropInfo.lean
  • Probability/TripleLawDropInfo/DropInfo.lean
  • Probability/TripleLawDropInfo/PairLawHelpers.lean

The following files were processed but had 0 suggestions (no changes needed):
CesaroHelpers, CondExpBasic, CondExpHelpers, CondExpHelpers/AEComb, CondIndep, CondIndep/Basic, CondIndep/Bounded, ConditionalKernel, ConditionalKernel/CondExpKernel, ConditionalKernel/JointLawEq, Martingale, Bridge/CesaroToCondExp.

Test plan

  • lake build passes on all 3296 modules
  • No new sorrys introduced
  • Only standard axioms (propext, quot.sound, Classical.choice)

Automated golfing via autoGolf.lean --preset power --min-line-reduction 2:
- Collapse multi-step proofs to direct lemma applications
- Replace verbose `have` chains with term-mode proofs
- Compress `by exact` to direct terms
- Notable: KoopmanCommutation −47 lines, L2Helpers −38 lines, Core −21 lines

Net: 22 files changed, ~70 insertions, ~305 deletions
Notable: BlockAverages −62 lines (17 suggestions, 14.6% heartbeat reduction),
AlphaConvergence −49 lines, AlphaIicCE −19 lines, BlockAvgDef −9 lines
CesaroConvergence −108 lines (15 suggestions), FutureRectangles −23,
FiniteProduct −21, MoreL2Helpers −43, DirectingMeasureIntegral −37,
ViaMartingale −12, CondExpConvergence −11, PairLawEquality −8
Ergodic: InvariantSigma −19, KoopmanMeanErgodic −12, BirkhoffAvgCLM −8
Util: ProductBounds −2, StrictMono −3
CylinderHelpers −11, ShiftInvariantMeasure −13, TailSigma −9,
CondExpShiftInvariance −6
…rgodic (batch 6)

Probability: CondExpExtras −211 lines, Extension −28, CondExp −12,
Projection −8, Convergence −6, Indicator −5, plus smaller changes.
Reverts invalid autoGolf suggestions in KoopmanMeanErgodic.lean.
cameronfreer added a commit that referenced this pull request May 18, 2026
KernelBridge.lean defines a local `Kernel.IndepFun.comp` lemma that
duplicates mathlib's `ProbabilityTheory.Kernel.IndepFun.comp` (specialized
to ℝ-valued composition targets). It has zero callers in the codebase:
the `_indep.comp` calls in `Probability/CondIndep/Indicator.lean` and
`Probability/CondIndep/Basic.lean` are on plain `IndepFun` (measure-based),
which resolves to mathlib's `ProbabilityTheory.IndepFun.comp` — a different
lemma in a different namespace.

This delete is stronger than PR #16's autoGolf suggestion (which kept the
lemma as a thin wrapper). Since there is nothing to wrap to, removing it
outright is cleaner.

- Exchangeability/DeFinetti/ViaKoopman/KernelBridge.lean:
  - delete the 30-line proof + 10-line docstring (lines 181-219)
  - update the module docstring "Main results" bullet list to match
cameronfreer added a commit that referenced this pull request May 18, 2026
)

Mines safe-subset replacements from the PR #16 autoGolf draft and applies
them to current main, skipping the suspicious subset (lia / bare
assumption / Real.ext_cauchy / grind only on non-arithmetic goals).

`fun_prop` adoptions (replace hand-built `Measurable.const_mul +
Finset.measurable_sum + .comp` chains):

- `DeFinetti/ViaKoopman/BlockAverage.lean`     (1 site)
- `DeFinetti/ViaL2/BlockAvgDef.lean`           (1 site)
- `DeFinetti/ViaL2/AlphaConvergence.lean`      (2 sites)
- `DeFinetti/ViaL2/CesaroConvergence.lean`     (3 sites)
- `DeFinetti/ViaL2/DirectingMeasureIntegral.lean` (4 sites, incl. one
  Integrable wrap via `fun_prop`)
- `DeFinetti/ViaL2/MainConvergence.lean`       (1 site)
- `DeFinetti/ViaMartingale/PairLawEquality.lean` (1 site,
  `measurable_consRV` → fun_prop)
- `Ergodic/ShiftInvariantRepresentatives.lean` (1 site,
  `measurable_coe_real_ereal.comp …` → fun_prop)
- `Core.lean:683` — collapse `simpa using (show … from by fun_prop)` to
  bare `fun_prop`.

Named-lemma replacements:

- `DeFinetti/ViaL2/DirectingMeasureIntegral.lean` 2× hand-built
  `IsPiSystem` proof for `Set.range Iic` → `isPiSystem_Iic`.
- `Contractability.lean:perm_range_eq` — 4-line `ext`+`use`+`simp` →
  `Finset.image_univ_equiv σ`.

Minor `by exact` removals in `BlockAvgDef.lean`.

Out of scope (per the audit, suspicious-category from #16):
- `BlockAverage.lean:82` `congr 1; ring` → `lia` swap (opaque substitution
  on non-arithmetic context).
- The proof-golfing-branch reversion of #18's
  `exists_perm_extending_strictMono` refactor.

Net -62 lines across 10 files. Build clean (3527 jobs), axioms standard,
0 sorries. No statement or signature changes.
cameronfreer added a commit that referenced this pull request May 25, 2026
…Info (#112)

Eight LSP-verified proof-body shrinks in the files that the bulk autoGolf
run in PR #16 never reached. Each site was probed individually rather
than via `exact?` (which timed out on these measure-heavy goals).

* `Crossings/Pathwise.lean:54` `up_neg_flip_eq_down`:
  body collapses to `rfl` — `downcrossingsBefore` is definitionally
  `upcrossingsBefore (-b) (-a) (negProcess X)`, so both sides of the
  lemma unfold to the same `⨆ N, ...` term.
* `Crossings/Pathwise.lean:123` `upcrossingsBefore_congr`:
  four lines (`simp only`/`congr`/`ext`/`rw`) collapse to
  `simp [upcrossingsBefore, upperCrossingTime_congr h]`.
* `Reverse.lean:80` `revCEFinite_martingale`:
  inline the local `have : 𝔽 (N-i) ≤ 𝔽 (N-j)` into the final
  `condExp_condExp_of_le` call.
* `Crossings/Bounds.lean:45` `hL1_bdd`:
  drop the `simp only [revCEFinite]`; `eLpNorm_one_condExp_le_eLpNorm`
  unifies definitionally.
* `Crossings/AntitoneLimit.lean:350` `h_tower`:
  rewrite as a term-mode `fun n => condExp_condExp_of_le (iInf_le 𝔽 n)
  (h_le n)`.
* `Crossings/AntitoneLimit.lean:368` `hL1_conv_Xn`:
  six-line `have`/`simp_rw`/`exact` collapses to a single
  `simpa [hXn_def, eLpNorm_sub_comm] using hL1_conv`.
* `TripleLawDropInfo/PairLawHelpers.lean:40` `marginal_law_eq_of_pair_law`:
  five lines (two `have`s + final `rw`) become a single
  `simpa [Measure.map_map …] using congrArg (Measure.map Prod.snd) h_law`.
* `TripleLawDropInfo/DropInfo.lean:211` final square-zero step:
  the trailing `have : ... = 0; linarith` two-liner collapses to a single
  `nlinarith [sq_nonneg (μ₂ ω - μ₁ ω)]`.

Net: 6 files, +11 / −30 (−19 lines).
@cameronfreer

Copy link
Copy Markdown
Owner Author

Closing as stale + conflicting. The valuable golf from this branch has been cherry-picked into focused, LSP-verified PRs that landed cleanly on top of main:

The remaining diff vs. current main is mostly stale conflicts with no remaining unique value worth rebasing through.

@cameronfreer
cameronfreer deleted the proof-golfing branch May 26, 2026 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant