Skip to content

refactor(Bernstein): decompose the repeated integration-by-parts proof#1168

Merged
tauceti-review-bot[bot] merged 4 commits into
TauCetiProject:mainfrom
CBirkbeck:decompose/chafai-repeated-ibp
Jul 24, 2026
Merged

refactor(Bernstein): decompose the repeated integration-by-parts proof#1168
tauceti-review-bot[bot] merged 4 commits into
TauCetiProject:mainfrom
CBirkbeck:decompose/chafai-repeated-ibp

Conversation

@CBirkbeck

Copy link
Copy Markdown
Contributor

chafai_repeated_ibp was a 76-line induction — the largest proof in
Bernstein/Measures.lean and one of the longest in the repo. Both branches of the induction
were far past the point where a case should be extracted (the base case ~20 lines, the
inductive step ~42), so the mathematical shape of the argument was buried.

Split into three helpers, each proving one self-contained fact:

Lines Declaration What it proves
14 integral_Ioi_neg_iteratedDerivWithin_one the order-one case: ∫_{(x,∞)} -f' = f x - L, by the FTC on [x, T] plus f → L
10 intervalIntegral_neg_one_pow_succ_kernel raising the sign exponent of the order-k kernel negates its integral
31 chafai_repeated_ibp_succ the inductive step: one integration by parts lowers the kernel order k + 1 → k, the boundary term decays, and T → ∞ gives the result
15 chafai_repeated_ibp now just the induction skeleton dispatching to the three

Every resulting proof is comfortably inside the project's ~50-line limit, and the main theorem
reads as the outline of the argument rather than its implementation.

Two incidental improvements fell out of the extraction:

  • the sign-flip step was an inline 13-line have doing intervalIntegral.integral_congr_ae
    by hand; as its own lemma it golfs to a 4-line proof;
  • the base case needed a 10-line hsimpl function-rewrite to strip the 0 + 1 / (0+1-1)!
    dressing off the goal. With the order-one fact stated cleanly in its own lemma, simpa
    discharges that in one line.

No statement changes: chafai_repeated_ibp keeps its exact signature, and its only consumer
(chafaiRescaled_integral_bernsteinKernel_eq_sub_tendsto_atTop) is untouched. All helpers are
private, matching the surrounding ibp_finite_interval / boundary_term_decay /
ibp_kernel_integrableOn machinery they sit with.

Gates: lake build ✓, lake exe axioms (allowlist) ✓, lake exe module-system ✓,
scripts/lint-env.sh PASS ✓.

`chafai_repeated_ibp` was a 76-line induction whose two branches were both far
past the point where a case should be extracted (base ~20 lines, inductive step
~42), burying the shape of the argument.

Extract three private helpers, each a self-contained fact:

* `integral_Ioi_neg_iteratedDerivWithin_one` (14L) — the order-one case
  `∫_(x,∞) -f' = f x - L`, via the FTC on `[x, T]` and `f → L`;
* `intervalIntegral_neg_one_pow_succ_kernel` (10L) — raising the sign exponent
  of the order-`k` kernel negates its integral;
* `chafai_repeated_ibp_succ` (31L) — the inductive step: one integration by
  parts lowers the kernel order, the boundary term decays, `T → ∞` concludes.

`chafai_repeated_ibp` is now a 15-line induction skeleton. Two simplifications
fall out: the sign flip was an inline 13-line `integral_congr_ae` argument that
golfs to 4 lines standalone, and the base case's 10-line `hsimpl` function
rewrite becomes a single `simpa` once the order-one fact is stated cleanly.

No signature changes; the sole consumer is untouched.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@tauceti-review-bot tauceti-review-bot Bot added roadmap/none PR advances no roadmap (infra, refactor, or a Mathlib bump) awaiting-CI CI has not yet reported on the latest commit review-in-progress A review is running on this exact commit right now and removed awaiting-CI CI has not yet reported on the latest commit labels Jul 24, 2026
@kim-em

kim-em commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

AI review — approved

Each rubric is judged independently by multiple review agents; the PR merges only once every rubric is green — any rubric that is not green (changes requested, blocked, errored, stale, or not yet run) blocks the merge. See the rubrics.

rubric state judge summary
correctness approved codex/gpt-5.6-sol The generalized endpoint lemma correctly applies the improper FTC on (x, ∞), and the extracted sign and successor lemmas preserve the original repeated integration-by-parts statement without weakening its hypotheses or conclusions.
reuse approved codex/gpt-5.6-sol The current proof reuses Mathlib’s integral_Ioi_of_hasDerivAt_of_nonpos directly, resolving the prior duplication concern. No direct replacement or materially redundant parallel API was found for the extracted private helpers or generalized endpoint specialization.
scope approved codex/gpt-5.6-sol This is a single-topic refactor of already-merged integration-by-parts mathematics. The endpoint-generalized lemma extracts the existing base-case argument and directly supports the refactored theorem.
attribution approved codex/gpt-5.6-sol The affected files credit the central Chafaï construction and relevant Bernstein references; the refactor and endpoint generalization introduce no additional identifiable source requiring attribution.
api-design approved codex/gpt-5.6-sol The new arbitrary-endpoint integral theorem is a reusable public result with a complete statement, while all proof-specific helpers remain private. No exposed bodies, redundant API, or missing automation annotations warrant changes.
generality approved codex/gpt-5.6-sol The generalized endpoint lemma is at the natural level for derivatives within [0, ∞), while the original zero-endpoint result is correctly retained as a specialization. All assumptions in the extracted private induction helpers are substantively used.
placement approved codex/gpt-5.6-sol The endpoint-general improper-integral theorem is in the canonical completely-monotone integral API, while the Bernstein-specific private helpers remain beside the machinery they use. The PR introduces no evidently wrong imports.
naming approved codex/gpt-5.6-sol The introduced names accurately describe their conclusions, follow adjacent terminology and structural _succ conventions, and introduce no notation.
documentation approved codex/gpt-5.6-sol The new public lemma and extracted helpers have accurate, result-focused docstrings, and the Integral module documentation covers the expanded API.
proof-quality approved codex/gpt-5.6-sol The extracted proofs are focused and robust, with arithmetic normalization handled by automation and the analytic structure documented. No brittle rewrite chain, undocumented definitional-equality manipulation, or missing factoring warrants changes.

