Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit f952dd1

Browse files
committed
refactor(algebra/big_operators/finprod, ring_theory/hahn_series): summable families now use finsum (#7388)
Adds a few `finprod/finsum` lemmas Uses them to refactor `hahn_series.summable_family` to use `finsum`
1 parent db89082 commit f952dd1

File tree

2 files changed

+101
-112
lines changed

2 files changed

+101
-112
lines changed

src/algebra/big_operators/finprod.lean

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,4 +667,37 @@ begin
667667
simp [hx]
668668
end
669669

670+
@[to_additive] lemma finprod_prod_comm (s : finset β) (f : α → β → M)
671+
(h : ∀ b ∈ s, (mul_support (λ a, f a b)).finite) :
672+
∏ᶠ a : α, ∏ b in s, f a b = ∏ b in s, ∏ᶠ a : α, f a b :=
673+
begin
674+
have hU : mul_support (λ a, ∏ b in s, f a b) ⊆
675+
(s.finite_to_set.bUnion (λ b hb, h b (finset.mem_coe.1 hb))).to_finset,
676+
{ rw finite.coe_to_finset,
677+
intros x hx,
678+
simp only [exists_prop, mem_Union, ne.def, mem_mul_support, finset.mem_coe],
679+
contrapose! hx,
680+
rw [mem_mul_support, not_not, finset.prod_congr rfl hx, finset.prod_const_one] },
681+
rw [finprod_eq_prod_of_mul_support_subset _ hU, finset.prod_comm],
682+
refine finset.prod_congr rfl (λ b hb, (finprod_eq_prod_of_mul_support_subset _ _).symm),
683+
intros a ha,
684+
simp only [finite.coe_to_finset, mem_Union],
685+
exact ⟨b, hb, ha⟩
686+
end
687+
688+
@[to_additive] lemma prod_finprod_comm (s : finset α) (f : α → β → M)
689+
(h : ∀ a ∈ s, (mul_support (f a)).finite) :
690+
∏ a in s, ∏ᶠ b : β, f a b = ∏ᶠ b : β, ∏ a in s, f a b :=
691+
(finprod_prod_comm s (λ b a, f a b) h).symm
692+
693+
lemma mul_finsum {R : Type*} [semiring R] (f : α → R) (r : R)
694+
(h : (function.support f).finite) :
695+
r * ∑ᶠ a : α, f a = ∑ᶠ a : α, r * f a :=
696+
(add_monoid_hom.mul_left r).map_finsum h
697+
698+
lemma finsum_mul {R : Type*} [semiring R] (f : α → R) (r : R)
699+
(h : (function.support f).finite) :
700+
(∑ᶠ a : α, f a) * r = ∑ᶠ a : α, f a * r :=
701+
(add_monoid_hom.mul_right r).map_finsum h
702+
670703
end type

src/ring_theory/hahn_series.lean

Lines changed: 68 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Aaron Anderson
55
-/
66
import order.well_founded_set
7-
import algebra.big_operators
7+
import algebra.big_operators.finprod
88
import ring_theory.valuation.basic
99
import algebra.module.pi
1010
import ring_theory.power_series.basic
@@ -743,8 +743,7 @@ variables (Γ) (R) [partial_order Γ] [add_comm_monoid R]
743743
structure summable_family (α : Type*) :=
744744
(to_fun : α → hahn_series Γ R)
745745
(is_pwo_Union_support' : set.is_pwo (⋃ (a : α), (to_fun a).support))
746-
(co_support : Γ → finset α)
747-
(mem_co_support' : ∀ (a : α) (g : Γ), a ∈ co_support g ↔ (to_fun a).coeff g ≠ 0)
746+
(finite_co_support' : ∀ (g : Γ), ({a | (to_fun a).coeff g ≠ 0}).finite)
748747

749748
end
750749

@@ -759,19 +758,15 @@ instance : has_coe_to_fun (summable_family Γ R α) :=
759758
lemma is_pwo_Union_support (s : summable_family Γ R α) : set.is_pwo (⋃ (a : α), (s a).support) :=
760759
s.is_pwo_Union_support'
761760

762-
@[simp]
763-
lemma mem_co_support {s : summable_family Γ R α} {a : α} {g : Γ} :
764-
a ∈ s.co_support g ↔ (s a).coeff g ≠ 0 := mem_co_support' _ _ _
761+
lemma finite_co_support (s : summable_family Γ R α) (g : Γ) :
762+
(function.support (λ a, (s a).coeff g)).finite :=
763+
s.finite_co_support' g
765764

766765
lemma coe_injective : @function.injective (summable_family Γ R α) (α → hahn_series Γ R) coe_fn
767-
| ⟨f1, hU1, c1, hc1⟩ ⟨f2, hU2, c2, hc2⟩ h :=
766+
| ⟨f1, hU1, hf1⟩ ⟨f2, hU2, hf2⟩ h :=
768767
begin
769768
change f1 = f2 at h,
770769
subst h,
771-
simp only,
772-
refine ⟨rfl, _⟩,
773-
ext g a,
774-
rw [hc1, hc2]
775770
end
776771

777772
@[ext]
@@ -784,18 +779,16 @@ instance : has_add (summable_family Γ R α) :=
784779
rw ← set.Union_union_distrib,
785780
exact set.Union_subset_Union (λ a, support_add_subset)
786781
end),
787-
co_support := λ g, ((x.co_support g) ∪ (y.co_support g)).filter
788-
(λ a, (x a).coeff g + (y a).coeff g ≠ 0),
789-
mem_co_support' := λ a g, begin
790-
simp only [mem_union, mem_filter, mem_co_support, and_iff_right_iff_imp,
791-
pi.add_apply, ne.def, add_coeff'],
792-
contrapose!,
793-
rintro ⟨hx, hy⟩,
794-
simp [hx, hy],
782+
finite_co_support' := λ g, ((x.finite_co_support g).union (y.finite_co_support g)).subset begin
783+
intros a ha,
784+
change (x a).coeff g + (y a).coeff g ≠ 0 at ha,
785+
rw [set.mem_union, function.mem_support, function.mem_support],
786+
contrapose! ha,
787+
rw [ha.1, ha.2, add_zero]
795788
end }⟩
796789

797790
instance : has_zero (summable_family Γ R α) :=
798-
⟨⟨0, by simp, λ _, ∅, by simp⟩⟩
791+
⟨⟨0, by simp, by simp⟩⟩
799792

800793
instance : inhabited (summable_family Γ R α) := ⟨0
801794

@@ -820,46 +813,34 @@ instance : add_comm_monoid (summable_family Γ R α) :=
820813
/-- The infinite sum of a `summable_family` of Hahn series. -/
821814
def hsum (s : summable_family Γ R α) :
822815
hahn_series Γ R :=
823-
{ coeff := λ g, ∑ i in s.co_support g, (s i).coeff g,
816+
{ coeff := λ g, ∑ᶠ i, (s i).coeff g,
824817
is_pwo_support' := s.is_pwo_Union_support.mono (λ g, begin
825818
contrapose,
826819
rw [set.mem_Union, not_exists, function.mem_support, not_not],
827820
simp_rw [mem_support, not_not],
828-
exact λ h, sum_eq_zero (λ a ha, h _),
821+
intro h,
822+
rw [finsum_congr h, finsum_zero],
829823
end) }
830824

831825
@[simp]
832826
lemma hsum_coeff {s : summable_family Γ R α} {g : Γ} :
833-
s.hsum.coeff g = ∑ i in s.co_support g, (s i).coeff g := rfl
827+
s.hsum.coeff g = ∑ᶠ i, (s i).coeff g := rfl
834828

835829
lemma support_hsum_subset {s : summable_family Γ R α} :
836830
s.hsum.support ⊆ ⋃ (a : α), (s a).support :=
837831
λ g hg, begin
838-
rw [mem_support, hsum_coeff] at hg,
832+
rw [mem_support, hsum_coeff, finsum_eq_sum _ (s.finite_co_support _)] at hg,
839833
obtain ⟨a, h1, h2⟩ := exists_ne_zero_of_sum_ne_zero hg,
840834
rw [set.mem_Union],
841835
exact ⟨a, h2⟩,
842836
end
843837

844-
lemma co_support_add_subset {s t : summable_family Γ R α} {g : Γ} :
845-
(s + t).co_support g ⊆ s.co_support g ∪ t.co_support g :=
846-
λ a ha, begin
847-
rw mem_co_support at ha,
848-
rw [mem_union, mem_co_support, mem_co_support],
849-
contrapose! ha,
850-
obtain ⟨hs, ht⟩ := ha,
851-
simp [hs, ht],
852-
end
853-
854838
@[simp]
855839
lemma hsum_add {s t : summable_family Γ R α} : (s + t).hsum = s.hsum + t.hsum :=
856840
begin
857841
ext g,
858-
simp only [add_apply, pi.add_apply, hsum_coeff, ne.def, add_coeff'],
859-
rw [sum_subset co_support_add_subset, finset.sum_add_distrib,
860-
← sum_subset (subset_union_left _ _), ← sum_subset (subset_union_right _ _)];
861-
{ intros x h1 h2,
862-
rwa [mem_co_support, not_not] at h2, }
842+
simp only [hsum_coeff, add_coeff, add_apply],
843+
exact finsum_add_distrib (s.finite_co_support _) (t.finite_co_support _)
863844
end
864845

865846
end add_comm_monoid
@@ -870,8 +851,8 @@ variables [partial_order Γ] [add_comm_group R] {α : Type*} {s t : summable_fam
870851
instance : add_comm_group (summable_family Γ R α) :=
871852
{ neg := λ s, { to_fun := λ a, - s a,
872853
is_pwo_Union_support' := by { simp_rw [support_neg], exact s.is_pwo_Union_support' },
873-
co_support := s.co_support,
874-
mem_co_support' := by simp },
854+
finite_co_support' := λ g, by { simp only [neg_coeff', pi.neg_apply, ne.def, neg_eq_zero],
855+
exact s.finite_co_support g } },
875856
add_left_neg := λ a, by { ext, apply add_left_neg },
876857
.. summable_family.add_comm_monoid }
877858

@@ -899,22 +880,15 @@ instance : has_scalar (hahn_series Γ R) (summable_family Γ R α) :=
899880
simp only [set.mem_Union, exists_imp_distrib],
900881
exact λ a ha, (set.add_subset_add (set.subset.refl _) (set.subset_Union _ a)) ha,
901882
end,
902-
co_support := λ g, ((add_antidiagonal x.is_pwo_support s.is_pwo_Union_support g).bUnion
903-
(λ ij, s.co_support ij.snd)).filter (λ a, (x * (s a)).coeff g ≠ 0),
904-
mem_co_support' := λ a g, begin
905-
rw [mem_filter],
906-
apply and_iff_right_of_imp,
907-
simp only [mem_bUnion, exists_prop, set.mem_Union, mem_add_antidiagonal, mem_co_support,
908-
mul_coeff, ne.def, mem_support, is_pwo_support, prod.exists],
909-
contrapose!,
910-
intro h,
911-
rw sum_eq_zero,
912-
rintros ⟨i, j⟩ hij,
913-
rw [mem_add_antidiagonal, mem_support] at hij,
914-
by_cases he : ∃ (b : α), (s b).coeff j ≠ 0,
915-
{ rw [h i j ⟨hij.1, hij.2.1, he⟩, mul_zero] },
916-
simp_rw [not_exists, ne.def, not_not] at he,
917-
rw [he a, mul_zero],
883+
finite_co_support' := λ g, begin
884+
refine ((add_antidiagonal x.is_pwo_support s.is_pwo_Union_support g).finite_to_set.bUnion
885+
(λ ij hij, _)).subset (λ a ha, _),
886+
{ exact λ ij hij, function.support (λ a, (s a).coeff ij.2) },
887+
{ apply s.finite_co_support },
888+
{ obtain ⟨i, j, hi, hj, rfl⟩ := support_mul_subset_add_support ha,
889+
simp only [exists_prop, set.mem_Union, mem_add_antidiagonal,
890+
mul_coeff, ne.def, mem_support, is_pwo_support, prod.exists],
891+
refine ⟨i, j, mem_coe.2 (mem_add_antidiagonal.2 ⟨rfl, hi, set.mem_Union.2 ⟨a, hj⟩⟩), hj⟩, }
918892
end } }
919893

