Skip to content

feat(NumberTheory/NumberField): the discriminant of the quadratic fields ℚ(√d) - #43491

Open
xroblot wants to merge 63 commits into
leanprover-community:masterfrom
xroblot:quadratic-field-sqrtd
Open

xroblot wants to merge 63 commits into
leanprover-community:masterfrom
xroblot:quadratic-field-sqrtd

Conversation

@xroblot

@xroblot xroblot commented Sep 6, 2026 •

Copy link
Copy Markdown
Collaborator

This PR computes the discriminant of the concrete quadratic fields ℚ(√d), realized as QuadraticAlgebra ℚ (d : ℚ) 0. If d is squarefree, this discriminant is 4 * d when d ≡ 2, 3 mod 4, and d when d ≡ 1 mod 4. More generally, the discriminant of ℚ(√D) is D for every fundamental discriminant D, which completes the classification of quadratic fields by their discriminant: every fundamental discriminant other than 1 is the discriminant of a quadratic field.

The statements take a [Fact (¬ IsSquare _)] assumption to get the NumberField instance on QuadraticAlgebra ℚ a b, as explained in the implementation notes of the module docstring. The PR also adds the lemma Squarefree.not_isSquare_intCast, which says that a squarefree integer other than 1 is not a square in ℚ, so that this assumption is easy to provide in the squarefree case.

The mathematics and design are mine. Claude Code was used as a coding assistant and for the housekeeping around this PR. 🤖


xroblot and others added 30 commits July 27, 2026 20:07
…-map

# Conflicts:
#	Mathlib/Algebra/QuadraticAlgebra/Basic.lean
…ratic-algebra-discr

# Conflicts:
#	Mathlib/Algebra/QuadraticAlgebra/Basic.lean
…-discr

# Conflicts:
#	Mathlib/Algebra/QuadraticAlgebra/Basic.lean
…-disc2

# Conflicts:
#	Mathlib/Algebra/QuadraticAlgebra/Discr.lean
…tic-algebra-fraction-ring

# Conflicts:
#	Mathlib.lean
#	Mathlib/Algebra/QuadraticAlgebra/Discr.lean
@joneugster joneugster added t-number-theory Number theory (also use t-algebra or t-analysis to specialize) t-algebra Algebra (groups, rings, fields, etc) labels Sep 20, 2026
xroblot and others added 13 commits September 23, 2026 14:18
…-fraction-ring

# Conflicts:
#	Mathlib.lean
#	Mathlib/Algebra/QuadraticAlgebra/Discriminant.lean
… into quadratic-algebra-integral-closure

# Conflicts:
#	Mathlib/Algebra/QuadraticAlgebra/Discriminant.lean
…re' into quadratic-field-basic

# Conflicts:
#	Mathlib/Algebra/QuadraticAlgebra/Discriminant.lean
#	Mathlib/Algebra/QuadraticAlgebra/Int.lean
#	Mathlib/Algebra/QuadraticAlgebra/IsQuadraticExtension.lean
#	Mathlib/LinearAlgebra/Matrix/Charpoly/Minpoly.lean
#	Mathlib/LinearAlgebra/Unimodular.lean
#	Mathlib/RingTheory/Trace/Basic.lean
…asic

# Conflicts:
#	Mathlib.lean
#	Mathlib/Algebra/QuadraticAlgebra/Basic.lean
#	Mathlib/Algebra/QuadraticAlgebra/Discriminant.lean
#	Mathlib/Algebra/QuadraticAlgebra/Int.lean
#	Mathlib/RingTheory/IntegralClosure/IsIntegralClosure/Basic.lean
#	Mathlib/RingTheory/Localization/FractionRing.lean
#	Mathlib/RingTheory/QuadraticAlgebra.lean
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot removed merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) large-import Automatically added label for PRs with a significant increase in transitive imports labels Nov 23, 2026
@mathlib-dependent-issues mathlib-dependent-issues Bot removed the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Nov 30, 2026
@mathlib-merge-conflicts mathlib-merge-conflicts Bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Nov 30, 2026
@mathlib-merge-conflicts

Copy link
Copy Markdown

This pull request has conflicts, please merge master and resolve them.

@github-actions github-actions Bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Dec 1, 2026
@artie2000 artie2000 self-assigned this Dec 1, 2026

@artie2000 artie2000 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.

just reviewing the docs for now

@@ -21,6 +21,7 @@ This file gathers results about squarefreeness and rational numbers.
## Main results

* `Rat.sq_mul_squarefree_unique`: the squarefree integer `d` in such a decomposition is unique.

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.

incidental but this docstring makes no sense

Comment on lines +38 to +40
/-- A squarefree integer `d` other than `1` is not a square in `ℚ`. In particular,
`QuadraticAlgebra ℚ d 0`, that is `ℚ(√d)`, is then a field; see the implementation notes of
`Mathlib.NumberTheory.NumberField.QuadraticField.Basic`. -/

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.

We don't need most of this - arguably we don't need a docstring here at all.
Was this docstring written by AI?

Comment on lines +41 to +46
The quadratic algebra `QuadraticAlgebra ℚ a b` is a field, hence a number field, exactly when
`QuadraticAlgebra.discr a b` is not a rational square. The results of this file on these
quadratic algebras therefore take a `[Fact (¬ IsSquare (QuadraticAlgebra.discr a b))]`
assumption, or `[Fact (¬ IsSquare (d : ℚ))]` for `QuadraticAlgebra ℚ d 0`, from which instance
search gets the `Field`, hence the `NumberField`, instance needed to state them. This assumption
holds when `d` is squarefree and different from `1`, see `Squarefree.not_isSquare_intCast`.

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.

Please could you rewrite this in a more human-oriented style? I find this note difficult to parse.

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.

I think this is rather insightful and clear to be honest?

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.

guess it's a matter of taste 🤷 I won't insist

Comment on lines +119 to +120
/-- If `QuadraticAlgebra.discr a b` is a fundamental discriminant, then the discriminant of the
number field `QuadraticAlgebra ℚ a b` is `QuadraticAlgebra.discr a b`.

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.

Is there a mathematical way to refer to QuadraticAlgebra.discr a b? I guess it's the "discriminant of $$X^2-bX-a$$." That might read better? What do you think?

discr_eq_quadraticAlgebra_discr (Int.algEquivIntegralClosure h).toRingEquiv.symm

/-- If `d` is a fundamental discriminant, then the discriminant of `ℚ(√d)` is `d`.
See the implementation notes in the module docstring for the `Fact` assumption. -/

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.

Suggested change
See the implementation notes in the module docstring for the `Fact` assumption. -/
See the module docstring for an explanation of the `Fact` assumption. -/

is possibly clearer?

@artie2000 artie2000 added the awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. label Dec 2, 2026
@felixpernegger felixpernegger added awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. and removed awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. labels Dec 2, 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

awaiting-author Reply -awaiting-author to remove the label on your PR once you have addressed all comments. t-algebra Algebra (groups, rings, fields, etc) 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