♻️ = approved on an earlier commit, re-run before merge.

Reviewing this diff at head 80b22e7. rubrics @ b9539a3. Review spend: $7.19.

Comment thread TauCeti/Analysis/CompletelyMonotone/Bernstein/Measures.lean
@tauceti-review-bot tauceti-review-bot Bot added awaiting-author The build failed or a review requested changes; author action needed and removed review-in-progress A review is running on this exact commit right now labels Jul 24, 2026
Address the documentation review:

* add a docstring to `chafai_repeated_ibp` stating the order-`n` kernel
  identity and its role in the Chafaï reconstruction (the lemma carried only
  inline proof comments before);
* rewrite the `integral_Ioi_neg_iteratedDerivWithin_one` and
  `chafai_repeated_ibp_succ` docstrings to describe what they prove — the
  order-one drop `f x - L`, and that the order-`k` identity implies the
  order-`k + 1` one — instead of narrating the FTC / integration-by-parts /
  limit mechanics, which move into one-line comments inside the proofs.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@tauceti-review-bot tauceti-review-bot Bot added awaiting-CI CI has not yet reported on the latest commit review-in-progress A review is running on this exact commit right now and removed awaiting-author The build failed or a review requested changes; author action needed awaiting-CI CI has not yet reported on the latest commit labels Jul 24, 2026
Comment thread TauCeti/Analysis/CompletelyMonotone/Bernstein/Measures.lean
@tauceti-review-bot tauceti-review-bot Bot added awaiting-author The build failed or a review requested changes; author action needed and removed review-in-progress A review is running on this exact commit right now labels Jul 24, 2026
…tegral to the integral API

Address the placement review: the extracted order-one helper is a general
completely-monotone integral fact with no Bernstein dependency, so it does not
belong as a private Bernstein helper — and it shared a name with the existing
zero-endpoint theorem.

Move it to `Analysis/CompletelyMonotone/Integral.lean` as public API under the
distinct name `IsCompletelyMonotone.integral_Ioi_neg_iteratedDerivWithin_one_of_nonneg`,
next to the zero-endpoint theorem it generalises, and route the Bernstein call
site through it.

Since the existing `integral_Ioi_neg_iteratedDerivWithin_one` is exactly the
`x = 0` case, it is now a one-line corollary (`le_rfl`) rather than a second
near-identical proof; it had no call sites outside its own module docstring.
Module docstring updated to list the new declaration.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@tauceti-review-bot tauceti-review-bot Bot added awaiting-CI CI has not yet reported on the latest commit review-in-progress A review is running on this exact commit right now and removed awaiting-author The build failed or a review requested changes; author action needed awaiting-CI CI has not yet reported on the latest commit labels Jul 24, 2026
Comment thread TauCeti/Analysis/CompletelyMonotone/Integral.lean
@tauceti-review-bot tauceti-review-bot Bot added awaiting-author The build failed or a review requested changes; author action needed and removed review-in-progress A review is running on this exact commit right now labels Jul 24, 2026
…'s improper FTC

Address the reuse review: the arbitrary-endpoint lemma re-derived Mathlib's
improper fundamental theorem of calculus by hand, evaluating on `[x, T]` and
passing to the limit, instead of applying
`integral_Ioi_of_hasDerivAt_of_nonpos` directly.

Supply that theorem's three hypotheses at the endpoint `x` — continuity within
`Ici x`, the derivative on `Ioi x`, and nonpositivity there — and negate. This
is the route the zero-endpoint proof already used, so the general lemma is now
literally that proof with `x` in place of `0`, which is what makes the
zero-endpoint case a `le_rfl` corollary.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@tauceti-review-bot tauceti-review-bot Bot added awaiting-CI CI has not yet reported on the latest commit review-in-progress A review is running on this exact commit right now and removed awaiting-author The build failed or a review requested changes; author action needed awaiting-CI CI has not yet reported on the latest commit labels Jul 24, 2026
@tauceti-review-bot tauceti-review-bot Bot added ready-to-merge CI green and every rubric approved; ready to merge and removed review-in-progress A review is running on this exact commit right now labels Jul 24, 2026
@tauceti-review-bot
tauceti-review-bot Bot added this pull request to the merge queue Jul 24, 2026
Merged via the queue into TauCetiProject:main with commit e015856 Jul 24, 2026
8 checks passed
@tauceti-review-bot tauceti-review-bot Bot removed the ready-to-merge CI green and every rubric approved; ready to merge label Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

roadmap/none PR advances no roadmap (infra, refactor, or a Mathlib bump)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants