Skip to content

[Merged by Bors] - feat(Algebra/QuadraticAlgebra): custom structure for quadratic algebras#27511

Closed
Nebula691 wants to merge 55 commits intoleanprover-community:masterfrom
Nebula691:jiayang/QuadraticAlgebra
Closed

[Merged by Bors] - feat(Algebra/QuadraticAlgebra): custom structure for quadratic algebras#27511
Nebula691 wants to merge 55 commits intoleanprover-community:masterfrom
Nebula691:jiayang/QuadraticAlgebra

Conversation

@Nebula691
Copy link
Copy Markdown
Contributor

@Nebula691 Nebula691 commented Jul 26, 2025

Discussed in #Is there code for X? > Z[(1+sqrt(1+4k))/2] @ 💬

Co-authored-by: Edison Xie yx3021@ic.ac.uk
Co-authored-by: Kenny Lau kc_kennylau@yahoo.com.hk


Open in Gitpod

@github-actions github-actions bot added new-contributor This PR was made by a contributor with at most 5 merged PRs. Welcome to the community! t-algebra Algebra (groups, rings, fields, etc) labels Jul 26, 2025
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jul 26, 2025

PR summary 4a2cfa2512

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference
Mathlib.Algebra.QuadraticAlgebra (new file) 1273

Declarations diff

+ QuadraticAlgebra
+ algebraMap_eq
+ algebraMap_injective
+ basis
+ basis_repr_apply
+ coe
+ coe_add
+ coe_algebraMap
+ coe_inj
+ coe_injective
+ coe_intCast
+ coe_mul
+ coe_mul_eq_smul
+ coe_natCast
+ coe_neg
+ coe_ofNat
+ coe_one
+ coe_pow
+ coe_smul
+ coe_sub
+ coe_zero
+ equivProd
+ finrank_eq_two
+ im_add
+ im_coe
+ im_intCast
+ im_mul
+ im_natCast
+ im_neg
+ im_ofNat
+ im_one
+ im_smul
+ im_sub
+ im_zero
+ imₗ
+ instCommRing
+ instCommSemiring
+ instNonAssocSemiring
+ instNonUnitalNonAssocSemiring
+ instance : Add (QuadraticAlgebra R a b)
+ instance : AddCommGroupWithOne (QuadraticAlgebra R a b)
+ instance : AddCommMonoidWithOne (QuadraticAlgebra R a b)
+ instance : Coe R (QuadraticAlgebra R a b) := ⟨coe⟩
+ instance : Inhabited (QuadraticAlgebra R a b) := ⟨0⟩
+ instance : Module.Finite R (QuadraticAlgebra R a b) := .of_basis (basis a b)
+ instance : Module.Free R (QuadraticAlgebra R a b) := .of_basis (basis a b)
+ instance : Mul (QuadraticAlgebra R a b)
+ instance : Neg (QuadraticAlgebra R a b) where neg z := ⟨-z.re, -z.im⟩
+ instance : One (QuadraticAlgebra R a b) := ⟨⟨1, 0⟩⟩
+ instance : SMul S (QuadraticAlgebra R a b) where smul s z := ⟨s • z.re, s • z.im⟩
+ instance : Zero (QuadraticAlgebra R a b) := ⟨⟨0, 0⟩⟩
+ instance [AddCommGroup R] : AddCommGroup (QuadraticAlgebra R a b)
+ instance [AddCommMonoid R] : AddCommMonoid (QuadraticAlgebra R a b) := fast_instance% by
+ instance [AddGroup R] : AddGroup (QuadraticAlgebra R a b) := fast_instance% by
+ instance [AddMonoid R] : AddMonoid (QuadraticAlgebra R a b) := fast_instance% by
+ instance [CommSemiring S] [CommSemiring R] [Algebra S R] :
+ instance [Monoid S] [AddMonoid R] [DistribMulAction S R] :
+ instance [Monoid S] [MulAction S R] : MulAction S (QuadraticAlgebra R a b)
+ instance [Nontrivial R] : Nontrivial (QuadraticAlgebra R a b) := (equivProd a b).nontrivial
+ instance [SMul S T] [IsScalarTower S T R] : IsScalarTower S T (QuadraticAlgebra R a b)
+ instance [SMul Sᵐᵒᵖ R] [IsCentralScalar S R] : IsCentralScalar S (QuadraticAlgebra R a b)
+ instance [SMulCommClass S T R] : SMulCommClass S T (QuadraticAlgebra R a b)
+ instance [Semiring S] [AddCommMonoid R] [Module S R] : Module S (QuadraticAlgebra R a b)
+ instance [Sub R] : Sub (QuadraticAlgebra R a b)
+ instance [Subsingleton R] : Subsingleton (QuadraticAlgebra R a b) := (equivProd a b).subsingleton
+ instance [Zero S] [SMulWithZero S R] [NoZeroSMulDivisors S R] :
+ linearEquivTuple
+ linearEquivTuple_apply
+ linearEquivTuple_symm_apply
+ mk_add_mk
+ mk_eta
+ mk_mul_mk
+ mk_sub_mk
+ mul_coe_eq_smul
+ neg_mk
+ rank_eq_two
+ re_add
+ re_coe
+ re_intCast
+ re_mul
+ re_natCast
+ re_neg
+ re_ofNat
+ re_one
+ re_smul
+ re_sub
+ re_zero
+ reₗ
+ smul_coe
+ smul_mk

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

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

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


