l3lab/ntp-mathlib huggingface dataset:
lemma baseChange_injective (h : Function.Injective <| algebraMap R A) :
    Function.Injective <| baseChange (R := R) (A := A) := fun E E' h1 => by
  rcases mk.inj h1 with ⟨h1, h2⟩
  replace h2 := (Units.mk.inj h2).left
  rcases WeierstrassCurve.mk.inj h1 with ⟨_, _, _, _, _⟩
  ext <;> apply_fun _ using h <;> 

Proof state:
case intro.intro.intro.intro.intro.a₄
R : Type u
inst✝² : CommRing R
E✝ : EllipticCurve R
A : Type v
inst✝¹ : CommRing A
inst✝ : Algebra R A
h : Function.Injective ⇑(algebraMap R A)
E E' : EllipticCurve R
h1✝ : (fun E => E.baseChange A) E = (fun E => E.baseChange A) E'
h1 : E.baseChange A = E'.baseChange A
h2 : ↑(algebraMap R A) ↑E.Δ' = ↑(algebraMap R A) ↑E'.Δ'
left✝³ : (algebraMap R A) E.a₁ = (algebraMap R A) E'.a₁
left✝² : (algebraMap R A) E.a₂ = (algebraMap R A) E'.a₂
left✝¹ : (algebraMap R A) E.a₃ = (algebraMap R A) E'.a₃
left✝ : (algebraMap R A) E.a₄ = (algebraMap R A) E'.a₄
right✝ : (algebraMap R A) E.a₆ = (algebraMap R A) E'.a₆
⊢ (algebraMap R A) E.a₄ = (algebraMap R A) E'.a₄

Next tactic:
assumption
lemma baseChange_injective (h : Function.Injective <| algebraMap R A) :
    Function.Injective <| baseChange (R := R) (A := A) := fun E E' h1 => by
  rcases mk.inj h1 with ⟨h1, h2⟩
  replace h2 := (Units.mk.inj h2).left
  rcases WeierstrassCurve.mk.inj h1 with ⟨_, _, _, _, _⟩
  ext <;> apply_fun _ using h <;> 

Proof state:
case intro.intro.intro.intro.intro.a₆
R : Type u
inst✝² : CommRing R
E✝ : EllipticCurve R
A : Type v
inst✝¹ : CommRing A
inst✝ : Algebra R A
h : Function.Injective ⇑(algebraMap R A)
E E' : EllipticCurve R
h1✝ : (fun E => E.baseChange A) E = (fun E => E.baseChange A) E'
h1 : E.baseChange A = E'.baseChange A
h2 : ↑(algebraMap R A) ↑E.Δ' = ↑(algebraMap R A) ↑E'.Δ'
left✝³ : (algebraMap R A) E.a₁ = (algebraMap R A) E'.a₁
left✝² : (algebraMap R A) E.a₂ = (algebraMap R A) E'.a₂
left✝¹ : (algebraMap R A) E.a₃ = (algebraMap R A) E'.a₃
left✝ : (algebraMap R A) E.a₄ = (algebraMap R A) E'.a₄
right✝ : (algebraMap R A) E.a₆ = (algebraMap R A) E'.a₆
⊢ (algebraMap R A) E.a₆ = (algebraMap R A) E'.a₆

Next tactic:
assumption
lemma baseChange_injective (h : Function.Injective <| algebraMap R A) :
    Function.Injective <| baseChange (R := R) (A := A) := fun E E' h1 => by
  rcases mk.inj h1 with ⟨h1, h2⟩
  replace h2 := (Units.mk.inj h2).left
  rcases WeierstrassCurve.mk.inj h1 with ⟨_, _, _, _, _⟩
  ext <;> apply_fun _ using h <;> 

Proof state:
case intro.intro.intro.intro.intro.Δ'.a
R : Type u
inst✝² : CommRing R
E✝ : EllipticCurve R
A : Type v
inst✝¹ : CommRing A
inst✝ : Algebra R A
h : Function.Injective ⇑(algebraMap R A)
E E' : EllipticCurve R
h1✝ : (fun E => E.baseChange A) E = (fun E => E.baseChange A) E'
h1 : E.baseChange A = E'.baseChange A
h2 : ↑(algebraMap R A) ↑E.Δ' = ↑(algebraMap R A) ↑E'.Δ'
left✝³ : (algebraMap R A) E.a₁ = (algebraMap R A) E'.a₁
left✝² : (algebraMap R A) E.a₂ = (algebraMap R A) E'.a₂
left✝¹ : (algebraMap R A) E.a₃ = (algebraMap R A) E'.a₃
left✝ : (algebraMap R A) E.a₄ = (algebraMap R A) E'.a₄
right✝ : (algebraMap R A) E.a₆ = (algebraMap R A) E'.a₆
⊢ (algebraMap R A) ↑E.Δ' = (algebraMap R A) ↑E'.Δ'

