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

Commit a521a32

Browse files
feat(data/set/basic): Missing set.image_perm (#13242)
Co-authored-by: YaelDillies <yael.dillies@gmail.com>
1 parent dee4958 commit a521a32

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

src/data/finset/basic.lean

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1838,20 +1838,6 @@ mem_map.trans $ by simp only [exists_prop]; refl
18381838
@[simp] lemma mem_map_equiv {f : α ≃ β} {b : β} : b ∈ s.map f.to_embedding ↔ f.symm b ∈ s :=
18391839
by { rw mem_map, exact ⟨by { rintro ⟨a, H, rfl⟩, simpa }, λ h, ⟨_, h, by simp⟩⟩ }
18401840

1841-
/-- If the only elements outside `s` are those left fixed by `σ`, then mapping by `σ` has no effect.
1842-
-/
1843-
lemma map_perm {σ : equiv.perm α} (hs : {a | σ a ≠ a} ⊆ s) : s.map (σ : α ↪ α) = s :=
1844-
begin
1845-
ext i,
1846-
rw mem_map,
1847-
obtain hi | hi := eq_or_ne (σ i) i,
1848-
{ refine ⟨_, λ h, ⟨i, h, hi⟩⟩,
1849-
rintro ⟨j, hj, h⟩,
1850-
rwa σ.injective (hi.trans h.symm) },
1851-
{ refine iff_of_true ⟨σ.symm i, hs $ λ h, hi _, σ.apply_symm_apply _⟩ (hs hi),
1852-
convert congr_arg σ h; exact (σ.apply_symm_apply _).symm }
1853-
end
1854-
18551841
lemma mem_map' (f : α ↪ β) {a} {s : finset α} : f a ∈ s.map f ↔ a ∈ s := mem_map_of_injective f.2
18561842

18571843
lemma mem_map_of_mem (f : α ↪ β) {a} {s : finset α} : a ∈ s → f a ∈ s.map f := (mem_map' _).2
@@ -1866,6 +1852,11 @@ theorem coe_map_subset_range (f : α ↪ β) (s : finset α) : (s.map f : set β
18661852
calc ↑(s.map f) = f '' s : coe_map f s
18671853
... ⊆ set.range f : set.image_subset_range f ↑s
18681854

1855+
/-- If the only elements outside `s` are those left fixed by `σ`, then mapping by `σ` has no effect.
1856+
-/
1857+
lemma map_perm {σ : equiv.perm α} (hs : {a | σ a ≠ a} ⊆ s) : s.map (σ : α ↪ α) = s :=
1858+
coe_injective $ (coe_map _ _).trans $ set.image_perm hs
1859+
18691860
theorem map_to_finset [decidable_eq α] [decidable_eq β] {s : multiset α} :
18701861
s.to_finset.map f = (s.map f).to_finset :=
18711862
ext $ λ _, by simp only [mem_map, multiset.mem_map, exists_prop, multiset.mem_to_finset]

src/data/set/basic.lean

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1593,6 +1593,19 @@ lemma surjective_onto_image {f : α → β} {s : set α} :
15931593
surjective (image_factorization f s) :=
15941594
λ ⟨_, ⟨a, ha, rfl⟩⟩, ⟨⟨a, ha⟩, rfl⟩
15951595

1596+
/-- If the only elements outside `s` are those left fixed by `σ`, then mapping by `σ` has no effect.
1597+
-/
1598+
lemma image_perm {s : set α} {σ : equiv.perm α} (hs : {a : α | σ a ≠ a} ⊆ s) : σ '' s = s :=
1599+
begin
1600+
ext i,
1601+
obtain hi | hi := eq_or_ne (σ i) i,
1602+
{ refine ⟨_, λ h, ⟨i, h, hi⟩⟩,
1603+
rintro ⟨j, hj, h⟩,
1604+
rwa σ.injective (hi.trans h.symm) },
1605+
{ refine iff_of_true ⟨σ.symm i, hs $ λ h, hi _, σ.apply_symm_apply _⟩ (hs hi),
1606+
convert congr_arg σ h; exact (σ.apply_symm_apply _).symm }
1607+
end
1608+
15961609
end image
15971610

15981611
/-! ### Subsingleton -/

0 commit comments

Comments
 (0)