920894
@[simp]
@@ -935,47 +909,31 @@ lemma hsum_smul {x : hahn_series Γ R} {s : summable_family Γ R α} :
935909
(x • s).hsum = x * s.hsum :=
936910
begin
937911
ext g,
938-
rw [mul_coeff, sum_subset (add_antidiagonal_mono_right support_hsum_subset)],
939-
{ rw hsum_coeff,
940-
have h : (x • s).co_support g ⊆ (add_antidiagonal x.is_pwo_support s.is_pwo_Union_support
941-
g).bUnion (λ ij, s.co_support ij.snd),
942-
{ intros a ha,
943-
rw [mem_co_support, smul_apply, mul_coeff] at ha,
944-
obtain ⟨ij, h1, h2⟩ := exists_ne_zero_of_sum_ne_zero ha,
945-
rw mem_bUnion,
946-
exact ⟨ij, add_antidiagonal_mono_right (set.subset_Union _ a) h1,
947-
mem_co_support.2 (right_ne_zero_of_mul h2)⟩ },
948-
refine eq.trans (sum_subset h _) _,
949-
{ apply is_pwo_Union_support },
950-
{ intros a h1 h2,
951-
contrapose! h2,
952-
rw [mem_co_support],
953-
exact h2 },
954-
have h' : ∀ a, ((x • s) a).coeff g =
955-
∑ (ij : Γ × Γ) in add_antidiagonal x.is_pwo_support s.is_pwo_Union_support g,
956-
x.coeff ij.fst * (s a).coeff ij.snd,
957-
{ intro a,
958-
rw [smul_apply, mul_coeff],
959-
apply sum_subset (add_antidiagonal_mono_right
960-
(set.subset_Union (support ∘ s) a)),
961-
intros ij h1 h2,
962-
rw [mem_add_antidiagonal] at *,
963-
have h : ¬ ij.snd ∈ (s a).support := λ c, h2 ⟨h1.1, h1.2.1, c⟩,
964-
rw [mem_support, not_not] at h,
965-
rw [h, mul_zero] },
966-
rw [sum_congr rfl (λ a ha, h' a), sum_comm],
967-
refine sum_congr rfl (λ ij hij, _),
968-
rw [hsum_coeff, ← mul_sum],
969-
apply congr rfl (sum_subset (subset_bUnion_of_mem _ hij) _).symm,
970-
intros a h1 h2,
971-
contrapose! h2,
972-
rw [mem_co_support],
973-
exact h2 },
974-
{ intros ij h1 h2,
912+
simp only [mul_coeff, hsum_coeff, smul_apply],
913+
have h : ∀ i, (s i).support ⊆ ⋃ j, (s j).support := set.subset_Union _,
914+
refine (eq.trans (finsum_congr (λ a, _))
915+
(finsum_sum_comm (add_antidiagonal x.is_pwo_support s.is_pwo_Union_support g)
916+
(λ i ij, x.coeff (prod.fst ij) * (s i).coeff ij.snd) _)).trans _,
917+
{ refine sum_subset (add_antidiagonal_mono_right (set.subset_Union _ a)) _,
918+
rintro ⟨i, j⟩ hU ha,
975919
rw mem_add_antidiagonal at *,
976-
have h : ¬ ij.snd ∈ s.hsum.support := λ con, h2 ⟨h1.1, h1.2.1, con⟩,
977-
rw [mem_support, not_not] at h,
978-
simp [h] },
920+
rw [not_not.1 (λ con, ha ⟨hU.1, hU.2.1, con⟩), mul_zero] },
921+
{ rintro ⟨i, j⟩ hij,
922+
refine (s.finite_co_support j).subset _,
923+
simp_rw [function.support_subset_iff', function.mem_support, not_not],
924+
intros a ha,
925+
rw [ha, mul_zero] },
926+
{ refine (sum_congr rfl _).trans (sum_subset (add_antidiagonal_mono_right _) _).symm,
927+
{ rintro ⟨i, j⟩ hij,
928+
rw mul_finsum,
929+
apply s.finite_co_support, },
930+
{ intros x hx,
931+
simp only [set.mem_Union, ne.def, mem_support],
932+
contrapose! hx,
933+
simp [hx] },
934+
{ rintro ⟨i, j⟩ hU ha,
935+
rw mem_add_antidiagonal at *,
936+
rw [← hsum_coeff, not_not.1 (λ con, ha ⟨hU.1, hU.2.1, con⟩), mul_zero] } }
979937
end
980938

981939
/-- The summation of a `summable_family` as a `linear_map`. -/
@@ -1003,31 +961,29 @@ def of_finsupp (f : α →₀ (hahn_series Γ R)) :
1003961
have h : (λ i, (f i).support) a ≤ _ := le_sup haf,
1004962
exact h ha,
1005963
end,
1006-
co_support := λ g, f.support.filter (λ a, (f a).coeff g ≠ 0),
1007-
mem_co_support' := λ a g, begin
1008-
simp only [mem_filter, and_iff_right_iff_imp, finsupp.mem_support_iff, ne.def],
1009-
contrapose!,
1010-
intro h,
1011-
simp [h]
964+
finite_co_support' := λ g, begin
965+
refine f.support.finite_to_set.subset (λ a ha, _),
966+
simp only [coeff.add_monoid_hom_apply, mem_coe, finsupp.mem_support_iff,
967+
ne.def, function.mem_support],
968+
contrapose! ha,
969+
simp [ha]
1012970
end }
1013971

1014972
@[simp]
1015973
lemma coe_of_finsupp {f : α →₀ (hahn_series Γ R)} : ⇑(summable_family.of_finsupp f) = f := rfl
1016974

1017-
@[simp]
1018-
lemma co_support_of_finsupp {f : α →₀ (hahn_series Γ R)} {g : Γ} :
1019-
(summable_family.of_finsupp f).co_support g = f.support.filter (λ a, (f a).coeff g ≠ 0) := rfl
1020-
1021975
@[simp]
1022976
lemma hsum_of_finsupp {f : α →₀ (hahn_series Γ R)} :
1023977
(of_finsupp f).hsum = f.sum (λ a, id) :=
1024978
begin
1025979
ext g,
1026-
simp only [filter_congr_decidable, hsum_coeff, coe_of_finsupp, ne.def, co_support_of_finsupp],
1027-
rw [sum_filter_ne_zero],
1028-
simp_rw [← coeff.add_monoid_hom_apply],
1029-
rw ← add_monoid_hom.map_sum,
1030-
refl
980+
simp only [hsum_coeff, coe_of_finsupp, finsupp.sum, ne.def],
981+
simp_rw [← coeff.add_monoid_hom_apply, id.def],
982+
rw [add_monoid_hom.map_sum, finsum_eq_sum_of_support_subset],
983+
intros x h,
984+
simp only [coeff.add_monoid_hom_apply, mem_coe, finsupp.mem_support_iff, ne.def],
985+
contrapose! h,
986+
simp [h]
1031987
end
1032988

1033989
end of_finsupp

0 commit comments

Comments
 (0)