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

Commit 6c17afb

Browse files
committed
feat(data/finset/basic): Map finset.filter under an equiv (#17513)
Rename `finset.map_filter` to `finset.filter_map`. This unfortunately means it doesn't match the `multiset` and `list` lemmas. Prove the true `finset.map_filter`.
1 parent 0013cf7 commit 6c17afb

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

src/data/finset/basic.lean

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2204,10 +2204,14 @@ lemma map_injective (f : α ↪ β) : injective (map f) := (map_embedding f).inj
22042204

22052205
@[simp] theorem map_embedding_apply : map_embedding f s = map f s := rfl
22062206

2207-
theorem map_filter {p : β → Prop} [decidable_pred p] :
2207+
lemma filter_map {p : β → Prop} [decidable_pred p] :
22082208
(s.map f).filter p = (s.filter (p ∘ f)).map f :=
22092209
eq_of_veq (map_filter _ _ _)
22102210

2211+
lemma map_filter {f : α ≃ β} {p : α → Prop} [decidable_pred p] :
2212+
(s.filter p).map f.to_embedding = (s.map f.to_embedding).filter (p ∘ f.symm) :=
2213+
by simp only [filter_map, function.comp, equiv.to_embedding_apply, equiv.symm_apply_apply]
2214+
22112215
@[simp] lemma disjoint_map {s t : finset α} (f : α ↪ β) :
22122216
disjoint (s.map f) (t.map f) ↔ disjoint s t :=
22132217
begin

src/data/finset/nat_antidiagonal.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ begin
114114
have : (λ (x : ℕ × ℕ), x.snd = m) ∘ prod.swap = (λ (x : ℕ × ℕ), x.fst = m),
115115
{ ext, simp },
116116
rw ←map_swap_antidiagonal,
117-
simp [map_filter, this, filter_fst_eq_antidiagonal, apply_ite (finset.map _)]
117+
simp [filter_map, this, filter_fst_eq_antidiagonal, apply_ite (finset.map _)]
118118
end
119119

120120
section equiv_prod

src/data/fintype/fin.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ end
5050
lemma card_filter_univ_succ' (p : fin (n + 1) → Prop) [decidable_pred p] :
5151
(univ.filter p).card = (ite (p 0) 1 0) + (univ.filter (p ∘ fin.succ)).card :=
5252
begin
53-
rw [fin.univ_succ, filter_cons, card_disj_union, map_filter, card_map],
53+
rw [fin.univ_succ, filter_cons, card_disj_union, filter_map, card_map],
5454
split_ifs; simp,
5555
end
5656

src/data/nat/count.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ begin
6363
rintro x hx ⟨c, _, rfl⟩,
6464
exact (self_le_add_right _ _).not_lt hx },
6565
simp_rw [count_eq_card_filter_range, range_add, filter_union, card_disjoint_union this,
66-
map_filter, add_left_embedding, card_map], refl,
66+
filter_map, add_left_embedding, card_map], refl,
6767
end
6868

6969
lemma count_add' (a b : ℕ) : count p (a + b) = count (λ k, p (k + b)) a + count p b :=

0 commit comments

Comments
 (0)