Skip to content

feat(NumberTheory/ArithmeticFunction): bundle Euler's totient as an arithmetic function - #46097

Open
xroblot wants to merge 3 commits into
leanprover-community:masterfrom
xroblot:totient-lcm-mul-totient-gcd
Open

xroblot wants to merge 3 commits into
leanprover-community:masterfrom
xroblot:totient-lcm-mul-totient-gcd

Conversation

@xroblot

@xroblot xroblot commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

This PR defines Euler's totient function as an arithmetic function, ArithmeticFunction.totient, in a new file NumberTheory/ArithmeticFunction/Totient.lean. It proves that it is multiplicative, that its Dirichlet convolution with ζ is the identity and that the convolution of μ with the identity is the totient. It also proves that φ (lcm m n) * φ (gcd m n) = φ m * φ n.

This supersedes #28676, which was closed by its author. In the discussion there, it was suggested that the bundled version could replace Nat.totient altogether, but there did not seem to be a consensus, so this PR keeps both, with ArithmeticFunction.totient unfolding to Nat.totient. The replacement can be done in a follow-up PR if desired.

🤖 This result is used in the proof of Stickelberger's theorem in #46022. It was extracted by Claude from the SKW project.

@xroblot xroblot added the t-number-theory Number theory (also use t-algebra or t-analysis to specialize) label Nov 16, 2026
@github-actions github-actions Bot added the large-import Automatically added label for PRs with a significant increase in transitive imports label Nov 16, 2026
@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

PR summary 7e7059942b

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference
Mathlib.NumberTheory.ArithmeticFunction.Totient (new file) 1286

Declarations diff (regex)

+ _root_.Nat.totient_lcm_mul_totient_gcd
+ coe_id_mul_coe_moebius
+ coe_moebius_mul_coe_id
+ isMultiplicative_totient
+ totient
+ totient_apply
+ totient_mul_zeta
+ zeta_mul_totient

You can run this locally as follows
## from your `mathlib4` directory:
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci

## summary with just the declaration names:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh <optional_commit>

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

The doc-module for scripts/pr_summary/declarations_diff.sh in the mathlib-ci repository contains some details about this script.

Declarations diff (Lean)

✅ Lean-aware diff — post-build, computed from the Lean environment (commit 7e70599).

  • +8 new declarations
  • −0 removed declarations
+ArithmeticFunction.coe_id_mul_coe_moebius
+ArithmeticFunction.coe_moebius_mul_coe_id
+ArithmeticFunction.isMultiplicative_totient
+ArithmeticFunction.totient
+ArithmeticFunction.totient_apply
+ArithmeticFunction.totient_mul_zeta
+ArithmeticFunction.zeta_mul_totient
+Nat.totient_lcm_mul_totient_gcd

No changes to strong technical debt.

Increase in weak tech debt: (relative, absolute) = (1.00, 0.00)
Current number Change Type (weak)
5156 1 exposed public sections

Current commit 7e7059942b
Reference commit c47f9ad906

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.py 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).

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

✅ PR Title Formatted Correctly

The title of this PR has been updated to match our commit style conventions.
Thank you!

@xroblot xroblot added the WIP Work in progress label Nov 16, 2026
@SnirBroshi

Copy link
Copy Markdown
Collaborator

Cool! Previous attempt at #28676, in which it was also discussed that perhaps the bundled version should simply replace Nat.totient instead of having two of them.

btw may I suggest prefixing the title with "bundle"? (though this check doesn't block merging)

@xroblot

xroblot commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

Cool! Previous attempt at #28676, in which it was also discussed that perhaps the bundled version should simply replace Nat.totient instead of having two of them.

btw may I suggest prefixing the title with "bundle"? (though this check doesn't block merging)

Thanks for the pointer, I hadn't seen that there was already a PR on this. It looks inactive, but I'll contact the author to make sure.

Comment thread Mathlib/Data/Nat/Totient.lean Resolved
@xroblot xroblot changed the title feat(NumberTheory/ArithmeticFunction): Euler's totient as an arithmetic function feat(NumberTheory/ArithmeticFunction): bundle Euler's totient as an arithmetic function Nov 18, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot removed the large-import Automatically added label for PRs with a significant increase in transitive imports label Nov 18, 2026
@xroblot xroblot removed the WIP Work in progress label Nov 18, 2026
@SnirBroshi SnirBroshi added the LLM-generated PRs with substantial input from LLMs - review accordingly label Nov 18, 2026

This branch has not been deployed

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

Labels

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.

2 participants