Skip to content

Commit c31e0d0

Browse files
committed
feat(AlgebraicGeometry/EllipticCurve/Affine/Point): add equivalences between points and explicit WithZero types (#25984)
This PR continues the work from #14627. Original PR: #14627
1 parent 5a6619a commit c31e0d0

File tree

1 file changed

+130
-15
lines changed
  • Mathlib/AlgebraicGeometry/EllipticCurve/Affine

1 file changed

+130
-15
lines changed

Mathlib/AlgebraicGeometry/EllipticCurve/Affine/Point.lean

Lines changed: 130 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -481,20 +481,143 @@ inductive Point
481481

482482
/-- For an algebraic extension `S` of a ring `R`, the type of nonsingular `S`-points on a
483483
Weierstrass curve `W` over `R` in affine coordinates. -/
484-
scoped notation3:max W' "⟮" S "⟯" => Affine.Point <| baseChange W' S
484+
scoped notation3:max W' "⟮" S "⟯" => Point <| baseChange W' S
485+
486+
/-- The equivalence between the nonsingular points on a Weierstrass curve `W` in affine coordinates
487+
satisfying a predicate and the set of pairs `⟨x, y⟩` satisfying `W.Nonsingular x y` with zero. -/
488+
def nonsingularPointEquivSubtype {p : W'.Point → Prop} (p0 : p .zero) : {P : W'.Point // p P} ≃
489+
WithZero {xy : R × R // ∃ h : W'.Nonsingular xy.fst xy.snd, p <| .some h} where
490+
toFun
491+
| ⟨.zero, _⟩ => none
492+
| ⟨.some h, ph⟩ => .some ⟨⟨_, _⟩, h, ph⟩
493+
invFun P := P.casesOn ⟨.zero, p0⟩ fun xy => ⟨.some xy.prop.choose, xy.prop.choose_spec⟩
494+
left_inv := by rintro (_ | _) <;> rfl
495+
right_inv := by rintro (_ | _) <;> rfl
496+
497+
@[simp]
498+
lemma nonsingularPointEquivSubtype_zero {p : W'.Point → Prop} (p0 : p .zero) :
499+
nonsingularPointEquivSubtype p0 ⟨.zero, p0⟩ = none :=
500+
rfl
501+
502+
@[simp]
503+
lemma nonsingularPointEquivSubtype_some {x y : R} {h : W'.Nonsingular x y} {p : W'.Point → Prop}
504+
(p0 : p .zero) (ph : p <| .some h) :
505+
nonsingularPointEquivSubtype p0 ⟨.some h, ph⟩ = .some ⟨⟨x, y⟩, h, ph⟩ :=
506+
rfl
507+
508+
@[simp]
509+
lemma nonsingularPointEquivSubtype_symm_none {p : W'.Point → Prop} (p0 : p .zero) :
510+
(nonsingularPointEquivSubtype p0).symm none = ⟨.zero, p0⟩ :=
511+
rfl
512+
513+
@[simp]
514+
lemma nonsingularPointEquivSubtype_symm_some {x y : R} {h : W'.Nonsingular x y}
515+
{p : W'.Point → Prop} (p0 : p .zero) (ph : p <| .some h) :
516+
(nonsingularPointEquivSubtype p0).symm (.some ⟨⟨x, y⟩, h, ph⟩) = ⟨.some h, ph⟩ :=
517+
rfl
518+
519+
variable (W') in
520+
/-- The equivalence between the nonsingular points on a Weierstrass curve `W` in affine coordinates
521+
and the set of pairs `⟨x, y⟩` satisfying `W.Nonsingular x y` with zero. -/
522+
def nonsingularPointEquiv : W'.Point ≃ WithZero {xy : R × R // W'.Nonsingular xy.fst xy.snd} :=
523+
(Equiv.Set.univ W'.Point).symm.trans <| (nonsingularPointEquivSubtype trivial).trans
524+
(Equiv.setCongr <| Set.ext fun _ => exists_iff_of_forall fun _ => trivial).optionCongr
525+
526+
@[simp]
527+
lemma nonsingularPointEquiv_zero : nonsingularPointEquiv W' .zero = none :=
528+
rfl
529+
530+
@[simp]
531+
lemma nonsingularPointEquiv_some {x y : R} (h : W'.Nonsingular x y) :
532+
W'.nonsingularPointEquiv (.some h) = .some ⟨⟨x, y⟩, h⟩ := by
533+
rfl
534+
535+
@[simp]
536+
lemma nonsingularPointEquiv_symm_none : W'.nonsingularPointEquiv.symm none = .zero :=
537+
rfl
538+
539+
@[simp]
540+
lemma nonsingularPointEquiv_symm_some {x y : R} (h : W'.Nonsingular x y) :
541+
W'.nonsingularPointEquiv.symm (.some ⟨⟨x, y⟩, h⟩) = .some h :=
542+
rfl
543+
544+
section IsElliptic
545+
546+
variable [Nontrivial R] [W'.IsElliptic]
547+
548+
/-- A point on an elliptic curve `W` over `R`. -/
549+
def Point.mk {x y : R} (h : W'.Equation x y) : W'.Point :=
550+
.some <| equation_iff_nonsingular.mp h
551+
552+
/-- The equivalence between the points on an elliptic curve `W` in affine coordinates satisfying a
553+
predicate and the set of pairs `⟨x, y⟩` satisfying `W.Equation x y` with zero. -/
554+
def pointEquivSubtype {p : W'.Point → Prop} (p0 : p .zero) :
555+
{P : W'.Point // p P} ≃ WithZero {xy : R × R // ∃ h : W'.Equation xy.fst xy.snd, p <| .mk h} :=
556+
(nonsingularPointEquivSubtype p0).trans
557+
(Equiv.setCongr <| by simpa only [equation_iff_nonsingular] using by rfl).optionCongr
558+
559+
@[simp]
560+
lemma pointEquivSubtype_zero {p : W'.Point → Prop} (p0 : p .zero) :
561+
pointEquivSubtype p0 ⟨.zero, p0⟩ = none :=
562+
rfl
563+
564+
@[simp]
565+
lemma pointEquivSubtype_some {x y : R} {h : W'.Equation x y} {p : W'.Point → Prop} (p0 : p .zero)
566+
(ph : p <| .mk h) : pointEquivSubtype p0 ⟨.mk h, ph⟩ = .some ⟨⟨x, y⟩, h, ph⟩ :=
567+
rfl
568+
569+
@[simp]
570+
lemma pointEquivSubtype_symm_none {p : W'.Point → Prop} (p0 : p .zero) :
571+
(pointEquivSubtype p0).symm none = ⟨.zero, p0⟩ :=
572+
rfl
573+
574+
@[simp]
575+
lemma pointEquivSubtype_symm_some {x y : R} {h : W'.Equation x y} {p : W'.Point → Prop}
576+
(p0 : p .zero) (ph : p <| .mk h) :
577+
(pointEquivSubtype p0).symm (.some ⟨⟨x, y⟩, h, ph⟩) = ⟨.mk h, ph⟩ :=
578+
rfl
579+
580+
variable (W') in
581+
/-- The equivalence between the rational points on an elliptic curve `E` and the set of pairs
582+
`⟨x, y⟩` satisfying `E.Equation x y` with zero. -/
583+
def pointEquiv : W'.Point ≃ WithZero {xy : R × R // W'.Equation xy.fst xy.snd} :=
584+
(Equiv.Set.univ W'.Point).symm.trans <| (pointEquivSubtype trivial).trans
585+
(Equiv.setCongr <| Set.ext fun _ => exists_iff_of_forall fun _ => trivial).optionCongr
586+
587+
@[simp]
588+
lemma pointEquiv_zero : W'.pointEquiv .zero = none :=
589+
rfl
590+
591+
@[simp]
592+
lemma pointEquiv_some {x y : R} (h : W'.Equation x y) :
593+
pointEquiv W' (.mk h) = .some ⟨⟨x, y⟩, h⟩ := by
594+
rfl
595+
596+
@[simp]
597+
lemma pointEquiv_symm_none : (pointEquiv W').symm none = .zero :=
598+
rfl
599+
600+
@[simp]
601+
lemma pointEquiv_symm_some {x y : R} (h : W'.Equation x y) :
602+
(pointEquiv W').symm (.some ⟨⟨x, y⟩, h⟩) = .mk h :=
603+
rfl
604+
605+
end IsElliptic
485606

486607
namespace Point
487608

609+
/-! ## Group law in affine coordinates -/
610+
488611
instance : Inhabited W'.Point :=
489-
.zero⟩
612+
⟨zero⟩
490613

491614
instance : Zero W'.Point :=
492-
.zero⟩
615+
⟨zero⟩
493616

494-
lemma zero_def : 0 = (.zero : W'.Point) :=
617+
lemma zero_def : 0 = (zero : W'.Point) :=
495618
rfl
496619

497-
lemma some_ne_zero {x y : R} (h : W'.Nonsingular x y) : Point.some h ≠ 0 := by
620+
lemma some_ne_zero {x y : R} (h : W'.Nonsingular x y) : some h ≠ 0 := by
498621
rintro (_ | _)
499622

500623
/-- The negation of a nonsingular point on a Weierstrass curve in affine coordinates.
@@ -524,6 +647,8 @@ instance : InvolutiveNeg W'.Point where
524647
· rfl
525648
· simp only [neg_some, negY_negY]
526649

650+
variable [DecidableEq F] [DecidableEq K] [DecidableEq L]
651+
527652
/-- The addition of two nonsingular points on a Weierstrass curve in affine coordinates.
528653
529654
Given two nonsingular points `P` and `Q` in affine coordinates, use `P + Q` instead of `add P Q`. -/
@@ -533,10 +658,6 @@ def add [DecidableEq F] : W.Point → W.Point → W.Point
533658
| @some _ _ _ x₁ y₁ h₁, @some _ _ _ x₂ y₂ h₂ =>
534659
if hxy : x₁ = x₂ ∧ y₁ = W.negY x₂ y₂ then 0 else some <| nonsingular_add h₁ h₂ hxy
535660

536-
section add
537-
538-
variable [DecidableEq F]
539-
540661
instance : Add W.Point :=
541662
⟨add⟩
542663

@@ -590,10 +711,6 @@ lemma add_of_X_ne' {x₁ x₂ y₁ y₂ : F} {h₁ : W.Nonsingular x₁ y₁} {h
590711
(hx : x₁ ≠ x₂) : some h₁ + some h₂ = -some (nonsingular_negAdd h₁ h₂ fun hxy => hx hxy.left) :=
591712
add_of_X_ne hx
592713

593-
variable [DecidableEq K] [DecidableEq L]
594-
595-
/-! ## Group law in affine coordinates -/
596-
597714
/-- The group homomorphism mapping a nonsingular affine point `(x, y)` of a Weierstrass curve `W` to
598715
the class of the non-zero fractional ideal `⟨X - x, Y - y⟩` in the ideal class group of `F[W]`. -/
599716
@[simps]
@@ -711,8 +828,6 @@ lemma map_baseChange [Algebra F K] [IsScalarTower R F K] [Algebra F L] [IsScalar
711828
have : Subsingleton (F →ₐ[F] L) := inferInstance
712829
convert map_map (Algebra.ofId F K) f P
713830

714-
end add
715-
716831
end Point
717832

718833
end Affine

0 commit comments

Comments
 (0)