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

Commit b189be7

Browse files
committed
feat(algebra/big_operators): add commute.*_sum_{left,right} lemmas (#13035)
This moves the existing `prod_commute` lemmas into the `commute` namespace for discoverabiliy, and adds the swapped variants. This also fixes an issue where lemmas about `add_commute` were misnamed using `commute`.
1 parent 19448a9 commit b189be7

File tree

4 files changed

+51
-5
lines changed

4 files changed

+51
-5
lines changed

src/algebra/big_operators/basic.lean

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,6 +1305,19 @@ begin
13051305
simp [finset.sum_range_succ', add_comm]
13061306
end
13071307

1308+
lemma _root_.commute.sum_right [non_unital_non_assoc_semiring β] (s : finset α)
1309+
(f : α → β) (b : β) (h : ∀ i ∈ s, commute b (f i)) :
1310+
commute b (∑ i in s, f i) :=
1311+
commute.multiset_sum_right _ _ $ λ b hb, begin
1312+
obtain ⟨i, hi, rfl⟩ := multiset.mem_map.mp hb,
1313+
exact h _ hi
1314+
end
1315+
1316+
lemma _root_.commute.sum_left [non_unital_non_assoc_semiring β] (s : finset α)
1317+
(f : α → β) (b : β) (h : ∀ i ∈ s, commute (f i) b) :
1318+
commute (∑ i in s, f i) b :=
1319+
(commute.sum_right _ _ _ $ λ i hi, (h _ hi).symm).symm
1320+
13081321
section opposite
13091322

13101323
open mul_opposite

src/algebra/big_operators/multiset.lean

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,19 @@ by { convert (m.map f).prod_hom (zpow_group_hom₀ _ : α →* α), rw map_map,
234234
end comm_group_with_zero
235235

236236
section semiring
237-
variables [semiring α] {a : α} {s : multiset ι} {f : ι → α}
237+
variables [non_unital_non_assoc_semiring α] {a : α} {s : multiset ι} {f : ι → α}
238+
239+
lemma _root_.commute.multiset_sum_right (s : multiset α) (a : α) (h : ∀ b ∈ s, commute a b) :
240+
commute a s.sum :=
241+
begin
242+
induction s using quotient.induction_on,
243+
rw [quot_mk_to_coe, coe_sum],
244+
exact commute.list_sum_right _ _ h,
245+
end
246+
247+
lemma _root_.commute.multiset_sum_left (s : multiset α) (b : α) (h : ∀ a ∈ s, commute a b) :
248+
commute s.sum b :=
249+
(commute.multiset_sum_right _ _ $ λ a ha, (h _ ha).symm).symm
238250

239251
lemma sum_map_mul_left : sum (s.map (λ i, a * f i)) = a * sum (s.map f) :=
240252
multiset.induction_on s (by simp) (λ i s ih, by simp [ih, mul_add])

src/data/finset/noncomm_prod.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,14 @@ begin
199199
simp
200200
end
201201

202-
@[to_additive]
202+
@[to_additive noncomm_sum_add_commute]
203203
lemma noncomm_prod_commute (s : multiset α)
204204
(comm : ∀ (x : α), x ∈ s → ∀ (y : α), y ∈ s → commute x y)
205205
(y : α) (h : ∀ (x : α), x ∈ s → commute y x) : commute y (s.noncomm_prod comm) :=
206206
begin
207207
induction s using quotient.induction_on,
208208
simp only [quot_mk_to_coe, noncomm_prod_coe],
209-
exact list.prod_commute _ _ h,
209+
exact commute.list_prod_right _ _ h,
210210
end
211211

212212
end multiset
@@ -282,7 +282,7 @@ begin
282282
simpa using h,
283283
end
284284

285-
@[to_additive]
285+
@[to_additive noncomm_sum_add_commute]
286286
lemma noncomm_prod_commute (s : finset α) (f : α → β)
287287
(comm : ∀ (x : α), x ∈ s → ∀ (y : α), y ∈ s → commute (f x) (f y))
288288
(y : β) (h : ∀ (x : α), x ∈ s → commute y (f x)) : commute y (s.noncomm_prod f comm) :=

src/data/list/big_operators.lean

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ lemma head_mul_tail_prod_of_ne_nil [inhabited M] (l : list M) (h : l ≠ []) :
161161
by cases l; [contradiction, simp]
162162

163163
@[to_additive]
164-
lemma prod_commute (l : list M) (y : M) (h : ∀ (x ∈ l), commute y x) : commute y l.prod :=
164+
lemma _root_.commute.list_prod_right (l : list M) (y : M) (h : ∀ (x ∈ l), commute y x) :
165+
commute y l.prod :=
165166
begin
166167
induction l with z l IH,
167168
{ simp },
@@ -170,6 +171,26 @@ begin
170171
exact commute.mul_right h.1 (IH h.2), }
171172
end
172173

174+
@[to_additive]
175+
lemma _root_.commute.list_prod_left (l : list M) (y : M) (h : ∀ (x ∈ l), commute x y) :
176+
commute l.prod y :=
177+
(commute.list_prod_right _ _ $ λ x hx, (h _ hx).symm).symm
178+
179+
lemma _root_.commute.list_sum_right [non_unital_non_assoc_semiring R] (a : R) (l : list R)
180+
(h : ∀ b ∈ l, commute a b) :
181+
commute a l.sum :=
182+
begin
183+
induction l with x xs ih,
184+
{ exact commute.zero_right _, },
185+
{ rw sum_cons,
186+
exact (h _ $ mem_cons_self _ _).add_right (ih $ λ j hj, h _ $ mem_cons_of_mem _ hj) }
187+
end
188+
189+
lemma _root_.commute.list_sum_left [non_unital_non_assoc_semiring R] (b : R) (l : list R)
190+
(h : ∀ a ∈ l, commute a b) :
191+
commute l.sum b :=
192+
(commute.list_sum_right _ _ $ λ x hx, (h _ hx).symm).symm
193+
173194
@[to_additive sum_le_sum] lemma prod_le_prod' [preorder M]
174195
[covariant_class M M (function.swap (*)) (≤)] [covariant_class M M (*) (≤)]
175196
{l : list ι} {f g : ι → M} (h : ∀ i ∈ l, f i ≤ g i) :

0 commit comments

Comments
 (0)