l3lab/ntp-mathlib huggingface dataset:
/-- The group homomorphism mapping an affine point $(x, y)$ of `W` to the class of the non-zero
fractional ideal $\langle X - x, Y - y \rangle$ of $F(W)$ in the class group of $F[W]$. -/
@[simps]
noncomputable def toClass : W.Point →+ Additive (ClassGroup W.CoordinateRing) where
  toFun := toClassFun
  map_zero' := rfl
  map_add' := by
    rintro (_ | @⟨x₁, y₁, h₁⟩) (_ | @⟨x₂, y₂, h₂⟩)
    any_goals 

Proof state:
case zero.some
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
x₂ y₂ : F
h₂ : W.nonsingular x₂ y₂
⊢ ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } (zero + some h₂) =
    ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } zero +
      ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } (some h₂)

Next tactic:
simp only [zero_def, toClassFun, _root_.zero_add, _root_.add_zero]
/-- The group homomorphism mapping an affine point $(x, y)$ of `W` to the class of the non-zero
fractional ideal $\langle X - x, Y - y \rangle$ of $F(W)$ in the class group of $F[W]$. -/
@[simps]
noncomputable def toClass : W.Point →+ Additive (ClassGroup W.CoordinateRing) where
  toFun := toClassFun
  map_zero' := rfl
  map_add' := by
    rintro (_ | @⟨x₁, y₁, h₁⟩) (_ | @⟨x₂, y₂, h₂⟩)
    any_goals 

Proof state:
case some.zero
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
x₁ y₁ : F
h₁ : W.nonsingular x₁ y₁
⊢ ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } (some h₁ + zero) =
    ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } (some h₁) +
      ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } zero

Next tactic:
simp only [zero_def, toClassFun, _root_.zero_add, _root_.add_zero]
/-- The group homomorphism mapping an affine point $(x, y)$ of `W` to the class of the non-zero
fractional ideal $\langle X - x, Y - y \rangle$ of $F(W)$ in the class group of $F[W]$. -/
@[simps]
noncomputable def toClass : W.Point →+ Additive (ClassGroup W.CoordinateRing) where
  toFun := toClassFun
  map_zero' := rfl
  map_add' := by
    rintro (_ | @⟨x₁, y₁, h₁⟩) (_ | @⟨x₂, y₂, h₂⟩)
    any_goals 

Proof state:
case some.some
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
x₁ y₁ : F
h₁ : W.nonsingular x₁ y₁
x₂ y₂ : F
h₂ : W.nonsingular x₂ y₂
⊢ ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } (some h₁ + some h₂) =
    ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } (some h₁) +
      ZeroHom.toFun { toFun := toClassFun, map_zero' := (_ : toClassFun 0 = toClassFun 0) } (some h₂)

Next tactic:
simp only [zero_def, toClassFun, _root_.zero_add, _root_.add_zero]
/-- The group homomorphism mapping an affine point $(x, y)$ of `W` to the class of the non-zero
fractional ideal $\langle X - x, Y - y \rangle$ of $F(W)$ in the class group of $F[W]$. -/
@[simps]
noncomputable def toClass : W.Point →+ Additive (ClassGroup W.CoordinateRing) where
  toFun := toClassFun
  map_zero' := rfl
  map_add' := by
    rintro (_ | @⟨x₁, y₁, h₁⟩) (_ | @⟨x₂, y₂, h₂⟩)
    any_goals simp only [zero_def, toClassFun, _root_.zero_add, _root_.add_zero]
    

Proof state:
case some.some
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
x₁ y₁ : F
h₁ : W.nonsingular x₁ y₁
x₂ y₂ : F
h₂ : W.nonsingular x₂ y₂
⊢ (match some h₁ + some h₂ with
    | zero => 0
    | some h => Additive.ofMul (ClassGroup.mk (CoordinateRing.XYIdeal' h))) =
    Additive.ofMul (ClassGroup.mk (CoordinateRing.XYIdeal' h₁)) +
      Additive.ofMul (ClassGroup.mk (CoordinateRing.XYIdeal' h₂))

Next tactic:
by_cases hx : x₁ = x₂
/-- The group homomorphism mapping an affine point $(x, y)$ of `W` to the class of the non-zero
fractional ideal $\langle X - x, Y - y \rangle$ of $F(W)$ in the class group of $F[W]$. -/
@[simps]
noncomputable def toClass : W.Point →+ Additive (ClassGroup W.CoordinateRing) where
  toFun := toClassFun
  map_zero' := rfl
  map_add' := by
    rintro (_ | @⟨x₁, y₁, h₁⟩) (_ | @⟨x₂, y₂, h₂⟩)
    any_goals simp only [zero_def, toClassFun, _root_.zero_add, _root_.add_zero]
    by_cases hx : x₁ = x₂
    · 

Proof state:
case pos
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
x₁ y₁ : F
h₁ : W.nonsingular x₁ y₁
x₂ y₂ : F
h₂ : W.nonsingular x₂ y₂
hx : x₁ = x₂
⊢ (match some h₁ + some h₂ with
    | zero => 0
    | some h => Additive.ofMul (ClassGroup.mk (CoordinateRing.XYIdeal' h))) =
    Additive.ofMul (ClassGroup.mk (CoordinateRing.XYIdeal' h₁)) +
      Additive.ofMul (ClassGroup.mk (CoordinateRing.XYIdeal' h₂))

Next tactic:
by_cases hy : y₁ = W.negY x₂ y₂
/-- The group homomorphism mapping an affine point $(x, y)$ of `W` to the class of the non-zero
fractional ideal $\langle X - x, Y - y \rangle$ of $F(W)$ in the class group of $F[W]$. -/
@[simps]
noncomputable def toClass : W.Point →+ Additive (ClassGroup W.CoordinateRing) where
  toFun := toClassFun
  map_zero' := rfl
  map_add' := by
    rintro (_ | @⟨x₁, y₁, h₁⟩) (_ | @⟨x₂, y₂, h₂⟩)
    any_goals simp only [zero_def, toClassFun, _root_.zero_add, _root_.add_zero]
    by_cases hx : x₁ = x₂
    · by_cases hy : y₁ = W.negY x₂ y₂
      · 

Proof state:
case pos
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
x₁ y₁ : F
h₁ : W.nonsingular x₁ y₁
x₂ y₂ : F
h₂ : W.nonsingular x₂ y₂
hx : x₁ = x₂
hy : y₁ = W.negY x₂ y₂
⊢ (match some h₁ + some h₂ with
    | zero => 0
    | some h => Additive.ofMul (ClassGroup.mk (CoordinateRing.XYIdeal' h))) =
    Additive.ofMul (ClassGroup.mk (CoordinateRing.XYIdeal' h₁)) +
      Additive.ofMul (ClassGroup.mk (CoordinateRing.XYIdeal' h₂))

Next tactic:
substs hx hy
/-- The group homomorphism mapping an affine point $(x, y)$ of `W` to the class of the non-zero
fractional ideal $\langle X - x, Y - y \rangle$ of $F(W)$ in the class group of $F[W]$. -/
@[simps]
noncomputable def toClass : W.Point →+ Additive (ClassGroup W.CoordinateRing) where
  toFun := toClassFun
  map_zero' := rfl
  map_add' := by
    rintro (_ | @⟨x₁, y₁, h₁⟩) (_ | @⟨x₂, y₂, h₂⟩)
    any_goals simp only [zero_def, toClassFun, _root_.zero_add, _root_.add_zero]
    by_cases hx : x₁ = x₂
    · by_cases hy : y₁ = W.negY x₂ y₂
      · substs hx hy
        

Proof state:
case pos
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
x₁ y₂ : F
h₂ : W.nonsingular x₁ y₂
h₁ : W.nonsingular x₁ (W.negY x₁ y₂)
⊢ (match some h₁ + some h₂ with
    | zero => 0
    | some h => Additive.ofMul (ClassGroup.mk (CoordinateRing.XYIdeal' h))) =
    Additive.ofMul (ClassGroup.mk (CoordinateRing.XYIdeal' h₁)) +
      Additive.ofMul (ClassGroup.mk (CoordinateRing.XYIdeal' h₂))

Next tactic:
simpa only [some_add_some_of_Yeq rfl rfl] using
          (CoordinateRing.mk_XYIdeal'_mul_mk_XYIdeal'_of_Yeq h₂).symm
/-- The group homomorphism mapping an affine point $(x, y)$ of `W` to the class of the non-zero
fractional ideal $\langle X - x, Y - y \rangle$ of $F(W)$ in the class group of $F[W]$. -/
@[simps]
noncomputable def toClass : W.Point →+ Additive (ClassGroup W.CoordinateRing) where
  toFun := toClassFun
  map_zero' := rfl
  map_add' := by
    rintro (_ | @⟨x₁, y₁, h₁⟩) (_ | @⟨x₂, y₂, h₂⟩)
    any_goals simp only [zero_def, toClassFun, _root_.zero_add, _root_.add_zero]
    by_cases hx : x₁ = x₂
    · by_cases hy : y₁ = W.negY x₂ y₂
      · substs hx hy
        simpa only [some_add_some_of_Yeq rfl rfl] using
          (CoordinateRing.mk_XYIdeal'_mul_mk_XYIdeal'_of_Yeq h₂).symm
      · 

Proof state:
case neg
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
x₁ y₁ : F
h₁ : W.nonsingular x₁ y₁
x₂ y₂ : F
h₂ : W.nonsingular x₂ y₂
hx : x₁ = x₂
hy : ¬y₁ = W.negY x₂ y₂
⊢ (match some h₁ + some h₂ with
    | zero => 0
    | some h => Additive.ofMul (ClassGroup.mk (CoordinateRing.XYIdeal' h))) =
    Additive.ofMul (ClassGroup.mk (CoordinateRing.XYIdeal' h₁)) +
      Additive.ofMul (ClassGroup.mk (CoordinateRing.XYIdeal' h₂))

Next tactic:
simpa only [some_add_some_of_Yne hx hy] using
          (CoordinateRing.mk_XYIdeal'_mul_mk_XYIdeal' h₁ h₂ fun _ => hy).symm
/-- The group homomorphism mapping an affine point $(x, y)$ of `W` to the class of the non-zero
fractional ideal $\langle X - x, Y - y \rangle$ of $F(W)$ in the class group of $F[W]$. -/
@[simps]
noncomputable def toClass : W.Point →+ Additive (ClassGroup W.CoordinateRing) where
  toFun := toClassFun
  map_zero' := rfl
  map_add' := by
    rintro (_ | @⟨x₁, y₁, h₁⟩) (_ | @⟨x₂, y₂, h₂⟩)
    any_goals simp only [zero_def, toClassFun, _root_.zero_add, _root_.add_zero]
    by_cases hx : x₁ = x₂
    · by_cases hy : y₁ = W.negY x₂ y₂
      · substs hx hy
        simpa only [some_add_some_of_Yeq rfl rfl] using
          (CoordinateRing.mk_XYIdeal'_mul_mk_XYIdeal'_of_Yeq h₂).symm
      · simpa only [some_add_some_of_Yne hx hy] using
          (CoordinateRing.mk_XYIdeal'_mul_mk_XYIdeal' h₁ h₂ fun _ => hy).symm
    · 

Proof state:
case neg
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
x₁ y₁ : F
h₁ : W.nonsingular x₁ y₁
x₂ y₂ : F
h₂ : W.nonsingular x₂ y₂
hx : ¬x₁ = x₂
⊢ (match some h₁ + some h₂ with
    | zero => 0
    | some h => Additive.ofMul (ClassGroup.mk (CoordinateRing.XYIdeal' h))) =
    Additive.ofMul (ClassGroup.mk (CoordinateRing.XYIdeal' h₁)) +
      Additive.ofMul (ClassGroup.mk (CoordinateRing.XYIdeal' h₂))

Next tactic:
simpa only [some_add_some_of_Xne hx] using
        (CoordinateRing.mk_XYIdeal'_mul_mk_XYIdeal' h₁ h₂ fun h => (hx h).elim).symm
lemma add_eq_zero (P Q : W.Point) : P + Q = 0 ↔ P = -Q := by
  

Proof state:
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
P Q : Point W
⊢ P + Q = 0 ↔ P = -Q

Next tactic:
rcases P, Q with ⟨_ | @⟨x₁, y₁, _⟩, _ | @⟨x₂, y₂, _⟩⟩
lemma add_eq_zero (P Q : W.Point) : P + Q = 0 ↔ P = -Q := by
  rcases P, Q with ⟨_ | @⟨x₁, y₁, _⟩, _ | @⟨x₂, y₂, _⟩⟩
  

Proof state:
case zero.zero
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
⊢ zero + zero = 0 ↔ zero = -zero
case zero.some
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
x₂ y₂ : F
h✝ : W.nonsingular x₂ y₂
⊢ zero + some h✝ = 0 ↔ zero = -some h✝
case some.zero
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
x₁ y₁ : F
h✝ : W.nonsingular x₁ y₁
⊢ some h✝ + zero = 0 ↔ some h✝ = -zero
case some.some
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
x₁ y₁ : F
h✝¹ : W.nonsingular x₁ y₁
x₂ y₂ : F
h✝ : W.nonsingular x₂ y₂
⊢ some h✝¹ + some h✝ = 0 ↔ some h✝¹ = -some h✝

Next tactic:
any_goals rfl
lemma add_eq_zero (P Q : W.Point) : P + Q = 0 ↔ P = -Q := by
  rcases P, Q with ⟨_ | @⟨x₁, y₁, _⟩, _ | @⟨x₂, y₂, _⟩⟩
  any_goals 

Proof state:
case zero.zero
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
⊢ zero + zero = 0 ↔ zero = -zero

Next tactic:
rfl
lemma add_eq_zero (P Q : W.Point) : P + Q = 0 ↔ P = -Q := by
  rcases P, Q with ⟨_ | @⟨x₁, y₁, _⟩, _ | @⟨x₂, y₂, _⟩⟩
  any_goals 

Proof state:
case zero.some
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
x₂ y₂ : F
h✝ : W.nonsingular x₂ y₂
⊢ zero + some h✝ = 0 ↔ zero = -some h✝

Next tactic:
rfl
lemma add_eq_zero (P Q : W.Point) : P + Q = 0 ↔ P = -Q := by
  rcases P, Q with ⟨_ | @⟨x₁, y₁, _⟩, _ | @⟨x₂, y₂, _⟩⟩
  any_goals 

Proof state:
case some.zero
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
x₁ y₁ : F
h✝ : W.nonsingular x₁ y₁
⊢ some h✝ + zero = 0 ↔ some h✝ = -zero

Next tactic:
rfl
lemma add_eq_zero (P Q : W.Point) : P + Q = 0 ↔ P = -Q := by
  rcases P, Q with ⟨_ | @⟨x₁, y₁, _⟩, _ | @⟨x₂, y₂, _⟩⟩
  any_goals 

Proof state:
case some.some
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
x₁ y₁ : F
h✝¹ : W.nonsingular x₁ y₁
x₂ y₂ : F
h✝ : W.nonsingular x₂ y₂
⊢ some h✝¹ + some h✝ = 0 ↔ some h✝¹ = -some h✝

Next tactic:
rfl
lemma add_eq_zero (P Q : W.Point) : P + Q = 0 ↔ P = -Q := by
  rcases P, Q with ⟨_ | @⟨x₁, y₁, _⟩, _ | @⟨x₂, y₂, _⟩⟩
  any_goals rfl
  · 

Proof state:
case zero.some
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
x₂ y₂ : F
h✝ : W.nonsingular x₂ y₂
⊢ zero + some h✝ = 0 ↔ zero = -some h✝

Next tactic:
rw [zero_def, zero_add, ← neg_eq_iff_eq_neg, neg_zero, eq_comm]
lemma add_eq_zero (P Q : W.Point) : P + Q = 0 ↔ P = -Q := by
  rcases P, Q with ⟨_ | @⟨x₁, y₁, _⟩, _ | @⟨x₂, y₂, _⟩⟩
  any_goals rfl
  · rw [zero_def, zero_add, ← neg_eq_iff_eq_neg, neg_zero, eq_comm]
  · 

Proof state:
case some.some
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
x₁ y₁ : F
h✝¹ : W.nonsingular x₁ y₁
x₂ y₂ : F
h✝ : W.nonsingular x₂ y₂
⊢ some h✝¹ + some h✝ = 0 ↔ some h✝¹ = -some h✝

Next tactic:
rw [neg_some, some.injEq]
lemma add_eq_zero (P Q : W.Point) : P + Q = 0 ↔ P = -Q := by
  rcases P, Q with ⟨_ | @⟨x₁, y₁, _⟩, _ | @⟨x₂, y₂, _⟩⟩
  any_goals rfl
  · rw [zero_def, zero_add, ← neg_eq_iff_eq_neg, neg_zero, eq_comm]
  · rw [neg_some, some.injEq]
    

Proof state:
case some.some
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
x₁ y₁ : F
h✝¹ : W.nonsingular x₁ y₁
x₂ y₂ : F
h✝ : W.nonsingular x₂ y₂
⊢ some h✝¹ + some h✝ = 0 ↔ x₁ = x₂ ∧ y₁ = W.negY x₂ y₂

Next tactic:
constructor
lemma add_eq_zero (P Q : W.Point) : P + Q = 0 ↔ P = -Q := by
  rcases P, Q with ⟨_ | @⟨x₁, y₁, _⟩, _ | @⟨x₂, y₂, _⟩⟩
  any_goals rfl
  · rw [zero_def, zero_add, ← neg_eq_iff_eq_neg, neg_zero, eq_comm]
  · rw [neg_some, some.injEq]
    constructor
    · 

Proof state:
case some.some.mp
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
x₁ y₁ : F
h✝¹ : W.nonsingular x₁ y₁
x₂ y₂ : F
h✝ : W.nonsingular x₂ y₂
⊢ some h✝¹ + some h✝ = 0 → x₁ = x₂ ∧ y₁ = W.negY x₂ y₂

Next tactic:
intro h
lemma add_eq_zero (P Q : W.Point) : P + Q = 0 ↔ P = -Q := by
  rcases P, Q with ⟨_ | @⟨x₁, y₁, _⟩, _ | @⟨x₂, y₂, _⟩⟩
  any_goals rfl
  · rw [zero_def, zero_add, ← neg_eq_iff_eq_neg, neg_zero, eq_comm]
  · rw [neg_some, some.injEq]
    constructor
    · intro h
      

Proof state:
case some.some.mp
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
x₁ y₁ : F
h✝¹ : W.nonsingular x₁ y₁
x₂ y₂ : F
h✝ : W.nonsingular x₂ y₂
h : some h✝¹ + some h✝ = 0
⊢ x₁ = x₂ ∧ y₁ = W.negY x₂ y₂

Next tactic:
by_cases hx : x₁ = x₂
lemma add_eq_zero (P Q : W.Point) : P + Q = 0 ↔ P = -Q := by
  rcases P, Q with ⟨_ | @⟨x₁, y₁, _⟩, _ | @⟨x₂, y₂, _⟩⟩
  any_goals rfl
  · rw [zero_def, zero_add, ← neg_eq_iff_eq_neg, neg_zero, eq_comm]
  · rw [neg_some, some.injEq]
    constructor
    · intro h
      by_cases hx : x₁ = x₂
      · 

Proof state:
case pos
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
x₁ y₁ : F
h✝¹ : W.nonsingular x₁ y₁
x₂ y₂ : F
h✝ : W.nonsingular x₂ y₂
h : some h✝¹ + some h✝ = 0
hx : x₁ = x₂
⊢ x₁ = x₂ ∧ y₁ = W.negY x₂ y₂

Next tactic:
by_cases hy : y₁ = W.negY x₂ y₂
lemma add_eq_zero (P Q : W.Point) : P + Q = 0 ↔ P = -Q := by
  rcases P, Q with ⟨_ | @⟨x₁, y₁, _⟩, _ | @⟨x₂, y₂, _⟩⟩
  any_goals rfl
  · rw [zero_def, zero_add, ← neg_eq_iff_eq_neg, neg_zero, eq_comm]
  · rw [neg_some, some.injEq]
    constructor
    · intro h
      by_cases hx : x₁ = x₂
      · by_cases hy : y₁ = W.negY x₂ y₂
        · 

Proof state:
case pos
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
x₁ y₁ : F
h✝¹ : W.nonsingular x₁ y₁
x₂ y₂ : F
h✝ : W.nonsingular x₂ y₂
h : some h✝¹ + some h✝ = 0
hx : x₁ = x₂
hy : y₁ = W.negY x₂ y₂
⊢ x₁ = x₂ ∧ y₁ = W.negY x₂ y₂

Next tactic:
exact ⟨hx, hy⟩
lemma add_eq_zero (P Q : W.Point) : P + Q = 0 ↔ P = -Q := by
  rcases P, Q with ⟨_ | @⟨x₁, y₁, _⟩, _ | @⟨x₂, y₂, _⟩⟩
  any_goals rfl
  · rw [zero_def, zero_add, ← neg_eq_iff_eq_neg, neg_zero, eq_comm]
  · rw [neg_some, some.injEq]
    constructor
    · intro h
      by_cases hx : x₁ = x₂
      · by_cases hy : y₁ = W.negY x₂ y₂
        · exact ⟨hx, hy⟩
        · 

Proof state:
case neg
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
x₁ y₁ : F
h✝¹ : W.nonsingular x₁ y₁
x₂ y₂ : F
h✝ : W.nonsingular x₂ y₂
h : some h✝¹ + some h✝ = 0
hx : x₁ = x₂
hy : ¬y₁ = W.negY x₂ y₂
⊢ x₁ = x₂ ∧ y₁ = W.negY x₂ y₂

Next tactic:
rw [some_add_some_of_Yne hx hy] at h
lemma add_eq_zero (P Q : W.Point) : P + Q = 0 ↔ P = -Q := by
  rcases P, Q with ⟨_ | @⟨x₁, y₁, _⟩, _ | @⟨x₂, y₂, _⟩⟩
  any_goals rfl
  · rw [zero_def, zero_add, ← neg_eq_iff_eq_neg, neg_zero, eq_comm]
  · rw [neg_some, some.injEq]
    constructor
    · intro h
      by_cases hx : x₁ = x₂
      · by_cases hy : y₁ = W.negY x₂ y₂
        · exact ⟨hx, hy⟩
        · rw [some_add_some_of_Yne hx hy] at h
          

Proof state:
case neg
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
x₁ y₁ : F
h✝¹ : W.nonsingular x₁ y₁
x₂ y₂ : F
h✝ : W.nonsingular x₂ y₂
hx : x₁ = x₂
hy : ¬y₁ = W.negY x₂ y₂
h : some (_ : W.nonsingular (W.addX x₁ x₂ (W.slope x₁ x₂ y₁ y₂)) (W.addY x₁ x₂ y₁ (W.slope x₁ x₂ y₁ y₂))) = 0
⊢ x₁ = x₂ ∧ y₁ = W.negY x₂ y₂

Next tactic:
contradiction
lemma add_eq_zero (P Q : W.Point) : P + Q = 0 ↔ P = -Q := by
  rcases P, Q with ⟨_ | @⟨x₁, y₁, _⟩, _ | @⟨x₂, y₂, _⟩⟩
  any_goals rfl
  · rw [zero_def, zero_add, ← neg_eq_iff_eq_neg, neg_zero, eq_comm]
  · rw [neg_some, some.injEq]
    constructor
    · intro h
      by_cases hx : x₁ = x₂
      · by_cases hy : y₁ = W.negY x₂ y₂
        · exact ⟨hx, hy⟩
        · rw [some_add_some_of_Yne hx hy] at h
          contradiction
      · 

Proof state:
case neg
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
x₁ y₁ : F
h✝¹ : W.nonsingular x₁ y₁
x₂ y₂ : F
h✝ : W.nonsingular x₂ y₂
h : some h✝¹ + some h✝ = 0
hx : ¬x₁ = x₂
⊢ x₁ = x₂ ∧ y₁ = W.negY x₂ y₂

Next tactic:
rw [some_add_some_of_Xne hx] at h
lemma add_eq_zero (P Q : W.Point) : P + Q = 0 ↔ P = -Q := by
  rcases P, Q with ⟨_ | @⟨x₁, y₁, _⟩, _ | @⟨x₂, y₂, _⟩⟩
  any_goals rfl
  · rw [zero_def, zero_add, ← neg_eq_iff_eq_neg, neg_zero, eq_comm]
  · rw [neg_some, some.injEq]
    constructor
    · intro h
      by_cases hx : x₁ = x₂
      · by_cases hy : y₁ = W.negY x₂ y₂
        · exact ⟨hx, hy⟩
        · rw [some_add_some_of_Yne hx hy] at h
          contradiction
      · rw [some_add_some_of_Xne hx] at h
        

Proof state:
case neg
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
x₁ y₁ : F
h✝¹ : W.nonsingular x₁ y₁
x₂ y₂ : F
h✝ : W.nonsingular x₂ y₂
hx : ¬x₁ = x₂
h : some (_ : W.nonsingular (W.addX x₁ x₂ (W.slope x₁ x₂ y₁ y₂)) (W.addY x₁ x₂ y₁ (W.slope x₁ x₂ y₁ y₂))) = 0
⊢ x₁ = x₂ ∧ y₁ = W.negY x₂ y₂

Next tactic:
contradiction
lemma add_eq_zero (P Q : W.Point) : P + Q = 0 ↔ P = -Q := by
  rcases P, Q with ⟨_ | @⟨x₁, y₁, _⟩, _ | @⟨x₂, y₂, _⟩⟩
  any_goals rfl
  · rw [zero_def, zero_add, ← neg_eq_iff_eq_neg, neg_zero, eq_comm]
  · rw [neg_some, some.injEq]
    constructor
    · intro h
      by_cases hx : x₁ = x₂
      · by_cases hy : y₁ = W.negY x₂ y₂
        · exact ⟨hx, hy⟩
        · rw [some_add_some_of_Yne hx hy] at h
          contradiction
      · rw [some_add_some_of_Xne hx] at h
        contradiction
    · 

Proof state:
case some.some.mpr
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
x₁ y₁ : F
h✝¹ : W.nonsingular x₁ y₁
x₂ y₂ : F
h✝ : W.nonsingular x₂ y₂
⊢ x₁ = x₂ ∧ y₁ = W.negY x₂ y₂ → some h✝¹ + some h✝ = 0

Next tactic:
exact fun ⟨hx, hy⟩ => some_add_some_of_Yeq hx hy
lemma add_left_neg (P : W.Point) : -P + P = 0 := by
  

Proof state:
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
P : Point W
⊢ -P + P = 0

Next tactic:
rw [add_eq_zero]
lemma neg_add_eq_zero (P Q : W.Point) : -P + Q = 0 ↔ P = Q := by
  

Proof state:
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
P Q : Point W
⊢ -P + Q = 0 ↔ P = Q

Next tactic:
rw [add_eq_zero, neg_inj]
lemma toClass_eq_zero (P : W.Point) : toClass P = 0 ↔ P = 0 := by
  

Proof state:
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
P : Point W
⊢ toClass P = 0 ↔ P = 0

Next tactic:
constructor
lemma toClass_eq_zero (P : W.Point) : toClass P = 0 ↔ P = 0 := by
  constructor
  · 

Proof state:
case mp
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
P : Point W
⊢ toClass P = 0 → P = 0

Next tactic:
intro hP
lemma toClass_eq_zero (P : W.Point) : toClass P = 0 ↔ P = 0 := by
  constructor
  · intro hP
    

Proof state:
case mp
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
P : Point W
hP : toClass P = 0
⊢ P = 0

Next tactic:
rcases P with (_ | @⟨_, _, ⟨h, _⟩⟩)
lemma toClass_eq_zero (P : W.Point) : toClass P = 0 ↔ P = 0 := by
  constructor
  · intro hP
    rcases P with (_ | @⟨_, _, ⟨h, _⟩⟩)
    · 

Proof state:
case mp.zero
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
hP : toClass zero = 0
⊢ zero = 0

Next tactic:
rfl
lemma toClass_eq_zero (P : W.Point) : toClass P = 0 ↔ P = 0 := by
  constructor
  · intro hP
    rcases P with (_ | @⟨_, _, ⟨h, _⟩⟩)
    · rfl
    · 

Proof state:
case mp.some.intro
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
x✝ y✝ : F
h : W.equation x✝ y✝
right✝ : eval x✝ (eval (C y✝) W.polynomialX) ≠ 0 ∨ eval x✝ (eval (C y✝) W.polynomialY) ≠ 0
hP :
  toClass
      (some
        (_ : W.equation x✝ y✝ ∧ (eval x✝ (eval (C y✝) W.polynomialX) ≠ 0 ∨ eval x✝ (eval (C y✝) W.polynomialY) ≠ 0))) =
    0
⊢ some (_ : W.equation x✝ y✝ ∧ (eval x✝ (eval (C y✝) W.polynomialX) ≠ 0 ∨ eval x✝ (eval (C y✝) W.polynomialY) ≠ 0)) = 0

Next tactic:
rcases (ClassGroup.mk_eq_one_of_coe_ideal <| by rfl).mp hP with ⟨p, h0, hp⟩
lemma toClass_eq_zero (P : W.Point) : toClass P = 0 ↔ P = 0 := by
  constructor
  · intro hP
    rcases P with (_ | @⟨_, _, ⟨h, _⟩⟩)
    · rfl
    · rcases (ClassGroup.mk_eq_one_of_coe_ideal <| by 

Proof state:
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
x✝ y✝ : F
h : W.equation x✝ y✝
right✝ : eval x✝ (eval (C y✝) W.polynomialX) ≠ 0 ∨ eval x✝ (eval (C y✝) W.polynomialY) ≠ 0
hP :
  toClass
      (some
        (_ : W.equation x✝ y✝ ∧ (eval x✝ (eval (C y✝) W.polynomialX) ≠ 0 ∨ eval x✝ (eval (C y✝) W.polynomialY) ≠ 0))) =
    0
⊢ ↑(CoordinateRing.XYIdeal'
        (_ : W.equation x✝ y✝ ∧ (eval x✝ (eval (C y✝) W.polynomialX) ≠ 0 ∨ eval x✝ (eval (C y✝) W.polynomialY) ≠ 0))) =
    ↑?m.5145140

Next tactic:
rfl
lemma toClass_eq_zero (P : W.Point) : toClass P = 0 ↔ P = 0 := by
  constructor
  · intro hP
    rcases P with (_ | @⟨_, _, ⟨h, _⟩⟩)
    · rfl
    · rcases (ClassGroup.mk_eq_one_of_coe_ideal <| by rfl).mp hP with ⟨p, h0, hp⟩
      

Proof state:
case mp.some.intro.intro.intro
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
x✝ y✝ : F
h : W.equation x✝ y✝
right✝ : eval x✝ (eval (C y✝) W.polynomialX) ≠ 0 ∨ eval x✝ (eval (C y✝) W.polynomialY) ≠ 0
hP :
  toClass
      (some
        (_ : W.equation x✝ y✝ ∧ (eval x✝ (eval (C y✝) W.polynomialX) ≠ 0 ∨ eval x✝ (eval (C y✝) W.polynomialY) ≠ 0))) =
    0
p : W.CoordinateRing
h0 : p ≠ 0
hp : CoordinateRing.XYIdeal W x✝ (C y✝) = span {p}
⊢ some (_ : W.equation x✝ y✝ ∧ (eval x✝ (eval (C y✝) W.polynomialX) ≠ 0 ∨ eval x✝ (eval (C y✝) W.polynomialY) ≠ 0)) = 0

Next tactic:
apply (p.natDegree_norm_ne_one _).elim