l3lab/ntp-mathlib huggingface dataset:
theorem embDomain_succ_smul_powers :
    (x • powers x hx).embDomain ⟨Nat.succ, Nat.succ_injective⟩ =
      powers x hx - ofFinsupp (Finsupp.single 0 1) := by
  apply SummableFamily.ext
  rintro (_ | n)
  · rw [embDomain_notin_range, sub_apply, coe_powers, pow_zero, coe_ofFinsupp,
      Finsupp.single_eq_same, sub_self]
    rw [Set.mem_range, not_exists]
    exact Nat.succ_ne_zero
  · 

Proof state:
case h.succ
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : CommRing R
inst✝ : IsDomain R
x : HahnSeries Γ R
hx : 0 < (addVal Γ R) x
n : ℕ
⊢ (embDomain (x • powers x hx) { toFun := Nat.succ, inj' := Nat.succ_injective }) (Nat.succ n) =
    (powers x hx - ofFinsupp fun₀ | 0 => 1) (Nat.succ n)

Next tactic:
refine' Eq.trans (embDomain_image _ ⟨Nat.succ, Nat.succ_injective⟩) _
theorem embDomain_succ_smul_powers :
    (x • powers x hx).embDomain ⟨Nat.succ, Nat.succ_injective⟩ =
      powers x hx - ofFinsupp (Finsupp.single 0 1) := by
  apply SummableFamily.ext
  rintro (_ | n)
  · rw [embDomain_notin_range, sub_apply, coe_powers, pow_zero, coe_ofFinsupp,
      Finsupp.single_eq_same, sub_self]
    rw [Set.mem_range, not_exists]
    exact Nat.succ_ne_zero
  · refine' Eq.trans (embDomain_image _ ⟨Nat.succ, Nat.succ_injective⟩) _
    

Proof state:
case h.succ
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : CommRing R
inst✝ : IsDomain R
x : HahnSeries Γ R
hx : 0 < (addVal Γ R) x
n : ℕ
⊢ (x • powers x hx) n = (powers x hx - ofFinsupp fun₀ | 0 => 1) (Nat.succ n)

Next tactic:
simp only [pow_succ, coe_powers, coe_sub, smul_apply, coe_ofFinsupp, Pi.sub_apply]
theorem embDomain_succ_smul_powers :
    (x • powers x hx).embDomain ⟨Nat.succ, Nat.succ_injective⟩ =
      powers x hx - ofFinsupp (Finsupp.single 0 1) := by
  apply SummableFamily.ext
  rintro (_ | n)
  · rw [embDomain_notin_range, sub_apply, coe_powers, pow_zero, coe_ofFinsupp,
      Finsupp.single_eq_same, sub_self]
    rw [Set.mem_range, not_exists]
    exact Nat.succ_ne_zero
  · refine' Eq.trans (embDomain_image _ ⟨Nat.succ, Nat.succ_injective⟩) _
    simp only [pow_succ, coe_powers, coe_sub, smul_apply, coe_ofFinsupp, Pi.sub_apply]
    

Proof state:
case h.succ
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : CommRing R
inst✝ : IsDomain R
x : HahnSeries Γ R
hx : 0 < (addVal Γ R) x
n : ℕ
⊢ x * x ^ n = x * x ^ n - (fun₀ | 0 => 1) (Nat.succ n)

Next tactic:
rw [Finsupp.single_eq_of_ne n.succ_ne_zero.symm, sub_zero]
theorem one_sub_self_mul_hsum_powers : (1 - x) * (powers x hx).hsum = 1 := by
  

Proof state:
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : CommRing R
inst✝ : IsDomain R
x : HahnSeries Γ R
hx : 0 < (addVal Γ R) x
⊢ (1 - x) * hsum (powers x hx) = 1

Next tactic:
rw [← hsum_smul, sub_smul 1 x (powers x hx), one_smul, hsum_sub, ←
    hsum_embDomain (x • powers x hx) ⟨Nat.succ, Nat.succ_injective⟩, embDomain_succ_smul_powers]
theorem one_sub_self_mul_hsum_powers : (1 - x) * (powers x hx).hsum = 1 := by
  rw [← hsum_smul, sub_smul 1 x (powers x hx), one_smul, hsum_sub, ←
    hsum_embDomain (x • powers x hx) ⟨Nat.succ, Nat.succ_injective⟩, embDomain_succ_smul_powers]
  

Proof state:
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : CommRing R
inst✝ : IsDomain R
x : HahnSeries Γ R
hx : 0 < (addVal Γ R) x
⊢ hsum (powers x hx) - hsum (powers x hx - ofFinsupp fun₀ | 0 => 1) = 1

Next tactic:
simp
theorem unit_aux (x : HahnSeries Γ R) {r : R} (hr : r * x.coeff x.order = 1) :
    0 < addVal Γ R (1 - C r * single (-x.order) 1 * x) := by
  

Proof state:
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedAddCommGroup Γ
inst✝¹ : CommRing R
inst✝ : IsDomain R
x : HahnSeries Γ R
r : R
hr : r * coeff x (order x) = 1
⊢ 0 < (addVal Γ R) (1 - C r * (single (-order x)) 1 * x)

Next tactic:
have h10 : (1 : R) ≠ 0 := one_ne_zero
theorem unit_aux (x : HahnSeries Γ R) {r : R} (hr : r * x.coeff x.order = 1) :
    0 < addVal Γ R (1 - C r * single (-x.order) 1 * x) := by
  have h10 : (1 : R) ≠ 0 := one_ne_zero
  

Proof state:
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedAddCommGroup Γ
inst✝¹ : CommRing R
inst✝ : IsDomain R
x : HahnSeries Γ R
r : R
hr : r * coeff x (order x) = 1
h10 : 1 ≠ 0
⊢ 0 < (addVal Γ R) (1 - C r * (single (-order x)) 1 * x)

Next tactic:
have x0 : x ≠ 0 := ne_zero_of_coeff_ne_zero (right_ne_zero_of_mul_eq_one hr)
theorem unit_aux (x : HahnSeries Γ R) {r : R} (hr : r * x.coeff x.order = 1) :
    0 < addVal Γ R (1 - C r * single (-x.order) 1 * x) := by
  have h10 : (1 : R) ≠ 0 := one_ne_zero
  have x0 : x ≠ 0 := ne_zero_of_coeff_ne_zero (right_ne_zero_of_mul_eq_one hr)
  

Proof state:
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedAddCommGroup Γ
inst✝¹ : CommRing R
inst✝ : IsDomain R
x : HahnSeries Γ R
r : R
hr : r * coeff x (order x) = 1
h10 : 1 ≠ 0
x0 : x ≠ 0
⊢ 0 < (addVal Γ R) (1 - C r * (single (-order x)) 1 * x)

Next tactic:
refine' lt_of_le_of_ne ((addVal Γ R).map_le_sub (ge_of_eq (addVal Γ R).map_one) _) _
theorem unit_aux (x : HahnSeries Γ R) {r : R} (hr : r * x.coeff x.order = 1) :
    0 < addVal Γ R (1 - C r * single (-x.order) 1 * x) := by
  have h10 : (1 : R) ≠ 0 := one_ne_zero
  have x0 : x ≠ 0 := ne_zero_of_coeff_ne_zero (right_ne_zero_of_mul_eq_one hr)
  refine' lt_of_le_of_ne ((addVal Γ R).map_le_sub (ge_of_eq (addVal Γ R).map_one) _) _
  · 

Proof state:
case refine'_1
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedAddCommGroup Γ
inst✝¹ : CommRing R
inst✝ : IsDomain R
x : HahnSeries Γ R
r : R
hr : r * coeff x (order x) = 1
h10 : 1 ≠ 0
x0 : x ≠ 0
⊢ 0 ≤ (addVal Γ R) (C r * (single (-order x)) 1 * x)

Next tactic:
simp only [AddValuation.map_mul]
theorem unit_aux (x : HahnSeries Γ R) {r : R} (hr : r * x.coeff x.order = 1) :
    0 < addVal Γ R (1 - C r * single (-x.order) 1 * x) := by
  have h10 : (1 : R) ≠ 0 := one_ne_zero
  have x0 : x ≠ 0 := ne_zero_of_coeff_ne_zero (right_ne_zero_of_mul_eq_one hr)
  refine' lt_of_le_of_ne ((addVal Γ R).map_le_sub (ge_of_eq (addVal Γ R).map_one) _) _
  · simp only [AddValuation.map_mul]
    

Proof state:
case refine'_1
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedAddCommGroup Γ
inst✝¹ : CommRing R
inst✝ : IsDomain R
x : HahnSeries Γ R
r : R
hr : r * coeff x (order x) = 1
h10 : 1 ≠ 0
x0 : x ≠ 0
⊢ 0 ≤ (addVal Γ R) (C r) + (addVal Γ R) ((single (-order x)) 1) + (addVal Γ R) x

Next tactic:
rw [addVal_apply_of_ne x0, addVal_apply_of_ne (single_ne_zero h10), addVal_apply_of_ne _,
      order_C, order_single h10, WithTop.coe_zero, zero_add, ← WithTop.coe_add, neg_add_self,
      WithTop.coe_zero]
theorem unit_aux (x : HahnSeries Γ R) {r : R} (hr : r * x.coeff x.order = 1) :
    0 < addVal Γ R (1 - C r * single (-x.order) 1 * x) := by
  have h10 : (1 : R) ≠ 0 := one_ne_zero
  have x0 : x ≠ 0 := ne_zero_of_coeff_ne_zero (right_ne_zero_of_mul_eq_one hr)
  refine' lt_of_le_of_ne ((addVal Γ R).map_le_sub (ge_of_eq (addVal Γ R).map_one) _) _
  · simp only [AddValuation.map_mul]
    rw [addVal_apply_of_ne x0, addVal_apply_of_ne (single_ne_zero h10), addVal_apply_of_ne _,
      order_C, order_single h10, WithTop.coe_zero, zero_add, ← WithTop.coe_add, neg_add_self,
      WithTop.coe_zero]
    · 

Proof state:
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedAddCommGroup Γ
inst✝¹ : CommRing R
inst✝ : IsDomain R
x : HahnSeries Γ R
r : R
hr : r * coeff x (order x) = 1
h10 : 1 ≠ 0
x0 : x ≠ 0
⊢ C r ≠ 0

Next tactic:
exact C_ne_zero (left_ne_zero_of_mul_eq_one hr)
theorem unit_aux (x : HahnSeries Γ R) {r : R} (hr : r * x.coeff x.order = 1) :
    0 < addVal Γ R (1 - C r * single (-x.order) 1 * x) := by
  have h10 : (1 : R) ≠ 0 := one_ne_zero
  have x0 : x ≠ 0 := ne_zero_of_coeff_ne_zero (right_ne_zero_of_mul_eq_one hr)
  refine' lt_of_le_of_ne ((addVal Γ R).map_le_sub (ge_of_eq (addVal Γ R).map_one) _) _
  · simp only [AddValuation.map_mul]
    rw [addVal_apply_of_ne x0, addVal_apply_of_ne (single_ne_zero h10), addVal_apply_of_ne _,
      order_C, order_single h10, WithTop.coe_zero, zero_add, ← WithTop.coe_add, neg_add_self,
      WithTop.coe_zero]
    · exact C_ne_zero (left_ne_zero_of_mul_eq_one hr)
  · 

Proof state:
case refine'_2
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedAddCommGroup Γ
inst✝¹ : CommRing R
inst✝ : IsDomain R
x : HahnSeries Γ R
r : R
hr : r * coeff x (order x) = 1
h10 : 1 ≠ 0
x0 : x ≠ 0
⊢ 0 ≠ (addVal Γ R) (1 - C r * (single (-order x)) 1 * x)

Next tactic:
rw [addVal_apply, ← WithTop.coe_zero]
theorem unit_aux (x : HahnSeries Γ R) {r : R} (hr : r * x.coeff x.order = 1) :
    0 < addVal Γ R (1 - C r * single (-x.order) 1 * x) := by
  have h10 : (1 : R) ≠ 0 := one_ne_zero
  have x0 : x ≠ 0 := ne_zero_of_coeff_ne_zero (right_ne_zero_of_mul_eq_one hr)
  refine' lt_of_le_of_ne ((addVal Γ R).map_le_sub (ge_of_eq (addVal Γ R).map_one) _) _
  · simp only [AddValuation.map_mul]
    rw [addVal_apply_of_ne x0, addVal_apply_of_ne (single_ne_zero h10), addVal_apply_of_ne _,
      order_C, order_single h10, WithTop.coe_zero, zero_add, ← WithTop.coe_add, neg_add_self,
      WithTop.coe_zero]
    · exact C_ne_zero (left_ne_zero_of_mul_eq_one hr)
  · rw [addVal_apply, ← WithTop.coe_zero]
    

Proof state:
case refine'_2
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedAddCommGroup Γ
inst✝¹ : CommRing R
inst✝ : IsDomain R
x : HahnSeries Γ R
r : R
hr : r * coeff x (order x) = 1
h10 : 1 ≠ 0
x0 : x ≠ 0
⊢ ↑0 ≠ if 1 - C r * (single (-order x)) 1 * x = 0 then ⊤ else ↑(order (1 - C r * (single (-order x)) 1 * x))

Next tactic:
split_ifs with h
theorem unit_aux (x : HahnSeries Γ R) {r : R} (hr : r * x.coeff x.order = 1) :
    0 < addVal Γ R (1 - C r * single (-x.order) 1 * x) := by
  have h10 : (1 : R) ≠ 0 := one_ne_zero
  have x0 : x ≠ 0 := ne_zero_of_coeff_ne_zero (right_ne_zero_of_mul_eq_one hr)
  refine' lt_of_le_of_ne ((addVal Γ R).map_le_sub (ge_of_eq (addVal Γ R).map_one) _) _
  · simp only [AddValuation.map_mul]
    rw [addVal_apply_of_ne x0, addVal_apply_of_ne (single_ne_zero h10), addVal_apply_of_ne _,
      order_C, order_single h10, WithTop.coe_zero, zero_add, ← WithTop.coe_add, neg_add_self,
      WithTop.coe_zero]
    · exact C_ne_zero (left_ne_zero_of_mul_eq_one hr)
  · rw [addVal_apply, ← WithTop.coe_zero]
    split_ifs with h
    · 

Proof state:
case pos
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedAddCommGroup Γ
inst✝¹ : CommRing R
inst✝ : IsDomain R
x : HahnSeries Γ R
r : R
hr : r * coeff x (order x) = 1
h10 : 1 ≠ 0
x0 : x ≠ 0
h : 1 - C r * (single (-order x)) 1 * x = 0
⊢ ↑0 ≠ ⊤

Next tactic:
apply WithTop.coe_ne_top
theorem unit_aux (x : HahnSeries Γ R) {r : R} (hr : r * x.coeff x.order = 1) :
    0 < addVal Γ R (1 - C r * single (-x.order) 1 * x) := by
  have h10 : (1 : R) ≠ 0 := one_ne_zero
  have x0 : x ≠ 0 := ne_zero_of_coeff_ne_zero (right_ne_zero_of_mul_eq_one hr)
  refine' lt_of_le_of_ne ((addVal Γ R).map_le_sub (ge_of_eq (addVal Γ R).map_one) _) _
  · simp only [AddValuation.map_mul]
    rw [addVal_apply_of_ne x0, addVal_apply_of_ne (single_ne_zero h10), addVal_apply_of_ne _,
      order_C, order_single h10, WithTop.coe_zero, zero_add, ← WithTop.coe_add, neg_add_self,
      WithTop.coe_zero]
    · exact C_ne_zero (left_ne_zero_of_mul_eq_one hr)
  · rw [addVal_apply, ← WithTop.coe_zero]
    split_ifs with h
    · apply WithTop.coe_ne_top
    

Proof state:
case neg
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedAddCommGroup Γ
inst✝¹ : CommRing R
inst✝ : IsDomain R
x : HahnSeries Γ R
r : R
hr : r * coeff x (order x) = 1
h10 : 1 ≠ 0
x0 : x ≠ 0
h : ¬1 - C r * (single (-order x)) 1 * x = 0
⊢ ↑0 ≠ ↑(order (1 - C r * (single (-order x)) 1 * x))

Next tactic:
rw [Ne.def, WithTop.coe_eq_coe]
theorem unit_aux (x : HahnSeries Γ R) {r : R} (hr : r * x.coeff x.order = 1) :
    0 < addVal Γ R (1 - C r * single (-x.order) 1 * x) := by
  have h10 : (1 : R) ≠ 0 := one_ne_zero
  have x0 : x ≠ 0 := ne_zero_of_coeff_ne_zero (right_ne_zero_of_mul_eq_one hr)
  refine' lt_of_le_of_ne ((addVal Γ R).map_le_sub (ge_of_eq (addVal Γ R).map_one) _) _
  · simp only [AddValuation.map_mul]
    rw [addVal_apply_of_ne x0, addVal_apply_of_ne (single_ne_zero h10), addVal_apply_of_ne _,
      order_C, order_single h10, WithTop.coe_zero, zero_add, ← WithTop.coe_add, neg_add_self,
      WithTop.coe_zero]
    · exact C_ne_zero (left_ne_zero_of_mul_eq_one hr)
  · rw [addVal_apply, ← WithTop.coe_zero]
    split_ifs with h
    · apply WithTop.coe_ne_top
    rw [Ne.def, WithTop.coe_eq_coe]
    

Proof state:
case neg
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedAddCommGroup Γ
inst✝¹ : CommRing R
inst✝ : IsDomain R
x : HahnSeries Γ R
r : R
hr : r * coeff x (order x) = 1
h10 : 1 ≠ 0
x0 : x ≠ 0
h : ¬1 - C r * (single (-order x)) 1 * x = 0
⊢ ¬0 = order (1 - C r * (single (-order x)) 1 * x)

Next tactic:
intro con
theorem unit_aux (x : HahnSeries Γ R) {r : R} (hr : r * x.coeff x.order = 1) :
    0 < addVal Γ R (1 - C r * single (-x.order) 1 * x) := by
  have h10 : (1 : R) ≠ 0 := one_ne_zero
  have x0 : x ≠ 0 := ne_zero_of_coeff_ne_zero (right_ne_zero_of_mul_eq_one hr)
  refine' lt_of_le_of_ne ((addVal Γ R).map_le_sub (ge_of_eq (addVal Γ R).map_one) _) _
  · simp only [AddValuation.map_mul]
    rw [addVal_apply_of_ne x0, addVal_apply_of_ne (single_ne_zero h10), addVal_apply_of_ne _,
      order_C, order_single h10, WithTop.coe_zero, zero_add, ← WithTop.coe_add, neg_add_self,
      WithTop.coe_zero]
    · exact C_ne_zero (left_ne_zero_of_mul_eq_one hr)
  · rw [addVal_apply, ← WithTop.coe_zero]
    split_ifs with h
    · apply WithTop.coe_ne_top
    rw [Ne.def, WithTop.coe_eq_coe]
    intro con
    

Proof state:
case neg
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedAddCommGroup Γ
inst✝¹ : CommRing R
inst✝ : IsDomain R
x : HahnSeries Γ R
r : R
hr : r * coeff x (order x) = 1
h10 : 1 ≠ 0
x0 : x ≠ 0
h : ¬1 - C r * (single (-order x)) 1 * x = 0
con : 0 = order (1 - C r * (single (-order x)) 1 * x)
⊢ False

Next tactic:
apply coeff_order_ne_zero h
theorem unit_aux (x : HahnSeries Γ R) {r : R} (hr : r * x.coeff x.order = 1) :
    0 < addVal Γ R (1 - C r * single (-x.order) 1 * x) := by
  have h10 : (1 : R) ≠ 0 := one_ne_zero
  have x0 : x ≠ 0 := ne_zero_of_coeff_ne_zero (right_ne_zero_of_mul_eq_one hr)
  refine' lt_of_le_of_ne ((addVal Γ R).map_le_sub (ge_of_eq (addVal Γ R).map_one) _) _
  · simp only [AddValuation.map_mul]
    rw [addVal_apply_of_ne x0, addVal_apply_of_ne (single_ne_zero h10), addVal_apply_of_ne _,
      order_C, order_single h10, WithTop.coe_zero, zero_add, ← WithTop.coe_add, neg_add_self,
      WithTop.coe_zero]
    · exact C_ne_zero (left_ne_zero_of_mul_eq_one hr)
  · rw [addVal_apply, ← WithTop.coe_zero]
    split_ifs with h
    · apply WithTop.coe_ne_top
    rw [Ne.def, WithTop.coe_eq_coe]
    intro con
    apply coeff_order_ne_zero h
    

Proof state:
case neg
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedAddCommGroup Γ
inst✝¹ : CommRing R
inst✝ : IsDomain R
x : HahnSeries Γ R
r : R
hr : r * coeff x (order x) = 1
h10 : 1 ≠ 0
x0 : x ≠ 0
h : ¬1 - C r * (single (-order x)) 1 * x = 0
con : 0 = order (1 - C r * (single (-order x)) 1 * x)
⊢ coeff (1 - C r * (single (-order x)) 1 * x) (order (1 - C r * (single (-order x)) 1 * x)) = 0

Next tactic:
rw [← con, mul_assoc, sub_coeff, one_coeff, if_pos rfl, C_mul_eq_smul, smul_coeff, smul_eq_mul,
      ← add_neg_self x.order, single_mul_coeff_add, one_mul, hr, sub_self]
theorem isUnit_iff {x : HahnSeries Γ R} : IsUnit x ↔ IsUnit (x.coeff x.order) := by
  

Proof state:
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedAddCommGroup Γ
inst✝¹ : CommRing R
inst✝ : IsDomain R
x : HahnSeries Γ R
⊢ IsUnit x ↔ IsUnit (coeff x (order x))

Next tactic:
constructor
theorem isUnit_iff {x : HahnSeries Γ R} : IsUnit x ↔ IsUnit (x.coeff x.order) := by
  constructor
  · 

Proof state:
case mp
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedAddCommGroup Γ
inst✝¹ : CommRing R
inst✝ : IsDomain R
x : HahnSeries Γ R
⊢ IsUnit x → IsUnit (coeff x (order x))

Next tactic:
rintro ⟨⟨u, i, ui, iu⟩, rfl⟩
theorem isUnit_iff {x : HahnSeries Γ R} : IsUnit x ↔ IsUnit (x.coeff x.order) := by
  constructor
  · rintro ⟨⟨u, i, ui, iu⟩, rfl⟩
    

Proof state:
case mp.intro.mk
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedAddCommGroup Γ
inst✝¹ : CommRing R
inst✝ : IsDomain R
u i : HahnSeries Γ R
ui : u * i = 1
iu : i * u = 1
⊢ IsUnit
    (coeff (↑{ val := u, inv := i, val_inv := ui, inv_val := iu })
      (order ↑{ val := u, inv := i, val_inv := ui, inv_val := iu }))

Next tactic:
refine'
      isUnit_of_mul_eq_one (u.coeff u.order) (i.coeff i.order)
        ((mul_coeff_order_add_order u i).symm.trans _)
theorem isUnit_iff {x : HahnSeries Γ R} : IsUnit x ↔ IsUnit (x.coeff x.order) := by
  constructor
  · rintro ⟨⟨u, i, ui, iu⟩, rfl⟩
    refine'
      isUnit_of_mul_eq_one (u.coeff u.order) (i.coeff i.order)
        ((mul_coeff_order_add_order u i).symm.trans _)
    

Proof state:
case mp.intro.mk
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedAddCommGroup Γ
inst✝¹ : CommRing R
inst✝ : IsDomain R
u i : HahnSeries Γ R
ui : u * i = 1
iu : i * u = 1
⊢ coeff (u * i) (order u + order i) = 1

Next tactic:
rw [ui, one_coeff, if_pos]
theorem isUnit_iff {x : HahnSeries Γ R} : IsUnit x ↔ IsUnit (x.coeff x.order) := by
  constructor
  · rintro ⟨⟨u, i, ui, iu⟩, rfl⟩
    refine'
      isUnit_of_mul_eq_one (u.coeff u.order) (i.coeff i.order)
        ((mul_coeff_order_add_order u i).symm.trans _)
    rw [ui, one_coeff, if_pos]
    

Proof state:
case mp.intro.mk.hc
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedAddCommGroup Γ
inst✝¹ : CommRing R
inst✝ : IsDomain R
u i : HahnSeries Γ R
ui : u * i = 1
iu : i * u = 1
⊢ order u + order i = 0

Next tactic:
rw [← order_mul (left_ne_zero_of_mul_eq_one ui) (right_ne_zero_of_mul_eq_one ui), ui, order_one]
theorem isUnit_iff {x : HahnSeries Γ R} : IsUnit x ↔ IsUnit (x.coeff x.order) := by
  constructor
  · rintro ⟨⟨u, i, ui, iu⟩, rfl⟩
    refine'
      isUnit_of_mul_eq_one (u.coeff u.order) (i.coeff i.order)
        ((mul_coeff_order_add_order u i).symm.trans _)
    rw [ui, one_coeff, if_pos]
    rw [← order_mul (left_ne_zero_of_mul_eq_one ui) (right_ne_zero_of_mul_eq_one ui), ui, order_one]
  · 

Proof state:
case mpr
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedAddCommGroup Γ
inst✝¹ : CommRing R
inst✝ : IsDomain R
x : HahnSeries Γ R
⊢ IsUnit (coeff x (order x)) → IsUnit x

Next tactic:
rintro ⟨⟨u, i, ui, iu⟩, h⟩
theorem isUnit_iff {x : HahnSeries Γ R} : IsUnit x ↔ IsUnit (x.coeff x.order) := by
  constructor
  · rintro ⟨⟨u, i, ui, iu⟩, rfl⟩
    refine'
      isUnit_of_mul_eq_one (u.coeff u.order) (i.coeff i.order)
        ((mul_coeff_order_add_order u i).symm.trans _)
    rw [ui, one_coeff, if_pos]
    rw [← order_mul (left_ne_zero_of_mul_eq_one ui) (right_ne_zero_of_mul_eq_one ui), ui, order_one]
  · rintro ⟨⟨u, i, ui, iu⟩, h⟩
    

Proof state:
case mpr.intro.mk
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedAddCommGroup Γ
inst✝¹ : CommRing R
inst✝ : IsDomain R
x : HahnSeries Γ R
u i : R
ui : u * i = 1
iu : i * u = 1
h : ↑{ val := u, inv := i, val_inv := ui, inv_val := iu } = coeff x (order x)
⊢ IsUnit x

Next tactic:
rw [Units.val_mk] at h
theorem isUnit_iff {x : HahnSeries Γ R} : IsUnit x ↔ IsUnit (x.coeff x.order) := by
  constructor
  · rintro ⟨⟨u, i, ui, iu⟩, rfl⟩
    refine'
      isUnit_of_mul_eq_one (u.coeff u.order) (i.coeff i.order)
        ((mul_coeff_order_add_order u i).symm.trans _)
    rw [ui, one_coeff, if_pos]
    rw [← order_mul (left_ne_zero_of_mul_eq_one ui) (right_ne_zero_of_mul_eq_one ui), ui, order_one]
  · rintro ⟨⟨u, i, ui, iu⟩, h⟩
    rw [Units.val_mk] at h
    

Proof state:
case mpr.intro.mk
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedAddCommGroup Γ
inst✝¹ : CommRing R
inst✝ : IsDomain R
x : HahnSeries Γ R
u i : R
ui : u * i = 1
iu : i * u = 1
h : u = coeff x (order x)
⊢ IsUnit x

Next tactic:
rw [h] at iu
theorem isUnit_iff {x : HahnSeries Γ R} : IsUnit x ↔ IsUnit (x.coeff x.order) := by
  constructor
  · rintro ⟨⟨u, i, ui, iu⟩, rfl⟩
    refine'
      isUnit_of_mul_eq_one (u.coeff u.order) (i.coeff i.order)
        ((mul_coeff_order_add_order u i).symm.trans _)
    rw [ui, one_coeff, if_pos]
    rw [← order_mul (left_ne_zero_of_mul_eq_one ui) (right_ne_zero_of_mul_eq_one ui), ui, order_one]
  · rintro ⟨⟨u, i, ui, iu⟩, h⟩
    rw [Units.val_mk] at h
    rw [h] at iu
    

Proof state:
case mpr.intro.mk
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedAddCommGroup Γ
inst✝¹ : CommRing R
inst✝ : IsDomain R
x : HahnSeries Γ R
u i : R
ui : u * i = 1
iu : i * coeff x (order x) = 1
h : u = coeff x (order x)
⊢ IsUnit x

Next tactic:
have h := SummableFamily.one_sub_self_mul_hsum_powers (unit_aux x iu)
theorem isUnit_iff {x : HahnSeries Γ R} : IsUnit x ↔ IsUnit (x.coeff x.order) := by
  constructor
  · rintro ⟨⟨u, i, ui, iu⟩, rfl⟩
    refine'
      isUnit_of_mul_eq_one (u.coeff u.order) (i.coeff i.order)
        ((mul_coeff_order_add_order u i).symm.trans _)
    rw [ui, one_coeff, if_pos]
    rw [← order_mul (left_ne_zero_of_mul_eq_one ui) (right_ne_zero_of_mul_eq_one ui), ui, order_one]
  · rintro ⟨⟨u, i, ui, iu⟩, h⟩
    rw [Units.val_mk] at h
    rw [h] at iu
    have h := SummableFamily.one_sub_self_mul_hsum_powers (unit_aux x iu)
    

Proof state:
case mpr.intro.mk
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedAddCommGroup Γ
inst✝¹ : CommRing R
inst✝ : IsDomain R
x : HahnSeries Γ R
u i : R
ui : u * i = 1
iu : i * coeff x (order x) = 1
h✝ : u = coeff x (order x)
h :
  (1 - (1 - C i * (single (-order x)) 1 * x)) *
      SummableFamily.hsum
        (SummableFamily.powers (1 - C i * (single (-order x)) 1 * x)
          (_ : 0 < (addVal Γ R) (1 - C i * (single (-order x)) 1 * x))) =
    1
⊢ IsUnit x

Next tactic:
rw [sub_sub_cancel] at h
theorem isUnit_iff {x : HahnSeries Γ R} : IsUnit x ↔ IsUnit (x.coeff x.order) := by
  constructor
  · rintro ⟨⟨u, i, ui, iu⟩, rfl⟩
    refine'
      isUnit_of_mul_eq_one (u.coeff u.order) (i.coeff i.order)
        ((mul_coeff_order_add_order u i).symm.trans _)
    rw [ui, one_coeff, if_pos]
    rw [← order_mul (left_ne_zero_of_mul_eq_one ui) (right_ne_zero_of_mul_eq_one ui), ui, order_one]
  · rintro ⟨⟨u, i, ui, iu⟩, h⟩
    rw [Units.val_mk] at h
    rw [h] at iu
    have h := SummableFamily.one_sub_self_mul_hsum_powers (unit_aux x iu)
    rw [sub_sub_cancel] at h
    

Proof state:
case mpr.intro.mk
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedAddCommGroup Γ
inst✝¹ : CommRing R
inst✝ : IsDomain R
x : HahnSeries Γ R
u i : R
ui : u * i = 1
iu : i * coeff x (order x) = 1
h✝ : u = coeff x (order x)
h :
  C i * (single (-order x)) 1 * x *
      SummableFamily.hsum
        (SummableFamily.powers (1 - C i * (single (-order x)) 1 * x)
          (_ : 0 < (addVal Γ R) (1 - C i * (single (-order x)) 1 * x))) =
    1
⊢ IsUnit x

Next tactic:
exact isUnit_of_mul_isUnit_right (isUnit_of_mul_eq_one _ _ h)
instance [Field R] : Field (HahnSeries Γ R) :=
  { inferInstanceAs (IsDomain (HahnSeries Γ R)),
    inferInstanceAs (CommRing (HahnSeries Γ R)) with
    inv := fun x =>
      if x0 : x = 0 then 0
      else
        C (x.coeff x.order)⁻¹ * (single (-x.order)) 1 *
          (SummableFamily.powers _ (unit_aux x (inv_mul_cancel (coeff_order_ne_zero x0)))).hsum
    inv_zero := dif_pos rfl
    mul_inv_cancel := fun x x0 => by
      

Proof state:
Γ : Type u_1
R : Type u_2
inst✝¹ : LinearOrderedAddCommGroup Γ
inst✝ : Field R
src✝¹ : IsDomain (HahnSeries Γ R) := inferInstanceAs (IsDomain (HahnSeries Γ R))
src✝ : CommRing (HahnSeries Γ R) := inferInstanceAs (CommRing (HahnSeries Γ R))
x : HahnSeries Γ R
x0 : x ≠ 0
⊢ x * x⁻¹ = 1

Next tactic:
refine' (congr rfl (dif_neg x0)).trans _