Skip to content

Commit

Permalink
rm domain hypothesis
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottCarnahan committed Feb 25, 2025
1 parent 69f2481 commit 9c54771
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 15 deletions.
44 changes: 44 additions & 0 deletions Mathlib/RingTheory/HahnSeries/Addition.lean
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,50 @@ theorem leadingCoeff_add_eq_right {Γ} [LinearOrder Γ] {x y : HahnSeries Γ R}
(x := addOppositeEquiv.symm (.op y))
(y := addOppositeEquiv.symm (.op x))

theorem ne_zero_of_eq_add_single [Zero Γ] {x y : HahnSeries Γ R}
(hxy : x = y + single x.order x.leadingCoeff) (hy : y ≠ 0) : x ≠ 0 := by
by_contra h
simp only [h, order_zero, leadingCoeff_zero, map_zero, add_zero] at hxy
exact hy hxy.symm

theorem coeff_order_of_eq_add_single {R} [AddCancelCommMonoid R] [Zero Γ] {x y : HahnSeries Γ R}
(hxy : x = y + single x.order x.leadingCoeff) (h : x ≠ 0) :
y.coeff x.order = 0 := by
let xo := x.isWF_support.min (support_nonempty_iff.2 h)
have : xo = x.order := (order_of_ne h).symm
have hx : x.coeff xo = y.coeff xo + (single x.order x.leadingCoeff).coeff xo := by
nth_rw 1 [hxy, coeff_add]
have hxx :
(single x.order x.leadingCoeff).coeff xo = (single x.order x.leadingCoeff).leadingCoeff := by
simp [leadingCoeff_of_single, coeff_single, this]
rw [← (leadingCoeff_of_ne h), hxx, leadingCoeff_of_single, self_eq_add_left, this] at hx
exact hx

theorem order_lt_order_of_eq_add_single {R} {Γ} [LinearOrder Γ] [Zero Γ] [AddCancelCommMonoid R]
{x y : HahnSeries Γ R} (hxy : x = y + single x.order x.leadingCoeff) (hy : y ≠ 0) :
x.order < y.order := by
have : x.order ≠ y.order := by
intro h
have hyne : single y.order y.leadingCoeff ≠ 0 := single_ne_zero <| leadingCoeff_ne_iff.mpr hy
rw [leadingCoeff_eq, ← h, coeff_order_of_eq_add_single hxy <| ne_zero_of_eq_add_single hxy hy,
single_eq_zero] at hyne
exact hyne rfl
refine lt_of_le_of_ne ?_ this
simp only [order, ne_zero_of_eq_add_single hxy hy, ↓reduceDIte, hy]
have : y.support ⊆ x.support := by
intro g hg
by_cases hgx : g = x.order
· refine (mem_support x g).mpr ?_
have : x.coeff x.order ≠ 0 := coeff_order_ne_zero <| ne_zero_of_eq_add_single hxy hy
rwa [← hgx] at this
· have : x.coeff g = (y + (single x.order) x.leadingCoeff).coeff g := by rw [← hxy]
rw [coeff_add, coeff_single_of_ne hgx, add_zero] at this
simpa [this] using hg
exact Set.IsWF.min_le_min_of_subset this

--rw [← WithTop.coe_lt_coe, order_eq_orderTop_of_ne hy, order_eq_orderTop_of_ne]


