Skip to content

[Merged by Bors] - feat(NumberTheory/ArithmeticFunction): bundle Euler's totient as an arithmetic function - #46097

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

xroblot wants to merge 5 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. Claude extracted it from my 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 e19e7a2456

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_id_mul_moebius
+ coe_moebius_mul_coe_id
+ isMultiplicative_totient
+ moebius_mul_coe_id
+ 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 e19e7a2).

  • +10 new declarations
  • −0 removed declarations
+ArithmeticFunction.coe_id_mul_coe_moebius
+ArithmeticFunction.coe_id_mul_moebius
+ArithmeticFunction.coe_moebius_mul_coe_id
+ArithmeticFunction.isMultiplicative_totient
+ArithmeticFunction.moebius_mul_coe_id
+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 e19e7a2456
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 <[email protected]>
@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
@MichaelStollBayreuth

Copy link
Copy Markdown
Contributor

LGTM. @SnirBroshi anything else, or are you OK with where this is now?

@SnirBroshi SnirBroshi added the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Nov 28, 2026
@xroblot xroblot removed the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Nov 28, 2026

@SnirBroshi SnirBroshi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks!

maintainer merge

@github-actions

Copy link
Copy Markdown

🚀 Pull request has been placed on the maintainer queue by SnirBroshi.

@mathlib-triage mathlib-triage Bot added the maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. label Nov 29, 2026

@riccardobrasca riccardobrasca left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

bors merge

@mathlib-bors mathlib-bors Bot added the ready-to-merge This PR has been sent to bors. label Nov 30, 2026
@mathlib-triage mathlib-triage Bot removed the maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. label Nov 30, 2026
mathlib-bors Bot pushed a commit that referenced this pull request Nov 30, 2026
…rithmetic function (#46097)

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.

:robot: This result is used in the proof of Stickelberger's theorem in #46022. Claude extracted it from my [SKW project](https://github.com/xroblot/SKW).
@mathlib-bors mathlib-bors Bot added the bors-staging This PR is currently being built by bors on the staging branch. label Nov 30, 2026
@mathlib-bors

mathlib-bors Bot commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

@mathlib-bors mathlib-bors Bot changed the title feat(NumberTheory/ArithmeticFunction): bundle Euler's totient as an arithmetic function [Merged by Bors] - feat(NumberTheory/ArithmeticFunction): bundle Euler's totient as an arithmetic function Nov 30, 2026
@mathlib-bors mathlib-bors Bot closed this Nov 30, 2026
TJHeeringa pushed a commit to TJHeeringa/mathlib4 that referenced this pull request Dec 2, 2026
…rithmetic function (leanprover-community#46097)

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 leanprover-community#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.

:robot: This result is used in the proof of Stickelberger's theorem in leanprover-community#46022. Claude extracted it from my [SKW project](https://github.com/xroblot/SKW).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bors-staging This PR is currently being built by bors on the staging branch. LLM-generated PRs with substantial input from LLMs - review accordingly ready-to-merge This PR has been sent to bors. 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.

4 participants