No changes to technical debt.

You can run this locally as

./scripts/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).

@Nebula691 Nebula691 changed the title Jiayang/quadratic algebra feat(Algebra/QuadraticAlgebra) : Define Quadratic Algebra Jul 26, 2025
Copy link
Copy Markdown
Collaborator

@kckennylau kckennylau left a comment

Choose a reason for hiding this comment

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

Thanks!

Comment on lines +55 to +57
@[simp]
theorem equivTuple_apply {R : Type*} (a b : R) (z : QuadraticAlgebra R a b) :
equivTuple a b z = ![z.re, z.im] := rfl
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.

Does the simpNF linter not complain? Also, a and b can be implicit.

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.

it didn't, and making a and b implicit will break the theorems after it then it would ask me to specify which a and b am I using

Whysoserioushah and others added 9 commits July 26, 2025 22:14
Co-authored-by: Kenny Lau <kc_kennylau@yahoo.com.hk>
Co-authored-by: Kenny Lau <kc_kennylau@yahoo.com.hk>
Co-authored-by: Kenny Lau <kc_kennylau@yahoo.com.hk>
Co-authored-by: Kenny Lau <kc_kennylau@yahoo.com.hk>
Co-authored-by: Kenny Lau <kc_kennylau@yahoo.com.hk>
Co-authored-by: Kenny Lau <kc_kennylau@yahoo.com.hk>
Co-authored-by: Kenny Lau <kc_kennylau@yahoo.com.hk>
Co-authored-by: Kenny Lau <kc_kennylau@yahoo.com.hk>
Co-authored-by: Kenny Lau <kc_kennylau@yahoo.com.hk>
Copy link
Copy Markdown
Member

@eric-wieser eric-wieser left a comment

Choose a reason for hiding this comment

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

This looks great to me now, thanks!

@YaelDillies
Copy link
Copy Markdown
Contributor

There is now plenty of evidence that my original kneejerk reaction was misguided and that we should indeed have this two-fields structure in mathlib.

My reasoning is that this is the minimal first step to unifying Complex and GaussianInt, and that further steps (such as using AdjoinRoot instead of an ad hoc structure) can be taken later (eg once Polynomial has been made computable).

@eric-wieser eric-wieser changed the title feat(Algebra/QuadraticAlgebra) : Define Quadratic Algebra feat(Algebra/QuadraticAlgebra): Define Quadratic Algebra Sep 2, 2025
Copy link
Copy Markdown
Member

@riccardobrasca riccardobrasca left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!


end Neg

section AddGroup
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.

Not super important, but in the section AddGroup there is no mention of any AddGroup.

Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
@YaelDillies YaelDillies changed the title feat(Algebra/QuadraticAlgebra): Define Quadratic Algebra feat(Algebra/QuadraticAlgebra): custom structure for quadratic algebras Sep 5, 2025
@riccardobrasca
Copy link
Copy Markdown
Member

bors merge