/-- `single` as an additive monoid/group homomorphism -/
@[simps!]
def single.addMonoidHom (a : Γ) : R →+ HahnSeries Γ R :=
Expand Down
37 changes: 33 additions & 4 deletions Mathlib/RingTheory/HahnSeries/Multiplication.lean
Original file line number Diff line number Diff line change
Expand Up @@ -486,20 +486,49 @@ theorem support_mul_subset_add_support [NonUnitalNonAssocSemiring R] {x y : Hahn
rw [← of_symm_smul_of_eq_mul, ← vadd_eq_add]
exact HahnModule.support_smul_subset_vadd_support

theorem coeff_mul_order_add_order {Γ} [LinearOrderedCancelAddCommMonoid Γ]
[NonUnitalNonAssocSemiring R] (x y : HahnSeries Γ R) :
section orderLemmas

variable {Γ : Type*} [LinearOrderedCancelAddCommMonoid Γ] [NonUnitalNonAssocSemiring R]

theorem coeff_mul_order_add_order (x y : HahnSeries Γ R) :
(x * y).coeff (x.order + y.order) = x.leadingCoeff * y.leadingCoeff := by
simp only [← of_symm_smul_of_eq_mul]
exact HahnModule.coeff_smul_order_add_order x y

@[deprecated (since := "2025-01-31")] alias mul_coeff_order_add_order := coeff_mul_order_add_order

theorem orderTop_add_le_mul {Γ} [LinearOrderedCancelAddCommMonoid Γ]
[NonUnitalNonAssocSemiring R] {x y : HahnSeries Γ R} :
theorem orderTop_add_le_mul {x y : HahnSeries Γ R} :
x.orderTop + y.orderTop ≤ (x * y).orderTop := by
rw [← smul_eq_mul]
exact HahnModule.orderTop_vAdd_le_orderTop_smul fun i j ↦ rfl

theorem order_mul_of_nonzero {x y : HahnSeries Γ R}
(h : x.leadingCoeff * y.leadingCoeff ≠ 0) : (x * y).order = x.order + y.order := by
have hx : x.leadingCoeff ≠ 0 := by aesop
have hy : y.leadingCoeff ≠ 0 := by aesop
have hxy : (x * y).coeff (x.order + y.order) ≠ 0 :=
ne_of_eq_of_ne (coeff_mul_order_add_order x y) h
refine le_antisymm (order_le_of_coeff_ne_zero
(Eq.mpr (congrArg (fun _a ↦ _a ≠ 0) (coeff_mul_order_add_order x y)) h)) ?_
rw [order_of_ne <| leadingCoeff_ne_iff.mp hx, order_of_ne <| leadingCoeff_ne_iff.mp hy,
order_of_ne <| ne_zero_of_coeff_ne_zero hxy, ← Set.IsWF.min_add]
exact Set.IsWF.min_le_min_of_subset support_mul_subset_add_support

theorem order_mul_single_of_isRegular {g : Γ} {r : R} (hr : IsRegular r)
{x : HahnSeries Γ R} (hx : x ≠ 0) : (((single g) r) * x).order = g + x.order := by
have : Nontrivial R := by
by_contra h
have : Subsingleton R := not_nontrivial_iff_subsingleton.mp h
have : Subsingleton (HahnSeries Γ R) := instSubsingleton
apply hx <| Subsingleton.eq_zero x
have hrx : ((single g) r).leadingCoeff * x.leadingCoeff ≠ 0 := by
rw [leadingCoeff_of_single]
intro h
apply (leadingCoeff_ne_iff.mpr hx) ((IsLeftRegular.mul_left_eq_zero_iff hr.left).mp h)
rw [order_mul_of_nonzero hrx, order_single <| IsRegular.ne_zero hr]

end orderLemmas

private theorem mul_assoc' [NonUnitalSemiring R] (x y z : HahnSeries Γ R) :
x * y * z = x * (y * z) := by
ext b
Expand Down
61 changes: 50 additions & 11 deletions Mathlib/RingTheory/HahnSeries/Summable.lean
Original file line number Diff line number Diff line change
Expand Up @@ -672,13 +672,51 @@ end SummableFamily

section Inversion

variable [LinearOrderedAddCommGroup Γ]
section CommRing

variable [LinearOrderedCancelAddCommMonoid Γ] [CommRing R]

theorem one_minus_single_neg_mul {x y : HahnSeries Γ R} {r : R} (hr : r * x.leadingCoeff = 1)
(hxy : x = y + single x.order x.leadingCoeff) (hxo : IsAddUnit x.order) :
1 - single (IsAddUnit.addUnit hxo).neg r * x = -(single (IsAddUnit.addUnit hxo).neg r * y) := by
nth_rw 2 [hxy]
rw [mul_add, single_mul_single, hr, AddUnits.neg_eq_val_neg, IsAddUnit.val_neg_add,
sub_add_eq_sub_sub_swap, sub_eq_neg_self, sub_eq_zero_of_eq single_zero_one.symm]

theorem unit_aux (x : HahnSeries Γ R) {r : R} (hr : r * x.leadingCoeff = 1)
(hxo : IsAddUnit x.order) : 0 < (1 - single (IsAddUnit.addUnit hxo).neg r * x).orderTop := by
let y := (x - single x.order x.leadingCoeff)
by_cases hy : y = 0
· have hrx : (single (IsAddUnit.addUnit hxo).neg) r * x = 1 := by
nth_rw 2 [eq_of_sub_eq_zero hy] -- get a bad loop without `nth_rw`
simp only [AddUnits.neg_eq_val_neg, ← leadingCoeff_eq, single_mul_single,
IsAddUnit.val_neg_add, hr, single_zero_one]
simp only [hrx, sub_self, orderTop_zero, WithTop.top_pos]
have hr' : IsRegular r := IsUnit.isRegular <| isUnit_of_mul_eq_one r x.leadingCoeff hr
have hy' : 0 < (single (IsAddUnit.addUnit hxo).neg r * y).order := by
rw [(order_mul_single_of_isRegular hr' hy)]
refine pos_of_lt_add_right (a := x.order) ?_
rw [← add_assoc, add_comm x.order, AddUnits.neg_eq_val_neg, IsAddUnit.val_neg_add, zero_add]
exact order_lt_order_of_eq_add_single (sub_add_cancel x _).symm hy
rw [one_minus_single_neg_mul hr (sub_add_cancel x _).symm, orderTop_neg]
exact zero_lt_orderTop_of_order hy'

theorem isUnit_of_isUnit_leadingCoeff_AddUnitOrder {x : HahnSeries Γ R} (hx : IsUnit x.leadingCoeff)
(hxo : IsAddUnit x.order) : IsUnit x := by
let ⟨⟨u, i, ui, iu⟩, h⟩ := hx
rw [Units.val_mk] at h
rw [h] at iu
have h' := SummableFamily.one_sub_self_mul_hsum_powers (unit_aux x iu hxo)
rw [sub_sub_cancel] at h'
exact isUnit_of_mul_isUnit_right (isUnit_of_mul_eq_one _ _ h')

end CommRing

section IsDomain

variable [CommRing R] [IsDomain R]
variable [LinearOrderedAddCommGroup Γ] [CommRing R] [IsDomain R]

theorem unit_aux (x : HahnSeries Γ R) {r : R} (hr : r * x.leadingCoeff = 1) :
theorem unit_aux' (x : HahnSeries Γ R) {r : R} (hr : r * x.leadingCoeff = 1) :
0 < (1 - single (-x.order) r * x).orderTop := by
by_cases hx : x = 0; · simp_all [hx]
have hrz : r ≠ 0 := by
Expand Down Expand Up @@ -707,28 +745,29 @@ theorem isUnit_iff {x : HahnSeries Γ R} : IsUnit x ↔ IsUnit (x.leadingCoeff)
((coeff_mul_order_add_order u i).symm.trans ?_)
rw [ui, coeff_one, 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)
· rintro ⟨⟨u, i, ui, iu⟩, hx⟩
rw [Units.val_mk] at hx
rw [hx] at iu
have h :=
SummableFamily.one_sub_self_mul_hsum_powers (unit_aux x iu (AddGroup.isAddUnit x.order))
rw [sub_sub_cancel] at h
exact isUnit_of_mul_isUnit_right (isUnit_of_mul_eq_one _ _ h)

end IsDomain

open Classical in
instance instField [Field R] : Field (HahnSeries Γ R) where
instance instField [LinearOrderedAddCommGroup Γ] [Field R] : Field (HahnSeries Γ R) where
__ : IsDomain (HahnSeries Γ R) := inferInstance
inv x :=
if x0 : x = 0 then 0
else
(single (-x.order)) (x.leadingCoeff)⁻¹ *
(SummableFamily.powers _ (unit_aux x (inv_mul_cancel₀ (leadingCoeff_ne_iff.mpr x0)))).hsum
(single (IsAddUnit.addUnit (AddGroup.isAddUnit x.order)).neg) (x.leadingCoeff)⁻¹ *
(SummableFamily.powers _ (unit_aux x (inv_mul_cancel₀ (leadingCoeff_ne_iff.mpr x0)) _)).hsum
inv_zero := dif_pos rfl
mul_inv_cancel x x0 := (congr rfl (dif_neg x0)).trans <| by
have h :=
SummableFamily.one_sub_self_mul_hsum_powers
(unit_aux x (inv_mul_cancel₀ (leadingCoeff_ne_iff.mpr x0)))
(unit_aux x (inv_mul_cancel₀ (leadingCoeff_ne_iff.mpr x0)) (AddGroup.isAddUnit x.order))
rw [sub_sub_cancel] at h
rw [← mul_assoc, mul_comm x, h]
nnqsmul := _
Expand Down

0 comments on commit 9c54771

Please sign in to comment.