Skip to content

Commit

Permalink
feat: graphOn API (#17303)
Browse files Browse the repository at this point in the history
From PFR

Co-authored-by: Arend Mellendijk
  • Loading branch information
YaelDillies committed Oct 8, 2024
1 parent ae1fbb5 commit 92fd0f8
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Mathlib/Data/Set/Function.lean
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,15 @@ theorem InjOn.imageFactorization_injective (h : InjOn f s) :
end injOn

section graphOn
variable {x : α × β}

@[simp] lemma mem_graphOn : x ∈ s.graphOn f ↔ x.1 ∈ s ∧ f x.1 = x.2 := by aesop (add simp graphOn)

@[simp] lemma graphOn_empty (f : α → β) : graphOn f ∅ = ∅ := image_empty _
@[simp] lemma graphOn_eq_empty : graphOn f s = ∅ ↔ s = ∅ := image_eq_empty
@[simp] lemma graphOn_nonempty : (s.graphOn f).Nonempty ↔ s.Nonempty := image_nonempty

protected alias ⟨_, Nonempty.graphOn⟩ := graphOn_nonempty

@[simp]
lemma graphOn_union (f : α → β) (s t : Set α) : graphOn f (s ∪ t) = graphOn f s ∪ graphOn f t :=
Expand All @@ -645,6 +652,24 @@ lemma graphOn_insert (f : α → β) (x : α) (s : Set α) :
lemma image_fst_graphOn (f : α → β) (s : Set α) : Prod.fst '' graphOn f s = s := by
simp [graphOn, image_image]

@[simp] lemma image_snd_graphOn (f : α → β) : Prod.snd '' s.graphOn f = f '' s := by ext x; simp

lemma fst_injOn_graph : (s.graphOn f).InjOn Prod.fst := by aesop (add simp InjOn)

lemma graphOn_comp (s : Set α) (f : α → β) (g : β → γ) :
s.graphOn (g ∘ f) = (fun x ↦ (x.1, g x.2)) '' s.graphOn f := by
simpa using image_comp (fun x ↦ (x.1, g x.2)) (fun x ↦ (x, f x)) _

lemma graphOn_univ_eq_range : univ.graphOn f = range fun x ↦ (x, f x) := image_univ

@[simp] lemma graphOn_inj {g : α → β} : s.graphOn f = s.graphOn g ↔ s.EqOn f g := by
simp [Set.ext_iff, funext_iff, forall_swap, EqOn]

lemma graphOn_univ_inj {g : α → β} : univ.graphOn f = univ.graphOn g ↔ f = g := by simp

lemma graphOn_univ_injective : Injective (univ.graphOn : (α → β) → Set (α × β)) :=
fun _f _g ↦ graphOn_univ_inj.1

lemma exists_eq_graphOn_image_fst [Nonempty β] {s : Set (α × β)} :
(∃ f : α → β, s = graphOn f (Prod.fst '' s)) ↔ InjOn Prod.fst s := by
refine ⟨?_, fun h ↦ ?_⟩
Expand Down

0 comments on commit 92fd0f8

Please sign in to comment.