Skip to content

Commit

Permalink
feat(data/finset/basic): equivalence of finsets from equivalence of t…
Browse files Browse the repository at this point in the history
…ypes (#4560)

Broken off from #4259.
Given an equivalence `α` to `β`, produce an equivalence between `finset α` and `finset β`, and simp lemmas about it.
  • Loading branch information
b-mehta committed Oct 11, 2020
1 parent df5adc5 commit d8d6e18
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/data/finset/basic.lean
Expand Up @@ -1412,6 +1412,7 @@ ext $ λ _, by simp only [mem_image, multiset.mem_to_finset, exists_prop, multis
theorem image_val_of_inj_on (H : ∀x∈s, ∀y∈s, f x = f y → x = y) : (image f s).1 = s.1.map f :=
multiset.erase_dup_eq_self.2 (nodup_map_on H s.2)

@[simp]
theorem image_id [decidable_eq α] : s.image id = s :=
ext $ λ _, by simp only [mem_image, exists_prop, id, exists_eq_right]

Expand Down Expand Up @@ -2163,6 +2164,24 @@ subrelation.wf H $ inv_image.wf _ $ nat.lt_wf

end finset

namespace equiv

/-- Given an equivalence `α` to `β`, produce an equivalence between `finset α` and `finset β`. -/
protected def finset_congr (e : α ≃ β) : finset α ≃ finset β :=
{ to_fun := λ s, s.map e.to_embedding,
inv_fun := λ s, s.map e.symm.to_embedding,
left_inv := λ s, by simp [finset.map_map],
right_inv := λ s, by simp [finset.map_map] }

@[simp] lemma finset_congr_apply (e : α ≃ β) (s : finset α) :
e.finset_congr s = s.map e.to_embedding :=
rfl
@[simp] lemma finset_congr_symm_apply (e : α ≃ β) (s : finset β) :
e.finset_congr.symm s = s.map e.symm.to_embedding :=
rfl

end equiv

namespace list
variable [decidable_eq α]

Expand Down

0 comments on commit d8d6e18

Please sign in to comment.