Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - feat(EllipticCurve): lemmas in Jacobian coordinates #13846

Closed
wants to merge 10 commits into from

Conversation

alreadydone
Copy link
Contributor

@alreadydone alreadydone commented Jun 15, 2024

  • equiv_iff_eq_of_Z_eq: if a point has two representations in Jacobian coordinates with the same, nonzero Z-coordinate, then the two representations are equal.

  • nonsingular_iff_of_Z_ne_zero: a lemma deleted in an earlier PR for no reason, now restored.

  • addXYZ_self: if the addition (not doubling) formula is applied to a point representative and itself, the result is (0,0,0).

  • addXYZ_neg: the addition formula applied to a point representative and its negation yields a representative of the point at infinity.

  • two trivial lemmas fromAffine_ne_zero and comp_fin3.

  • a series of map lemmas showing the addition and doubling formulas in Jacobian coordinates commute with ring homomorphisms.


Open in Gitpod

@alreadydone alreadydone added awaiting-review awaiting-CI t-algebraic-geometry Algebraic geometry t-algebra Algebra (groups, rings, fields, etc) labels Jun 15, 2024
@alreadydone alreadydone requested a review from Multramate June 15, 2024 05:07
Copy link

github-actions bot commented Jun 15, 2024

PR summary 5dc441b533

Import changes

Dependency changes

File Base Count Head Count Change
Mathlib.AlgebraicGeometry.EllipticCurve.Jacobian 1019 1020 +1 (+0.10%)

Declarations diff

+ addXYZ_neg
+ addXYZ_self
+ addX_neg
+ addX_self
+ addY_neg
+ addY_self
+ addZ_neg
+ addZ_self
+ comp_fin3
+ equiv_iff_eq_of_Z_eq
+ equiv_iff_eq_of_Z_eq'
+ fromAffine_ne_zero
+ map_addX
+ map_addXYZ
+ map_addY
+ map_addZ
+ map_dblU
+ map_dblX
+ map_dblXYZ
+ map_dblY
+ map_dblZ
+ map_neg
+ map_negAddY
+ map_negDblY
+ map_negY
+ map_polynomial
+ map_polynomialX
+ map_polynomialY
+ map_polynomialZ
+ map_smul
+ negAddY_neg
+ negAddY_self
+ nonsingular_iff_of_Y_eq_negY
+ nonsingular_iff_of_Z_ne_zero
+ pderiv_map
+ smul_fin3

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

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

Copy link
Collaborator

@YaelDillies YaelDillies left a comment

Choose a reason for hiding this comment

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

The rest looks good but I am not an expert

Copy link
Collaborator

@Multramate Multramate left a comment

Choose a reason for hiding this comment

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

Thanks! Here are some preliminary suggestions. I will look into the code later.

This reverts commit 1a5e80a but do not restore @[simp] attributes
@alreadydone alreadydone force-pushed the EllCurve/Jacobian_lemmas branch from 4f8e234 to 36f1e0a Compare June 17, 2024 06:08
Copy link
Collaborator

@Multramate Multramate left a comment

Choose a reason for hiding this comment

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

Some further comments.

Comment on lines +407 to +411
lemma nonsingular_iff_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) :
W.Nonsingular P ↔ W.Equation P ∧ (eval P W.polynomialX ≠ 0 ∨ eval P W.polynomialY ≠ 0) := by
rw [nonsingular_of_Z_ne_zero hPz, Affine.Nonsingular, ← equation_of_Z_ne_zero hPz,
← eval_polynomialX_of_Z_ne_zero hPz, div_ne_zero_iff, and_iff_left <| pow_ne_zero 4 hPz,
← eval_polynomialY_of_Z_ne_zero hPz, div_ne_zero_iff, and_iff_left <| pow_ne_zero 3 hPz]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you remind me where you need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No I don't need this, but I think it's an interesting result, and it can be generalized to arbitrary comm. rings assuming P z is not a zero divisor, because in analogy to polynomial_relation in the projective API, here we have

6 * eval P W.polynomial = 2 * P x * eval P W.polynomialX + 3 * P y * eval P W.polynomialY + P z * eval P W.polynomialZ

due to weighted homogeneity, which you use with P z = 1 in nonsingular_some.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah sure, can you generalise it to that context then, if it's not too difficult?

Copy link
Contributor Author

@alreadydone alreadydone Jun 20, 2024

Choose a reason for hiding this comment

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

I have it ready here but I prefer to merge this first. It's another +40 -14 on top of this.

By the way I think a more meaningful definition of Nonsingular is that the three derivatives generate the unit ideal. In order to get rid of the third derivative, the sufficient condition is IsUnit (P z) rather than P z ∈ R⁰. I'm not sure whether either of these two forms of the lemma will ever be used though.

