Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(data/finset): add
finset.erase_none
(#9630)
* move `option.to_finset` and `finset.insert_none` to a new file `data.finset.option`; redefine the latter in terms of `finset.cons`; * define `finset.erase_none`, prove lemmas about it; * add `finset.prod_cons`, `finset.sum_cons`, `finset.coe_cons`, `finset.cons_subset_cons`, `finset.card_cons`; * add `finset.subtype_mono` and `finset.bUnion_congr`; * add `set.insert_subset_insert_iff`; * add `@[simp]` to `finset.map_subset_map`; * upgrade `finset.map_embedding` to an `order_embedding`; * add `@[simps]` to `equiv.option_is_some_equiv` and `function.embedding.some`; * golf some proofs.
- Loading branch information
Showing
12 changed files
with
225 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/- | ||
Copyright (c) 2021 Yury Kudryashov. All rights reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: Yury Kudryashov | ||
-/ | ||
|
||
import algebra.big_operators.basic | ||
import data.finset.option | ||
|
||
/-! | ||
# Lemmas about products and sums over finite sets in `option α` | ||
In this file we prove formulas for products and sums over `finset.insert_none s` and | ||
`finset.erase_none s`. | ||
-/ | ||
|
||
open_locale big_operators | ||
open function | ||
|
||
namespace finset | ||
|
||
variables {α M : Type*} [comm_monoid M] | ||
|
||
@[simp, to_additive] lemma prod_insert_none (f : option α → M) (s : finset α) : | ||
∏ x in s.insert_none, f x = f none * ∏ x in s, f (some x) := | ||
by simp [insert_none] | ||
|
||
@[to_additive] lemma prod_erase_none (f : α → M) (s : finset (option α)) : | ||
∏ x in s.erase_none, f x = ∏ x in s, option.elim x 1 f := | ||
by classical; | ||
calc ∏ x in s.erase_none, f x = ∏ x in s.erase_none.map embedding.some, option.elim x 1 f : | ||
(prod_map s.erase_none embedding.some (λ x, option.elim x 1 f)).symm | ||
... = ∏ x in s.erase none, option.elim x 1 f : by rw map_some_erase_none | ||
... = ∏ x in s, option.elim x 1 f : prod_erase _ rfl | ||
|
||
end finset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.