Skip to content

chore(Algebra/QuadraticAlgebra): define all the casts through C - #43583

Open
xroblot wants to merge 2 commits into
leanprover-community:masterfrom
xroblot:quadratic-algebra-c-reducible
Open

xroblot wants to merge 2 commits into
leanprover-community:masterfrom
xroblot:quadratic-algebra-c-reducible

Conversation

@xroblot

@xroblot xroblot commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

The casts into QuadraticAlgebra R a b were defined in two different ways, some through C and some through the anonymous constructor, which made the Algebra ℤ instances non-defeq at instance transparency. Using C everywhere fixes it, and an example records the defeq.

Prepared with Claude Code 🤖


@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

PR summary 121ba01f18

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff (regex)

+ instance : NNRatCast (QuadraticAlgebra K a b) where nnratCast q := .C q
+ instance : RatCast (QuadraticAlgebra K a b) where ratCast q := .C q
- instance : NNRatCast (QuadraticAlgebra K a b) where nnratCast q := ⟨q, 0⟩
- instance : RatCast (QuadraticAlgebra K a b) where ratCast q := ⟨q, 0⟩

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 121ba01).

  • +2 new declarations
  • −4 removed declarations
-QuadraticAlgebra.im_nnratCast
-QuadraticAlgebra.im_ratCast
+QuadraticAlgebra.nnratCast_def
+QuadraticAlgebra.ratCast_def
-QuadraticAlgebra.re_nnratCast
-QuadraticAlgebra.re_ratCast

No changes to strong technical debt.
No changes to weak technical debt.

Current commit 121ba01f18
Reference commit 9b46e33ce0

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 added the t-algebra Algebra (groups, rings, fields, etc) label Sep 8, 2026
@xroblot xroblot added the WIP Work in progress label Sep 8, 2026
@xroblot

xroblot commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator Author

!radar

@jcommelin jcommelin 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 commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

👎 Rejected by label

@jcommelin

Copy link
Copy Markdown
Member

Whhops, too fast. But I do like the look of this.

@xroblot

xroblot commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator Author

@jcommelin I still want to do some testing before merging this PR

@leanprover-radar

leanprover-radar commented Sep 8, 2026

Copy link
Copy Markdown

Benchmark results for 40e78fb against 9b46e33 are in. No significant results found. @xroblot

  • build//instructions: -1.4G (-0.00%)

No significant changes detected.

@xroblot xroblot removed the WIP Work in progress label Sep 8, 2026
@xroblot

xroblot commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator Author

@jcommelin Timings are fine so this PR is ready to be merged if you want to

Comment thread Mathlib/Algebra/QuadraticAlgebra/Defs.lean Outdated
@xroblot xroblot changed the title chore(Algebra/QuadraticAlgebra): define natCast and intCast without C chore(Algebra/QuadraticAlgebra): define all the casts through C Sep 9, 2026
@xroblot

xroblot commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator Author

!radar

@leanprover-radar

leanprover-radar commented Sep 9, 2026

Copy link
Copy Markdown

Benchmark results for 121ba01 against 9b46e33 are in. No significant results found. @xroblot

  • 🟥 build//instructions: +22.0G (+0.02%)

Small changes (1🟥)

  • 🟥 build/module/Mathlib.Algebra.QuadraticAlgebra.Defs//instructions: +533.3M (+2.48%)

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

Labels

t-algebra Algebra (groups, rings, fields, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants