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

Commit 3126384

Browse files
committed
refactor(data/finset/noncomm_prod): Use set.pairwise (#16859)
Redefine the various `noncomm_prod`s using `set.pairwise`. This has the advantage of having a solid API around monotonicity in the set or in the relation and avoiding checking the trivial `i = j` case.
1 parent 7121691 commit 3126384

File tree

13 files changed

+160
-237
lines changed

13 files changed

+160
-237
lines changed

src/algebra/group/commute.lean

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ protected lemma symm {a b : S} (h : commute a b) : commute b a := eq.symm h
5454
protected theorem symm_iff {a b : S} : commute a b ↔ commute b a :=
5555
⟨commute.symm, commute.symm⟩
5656

57+
@[to_additive] instance : is_refl S commute := ⟨commute.refl⟩
58+
59+
-- This instance is useful for `finset.noncomm_prod`
60+
@[to_additive] instance on_is_refl {f : G → S} : is_refl G (λ a b, commute (f a) (f b)) :=
61+
⟨λ _, commute.refl _⟩
62+
5763
end has_mul
5864

5965
section semigroup

src/analysis/normed_space/exponential.lean

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -452,18 +452,17 @@ end
452452
/-- In a Banach-algebra `𝔸` over `𝕂 = ℝ` or `𝕂 = ℂ`, if a family of elements `f i` mutually
453453
commute then `exp 𝕂 (∑ i, f i) = ∏ i, exp 𝕂 (f i)`. -/
454454
lemma exp_sum_of_commute {ι} (s : finset ι) (f : ι → 𝔸)
455-
(h : ∀ (i ∈ s) (j ∈ s), commute (f i) (f j)) :
455+
(h : (s : set ι).pairwise $ λ i j, commute (f i) (f j)) :
456456
exp 𝕂 (∑ i in s, f i) = s.noncomm_prod (λ i, exp 𝕂 (f i))
457-
(λ i hi j hj, (h i hi j hj).exp 𝕂) :=
457+
(λ i hi j hj _, (h.of_refl hi hj).exp 𝕂) :=
458458
begin
459459
classical,
460460
induction s using finset.induction_on with a s ha ih,
461461
{ simp },
462462
rw [finset.noncomm_prod_insert_of_not_mem _ _ _ _ ha, finset.sum_insert ha,
463-
exp_add_of_commute, ih],
464-
refine commute.sum_right _ _ _ _,
465-
intros i hi,
466-
exact h _ (finset.mem_insert_self _ _) _ (finset.mem_insert_of_mem hi),
463+
exp_add_of_commute, ih (h.mono $ finset.subset_insert _ _)],
464+
refine commute.sum_right _ _ _ (λ i hi, _),
465+
exact h.of_refl (finset.mem_insert_self _ _) (finset.mem_insert_of_mem hi),
467466
end
468467

469468
lemma exp_nsmul (n : ℕ) (x : 𝔸) :
@@ -591,7 +590,7 @@ lemma exp_sum {ι} (s : finset ι) (f : ι → 𝔸) :
591590
exp 𝕂 (∑ i in s, f i) = ∏ i in s, exp 𝕂 (f i) :=
592591
begin
593592
rw [exp_sum_of_commute, finset.noncomm_prod_eq_prod],
594-
exact λ i hi j hj, commute.all _ _,
593+
exact λ i hi j hj _, commute.all _ _,
595594
end
596595

597596
end comm_algebra

src/analysis/normed_space/matrix_exponential.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ begin
149149
end
150150

151151
lemma exp_sum_of_commute {ι} (s : finset ι) (f : ι → matrix m m 𝔸)
152-
(h : ∀ (i ∈ s) (j ∈ s), commute (f i) (f j)) :
152+
(h : (s : set ι).pairwise $ λ i j, commute (f i) (f j)) :
153153
exp 𝕂 (∑ i in s, f i) = s.noncomm_prod (λ i, exp 𝕂 (f i))
154-
(λ i hi j hj, (h i hi j hj).exp 𝕂) :=
154+
(λ i hi j hj _, (h.of_refl hi hj).exp 𝕂) :=
155155
begin
156156
letI : semi_normed_ring (matrix m m 𝔸) := matrix.linfty_op_semi_normed_ring,
157157
letI : normed_ring (matrix m m 𝔸) := matrix.linfty_op_normed_ring,

src/data/finset/basic.lean

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2025,6 +2025,9 @@ def to_finset (l : list α) : finset α := multiset.to_finset l
20252025
lemma to_finset_eq (n : nodup l) : @finset.mk α l n = l.to_finset := multiset.to_finset_eq n
20262026

20272027
@[simp] lemma mem_to_finset : a ∈ l.to_finset ↔ a ∈ l := mem_dedup
2028+
@[simp, norm_cast] lemma coe_to_finset (l : list α) : (l.to_finset : set α) = {a | a ∈ l} :=
2029+
set.ext $ λ _, list.mem_to_finset
2030+
20282031
@[simp] lemma to_finset_nil : to_finset (@nil α) = ∅ := rfl
20292032

20302033
@[simp] lemma to_finset_cons : to_finset (a :: l) = insert a (to_finset l) :=

0 commit comments

Comments
 (0)