Skip to content

Commit b0a0c20

Browse files
committed
feat(Data/Finset/Image): add image_comp and image_comp_image (leanprover-community#39533)
The statement `image_comp` is worth adding because it matches the Set version, and also is more useful for rewriting in the forward direction.
1 parent c46e995 commit b0a0c20

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

Mathlib/Data/Finset/Image.lean

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,17 @@ theorem image_id' [DecidableEq α] : (s.image fun x => x) = s :=
349349
theorem image_image [DecidableEq γ] {g : β → γ} : (s.image f).image g = s.image (g ∘ f) :=
350350
eq_of_veq <| by simp only [image_val, dedup_map_dedup_eq, Multiset.map_map]
351351

352+
/-- Reverse of `Finset.image_image`. The `Finset` analogue of `Set.image_comp`. -/
353+
theorem image_comp [DecidableEq γ] {g : β → γ} : s.image (g ∘ f) = (s.image f).image g :=
354+
image_image.symm
355+
356+
/-- Point-free form of `Finset.image_image`: `image` distributes over `Function.comp`. -/
357+
theorem image_comp_image [DecidableEq γ] {g : β → γ} :
358+
image g ∘ image f = image (g ∘ f) := by ext s; simp [image_image]
359+
360+
theorem image_comp_eq [DecidableEq γ] {g : β → γ} :
361+
image (g ∘ f) = image g ∘ image f := image_comp_image.symm
362+
352363
theorem image_comm {β'} [DecidableEq β'] [DecidableEq γ] {f : β → γ} {g : α → β} {f' : α → β'}
353364
{g' : β' → γ} (h_comm : ∀ a, f (g a) = g' (f' a)) :
354365
(s.image g).image f = (s.image f').image g' := by simp_rw [image_image, comp_def, h_comm]

Mathlib/Data/Set/Image.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ theorem image_comp (f : β → γ) (g : α → β) (a : Set α) : f ∘ g '' a =
219219

220220
theorem image_comp_eq {g : β → γ} : image (g ∘ f) = image g ∘ image f := by grind
221221

222+
theorem image_comp_image {g : β → γ} : image g ∘ image f = image (g ∘ f) := by grind
223+
222224
/-- A variant of `image_comp`, useful for rewriting -/
223225
@[grind =]
224226
theorem image_image (g : β → γ) (f : α → β) (s : Set α) : g '' f '' s = (fun x => g (f x)) '' s :=

0 commit comments

Comments
 (0)