Skip to content

feat(NumberTheory/Bernoulli): von Staudt-Clausen theorem#34906

Open
seewoo5 wants to merge 79 commits intoleanprover-community:masterfrom
seewoo5:vsc
Open

feat(NumberTheory/Bernoulli): von Staudt-Clausen theorem#34906
seewoo5 wants to merge 79 commits intoleanprover-community:masterfrom
seewoo5:vsc

Conversation

@seewoo5
Copy link
Copy Markdown
Collaborator

@seewoo5 seewoo5 commented Feb 6, 2026


Rado's proof ("A New Proof of a Theorem of v. Staudt", JLMS 1935) of von Staudt-Clausen theorem. Initially written by AxiomProver (see commit 97a308e) with further golfs with Claude and Codex.

Open in Gitpod

seewoo5 and others added 14 commits February 5, 2026 15:46
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…n section

- Remove unused `Units.val_mk` from simp calls
- Convert deprecated `induction'` to `induction` in three lemmas
- Fix whitespace: `2*m` → `2 * m`, `2*k` → `2 * k`, `)^(` → `) ^ (`
- Fix resulting lines exceeding 100 char limit
- Add `set_option linter.style.longFile 1800` for file length

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Simplify several proofs by inlining single-use haves, using pow_succ,
removing redundant intermediate steps, and leveraging Finset.sum_filter.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…a proofs

Remove `have IH := IH` identity bindings, unwrap redundant
`have h1 := ...; exact h1` wrapping, inline single-use omega
equalities into pow_succ rewrites, and merge consecutive single-use
rewrite steps.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…o callers

Merge trivial single-use helper lemmas directly into their sole call sites
to reduce declaration count and improve code locality.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Golf 4 verbose proofs by replacing manual have-chains with
field_simp/ring, leveraging core_algebraic_identity, and eliminating
redundant cast round-trips. Net savings: ~130 lines.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…callers

Remove lemmas with 1-2 line proof bodies that are used only once or not
at all, inlining their proofs at call sites to reduce indirection.

Dead code removed: pIntegral_add, pIntegral_even_term
Inlined: geom_sum_of_root_of_unity, generator_pow_card_sub_one_eq_one,
pIntegral_neg_pow_div_two, pIntegral_odd_term, power_sum_eq_faulhaber,
coprime_add_of_coprime_den, von_staudt_clausen_pos

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…d_rest

Replace ~120-line proof with ~15-line proof using by_cases on divisibility,
Finset.add_sum_erase for the positive case, and Finset.filter_congr for
the negative case.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions Bot added large-import Automatically added label for PRs with a significant increase in transitive imports t-number-theory Number theory (also use t-algebra or t-analysis to specialize) labels Feb 6, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 6, 2026

PR summary ee3a5404e5

Import changes exceeding 2%

% File
+25.56% Mathlib.NumberTheory.Bernoulli

Import changes for modified files

Dependency changes

File Base Count Head Count Change
Mathlib.NumberTheory.Bernoulli 1639 2058 +419 (+25.56%)
Import changes for all files
Files Import difference
8 files Mathlib.NumberTheory.ModularForms.DedekindEta Mathlib.NumberTheory.ModularForms.Delta Mathlib.NumberTheory.ModularForms.Derivative Mathlib.NumberTheory.ModularForms.Discriminant Mathlib.NumberTheory.ModularForms.EisensteinSeries.E2.MDifferentiable Mathlib.NumberTheory.ModularForms.EisensteinSeries.E2.Summable Mathlib.NumberTheory.ModularForms.EisensteinSeries.E2.Transform Mathlib.NumberTheory.ModularForms.EisensteinSeries.QExpansion
8
Mathlib.NumberTheory.LSeries.HurwitzZetaValues 80
Mathlib.NumberTheory.ZetaValues 81
Mathlib.NumberTheory.BernoulliPolynomials 417
Mathlib.NumberTheory.Bernoulli 419
Mathlib.Algebra.BigOperators.Group.Finset.Rat (new file) 701

Declarations diff

+ bernoulli_add_indicator_eq_sub
+ choose_two_mul_succ_mul_div_eq
+ den_sum_dvd_lcm_den
+ den_sum_dvd_prod_den
+ factorization_succ_le_sub_one
+ faulhaber_sum_div_prime_eq
+ not_dvd_den_bernoulli_add_indicator
+ not_dvd_den_vonStaudt_sum
+ pIntegral
+ pIntegral_bernoulli_even_term
+ pIntegral_choose_mul_pow_div
+ pIntegral_faulhaber_sum
+ pIntegral_mul
+ pIntegral_pow_div
+ prod_one_div_prime_den_coprime
+ sum_one_div_prime_eq_indicator_div_add
+ sum_pow_add_indicator_eq_zero
+ sum_pow_filter_eq_faulhaber
+ vonStaudtIndicator
+ vonStaudtPrimes
+ vonStaudt_clausen

You can run this locally as follows
## summary with just the declaration names:
./scripts/pr_summary/declarations_diff.sh <optional_commit>

## more verbose report:
./scripts/pr_summary/declarations_diff.sh long <optional_commit>

