l3lab/ntp-mathlib huggingface dataset:
/-- The ring `HahnSeries (σ →₀ ℕ) R` is isomorphic to `MvPowerSeries σ R` for a `Fintype` `σ`.
We take the index set of the hahn series to be `Finsupp` rather than `pi`,
even though we assume `Fintype σ` as this is more natural for alignment with `MvPowerSeries`.
After importing `Algebra.Order.Pi` the ring `HahnSeries (σ → ℕ) R` could be constructed instead.
 -/
@[simps]
def toMvPowerSeries {σ : Type*} [Fintype σ] : HahnSeries (σ →₀ ℕ) R ≃+* MvPowerSeries σ R where
  toFun f := f.coeff
  invFun f := ⟨(f : (σ →₀ ℕ) → R), Finsupp.isPwo _⟩
  left_inv f := by
    ext
    simp
  right_inv f := by
    ext
    simp
  map_add' f g := by
    ext
    simp
  map_mul' f g := by
    ext n
    simp only [MvPowerSeries.coeff_mul]
    classical
      change (f * g).coeff n = _
      simp_rw [mul_coeff]
      refine' (sum_filter_ne_zero _).symm.trans $ (sum_congr _ fun _ _ ↦ rfl).trans $
        sum_filter_ne_zero _
      ext m
      simp only [and_congr_left_iff, mem_addAntidiagonal, mem_filter, mem_support,
        Finset.mem_antidiagonal]
      rintro h
      

Proof state:
case h.a
Γ : Type u_1
R : Type u_2
inst✝² : Semiring R
inst✝¹ : StrictOrderedSemiring Γ
σ : Type u_3
inst✝ : Fintype σ
f g : HahnSeries (σ →₀ ℕ) R
n : σ →₀ ℕ
m : (σ →₀ ℕ) × (σ →₀ ℕ)
h : coeff f m.1 * coeff g m.2 ≠ 0
⊢ coeff f m.1 ≠ 0 ∧ coeff g m.2 ≠ 0 ∧ m.1 + m.2 = n ↔ m.1 + m.2 = n

Next tactic:
rw [and_iff_right (left_ne_zero_of_mul h), and_iff_right (right_ne_zero_of_mul h)]
/-- The ring `HahnSeries (σ →₀ ℕ) R` is isomorphic to `MvPowerSeries σ R` for a `Fintype` `σ`.
We take the index set of the hahn series to be `Finsupp` rather than `pi`,
even though we assume `Fintype σ` as this is more natural for alignment with `MvPowerSeries`.
After importing `Algebra.Order.Pi` the ring `HahnSeries (σ → ℕ) R` could be constructed instead.
 -/
@[simps]
def toMvPowerSeries {σ : Type*} [Fintype σ] : HahnSeries (σ →₀ ℕ) R ≃+* MvPowerSeries σ R where
  toFun f := f.coeff
  invFun f := ⟨(f : (σ →₀ ℕ) → R), Finsupp.isPwo _⟩
  left_inv f := by
    ext
    simp
  right_inv f := by
    ext
    simp
  map_add' f g := by
    

Proof state:
Γ : Type u_1
R : Type u_2
inst✝² : Semiring R
inst✝¹ : StrictOrderedSemiring Γ
σ : Type u_3
inst✝ : Fintype σ
f g : HahnSeries (σ →₀ ℕ) R
⊢ Equiv.toFun
      { toFun := fun f => f.coeff,
        invFun := fun f => { coeff := f, isPwo_support' := (_ : Set.IsPwo (Function.support f)) },
        left_inv :=
          (_ :
            ∀ (f : HahnSeries (σ →₀ ℕ) R),
              (fun f => { coeff := f, isPwo_support' := (_ : Set.IsPwo (Function.support f)) }) ((fun f => f.coeff) f) =
                f),
        right_inv :=
          (_ :
            ∀ (f : MvPowerSeries σ R),
              (fun f => f.coeff) ((fun f => { coeff := f, isPwo_support' := (_ : Set.IsPwo (Function.support f)) }) f) =
                f) }
      (f + g) =
    Equiv.toFun
        { toFun := fun f => f.coeff,
          invFun := fun f => { coeff := f, isPwo_support' := (_ : Set.IsPwo (Function.support f)) },
          left_inv :=
            (_ :
              ∀ (f : HahnSeries (σ →₀ ℕ) R),
                (fun f => { coeff := f, isPwo_support' := (_ : Set.IsPwo (Function.support f)) })
                    ((fun f => f.coeff) f) =
                  f),
          right_inv :=
            (_ :
              ∀ (f : MvPowerSeries σ R),
                (fun f => f.coeff)
                    ((fun f => { coeff := f, isPwo_support' := (_ : Set.IsPwo (Function.support f)) }) f) =
                  f) }
        f +
      Equiv.toFun
        { toFun := fun f => f.coeff,
          invFun := fun f => { coeff := f, isPwo_support' := (_ : Set.IsPwo (Function.support f)) },
          left_inv :=
            (_ :
              ∀ (f : HahnSeries (σ →₀ ℕ) R),
                (fun f => { coeff := f, isPwo_support' := (_ : Set.IsPwo (Function.support f)) })
                    ((fun f => f.coeff) f) =
                  f),
          right_inv :=
            (_ :
              ∀ (f : MvPowerSeries σ R),
                (fun f => f.coeff)
                    ((fun f => { coeff := f, isPwo_support' := (_ : Set.IsPwo (Function.support f)) }) f) =
                  f) }
        g

Next tactic:
ext
/-- The ring `HahnSeries (σ →₀ ℕ) R` is isomorphic to `MvPowerSeries σ R` for a `Fintype` `σ`.
We take the index set of the hahn series to be `Finsupp` rather than `pi`,
even though we assume `Fintype σ` as this is more natural for alignment with `MvPowerSeries`.
After importing `Algebra.Order.Pi` the ring `HahnSeries (σ → ℕ) R` could be constructed instead.
 -/
@[simps]
def toMvPowerSeries {σ : Type*} [Fintype σ] : HahnSeries (σ →₀ ℕ) R ≃+* MvPowerSeries σ R where
  toFun f := f.coeff
  invFun f := ⟨(f : (σ →₀ ℕ) → R), Finsupp.isPwo _⟩
  left_inv f := by
    ext
    simp
  right_inv f := by
    ext
    simp
  map_add' f g := by
    ext
    

Proof state:
case h
Γ : Type u_1
R : Type u_2
inst✝² : Semiring R
inst✝¹ : StrictOrderedSemiring Γ
σ : Type u_3
inst✝ : Fintype σ
f g : HahnSeries (σ →₀ ℕ) R
n✝ : σ →₀ ℕ
⊢ (MvPowerSeries.coeff R n✝)
      (Equiv.toFun
        { toFun := fun f => f.coeff,
          invFun := fun f => { coeff := f, isPwo_support' := (_ : Set.IsPwo (Function.support f)) },
          left_inv :=
            (_ :
              ∀ (f : HahnSeries (σ →₀ ℕ) R),
                (fun f => { coeff := f, isPwo_support' := (_ : Set.IsPwo (Function.support f)) })
                    ((fun f => f.coeff) f) =
                  f),
          right_inv :=
            (_ :
              ∀ (f : MvPowerSeries σ R),
                (fun f => f.coeff)
                    ((fun f => { coeff := f, isPwo_support' := (_ : Set.IsPwo (Function.support f)) }) f) =
                  f) }
        (f + g)) =
    (MvPowerSeries.coeff R n✝)
      (Equiv.toFun
          { toFun := fun f => f.coeff,
            invFun := fun f => { coeff := f, isPwo_support' := (_ : Set.IsPwo (Function.support f)) },
            left_inv :=
              (_ :
                ∀ (f : HahnSeries (σ →₀ ℕ) R),
                  (fun f => { coeff := f, isPwo_support' := (_ : Set.IsPwo (Function.support f)) })
                      ((fun f => f.coeff) f) =
                    f),
            right_inv :=
              (_ :
                ∀ (f : MvPowerSeries σ R),
                  (fun f => f.coeff)
                      ((fun f => { coeff := f, isPwo_support' := (_ : Set.IsPwo (Function.support f)) }) f) =
                    f) }
          f +
        Equiv.toFun
          { toFun := fun f => f.coeff,
            invFun := fun f => { coeff := f, isPwo_support' := (_ : Set.IsPwo (Function.support f)) },
            left_inv :=
              (_ :
                ∀ (f : HahnSeries (σ →₀ ℕ) R),
                  (fun f => { coeff := f, isPwo_support' := (_ : Set.IsPwo (Function.support f)) })
                      ((fun f => f.coeff) f) =
                    f),
            right_inv :=
              (_ :
                ∀ (f : MvPowerSeries σ R),
                  (fun f => f.coeff)
                      ((fun f => { coeff := f, isPwo_support' := (_ : Set.IsPwo (Function.support f)) }) f) =
                    f) }
          g)

Next tactic:
simp
/-- The `R`-algebra `HahnSeries ℕ A` is isomorphic to `PowerSeries A`. -/
@[simps!]
def toPowerSeriesAlg : HahnSeries ℕ A ≃ₐ[R] PowerSeries A :=
  { toPowerSeries with
    commutes' := fun r => by
      

Proof state:
Γ : Type u_1
R : Type u_2
inst✝² : CommSemiring R
A : Type u_3
inst✝¹ : Semiring A
inst✝ : Algebra R A
src✝ : HahnSeries ℕ A ≃+* PowerSeries A := toPowerSeries
r : R
⊢ Equiv.toFun src✝.toEquiv ((algebraMap R (HahnSeries ℕ A)) r) = (algebraMap R (PowerSeries A)) r

Next tactic:
ext n
/-- The `R`-algebra `HahnSeries ℕ A` is isomorphic to `PowerSeries A`. -/
@[simps!]
def toPowerSeriesAlg : HahnSeries ℕ A ≃ₐ[R] PowerSeries A :=
  { toPowerSeries with
    commutes' := fun r => by
      ext n
      

Proof state:
case h
Γ : Type u_1
R : Type u_2
inst✝² : CommSemiring R
A : Type u_3
inst✝¹ : Semiring A
inst✝ : Algebra R A
src✝ : HahnSeries ℕ A ≃+* PowerSeries A := toPowerSeries
r : R
n : ℕ
⊢ (PowerSeries.coeff A n) (Equiv.toFun src✝.toEquiv ((algebraMap R (HahnSeries ℕ A)) r)) =
    (PowerSeries.coeff A n) ((algebraMap R (PowerSeries A)) r)

Next tactic:
cases n
/-- The `R`-algebra `HahnSeries ℕ A` is isomorphic to `PowerSeries A`. -/
@[simps!]
def toPowerSeriesAlg : HahnSeries ℕ A ≃ₐ[R] PowerSeries A :=
  { toPowerSeries with
    commutes' := fun r => by
      ext n
      cases n <;> 

Proof state:
case h.zero
Γ : Type u_1
R : Type u_2
inst✝² : CommSemiring R
A : Type u_3
inst✝¹ : Semiring A
inst✝ : Algebra R A
src✝ : HahnSeries ℕ A ≃+* PowerSeries A := toPowerSeries
r : R
⊢ (PowerSeries.coeff A Nat.zero) (Equiv.toFun src✝.toEquiv ((algebraMap R (HahnSeries ℕ A)) r)) =
    (PowerSeries.coeff A Nat.zero) ((algebraMap R (PowerSeries A)) r)

Next tactic:
simp [algebraMap_apply, PowerSeries.algebraMap_apply]
/-- The `R`-algebra `HahnSeries ℕ A` is isomorphic to `PowerSeries A`. -/
@[simps!]
def toPowerSeriesAlg : HahnSeries ℕ A ≃ₐ[R] PowerSeries A :=
  { toPowerSeries with
    commutes' := fun r => by
      ext n
      cases n <;> 

Proof state:
case h.succ
Γ : Type u_1
R : Type u_2
inst✝² : CommSemiring R
A : Type u_3
inst✝¹ : Semiring A
inst✝ : Algebra R A
src✝ : HahnSeries ℕ A ≃+* PowerSeries A := toPowerSeries
r : R
n✝ : ℕ
⊢ (PowerSeries.coeff A (Nat.succ n✝)) (Equiv.toFun src✝.toEquiv ((algebraMap R (HahnSeries ℕ A)) r)) =
    (PowerSeries.coeff A (Nat.succ n✝)) ((algebraMap R (PowerSeries A)) r)

Next tactic:
simp [algebraMap_apply, PowerSeries.algebraMap_apply]
/-- The additive valuation on `HahnSeries Γ R`, returning the smallest index at which
  a Hahn Series has a nonzero coefficient, or `⊤` for the 0 series.  -/
def addVal : AddValuation (HahnSeries Γ R) (WithTop Γ) :=
  AddValuation.of (fun x => if x = (0 : HahnSeries Γ R) then (⊤ : WithTop Γ) else x.order)
    (if_pos rfl) ((if_neg one_ne_zero).trans (by 

Proof state:
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : Ring R
inst✝ : IsDomain R
⊢ ↑(order 1) = 0

Next tactic:
simp [order_of_ne]
/-- The additive valuation on `HahnSeries Γ R`, returning the smallest index at which
  a Hahn Series has a nonzero coefficient, or `⊤` for the 0 series.  -/
def addVal : AddValuation (HahnSeries Γ R) (WithTop Γ) :=
  AddValuation.of (fun x => if x = (0 : HahnSeries Γ R) then (⊤ : WithTop Γ) else x.order)
    (if_pos rfl) ((if_neg one_ne_zero).trans (by simp [order_of_ne]))
    (fun x y => by
      

Proof state:
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : Ring R
inst✝ : IsDomain R
x y : HahnSeries Γ R
⊢ min ((fun x => if x = 0 then ⊤ else ↑(order x)) x) ((fun x => if x = 0 then ⊤ else ↑(order x)) y) ≤
    (fun x => if x = 0 then ⊤ else ↑(order x)) (x + y)

Next tactic:
by_cases hx : x = 0
/-- The additive valuation on `HahnSeries Γ R`, returning the smallest index at which
  a Hahn Series has a nonzero coefficient, or `⊤` for the 0 series.  -/
def addVal : AddValuation (HahnSeries Γ R) (WithTop Γ) :=
  AddValuation.of (fun x => if x = (0 : HahnSeries Γ R) then (⊤ : WithTop Γ) else x.order)
    (if_pos rfl) ((if_neg one_ne_zero).trans (by simp [order_of_ne]))
    (fun x y => by
      by_cases hx : x = 0
      · 

Proof state:
case pos
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : Ring R
inst✝ : IsDomain R
x y : HahnSeries Γ R
hx : x = 0
⊢ min ((fun x => if x = 0 then ⊤ else ↑(order x)) x) ((fun x => if x = 0 then ⊤ else ↑(order x)) y) ≤
    (fun x => if x = 0 then ⊤ else ↑(order x)) (x + y)

Next tactic:
by_cases hy : y = 0
/-- The additive valuation on `HahnSeries Γ R`, returning the smallest index at which
  a Hahn Series has a nonzero coefficient, or `⊤` for the 0 series.  -/
def addVal : AddValuation (HahnSeries Γ R) (WithTop Γ) :=
  AddValuation.of (fun x => if x = (0 : HahnSeries Γ R) then (⊤ : WithTop Γ) else x.order)
    (if_pos rfl) ((if_neg one_ne_zero).trans (by simp [order_of_ne]))
    (fun x y => by
      by_cases hx : x = 0
      · by_cases hy : y = 0 <;> · 

Proof state:
case pos
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : Ring R
inst✝ : IsDomain R
x y : HahnSeries Γ R
hx : x = 0
hy : y = 0
⊢ min ((fun x => if x = 0 then ⊤ else ↑(order x)) x) ((fun x => if x = 0 then ⊤ else ↑(order x)) y) ≤
    (fun x => if x = 0 then ⊤ else ↑(order x)) (x + y)

Next tactic:
simp [hx, hy]
/-- The additive valuation on `HahnSeries Γ R`, returning the smallest index at which
  a Hahn Series has a nonzero coefficient, or `⊤` for the 0 series.  -/
def addVal : AddValuation (HahnSeries Γ R) (WithTop Γ) :=
  AddValuation.of (fun x => if x = (0 : HahnSeries Γ R) then (⊤ : WithTop Γ) else x.order)
    (if_pos rfl) ((if_neg one_ne_zero).trans (by simp [order_of_ne]))
    (fun x y => by
      by_cases hx : x = 0
      · by_cases hy : y = 0 <;> · 

Proof state:
case neg
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : Ring R
inst✝ : IsDomain R
x y : HahnSeries Γ R
hx : x = 0
hy : ¬y = 0
⊢ min ((fun x => if x = 0 then ⊤ else ↑(order x)) x) ((fun x => if x = 0 then ⊤ else ↑(order x)) y) ≤
    (fun x => if x = 0 then ⊤ else ↑(order x)) (x + y)

Next tactic:
simp [hx, hy]
/-- The additive valuation on `HahnSeries Γ R`, returning the smallest index at which
  a Hahn Series has a nonzero coefficient, or `⊤` for the 0 series.  -/
def addVal : AddValuation (HahnSeries Γ R) (WithTop Γ) :=
  AddValuation.of (fun x => if x = (0 : HahnSeries Γ R) then (⊤ : WithTop Γ) else x.order)
    (if_pos rfl) ((if_neg one_ne_zero).trans (by simp [order_of_ne]))
    (fun x y => by
      by_cases hx : x = 0
      · by_cases hy : y = 0 <;> · simp [hx, hy]
      · 

Proof state:
case neg
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : Ring R
inst✝ : IsDomain R
x y : HahnSeries Γ R
hx : ¬x = 0
⊢ min ((fun x => if x = 0 then ⊤ else ↑(order x)) x) ((fun x => if x = 0 then ⊤ else ↑(order x)) y) ≤
    (fun x => if x = 0 then ⊤ else ↑(order x)) (x + y)

Next tactic:
by_cases hy : y = 0
/-- The additive valuation on `HahnSeries Γ R`, returning the smallest index at which
  a Hahn Series has a nonzero coefficient, or `⊤` for the 0 series.  -/
def addVal : AddValuation (HahnSeries Γ R) (WithTop Γ) :=
  AddValuation.of (fun x => if x = (0 : HahnSeries Γ R) then (⊤ : WithTop Γ) else x.order)
    (if_pos rfl) ((if_neg one_ne_zero).trans (by simp [order_of_ne]))
    (fun x y => by
      by_cases hx : x = 0
      · by_cases hy : y = 0 <;> · simp [hx, hy]
      · by_cases hy : y = 0
        · 

Proof state:
case pos
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : Ring R
inst✝ : IsDomain R
x y : HahnSeries Γ R
hx : ¬x = 0
hy : y = 0
⊢ min ((fun x => if x = 0 then ⊤ else ↑(order x)) x) ((fun x => if x = 0 then ⊤ else ↑(order x)) y) ≤
    (fun x => if x = 0 then ⊤ else ↑(order x)) (x + y)

Next tactic:
simp [hx, hy]
/-- The additive valuation on `HahnSeries Γ R`, returning the smallest index at which
  a Hahn Series has a nonzero coefficient, or `⊤` for the 0 series.  -/
def addVal : AddValuation (HahnSeries Γ R) (WithTop Γ) :=
  AddValuation.of (fun x => if x = (0 : HahnSeries Γ R) then (⊤ : WithTop Γ) else x.order)
    (if_pos rfl) ((if_neg one_ne_zero).trans (by simp [order_of_ne]))
    (fun x y => by
      by_cases hx : x = 0
      · by_cases hy : y = 0 <;> · simp [hx, hy]
      · by_cases hy : y = 0
        · simp [hx, hy]
        · 

Proof state:
case neg
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : Ring R
inst✝ : IsDomain R
x y : HahnSeries Γ R
hx : ¬x = 0
hy : ¬y = 0
⊢ min ((fun x => if x = 0 then ⊤ else ↑(order x)) x) ((fun x => if x = 0 then ⊤ else ↑(order x)) y) ≤
    (fun x => if x = 0 then ⊤ else ↑(order x)) (x + y)

Next tactic:
simp only [hx, hy, support_nonempty_iff, if_neg, not_false_iff, isWf_support]
/-- The additive valuation on `HahnSeries Γ R`, returning the smallest index at which
  a Hahn Series has a nonzero coefficient, or `⊤` for the 0 series.  -/
def addVal : AddValuation (HahnSeries Γ R) (WithTop Γ) :=
  AddValuation.of (fun x => if x = (0 : HahnSeries Γ R) then (⊤ : WithTop Γ) else x.order)
    (if_pos rfl) ((if_neg one_ne_zero).trans (by simp [order_of_ne]))
    (fun x y => by
      by_cases hx : x = 0
      · by_cases hy : y = 0 <;> · simp [hx, hy]
      · by_cases hy : y = 0
        · simp [hx, hy]
        · simp only [hx, hy, support_nonempty_iff, if_neg, not_false_iff, isWf_support]
          

Proof state:
case neg
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : Ring R
inst✝ : IsDomain R
x y : HahnSeries Γ R
hx : ¬x = 0
hy : ¬y = 0
⊢ min ↑(order x) ↑(order y) ≤ if x + y = 0 then ⊤ else ↑(order (x + y))

Next tactic:
by_cases hxy : x + y = 0
/-- The additive valuation on `HahnSeries Γ R`, returning the smallest index at which
  a Hahn Series has a nonzero coefficient, or `⊤` for the 0 series.  -/
def addVal : AddValuation (HahnSeries Γ R) (WithTop Γ) :=
  AddValuation.of (fun x => if x = (0 : HahnSeries Γ R) then (⊤ : WithTop Γ) else x.order)
    (if_pos rfl) ((if_neg one_ne_zero).trans (by simp [order_of_ne]))
    (fun x y => by
      by_cases hx : x = 0
      · by_cases hy : y = 0 <;> · simp [hx, hy]
      · by_cases hy : y = 0
        · simp [hx, hy]
        · simp only [hx, hy, support_nonempty_iff, if_neg, not_false_iff, isWf_support]
          by_cases hxy : x + y = 0
          · 

Proof state:
case pos
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : Ring R
inst✝ : IsDomain R
x y : HahnSeries Γ R
hx : ¬x = 0
hy : ¬y = 0
hxy : x + y = 0
⊢ min ↑(order x) ↑(order y) ≤ if x + y = 0 then ⊤ else ↑(order (x + y))

Next tactic:
simp [hxy]
/-- The additive valuation on `HahnSeries Γ R`, returning the smallest index at which
  a Hahn Series has a nonzero coefficient, or `⊤` for the 0 series.  -/
def addVal : AddValuation (HahnSeries Γ R) (WithTop Γ) :=
  AddValuation.of (fun x => if x = (0 : HahnSeries Γ R) then (⊤ : WithTop Γ) else x.order)
    (if_pos rfl) ((if_neg one_ne_zero).trans (by simp [order_of_ne]))
    (fun x y => by
      by_cases hx : x = 0
      · by_cases hy : y = 0 <;> · simp [hx, hy]
      · by_cases hy : y = 0
        · simp [hx, hy]
        · simp only [hx, hy, support_nonempty_iff, if_neg, not_false_iff, isWf_support]
          by_cases hxy : x + y = 0
          · simp [hxy]
          

Proof state:
case neg
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : Ring R
inst✝ : IsDomain R
x y : HahnSeries Γ R
hx : ¬x = 0
hy : ¬y = 0
hxy : ¬x + y = 0
⊢ min ↑(order x) ↑(order y) ≤ if x + y = 0 then ⊤ else ↑(order (x + y))

Next tactic:
rw [if_neg hxy, ← WithTop.coe_min, WithTop.coe_le_coe]
/-- The additive valuation on `HahnSeries Γ R`, returning the smallest index at which
  a Hahn Series has a nonzero coefficient, or `⊤` for the 0 series.  -/
def addVal : AddValuation (HahnSeries Γ R) (WithTop Γ) :=
  AddValuation.of (fun x => if x = (0 : HahnSeries Γ R) then (⊤ : WithTop Γ) else x.order)
    (if_pos rfl) ((if_neg one_ne_zero).trans (by simp [order_of_ne]))
    (fun x y => by
      by_cases hx : x = 0
      · by_cases hy : y = 0 <;> · simp [hx, hy]
      · by_cases hy : y = 0
        · simp [hx, hy]
        · simp only [hx, hy, support_nonempty_iff, if_neg, not_false_iff, isWf_support]
          by_cases hxy : x + y = 0
          · simp [hxy]
          rw [if_neg hxy, ← WithTop.coe_min, WithTop.coe_le_coe]
          

Proof state:
case neg
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : Ring R
inst✝ : IsDomain R
x y : HahnSeries Γ R
hx : ¬x = 0
hy : ¬y = 0
hxy : ¬x + y = 0
⊢ min (order x) (order y) ≤ order (x + y)

Next tactic:
exact min_order_le_order_add hxy
/-- The additive valuation on `HahnSeries Γ R`, returning the smallest index at which
  a Hahn Series has a nonzero coefficient, or `⊤` for the 0 series.  -/
def addVal : AddValuation (HahnSeries Γ R) (WithTop Γ) :=
  AddValuation.of (fun x => if x = (0 : HahnSeries Γ R) then (⊤ : WithTop Γ) else x.order)
    (if_pos rfl) ((if_neg one_ne_zero).trans (by simp [order_of_ne]))
    (fun x y => by
      by_cases hx : x = 0
      · by_cases hy : y = 0 <;> · simp [hx, hy]
      · by_cases hy : y = 0
        · simp [hx, hy]
        · simp only [hx, hy, support_nonempty_iff, if_neg, not_false_iff, isWf_support]
          by_cases hxy : x + y = 0
          · simp [hxy]
          rw [if_neg hxy, ← WithTop.coe_min, WithTop.coe_le_coe]
          exact min_order_le_order_add hxy)
    fun x y => by
    

Proof state:
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : Ring R
inst✝ : IsDomain R
x y : HahnSeries Γ R
⊢ (fun x => if x = 0 then ⊤ else ↑(order x)) (x * y) =
    (fun x => if x = 0 then ⊤ else ↑(order x)) x + (fun x => if x = 0 then ⊤ else ↑(order x)) y

Next tactic:
by_cases hx : x = 0
/-- The additive valuation on `HahnSeries Γ R`, returning the smallest index at which
  a Hahn Series has a nonzero coefficient, or `⊤` for the 0 series.  -/
def addVal : AddValuation (HahnSeries Γ R) (WithTop Γ) :=
  AddValuation.of (fun x => if x = (0 : HahnSeries Γ R) then (⊤ : WithTop Γ) else x.order)
    (if_pos rfl) ((if_neg one_ne_zero).trans (by simp [order_of_ne]))
    (fun x y => by
      by_cases hx : x = 0
      · by_cases hy : y = 0 <;> · simp [hx, hy]
      · by_cases hy : y = 0
        · simp [hx, hy]
        · simp only [hx, hy, support_nonempty_iff, if_neg, not_false_iff, isWf_support]
          by_cases hxy : x + y = 0
          · simp [hxy]
          rw [if_neg hxy, ← WithTop.coe_min, WithTop.coe_le_coe]
          exact min_order_le_order_add hxy)
    fun x y => by
    by_cases hx : x = 0
    · 

Proof state:
case pos
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : Ring R
inst✝ : IsDomain R
x y : HahnSeries Γ R
hx : x = 0
⊢ (fun x => if x = 0 then ⊤ else ↑(order x)) (x * y) =
    (fun x => if x = 0 then ⊤ else ↑(order x)) x + (fun x => if x = 0 then ⊤ else ↑(order x)) y

Next tactic:
simp [hx]
/-- The additive valuation on `HahnSeries Γ R`, returning the smallest index at which
  a Hahn Series has a nonzero coefficient, or `⊤` for the 0 series.  -/
def addVal : AddValuation (HahnSeries Γ R) (WithTop Γ) :=
  AddValuation.of (fun x => if x = (0 : HahnSeries Γ R) then (⊤ : WithTop Γ) else x.order)
    (if_pos rfl) ((if_neg one_ne_zero).trans (by simp [order_of_ne]))
    (fun x y => by
      by_cases hx : x = 0
      · by_cases hy : y = 0 <;> · simp [hx, hy]
      · by_cases hy : y = 0
        · simp [hx, hy]
        · simp only [hx, hy, support_nonempty_iff, if_neg, not_false_iff, isWf_support]
          by_cases hxy : x + y = 0
          · simp [hxy]
          rw [if_neg hxy, ← WithTop.coe_min, WithTop.coe_le_coe]
          exact min_order_le_order_add hxy)
    fun x y => by
    by_cases hx : x = 0
    · simp [hx]
    

Proof state:
case neg
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : Ring R
inst✝ : IsDomain R
x y : HahnSeries Γ R
hx : ¬x = 0
⊢ (fun x => if x = 0 then ⊤ else ↑(order x)) (x * y) =
    (fun x => if x = 0 then ⊤ else ↑(order x)) x + (fun x => if x = 0 then ⊤ else ↑(order x)) y

Next tactic:
by_cases hy : y = 0
/-- The additive valuation on `HahnSeries Γ R`, returning the smallest index at which
  a Hahn Series has a nonzero coefficient, or `⊤` for the 0 series.  -/
def addVal : AddValuation (HahnSeries Γ R) (WithTop Γ) :=
  AddValuation.of (fun x => if x = (0 : HahnSeries Γ R) then (⊤ : WithTop Γ) else x.order)
    (if_pos rfl) ((if_neg one_ne_zero).trans (by simp [order_of_ne]))
    (fun x y => by
      by_cases hx : x = 0
      · by_cases hy : y = 0 <;> · simp [hx, hy]
      · by_cases hy : y = 0
        · simp [hx, hy]
        · simp only [hx, hy, support_nonempty_iff, if_neg, not_false_iff, isWf_support]
          by_cases hxy : x + y = 0
          · simp [hxy]
          rw [if_neg hxy, ← WithTop.coe_min, WithTop.coe_le_coe]
          exact min_order_le_order_add hxy)
    fun x y => by
    by_cases hx : x = 0
    · simp [hx]
    by_cases hy : y = 0
    · 

Proof state:
case pos
Γ : Type u_1
R : Type u_2
inst✝² : LinearOrderedCancelAddCommMonoid Γ
inst✝¹ : Ring R
inst✝ : IsDomain R
x y : HahnSeries Γ R
hx : ¬x = 0
hy : y = 0
⊢ (fun x => if x = 0 then ⊤ else ↑(order x)) (x * y) =
    (fun x => if x = 0 then ⊤ else ↑(order x)) x + (fun x => if x = 0 then ⊤ else ↑(order x)) y

Next tactic:
simp [hy]