Copy link
Collaborator

@Multramate Multramate left a comment

Choose a reason for hiding this comment

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

LGTM otherwise. I will likely move a few things around when I split the file, so I won't bother you further with minor golfs or rearrangements.

lemma comp_fin3 {S} (f : R → S) (X Y Z : R) : f ∘ ![X, Y, Z] = ![f X, f Y, f Z] := by
ext i; fin_cases i <;> rfl
lemma comp_fin3 {S} (f : R → S) (X Y Z : R) : f ∘ ![X, Y, Z] = ![f X, f Y, f Z] :=
(FinVec.map_eq _ _).symm
Copy link
Collaborator

Choose a reason for hiding this comment

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

Untested:

Suggested change
(FinVec.map_eq _ _).symm
(FinVec.map_eq ..).symm

Copy link
Collaborator

Choose a reason for hiding this comment

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

Since we already have FinVec.map_eq, do we still need comp_fin3? Otherwise, should this be comp_fin3_ext, and does it make sense to have an analogous comp_fin3 for P : Fin 3 -> R?

Copy link
Contributor Author

@alreadydone alreadydone Jun 20, 2024

Choose a reason for hiding this comment

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

As I commented, it can't be used to rewrite to the desired form directly.

@jcommelin
Copy link
Member

Thanks 🎉

bors merge

@github-actions github-actions bot added ready-to-merge This PR has been sent to bors. and removed awaiting-review labels Jun 26, 2024
mathlib-bors bot pushed a commit that referenced this pull request Jun 26, 2024
+ `equiv_iff_eq_of_Z_eq`: if a point has two representations in Jacobian coordinates with the same, nonzero Z-coordinate, then the two representations are equal.

+ `nonsingular_iff_of_Z_ne_zero`: a lemma deleted in an earlier PR for no reason, now restored.

+ `addXYZ_self`: if the addition (not doubling) formula is applied to a point representative and itself, the result is (0,0,0).

+ `addXYZ_neg`: the addition formula applied to a point representative and its negation yields a representative of the point at infinity.

+ two trivial lemmas `fromAffine_ne_zero` and `comp_fin3`.

+ a series of `map` lemmas showing the addition and doubling formulas in Jacobian coordinates commute with ring homomorphisms.



Co-authored-by: Junyan Xu <[email protected]>
@mathlib-bors
Copy link
Contributor

mathlib-bors bot commented Jun 26, 2024

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title feat(EllipticCurve): lemmas in Jacobian coordinates [Merged by Bors] - feat(EllipticCurve): lemmas in Jacobian coordinates Jun 26, 2024
@mathlib-bors mathlib-bors bot closed this Jun 26, 2024
@mathlib-bors mathlib-bors bot deleted the EllCurve/Jacobian_lemmas branch June 26, 2024 12:43
kbuzzard pushed a commit that referenced this pull request Jun 26, 2024
+ `equiv_iff_eq_of_Z_eq`: if a point has two representations in Jacobian coordinates with the same, nonzero Z-coordinate, then the two representations are equal.

+ `nonsingular_iff_of_Z_ne_zero`: a lemma deleted in an earlier PR for no reason, now restored.

+ `addXYZ_self`: if the addition (not doubling) formula is applied to a point representative and itself, the result is (0,0,0).

+ `addXYZ_neg`: the addition formula applied to a point representative and its negation yields a representative of the point at infinity.

+ two trivial lemmas `fromAffine_ne_zero` and `comp_fin3`.

+ a series of `map` lemmas showing the addition and doubling formulas in Jacobian coordinates commute with ring homomorphisms.



Co-authored-by: Junyan Xu <[email protected]>
dagurtomas pushed a commit that referenced this pull request Jul 2, 2024
+ `equiv_iff_eq_of_Z_eq`: if a point has two representations in Jacobian coordinates with the same, nonzero Z-coordinate, then the two representations are equal.

+ `nonsingular_iff_of_Z_ne_zero`: a lemma deleted in an earlier PR for no reason, now restored.

+ `addXYZ_self`: if the addition (not doubling) formula is applied to a point representative and itself, the result is (0,0,0).

+ `addXYZ_neg`: the addition formula applied to a point representative and its negation yields a representative of the point at infinity.

+ two trivial lemmas `fromAffine_ne_zero` and `comp_fin3`.

+ a series of `map` lemmas showing the addition and doubling formulas in Jacobian coordinates commute with ring homomorphisms.



Co-authored-by: Junyan Xu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge This PR has been sent to bors. t-algebra Algebra (groups, rings, fields, etc) t-algebraic-geometry Algebraic geometry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants