l3lab/ntp-mathlib huggingface dataset:
/-- The function
`fun t ↦ Ring.inverse (x + t) - (∑ i in Finset.range n, (- x⁻¹ * t) ^ i) * x⁻¹`
is `O(t ^ n)` as `t → 0`. -/
theorem inverse_add_norm_diff_nth_order (x : Rˣ) (n : ℕ) :
    (fun t : R => inverse (↑x + t) - (∑ i in range n, (-↑x⁻¹ * t) ^ i) * ↑x⁻¹) =O[𝓝 (0 : R)]
      fun t => ‖t‖ ^ n := by
  refine EventuallyEq.trans_isBigO (.sub (inverse_add_nth_order x n) (.refl _ _)) ?_
  simp only [add_sub_cancel']
  

Proof state:
R : Type u_1
inst✝¹ : NormedRing R
inst✝ : CompleteSpace R
x : Rˣ
n : ℕ
⊢ (fun x_1 => (-↑x⁻¹ * x_1) ^ n * inverse (↑x + x_1)) =O[𝓝 0] fun t => ‖t‖ ^ n

Next tactic:
refine ((isBigO_refl _ _).norm_right.mul (inverse_add_norm x)).trans ?_
/-- The function
`fun t ↦ Ring.inverse (x + t) - (∑ i in Finset.range n, (- x⁻¹ * t) ^ i) * x⁻¹`
is `O(t ^ n)` as `t → 0`. -/
theorem inverse_add_norm_diff_nth_order (x : Rˣ) (n : ℕ) :
    (fun t : R => inverse (↑x + t) - (∑ i in range n, (-↑x⁻¹ * t) ^ i) * ↑x⁻¹) =O[𝓝 (0 : R)]
      fun t => ‖t‖ ^ n := by
  refine EventuallyEq.trans_isBigO (.sub (inverse_add_nth_order x n) (.refl _ _)) ?_
  simp only [add_sub_cancel']
  refine ((isBigO_refl _ _).norm_right.mul (inverse_add_norm x)).trans ?_
  

Proof state:
R : Type u_1
inst✝¹ : NormedRing R
inst✝ : CompleteSpace R
x : Rˣ
n : ℕ
⊢ (fun x_1 => ‖(-↑x⁻¹ * x_1) ^ n‖ * 1) =O[𝓝 0] fun t => ‖t‖ ^ n

Next tactic:
simp only [mul_one, isBigO_norm_left]
/-- The function
`fun t ↦ Ring.inverse (x + t) - (∑ i in Finset.range n, (- x⁻¹ * t) ^ i) * x⁻¹`
is `O(t ^ n)` as `t → 0`. -/
theorem inverse_add_norm_diff_nth_order (x : Rˣ) (n : ℕ) :
    (fun t : R => inverse (↑x + t) - (∑ i in range n, (-↑x⁻¹ * t) ^ i) * ↑x⁻¹) =O[𝓝 (0 : R)]
      fun t => ‖t‖ ^ n := by
  refine EventuallyEq.trans_isBigO (.sub (inverse_add_nth_order x n) (.refl _ _)) ?_
  simp only [add_sub_cancel']
  refine ((isBigO_refl _ _).norm_right.mul (inverse_add_norm x)).trans ?_
  simp only [mul_one, isBigO_norm_left]
  

Proof state:
R : Type u_1
inst✝¹ : NormedRing R
inst✝ : CompleteSpace R
x : Rˣ
n : ℕ
⊢ (fun x_1 => (-↑x⁻¹ * x_1) ^ n) =O[𝓝 0] fun t => ‖t‖ ^ n

Next tactic:
exact ((isBigO_refl _ _).norm_right.const_mul_left _).pow _
/-- The function `fun t ↦ Ring.inverse (x + t) - x⁻¹` is `O(t)` as `t → 0`. -/
theorem inverse_add_norm_diff_first_order (x : Rˣ) :
    (fun t : R => inverse (↑x + t) - ↑x⁻¹) =O[𝓝 0] fun t => ‖t‖ := by
  

Proof state:
R : Type u_1
inst✝¹ : NormedRing R
inst✝ : CompleteSpace R
x : Rˣ
⊢ (fun t => inverse (↑x + t) - ↑x⁻¹) =O[𝓝 0] fun t => ‖t‖

Next tactic:
simpa using inverse_add_norm_diff_nth_order x 1
/-- The function `fun t ↦ Ring.inverse (x + t) - x⁻¹ + x⁻¹ * t * x⁻¹` is `O(t ^ 2)` as `t → 0`. -/
theorem inverse_add_norm_diff_second_order (x : Rˣ) :
    (fun t : R => inverse (↑x + t) - ↑x⁻¹ + ↑x⁻¹ * t * ↑x⁻¹) =O[𝓝 0] fun t => ‖t‖ ^ 2 := by
  

Proof state:
R : Type u_1
inst✝¹ : NormedRing R
inst✝ : CompleteSpace R
x : Rˣ
⊢ (fun t => inverse (↑x + t) - ↑x⁻¹ + ↑x⁻¹ * t * ↑x⁻¹) =O[𝓝 0] fun t => ‖t‖ ^ 2

Next tactic:
convert inverse_add_norm_diff_nth_order x 2 using 2
/-- The function `fun t ↦ Ring.inverse (x + t) - x⁻¹ + x⁻¹ * t * x⁻¹` is `O(t ^ 2)` as `t → 0`. -/
theorem inverse_add_norm_diff_second_order (x : Rˣ) :
    (fun t : R => inverse (↑x + t) - ↑x⁻¹ + ↑x⁻¹ * t * ↑x⁻¹) =O[𝓝 0] fun t => ‖t‖ ^ 2 := by
  convert inverse_add_norm_diff_nth_order x 2 using 2
  

Proof state:
case h.e'_7.h
R : Type u_1
inst✝¹ : NormedRing R
inst✝ : CompleteSpace R
x : Rˣ
x✝ : R
⊢ inverse (↑x + x✝) - ↑x⁻¹ + ↑x⁻¹ * x✝ * ↑x⁻¹ = inverse (↑x + x✝) - (∑ i in range 2, (-↑x⁻¹ * x✝) ^ i) * ↑x⁻¹

Next tactic:
simp only [sum_range_succ, sum_range_zero, zero_add, pow_zero, pow_one, add_mul, one_mul,
    ← sub_sub, neg_mul, sub_neg_eq_add]
/-- The function `Ring.inverse` is continuous at each unit of `R`. -/
theorem inverse_continuousAt (x : Rˣ) : ContinuousAt inverse (x : R) := by
  

Proof state:
R : Type u_1
inst✝¹ : NormedRing R
inst✝ : CompleteSpace R
x : Rˣ
⊢ ContinuousAt inverse ↑x

Next tactic:
have h_is_o : (fun t : R => inverse (↑x + t) - ↑x⁻¹) =o[𝓝 0] (fun _ => 1 : R → ℝ) :=
    (inverse_add_norm_diff_first_order x).trans_isLittleO (isLittleO_id_const one_ne_zero).norm_left
/-- The function `Ring.inverse` is continuous at each unit of `R`. -/
theorem inverse_continuousAt (x : Rˣ) : ContinuousAt inverse (x : R) := by
  have h_is_o : (fun t : R => inverse (↑x + t) - ↑x⁻¹) =o[𝓝 0] (fun _ => 1 : R → ℝ) :=
    (inverse_add_norm_diff_first_order x).trans_isLittleO (isLittleO_id_const one_ne_zero).norm_left
  

Proof state:
R : Type u_1
inst✝¹ : NormedRing R
inst✝ : CompleteSpace R
x : Rˣ
h_is_o : (fun t => inverse (↑x + t) - ↑x⁻¹) =o[𝓝 0] fun x => 1
⊢ ContinuousAt inverse ↑x

Next tactic:
have h_lim : Tendsto (fun y : R => y - x) (𝓝 x) (𝓝 0) := by
    refine' tendsto_zero_iff_norm_tendsto_zero.mpr _
    exact tendsto_iff_norm_sub_tendsto_zero.mp tendsto_id
/-- The function `Ring.inverse` is continuous at each unit of `R`. -/
theorem inverse_continuousAt (x : Rˣ) : ContinuousAt inverse (x : R) := by
  have h_is_o : (fun t : R => inverse (↑x + t) - ↑x⁻¹) =o[𝓝 0] (fun _ => 1 : R → ℝ) :=
    (inverse_add_norm_diff_first_order x).trans_isLittleO (isLittleO_id_const one_ne_zero).norm_left
  have h_lim : Tendsto (fun y : R => y - x) (𝓝 x) (𝓝 0) := by
    

Proof state:
R : Type u_1
inst✝¹ : NormedRing R
inst✝ : CompleteSpace R
x : Rˣ
h_is_o : (fun t => inverse (↑x + t) - ↑x⁻¹) =o[𝓝 0] fun x => 1
⊢ Tendsto (fun y => y - ↑x) (𝓝 ↑x) (𝓝 0)

Next tactic:
refine' tendsto_zero_iff_norm_tendsto_zero.mpr _
/-- The function `Ring.inverse` is continuous at each unit of `R`. -/
theorem inverse_continuousAt (x : Rˣ) : ContinuousAt inverse (x : R) := by
  have h_is_o : (fun t : R => inverse (↑x + t) - ↑x⁻¹) =o[𝓝 0] (fun _ => 1 : R → ℝ) :=
    (inverse_add_norm_diff_first_order x).trans_isLittleO (isLittleO_id_const one_ne_zero).norm_left
  have h_lim : Tendsto (fun y : R => y - x) (𝓝 x) (𝓝 0) := by
    refine' tendsto_zero_iff_norm_tendsto_zero.mpr _
    

Proof state:
R : Type u_1
inst✝¹ : NormedRing R
inst✝ : CompleteSpace R
x : Rˣ
h_is_o : (fun t => inverse (↑x + t) - ↑x⁻¹) =o[𝓝 0] fun x => 1
⊢ Tendsto (fun x_1 => ‖x_1 - ↑x‖) (𝓝 ↑x) (𝓝 0)

Next tactic:
exact tendsto_iff_norm_sub_tendsto_zero.mp tendsto_id
/-- The function `Ring.inverse` is continuous at each unit of `R`. -/
theorem inverse_continuousAt (x : Rˣ) : ContinuousAt inverse (x : R) := by
  have h_is_o : (fun t : R => inverse (↑x + t) - ↑x⁻¹) =o[𝓝 0] (fun _ => 1 : R → ℝ) :=
    (inverse_add_norm_diff_first_order x).trans_isLittleO (isLittleO_id_const one_ne_zero).norm_left
  have h_lim : Tendsto (fun y : R => y - x) (𝓝 x) (𝓝 0) := by
    refine' tendsto_zero_iff_norm_tendsto_zero.mpr _
    exact tendsto_iff_norm_sub_tendsto_zero.mp tendsto_id
  

Proof state:
R : Type u_1
inst✝¹ : NormedRing R
inst✝ : CompleteSpace R
x : Rˣ
h_is_o : (fun t => inverse (↑x + t) - ↑x⁻¹) =o[𝓝 0] fun x => 1
h_lim : Tendsto (fun y => y - ↑x) (𝓝 ↑x) (𝓝 0)
⊢ ContinuousAt inverse ↑x

Next tactic:
rw [ContinuousAt, tendsto_iff_norm_sub_tendsto_zero, inverse_unit]
/-- The function `Ring.inverse` is continuous at each unit of `R`. -/
theorem inverse_continuousAt (x : Rˣ) : ContinuousAt inverse (x : R) := by
  have h_is_o : (fun t : R => inverse (↑x + t) - ↑x⁻¹) =o[𝓝 0] (fun _ => 1 : R → ℝ) :=
    (inverse_add_norm_diff_first_order x).trans_isLittleO (isLittleO_id_const one_ne_zero).norm_left
  have h_lim : Tendsto (fun y : R => y - x) (𝓝 x) (𝓝 0) := by
    refine' tendsto_zero_iff_norm_tendsto_zero.mpr _
    exact tendsto_iff_norm_sub_tendsto_zero.mp tendsto_id
  rw [ContinuousAt, tendsto_iff_norm_sub_tendsto_zero, inverse_unit]
  

Proof state:
R : Type u_1
inst✝¹ : NormedRing R
inst✝ : CompleteSpace R
x : Rˣ
h_is_o : (fun t => inverse (↑x + t) - ↑x⁻¹) =o[𝓝 0] fun x => 1
h_lim : Tendsto (fun y => y - ↑x) (𝓝 ↑x) (𝓝 0)
⊢ Tendsto (fun e => ‖inverse e - ↑x⁻¹‖) (𝓝 ↑x) (𝓝 0)

Next tactic:
simpa [(· ∘ ·)] using h_is_o.norm_left.tendsto_div_nhds_zero.comp h_lim
/-- An ideal which contains an element within `1` of `1 : R` is the unit ideal. -/
theorem eq_top_of_norm_lt_one (I : Ideal R) {x : R} (hxI : x ∈ I) (hx : ‖1 - x‖ < 1) : I = ⊤ :=
  let u := Units.oneSub (1 - x) hx
  I.eq_top_iff_one.mpr <| by 

Proof state:
R : Type u_1
inst✝¹ : NormedRing R
inst✝ : CompleteSpace R
I : Ideal R
x : R
hxI : x ∈ I
hx : ‖1 - x‖ < 1
u : Rˣ := Units.oneSub (1 - x) hx
⊢ 1 ∈ I

Next tactic:
simpa only [show u.inv * x = 1 by simp] using I.mul_mem_left u.inv hxI
/-- An ideal which contains an element within `1` of `1 : R` is the unit ideal. -/
theorem eq_top_of_norm_lt_one (I : Ideal R) {x : R} (hxI : x ∈ I) (hx : ‖1 - x‖ < 1) : I = ⊤ :=
  let u := Units.oneSub (1 - x) hx
  I.eq_top_iff_one.mpr <| by simpa only [show u.inv * x = 1 by 

Proof state:
R : Type u_1
inst✝¹ : NormedRing R
inst✝ : CompleteSpace R
I : Ideal R
x : R
hxI : x ∈ I
hx : ‖1 - x‖ < 1
u : Rˣ := Units.oneSub (1 - x) hx
⊢ u.inv * x = 1

Next tactic:
simp
/-- The `Ideal.closure` of a proper ideal in a complete normed ring is proper. -/
theorem closure_ne_top (I : Ideal R) (hI : I ≠ ⊤) : I.closure ≠ ⊤ := by
  

Proof state:
R : Type u_1
inst✝¹ : NormedRing R
inst✝ : CompleteSpace R
I : Ideal R
hI : I ≠ ⊤
⊢ Ideal.closure I ≠ ⊤

Next tactic:
have h := closure_minimal (coe_subset_nonunits hI) nonunits.isClosed
/-- The `Ideal.closure` of a proper ideal in a complete normed ring is proper. -/
theorem closure_ne_top (I : Ideal R) (hI : I ≠ ⊤) : I.closure ≠ ⊤ := by
  have h := closure_minimal (coe_subset_nonunits hI) nonunits.isClosed
  

Proof state:
R : Type u_1
inst✝¹ : NormedRing R
inst✝ : CompleteSpace R
I : Ideal R
hI : I ≠ ⊤
h : closure ↑I ⊆ nonunits R
⊢ Ideal.closure I ≠ ⊤

Next tactic:
simpa only [I.closure.eq_top_iff_one, Ne.def] using mt (@h 1) one_not_mem_nonunits
theorem v_eq_succ_vp : u.v = succ₂ u.vp := by
  

Proof state:
u : XgcdType
⊢ v u = succ₂ (vp u)

Next tactic:
ext
theorem v_eq_succ_vp : u.v = succ₂ u.vp := by
  ext <;> 

Proof state:
case a
u : XgcdType
⊢ (v u).1 = (succ₂ (vp u)).1

Next tactic:
dsimp [v, vp, w, z, a, b, succ₂]
theorem v_eq_succ_vp : u.v = succ₂ u.vp := by
  ext <;> 

Proof state:
case a
u : XgcdType
⊢ (v u).2 = (succ₂ (vp u)).2

Next tactic:
dsimp [v, vp, w, z, a, b, succ₂]
theorem v_eq_succ_vp : u.v = succ₂ u.vp := by
  ext <;> dsimp [v, vp, w, z, a, b, succ₂] <;> (

Proof state:
case a
u : XgcdType
⊢ succ u.wp * succ u.ap + u.x * succ u.bp = succ (u.wp + u.x + u.ap + u.wp * u.ap + u.x * u.bp)

Next tactic:
repeat' rw [Nat.succ_eq_add_one]; ring_nf
theorem v_eq_succ_vp : u.v = succ₂ u.vp := by
  ext <;> dsimp [v, vp, w, z, a, b, succ₂] <;> (repeat' 

Proof state:
case a
u : XgcdType
⊢ succ u.wp * succ u.ap + u.x * succ u.bp = succ (u.wp + u.x + u.ap + u.wp * u.ap + u.x * u.bp)

Next tactic:
rw [Nat.succ_eq_add_one]
theorem v_eq_succ_vp : u.v = succ₂ u.vp := by
  ext <;> dsimp [v, vp, w, z, a, b, succ₂] <;> (repeat' rw [Nat.succ_eq_add_one]; 

Proof state:
case a
u : XgcdType
⊢ (u.wp + 1) * succ u.ap + u.x * succ u.bp = succ (u.wp + u.x + u.ap + u.wp * u.ap + u.x * u.bp)

Next tactic:
ring_nf
theorem v_eq_succ_vp : u.v = succ₂ u.vp := by
  ext <;> dsimp [v, vp, w, z, a, b, succ₂] <;> (repeat' 

Proof state:
case a
u : XgcdType
⊢ u.wp * succ u.ap + succ u.ap + u.x * succ u.bp = succ (u.wp + u.wp * u.ap + u.x + u.x * u.bp + u.ap)

Next tactic:
rw [Nat.succ_eq_add_one]
theorem v_eq_succ_vp : u.v = succ₂ u.vp := by
  ext <;> dsimp [v, vp, w, z, a, b, succ₂] <;> (repeat' rw [Nat.succ_eq_add_one]; 

Proof state:
case a
u : XgcdType
⊢ u.wp * (u.ap + 1) + (u.ap + 1) + u.x * succ u.bp = succ (u.wp + u.wp * u.ap + u.x + u.x * u.bp + u.ap)

Next tactic:
ring_nf
theorem v_eq_succ_vp : u.v = succ₂ u.vp := by
  ext <;> dsimp [v, vp, w, z, a, b, succ₂] <;> (repeat' 

Proof state:
case a
u : XgcdType
⊢ 1 + u.wp + u.wp * u.ap + u.ap + u.x * succ u.bp = succ (u.wp + u.wp * u.ap + u.ap + u.x + u.x * u.bp)

Next tactic:
rw [Nat.succ_eq_add_one]
theorem v_eq_succ_vp : u.v = succ₂ u.vp := by
  ext <;> dsimp [v, vp, w, z, a, b, succ₂] <;> (repeat' rw [Nat.succ_eq_add_one]; 

Proof state:
case a
u : XgcdType
⊢ 1 + u.wp + u.wp * u.ap + u.ap + u.x * (u.bp + 1) = succ (u.wp + u.wp * u.ap + u.ap + u.x + u.x * u.bp)

Next tactic:
ring_nf
theorem v_eq_succ_vp : u.v = succ₂ u.vp := by
  ext <;> dsimp [v, vp, w, z, a, b, succ₂] <;> (repeat' 

Proof state:
case a
u : XgcdType
⊢ 1 + u.wp + u.wp * u.ap + u.ap + u.x + u.x * u.bp = succ (u.wp + u.wp * u.ap + u.ap + u.x + u.x * u.bp)

Next tactic:
rw [Nat.succ_eq_add_one]
theorem v_eq_succ_vp : u.v = succ₂ u.vp := by
  ext <;> dsimp [v, vp, w, z, a, b, succ₂] <;> (repeat' rw [Nat.succ_eq_add_one]; 

Proof state:
case a
u : XgcdType
⊢ 1 + u.wp + u.wp * u.ap + u.ap + u.x + u.x * u.bp = u.wp + u.wp * u.ap + u.ap + u.x + u.x * u.bp + 1

Next tactic:
ring_nf
theorem v_eq_succ_vp : u.v = succ₂ u.vp := by
  ext <;> dsimp [v, vp, w, z, a, b, succ₂] <;> (

Proof state:
case a
u : XgcdType
⊢ u.y * succ u.ap + succ u.zp * succ u.bp = succ (u.y + u.zp + u.bp + u.y * u.ap + u.zp * u.bp)

Next tactic:
repeat' rw [Nat.succ_eq_add_one]; ring_nf
theorem v_eq_succ_vp : u.v = succ₂ u.vp := by
  ext <;> dsimp [v, vp, w, z, a, b, succ₂] <;> (repeat' 

Proof state:
case a
u : XgcdType
⊢ u.y * succ u.ap + succ u.zp * succ u.bp = succ (u.y + u.zp + u.bp + u.y * u.ap + u.zp * u.bp)

Next tactic:
rw [Nat.succ_eq_add_one]
theorem v_eq_succ_vp : u.v = succ₂ u.vp := by
  ext <;> dsimp [v, vp, w, z, a, b, succ₂] <;> (repeat' rw [Nat.succ_eq_add_one]; 

Proof state:
case a
u : XgcdType
⊢ u.y * (u.ap + 1) + succ u.zp * succ u.bp = succ (u.y + u.zp + u.bp + u.y * u.ap + u.zp * u.bp)

Next tactic:
ring_nf
theorem v_eq_succ_vp : u.v = succ₂ u.vp := by
  ext <;> dsimp [v, vp, w, z, a, b, succ₂] <;> (repeat' 

Proof state:
case a
u : XgcdType
⊢ u.y + u.y * u.ap + succ u.zp * succ u.bp = succ (u.y + u.y * u.ap + u.zp + u.zp * u.bp + u.bp)

Next tactic:
rw [Nat.succ_eq_add_one]
theorem v_eq_succ_vp : u.v = succ₂ u.vp := by
  ext <;> dsimp [v, vp, w, z, a, b, succ₂] <;> (repeat' rw [Nat.succ_eq_add_one]; 

Proof state:
case a
u : XgcdType
⊢ u.y + u.y * u.ap + (u.zp + 1) * succ u.bp = succ (u.y + u.y * u.ap + u.zp + u.zp * u.bp + u.bp)

Next tactic:
ring_nf
theorem v_eq_succ_vp : u.v = succ₂ u.vp := by
  ext <;> dsimp [v, vp, w, z, a, b, succ₂] <;> (repeat' 

Proof state:
case a
u : XgcdType
⊢ u.y + u.y * u.ap + u.zp * succ u.bp + succ u.bp = succ (u.y + u.y * u.ap + u.zp + u.zp * u.bp + u.bp)

Next tactic:
rw [Nat.succ_eq_add_one]
theorem v_eq_succ_vp : u.v = succ₂ u.vp := by
  ext <;> dsimp [v, vp, w, z, a, b, succ₂] <;> (repeat' rw [Nat.succ_eq_add_one]; 

Proof state:
case a
u : XgcdType
⊢ u.y + u.y * u.ap + u.zp * (u.bp + 1) + (u.bp + 1) = succ (u.y + u.y * u.ap + u.zp + u.zp * u.bp + u.bp)

Next tactic:
ring_nf
theorem v_eq_succ_vp : u.v = succ₂ u.vp := by
  ext <;> dsimp [v, vp, w, z, a, b, succ₂] <;> (repeat' 

Proof state:
case a
u : XgcdType
⊢ 1 + u.y + u.y * u.ap + u.zp + u.zp * u.bp + u.bp = succ (u.y + u.y * u.ap + u.zp + u.zp * u.bp + u.bp)

Next tactic:
rw [Nat.succ_eq_add_one]
theorem v_eq_succ_vp : u.v = succ₂ u.vp := by
  ext <;> dsimp [v, vp, w, z, a, b, succ₂] <;> (repeat' rw [Nat.succ_eq_add_one]; 

Proof state:
case a
u : XgcdType
⊢ 1 + u.y + u.y * u.ap + u.zp + u.zp * u.bp + u.bp = u.y + u.y * u.ap + u.zp + u.zp * u.bp + u.bp + 1

Next tactic:
ring_nf
theorem isSpecial_iff : u.IsSpecial ↔ u.IsSpecial' := by
  

Proof state:
u : XgcdType
⊢ IsSpecial u ↔ IsSpecial' u

Next tactic:
dsimp [IsSpecial, IsSpecial']
theorem isSpecial_iff : u.IsSpecial ↔ u.IsSpecial' := by
  dsimp [IsSpecial, IsSpecial']
  

Proof state:
u : XgcdType
⊢ u.wp + u.zp + u.wp * u.zp = u.x * u.y ↔ w u * z u = succPNat (u.x * u.y)

Next tactic:
let ⟨wp, x, y, zp, ap, bp⟩ := u
theorem isSpecial_iff : u.IsSpecial ↔ u.IsSpecial' := by
  dsimp [IsSpecial, IsSpecial']
  let ⟨wp, x, y, zp, ap, bp⟩ := u
  

Proof state:
u : XgcdType
wp x y zp ap bp : ℕ
⊢ { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.wp +
          { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.zp +
        { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.wp *
          { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.zp =
      { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.x *
        { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.y ↔
    w { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp } *
        z { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp } =
      succPNat
        ({ wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.x *
          { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.y)

Next tactic:
constructor
theorem isSpecial_iff : u.IsSpecial ↔ u.IsSpecial' := by
  dsimp [IsSpecial, IsSpecial']
  let ⟨wp, x, y, zp, ap, bp⟩ := u
  constructor <;> 

Proof state:
case mp
u : XgcdType
wp x y zp ap bp : ℕ
⊢ { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.wp +
          { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.zp +
        { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.wp *
          { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.zp =
      { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.x *
        { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.y →
    w { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp } *
        z { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp } =
      succPNat
        ({ wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.x *
          { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.y)

Next tactic:
intro h
theorem isSpecial_iff : u.IsSpecial ↔ u.IsSpecial' := by
  dsimp [IsSpecial, IsSpecial']
  let ⟨wp, x, y, zp, ap, bp⟩ := u
  constructor <;> 

Proof state:
case mpr
u : XgcdType
wp x y zp ap bp : ℕ
⊢ w { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp } *
        z { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp } =
      succPNat
        ({ wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.x *
          { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.y) →
    { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.wp +
          { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.zp +
        { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.wp *
          { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.zp =
      { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.x *
        { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.y

Next tactic:
intro h
theorem isSpecial_iff : u.IsSpecial ↔ u.IsSpecial' := by
  dsimp [IsSpecial, IsSpecial']
  let ⟨wp, x, y, zp, ap, bp⟩ := u
  constructor <;> intro h <;> 

Proof state:
case mp
u : XgcdType
wp x y zp ap bp : ℕ
h :
  { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.wp +
        { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.zp +
      { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.wp *
        { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.zp =
    { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.x *
      { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.y
⊢ w { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp } *
      z { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp } =
    succPNat
      ({ wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.x *
        { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.y)

Next tactic:
simp [w, z, succPNat] at *
theorem isSpecial_iff : u.IsSpecial ↔ u.IsSpecial' := by
  dsimp [IsSpecial, IsSpecial']
  let ⟨wp, x, y, zp, ap, bp⟩ := u
  constructor <;> intro h <;> 

Proof state:
case mpr
u : XgcdType
wp x y zp ap bp : ℕ
h :
  w { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp } *
      z { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp } =
    succPNat
      ({ wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.x *
        { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.y)
⊢ { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.wp +
        { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.zp +
      { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.wp *
        { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.zp =
    { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.x *
      { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.y

Next tactic:
simp [w, z, succPNat] at *
theorem isSpecial_iff : u.IsSpecial ↔ u.IsSpecial' := by
  dsimp [IsSpecial, IsSpecial']
  let ⟨wp, x, y, zp, ap, bp⟩ := u
  constructor <;> intro h <;> simp [w, z, succPNat] at * <;>
    

Proof state:
case mp
u : XgcdType
wp x y zp ap bp : ℕ
h : wp + zp + wp * zp = x * y
⊢ { val := succ wp, property := (_ : 0 < succ { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.wp) } *
      { val := succ zp, property := (_ : 0 < succ { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.zp) } =
    { val := succ (x * y),
      property :=
        (_ :
          0 <
            succ
              ({ wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.x *
                { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.y)) }

Next tactic:
simp only [← coe_inj, mul_coe, mk_coe] at *
theorem isSpecial_iff : u.IsSpecial ↔ u.IsSpecial' := by
  dsimp [IsSpecial, IsSpecial']
  let ⟨wp, x, y, zp, ap, bp⟩ := u
  constructor <;> intro h <;> simp [w, z, succPNat] at * <;>
    

Proof state:
case mpr
u : XgcdType
wp x y zp ap bp : ℕ
h :
  { val := succ wp, property := (_ : 0 < succ { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.wp) } *
      { val := succ zp, property := (_ : 0 < succ { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.zp) } =
    { val := succ (x * y),
      property :=
        (_ :
          0 <
            succ
              ({ wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.x *
                { wp := wp, x := x, y := y, zp := zp, ap := ap, bp := bp }.y)) }
⊢ wp + zp + wp * zp = x * y

Next tactic:
simp only [← coe_inj, mul_coe, mk_coe] at *
theorem isSpecial_iff : u.IsSpecial ↔ u.IsSpecial' := by
  dsimp [IsSpecial, IsSpecial']
  let ⟨wp, x, y, zp, ap, bp⟩ := u
  constructor <;> intro h <;> simp [w, z, succPNat] at * <;>
    simp only [← coe_inj, mul_coe, mk_coe] at *
  · 

Proof state:
case mp
u : XgcdType
wp x y zp ap bp : ℕ
h : wp + zp + wp * zp = x * y
⊢ succ wp * succ zp = succ (x * y)

Next tactic:
simp_all [← h, Nat.mul, Nat.succ_eq_add_one]
theorem isSpecial_iff : u.IsSpecial ↔ u.IsSpecial' := by
  dsimp [IsSpecial, IsSpecial']
  let ⟨wp, x, y, zp, ap, bp⟩ := u
  constructor <;> intro h <;> simp [w, z, succPNat] at * <;>
    simp only [← coe_inj, mul_coe, mk_coe] at *
  · simp_all [← h, Nat.mul, Nat.succ_eq_add_one]; 

Proof state:
case mp
u : XgcdType
wp x y zp ap bp : ℕ
⊢ (wp + 1) * (zp + 1) = wp + zp + wp * zp + 1

Next tactic:
ring
theorem isSpecial_iff : u.IsSpecial ↔ u.IsSpecial' := by
  dsimp [IsSpecial, IsSpecial']
  let ⟨wp, x, y, zp, ap, bp⟩ := u
  constructor <;> intro h <;> simp [w, z, succPNat] at * <;>
    simp only [← coe_inj, mul_coe, mk_coe] at *
  · simp_all [← h, Nat.mul, Nat.succ_eq_add_one]; ring
  · 

Proof state:
case mpr
u : XgcdType
wp x y zp ap bp : ℕ
h : succ wp * succ zp = succ (x * y)
⊢ wp + zp + wp * zp = x * y

Next tactic:
simp [Nat.succ_eq_add_one, Nat.mul_add, Nat.add_mul, ← Nat.add_assoc] at h
theorem isSpecial_iff : u.IsSpecial ↔ u.IsSpecial' := by
  dsimp [IsSpecial, IsSpecial']
  let ⟨wp, x, y, zp, ap, bp⟩ := u
  constructor <;> intro h <;> simp [w, z, succPNat] at * <;>
    simp only [← coe_inj, mul_coe, mk_coe] at *
  · simp_all [← h, Nat.mul, Nat.succ_eq_add_one]; ring
  · simp [Nat.succ_eq_add_one, Nat.mul_add, Nat.add_mul, ← Nat.add_assoc] at h; 

Proof state:
case mpr
u : XgcdType
wp x y zp ap bp : ℕ
h : wp * zp + zp + wp = x * y
⊢ wp + zp + wp * zp = x * y

Next tactic:
rw [← h]
theorem isSpecial_iff : u.IsSpecial ↔ u.IsSpecial' := by
  dsimp [IsSpecial, IsSpecial']
  let ⟨wp, x, y, zp, ap, bp⟩ := u
  constructor <;> intro h <;> simp [w, z, succPNat] at * <;>
    simp only [← coe_inj, mul_coe, mk_coe] at *
  · simp_all [← h, Nat.mul, Nat.succ_eq_add_one]; ring
  · simp [Nat.succ_eq_add_one, Nat.mul_add, Nat.add_mul, ← Nat.add_assoc] at h; rw [← h]; 

Proof state:
case mpr
u : XgcdType
wp x y zp ap bp : ℕ
h : wp * zp + zp + wp = x * y
⊢ wp + zp + wp * zp = wp * zp + zp + wp

Next tactic:
ring
theorem flip_isReduced : (flip u).IsReduced ↔ u.IsReduced := by
  

Proof state:
u : XgcdType
⊢ IsReduced (flip u) ↔ IsReduced u

Next tactic:
dsimp [IsReduced, flip]