Next tactic:
assumption
/-- When 3 is invertible, $Y^2 + Y = X^3$ is an elliptic curve.
It is of j-invariant 0 (see `EllipticCurve.ofJ0_j`). -/
def ofJ0 [Invertible (3 : R)] : EllipticCurve R :=
  have := invertibleNeg (3 ^ 3 : R)
  ⟨WeierstrassCurve.ofJ0 R, unitOfInvertible (-3 ^ 3 : R),
    by 

Proof state:
R : Type u
inst✝¹ : CommRing R
E : EllipticCurve R
inst✝ : Invertible 3
this : Invertible (-3 ^ 3)
⊢ ↑(unitOfInvertible (-3 ^ 3)) = (WeierstrassCurve.ofJ0 R).Δ

Next tactic:
rw [val_unitOfInvertible, WeierstrassCurve.ofJ0_Δ R]
/-- When 3 is invertible, $Y^2 + Y = X^3$ is an elliptic curve.
It is of j-invariant 0 (see `EllipticCurve.ofJ0_j`). -/
def ofJ0 [Invertible (3 : R)] : EllipticCurve R :=
  have := invertibleNeg (3 ^ 3 : R)
  ⟨WeierstrassCurve.ofJ0 R, unitOfInvertible (-3 ^ 3 : R),
    by rw [val_unitOfInvertible, WeierstrassCurve.ofJ0_Δ R]; 

Proof state:
R : Type u
inst✝¹ : CommRing R
E : EllipticCurve R
inst✝ : Invertible 3
this : Invertible (-3 ^ 3)
⊢ -3 ^ 3 = -27

Next tactic:
norm_num1
lemma ofJ0_j [Invertible (3 : R)] : (ofJ0 R).j = 0 := by
  

Proof state:
R : Type u
inst✝¹ : CommRing R
E : EllipticCurve R
inst✝ : Invertible 3
⊢ (ofJ0 R).j = 0

Next tactic:
simp only [j, ofJ0, WeierstrassCurve.ofJ0_c₄]
lemma ofJ0_j [Invertible (3 : R)] : (ofJ0 R).j = 0 := by
  simp only [j, ofJ0, WeierstrassCurve.ofJ0_c₄]
  

Proof state:
R : Type u
inst✝¹ : CommRing R
E : EllipticCurve R
inst✝ : Invertible 3
⊢ ↑(unitOfInvertible (-3 ^ 3))⁻¹ * 0 ^ 3 = 0

Next tactic:
ring1
/-- When 2 is invertible, $Y^2 = X^3 + X$ is an elliptic curve.
It is of j-invariant 1728 (see `EllipticCurve.ofJ1728_j`). -/
def ofJ1728 [Invertible (2 : R)] : EllipticCurve R :=
  have := invertibleNeg (2 ^ 6 : R)
  ⟨WeierstrassCurve.ofJ1728 R, unitOfInvertible (-2 ^ 6 : R),
    by 

Proof state:
R : Type u
inst✝¹ : CommRing R
E : EllipticCurve R
inst✝ : Invertible 2
this : Invertible (-2 ^ 6)
⊢ ↑(unitOfInvertible (-2 ^ 6)) = (WeierstrassCurve.ofJ1728 R).Δ

Next tactic:
rw [val_unitOfInvertible, WeierstrassCurve.ofJ1728_Δ R]
/-- When 2 is invertible, $Y^2 = X^3 + X$ is an elliptic curve.
It is of j-invariant 1728 (see `EllipticCurve.ofJ1728_j`). -/
def ofJ1728 [Invertible (2 : R)] : EllipticCurve R :=
  have := invertibleNeg (2 ^ 6 : R)
  ⟨WeierstrassCurve.ofJ1728 R, unitOfInvertible (-2 ^ 6 : R),
    by rw [val_unitOfInvertible, WeierstrassCurve.ofJ1728_Δ R]; 

Proof state:
R : Type u
inst✝¹ : CommRing R
E : EllipticCurve R
inst✝ : Invertible 2
this : Invertible (-2 ^ 6)
⊢ -2 ^ 6 = -64

Next tactic:
norm_num1
lemma ofJ1728_j [Invertible (2 : R)] : (ofJ1728 R).j = 1728 := by
  

Proof state:
R : Type u
inst✝¹ : CommRing R
E : EllipticCurve R
inst✝ : Invertible 2
⊢ (ofJ1728 R).j = 1728

Next tactic:
field_simp [j, ofJ1728, @val_unitOfInvertible _ _ _ <| invertibleNeg _,
    WeierstrassCurve.ofJ1728_c₄]
lemma ofJ1728_j [Invertible (2 : R)] : (ofJ1728 R).j = 1728 := by
  field_simp [j, ofJ1728, @val_unitOfInvertible _ _ _ <| invertibleNeg _,
    WeierstrassCurve.ofJ1728_c₄]
  

Proof state:
R : Type u
inst✝¹ : CommRing R
E : EllipticCurve R
inst✝ : Invertible 2
⊢ -(1728 * 2 ^ 6) = (-48) ^ 3

Next tactic:
norm_num1
lemma ofJ'_j (j : R) [Invertible j] [Invertible (j - 1728)] : (ofJ' j).j = j := by
  

Proof state:
R : Type u
inst✝² : CommRing R
E : EllipticCurve R
j : R
inst✝¹ : Invertible j
inst✝ : Invertible (j - 1728)
⊢ (ofJ' j).j = j

Next tactic:
field_simp [EllipticCurve.j, ofJ', @val_unitOfInvertible _ _ _ <| invertibleMul ..,
    WeierstrassCurve.ofJ_c₄]
lemma ofJ'_j (j : R) [Invertible j] [Invertible (j - 1728)] : (ofJ' j).j = j := by
  field_simp [EllipticCurve.j, ofJ', @val_unitOfInvertible _ _ _ <| invertibleMul ..,
    WeierstrassCurve.ofJ_c₄]
  

Proof state:
R : Type u
inst✝² : CommRing R
E : EllipticCurve R
j : R
inst✝¹ : Invertible j
inst✝ : Invertible (j - 1728)
⊢ j * (j ^ 2 * (j - 1728) ^ 9) = (j * (j - 1728) ^ 3) ^ 3

Next tactic:
ring1
private lemma two_or_three_ne_zero : (2 : F) ≠ 0 ∨ (3 : F) ≠ 0 :=
  ne_zero_or_ne_zero_of_nat_coprime <| by 

Proof state:
R : Type u
inst✝¹ : CommRing R
E : EllipticCurve R
F : Type u
inst✝ : Field F
j : F
⊢ Nat.Coprime 2 3

Next tactic:
decide
/-- For any element j of a field $F$, there exists an elliptic curve over $F$
with j-invariant equal to j (see `EllipticCurve.ofJ_j`).
Its coefficients are given explicitly (see `EllipticCurve.ofJ0`, `EllipticCurve.ofJ1728`
and `EllipticCurve.ofJ'`). -/
def ofJ : EllipticCurve F :=
  if h0 : j = 0 then
    if h3 : (3 : F) = 0 then @ofJ1728 _ _ <| invertibleOfNonzero <|
      two_or_three_ne_zero.neg_resolve_right h3
    else @ofJ0 _ _ <| invertibleOfNonzero h3
  else if h1728 : j = 1728 then
    @ofJ1728 _ _ <| invertibleOfNonzero fun h => h0 <|
    by 

Proof state:
R : Type u
inst✝² : CommRing R
E : EllipticCurve R
F : Type u
inst✝¹ : Field F
j : F
inst✝ : DecidableEq F
h0 : ¬j = 0
h1728 : j = 1728
h : 2 = 0
⊢ j = 0

Next tactic:
rw [h1728, show (1728 : F) = 2 * 864 by norm_num1, h, zero_mul]
/-- For any element j of a field $F$, there exists an elliptic curve over $F$
with j-invariant equal to j (see `EllipticCurve.ofJ_j`).
Its coefficients are given explicitly (see `EllipticCurve.ofJ0`, `EllipticCurve.ofJ1728`
and `EllipticCurve.ofJ'`). -/
def ofJ : EllipticCurve F :=
  if h0 : j = 0 then
    if h3 : (3 : F) = 0 then @ofJ1728 _ _ <| invertibleOfNonzero <|
      two_or_three_ne_zero.neg_resolve_right h3
    else @ofJ0 _ _ <| invertibleOfNonzero h3
  else if h1728 : j = 1728 then
    @ofJ1728 _ _ <| invertibleOfNonzero fun h => h0 <|
    by rw [h1728, show (1728 : F) = 2 * 864 by 

Proof state:
R : Type u
inst✝² : CommRing R
E : EllipticCurve R
F : Type u
inst✝¹ : Field F
j : F
inst✝ : DecidableEq F
h0 : ¬j = 0
h1728 : j = 1728
h : 2 = 0
⊢ 1728 = 2 * 864

Next tactic:
norm_num1
lemma ofJ_0_of_three_ne_zero [h3 : NeZero (3 : F)] :
    ofJ 0 = @ofJ0 _ _ (invertibleOfNonzero h3.out) := by
  

Proof state:
R : Type u
inst✝² : CommRing R
E : EllipticCurve R
F : Type u
inst✝¹ : Field F
j : F
inst✝ : DecidableEq F
h3 : NeZero 3
⊢ ofJ 0 = ofJ0 F

Next tactic:
rw [ofJ, dif_pos rfl, dif_neg h3.out]
lemma ofJ_0_of_three_eq_zero (h3 : (3 : F) = 0) :
    ofJ 0 = @ofJ1728 _ _ (invertibleOfNonzero <| two_or_three_ne_zero.neg_resolve_right h3) := by
  

Proof state:
R : Type u
inst✝² : CommRing R
E : EllipticCurve R
F : Type u
inst✝¹ : Field F
j : F
inst✝ : DecidableEq F
h3 : 3 = 0
⊢ ofJ 0 = ofJ1728 F

Next tactic:
rw [ofJ, dif_pos rfl, dif_pos h3]
lemma ofJ_1728_of_three_eq_zero (h3 : (3 : F) = 0) :
    ofJ 1728 = @ofJ1728 _ _ (invertibleOfNonzero <| two_or_three_ne_zero.neg_resolve_right h3) := by
  

Proof state:
R : Type u
inst✝² : CommRing R
E : EllipticCurve R
F : Type u
inst✝¹ : Field F
j : F
inst✝ : DecidableEq F
h3 : 3 = 0
⊢ ofJ 1728 = ofJ1728 F

Next tactic:
rw [ofJ, dif_pos <| by rw [show (1728 : F) = 3 * 576 by norm_num1, h3, zero_mul], dif_pos h3]
lemma ofJ_1728_of_three_eq_zero (h3 : (3 : F) = 0) :
    ofJ 1728 = @ofJ1728 _ _ (invertibleOfNonzero <| two_or_three_ne_zero.neg_resolve_right h3) := by
  rw [ofJ, dif_pos <| by 

Proof state:
R : Type u
inst✝² : CommRing R
E : EllipticCurve R
F : Type u
inst✝¹ : Field F
j : F
inst✝ : DecidableEq F
h3 : 3 = 0
⊢ 1728 = 0

Next tactic:
rw [show (1728 : F) = 3 * 576 by norm_num1, h3, zero_mul]
lemma ofJ_1728_of_three_eq_zero (h3 : (3 : F) = 0) :
    ofJ 1728 = @ofJ1728 _ _ (invertibleOfNonzero <| two_or_three_ne_zero.neg_resolve_right h3) := by
  rw [ofJ, dif_pos <| by rw [show (1728 : F) = 3 * 576 by 

Proof state:
R : Type u
inst✝² : CommRing R
E : EllipticCurve R
F : Type u
inst✝¹ : Field F
j : F
inst✝ : DecidableEq F
h3 : 3 = 0
⊢ 1728 = 3 * 576

Next tactic:
norm_num1
lemma ofJ_1728_of_two_ne_zero [h2 : NeZero (2 : F)] :
    ofJ 1728 = @ofJ1728 _ _ (invertibleOfNonzero h2.out) := by
  

Proof state:
R : Type u
inst✝² : CommRing R
E : EllipticCurve R
F : Type u
inst✝¹ : Field F
j : F
inst✝ : DecidableEq F
h2 : NeZero 2
⊢ ofJ 1728 = ofJ1728 F

Next tactic:
by_cases h3 : (3 : F) = 0
lemma ofJ_1728_of_two_ne_zero [h2 : NeZero (2 : F)] :
    ofJ 1728 = @ofJ1728 _ _ (invertibleOfNonzero h2.out) := by
  by_cases h3 : (3 : F) = 0
  · 

Proof state:
case pos
R : Type u
inst✝² : CommRing R
E : EllipticCurve R
F : Type u
inst✝¹ : Field F
j : F
inst✝ : DecidableEq F
h2 : NeZero 2
h3 : 3 = 0
⊢ ofJ 1728 = ofJ1728 F

Next tactic:
exact ofJ_1728_of_three_eq_zero h3
lemma ofJ_1728_of_two_ne_zero [h2 : NeZero (2 : F)] :
    ofJ 1728 = @ofJ1728 _ _ (invertibleOfNonzero h2.out) := by
  by_cases h3 : (3 : F) = 0
  · exact ofJ_1728_of_three_eq_zero h3
  · 

Proof state:
case neg
R : Type u
inst✝² : CommRing R
E : EllipticCurve R
F : Type u
inst✝¹ : Field F
j : F
inst✝ : DecidableEq F
h2 : NeZero 2
h3 : ¬3 = 0
⊢ ofJ 1728 = ofJ1728 F

Next tactic:
have h : (1728 : F) ≠ 0 := fun h => or_iff_not_and_not.mp
      (mul_eq_zero.mp <| by rwa [show 2 ^ 6 * 3 ^ 3 = (1728 : F) by norm_num1])
      ⟨pow_ne_zero 6 h2.out, pow_ne_zero 3 h3⟩
lemma ofJ_1728_of_two_ne_zero [h2 : NeZero (2 : F)] :
    ofJ 1728 = @ofJ1728 _ _ (invertibleOfNonzero h2.out) := by
  by_cases h3 : (3 : F) = 0
  · exact ofJ_1728_of_three_eq_zero h3
  · have h : (1728 : F) ≠ 0 := fun h => or_iff_not_and_not.mp
      (mul_eq_zero.mp <| by 

Proof state:
R : Type u
inst✝² : CommRing R
E : EllipticCurve R
F : Type u
inst✝¹ : Field F
j : F
inst✝ : DecidableEq F
h2 : NeZero 2
h3 : ¬3 = 0
h : 1728 = 0
⊢ 2 ^ 6 * 3 ^ 3 = 0

Next tactic:
rwa [show 2 ^ 6 * 3 ^ 3 = (1728 : F) by norm_num1]
lemma ofJ_1728_of_two_ne_zero [h2 : NeZero (2 : F)] :
    ofJ 1728 = @ofJ1728 _ _ (invertibleOfNonzero h2.out) := by
  by_cases h3 : (3 : F) = 0
  · exact ofJ_1728_of_three_eq_zero h3
  · have h : (1728 : F) ≠ 0 := fun h => or_iff_not_and_not.mp
      (mul_eq_zero.mp <| by rwa [show 2 ^ 6 * 3 ^ 3 = (1728 : F) by 

Proof state:
R : Type u
inst✝² : CommRing R
E : EllipticCurve R
F : Type u
inst✝¹ : Field F
j : F
inst✝ : DecidableEq F
h2 : NeZero 2
h3 : ¬3 = 0
h : 1728 = 0
⊢ 2 ^ 6 * 3 ^ 3 = 1728

Next tactic:
norm_num1
lemma ofJ_1728_of_two_ne_zero [h2 : NeZero (2 : F)] :
    ofJ 1728 = @ofJ1728 _ _ (invertibleOfNonzero h2.out) := by
  by_cases h3 : (3 : F) = 0
  · exact ofJ_1728_of_three_eq_zero h3
  · have h : (1728 : F) ≠ 0 := fun h => or_iff_not_and_not.mp
      (mul_eq_zero.mp <| by rwa [show 2 ^ 6 * 3 ^ 3 = (1728 : F) by norm_num1])
      ⟨pow_ne_zero 6 h2.out, pow_ne_zero 3 h3⟩
    

Proof state:
case neg
R : Type u
inst✝² : CommRing R
E : EllipticCurve R
F : Type u
inst✝¹ : Field F
j : F
inst✝ : DecidableEq F
h2 : NeZero 2
h3 : ¬3 = 0
h : 1728 ≠ 0
⊢ ofJ 1728 = ofJ1728 F

Next tactic:
rw [ofJ, dif_neg h, dif_pos rfl]
lemma ofJ_1728_of_two_eq_zero (h2 : (2 : F) = 0) :
    ofJ 1728 = @ofJ0 _ _ (invertibleOfNonzero <| two_or_three_ne_zero.neg_resolve_left h2) := by
  

Proof state:
R : Type u
inst✝² : CommRing R
E : EllipticCurve R
F : Type u
inst✝¹ : Field F
j : F
inst✝ : DecidableEq F
h2 : 2 = 0
⊢ ofJ 1728 = ofJ0 F

Next tactic:
rw [ofJ, dif_pos <| by rw [show (1728 : F) = 2 * 864 by norm_num1, h2, zero_mul], dif_neg]
lemma ofJ_1728_of_two_eq_zero (h2 : (2 : F) = 0) :
    ofJ 1728 = @ofJ0 _ _ (invertibleOfNonzero <| two_or_three_ne_zero.neg_resolve_left h2) := by
  rw [ofJ, dif_pos <| by 

Proof state:
R : Type u
inst✝² : CommRing R
E : EllipticCurve R
F : Type u
inst✝¹ : Field F
j : F
inst✝ : DecidableEq F
h2 : 2 = 0
⊢ 1728 = 0

Next tactic:
rw [show (1728 : F) = 2 * 864 by norm_num1, h2, zero_mul]
lemma ofJ_1728_of_two_eq_zero (h2 : (2 : F) = 0) :
    ofJ 1728 = @ofJ0 _ _ (invertibleOfNonzero <| two_or_three_ne_zero.neg_resolve_left h2) := by
  rw [ofJ, dif_pos <| by rw [show (1728 : F) = 2 * 864 by 

Proof state:
R : Type u
inst✝² : CommRing R
E : EllipticCurve R
F : Type u
inst✝¹ : Field F
j : F
inst✝ : DecidableEq F
h2 : 2 = 0
⊢ 1728 = 2 * 864

Next tactic:
norm_num1
lemma ofJ_ne_0_ne_1728 (h0 : j ≠ 0) (h1728 : j ≠ 1728) : ofJ j =
    @ofJ' _ _ j (invertibleOfNonzero h0) (invertibleOfNonzero <| sub_ne_zero_of_ne h1728) := by
  

Proof state:
R : Type u
inst✝² : CommRing R
E : EllipticCurve R
F : Type u
inst✝¹ : Field F
j : F
inst✝ : DecidableEq F
h0 : j ≠ 0
h1728 : j ≠ 1728
⊢ ofJ j = ofJ' j

Next tactic:
rw [ofJ, dif_neg h0, dif_neg h1728]
lemma ofJ_j : (ofJ j).j = j := by
  

Proof state:
R : Type u
inst✝² : CommRing R
E : EllipticCurve R
F : Type u
inst✝¹ : Field F
j : F
inst✝ : DecidableEq F
⊢ (ofJ j).j = j

Next tactic:
by_cases h0 : j = 0
lemma ofJ_j : (ofJ j).j = j := by
  by_cases h0 : j = 0
  · 

Proof state:
case pos
R : Type u
inst✝² : CommRing R
E : EllipticCurve R
F : Type u
inst✝¹ : Field F
j : F
inst✝ : DecidableEq F
h0 : j = 0
⊢ (ofJ j).j = j

Next tactic:
by_cases h3 : (3 : F) = 0
lemma ofJ_j : (ofJ j).j = j := by
  by_cases h0 : j = 0
  · by_cases h3 : (3 : F) = 0
    · 

Proof state:
case pos
R : Type u
inst✝² : CommRing R
E : EllipticCurve R
F : Type u
inst✝¹ : Field F
j : F
inst✝ : DecidableEq F
h0 : j = 0
h3 : 3 = 0
⊢ (ofJ j).j = j

Next tactic:
rw [h0, ofJ_0_of_three_eq_zero h3,
        @ofJ1728_j _ _ <| invertibleOfNonzero <| two_or_three_ne_zero.neg_resolve_right h3,
        show (1728 : F) = 3 * 576 by norm_num1, h3, zero_mul]
lemma ofJ_j : (ofJ j).j = j := by
  by_cases h0 : j = 0
  · by_cases h3 : (3 : F) = 0
    · rw [h0, ofJ_0_of_three_eq_zero h3,
        @ofJ1728_j _ _ <| invertibleOfNonzero <| two_or_three_ne_zero.neg_resolve_right h3,
        show (1728 : F) = 3 * 576 by 

Proof state:
R : Type u
inst✝² : CommRing R
E : EllipticCurve R
F : Type u
inst✝¹ : Field F
j : F
inst✝ : DecidableEq F
h0 : j = 0
h3 : 3 = 0
⊢ 1728 = 3 * 576

Next tactic:
norm_num1
lemma ofJ_j : (ofJ j).j = j := by
  by_cases h0 : j = 0
  · by_cases h3 : (3 : F) = 0
    · rw [h0, ofJ_0_of_three_eq_zero h3,
        @ofJ1728_j _ _ <| invertibleOfNonzero <| two_or_three_ne_zero.neg_resolve_right h3,
        show (1728 : F) = 3 * 576 by norm_num1, h3, zero_mul]
    · 

Proof state:
case neg
R : Type u
inst✝² : CommRing R
E : EllipticCurve R
F : Type u
inst✝¹ : Field F
j : F
inst✝ : DecidableEq F
h0 : j = 0
h3 : ¬3 = 0
⊢ (ofJ j).j = j

Next tactic:
rw [h0, ofJ_0_of_three_ne_zero (h3 := neZero_iff.2 h3), @ofJ0_j _ _ <| invertibleOfNonzero h3]
lemma ofJ_j : (ofJ j).j = j := by
  by_cases h0 : j = 0
  · by_cases h3 : (3 : F) = 0
    · rw [h0, ofJ_0_of_three_eq_zero h3,
        @ofJ1728_j _ _ <| invertibleOfNonzero <| two_or_three_ne_zero.neg_resolve_right h3,
        show (1728 : F) = 3 * 576 by norm_num1, h3, zero_mul]
    · rw [h0, ofJ_0_of_three_ne_zero (h3 := neZero_iff.2 h3), @ofJ0_j _ _ <| invertibleOfNonzero h3]
  · 

Proof state:
case neg
R : Type u
inst✝² : CommRing R
E : EllipticCurve R
F : Type u
inst✝¹ : Field F
j : F
inst✝ : DecidableEq F
h0 : ¬j = 0
⊢ (ofJ j).j = j

Next tactic:
by_cases h1728 : j = 1728
lemma ofJ_j : (ofJ j).j = j := by
  by_cases h0 : j = 0
  · by_cases h3 : (3 : F) = 0
    · rw [h0, ofJ_0_of_three_eq_zero h3,
        @ofJ1728_j _ _ <| invertibleOfNonzero <| two_or_three_ne_zero.neg_resolve_right h3,
        show (1728 : F) = 3 * 576 by norm_num1, h3, zero_mul]
    · rw [h0, ofJ_0_of_three_ne_zero (h3 := neZero_iff.2 h3), @ofJ0_j _ _ <| invertibleOfNonzero h3]
  · by_cases h1728 : j = 1728
    · 

Proof state:
case pos
R : Type u
inst✝² : CommRing R
E : EllipticCurve R
F : Type u
inst✝¹ : Field F
j : F
inst✝ : DecidableEq F
h0 : ¬j = 0
h1728 : j = 1728
⊢ (ofJ j).j = j

Next tactic:
have h2 : (2 : F) ≠ 0 :=
        fun h => h0 <| by rw [h1728, show (1728 : F) = 2 * 864 by norm_num1, h, zero_mul]
lemma ofJ_j : (ofJ j).j = j := by
  by_cases h0 : j = 0
  · by_cases h3 : (3 : F) = 0
    · rw [h0, ofJ_0_of_three_eq_zero h3,
        @ofJ1728_j _ _ <| invertibleOfNonzero <| two_or_three_ne_zero.neg_resolve_right h3,
        show (1728 : F) = 3 * 576 by norm_num1, h3, zero_mul]
    · rw [h0, ofJ_0_of_three_ne_zero (h3 := neZero_iff.2 h3), @ofJ0_j _ _ <| invertibleOfNonzero h3]
  · by_cases h1728 : j = 1728
    · have h2 : (2 : F) ≠ 0 :=
        fun h => h0 <| by 

Proof state:
R : Type u
inst✝² : CommRing R
E : EllipticCurve R
F : Type u
inst✝¹ : Field F
j : F
inst✝ : DecidableEq F
h0 : ¬j = 0
h1728 : j = 1728
h : 2 = 0
⊢ j = 0

Next tactic:
rw [h1728, show (1728 : F) = 2 * 864 by norm_num1, h, zero_mul]
lemma ofJ_j : (ofJ j).j = j := by
  by_cases h0 : j = 0
  · by_cases h3 : (3 : F) = 0
    · rw [h0, ofJ_0_of_three_eq_zero h3,
        @ofJ1728_j _ _ <| invertibleOfNonzero <| two_or_three_ne_zero.neg_resolve_right h3,
        show (1728 : F) = 3 * 576 by norm_num1, h3, zero_mul]
    · rw [h0, ofJ_0_of_three_ne_zero (h3 := neZero_iff.2 h3), @ofJ0_j _ _ <| invertibleOfNonzero h3]
  · by_cases h1728 : j = 1728
    · have h2 : (2 : F) ≠ 0 :=
        fun h => h0 <| by rw [h1728, show (1728 : F) = 2 * 864 by 

Proof state:
R : Type u
inst✝² : CommRing R
E : EllipticCurve R
F : Type u
inst✝¹ : Field F
j : F
inst✝ : DecidableEq F
h0 : ¬j = 0
h1728 : j = 1728
h : 2 = 0
⊢ 1728 = 2 * 864

Next tactic:
norm_num1
lemma ofJ_j : (ofJ j).j = j := by
  by_cases h0 : j = 0
  · by_cases h3 : (3 : F) = 0
    · rw [h0, ofJ_0_of_three_eq_zero h3,
        @ofJ1728_j _ _ <| invertibleOfNonzero <| two_or_three_ne_zero.neg_resolve_right h3,
        show (1728 : F) = 3 * 576 by norm_num1, h3, zero_mul]
    · rw [h0, ofJ_0_of_three_ne_zero (h3 := neZero_iff.2 h3), @ofJ0_j _ _ <| invertibleOfNonzero h3]
  · by_cases h1728 : j = 1728
    · have h2 : (2 : F) ≠ 0 :=
        fun h => h0 <| by rw [h1728, show (1728 : F) = 2 * 864 by norm_num1, h, zero_mul]
      

Proof state:
case pos
R : Type u
inst✝² : CommRing R
E : EllipticCurve R
F : Type u
inst✝¹ : Field F
j : F
inst✝ : DecidableEq F
h0 : ¬j = 0
h1728 : j = 1728
h2 : 2 ≠ 0
⊢ (ofJ j).j = j

Next tactic:
rw [h1728, ofJ_1728_of_two_ne_zero (h2 := neZero_iff.2 h2),
        @ofJ1728_j _ _ <| invertibleOfNonzero h2]
lemma ofJ_j : (ofJ j).j = j := by
  by_cases h0 : j = 0
  · by_cases h3 : (3 : F) = 0
    · rw [h0, ofJ_0_of_three_eq_zero h3,
        @ofJ1728_j _ _ <| invertibleOfNonzero <| two_or_three_ne_zero.neg_resolve_right h3,
        show (1728 : F) = 3 * 576 by norm_num1, h3, zero_mul]
    · rw [h0, ofJ_0_of_three_ne_zero (h3 := neZero_iff.2 h3), @ofJ0_j _ _ <| invertibleOfNonzero h3]
  · by_cases h1728 : j = 1728
    · have h2 : (2 : F) ≠ 0 :=
        fun h => h0 <| by rw [h1728, show (1728 : F) = 2 * 864 by norm_num1, h, zero_mul]
      rw [h1728, ofJ_1728_of_two_ne_zero (h2 := neZero_iff.2 h2),
        @ofJ1728_j _ _ <| invertibleOfNonzero h2]
    · 

Proof state:
case neg
R : Type u
inst✝² : CommRing R
E : EllipticCurve R
F : Type u
inst✝¹ : Field F
j : F
inst✝ : DecidableEq F
h0 : ¬j = 0
h1728 : ¬j = 1728
⊢ (ofJ j).j = j

Next tactic:
rw [ofJ_ne_0_ne_1728 j h0 h1728,
        @ofJ'_j _ _ _ (invertibleOfNonzero h0) (invertibleOfNonzero <| sub_ne_zero_of_ne h1728)]
lemma chooseNatLt_aux {lo hi : Nat} (a : Nat) (h : Nat.succ lo ≤ a ∧ a ≤ hi) :
    lo ≤ Nat.pred a ∧ Nat.pred a < hi :=
  And.intro (Nat.le_sub_one_of_lt (Nat.lt_of_succ_le h.left)) <|
    show a.pred.succ ≤ hi by
       

Proof state:
lo hi a : ℕ
h : Nat.succ lo ≤ a ∧ a ≤ hi
⊢ Nat.succ (Nat.pred a) ≤ hi

Next tactic:
rw [Nat.succ_pred_eq_of_pos]
lemma chooseNatLt_aux {lo hi : Nat} (a : Nat) (h : Nat.succ lo ≤ a ∧ a ≤ hi) :
    lo ≤ Nat.pred a ∧ Nat.pred a < hi :=
  And.intro (Nat.le_sub_one_of_lt (Nat.lt_of_succ_le h.left)) <|
    show a.pred.succ ≤ hi by
       rw [Nat.succ_pred_eq_of_pos]
       

Proof state:
lo hi a : ℕ
h : Nat.succ lo ≤ a ∧ a ≤ hi
⊢ a ≤ hi
lo hi a : ℕ h : Nat.succ lo ≤ a ∧ a ≤ hi ⊢ 0 < a

Next tactic:
exact h.right
lemma chooseNatLt_aux {lo hi : Nat} (a : Nat) (h : Nat.succ lo ≤ a ∧ a ≤ hi) :
    lo ≤ Nat.pred a ∧ Nat.pred a < hi :=
  And.intro (Nat.le_sub_one_of_lt (Nat.lt_of_succ_le h.left)) <|
    show a.pred.succ ≤ hi by
       rw [Nat.succ_pred_eq_of_pos]
       exact h.right
       

Proof state:
lo hi a : ℕ
h : Nat.succ lo ≤ a ∧ a ≤ hi
⊢ 0 < a

Next tactic:
exact lt_of_le_of_lt (Nat.zero_le lo) h.left
theorem continuous_right_toIcoMod : ContinuousWithinAt (toIcoMod hp a) (Ici x) x := by
  

Proof state:
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : Archimedean 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
a x : 𝕜
⊢ ContinuousWithinAt (toIcoMod hp a) (Ici x) x

Next tactic:
intro s h
theorem continuous_right_toIcoMod : ContinuousWithinAt (toIcoMod hp a) (Ici x) x := by
  intro s h
  

Proof state:
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : Archimedean 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
a x : 𝕜
s : Set 𝕜
h : s ∈ 𝓝 (toIcoMod hp a x)
⊢ s ∈ Filter.map (toIcoMod hp a) (𝓝[≥] x)

Next tactic:
rw [Filter.mem_map, mem_nhdsWithin_iff_exists_mem_nhds_inter]
theorem continuous_right_toIcoMod : ContinuousWithinAt (toIcoMod hp a) (Ici x) x := by
  intro s h
  rw [Filter.mem_map, mem_nhdsWithin_iff_exists_mem_nhds_inter]
  

Proof state:
𝕜 : Type u_1
B : Type u_2
inst✝³ : LinearOrderedAddCommGroup 𝕜
inst✝² : Archimedean 𝕜
inst✝¹ : TopologicalSpace 𝕜
inst✝ : OrderTopology 𝕜
p : 𝕜
hp : 0 < p
a x : 𝕜
s : Set 𝕜
h : s ∈ 𝓝 (toIcoMod hp a x)
⊢ ∃ u ∈ 𝓝 x, u ∩ Ici x ⊆ toIcoMod hp a ⁻¹' s

Next tactic:
haveI : Nontrivial 𝕜 := ⟨⟨0, p, hp.ne⟩⟩