Skip to content

Commit

Permalink
feat(algebra/big_operators/basic): Reindexing a product with a permut…
Browse files Browse the repository at this point in the history
…ation (#11344)

This proves `(∏ x in s, f (σ x)) = ∏ x in s, f x` for a permutation `σ`.
  • Loading branch information
YaelDillies committed Jan 18, 2022
1 parent 8d5caba commit a0da4f1
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/algebra/big_operators/basic.lean
Expand Up @@ -259,6 +259,18 @@ by rw [finset.prod, ← multiset.coe_prod, ← multiset.coe_map, finset.coe_to_l

end to_list

@[to_additive]
lemma _root_.equiv.perm.prod_comp (σ : equiv.perm α) (s : finset α) (f : α → β)
(hs : {a | σ a ≠ a} ⊆ s) :
(∏ x in s, f (σ x)) = ∏ x in s, f x :=
by { convert (prod_map _ σ.to_embedding _).symm, exact (map_perm hs).symm }

@[to_additive]
lemma _root_.equiv.perm.prod_comp' (σ : equiv.perm α) (s : finset α) (f : α → α → β)
(hs : {a | σ a ≠ a} ⊆ s) :
(∏ x in s, f (σ x) x) = ∏ x in s, f x (σ.symm x) :=
by { convert σ.prod_comp s (λ x, f x (σ.symm x)) hs, ext, rw equiv.symm_apply_apply }

end comm_monoid

end finset
Expand Down
14 changes: 14 additions & 0 deletions src/data/finset/basic.lean
Expand Up @@ -1890,6 +1890,20 @@ mem_map.trans $ by simp only [exists_prop]; refl
b ∈ s.map f.to_embedding ↔ f.symm b ∈ s :=
by { rw mem_map, exact ⟨by { rintro ⟨a, H, rfl⟩, simpa }, λ h, ⟨_, h, by simp⟩⟩ }

/-- If the only elements outside `s` are those left fixed by `σ`, then mapping by `σ` has no effect.
-/
lemma map_perm {σ : equiv.perm α} (hs : {a | σ a ≠ a} ⊆ s) : s.map (σ : α ↪ α) = s :=
begin
ext i,
rw mem_map,
obtain hi | hi := eq_or_ne (σ i) i,
{ refine ⟨_, λ h, ⟨i, h, hi⟩⟩,
rintro ⟨j, hj, h⟩,
rwa σ.injective (hi.trans h.symm) },
{ refine iff_of_true ⟨σ.symm i, hs $ λ h, hi _, σ.apply_symm_apply _⟩ (hs hi),
convert congr_arg σ h; exact (σ.apply_symm_apply _).symm }
end

theorem mem_map' (f : α ↪ β) {a} {s : finset α} : f a ∈ s.map f ↔ a ∈ s :=
mem_map_of_injective f.2

Expand Down
3 changes: 3 additions & 0 deletions src/data/finset/card.lean
Expand Up @@ -183,6 +183,9 @@ card_le_of_subset $ filter_subset _ _
lemma eq_of_subset_of_card_le {s t : finset α} (h : s ⊆ t) (h₂ : t.card ≤ s.card) : s = t :=
eq_of_veq $ multiset.eq_of_le_of_card_le (val_le_iff.mpr h) h₂

lemma map_eq_of_subset {f : α ↪ α} (hs : s.map f ⊆ s) : s.map f = s :=
eq_of_subset_of_card_le hs (card_map _).ge

lemma filter_card_eq {p : α → Prop} [decidable_pred p] (h : (s.filter p).card = s.card) (x : α)
(hx : x ∈ s) :
p x :=
Expand Down
2 changes: 1 addition & 1 deletion src/linear_algebra/matrix/determinant.lean
Expand Up @@ -156,7 +156,7 @@ calc det (M ⬝ N) = ∑ p : n → n, ∑ σ : perm n, ε σ * ∏ i, (M (σ i)
sum_congr rfl (λ σ _, fintype.sum_equiv (equiv.mul_right σ⁻¹) _ _
(λ τ,
have ∏ j, M (τ j) (σ j) = ∏ j, M ((τ * σ⁻¹) j) j,
by { rw ← σ⁻¹.prod_comp, simp only [equiv.perm.coe_mul, apply_inv_self] },
by { rw ← (σ⁻¹ : _ ≃ _).prod_comp, simp only [equiv.perm.coe_mul, apply_inv_self] },
have h : ε σ * ε (τ * σ⁻¹) = ε τ :=
calc ε σ * ε (τ * σ⁻¹) = ε ((τ * σ⁻¹) * σ) :
by { rw [mul_comm, sign_mul (τ * σ⁻¹)], simp only [int.cast_mul, units.coe_mul] }
Expand Down
2 changes: 1 addition & 1 deletion src/number_theory/sum_four_squares.lean
Expand Up @@ -99,7 +99,7 @@ let ⟨x, hx⟩ := h01 in let ⟨y, hy⟩ := h23 in
← int.sq_add_sq_of_two_mul_sq_add_sq hy.symm,
← mul_right_inj' (show (2 : ℤ) ≠ 0, from dec_trivial), ← h, mul_add, ← hx, ← hy],
have : ∑ x, f (σ x)^2 = ∑ x, f x^2,
{ conv_rhs { rw ← σ.sum_comp } },
{ conv_rhs { rw ←equiv.sum_comp σ } },
have fin4univ : (univ : finset (fin 4)).1 = 0 ::ₘ 1 ::ₘ 2 ::ₘ 3 ::ₘ 0, from dec_trivial,
simpa [finset.sum_eq_multiset_sum, fin4univ, multiset.sum_cons, f, add_assoc]
end
Expand Down

0 comments on commit a0da4f1

Please sign in to comment.