@ghost ghost added the ready-to-merge This PR has been sent to bors. label Sep 5, 2025
mathlib-bors bot pushed a commit that referenced this pull request Sep 5, 2025
…as (#27511)

Discussed in [#Is there code for X? > Z&#91;(1+sqrt(1+4k))/2&#93; @ 💬](https://leanprover.zulipchat.com/#narrow/channel/217875-Is-there-code-for-X.3F/topic/Z.5B.281.2Bsqrt.281.2B4k.29.29.2F2.5D/near/520523635)

Co-authored-by: Edison Xie <yx3021@ic.ac.uk>
Co-authored-by: Kenny Lau <kc_kennylau@yahoo.com.hk>
Co-authored-by: Whysoserioushah <yx3021@ic.ac.uk>
Co-authored-by: Whysoserioushah <109107491+Whysoserioushah@users.noreply.github.com>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Co-authored-by: hongjiayang1 <jh1321@ic.ac.uk>
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Sep 5, 2025

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title feat(Algebra/QuadraticAlgebra): custom structure for quadratic algebras [Merged by Bors] - feat(Algebra/QuadraticAlgebra): custom structure for quadratic algebras Sep 5, 2025
@mathlib-bors mathlib-bors bot closed this Sep 5, 2025
CBirkbeck pushed a commit to CBirkbeck/mathlib4 that referenced this pull request Sep 8, 2025
…as (leanprover-community#27511)

Discussed in [#Is there code for X? > Z&leanprover-community#91;(1+sqrt(1+4k))/2&leanprover-community#93; @ 💬](https://leanprover.zulipchat.com/#narrow/channel/217875-Is-there-code-for-X.3F/topic/Z.5B.281.2Bsqrt.281.2B4k.29.29.2F2.5D/near/520523635)

Co-authored-by: Edison Xie <yx3021@ic.ac.uk>
Co-authored-by: Kenny Lau <kc_kennylau@yahoo.com.hk>
Co-authored-by: Whysoserioushah <yx3021@ic.ac.uk>
Co-authored-by: Whysoserioushah <109107491+Whysoserioushah@users.noreply.github.com>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Co-authored-by: hongjiayang1 <jh1321@ic.ac.uk>
yuanyi-350 pushed a commit to yuanyi-350/yuanyi_mathlib4 that referenced this pull request Sep 10, 2025
…as (leanprover-community#27511)

Discussed in [#Is there code for X? > Z&leanprover-community#91;(1+sqrt(1+4k))/2&leanprover-community#93; @ 💬](https://leanprover.zulipchat.com/#narrow/channel/217875-Is-there-code-for-X.3F/topic/Z.5B.281.2Bsqrt.281.2B4k.29.29.2F2.5D/near/520523635)

Co-authored-by: Edison Xie <yx3021@ic.ac.uk>
Co-authored-by: Kenny Lau <kc_kennylau@yahoo.com.hk>
Co-authored-by: Whysoserioushah <yx3021@ic.ac.uk>
Co-authored-by: Whysoserioushah <109107491+Whysoserioushah@users.noreply.github.com>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Co-authored-by: hongjiayang1 <jh1321@ic.ac.uk>
robertmaxton42 pushed a commit to robertmaxton42/mathlib4 that referenced this pull request Sep 11, 2025
…as (leanprover-community#27511)

Discussed in [#Is there code for X? > Z&leanprover-community#91;(1+sqrt(1+4k))/2&leanprover-community#93; @ 💬](https://leanprover.zulipchat.com/#narrow/channel/217875-Is-there-code-for-X.3F/topic/Z.5B.281.2Bsqrt.281.2B4k.29.29.2F2.5D/near/520523635)

Co-authored-by: Edison Xie <yx3021@ic.ac.uk>
Co-authored-by: Kenny Lau <kc_kennylau@yahoo.com.hk>
Co-authored-by: Whysoserioushah <yx3021@ic.ac.uk>
Co-authored-by: Whysoserioushah <109107491+Whysoserioushah@users.noreply.github.com>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Co-authored-by: hongjiayang1 <jh1321@ic.ac.uk>
joelriou pushed a commit to joelriou/mathlib4 that referenced this pull request Oct 2, 2025
…as (leanprover-community#27511)

Discussed in [#Is there code for X? > Z&leanprover-community#91;(1+sqrt(1+4k))/2&leanprover-community#93; @ 💬](https://leanprover.zulipchat.com/#narrow/channel/217875-Is-there-code-for-X.3F/topic/Z.5B.281.2Bsqrt.281.2B4k.29.29.2F2.5D/near/520523635)

Co-authored-by: Edison Xie <yx3021@ic.ac.uk>
Co-authored-by: Kenny Lau <kc_kennylau@yahoo.com.hk>
Co-authored-by: Whysoserioushah <yx3021@ic.ac.uk>
Co-authored-by: Whysoserioushah <109107491+Whysoserioushah@users.noreply.github.com>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Co-authored-by: hongjiayang1 <jh1321@ic.ac.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-contributor This PR was made by a contributor with at most 5 merged PRs. Welcome to the community! ready-to-merge This PR has been sent to bors. t-algebra Algebra (groups, rings, fields, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.