The doc-module for scripts/pr_summary/declarations_diff.sh contains some details about this script.


No changes to technical debt.

This script lives in the mathlib-ci repository. To run it locally, from your mathlib4 directory:

git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
../mathlib-ci/scripts/reporting/technical-debt-metrics.sh pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

seewoo5 and others added 9 commits February 5, 2026 22:23
Add missing documentation for `vonStaudtIndicator` and `pIntegral`.
Remove unused arguments from `cast_ne_zero_of_mem_filter`,
`generator_pow_ne_one`, `sum_units_pow_eq_zero_of_not_dvd`,
`den_pow_div_dvd`, `valuation_bound`, `pIntegral_pow_div_factor`,
and `pIntegral_T1`, along with their call sites.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove unused arguments from pIntegral_T2, pIntegral_case_one,
even_term_decomposition_identity, power_sum_indicator_divisible_by_p,
divisibility_to_rat_eq, sum_other_primes_coprime_p_pos, and cascading
unused arguments in pIntegral_second_term, pIntegral_coeff_term,
pIntegral_first_term, and pIntegral_even_term_in_sum.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ther

Move pIntegral_of_int, pIntegral_mul, pIntegral_mul_int,
pIntegral_mul_nat, and pIntegral_sub to directly after pIntegral_sum
so all basic pIntegral closure properties are co-located.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove pIntegral_nat_mul and use pIntegral_int_mul directly at call
sites, relying on Lean's automatic ℕ → ℤ coercion.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Merge the single-use von_staudt_clausen_zero lemma directly into the
k = 0 case of von_staudt_clausen.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove single-use i1_term_forms_eq and replace it with a shorter
`convert` + `push_cast` + `field_simp` proof inside pIntegral_i1_term_in_sum.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@seewoo5 seewoo5 marked this pull request as draft February 6, 2026 17:14
seewoo5 and others added 3 commits February 7, 2026 21:03
Inline ~20 single-use helper lemmas into their callers, reducing
the file from ~1053 to 884 lines and from ~80 to 60 definitions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Comment thread Mathlib/NumberTheory/Bernoulli.lean Outdated
Comment thread Mathlib/NumberTheory/Bernoulli.lean Outdated
Comment thread Mathlib/NumberTheory/Bernoulli.lean Outdated
Comment thread Mathlib/NumberTheory/Bernoulli.lean Outdated
Comment thread Mathlib/NumberTheory/Bernoulli.lean Outdated
Comment thread Mathlib/NumberTheory/Bernoulli.lean Outdated
Comment thread Mathlib/NumberTheory/Bernoulli.lean Outdated
Comment thread Mathlib/NumberTheory/Bernoulli.lean Outdated
@MichaelStollBayreuth MichaelStollBayreuth added the awaiting-author A reviewer has asked the author a question or requested changes. label Apr 24, 2026
@MichaelStollBayreuth
Copy link
Copy Markdown
Contributor

MichaelStollBayreuth commented Apr 25, 2026

A general remark: omega should be replaced by lia throughout. (As far as I know, omega is supposed to be phased out, and lia ("linear integer arithmetic", which is part of grind) is the deignated replacement.)

Comment thread Mathlib/NumberTheory/Bernoulli.lean Outdated
Comment thread Mathlib/NumberTheory/Bernoulli.lean Outdated
Comment thread Mathlib/NumberTheory/Bernoulli.lean Outdated
@MichaelStollBayreuth
Copy link
Copy Markdown
Contributor

I think more of the explicit arguments of the private lemmas could be made implicit.

Copy link
Copy Markdown
Contributor

@MichaelStollBayreuth MichaelStollBayreuth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could actually move the new lemmas to Mathlib.Algebra.GCDMonoid.FinsetLemmas (and change the title/module docstring of that file to also mention Rat.den or so).



@[expose] public section

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
namespace Rat


theorem den_sum_dvd_prod_den {ι : Type*} (s : Finset ι) (f : ι → ℚ) :
(∑ i ∈ s, f i).den ∣ ∏ i ∈ s, (f i).den :=
dvd_trans (den_sum_dvd_lcm_den s f) (s.lcm_dvd_prod (fun i ↦ (f i).den))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
dvd_trans (den_sum_dvd_lcm_den s f) (s.lcm_dvd_prod (fun i ↦ (f i).den))
(den_sum_dvd_lcm_den s f).trans <|s.lcm_dvd_prod _
theorem den_prod_dvd_prod_den {ι : Type*} (s : Finset ι) (f : ι → ℚ) :
(∏ i ∈ s, f i).den ∣ ∏ i ∈ s, (f i).den := by
classical
induction s using Finset.induction_on with
| empty => simp
| insert _ _ has ih =>
simp_rw [Finset.prod_insert has]
exact (mul_den_dvd ..).trans <| mul_dvd_mul_left _ ih
end Rat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-author A reviewer has asked the author a question or requested changes. large-import Automatically added label for PRs with a significant increase in transitive imports LLM-generated PRs with substantial input from LLMs - review accordingly t-number-theory Number theory (also use t-algebra or t-analysis to specialize)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants