l3lab/ntp-mathlib huggingface dataset:
lemma XYIdeal_eq₂ {x₁ x₂ y₁ y₂ : F} (h₁ : W.equation x₁ y₁)
    (h₂ : W.equation x₂ y₂) (hxy : x₁ = x₂ → y₁ ≠ W.negY x₂ y₂) :
    XYIdeal W x₂ (C y₂) = XYIdeal W x₂ (linePolynomial x₁ y₁ <| W.slope x₁ x₂ y₁ y₂) := by
  have hy₂ : y₂ = (linePolynomial x₁ y₁ <| W.slope x₁ x₂ y₁ y₂).eval x₂ := by
    by_cases hx : x₁ = x₂
    · rcases hx, Yeq_of_Yne h₁ h₂ hx <| hxy hx with ⟨rfl, rfl⟩
      field_simp [linePolynomial, sub_ne_zero_of_ne (hxy rfl)]
    · field_simp [linePolynomial, slope_of_Xne hx, sub_ne_zero_of_ne hx]
      ring1
  nth_rw 1 [hy₂]
  simp only [XYIdeal, XClass, YClass, linePolynomial]
  

Proof state:
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
x₁ x₂ y₁ y₂ : F
h₁ : W.equation x₁ y₁
h₂ : W.equation x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ W.negY x₂ y₂
hy₂ : y₂ = eval x₂ (x₁.linePolynomial y₁ (W.slope x₁ x₂ y₁ y₂))
⊢ span {(mk W) (C (Y - C x₂)), (mk W) (Y - C (C (eval x₂ (C (W.slope x₁ x₂ y₁ y₂) * (Y - C x₁) + C y₁))))} =
    span {(mk W) (C (Y - C x₂)), (mk W) (Y - C (C (W.slope x₁ x₂ y₁ y₂) * (Y - C x₁) + C y₁))}

Next tactic:
rw [← span_pair_add_mul_right <| mk W <| C <| C <| -W.slope x₁ x₂ y₁ y₂, ← _root_.map_mul,
    ← map_add]
lemma XYIdeal_eq₂ {x₁ x₂ y₁ y₂ : F} (h₁ : W.equation x₁ y₁)
    (h₂ : W.equation x₂ y₂) (hxy : x₁ = x₂ → y₁ ≠ W.negY x₂ y₂) :
    XYIdeal W x₂ (C y₂) = XYIdeal W x₂ (linePolynomial x₁ y₁ <| W.slope x₁ x₂ y₁ y₂) := by
  have hy₂ : y₂ = (linePolynomial x₁ y₁ <| W.slope x₁ x₂ y₁ y₂).eval x₂ := by
    by_cases hx : x₁ = x₂
    · rcases hx, Yeq_of_Yne h₁ h₂ hx <| hxy hx with ⟨rfl, rfl⟩
      field_simp [linePolynomial, sub_ne_zero_of_ne (hxy rfl)]
    · field_simp [linePolynomial, slope_of_Xne hx, sub_ne_zero_of_ne hx]
      ring1
  nth_rw 1 [hy₂]
  simp only [XYIdeal, XClass, YClass, linePolynomial]
  rw [← span_pair_add_mul_right <| mk W <| C <| C <| -W.slope x₁ x₂ y₁ y₂, ← _root_.map_mul,
    ← map_add]
  

Proof state:
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
x₁ x₂ y₁ y₂ : F
h₁ : W.equation x₁ y₁
h₂ : W.equation x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ W.negY x₂ y₂
hy₂ : y₂ = eval x₂ (x₁.linePolynomial y₁ (W.slope x₁ x₂ y₁ y₂))
⊢ span
      {(mk W) (C (Y - C x₂)),
        (mk W)
          (Y - C (C (eval x₂ (C (W.slope x₁ x₂ y₁ y₂) * (Y - C x₁) + C y₁))) +
            C (Y - C x₂) * C (C (-W.slope x₁ x₂ y₁ y₂)))} =
    span {(mk W) (C (Y - C x₂)), (mk W) (Y - C (C (W.slope x₁ x₂ y₁ y₂) * (Y - C x₁) + C y₁))}

Next tactic:
apply congr_arg (_ ∘ _ ∘ _ ∘ _)
lemma XYIdeal_eq₂ {x₁ x₂ y₁ y₂ : F} (h₁ : W.equation x₁ y₁)
    (h₂ : W.equation x₂ y₂) (hxy : x₁ = x₂ → y₁ ≠ W.negY x₂ y₂) :
    XYIdeal W x₂ (C y₂) = XYIdeal W x₂ (linePolynomial x₁ y₁ <| W.slope x₁ x₂ y₁ y₂) := by
  have hy₂ : y₂ = (linePolynomial x₁ y₁ <| W.slope x₁ x₂ y₁ y₂).eval x₂ := by
    by_cases hx : x₁ = x₂
    · rcases hx, Yeq_of_Yne h₁ h₂ hx <| hxy hx with ⟨rfl, rfl⟩
      field_simp [linePolynomial, sub_ne_zero_of_ne (hxy rfl)]
    · field_simp [linePolynomial, slope_of_Xne hx, sub_ne_zero_of_ne hx]
      ring1
  nth_rw 1 [hy₂]
  simp only [XYIdeal, XClass, YClass, linePolynomial]
  rw [← span_pair_add_mul_right <| mk W <| C <| C <| -W.slope x₁ x₂ y₁ y₂, ← _root_.map_mul,
    ← map_add]
  apply congr_arg (_ ∘ _ ∘ _ ∘ _)
  

Proof state:
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
x₁ x₂ y₁ y₂ : F
h₁ : W.equation x₁ y₁
h₂ : W.equation x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ W.negY x₂ y₂
hy₂ : y₂ = eval x₂ (x₁.linePolynomial y₁ (W.slope x₁ x₂ y₁ y₂))
⊢ Y - C (C (eval x₂ (C (W.slope x₁ x₂ y₁ y₂) * (Y - C x₁) + C y₁))) + C (Y - C x₂) * C (C (-W.slope x₁ x₂ y₁ y₂)) =
    Y - C (C (W.slope x₁ x₂ y₁ y₂) * (Y - C x₁) + C y₁)

Next tactic:
eval_simp
lemma XYIdeal_eq₂ {x₁ x₂ y₁ y₂ : F} (h₁ : W.equation x₁ y₁)
    (h₂ : W.equation x₂ y₂) (hxy : x₁ = x₂ → y₁ ≠ W.negY x₂ y₂) :
    XYIdeal W x₂ (C y₂) = XYIdeal W x₂ (linePolynomial x₁ y₁ <| W.slope x₁ x₂ y₁ y₂) := by
  have hy₂ : y₂ = (linePolynomial x₁ y₁ <| W.slope x₁ x₂ y₁ y₂).eval x₂ := by
    by_cases hx : x₁ = x₂
    · rcases hx, Yeq_of_Yne h₁ h₂ hx <| hxy hx with ⟨rfl, rfl⟩
      field_simp [linePolynomial, sub_ne_zero_of_ne (hxy rfl)]
    · field_simp [linePolynomial, slope_of_Xne hx, sub_ne_zero_of_ne hx]
      ring1
  nth_rw 1 [hy₂]
  simp only [XYIdeal, XClass, YClass, linePolynomial]
  rw [← span_pair_add_mul_right <| mk W <| C <| C <| -W.slope x₁ x₂ y₁ y₂, ← _root_.map_mul,
    ← map_add]
  apply congr_arg (_ ∘ _ ∘ _ ∘ _)
  eval_simp
  

Proof state:
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
x₁ x₂ y₁ y₂ : F
h₁ : W.equation x₁ y₁
h₂ : W.equation x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ W.negY x₂ y₂
hy₂ : y₂ = eval x₂ (x₁.linePolynomial y₁ (W.slope x₁ x₂ y₁ y₂))
⊢ Y - C (C (W.slope x₁ x₂ y₁ y₂ * (x₂ - x₁) + y₁)) + C (Y - C x₂) * C (C (-W.slope x₁ x₂ y₁ y₂)) =
    Y - C (C (W.slope x₁ x₂ y₁ y₂) * (Y - C x₁) + C y₁)

Next tactic:
C_simp
lemma XYIdeal_eq₂ {x₁ x₂ y₁ y₂ : F} (h₁ : W.equation x₁ y₁)
    (h₂ : W.equation x₂ y₂) (hxy : x₁ = x₂ → y₁ ≠ W.negY x₂ y₂) :
    XYIdeal W x₂ (C y₂) = XYIdeal W x₂ (linePolynomial x₁ y₁ <| W.slope x₁ x₂ y₁ y₂) := by
  have hy₂ : y₂ = (linePolynomial x₁ y₁ <| W.slope x₁ x₂ y₁ y₂).eval x₂ := by
    by_cases hx : x₁ = x₂
    · rcases hx, Yeq_of_Yne h₁ h₂ hx <| hxy hx with ⟨rfl, rfl⟩
      field_simp [linePolynomial, sub_ne_zero_of_ne (hxy rfl)]
    · field_simp [linePolynomial, slope_of_Xne hx, sub_ne_zero_of_ne hx]
      ring1
  nth_rw 1 [hy₂]
  simp only [XYIdeal, XClass, YClass, linePolynomial]
  rw [← span_pair_add_mul_right <| mk W <| C <| C <| -W.slope x₁ x₂ y₁ y₂, ← _root_.map_mul,
    ← map_add]
  apply congr_arg (_ ∘ _ ∘ _ ∘ _)
  eval_simp
  C_simp
  

Proof state:
R : Type u
inst✝¹ : CommRing R
W✝ : Affine R
F : Type u
inst✝ : Field F
W : Affine F
x₁ x₂ y₁ y₂ : F
h₁ : W.equation x₁ y₁
h₂ : W.equation x₂ y₂
hxy : x₁ = x₂ → y₁ ≠ W.negY x₂ y₂
hy₂ : y₂ = eval x₂ (x₁.linePolynomial y₁ (W.slope x₁ x₂ y₁ y₂))
⊢ Y - (C (C (W.slope x₁ x₂ y₁ y₂)) * (C (C x₂) - C (C x₁)) + C (C y₁)) +
      (C Y - C (C x₂)) * -C (C (W.slope x₁ x₂ y₁ y₂)) =
    Y - (C (C (W.slope x₁ x₂ y₁ y₂)) * (C Y - C (C x₁)) + C (C y₁))

Next tactic:
ring1
lemma XYIdeal_neg_mul {x y : F} (h : W.nonsingular x y) :
    XYIdeal W x (C <| W.negY x y) * XYIdeal W x (C y) = XIdeal W x := 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.nonsingular x y
⊢ XYIdeal W x (C (W.negY x y)) * XYIdeal W x (C y) = XIdeal W x

Next tactic:
have Y_rw : (Y - C (C y)) * (Y - C (C (W.negY x y))) -
      C (X - C x) * (C (X ^ 2 + C (x + W.a₂) * X + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y) =
        W.polynomial * 1 := by
    linear_combination (norm := (rw [negY, polynomial]; C_simp; ring1))
      congr_arg C (congr_arg C ((W.equation_iff _ _).mp h.left).symm)
lemma XYIdeal_neg_mul {x y : F} (h : W.nonsingular x y) :
    XYIdeal W x (C <| W.negY x y) * XYIdeal W x (C y) = XIdeal W x := by
  have Y_rw : (Y - C (C y)) * (Y - C (C (W.negY x y))) -
      C (X - C x) * (C (X ^ 2 + C (x + W.a₂) * X + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y) =
        W.polynomial * 1 := 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.nonsingular x y
⊢ (Y - C (C y)) * (Y - C (C (W.negY x y))) -
      C (Y - C x) * (C (Y ^ 2 + C (x + W.a₂) * Y + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y) =
    W.polynomial * 1

Next tactic:
linear_combination (norm := (rw [negY, polynomial]; C_simp; ring1))
      congr_arg C (congr_arg C ((W.equation_iff _ _).mp h.left).symm)
lemma XYIdeal_neg_mul {x y : F} (h : W.nonsingular x y) :
    XYIdeal W x (C <| W.negY x y) * XYIdeal W x (C y) = XIdeal W x := by
  have Y_rw : (Y - C (C y)) * (Y - C (C (W.negY x y))) -
      C (X - C x) * (C (X ^ 2 + C (x + W.a₂) * X + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y) =
        W.polynomial * 1 := by
    linear_combination (norm := (

Proof state:
case a
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
⊢ (Y - C (C y)) * (Y - C (C (W.negY x y))) -
          C (Y - C x) * (C (Y ^ 2 + C (x + W.a₂) * Y + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y) -
        W.polynomial * 1 -
      (C (C (x ^ 3 + W.a₂ * x ^ 2 + W.a₄ * x + W.a₆)) - C (C (y ^ 2 + W.a₁ * x * y + W.a₃ * y))) =
    0

Next tactic:
rw [negY, polynomial]
lemma XYIdeal_neg_mul {x y : F} (h : W.nonsingular x y) :
    XYIdeal W x (C <| W.negY x y) * XYIdeal W x (C y) = XIdeal W x := by
  have Y_rw : (Y - C (C y)) * (Y - C (C (W.negY x y))) -
      C (X - C x) * (C (X ^ 2 + C (x + W.a₂) * X + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y) =
        W.polynomial * 1 := by
    linear_combination (norm := (rw [negY, polynomial]; 

Proof state:
case a
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
⊢ (Y - C (C y)) * (Y - C (C (-y - W.a₁ * x - W.a₃))) -
          C (Y - C x) * (C (Y ^ 2 + C (x + W.a₂) * Y + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y) -
        (Y ^ 2 + C (C W.a₁ * Y + C W.a₃) * Y - C (Y ^ 3 + C W.a₂ * Y ^ 2 + C W.a₄ * Y + C W.a₆)) * 1 -
      (C (C (x ^ 3 + W.a₂ * x ^ 2 + W.a₄ * x + W.a₆)) - C (C (y ^ 2 + W.a₁ * x * y + W.a₃ * y))) =
    0

Next tactic:
C_simp
lemma XYIdeal_neg_mul {x y : F} (h : W.nonsingular x y) :
    XYIdeal W x (C <| W.negY x y) * XYIdeal W x (C y) = XIdeal W x := by
  have Y_rw : (Y - C (C y)) * (Y - C (C (W.negY x y))) -
      C (X - C x) * (C (X ^ 2 + C (x + W.a₂) * X + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y) =
        W.polynomial * 1 := by
    linear_combination (norm := (rw [negY, polynomial]; C_simp; 

Proof state:
case a
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
⊢ (Y - C (C y)) * (Y - (-C (C y) - C (C W.a₁) * C (C x) - C (C W.a₃))) -
          (C Y - C (C x)) *
            (C Y ^ 2 + (C (C x) + C (C W.a₂)) * C Y + (C (C x) ^ 2 + C (C W.a₂) * C (C x) + C (C W.a₄)) -
              C (C W.a₁) * Y) -
        (Y ^ 2 + (C (C W.a₁) * C Y + C (C W.a₃)) * Y -
            (C Y ^ 3 + C (C W.a₂) * C Y ^ 2 + C (C W.a₄) * C Y + C (C W.a₆))) *
          1 -
      (C (C x) ^ 3 + C (C W.a₂) * C (C x) ^ 2 + C (C W.a₄) * C (C x) + C (C W.a₆) -
        (C (C y) ^ 2 + C (C W.a₁) * C (C x) * C (C y) + C (C W.a₃) * C (C y))) =
    0

Next tactic:
ring1
lemma XYIdeal_neg_mul {x y : F} (h : W.nonsingular x y) :
    XYIdeal W x (C <| W.negY x y) * XYIdeal W x (C y) = XIdeal W x := by
  have Y_rw : (Y - C (C y)) * (Y - C (C (W.negY x y))) -
      C (X - C x) * (C (X ^ 2 + C (x + W.a₂) * X + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y) =
        W.polynomial * 1 := by
    linear_combination (norm := (rw [negY, polynomial]; C_simp; ring1))
      congr_arg C (congr_arg C ((W.equation_iff _ _).mp h.left).symm)
  

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.nonsingular x y
Y_rw :
  (Y - C (C y)) * (Y - C (C (W.negY x y))) -
      C (Y - C x) * (C (Y ^ 2 + C (x + W.a₂) * Y + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y) =
    W.polynomial * 1
⊢ XYIdeal W x (C (W.negY x y)) * XYIdeal W x (C y) = XIdeal W x

Next tactic:
simp_rw [XYIdeal, XClass, YClass, span_pair_mul_span_pair, mul_comm, ← _root_.map_mul,
    AdjoinRoot.mk_eq_mk.mpr ⟨1, Y_rw⟩, _root_.map_mul, span_insert,
    ← span_singleton_mul_span_singleton, ← mul_sup, ← span_insert]
lemma XYIdeal_neg_mul {x y : F} (h : W.nonsingular x y) :
    XYIdeal W x (C <| W.negY x y) * XYIdeal W x (C y) = XIdeal W x := by
  have Y_rw : (Y - C (C y)) * (Y - C (C (W.negY x y))) -
      C (X - C x) * (C (X ^ 2 + C (x + W.a₂) * X + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y) =
        W.polynomial * 1 := by
    linear_combination (norm := (rw [negY, polynomial]; C_simp; ring1))
      congr_arg C (congr_arg C ((W.equation_iff _ _).mp h.left).symm)
  simp_rw [XYIdeal, XClass, YClass, span_pair_mul_span_pair, mul_comm, ← _root_.map_mul,
    AdjoinRoot.mk_eq_mk.mpr ⟨1, Y_rw⟩, _root_.map_mul, span_insert,
    ← span_singleton_mul_span_singleton, ← mul_sup, ← span_insert]
  

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.nonsingular x y
Y_rw :
  (Y - C (C y)) * (Y - C (C (W.negY x y))) -
      C (Y - C x) * (C (Y ^ 2 + C (x + W.a₂) * Y + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y) =
    W.polynomial * 1
⊢ span {(mk W) (C (Y - C x))} *
      span
        {(mk W) (C (Y - C x)), (mk W) (Y - C (C y)), (mk W) (Y - C (C (W.negY x y))),
          (AdjoinRoot.mk W.polynomial) (C (Y ^ 2 + C (x + W.a₂) * Y + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y)} =
    XIdeal W x

Next tactic:
convert mul_top (_ : Ideal W.CoordinateRing) using 2
lemma XYIdeal_neg_mul {x y : F} (h : W.nonsingular x y) :
    XYIdeal W x (C <| W.negY x y) * XYIdeal W x (C y) = XIdeal W x := by
  have Y_rw : (Y - C (C y)) * (Y - C (C (W.negY x y))) -
      C (X - C x) * (C (X ^ 2 + C (x + W.a₂) * X + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y) =
        W.polynomial * 1 := by
    linear_combination (norm := (rw [negY, polynomial]; C_simp; ring1))
      congr_arg C (congr_arg C ((W.equation_iff _ _).mp h.left).symm)
  simp_rw [XYIdeal, XClass, YClass, span_pair_mul_span_pair, mul_comm, ← _root_.map_mul,
    AdjoinRoot.mk_eq_mk.mpr ⟨1, Y_rw⟩, _root_.map_mul, span_insert,
    ← span_singleton_mul_span_singleton, ← mul_sup, ← span_insert]
  convert mul_top (_ : Ideal W.CoordinateRing) using 2
  

Proof state:
case h.e'_2.h.e'_6
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
Y_rw :
  (Y - C (C y)) * (Y - C (C (W.negY x y))) -
      C (Y - C x) * (C (Y ^ 2 + C (x + W.a₂) * Y + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y) =
    W.polynomial * 1
⊢ span
      {(mk W) (C (Y - C x)), (mk W) (Y - C (C y)), (mk W) (Y - C (C (W.negY x y))),
        (AdjoinRoot.mk W.polynomial) (C (Y ^ 2 + C (x + W.a₂) * Y + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y)} =
    ⊤

Next tactic:
simp_rw [← @Set.image_singleton _ _ <| mk W, ← Set.image_insert_eq, ← map_span]
lemma XYIdeal_neg_mul {x y : F} (h : W.nonsingular x y) :
    XYIdeal W x (C <| W.negY x y) * XYIdeal W x (C y) = XIdeal W x := by
  have Y_rw : (Y - C (C y)) * (Y - C (C (W.negY x y))) -
      C (X - C x) * (C (X ^ 2 + C (x + W.a₂) * X + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y) =
        W.polynomial * 1 := by
    linear_combination (norm := (rw [negY, polynomial]; C_simp; ring1))
      congr_arg C (congr_arg C ((W.equation_iff _ _).mp h.left).symm)
  simp_rw [XYIdeal, XClass, YClass, span_pair_mul_span_pair, mul_comm, ← _root_.map_mul,
    AdjoinRoot.mk_eq_mk.mpr ⟨1, Y_rw⟩, _root_.map_mul, span_insert,
    ← span_singleton_mul_span_singleton, ← mul_sup, ← span_insert]
  convert mul_top (_ : Ideal W.CoordinateRing) using 2
  simp_rw [← @Set.image_singleton _ _ <| mk W, ← Set.image_insert_eq, ← map_span]
  

Proof state:
case h.e'_2.h.e'_6
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
Y_rw :
  (Y - C (C y)) * (Y - C (C (W.negY x y))) -
      C (Y - C x) * (C (Y ^ 2 + C (x + W.a₂) * Y + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y) =
    W.polynomial * 1
⊢ Ideal.map (mk W)
      (span
        {C (Y - C x), Y - C (C y), Y - C (C (W.negY x y)),
          C (Y ^ 2 + C (x + W.a₂) * Y + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y}) =
    ⊤

Next tactic:
convert map_top (R := F[X][Y]) (mk W) using 1
lemma XYIdeal_neg_mul {x y : F} (h : W.nonsingular x y) :
    XYIdeal W x (C <| W.negY x y) * XYIdeal W x (C y) = XIdeal W x := by
  have Y_rw : (Y - C (C y)) * (Y - C (C (W.negY x y))) -
      C (X - C x) * (C (X ^ 2 + C (x + W.a₂) * X + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y) =
        W.polynomial * 1 := by
    linear_combination (norm := (rw [negY, polynomial]; C_simp; ring1))
      congr_arg C (congr_arg C ((W.equation_iff _ _).mp h.left).symm)
  simp_rw [XYIdeal, XClass, YClass, span_pair_mul_span_pair, mul_comm, ← _root_.map_mul,
    AdjoinRoot.mk_eq_mk.mpr ⟨1, Y_rw⟩, _root_.map_mul, span_insert,
    ← span_singleton_mul_span_singleton, ← mul_sup, ← span_insert]
  convert mul_top (_ : Ideal W.CoordinateRing) using 2
  simp_rw [← @Set.image_singleton _ _ <| mk W, ← Set.image_insert_eq, ← map_span]
  convert map_top (R := F[X][Y]) (mk W) using 1
  

Proof state:
case h.e'_2
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
Y_rw :
  (Y - C (C y)) * (Y - C (C (W.negY x y))) -
      C (Y - C x) * (C (Y ^ 2 + C (x + W.a₂) * Y + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y) =
    W.polynomial * 1
⊢ Ideal.map (mk W)
      (span
        {C (Y - C x), Y - C (C y), Y - C (C (W.negY x y)),
          C (Y ^ 2 + C (x + W.a₂) * Y + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y}) =
    Ideal.map (mk W) ⊤

Next tactic:
apply congr_arg
lemma XYIdeal_neg_mul {x y : F} (h : W.nonsingular x y) :
    XYIdeal W x (C <| W.negY x y) * XYIdeal W x (C y) = XIdeal W x := by
  have Y_rw : (Y - C (C y)) * (Y - C (C (W.negY x y))) -
      C (X - C x) * (C (X ^ 2 + C (x + W.a₂) * X + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y) =
        W.polynomial * 1 := by
    linear_combination (norm := (rw [negY, polynomial]; C_simp; ring1))
      congr_arg C (congr_arg C ((W.equation_iff _ _).mp h.left).symm)
  simp_rw [XYIdeal, XClass, YClass, span_pair_mul_span_pair, mul_comm, ← _root_.map_mul,
    AdjoinRoot.mk_eq_mk.mpr ⟨1, Y_rw⟩, _root_.map_mul, span_insert,
    ← span_singleton_mul_span_singleton, ← mul_sup, ← span_insert]
  convert mul_top (_ : Ideal W.CoordinateRing) using 2
  simp_rw [← @Set.image_singleton _ _ <| mk W, ← Set.image_insert_eq, ← map_span]
  convert map_top (R := F[X][Y]) (mk W) using 1
  apply congr_arg
  

Proof state:
case h.e'_2.h
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
Y_rw :
  (Y - C (C y)) * (Y - C (C (W.negY x y))) -
      C (Y - C x) * (C (Y ^ 2 + C (x + W.a₂) * Y + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y) =
    W.polynomial * 1
⊢ span
      {C (Y - C x), Y - C (C y), Y - C (C (W.negY x y)),
        C (Y ^ 2 + C (x + W.a₂) * Y + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y} =
    ⊤

Next tactic:
simp_rw [eq_top_iff_one, mem_span_insert', mem_span_singleton']
lemma XYIdeal_neg_mul {x y : F} (h : W.nonsingular x y) :
    XYIdeal W x (C <| W.negY x y) * XYIdeal W x (C y) = XIdeal W x := by
  have Y_rw : (Y - C (C y)) * (Y - C (C (W.negY x y))) -
      C (X - C x) * (C (X ^ 2 + C (x + W.a₂) * X + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y) =
        W.polynomial * 1 := by
    linear_combination (norm := (rw [negY, polynomial]; C_simp; ring1))
      congr_arg C (congr_arg C ((W.equation_iff _ _).mp h.left).symm)
  simp_rw [XYIdeal, XClass, YClass, span_pair_mul_span_pair, mul_comm, ← _root_.map_mul,
    AdjoinRoot.mk_eq_mk.mpr ⟨1, Y_rw⟩, _root_.map_mul, span_insert,
    ← span_singleton_mul_span_singleton, ← mul_sup, ← span_insert]
  convert mul_top (_ : Ideal W.CoordinateRing) using 2
  simp_rw [← @Set.image_singleton _ _ <| mk W, ← Set.image_insert_eq, ← map_span]
  convert map_top (R := F[X][Y]) (mk W) using 1
  apply congr_arg
  simp_rw [eq_top_iff_one, mem_span_insert', mem_span_singleton']
  

Proof state:
case h.e'_2.h
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
Y_rw :
  (Y - C (C y)) * (Y - C (C (W.negY x y))) -
      C (Y - C x) * (C (Y ^ 2 + C (x + W.a₂) * Y + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y) =
    W.polynomial * 1
⊢ ∃ a a_1 a_2 a_3,
    a_3 * (C (Y ^ 2 + C (x + W.a₂) * Y + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y) =
      1 + a * C (Y - C x) + a_1 * (Y - C (C y)) + a_2 * (Y - C (C (W.negY x y)))

Next tactic:
rcases ((W.nonsingular_iff' _ _).mp h).right with hx | hy
lemma XYIdeal_neg_mul {x y : F} (h : W.nonsingular x y) :
    XYIdeal W x (C <| W.negY x y) * XYIdeal W x (C y) = XIdeal W x := by
  have Y_rw : (Y - C (C y)) * (Y - C (C (W.negY x y))) -
      C (X - C x) * (C (X ^ 2 + C (x + W.a₂) * X + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y) =
        W.polynomial * 1 := by
    linear_combination (norm := (rw [negY, polynomial]; C_simp; ring1))
      congr_arg C (congr_arg C ((W.equation_iff _ _).mp h.left).symm)
  simp_rw [XYIdeal, XClass, YClass, span_pair_mul_span_pair, mul_comm, ← _root_.map_mul,
    AdjoinRoot.mk_eq_mk.mpr ⟨1, Y_rw⟩, _root_.map_mul, span_insert,
    ← span_singleton_mul_span_singleton, ← mul_sup, ← span_insert]
  convert mul_top (_ : Ideal W.CoordinateRing) using 2
  simp_rw [← @Set.image_singleton _ _ <| mk W, ← Set.image_insert_eq, ← map_span]
  convert map_top (R := F[X][Y]) (mk W) using 1
  apply congr_arg
  simp_rw [eq_top_iff_one, mem_span_insert', mem_span_singleton']
  rcases ((W.nonsingular_iff' _ _).mp h).right with hx | hy
  · 

Proof state:
case h.e'_2.h.inl
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
Y_rw :
  (Y - C (C y)) * (Y - C (C (W.negY x y))) -
      C (Y - C x) * (C (Y ^ 2 + C (x + W.a₂) * Y + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y) =
    W.polynomial * 1
hx : W.a₁ * y - (3 * x ^ 2 + 2 * W.a₂ * x + W.a₄) ≠ 0
⊢ ∃ a a_1 a_2 a_3,
    a_3 * (C (Y ^ 2 + C (x + W.a₂) * Y + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y) =
      1 + a * C (Y - C x) + a_1 * (Y - C (C y)) + a_2 * (Y - C (C (W.negY x y)))

Next tactic:
let W_X := W.a₁ * y - (3 * x ^ 2 + 2 * W.a₂ * x + W.a₄)
lemma XYIdeal_neg_mul {x y : F} (h : W.nonsingular x y) :
    XYIdeal W x (C <| W.negY x y) * XYIdeal W x (C y) = XIdeal W x := by
  have Y_rw : (Y - C (C y)) * (Y - C (C (W.negY x y))) -
      C (X - C x) * (C (X ^ 2 + C (x + W.a₂) * X + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y) =
        W.polynomial * 1 := by
    linear_combination (norm := (rw [negY, polynomial]; C_simp; ring1))
      congr_arg C (congr_arg C ((W.equation_iff _ _).mp h.left).symm)
  simp_rw [XYIdeal, XClass, YClass, span_pair_mul_span_pair, mul_comm, ← _root_.map_mul,
    AdjoinRoot.mk_eq_mk.mpr ⟨1, Y_rw⟩, _root_.map_mul, span_insert,
    ← span_singleton_mul_span_singleton, ← mul_sup, ← span_insert]
  convert mul_top (_ : Ideal W.CoordinateRing) using 2
  simp_rw [← @Set.image_singleton _ _ <| mk W, ← Set.image_insert_eq, ← map_span]
  convert map_top (R := F[X][Y]) (mk W) using 1
  apply congr_arg
  simp_rw [eq_top_iff_one, mem_span_insert', mem_span_singleton']
  rcases ((W.nonsingular_iff' _ _).mp h).right with hx | hy
  · let W_X := W.a₁ * y - (3 * x ^ 2 + 2 * W.a₂ * x + W.a₄)
    

Proof state:
case h.e'_2.h.inl
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
Y_rw :
  (Y - C (C y)) * (Y - C (C (W.negY x y))) -
      C (Y - C x) * (C (Y ^ 2 + C (x + W.a₂) * Y + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y) =
    W.polynomial * 1
hx : W.a₁ * y - (3 * x ^ 2 + 2 * W.a₂ * x + W.a₄) ≠ 0
W_X : F := W.a₁ * y - (3 * x ^ 2 + 2 * W.a₂ * x + W.a₄)
⊢ ∃ a a_1 a_2 a_3,
    a_3 * (C (Y ^ 2 + C (x + W.a₂) * Y + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y) =
      1 + a * C (Y - C x) + a_1 * (Y - C (C y)) + a_2 * (Y - C (C (W.negY x y)))

Next tactic:
refine
      ⟨C (C W_X⁻¹ * -(X + C (2 * x + W.a₂))), C (C <| W_X⁻¹ * W.a₁), 0, C (C <| W_X⁻¹ * -1), ?_⟩