Skip to content

Commit

Permalink
feat(algebra/big_operators): product over coerced fintype (#7236)
Browse files Browse the repository at this point in the history
  • Loading branch information
b-mehta committed Apr 21, 2021
1 parent ad58861 commit 4abf961
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
20 changes: 18 additions & 2 deletions src/algebra/big_operators/basic.lean
Expand Up @@ -516,6 +516,17 @@ begin
exact finset.prod_congr rfl h
end

@[to_additive]
lemma prod_finset_coe (f : α → β) (s : finset α) :
∏ (i : (s : set α)), f i = ∏ i in s, f i :=
prod_attach

@[to_additive]
lemma prod_subtype {p : α → Prop} {F : fintype (subtype p)} (s : finset α)
(h : ∀ x, x ∈ s ↔ p x) (f : α → β) :
∏ a in s, f a = ∏ a : subtype p, f a :=
have (∈ s) = p, from set.ext h, by { substI p, rw [←prod_finset_coe], congr }

@[to_additive]
lemma prod_eq_one {f : α → β} {s : finset α} (h : ∀x∈s, f x = 1) : (∏ x in s, f x) = 1 :=
calc (∏ x in s, f x) = ∏ x in s, 1 : finset.prod_congr rfl h
Expand Down Expand Up @@ -1307,18 +1318,23 @@ prod_bij
/-- `fintype.prod_equiv` is a specialization of `finset.prod_bij` that
automatically fills in most arguments.
See `equiv.prod_comp` for a version without `h`.
See `equiv.prod_comp` for a version without `h`.
-/
@[to_additive "`fintype.sum_equiv` is a specialization of `finset.sum_bij` that
automatically fills in most arguments.
See `equiv.sum_comp` for a version without `h`.
See `equiv.sum_comp` for a version without `h`.
"]
lemma prod_equiv {α β M : Type*} [fintype α] [fintype β] [comm_monoid M]
(e : α ≃ β) (f : α → M) (g : β → M) (h : ∀ x, f x = g (e x)) :
∏ x : α, f x = ∏ x : β, g x :=
prod_bijective e e.bijective f g h

@[to_additive]
lemma prod_finset_coe [comm_monoid β] :
∏ (i : (s : set α)), f i = ∏ i in s, f i :=
(finset.prod_subtype s (λ _, iff.rfl) f).symm

end fintype

namespace list
Expand Down
11 changes: 0 additions & 11 deletions src/data/fintype/card.lean
Expand Up @@ -277,17 +277,6 @@ begin
simp only [fin.coe_eq_val, hi, dif_pos]
end

@[to_additive]
lemma finset.prod_subtype {M : Type*} [comm_monoid M]
{p : α → Prop} {F : fintype (subtype p)} (s : finset α) (h : ∀ x, x ∈ s ↔ p x) (f : α → M) :
∏ a in s, f a = ∏ a : subtype p, f a :=
have (∈ s) = p, from set.ext h,
begin
rw [← prod_attach, attach_eq_univ],
substI p,
congr
end

@[to_additive]
lemma finset.prod_to_finset_eq_subtype {M : Type*} [comm_monoid M] [fintype α]
(p : α → Prop) [decidable_pred p] (f : α → M) :
Expand Down

0 comments on commit 4abf961

Please sign in to comment.