doc-next-gen

Mathlib.Data.Set.Function

Module docstring

{"# Functions over sets

This file contains basic results on the following predicates of functions and sets:

  • Set.EqOn f₁ f₂ s : functions f₁ and f₂ are equal at every point of s;
  • Set.MapsTo f s t : f sends every point of s to a point of t;
  • Set.InjOn f s : restriction of f to s is injective;
  • Set.SurjOn f s t : every point in s has a preimage in s;
  • Set.BijOn f s t : f is a bijection between s and t;
  • Set.LeftInvOn f' f s : for every x ∈ s we have f' (f x) = x;
  • Set.RightInvOn f' f t : for every y ∈ t we have f (f' y) = y;
  • Set.InvOn f' f s t : f' is a two-side inverse of f on s and t, i.e. we have Set.LeftInvOn f' f s and Set.RightInvOn f' f t. ","### Equality on a set ","### Injectivity on a set ","### Surjectivity on a set ","### Bijectivity ","### left inverse ","### Right inverse ","### Two-side inverses ","### invFunOn is a left/right inverse ","### Equivalences, permutations "}
Set.eqOn_empty theorem
(f₁ f₂ : α → β) : EqOn f₁ f₂ ∅
Full source
@[simp]
theorem eqOn_empty (f₁ f₂ : α → β) : EqOn f₁ f₂  := fun _ => False.elim
Functions Agree on Empty Set
Informal description
For any two functions $f_1, f_2 : \alpha \to \beta$, they are equal on the empty set $\emptyset$, i.e., $f_1$ and $f_2$ agree at every point of $\emptyset$.
Set.eqOn_singleton theorem
: Set.EqOn f₁ f₂ { a } ↔ f₁ a = f₂ a
Full source
@[simp]
theorem eqOn_singleton : Set.EqOnSet.EqOn f₁ f₂ {a} ↔ f₁ a = f₂ a := by
  simp [Set.EqOn]
Equality of Functions on a Singleton Set is Pointwise Equality
Informal description
Two functions $f_1$ and $f_2$ are equal on the singleton set $\{a\}$ if and only if they agree at the point $a$, i.e., $f_1(a) = f_2(a)$.
Set.eqOn_univ theorem
(f₁ f₂ : α → β) : EqOn f₁ f₂ univ ↔ f₁ = f₂
Full source
@[simp]
theorem eqOn_univ (f₁ f₂ : α → β) : EqOnEqOn f₁ f₂ univ ↔ f₁ = f₂ := by
  simp [EqOn, funext_iff]
Equality on Universe Set Implies Function Equality
Informal description
For any two functions $f_1, f_2 : \alpha \to \beta$, the functions are equal on the entire universe set $\text{univ}$ if and only if $f_1$ and $f_2$ are equal as functions, i.e., $f_1 = f_2$.
Set.EqOn.symm theorem
(h : EqOn f₁ f₂ s) : EqOn f₂ f₁ s
Full source
@[symm]
theorem EqOn.symm (h : EqOn f₁ f₂ s) : EqOn f₂ f₁ s := fun _ hx => (h hx).symm
Symmetry of Function Equality on a Set
Informal description
For any two functions $f_1, f_2 : \alpha \to \beta$ and any subset $s \subseteq \alpha$, if $f_1$ and $f_2$ are equal on $s$ (i.e., $f_1(x) = f_2(x)$ for all $x \in s$), then $f_2$ and $f_1$ are also equal on $s$.
Set.eqOn_comm theorem
: EqOn f₁ f₂ s ↔ EqOn f₂ f₁ s
Full source
theorem eqOn_comm : EqOnEqOn f₁ f₂ s ↔ EqOn f₂ f₁ s :=
  ⟨EqOn.symm, EqOn.symm⟩
Commutativity of Function Equality on a Set
Informal description
For any two functions $f_1, f_2 : \alpha \to \beta$ and any subset $s \subseteq \alpha$, the functions are equal on $s$ (i.e., $f_1(x) = f_2(x)$ for all $x \in s$) if and only if $f_2$ and $f_1$ are equal on $s$.
Set.eqOn_refl theorem
(f : α → β) (s : Set α) : EqOn f f s
Full source
theorem eqOn_refl (f : α → β) (s : Set α) : EqOn f f s := fun _ _ => rfl
Reflexivity of Function Equality on a Set
Informal description
For any function $f : \alpha \to \beta$ and any subset $s \subseteq \alpha$, the function $f$ is equal to itself on $s$, i.e., for all $x \in s$, $f(x) = f(x)$.
Set.EqOn.trans theorem
(h₁ : EqOn f₁ f₂ s) (h₂ : EqOn f₂ f₃ s) : EqOn f₁ f₃ s
Full source
theorem EqOn.trans (h₁ : EqOn f₁ f₂ s) (h₂ : EqOn f₂ f₃ s) : EqOn f₁ f₃ s := fun _ hx =>
  (h₁ hx).trans (h₂ hx)
Transitivity of Function Equality on a Set
Informal description
For functions $f_1, f_2, f_3 : \alpha \to \beta$ and a set $s \subseteq \alpha$, if $f_1$ and $f_2$ are equal on $s$ and $f_2$ and $f_3$ are equal on $s$, then $f_1$ and $f_3$ are equal on $s$.
Set.EqOn.image_eq theorem
(heq : EqOn f₁ f₂ s) : f₁ '' s = f₂ '' s
Full source
theorem EqOn.image_eq (heq : EqOn f₁ f₂ s) : f₁ '' s = f₂ '' s :=
  image_congr heq
Image Equality under Function Equality on a Set
Informal description
For any two functions $f_1, f_2 : \alpha \to \beta$ and any subset $s \subseteq \alpha$, if $f_1$ and $f_2$ are equal on $s$ (i.e., $f_1(x) = f_2(x)$ for all $x \in s$), then their images of $s$ are equal: $f_1(s) = f_2(s)$.
Set.EqOn.image_eq_self theorem
{f : α → α} (h : Set.EqOn f id s) : f '' s = s
Full source
/-- Variant of `EqOn.image_eq`, for one function being the identity. -/
theorem EqOn.image_eq_self {f : α → α} (h : Set.EqOn f id s) : f '' s = s := by
  rw [h.image_eq, image_id]
Image of Set under Identity-like Function Equals Itself
Informal description
For any function $f : \alpha \to \alpha$ and subset $s \subseteq \alpha$, if $f$ coincides with the identity function on $s$ (i.e., $f(x) = x$ for all $x \in s$), then the image of $s$ under $f$ equals $s$ itself, i.e., $f(s) = s$.
Set.EqOn.inter_preimage_eq theorem
(heq : EqOn f₁ f₂ s) (t : Set β) : s ∩ f₁ ⁻¹' t = s ∩ f₂ ⁻¹' t
Full source
theorem EqOn.inter_preimage_eq (heq : EqOn f₁ f₂ s) (t : Set β) : s ∩ f₁ ⁻¹' t = s ∩ f₂ ⁻¹' t :=
  ext fun x => and_congr_right_iff.2 fun hx => by rw [mem_preimage, mem_preimage, heq hx]
Equality of Preimages under Equal Functions on a Set
Informal description
For functions $f_1, f_2 : \alpha \to \beta$ and sets $s \subseteq \alpha$, $t \subseteq \beta$, if $f_1$ and $f_2$ are equal on $s$ (i.e., $f_1(x) = f_2(x)$ for all $x \in s$), then the intersection of $s$ with the preimage of $t$ under $f_1$ is equal to the intersection of $s$ with the preimage of $t$ under $f_2$. In other words: $$ s \cap f_1^{-1}(t) = s \cap f_2^{-1}(t) $$
Set.EqOn.mono theorem
(hs : s₁ ⊆ s₂) (hf : EqOn f₁ f₂ s₂) : EqOn f₁ f₂ s₁
Full source
theorem EqOn.mono (hs : s₁ ⊆ s₂) (hf : EqOn f₁ f₂ s₂) : EqOn f₁ f₂ s₁ := fun _ hx => hf (hs hx)
Restriction of Function Equality to Smaller Subset
Informal description
Let $f_1$ and $f_2$ be functions from a type $\alpha$ to a type $\beta$, and let $s_1$ and $s_2$ be subsets of $\alpha$ such that $s_1 \subseteq s_2$. If $f_1$ and $f_2$ agree on $s_2$ (i.e., $f_1(x) = f_2(x)$ for all $x \in s_2$), then they also agree on $s_1$.
Set.eqOn_union theorem
: EqOn f₁ f₂ (s₁ ∪ s₂) ↔ EqOn f₁ f₂ s₁ ∧ EqOn f₁ f₂ s₂
Full source
@[simp]
theorem eqOn_union : EqOnEqOn f₁ f₂ (s₁ ∪ s₂) ↔ EqOn f₁ f₂ s₁ ∧ EqOn f₁ f₂ s₂ :=
  forall₂_or_left
Equality of Functions on Union of Sets is Equivalent to Equality on Each Set
Informal description
For functions $f_1, f_2 : \alpha \to \beta$ and subsets $s_1, s_2 \subseteq \alpha$, the functions $f_1$ and $f_2$ are equal on the union $s_1 \cup s_2$ if and only if they are equal on both $s_1$ and $s_2$ individually. In symbols: $$(\forall x \in s_1 \cup s_2, f_1(x) = f_2(x)) \leftrightarrow (\forall x \in s_1, f_1(x) = f_2(x)) \land (\forall x \in s_2, f_1(x) = f_2(x))$$
Set.EqOn.union theorem
(h₁ : EqOn f₁ f₂ s₁) (h₂ : EqOn f₁ f₂ s₂) : EqOn f₁ f₂ (s₁ ∪ s₂)
Full source
theorem EqOn.union (h₁ : EqOn f₁ f₂ s₁) (h₂ : EqOn f₁ f₂ s₂) : EqOn f₁ f₂ (s₁ ∪ s₂) :=
  eqOn_union.2 ⟨h₁, h₂⟩
Equality of Functions on Union of Sets from Equality on Each Set
Informal description
For functions $f_1, f_2 : \alpha \to \beta$ and subsets $s_1, s_2 \subseteq \alpha$, if $f_1$ and $f_2$ are equal on $s_1$ and also equal on $s_2$, then they are equal on the union $s_1 \cup s_2$. In symbols: $$(\forall x \in s_1, f_1(x) = f_2(x)) \land (\forall x \in s_2, f_1(x) = f_2(x)) \implies (\forall x \in s_1 \cup s_2, f_1(x) = f_2(x))$$
Set.EqOn.comp_left theorem
(h : s.EqOn f₁ f₂) : s.EqOn (g ∘ f₁) (g ∘ f₂)
Full source
theorem EqOn.comp_left (h : s.EqOn f₁ f₂) : s.EqOn (g ∘ f₁) (g ∘ f₂) := fun _ ha =>
  congr_arg _ <| h ha
Composition Preserves Equality on a Set
Informal description
Let $f_1$ and $f_2$ be functions from a set $S$ to a type $\alpha$, and let $g$ be a function from $\alpha$ to a type $\beta$. If $f_1$ and $f_2$ are equal on $S$ (i.e., $f_1(x) = f_2(x)$ for all $x \in S$), then the compositions $g \circ f_1$ and $g \circ f_2$ are also equal on $S$.
Set.eqOn_range theorem
{ι : Sort*} {f : ι → α} {g₁ g₂ : α → β} : EqOn g₁ g₂ (range f) ↔ g₁ ∘ f = g₂ ∘ f
Full source
@[simp]
theorem eqOn_range {ι : Sort*} {f : ι → α} {g₁ g₂ : α → β} :
    EqOnEqOn g₁ g₂ (range f) ↔ g₁ ∘ f = g₂ ∘ f :=
  forall_mem_range.trans <| funext_iff.symm
Equality on Range is Equivalent to Equality of Compositions
Informal description
Let $f : \iota \to \alpha$ be a function and $g_1, g_2 : \alpha \to \beta$ be two functions. Then $g_1$ and $g_2$ are equal on the range of $f$ (i.e., $g_1(y) = g_2(y)$ for all $y$ in the range of $f$) if and only if the compositions $g_1 \circ f$ and $g_2 \circ f$ are equal as functions from $\iota$ to $\beta$.
Set.mapsTo' theorem
: MapsTo f s t ↔ f '' s ⊆ t
Full source
theorem mapsTo' : MapsToMapsTo f s t ↔ f '' s ⊆ t :=
  image_subset_iff.symm
MapsTo Characterization via Image Subset
Informal description
A function $f$ maps every element of a set $s$ into a set $t$ if and only if the image of $s$ under $f$ is a subset of $t$, i.e., $f(s) \subseteq t$.
Set.mapsTo_prodMap_diagonal theorem
: MapsTo (Prod.map f f) (diagonal α) (diagonal β)
Full source
theorem mapsTo_prodMap_diagonal : MapsTo (Prod.map f f) (diagonal α) (diagonal β) :=
  diagonal_subset_iff.2 fun _ => rfl
Product Map Preserves Diagonal
Informal description
For any function $f : \alpha \to \beta$, the product map $\text{Prod.map}\, f\, f$ sends the diagonal of $\alpha$ (i.e., the set $\{(x, x) \mid x \in \alpha\}$) to the diagonal of $\beta$ (i.e., the set $\{(y, y) \mid y \in \beta\}$).
Set.MapsTo.subset_preimage theorem
(hf : MapsTo f s t) : s ⊆ f ⁻¹' t
Full source
theorem MapsTo.subset_preimage (hf : MapsTo f s t) : s ⊆ f ⁻¹' t := hf
Preimage Contains Domain Under MapsTo Condition
Informal description
If a function $f$ maps every element of a set $s$ into a set $t$, then $s$ is a subset of the preimage of $t$ under $f$, i.e., $s \subseteq f^{-1}(t)$.
Set.mapsTo_iff_subset_preimage theorem
: MapsTo f s t ↔ s ⊆ f ⁻¹' t
Full source
theorem mapsTo_iff_subset_preimage : MapsToMapsTo f s t ↔ s ⊆ f ⁻¹' t := Iff.rfl
MapsTo Characterization via Preimage Subset
Informal description
For any function $f : \alpha \to \beta$ and sets $s \subseteq \alpha$, $t \subseteq \beta$, the condition that $f$ maps every element of $s$ into $t$ is equivalent to $s$ being a subset of the preimage of $t$ under $f$, i.e., \[ \text{MapsTo}(f, s, t) \leftrightarrow s \subseteq f^{-1}(t). \]
Set.mapsTo_singleton theorem
{x : α} : MapsTo f { x } t ↔ f x ∈ t
Full source
@[simp]
theorem mapsTo_singleton {x : α} : MapsToMapsTo f {x} t ↔ f x ∈ t :=
  singleton_subset_iff
Mapping of Singleton Set to Target Set
Informal description
For any function $f : \alpha \to \beta$, point $x \in \alpha$, and set $t \subseteq \beta$, the function $f$ maps the singleton set $\{x\}$ into $t$ if and only if $f(x) \in t$. In other words, $f(\{x\}) \subseteq t \leftrightarrow f(x) \in t$.
Set.mapsTo_empty theorem
(f : α → β) (t : Set β) : MapsTo f ∅ t
Full source
theorem mapsTo_empty (f : α → β) (t : Set β) : MapsTo f  t :=
  empty_subset _
Vacuously True Mapping from Empty Set
Informal description
For any function $f : \alpha \to \beta$ and any subset $t \subseteq \beta$, the function $f$ maps every element of the empty set $\emptyset \subseteq \alpha$ to $t$. In other words, $f$ vacuously satisfies the `MapsTo` condition when the source set is empty.
Set.mapsTo_empty_iff theorem
: MapsTo f s ∅ ↔ s = ∅
Full source
@[simp] theorem mapsTo_empty_iff : MapsToMapsTo f s ∅ ↔ s = ∅ := by
  simp [mapsTo', subset_empty_iff]
Maps to Empty Set iff Domain is Empty
Informal description
For any function $f : \alpha \to \beta$ and set $s \subseteq \alpha$, the function $f$ maps every element of $s$ into the empty set $\emptyset \subseteq \beta$ if and only if $s$ is itself empty. In other words, $f$ maps $s$ to $\emptyset$ if and only if $s = \emptyset$.
Set.MapsTo.nonempty theorem
(h : MapsTo f s t) (hs : s.Nonempty) : t.Nonempty
Full source
/-- If `f` maps `s` to `t` and `s` is non-empty, `t` is non-empty. -/
theorem MapsTo.nonempty (h : MapsTo f s t) (hs : s.Nonempty) : t.Nonempty :=
  (hs.image f).mono (mapsTo'.mp h)
Non-Empty Image of Non-Empty Set under Mapping
Informal description
If a function $f$ maps a non-empty set $s$ into a set $t$, then $t$ is non-empty.
Set.MapsTo.image_subset theorem
(h : MapsTo f s t) : f '' s ⊆ t
Full source
theorem MapsTo.image_subset (h : MapsTo f s t) : f '' sf '' s ⊆ t :=
  mapsTo'.1 h
Image Subset under MapsTo Condition
Informal description
If a function $f$ maps every element of a set $s$ into a set $t$, then the image of $s$ under $f$ is a subset of $t$, i.e., $f(s) \subseteq t$.
Set.MapsTo.congr theorem
(h₁ : MapsTo f₁ s t) (h : EqOn f₁ f₂ s) : MapsTo f₂ s t
Full source
theorem MapsTo.congr (h₁ : MapsTo f₁ s t) (h : EqOn f₁ f₂ s) : MapsTo f₂ s t := fun _ hx =>
  h hx ▸ h₁ hx
Equality of Functions Preserves Mapping Property
Informal description
Let $f_1$ and $f_2$ be functions from a set $s$ to a set $t$, and suppose that $f_1$ and $f_2$ are equal on $s$ (i.e., $f_1(x) = f_2(x)$ for all $x \in s$). If $f_1$ maps $s$ into $t$, then $f_2$ also maps $s$ into $t$.
Set.EqOn.comp_right theorem
(hg : t.EqOn g₁ g₂) (hf : s.MapsTo f t) : s.EqOn (g₁ ∘ f) (g₂ ∘ f)
Full source
theorem EqOn.comp_right (hg : t.EqOn g₁ g₂) (hf : s.MapsTo f t) : s.EqOn (g₁ ∘ f) (g₂ ∘ f) :=
  fun _ ha => hg <| hf ha
Composition Preserves Equality on Sets
Informal description
Let $s$ and $t$ be sets, and let $f : s \to t$, $g_1, g_2 : t \to \alpha$ be functions. If $g_1$ and $g_2$ are equal on $t$ (i.e., $g_1(y) = g_2(y)$ for all $y \in t$) and $f$ maps $s$ into $t$, then the compositions $g_1 \circ f$ and $g_2 \circ f$ are equal on $s$ (i.e., $g_1(f(x)) = g_2(f(x))$ for all $x \in s$).
Set.EqOn.mapsTo_iff theorem
(H : EqOn f₁ f₂ s) : MapsTo f₁ s t ↔ MapsTo f₂ s t
Full source
theorem EqOn.mapsTo_iff (H : EqOn f₁ f₂ s) : MapsToMapsTo f₁ s t ↔ MapsTo f₂ s t :=
  ⟨fun h => h.congr H, fun h => h.congr H.symm⟩
Equality on Set Preserves Mapping Property
Informal description
For any two functions $f_1, f_2 : \alpha \to \beta$ and subsets $s \subseteq \alpha$, $t \subseteq \beta$, if $f_1$ and $f_2$ are equal on $s$ (i.e., $f_1(x) = f_2(x)$ for all $x \in s$), then $f_1$ maps $s$ into $t$ if and only if $f_2$ maps $s$ into $t$.
Set.MapsTo.comp theorem
(h₁ : MapsTo g t p) (h₂ : MapsTo f s t) : MapsTo (g ∘ f) s p
Full source
theorem MapsTo.comp (h₁ : MapsTo g t p) (h₂ : MapsTo f s t) : MapsTo (g ∘ f) s p := fun _ h =>
  h₁ (h₂ h)
Composition Preserves MapsTo Property
Informal description
Let $f : \alpha \to \beta$ and $g : \beta \to \gamma$ be functions, and let $s \subseteq \alpha$, $t \subseteq \beta$, $p \subseteq \gamma$ be subsets. If $g$ maps $t$ into $p$ and $f$ maps $s$ into $t$, then the composition $g \circ f$ maps $s$ into $p$.
Set.mapsTo_id theorem
(s : Set α) : MapsTo id s s
Full source
theorem mapsTo_id (s : Set α) : MapsTo id s s := fun _ => id
Identity Function Maps Set to Itself
Informal description
For any set $s$ in a type $\alpha$, the identity function $\text{id}$ maps every element of $s$ to itself, i.e., $\text{id}$ sends $s$ to $s$.
Set.MapsTo.iterate theorem
{f : α → α} {s : Set α} (h : MapsTo f s s) : ∀ n, MapsTo f^[n] s s
Full source
theorem MapsTo.iterate {f : α → α} {s : Set α} (h : MapsTo f s s) : ∀ n, MapsTo f^[n] s s
  | 0 => fun _ => id
  | n + 1 => (MapsTo.iterate h n).comp h
Iteration Preserves MapsTo Property
Informal description
Let $f : \alpha \to \alpha$ be a function and $s \subseteq \alpha$ a subset such that $f$ maps $s$ into itself (i.e., for all $x \in s$, $f(x) \in s$). Then for any natural number $n$, the $n$-th iterate $f^{[n]}$ also maps $s$ into itself.
Set.MapsTo.iterate_restrict theorem
{f : α → α} {s : Set α} (h : MapsTo f s s) (n : ℕ) : (h.restrict f s s)^[n] = (h.iterate n).restrict _ _ _
Full source
theorem MapsTo.iterate_restrict {f : α → α} {s : Set α} (h : MapsTo f s s) (n : ) :
    (h.restrict f s s)^[n] = (h.iterate n).restrict _ _ _ := by
  funext x
  rw [Subtype.ext_iff, MapsTo.val_restrict_apply]
  induction n generalizing x with
  | zero => rfl
  | succ n ihn => simp [Nat.iterate, ihn]
Iteration Commutes with Restriction for Self-Mapping Functions
Informal description
Let $f : \alpha \to \alpha$ be a function and $s \subseteq \alpha$ a subset such that $f$ maps $s$ into itself (i.e., for all $x \in s$, $f(x) \in s$). Then for any natural number $n$, the $n$-th iterate of the restriction of $f$ to $s$ is equal to the restriction of the $n$-th iterate of $f$ to $s$. In other words, $(f|_s)^{[n]} = f^{[n]}|_s$.
Set.mapsTo_of_subsingleton' theorem
[Subsingleton β] (f : α → β) (h : s.Nonempty → t.Nonempty) : MapsTo f s t
Full source
lemma mapsTo_of_subsingleton' [Subsingleton β] (f : α → β) (h : s.Nonempty → t.Nonempty) :
    MapsTo f s t :=
  fun a ha ↦ Subsingleton.mem_iff_nonempty.2 <| h ⟨a, ha⟩
Mapping from Nonempty Set to Nonempty Set in Subsingleton Codomain
Informal description
Let $f : \alpha \to \beta$ be a function between types $\alpha$ and $\beta$, where $\beta$ is a subsingleton (i.e., all elements of $\beta$ are equal). If the nonemptiness of a set $s \subseteq \alpha$ implies the nonemptiness of a set $t \subseteq \beta$, then $f$ maps every element of $s$ to an element of $t$.
Set.mapsTo_of_subsingleton theorem
[Subsingleton α] (f : α → α) (s : Set α) : MapsTo f s s
Full source
lemma mapsTo_of_subsingleton [Subsingleton α] (f : α → α) (s : Set α) : MapsTo f s s :=
  mapsTo_of_subsingleton' _ id
Mapping Property for Functions on Subsingleton Sets
Informal description
For any function $f : \alpha \to \alpha$ where $\alpha$ is a subsingleton (all elements are equal), and any subset $s \subseteq \alpha$, the function $f$ maps every element of $s$ to an element of $s$.
Set.MapsTo.mono theorem
(hf : MapsTo f s₁ t₁) (hs : s₂ ⊆ s₁) (ht : t₁ ⊆ t₂) : MapsTo f s₂ t₂
Full source
theorem MapsTo.mono (hf : MapsTo f s₁ t₁) (hs : s₂ ⊆ s₁) (ht : t₁ ⊆ t₂) : MapsTo f s₂ t₂ :=
  fun _ hx => ht (hf <| hs hx)
Monotonicity of MapsTo under set inclusion
Informal description
Let $f : \alpha \to \beta$ be a function, and let $s_1, s_2 \subseteq \alpha$ and $t_1, t_2 \subseteq \beta$ be sets. If $f$ maps $s_1$ into $t_1$ (i.e., $f(x) \in t_1$ for all $x \in s_1$), and we have $s_2 \subseteq s_1$ and $t_1 \subseteq t_2$, then $f$ maps $s_2$ into $t_2$.
Set.MapsTo.mono_left theorem
(hf : MapsTo f s₁ t) (hs : s₂ ⊆ s₁) : MapsTo f s₂ t
Full source
theorem MapsTo.mono_left (hf : MapsTo f s₁ t) (hs : s₂ ⊆ s₁) : MapsTo f s₂ t := fun _ hx =>
  hf (hs hx)
Restriction Preserves MapsTo Property
Informal description
Let $f : \alpha \to \alpha$ be a function, and let $s_1, s_2, t$ be subsets of $\alpha$. If $f$ maps $s_1$ into $t$ (i.e., $f(x) \in t$ for all $x \in s_1$) and $s_2 \subseteq s_1$, then $f$ maps $s_2$ into $t$.
Set.MapsTo.mono_right theorem
(hf : MapsTo f s t₁) (ht : t₁ ⊆ t₂) : MapsTo f s t₂
Full source
theorem MapsTo.mono_right (hf : MapsTo f s t₁) (ht : t₁ ⊆ t₂) : MapsTo f s t₂ := fun _ hx =>
  ht (hf hx)
MapsTo is Monotonic in the Target Set
Informal description
Let $f$ be a function that maps every element of a set $s$ to an element of a set $t_1$. If $t_1$ is a subset of $t_2$, then $f$ also maps every element of $s$ to an element of $t_2$.
Set.MapsTo.union_union theorem
(h₁ : MapsTo f s₁ t₁) (h₂ : MapsTo f s₂ t₂) : MapsTo f (s₁ ∪ s₂) (t₁ ∪ t₂)
Full source
theorem MapsTo.union_union (h₁ : MapsTo f s₁ t₁) (h₂ : MapsTo f s₂ t₂) :
    MapsTo f (s₁ ∪ s₂) (t₁ ∪ t₂) := fun _ hx =>
  hx.elim (fun hx => Or.inl <| h₁ hx) fun hx => Or.inr <| h₂ hx
Union Preservation of MapsTo: $f(s_1 \cup s_2) \subseteq t_1 \cup t_2$ under $f(s_i) \subseteq t_i$ for $i=1,2$
Informal description
Let $f$ be a function, and let $s_1, s_2$ and $t_1, t_2$ be sets. If $f$ maps every element of $s_1$ into $t_1$ and every element of $s_2$ into $t_2$, then $f$ maps every element of $s_1 \cup s_2$ into $t_1 \cup t_2$.
Set.MapsTo.union theorem
(h₁ : MapsTo f s₁ t) (h₂ : MapsTo f s₂ t) : MapsTo f (s₁ ∪ s₂) t
Full source
theorem MapsTo.union (h₁ : MapsTo f s₁ t) (h₂ : MapsTo f s₂ t) : MapsTo f (s₁ ∪ s₂) t :=
  union_self t ▸ h₁.union_union h₂
Union Preservation of MapsTo to Common Target: $f(s_1 \cup s_2) \subseteq t$ under $f(s_i) \subseteq t$ for $i=1,2$
Informal description
Let $f$ be a function, $s_1$ and $s_2$ be sets, and $t$ be a target set. If $f$ maps every element of $s_1$ into $t$ and every element of $s_2$ into $t$, then $f$ maps every element of $s_1 \cup s_2$ into $t$.
Set.mapsTo_union theorem
: MapsTo f (s₁ ∪ s₂) t ↔ MapsTo f s₁ t ∧ MapsTo f s₂ t
Full source
@[simp]
theorem mapsTo_union : MapsToMapsTo f (s₁ ∪ s₂) t ↔ MapsTo f s₁ t ∧ MapsTo f s₂ t :=
  ⟨fun h =>
    ⟨h.mono subset_union_left (Subset.refl t),
      h.mono subset_union_right (Subset.refl t)⟩,
    fun h => h.1.union h.2⟩
Characterization of MapsTo on Union: $f(s_1 \cup s_2) \subseteq t$ iff $f(s_1) \subseteq t$ and $f(s_2) \subseteq t$
Informal description
For any function $f : \alpha \to \beta$ and sets $s_1, s_2 \subseteq \alpha$, $t \subseteq \beta$, the following are equivalent: 1. $f$ maps every element of $s_1 \cup s_2$ into $t$; 2. $f$ maps every element of $s_1$ into $t$ and every element of $s_2$ into $t$. In other words, $f(s_1 \cup s_2) \subseteq t$ if and only if $f(s_1) \subseteq t$ and $f(s_2) \subseteq t$.
Set.MapsTo.inter theorem
(h₁ : MapsTo f s t₁) (h₂ : MapsTo f s t₂) : MapsTo f s (t₁ ∩ t₂)
Full source
theorem MapsTo.inter (h₁ : MapsTo f s t₁) (h₂ : MapsTo f s t₂) : MapsTo f s (t₁ ∩ t₂) := fun _ hx =>
  ⟨h₁ hx, h₂ hx⟩
Mapping to Intersection of Target Sets
Informal description
Let $f : \alpha \to \beta$ be a function, $s$ a subset of $\alpha$, and $t_1, t_2$ subsets of $\beta$. If $f$ maps every point of $s$ into $t_1$ and also maps every point of $s$ into $t_2$, then $f$ maps every point of $s$ into the intersection $t_1 \cap t_2$.
Set.MapsTo.insert theorem
(h : MapsTo f s t) (x : α) : MapsTo f (insert x s) (insert (f x) t)
Full source
lemma MapsTo.insert (h : MapsTo f s t) (x : α) : MapsTo f (insert x s) (insert (f x) t) := by
  simpa [← singleton_union] using h.mono_right subset_union_right
Extension of MapsTo by Insertion of a Point
Informal description
Let $f : \alpha \to \beta$ be a function, $s \subseteq \alpha$ a subset, and $t \subseteq \beta$ a subset. If $f$ maps every point of $s$ into $t$, then for any element $x \in \alpha$, $f$ maps every point of the set $\{x\} \cup s$ into the set $\{f(x)\} \cup t$.
Set.MapsTo.inter_inter theorem
(h₁ : MapsTo f s₁ t₁) (h₂ : MapsTo f s₂ t₂) : MapsTo f (s₁ ∩ s₂) (t₁ ∩ t₂)
Full source
theorem MapsTo.inter_inter (h₁ : MapsTo f s₁ t₁) (h₂ : MapsTo f s₂ t₂) :
    MapsTo f (s₁ ∩ s₂) (t₁ ∩ t₂) := fun _ hx => ⟨h₁ hx.1, h₂ hx.2⟩
Intersection Preservation under MapsTo
Informal description
Let $f : \alpha \to \beta$ be a function, and let $s_1, s_2 \subseteq \alpha$ and $t_1, t_2 \subseteq \beta$ be subsets. If $f$ maps $s_1$ into $t_1$ and $s_2$ into $t_2$, then $f$ maps the intersection $s_1 \cap s_2$ into the intersection $t_1 \cap t_2$.
Set.mapsTo_inter theorem
: MapsTo f s (t₁ ∩ t₂) ↔ MapsTo f s t₁ ∧ MapsTo f s t₂
Full source
@[simp]
theorem mapsTo_inter : MapsToMapsTo f s (t₁ ∩ t₂) ↔ MapsTo f s t₁ ∧ MapsTo f s t₂ :=
  ⟨fun h =>
    ⟨h.mono (Subset.refl s) inter_subset_left,
      h.mono (Subset.refl s) inter_subset_right⟩,
    fun h => h.1.inter h.2⟩
Characterization of Mapping into Intersection via Component Mappings
Informal description
For any function $f : \alpha \to \beta$ and subsets $s \subseteq \alpha$, $t_1 \subseteq \beta$, $t_2 \subseteq \beta$, the following are equivalent: 1. $f$ maps every point of $s$ into the intersection $t_1 \cap t_2$; 2. $f$ maps every point of $s$ into $t_1$ and also maps every point of $s$ into $t_2$. In other words, $f(s) \subseteq t_1 \cap t_2$ if and only if $f(s) \subseteq t_1$ and $f(s) \subseteq t_2$.
Set.mapsTo_univ theorem
(f : α → β) (s : Set α) : MapsTo f s univ
Full source
theorem mapsTo_univ (f : α → β) (s : Set α) : MapsTo f s univ := fun _ _ => trivial
Image of Any Set under Any Function is Contained in Universal Set
Informal description
For any function $f : \alpha \to \beta$ and any subset $s \subseteq \alpha$, the image of $s$ under $f$ is contained in the universal set of $\beta$ (i.e., $f(s) \subseteq \beta$).
Set.mapsTo_range theorem
(f : α → β) (s : Set α) : MapsTo f s (range f)
Full source
theorem mapsTo_range (f : α → β) (s : Set α) : MapsTo f s (range f) :=
  (mapsTo_image f s).mono (Subset.refl s) (image_subset_range _ _)
Image of Set under Function is Contained in its Range
Informal description
For any function $f : \alpha \to \beta$ and any subset $s \subseteq \alpha$, the image of $s$ under $f$ is contained in the range of $f$, i.e., $f(s) \subseteq \text{range}(f)$.
Set.mapsTo_image_iff theorem
{f : α → β} {g : γ → α} {s : Set γ} {t : Set β} : MapsTo f (g '' s) t ↔ MapsTo (f ∘ g) s t
Full source
@[simp]
theorem mapsTo_image_iff {f : α → β} {g : γ → α} {s : Set γ} {t : Set β} :
    MapsToMapsTo f (g '' s) t ↔ MapsTo (f ∘ g) s t :=
  ⟨fun h c hc => h ⟨c, hc, rfl⟩, fun h _ ⟨_, hc⟩ => hc.2 ▸ h hc.1⟩
Image Mapping Equivalence: $f(g(s)) \subseteq t \leftrightarrow (f \circ g)(s) \subseteq t$
Informal description
For functions $f : \alpha \to \beta$ and $g : \gamma \to \alpha$, and sets $s \subseteq \gamma$ and $t \subseteq \beta$, the following are equivalent: 1. $f$ maps the image $g(s)$ into $t$ (i.e., $f(g(s)) \subseteq t$); 2. The composition $f \circ g$ maps $s$ into $t$ (i.e., $(f \circ g)(s) \subseteq t$).
Set.MapsTo.comp_left theorem
(g : β → γ) (hf : MapsTo f s t) : MapsTo (g ∘ f) s (g '' t)
Full source
lemma MapsTo.comp_left (g : β → γ) (hf : MapsTo f s t) : MapsTo (g ∘ f) s (g '' t) :=
  fun x hx ↦ ⟨f x, hf hx, rfl⟩
Composition Preserves Mapping: $g \circ f(s) \subseteq g(t)$
Informal description
Given a function $g : \beta \to \gamma$ and a function $f : \alpha \to \beta$ that maps a set $s \subseteq \alpha$ into a set $t \subseteq \beta$, the composition $g \circ f$ maps $s$ into the image $g(t) \subseteq \gamma$.
Set.MapsTo.comp_right theorem
{s : Set β} {t : Set γ} (hg : MapsTo g s t) (f : α → β) : MapsTo (g ∘ f) (f ⁻¹' s) t
Full source
lemma MapsTo.comp_right {s : Set β} {t : Set γ} (hg : MapsTo g s t) (f : α → β) :
    MapsTo (g ∘ f) (f ⁻¹' s) t := fun _ hx ↦ hg hx
Composition Preserves Mapping Property on Preimage
Informal description
Let $s$ be a subset of $\beta$ and $t$ a subset of $\gamma$. If $g$ maps $s$ into $t$, then for any function $f : \alpha \to \beta$, the composition $g \circ f$ maps the preimage $f^{-1}(s)$ into $t$.
Set.mapsTo_range_iff theorem
{g : ι → α} : MapsTo f (range g) t ↔ ∀ i, f (g i) ∈ t
Full source
@[simp]
lemma mapsTo_range_iff {g : ι → α} : MapsToMapsTo f (range g) t ↔ ∀ i, f (g i) ∈ t :=
  forall_mem_range
Mapping Criterion for Function Range: $f(\text{range } g) \subseteq t \leftrightarrow \forall i, f(g(i)) \in t$
Informal description
For any function $f : \alpha \to \beta$ and set $t \subseteq \beta$, the following are equivalent: 1. $f$ maps the range of a function $g : \iota \to \alpha$ into $t$ (i.e., $f(\text{range } g) \subseteq t$) 2. For every index $i \in \iota$, the image $f(g(i))$ belongs to $t$
Set.MapsTo.mem_iff theorem
(h : MapsTo f s t) (hc : MapsTo f sᶜ tᶜ) {x} : f x ∈ t ↔ x ∈ s
Full source
theorem MapsTo.mem_iff (h : MapsTo f s t) (hc : MapsTo f sᶜ tᶜ) {x} : f x ∈ tf x ∈ t ↔ x ∈ s :=
  ⟨fun ht => by_contra fun hs => hc hs ht, fun hx => h hx⟩
Characterization of Set Membership via Mapping Properties: $f(x) \in t \leftrightarrow x \in s$ under Complementary Mapping Conditions
Informal description
Let $f : \alpha \to \beta$ be a function, $s \subseteq \alpha$ and $t \subseteq \beta$. If $f$ maps $s$ into $t$ and also maps the complement of $s$ into the complement of $t$, then for any $x \in \alpha$, we have $f(x) \in t$ if and only if $x \in s$.
Set.Subsingleton.injOn theorem
(hs : s.Subsingleton) (f : α → β) : InjOn f s
Full source
theorem Subsingleton.injOn (hs : s.Subsingleton) (f : α → β) : InjOn f s := fun _ hx _ hy _ =>
  hs hx hy
Injectivity on Subsingleton Sets
Informal description
For any subsingleton set $s$ (i.e., a set containing at most one element) and any function $f : \alpha \to \beta$, the restriction of $f$ to $s$ is injective.
Set.injOn_empty theorem
(f : α → β) : InjOn f ∅
Full source
@[simp]
theorem injOn_empty (f : α → β) : InjOn f  :=
  subsingleton_empty.injOn f
Injectivity on the Empty Set
Informal description
For any function $f : \alpha \to \beta$, the restriction of $f$ to the empty set $\emptyset$ is injective.
Set.injOn_singleton theorem
(f : α → β) (a : α) : InjOn f { a }
Full source
@[simp]
theorem injOn_singleton (f : α → β) (a : α) : InjOn f {a} :=
  subsingleton_singleton.injOn f
Injectivity on Singleton Sets
Informal description
For any function $f : \alpha \to \beta$ and any element $a \in \alpha$, the restriction of $f$ to the singleton set $\{a\}$ is injective.
Set.injOn_pair theorem
{b : α} : InjOn f { a, b } ↔ f a = f b → a = b
Full source
@[simp] lemma injOn_pair {b : α} : InjOnInjOn f {a, b} ↔ f a = f b → a = b := by unfold InjOn; aesop
Injectivity on a Pair: $f$ is injective on $\{a, b\}$ iff $f(a) = f(b) \to a = b$
Informal description
A function $f : \alpha \to \beta$ is injective on the two-element set $\{a, b\}$ if and only if for any $a, b \in \alpha$, the equality $f(a) = f(b)$ implies $a = b$.
Set.InjOn.ne_iff theorem
{x y} (h : InjOn f s) (hx : x ∈ s) (hy : y ∈ s) : f x ≠ f y ↔ x ≠ y
Full source
theorem InjOn.ne_iff {x y} (h : InjOn f s) (hx : x ∈ s) (hy : y ∈ s) : f x ≠ f yf x ≠ f y ↔ x ≠ y :=
  (h.eq_iff hx hy).not
Injectivity Preserves Inequality on a Set
Informal description
Let $f$ be a function injective on a set $s$, and let $x, y \in s$. Then $f(x) \neq f(y)$ if and only if $x \neq y$.
Set.InjOn.congr theorem
(h₁ : InjOn f₁ s) (h : EqOn f₁ f₂ s) : InjOn f₂ s
Full source
theorem InjOn.congr (h₁ : InjOn f₁ s) (h : EqOn f₁ f₂ s) : InjOn f₂ s := fun _ hx _ hy =>
  h hx ▸ h hy ▸ h₁ hx hy
Preservation of Injectivity under Function Equality on a Set
Informal description
Let $f_1$ and $f_2$ be functions defined on a set $s$. If $f_1$ is injective on $s$ and $f_1(x) = f_2(x)$ for all $x \in s$, then $f_2$ is also injective on $s$.
Set.EqOn.injOn_iff theorem
(H : EqOn f₁ f₂ s) : InjOn f₁ s ↔ InjOn f₂ s
Full source
theorem EqOn.injOn_iff (H : EqOn f₁ f₂ s) : InjOnInjOn f₁ s ↔ InjOn f₂ s :=
  ⟨fun h => h.congr H, fun h => h.congr H.symm⟩
Injectivity Equivalence Under Function Equality on a Set
Informal description
For any two functions $f_1, f_2 : \alpha \to \beta$ and any subset $s \subseteq \alpha$, if $f_1$ and $f_2$ are equal on $s$ (i.e., $f_1(x) = f_2(x)$ for all $x \in s$), then $f_1$ is injective on $s$ if and only if $f_2$ is injective on $s$.
Set.InjOn.mono theorem
(h : s₁ ⊆ s₂) (ht : InjOn f s₂) : InjOn f s₁
Full source
theorem InjOn.mono (h : s₁ ⊆ s₂) (ht : InjOn f s₂) : InjOn f s₁ := fun _ hx _ hy H =>
  ht (h hx) (h hy) H
Injectivity Preserved Under Subset Restriction
Informal description
Let $f : \alpha \to \beta$ be a function and $s_1, s_2$ be subsets of $\alpha$ such that $s_1 \subseteq s_2$. If $f$ is injective on $s_2$, then $f$ is injective on $s_1$.
Set.injOn_union theorem
(h : Disjoint s₁ s₂) : InjOn f (s₁ ∪ s₂) ↔ InjOn f s₁ ∧ InjOn f s₂ ∧ ∀ x ∈ s₁, ∀ y ∈ s₂, f x ≠ f y
Full source
theorem injOn_union (h : Disjoint s₁ s₂) :
    InjOnInjOn f (s₁ ∪ s₂) ↔ InjOn f s₁ ∧ InjOn f s₂ ∧ ∀ x ∈ s₁, ∀ y ∈ s₂, f x ≠ f y := by
  refine ⟨fun H => ⟨H.mono subset_union_left, H.mono subset_union_right, ?_⟩, ?_⟩
  · intro x hx y hy hxy
    obtain rfl : x = y := H (Or.inl hx) (Or.inr hy) hxy
    exact h.le_bot ⟨hx, hy⟩
  · rintro ⟨h₁, h₂, h₁₂⟩
    rintro x (hx | hx) y (hy | hy) hxy
    exacts [h₁ hx hy hxy, (h₁₂ _ hx _ hy hxy).elim, (h₁₂ _ hy _ hx hxy.symm).elim, h₂ hx hy hxy]
Injectivity on Union of Disjoint Sets
Informal description
Let $f : \alpha \to \beta$ be a function and $s_1, s_2$ be disjoint subsets of $\alpha$. Then $f$ is injective on $s_1 \cup s_2$ if and only if the following three conditions hold: 1. $f$ is injective on $s_1$, 2. $f$ is injective on $s_2$, and 3. For all $x \in s_1$ and $y \in s_2$, we have $f(x) \neq f(y)$.
Set.injOn_insert theorem
{f : α → β} {s : Set α} {a : α} (has : a ∉ s) : Set.InjOn f (insert a s) ↔ Set.InjOn f s ∧ f a ∉ f '' s
Full source
theorem injOn_insert {f : α → β} {s : Set α} {a : α} (has : a ∉ s) :
    Set.InjOnSet.InjOn f (insert a s) ↔ Set.InjOn f s ∧ f a ∉ f '' s := by
  rw [← union_singleton, injOn_union (disjoint_singleton_right.2 has)]
  simp
Injectivity on Insertion of a New Element
Informal description
Let $f : \alpha \to \beta$ be a function, $s \subseteq \alpha$ a subset, and $a \in \alpha$ an element not in $s$. Then $f$ is injective on the set $\{a\} \cup s$ if and only if: 1. $f$ is injective on $s$, and 2. The image of $a$ under $f$ is not in the image of $s$ under $f$, i.e., $f(a) \notin f(s)$.
Set.injOn_of_injective theorem
(h : Injective f) {s : Set α} : InjOn f s
Full source
theorem injOn_of_injective (h : Injective f) {s : Set α} : InjOn f s := fun _ _ _ _ hxy => h hxy
Injective Function Restriction to Subset Preserves Injectivity
Informal description
If a function $f : \alpha \to \beta$ is injective, then its restriction to any subset $s \subseteq \alpha$ is also injective. In other words, for any $x, y \in s$, if $f(x) = f(y)$, then $x = y$.
Set.injOn_subtype_val theorem
{s : Set { x // p x }} : Set.InjOn Subtype.val s
Full source
theorem injOn_subtype_val {s : Set { x // p x }} : Set.InjOn Subtype.val s :=
  Subtype.coe_injective.injOn
Injectivity of Subtype Projection on Subsets
Informal description
For any subset $s$ of a subtype $\{x \mid p\, x\}$, the restriction of the canonical projection function $\mathrm{val}$ (which maps $\langle x, h\rangle$ to $x$) to $s$ is injective.
Set.injOn_id theorem
(s : Set α) : InjOn id s
Full source
lemma injOn_id (s : Set α) : InjOn id s := injective_id.injOn
Injectivity of Identity Function on Any Set
Informal description
For any set $s$ in a type $\alpha$, the identity function $\mathrm{id} : \alpha \to \alpha$ is injective when restricted to $s$.
Set.InjOn.comp theorem
(hg : InjOn g t) (hf : InjOn f s) (h : MapsTo f s t) : InjOn (g ∘ f) s
Full source
theorem InjOn.comp (hg : InjOn g t) (hf : InjOn f s) (h : MapsTo f s t) : InjOn (g ∘ f) s :=
  fun _ hx _ hy heq => hf hx hy <| hg (h hx) (h hy) heq
Composition Preserves Injectivity on Sets
Informal description
Let $f : \alpha \to \beta$ and $g : \beta \to \gamma$ be functions, and let $s \subseteq \alpha$ and $t \subseteq \beta$ be sets. If $g$ is injective on $t$, $f$ is injective on $s$, and $f$ maps every element of $s$ into $t$, then the composition $g \circ f$ is injective on $s$.
Set.InjOn.of_comp theorem
(h : InjOn (g ∘ f) s) : InjOn f s
Full source
lemma InjOn.of_comp (h : InjOn (g ∘ f) s) : InjOn f s :=
  fun _ hx _ hy heq ↦ h hx hy (by simp [heq])
Injectivity of Function Composition Implies Injectivity of Inner Function
Informal description
If the composition $g \circ f$ is injective on a set $s$, then $f$ is injective on $s$.
Set.InjOn.image_of_comp theorem
(h : InjOn (g ∘ f) s) : InjOn g (f '' s)
Full source
lemma InjOn.image_of_comp (h : InjOn (g ∘ f) s) : InjOn g (f '' s) :=
  forall_mem_image.2 fun _x hx ↦ forall_mem_image.2 fun _y hy heq ↦ congr_arg f <| h hx hy heq
Injectivity of $g$ on the Image of $f$ under Composition Condition
Informal description
If the composition $g \circ f$ is injective on a set $s$, then $g$ is injective on the image $f(s)$.
Set.InjOn.comp_iff theorem
(hf : InjOn f s) : InjOn (g ∘ f) s ↔ InjOn g (f '' s)
Full source
lemma InjOn.comp_iff (hf : InjOn f s) : InjOnInjOn (g ∘ f) s ↔ InjOn g (f '' s) :=
  ⟨image_of_comp, fun h ↦ InjOn.comp h hf <| mapsTo_image f s⟩
Injectivity of Composition Equivalence: $g \circ f$ injective on $s$ $\leftrightarrow$ $g$ injective on $f(s)$
Informal description
Let $f : \alpha \to \beta$ be a function injective on a set $s \subseteq \alpha$, and let $g : \beta \to \gamma$ be another function. Then the composition $g \circ f$ is injective on $s$ if and only if $g$ is injective on the image $f(s)$.
Set.InjOn.iterate theorem
{f : α → α} {s : Set α} (h : InjOn f s) (hf : MapsTo f s s) : ∀ n, InjOn f^[n] s
Full source
lemma InjOn.iterate {f : α → α} {s : Set α} (h : InjOn f s) (hf : MapsTo f s s) :
    ∀ n, InjOn f^[n] s
  | 0 => injOn_id _
  | (n + 1) => (h.iterate hf n).comp h hf
Iterates Preserve Injectivity on a Set
Informal description
Let $f : \alpha \to \alpha$ be a function that is injective on a set $s \subseteq \alpha$, and suppose $f$ maps $s$ into itself. Then for any natural number $n$, the $n$-th iterate $f^{[n]}$ of $f$ is also injective on $s$.
Set.injOn_of_subsingleton theorem
[Subsingleton α] (f : α → β) (s : Set α) : InjOn f s
Full source
lemma injOn_of_subsingleton [Subsingleton α] (f : α → β) (s : Set α) : InjOn f s :=
  (injective_of_subsingleton _).injOn
Injectivity of Functions on Subsingleton Domains
Informal description
For any subsingleton type $\alpha$ (a type with at most one element), any function $f : \alpha \to \beta$, and any subset $s \subseteq \alpha$, the function $f$ is injective on $s$.
Function.Injective.injOn_range theorem
(h : Injective (g ∘ f)) : InjOn g (range f)
Full source
theorem _root_.Function.Injective.injOn_range (h : Injective (g ∘ f)) : InjOn g (range f) := by
  rintro _ ⟨x, rfl⟩ _ ⟨y, rfl⟩ H
  exact congr_arg f (h H)
Injectivity of Composition Implies Injectivity on Range
Informal description
If the composition $g \circ f$ is injective, then the function $g$ is injective on the range of $f$, i.e., for any $y_1, y_2 \in \text{range}(f)$, $g(y_1) = g(y_2)$ implies $y_1 = y_2$.
Set.InjOn.injective_iff theorem
(s : Set β) (h : InjOn g s) (hs : range f ⊆ s) : Injective (g ∘ f) ↔ Injective f
Full source
theorem _root_.Set.InjOn.injective_iff (s : Set β) (h : InjOn g s) (hs : rangerange f ⊆ s) :
    InjectiveInjective (g ∘ f) ↔ Injective f :=
  ⟨(·.of_comp), fun h _ ↦ by aesop⟩
Injectivity of Composition vs. Injectivity of Components
Informal description
Let $f : \alpha \to \beta$ and $g : \beta \to \gamma$ be functions, and let $s$ be a subset of $\beta$ such that the range of $f$ is contained in $s$. If $g$ is injective on $s$, then the composition $g \circ f$ is injective if and only if $f$ is injective.
Set.exists_injOn_iff_injective theorem
[Nonempty β] : (∃ f : α → β, InjOn f s) ↔ ∃ f : s → β, Injective f
Full source
theorem exists_injOn_iff_injective [Nonempty β] :
    (∃ f : α → β, InjOn f s) ↔ ∃ f : s → β, Injective f :=
  ⟨fun ⟨_, hf⟩ => ⟨_, hf.injective⟩,
   fun ⟨f, hf⟩ => by
    lift f to α → β using trivial
    exact ⟨f, injOn_iff_injective.2 hf⟩⟩
Existence of Injective Function on Set vs. Existence of Injective Function from Set
Informal description
For a nonempty type $\beta$, there exists a function $f : \alpha \to \beta$ that is injective on a set $s \subseteq \alpha$ if and only if there exists an injective function $f : s \to \beta$.
Set.injOn_preimage theorem
{B : Set (Set β)} (hB : B ⊆ 𝒫 range f) : InjOn (preimage f) B
Full source
theorem injOn_preimage {B : Set (Set β)} (hB : B ⊆ 𝒫 range f) : InjOn (preimage f) B :=
  fun _ hs _ ht hst => (preimage_eq_preimage' (hB hs) (hB ht)).1 hst
Injectivity of Preimage Function on Subsets of Range
Informal description
For any family of subsets $B$ of $\beta$ such that every element of $B$ is a subset of the range of $f$, the preimage function $f^{-1}$ is injective when restricted to $B$.
Set.InjOn.mem_of_mem_image theorem
{x} (hf : InjOn f s) (hs : s₁ ⊆ s) (h : x ∈ s) (h₁ : f x ∈ f '' s₁) : x ∈ s₁
Full source
theorem InjOn.mem_of_mem_image {x} (hf : InjOn f s) (hs : s₁ ⊆ s) (h : x ∈ s) (h₁ : f x ∈ f '' s₁) :
    x ∈ s₁ :=
  let ⟨_, h', Eq⟩ := h₁
  hf (hs h') h Eq ▸ h'
Injectivity Implies Preimage Membership in Subset
Informal description
Let $f$ be a function defined on a set $s$, and let $s_1$ be a subset of $s$. If $f$ is injective on $s$ and $x$ is an element of $s$ such that $f(x)$ belongs to the image $f(s_1)$, then $x$ must belong to $s_1$.
Set.InjOn.mem_image_iff theorem
{x} (hf : InjOn f s) (hs : s₁ ⊆ s) (hx : x ∈ s) : f x ∈ f '' s₁ ↔ x ∈ s₁
Full source
theorem InjOn.mem_image_iff {x} (hf : InjOn f s) (hs : s₁ ⊆ s) (hx : x ∈ s) :
    f x ∈ f '' s₁f x ∈ f '' s₁ ↔ x ∈ s₁ :=
  ⟨hf.mem_of_mem_image hs hx, mem_image_of_mem f⟩
Injectivity Characterizes Preimage Membership via Images
Informal description
Let $f : \alpha \to \beta$ be a function, $s \subseteq \alpha$ a set on which $f$ is injective, and $s_1 \subseteq s$ a subset. Then for any $x \in s$, we have $f(x) \in f(s_1)$ if and only if $x \in s_1$.
Set.InjOn.preimage_image_inter theorem
(hf : InjOn f s) (hs : s₁ ⊆ s) : f ⁻¹' (f '' s₁) ∩ s = s₁
Full source
theorem InjOn.preimage_image_inter (hf : InjOn f s) (hs : s₁ ⊆ s) : f ⁻¹' (f '' s₁)f ⁻¹' (f '' s₁) ∩ s = s₁ :=
  ext fun _ => ⟨fun ⟨h₁, h₂⟩ => hf.mem_of_mem_image hs h₂ h₁, fun h => ⟨mem_image_of_mem _ h, hs h⟩⟩
Preimage of Image Equals Original Set for Injective Functions
Informal description
Let $f$ be a function defined on a set $s$, and let $s_1$ be a subset of $s$. If $f$ is injective on $s$, then the intersection of the preimage of the image of $s_1$ under $f$ with $s$ equals $s_1$, i.e., $$ f^{-1}(f(s_1)) \cap s = s_1. $$
Set.EqOn.cancel_left theorem
(h : s.EqOn (g ∘ f₁) (g ∘ f₂)) (hg : t.InjOn g) (hf₁ : s.MapsTo f₁ t) (hf₂ : s.MapsTo f₂ t) : s.EqOn f₁ f₂
Full source
theorem EqOn.cancel_left (h : s.EqOn (g ∘ f₁) (g ∘ f₂)) (hg : t.InjOn g) (hf₁ : s.MapsTo f₁ t)
    (hf₂ : s.MapsTo f₂ t) : s.EqOn f₁ f₂ := fun _ ha => hg (hf₁ ha) (hf₂ ha) (h ha)
Cancellation of Left Composition under Equality on a Set
Informal description
Let $f_1, f_2 : \alpha \to \beta$ and $g : \beta \to \gamma$ be functions, and let $s \subseteq \alpha$, $t \subseteq \beta$ be sets. If: 1. The compositions $g \circ f_1$ and $g \circ f_2$ are equal on $s$ (i.e., $g(f_1(x)) = g(f_2(x))$ for all $x \in s$), 2. $g$ is injective on $t$, 3. $f_1$ maps $s$ into $t$, 4. $f_2$ maps $s$ into $t$, then $f_1$ and $f_2$ are equal on $s$ (i.e., $f_1(x) = f_2(x)$ for all $x \in s$).
Set.InjOn.cancel_left theorem
(hg : t.InjOn g) (hf₁ : s.MapsTo f₁ t) (hf₂ : s.MapsTo f₂ t) : s.EqOn (g ∘ f₁) (g ∘ f₂) ↔ s.EqOn f₁ f₂
Full source
theorem InjOn.cancel_left (hg : t.InjOn g) (hf₁ : s.MapsTo f₁ t) (hf₂ : s.MapsTo f₂ t) :
    s.EqOn (g ∘ f₁) (g ∘ f₂) ↔ s.EqOn f₁ f₂ :=
  ⟨fun h => h.cancel_left hg hf₁ hf₂, EqOn.comp_left⟩
Injective Cancellation of Left Composition on Sets
Informal description
Let $f_1, f_2 : \alpha \to \beta$ and $g : \beta \to \gamma$ be functions, and let $s \subseteq \alpha$, $t \subseteq \beta$ be sets. Suppose that: 1. $g$ is injective on $t$, 2. $f_1$ maps $s$ into $t$, 3. $f_2$ maps $s$ into $t$. Then the compositions $g \circ f_1$ and $g \circ f_2$ are equal on $s$ if and only if $f_1$ and $f_2$ are equal on $s$. In other words, for all $x \in s$, $$ g(f_1(x)) = g(f_2(x)) \leftrightarrow f_1(x) = f_2(x). $$
Set.InjOn.image_inter theorem
{s t u : Set α} (hf : u.InjOn f) (hs : s ⊆ u) (ht : t ⊆ u) : f '' (s ∩ t) = f '' s ∩ f '' t
Full source
lemma InjOn.image_inter {s t u : Set α} (hf : u.InjOn f) (hs : s ⊆ u) (ht : t ⊆ u) :
    f '' (s ∩ t) = f '' sf '' s ∩ f '' t := by
  apply Subset.antisymm (image_inter_subset _ _ _)
  intro x ⟨⟨y, ys, hy⟩, ⟨z, zt, hz⟩⟩
  have : y = z := by
    apply hf (hs ys) (ht zt)
    rwa [← hz] at hy
  rw [← this] at zt
  exact ⟨y, ⟨ys, zt⟩, hy⟩
Image of Intersection under Injective Function
Informal description
Let $f : \alpha \to \beta$ be a function and $u \subseteq \alpha$ a subset where $f$ is injective. For any subsets $s, t \subseteq u$, the image of the intersection $s \cap t$ under $f$ equals the intersection of the images $f(s) \cap f(t)$. That is, $$ f(s \cap t) = f(s) \cap f(t). $$
Set.InjOn.image theorem
(h : s.InjOn f) : s.powerset.InjOn (image f)
Full source
lemma InjOn.image (h : s.InjOn f) : s.powerset.InjOn (image f) :=
  fun s₁ hs₁ s₂ hs₂ h' ↦ by rw [← h.preimage_image_inter hs₁, h', h.preimage_image_inter hs₂]
Injectivity of Image Function on Power Set for Injective Functions
Informal description
Let $f : \alpha \to \beta$ be a function and $s \subseteq \alpha$ a subset where $f$ is injective. Then the image function $f$ is injective on the power set of $s$, i.e., for any subsets $s_1, s_2 \in \mathcal{P}(s)$, if $f(s_1) = f(s_2)$, then $s_1 = s_2$.
Set.InjOn.image_eq_image_iff theorem
(h : s.InjOn f) (h₁ : s₁ ⊆ s) (h₂ : s₂ ⊆ s) : f '' s₁ = f '' s₂ ↔ s₁ = s₂
Full source
theorem InjOn.image_eq_image_iff (h : s.InjOn f) (h₁ : s₁ ⊆ s) (h₂ : s₂ ⊆ s) :
    f '' s₁f '' s₁ = f '' s₂ ↔ s₁ = s₂ :=
  h.image.eq_iff h₁ h₂
Injectivity Condition for Image Equality of Subsets
Informal description
Let $f : \alpha \to \beta$ be a function that is injective on a subset $s \subseteq \alpha$. For any subsets $s_1, s_2 \subseteq s$, the images of $s_1$ and $s_2$ under $f$ are equal if and only if $s_1$ and $s_2$ are equal, i.e., $$ f(s_1) = f(s_2) \leftrightarrow s_1 = s_2. $$
Set.InjOn.image_subset_image_iff theorem
(h : s.InjOn f) (h₁ : s₁ ⊆ s) (h₂ : s₂ ⊆ s) : f '' s₁ ⊆ f '' s₂ ↔ s₁ ⊆ s₂
Full source
lemma InjOn.image_subset_image_iff (h : s.InjOn f) (h₁ : s₁ ⊆ s) (h₂ : s₂ ⊆ s) :
    f '' s₁f '' s₁ ⊆ f '' s₂f '' s₁ ⊆ f '' s₂ ↔ s₁ ⊆ s₂ := by
  refine ⟨fun h' ↦ ?_, image_subset _⟩
  rw [← h.preimage_image_inter h₁, ← h.preimage_image_inter h₂]
  exact inter_subset_inter_left _ (preimage_mono h')
Image Subset Relation Under Injective Function Reflects Subset Relation
Informal description
Let $f$ be a function defined on a set $s$, and let $s_1$ and $s_2$ be subsets of $s$. If $f$ is injective on $s$, then the image of $s_1$ under $f$ is a subset of the image of $s_2$ under $f$ if and only if $s_1$ is a subset of $s_2$, i.e., $$ f(s_1) \subseteq f(s_2) \leftrightarrow s_1 \subseteq s_2. $$
Set.InjOn.image_ssubset_image_iff theorem
(h : s.InjOn f) (h₁ : s₁ ⊆ s) (h₂ : s₂ ⊆ s) : f '' s₁ ⊂ f '' s₂ ↔ s₁ ⊂ s₂
Full source
lemma InjOn.image_ssubset_image_iff (h : s.InjOn f) (h₁ : s₁ ⊆ s) (h₂ : s₂ ⊆ s) :
    f '' s₁f '' s₁ ⊂ f '' s₂f '' s₁ ⊂ f '' s₂ ↔ s₁ ⊂ s₂ := by
  simp_rw [ssubset_def, h.image_subset_image_iff h₁ h₂, h.image_subset_image_iff h₂ h₁]
Strict Image Subset Relation Under Injective Function Reflects Strict Subset Relation
Informal description
Let $f$ be a function defined on a set $s$, and let $s_1$ and $s_2$ be subsets of $s$. If $f$ is injective on $s$, then the image of $s_1$ under $f$ is a strict subset of the image of $s_2$ under $f$ if and only if $s_1$ is a strict subset of $s_2$, i.e., $$ f(s_1) \subset f(s_2) \leftrightarrow s_1 \subset s_2. $$
Disjoint.image theorem
{s t u : Set α} {f : α → β} (h : Disjoint s t) (hf : u.InjOn f) (hs : s ⊆ u) (ht : t ⊆ u) : Disjoint (f '' s) (f '' t)
Full source
theorem _root_.Disjoint.image {s t u : Set α} {f : α → β} (h : Disjoint s t) (hf : u.InjOn f)
    (hs : s ⊆ u) (ht : t ⊆ u) : Disjoint (f '' s) (f '' t) := by
  rw [disjoint_iff_inter_eq_empty] at h ⊢
  rw [← hf.image_inter hs ht, h, image_empty]
Disjointness Preservation under Injective Images
Informal description
Let $f : \alpha \to \beta$ be a function and $u \subseteq \alpha$ a subset where $f$ is injective. For any disjoint subsets $s, t \subseteq u$, the images $f(s)$ and $f(t)$ are also disjoint, i.e., $$ f(s) \cap f(t) = \emptyset. $$
Set.InjOn.image_diff theorem
{t : Set α} (h : s.InjOn f) : f '' (s \ t) = f '' s \ f '' (s ∩ t)
Full source
lemma InjOn.image_diff {t : Set α} (h : s.InjOn f) : f '' (s \ t) = f '' sf '' s \ f '' (s ∩ t) := by
  refine subset_antisymm (subset_diff.2 ⟨image_subset f diff_subset, ?_⟩)
    (diff_subset_iff.2 (by rw [← image_union, inter_union_diff]))
  exact Disjoint.image disjoint_sdiff_inter h diff_subset inter_subset_left
Image of Set Difference Under Injective Function Equals Difference of Images
Informal description
Let $f : \alpha \to \beta$ be a function that is injective on a set $s \subseteq \alpha$. Then for any subset $t \subseteq \alpha$, the image of the set difference $s \setminus t$ under $f$ equals the set difference of the image of $s$ and the image of the intersection $s \cap t$, i.e., $$ f(s \setminus t) = f(s) \setminus f(s \cap t). $$
Set.InjOn.image_diff_subset theorem
{f : α → β} {t : Set α} (h : InjOn f s) (hst : t ⊆ s) : f '' (s \ t) = f '' s \ f '' t
Full source
lemma InjOn.image_diff_subset {f : α → β} {t : Set α} (h : InjOn f s) (hst : t ⊆ s) :
    f '' (s \ t) = f '' sf '' s \ f '' t := by
  rw [h.image_diff, inter_eq_self_of_subset_right hst]
Image of Set Difference Under Injective Function with Subset Condition
Informal description
Let $f : \alpha \to \beta$ be a function that is injective on a set $s \subseteq \alpha$, and let $t \subseteq s$ be a subset. Then the image of the set difference $s \setminus t$ under $f$ equals the set difference of the image of $s$ and the image of $t$, i.e., $$ f(s \setminus t) = f(s) \setminus f(t). $$
Set.InjOn.imageFactorization_injective theorem
(h : InjOn f s) : Injective (s.imageFactorization f)
Full source
theorem InjOn.imageFactorization_injective (h : InjOn f s) :
    Injective (s.imageFactorization f) :=
  fun ⟨x, hx⟩ ⟨y, hy⟩ h' ↦ by simpa [imageFactorization, h.eq_iff hx hy] using h'
Injectivity of Image Factorization for Injective Functions on a Set
Informal description
If a function $f : \alpha \to \beta$ is injective on a set $s \subseteq \alpha$, then the image factorization of $f$ restricted to $s$ is injective. That is, the function $s.\text{imageFactorization}\, f$ (which maps elements of $s$ to their images under $f$) is injective.
Set.imageFactorization_injective_iff theorem
: Injective (s.imageFactorization f) ↔ InjOn f s
Full source
@[simp] theorem imageFactorization_injective_iff : InjectiveInjective (s.imageFactorization f) ↔ InjOn f s :=
  ⟨fun h x hx y hy _ ↦ by simpa using @h ⟨x, hx⟩ ⟨y, hy⟩ (by simpa [imageFactorization]),
    InjOn.imageFactorization_injective⟩
Injectivity of Image Factorization vs Injectivity on Set
Informal description
The image factorization of a function $f$ restricted to a set $s$ is injective if and only if $f$ is injective on $s$. In other words, the function $s.\text{imageFactorization}\, f$ (which maps elements of $s$ to their images under $f$) is injective precisely when $f$ is injective on $s$.
Set.graphOn_univ_inj theorem
{g : α → β} : univ.graphOn f = univ.graphOn g ↔ f = g
Full source
lemma graphOn_univ_inj {g : α → β} : univuniv.graphOn f = univ.graphOn g ↔ f = g := by simp
Graph Equality Implies Function Equality on Universal Domain
Informal description
For any two functions $f, g : \alpha \to \beta$, the graphs of $f$ and $g$ over the universal set $\text{univ}$ (i.e., the entire domain $\alpha$) are equal if and only if the functions themselves are equal. In other words, $\{(x, f(x)) \mid x \in \alpha\} = \{(x, g(x)) \mid x \in \alpha\}$ holds precisely when $f = g$.
Set.graphOn_univ_injective theorem
: Injective (univ.graphOn : (α → β) → Set (α × β))
Full source
lemma graphOn_univ_injective : Injective (univ.graphOn : (α → β) → Set (α × β)) :=
  fun _f _g ↦ graphOn_univ_inj.1
Injectivity of Graph Construction over Universal Domain
Informal description
The function that maps each function $f : \alpha \to \beta$ to its graph $\{(x, f(x)) \mid x \in \alpha\}$ over the universal set $\alpha$ is injective. In other words, if two functions have identical graphs over the entire domain, then they must be the same function.
Set.exists_eq_graphOn_image_fst theorem
[Nonempty β] {s : Set (α × β)} : (∃ f : α → β, s = graphOn f (Prod.fst '' s)) ↔ InjOn Prod.fst s
Full source
lemma exists_eq_graphOn_image_fst [Nonempty β] {s : Set (α × β)} :
    (∃ f : α → β, s = graphOn f (Prod.fst '' s)) ↔ InjOn Prod.fst s := by
  refine ⟨?_, fun h ↦ ?_⟩
  · rintro ⟨f, hf⟩
    rw [hf]
    exact InjOn.image_of_comp <| injOn_id _
  · have : ∀ x ∈ Prod.fst '' s, ∃ y, (x, y) ∈ s := forall_mem_image.2 fun (x, y) h ↦ ⟨y, h⟩
    choose! f hf using this
    rw [forall_mem_image] at hf
    use f
    rw [graphOn, image_image, EqOn.image_eq_self]
    exact fun x hx ↦ h (hf hx) hx rfl
Graph Representation Theorem via First Projection Injectivity
Informal description
Let $\alpha$ and $\beta$ be types with $\beta$ nonempty, and let $s$ be a subset of $\alpha \times \beta$. There exists a function $f : \alpha \to \beta$ such that $s$ is equal to the graph of $f$ restricted to the projection of $s$ onto $\alpha$ (i.e., $s = \{(x, f(x)) \mid x \in \pi_1(s)\}$) if and only if the projection $\pi_1 : \alpha \times \beta \to \alpha$ is injective when restricted to $s$.
Set.exists_eq_graphOn theorem
[Nonempty β] {s : Set (α × β)} : (∃ f t, s = graphOn f t) ↔ InjOn Prod.fst s
Full source
lemma exists_eq_graphOn [Nonempty β] {s : Set (α × β)} :
    (∃ f t, s = graphOn f t) ↔ InjOn Prod.fst s :=
  .trans ⟨fun ⟨f, t, hs⟩ ↦ ⟨f, by rw [hs, image_fst_graphOn]⟩, fun ⟨f, hf⟩ ↦ ⟨f, _, hf⟩⟩
    exists_eq_graphOn_image_fst
Graph Representation Theorem via First Projection Injectivity (General Form)
Informal description
Let $\alpha$ and $\beta$ be types with $\beta$ nonempty, and let $s$ be a subset of $\alpha \times \beta$. There exists a function $f : \alpha \to \beta$ and a set $t \subseteq \alpha$ such that $s$ is equal to the graph of $f$ restricted to $t$ (i.e., $s = \{(x, f(x)) \mid x \in t\}$) if and only if the first projection $\pi_1 : \alpha \times \beta \to \alpha$ is injective when restricted to $s$.
Set.SurjOn.subset_range theorem
(h : SurjOn f s t) : t ⊆ range f
Full source
theorem SurjOn.subset_range (h : SurjOn f s t) : t ⊆ range f :=
  Subset.trans h <| image_subset_range f s
Surjective Function's Image Contains Target Set
Informal description
If a function $f$ is surjective from a set $s$ to a set $t$, then $t$ is a subset of the range of $f$, i.e., $t \subseteq \text{range}(f)$.
Set.surjOn_iff_exists_map_subtype theorem
: SurjOn f s t ↔ ∃ (t' : Set β) (g : s → t'), t ⊆ t' ∧ Surjective g ∧ ∀ x : s, f x = g x
Full source
theorem surjOn_iff_exists_map_subtype :
    SurjOnSurjOn f s t ↔ ∃ (t' : Set β) (g : s → t'), t ⊆ t' ∧ Surjective g ∧ ∀ x : s, f x = g x :=
  ⟨fun h =>
    ⟨_, (mapsTo_image f s).restrict f s _, h, surjective_mapsTo_image_restrict _ _, fun _ => rfl⟩,
    fun ⟨t', g, htt', hg, hfg⟩ y hy =>
    let ⟨x, hx⟩ := hg ⟨y, htt' hy⟩
    ⟨x, x.2, by rw [hfg, hx, Subtype.coe_mk]⟩⟩
Characterization of Surjectivity via Subtype Map
Informal description
A function $f : \alpha \to \beta$ is surjective from a set $s \subseteq \alpha$ to a set $t \subseteq \beta$ if and only if there exists a superset $t' \supseteq t$ and a surjective function $g : s \to t'$ such that $f(x) = g(x)$ for all $x \in s$.
Set.surjOn_empty theorem
(f : α → β) (s : Set α) : SurjOn f s ∅
Full source
theorem surjOn_empty (f : α → β) (s : Set α) : SurjOn f s  :=
  empty_subset _
Surjectivity onto Empty Set
Informal description
For any function $f : \alpha \to \beta$ and any set $s \subseteq \alpha$, the function $f$ is surjective onto the empty set, i.e., $\text{SurjOn}\ f\ s\ \emptyset$.
Set.surjOn_empty_iff theorem
: SurjOn f ∅ t ↔ t = ∅
Full source
@[simp] theorem surjOn_empty_iff : SurjOnSurjOn f ∅ t ↔ t = ∅ := by
  simp [SurjOn, subset_empty_iff]
Surjectivity on Empty Set Characterization: $f(\emptyset) = t \leftrightarrow t = \emptyset$
Informal description
For any function $f : \alpha \to \beta$ and any set $t \subseteq \beta$, the function $f$ is surjective on the empty set $\emptyset$ and $t$ if and only if $t$ is the empty set. In other words, $f$ maps $\emptyset$ onto $t$ precisely when $t = \emptyset$.
Set.surjOn_singleton theorem
: SurjOn f s { b } ↔ b ∈ f '' s
Full source
@[simp] lemma surjOn_singleton : SurjOnSurjOn f s {b} ↔ b ∈ f '' s := singleton_subset_iff
Surjectivity to Singleton Set Characterization
Informal description
A function $f$ is surjective from a set $s$ to the singleton set $\{b\}$ if and only if $b$ is in the image of $f$ on $s$, i.e., $b \in f(s)$.
Set.surjOn_image theorem
(f : α → β) (s : Set α) : SurjOn f s (f '' s)
Full source
theorem surjOn_image (f : α → β) (s : Set α) : SurjOn f s (f '' s) :=
  Subset.rfl
Surjectivity of a Function onto its Image
Informal description
For any function $f : \alpha \to \beta$ and any subset $s \subseteq \alpha$, the function $f$ is surjective from $s$ to its image $f(s) := \{f(x) \mid x \in s\}$.
Set.SurjOn.comap_nonempty theorem
(h : SurjOn f s t) (ht : t.Nonempty) : s.Nonempty
Full source
theorem SurjOn.comap_nonempty (h : SurjOn f s t) (ht : t.Nonempty) : s.Nonempty :=
  (ht.mono h).of_image
Nonempty Domain of Surjective Function
Informal description
If a function $f$ is surjective from a set $s$ to a nonempty set $t$, then $s$ is nonempty.
Set.SurjOn.congr theorem
(h : SurjOn f₁ s t) (H : EqOn f₁ f₂ s) : SurjOn f₂ s t
Full source
theorem SurjOn.congr (h : SurjOn f₁ s t) (H : EqOn f₁ f₂ s) : SurjOn f₂ s t := by
  rwa [SurjOn, ← H.image_eq]
Preservation of Surjectivity under Function Equality on Domain
Informal description
Let $f_1, f_2 : \alpha \to \beta$ be functions and $s \subseteq \alpha$, $t \subseteq \beta$ be sets. If $f_1$ is surjective from $s$ to $t$ and $f_1$ and $f_2$ are equal on $s$, then $f_2$ is also surjective from $s$ to $t$.
Set.EqOn.surjOn_iff theorem
(h : EqOn f₁ f₂ s) : SurjOn f₁ s t ↔ SurjOn f₂ s t
Full source
theorem EqOn.surjOn_iff (h : EqOn f₁ f₂ s) : SurjOnSurjOn f₁ s t ↔ SurjOn f₂ s t :=
  ⟨fun H => H.congr h, fun H => H.congr h.symm⟩
Equivalence of Surjectivity for Functionally Equal Mappings on a Domain
Informal description
For any two functions $f_1, f_2 : \alpha \to \beta$ and subsets $s \subseteq \alpha$, $t \subseteq \beta$, if $f_1$ and $f_2$ are equal on $s$ (i.e., $f_1(x) = f_2(x)$ for all $x \in s$), then $f_1$ is surjective from $s$ to $t$ if and only if $f_2$ is surjective from $s$ to $t$.
Set.SurjOn.mono theorem
(hs : s₁ ⊆ s₂) (ht : t₁ ⊆ t₂) (hf : SurjOn f s₁ t₂) : SurjOn f s₂ t₁
Full source
theorem SurjOn.mono (hs : s₁ ⊆ s₂) (ht : t₁ ⊆ t₂) (hf : SurjOn f s₁ t₂) : SurjOn f s₂ t₁ :=
  Subset.trans ht <| Subset.trans hf <| image_subset _ hs
Monotonicity of Surjectivity under Subset Containment
Informal description
Let $f$ be a function, $s_1 \subseteq s_2$ be subsets of its domain, and $t_1 \subseteq t_2$ be subsets of its codomain. If $f$ is surjective from $s_1$ to $t_2$, then $f$ is also surjective from $s_2$ to $t_1$.
Set.SurjOn.union theorem
(h₁ : SurjOn f s t₁) (h₂ : SurjOn f s t₂) : SurjOn f s (t₁ ∪ t₂)
Full source
theorem SurjOn.union (h₁ : SurjOn f s t₁) (h₂ : SurjOn f s t₂) : SurjOn f s (t₁ ∪ t₂) := fun _ hx =>
  hx.elim (fun hx => h₁ hx) fun hx => h₂ hx
Surjectivity Preserved Under Union of Codomains
Informal description
Let $f$ be a function, $s$ a set, and $t_1, t_2$ subsets of the codomain. If $f$ is surjective on $s$ to $t_1$ and surjective on $s$ to $t_2$, then $f$ is surjective on $s$ to the union $t_1 \cup t_2$.
Set.SurjOn.union_union theorem
(h₁ : SurjOn f s₁ t₁) (h₂ : SurjOn f s₂ t₂) : SurjOn f (s₁ ∪ s₂) (t₁ ∪ t₂)
Full source
theorem SurjOn.union_union (h₁ : SurjOn f s₁ t₁) (h₂ : SurjOn f s₂ t₂) :
    SurjOn f (s₁ ∪ s₂) (t₁ ∪ t₂) :=
  (h₁.mono subset_union_left (Subset.refl _)).union
    (h₂.mono subset_union_right (Subset.refl _))
Surjectivity Preserved Under Union of Domains and Codomains
Informal description
Let $f$ be a function, $s_1, s_2$ subsets of its domain, and $t_1, t_2$ subsets of its codomain. If $f$ is surjective from $s_1$ to $t_1$ and from $s_2$ to $t_2$, then $f$ is surjective from $s_1 \cup s_2$ to $t_1 \cup t_2$.
Set.SurjOn.inter_inter theorem
(h₁ : SurjOn f s₁ t₁) (h₂ : SurjOn f s₂ t₂) (h : InjOn f (s₁ ∪ s₂)) : SurjOn f (s₁ ∩ s₂) (t₁ ∩ t₂)
Full source
theorem SurjOn.inter_inter (h₁ : SurjOn f s₁ t₁) (h₂ : SurjOn f s₂ t₂) (h : InjOn f (s₁ ∪ s₂)) :
    SurjOn f (s₁ ∩ s₂) (t₁ ∩ t₂) := by
  intro y hy
  rcases h₁ hy.1 with ⟨x₁, hx₁, rfl⟩
  rcases h₂ hy.2 with ⟨x₂, hx₂, heq⟩
  obtain rfl : x₁ = x₂ := h (Or.inl hx₁) (Or.inr hx₂) heq.symm
  exact mem_image_of_mem f ⟨hx₁, hx₂⟩
Surjectivity Preserved Under Intersection for Injective Functions
Informal description
Let $f$ be a function, and let $s_1, s_2$ be subsets of its domain and $t_1, t_2$ subsets of its codomain. If $f$ is surjective on $s_1$ to $t_1$ and on $s_2$ to $t_2$, and if $f$ is injective on $s_1 \cup s_2$, then $f$ is surjective on $s_1 \cap s_2$ to $t_1 \cap t_2$.
Set.SurjOn.inter theorem
(h₁ : SurjOn f s₁ t) (h₂ : SurjOn f s₂ t) (h : InjOn f (s₁ ∪ s₂)) : SurjOn f (s₁ ∩ s₂) t
Full source
theorem SurjOn.inter (h₁ : SurjOn f s₁ t) (h₂ : SurjOn f s₂ t) (h : InjOn f (s₁ ∪ s₂)) :
    SurjOn f (s₁ ∩ s₂) t :=
  inter_self t ▸ h₁.inter_inter h₂ h
Surjectivity on Intersection of Domains for Injective Functions
Informal description
Let $f$ be a function, $s_1, s_2$ subsets of its domain, and $t$ a subset of its codomain. If $f$ is surjective from $s_1$ to $t$ and from $s_2$ to $t$, and if $f$ is injective on $s_1 \cup s_2$, then $f$ is surjective from $s_1 \cap s_2$ to $t$.
Set.surjOn_id theorem
(s : Set α) : SurjOn id s s
Full source
lemma surjOn_id (s : Set α) : SurjOn id s s := by simp [SurjOn]
Identity Function is Surjective on Any Set
Informal description
For any set $s$ in a type $\alpha$, the identity function $\text{id}$ is surjective from $s$ to $s$.
Set.SurjOn.comp theorem
(hg : SurjOn g t p) (hf : SurjOn f s t) : SurjOn (g ∘ f) s p
Full source
theorem SurjOn.comp (hg : SurjOn g t p) (hf : SurjOn f s t) : SurjOn (g ∘ f) s p :=
  Subset.trans hg <| Subset.trans (image_subset g hf) <| image_comp g f s ▸ Subset.refl _
Composition Preserves Surjectivity
Informal description
Let $f : s \to t$ and $g : t \to p$ be functions. If $f$ is surjective onto $t$ and $g$ is surjective onto $p$, then the composition $g \circ f$ is surjective onto $p$.
Set.SurjOn.of_comp theorem
(h : SurjOn (g ∘ f) s p) (hr : MapsTo f s t) : SurjOn g t p
Full source
lemma SurjOn.of_comp (h : SurjOn (g ∘ f) s p) (hr : MapsTo f s t) : SurjOn g t p := by
  intro z hz
  obtain ⟨x, hx, rfl⟩ := h hz
  exact ⟨f x, hr hx, rfl⟩
Surjectivity of a Function via Composition
Informal description
Let $f : \alpha \to \beta$ and $g : \beta \to \gamma$ be functions, and let $s \subseteq \alpha$, $t \subseteq \beta$, $p \subseteq \gamma$ be sets. If the composition $g \circ f$ is surjective from $s$ to $p$ (i.e., $\forall z \in p, \exists x \in s, g(f(x)) = z$) and $f$ maps $s$ into $t$ (i.e., $f(s) \subseteq t$), then $g$ is surjective from $t$ to $p$ (i.e., $\forall z \in p, \exists y \in t, g(y) = z$).
Set.surjOn_comp_iff theorem
: SurjOn (g ∘ f) s p ↔ SurjOn g (f '' s) p
Full source
lemma surjOn_comp_iff : SurjOnSurjOn (g ∘ f) s p ↔ SurjOn g (f '' s) p :=
  ⟨fun h ↦ h.of_comp <| mapsTo_image f s, fun h ↦ h.comp <| surjOn_image _ _⟩
Surjectivity of Composition Equivalence: $g \circ f$ surjective $\leftrightarrow$ $g$ surjective on $f(s)$
Informal description
For any functions $f : \alpha \to \beta$ and $g : \beta \to \gamma$, and sets $s \subseteq \alpha$ and $p \subseteq \gamma$, the composition $g \circ f$ is surjective from $s$ to $p$ if and only if $g$ is surjective from the image $f(s) \subseteq \beta$ to $p$.
Set.SurjOn.iterate theorem
{f : α → α} {s : Set α} (h : SurjOn f s s) : ∀ n, SurjOn f^[n] s s
Full source
lemma SurjOn.iterate {f : α → α} {s : Set α} (h : SurjOn f s s) : ∀ n, SurjOn f^[n] s s
  | 0 => surjOn_id _
  | (n + 1) => (h.iterate n).comp h
Iterates Preserve Surjectivity on a Set
Informal description
Let $f : \alpha \to \alpha$ be a function and $s \subseteq \alpha$ a set. If $f$ is surjective from $s$ to $s$ (i.e., for every $y \in s$, there exists $x \in s$ such that $f(x) = y$), then for every natural number $n$, the $n$-th iterate $f^{[n]}$ is also surjective from $s$ to $s$.
Set.SurjOn.comp_left theorem
(hf : SurjOn f s t) (g : β → γ) : SurjOn (g ∘ f) s (g '' t)
Full source
lemma SurjOn.comp_left (hf : SurjOn f s t) (g : β → γ) : SurjOn (g ∘ f) s (g '' t) := by
  rw [SurjOn, image_comp g f]; exact image_subset _ hf
Composition Preserves Surjectivity on Sets (Left)
Informal description
Let $f : \alpha \to \beta$ be a function that is surjective from a set $s \subseteq \alpha$ to a set $t \subseteq \beta$ (i.e., for every $y \in t$, there exists $x \in s$ such that $f(x) = y$). Then for any function $g : \beta \to \gamma$, the composition $g \circ f$ is surjective from $s$ to the image $g(t) \subseteq \gamma$.
Set.SurjOn.comp_right theorem
{s : Set β} {t : Set γ} (hf : Surjective f) (hg : SurjOn g s t) : SurjOn (g ∘ f) (f ⁻¹' s) t
Full source
lemma SurjOn.comp_right {s : Set β} {t : Set γ} (hf : Surjective f) (hg : SurjOn g s t) :
    SurjOn (g ∘ f) (f ⁻¹' s) t := by
  rwa [SurjOn, image_comp g f, image_preimage_eq _ hf]
Composition Preserves Surjectivity on Sets (Right)
Informal description
Let $f : \alpha \to \beta$ be a surjective function, and let $g : \beta \to \gamma$ be a function that is surjective from a set $s \subseteq \beta$ to a set $t \subseteq \gamma$. Then the composition $g \circ f$ is surjective from the preimage $f^{-1}(s) \subseteq \alpha$ to $t$.
Set.surjOn_of_subsingleton' theorem
[Subsingleton β] (f : α → β) (h : t.Nonempty → s.Nonempty) : SurjOn f s t
Full source
lemma surjOn_of_subsingleton' [Subsingleton β] (f : α → β) (h : t.Nonempty → s.Nonempty) :
    SurjOn f s t :=
  fun _ ha ↦ Subsingleton.mem_iff_nonempty.2 <| (h ⟨_, ha⟩).image _
Surjectivity of a Function on a Subsingleton Codomain
Informal description
Let $β$ be a type with at most one element (i.e., a subsingleton), and let $f : α → β$ be a function. If the nonemptiness of the set $t ⊆ β$ implies the nonemptiness of the set $s ⊆ α$, then $f$ maps $s$ surjectively onto $t$.
Set.surjOn_of_subsingleton theorem
[Subsingleton α] (f : α → α) (s : Set α) : SurjOn f s s
Full source
lemma surjOn_of_subsingleton [Subsingleton α] (f : α → α) (s : Set α) : SurjOn f s s :=
  surjOn_of_subsingleton' _ id
Surjectivity of Endofunction on Subsingleton Set
Informal description
Let $α$ be a type with at most one element (i.e., a subsingleton), and let $f : α → α$ be a function. Then for any subset $s$ of $α$, the function $f$ maps $s$ surjectively onto itself.
Set.surjective_iff_surjOn_univ theorem
: Surjective f ↔ SurjOn f univ univ
Full source
theorem surjective_iff_surjOn_univ : SurjectiveSurjective f ↔ SurjOn f univ univ := by
  simp [Surjective, SurjOn, subset_def]
Surjectivity Characterization via Universal Surjective On
Informal description
A function $f : \alpha \to \beta$ is surjective if and only if it maps the entire domain $\alpha$ (represented as `univ`) surjectively onto the entire codomain $\beta$ (also represented as `univ`). In other words, $f$ is surjective precisely when for every $y \in \beta$, there exists an $x \in \alpha$ such that $f(x) = y$.
Set.SurjOn.image_eq_of_mapsTo theorem
(h₁ : SurjOn f s t) (h₂ : MapsTo f s t) : f '' s = t
Full source
theorem SurjOn.image_eq_of_mapsTo (h₁ : SurjOn f s t) (h₂ : MapsTo f s t) : f '' s = t :=
  eq_of_subset_of_subset h₂.image_subset h₁
Image Equals Target under Surjective MapsTo Condition
Informal description
Let $f : X \to Y$ be a function, $s \subseteq X$, and $t \subseteq Y$. If $f$ is surjective from $s$ to $t$ (i.e., for every $y \in t$ there exists $x \in s$ such that $f(x) = y$) and $f$ maps every element of $s$ into $t$, then the image of $s$ under $f$ equals $t$, i.e., $f(s) = t$.
Set.image_eq_iff_surjOn_mapsTo theorem
: f '' s = t ↔ s.SurjOn f t ∧ s.MapsTo f t
Full source
theorem image_eq_iff_surjOn_mapsTo : f '' sf '' s = t ↔ s.SurjOn f t ∧ s.MapsTo f t := by
  refine ⟨?_, fun h => h.1.image_eq_of_mapsTo h.2⟩
  rintro rfl
  exact ⟨s.surjOn_image f, s.mapsTo_image f⟩
Image Equals Target iff Surjective and MapsTo
Informal description
For any function $f : \alpha \to \beta$ and subsets $s \subseteq \alpha$, $t \subseteq \beta$, the image of $s$ under $f$ equals $t$ if and only if $f$ is surjective from $s$ to $t$ and $f$ maps every element of $s$ into $t$. In other words: $$ f(s) = t \iff (\forall y \in t, \exists x \in s, f(x) = y) \land (\forall x \in s, f(x) \in t) $$
Set.SurjOn.image_preimage theorem
(h : Set.SurjOn f s t) (ht : t₁ ⊆ t) : f '' (f ⁻¹' t₁) = t₁
Full source
lemma SurjOn.image_preimage (h : Set.SurjOn f s t) (ht : t₁ ⊆ t) : f '' (f ⁻¹' t₁) = t₁ :=
  image_preimage_eq_iff.2 fun _ hx ↦ mem_range_of_mem_image f s <| h <| ht hx
Image of Preimage Equals Subset under Surjective Restriction
Informal description
Let $f : X \to Y$ be a function, $s \subseteq X$, and $t \subseteq Y$ such that $f$ is surjective from $s$ to $t$ (i.e., for every $y \in t$, there exists $x \in s$ with $f(x) = y$). Then for any subset $t_1 \subseteq t$, the image of the preimage of $t_1$ under $f$ equals $t_1$, i.e., $f(f^{-1}(t_1)) = t_1$.
Set.SurjOn.mapsTo_compl theorem
(h : SurjOn f s t) (h' : Injective f) : MapsTo f sᶜ tᶜ
Full source
theorem SurjOn.mapsTo_compl (h : SurjOn f s t) (h' : Injective f) : MapsTo f sᶜ tᶜ :=
  fun _ hs ht =>
  let ⟨_, hx', HEq⟩ := h ht
  hs <| h' HEq ▸ hx'
Surjective and Injective Function Maps Complement to Complement
Informal description
Let $f : X \to Y$ be a function, $s \subseteq X$, and $t \subseteq Y$ such that $f$ is surjective from $s$ to $t$ (i.e., for every $y \in t$, there exists $x \in s$ with $f(x) = y$). If $f$ is injective, then $f$ maps the complement of $s$ into the complement of $t$, i.e., $f(s^c) \subseteq t^c$.
Set.MapsTo.surjOn_compl theorem
(h : MapsTo f s t) (h' : Surjective f) : SurjOn f sᶜ tᶜ
Full source
theorem MapsTo.surjOn_compl (h : MapsTo f s t) (h' : Surjective f) : SurjOn f sᶜ tᶜ :=
  h'.forall.2 fun _ ht => (mem_image_of_mem _) fun hs => ht (h hs)
Surjectivity of a Function on Complements under Mapping Condition
Informal description
Let $f : X \to Y$ be a surjective function, and let $s \subseteq X$ and $t \subseteq Y$ be sets such that $f$ maps $s$ into $t$ (i.e., $f(x) \in t$ for all $x \in s$). Then $f$ is surjective from the complement of $s$ to the complement of $t$, i.e., for every $y \in t^c$, there exists $x \in s^c$ such that $f(x) = y$.
Set.EqOn.cancel_right theorem
(hf : s.EqOn (g₁ ∘ f) (g₂ ∘ f)) (hf' : s.SurjOn f t) : t.EqOn g₁ g₂
Full source
theorem EqOn.cancel_right (hf : s.EqOn (g₁ ∘ f) (g₂ ∘ f)) (hf' : s.SurjOn f t) : t.EqOn g₁ g₂ := by
  intro b hb
  obtain ⟨a, ha, rfl⟩ := hf' hb
  exact hf ha
Cancellation of Function Equality under Composition with a Surjective Function
Informal description
Let $f : s \to t$ be a surjective function from set $s$ to set $t$, and let $g_1, g_2 : t \to \alpha$ be functions. If the compositions $g_1 \circ f$ and $g_2 \circ f$ are equal on $s$, then $g_1$ and $g_2$ are equal on $t$.
Set.SurjOn.cancel_right theorem
(hf : s.SurjOn f t) (hf' : s.MapsTo f t) : s.EqOn (g₁ ∘ f) (g₂ ∘ f) ↔ t.EqOn g₁ g₂
Full source
theorem SurjOn.cancel_right (hf : s.SurjOn f t) (hf' : s.MapsTo f t) :
    s.EqOn (g₁ ∘ f) (g₂ ∘ f) ↔ t.EqOn g₁ g₂ :=
  ⟨fun h => h.cancel_right hf, fun h => h.comp_right hf'⟩
Equivalence of Function Equality under Composition with a Surjective Map
Informal description
Let $f : \alpha \to \beta$ be a function, $s \subseteq \alpha$ and $t \subseteq \beta$ be sets, and $g_1, g_2 : \beta \to \gamma$ be functions. If $f$ is surjective from $s$ to $t$ (i.e., for every $y \in t$ there exists $x \in s$ such that $f(x) = y$) and $f$ maps $s$ into $t$ (i.e., $f(x) \in t$ for all $x \in s$), then the following equivalence holds: \[ g_1 \circ f = g_2 \circ f \text{ on } s \quad \text{if and only if} \quad g_1 = g_2 \text{ on } t. \]
Set.eqOn_comp_right_iff theorem
: s.EqOn (g₁ ∘ f) (g₂ ∘ f) ↔ (f '' s).EqOn g₁ g₂
Full source
theorem eqOn_comp_right_iff : s.EqOn (g₁ ∘ f) (g₂ ∘ f) ↔ (f '' s).EqOn g₁ g₂ :=
  (s.surjOn_image f).cancel_right <| s.mapsTo_image f
Equality of Compositions on a Set and its Image
Informal description
For functions $f : \alpha \to \beta$, $g_1, g_2 : \beta \to \gamma$, and a set $s \subseteq \alpha$, the compositions $g_1 \circ f$ and $g_2 \circ f$ are equal on $s$ if and only if $g_1$ and $g_2$ are equal on the image $f(s) := \{f(x) \mid x \in s\}$. In other words: \[ g_1 \circ f = g_2 \circ f \text{ on } s \quad \text{if and only if} \quad g_1 = g_2 \text{ on } f(s). \]
Set.SurjOn.forall theorem
{p : β → Prop} (hf : s.SurjOn f t) (hf' : s.MapsTo f t) : (∀ y ∈ t, p y) ↔ (∀ x ∈ s, p (f x))
Full source
theorem SurjOn.forall {p : β → Prop} (hf : s.SurjOn f t) (hf' : s.MapsTo f t) :
    (∀ y ∈ t, p y) ↔ (∀ x ∈ s, p (f x)) :=
  ⟨fun H x hx ↦ H (f x) (hf' hx), fun H _y hy ↦ let ⟨x, hx, hxy⟩ := hf hy; hxy ▸ H x hx⟩
Universal Quantifier Transfer via Surjective Maps
Informal description
Let $f : \alpha \to \beta$ be a function, $s \subseteq \alpha$ and $t \subseteq \beta$ be sets, and $p : \beta \to \text{Prop}$ be a predicate. If $f$ is surjective from $s$ to $t$ (i.e., $\forall y \in t, \exists x \in s, f(x) = y$) and $f$ maps $s$ into $t$ (i.e., $\forall x \in s, f(x) \in t$), then the following equivalence holds: \[ (\forall y \in t, p(y)) \leftrightarrow (\forall x \in s, p(f(x))) \]
Set.BijOn.mapsTo theorem
(h : BijOn f s t) : MapsTo f s t
Full source
theorem BijOn.mapsTo (h : BijOn f s t) : MapsTo f s t :=
  h.left
Bijection Implies Mapping to Target Set
Informal description
If $f$ is a bijection from set $s$ to set $t$, then $f$ maps every element of $s$ to an element of $t$.
Set.BijOn.injOn theorem
(h : BijOn f s t) : InjOn f s
Full source
theorem BijOn.injOn (h : BijOn f s t) : InjOn f s :=
  h.right.left
Injectivity of a Bijective Function on its Domain
Informal description
If a function $f$ is a bijection from a set $s$ to a set $t$, then $f$ is injective on $s$.
Set.BijOn.surjOn theorem
(h : BijOn f s t) : SurjOn f s t
Full source
theorem BijOn.surjOn (h : BijOn f s t) : SurjOn f s t :=
  h.right.right
Bijectivity Implies Surjectivity on Sets
Informal description
If a function $f$ is a bijection from a set $s$ to a set $t$, then $f$ is surjective from $s$ to $t$, meaning that for every $y \in t$, there exists an $x \in s$ such that $f(x) = y$.
Set.BijOn.mk theorem
(h₁ : MapsTo f s t) (h₂ : InjOn f s) (h₃ : SurjOn f s t) : BijOn f s t
Full source
theorem BijOn.mk (h₁ : MapsTo f s t) (h₂ : InjOn f s) (h₃ : SurjOn f s t) : BijOn f s t :=
  ⟨h₁, h₂, h₃⟩
Characterization of Bijective Functions via Injectivity and Surjectivity
Informal description
Let $f : \alpha \to \beta$ be a function, and let $s \subseteq \alpha$, $t \subseteq \beta$. If: 1. $f$ maps every point of $s$ into $t$ (i.e., $f(x) \in t$ for all $x \in s$), 2. $f$ is injective when restricted to $s$ (i.e., $f(x_1) = f(x_2)$ implies $x_1 = x_2$ for all $x_1, x_2 \in s$), and 3. $f$ is surjective from $s$ to $t$ (i.e., for every $y \in t$ there exists $x \in s$ such that $f(x) = y$), then $f$ is a bijection between $s$ and $t$.
Set.bijOn_singleton theorem
: BijOn f { a } { b } ↔ f a = b
Full source
@[simp] lemma bijOn_singleton : BijOnBijOn f {a} {b} ↔ f a = b := by simp [BijOn, eq_comm]
Bijection between Singletons is Determined by Function Value
Informal description
A function $f$ is a bijection between the singleton set $\{a\}$ and the singleton set $\{b\}$ if and only if $f(a) = b$.
Set.BijOn.inter_mapsTo theorem
(h₁ : BijOn f s₁ t₁) (h₂ : MapsTo f s₂ t₂) (h₃ : s₁ ∩ f ⁻¹' t₂ ⊆ s₂) : BijOn f (s₁ ∩ s₂) (t₁ ∩ t₂)
Full source
theorem BijOn.inter_mapsTo (h₁ : BijOn f s₁ t₁) (h₂ : MapsTo f s₂ t₂) (h₃ : s₁ ∩ f ⁻¹' t₂s₁ ∩ f ⁻¹' t₂ ⊆ s₂) :
    BijOn f (s₁ ∩ s₂) (t₁ ∩ t₂) :=
  ⟨h₁.mapsTo.inter_inter h₂, h₁.injOn.mono inter_subset_left, fun _ hy =>
    let ⟨x, hx, hxy⟩ := h₁.surjOn hy.1
    ⟨x, ⟨hx, h₃ ⟨hx, hxy.symm.subst hy.2⟩⟩, hxy⟩⟩
Bijectivity of Intersection under MapsTo Condition
Informal description
Let $f : \alpha \to \beta$ be a function, and let $s_1, s_2 \subseteq \alpha$ and $t_1, t_2 \subseteq \beta$ be subsets. If $f$ is a bijection from $s_1$ to $t_1$, $f$ maps $s_2$ into $t_2$, and the intersection $s_1 \cap f^{-1}(t_2)$ is contained in $s_2$, then $f$ is a bijection from $s_1 \cap s_2$ to $t_1 \cap t_2$.
Set.MapsTo.inter_bijOn theorem
(h₁ : MapsTo f s₁ t₁) (h₂ : BijOn f s₂ t₂) (h₃ : s₂ ∩ f ⁻¹' t₁ ⊆ s₁) : BijOn f (s₁ ∩ s₂) (t₁ ∩ t₂)
Full source
theorem MapsTo.inter_bijOn (h₁ : MapsTo f s₁ t₁) (h₂ : BijOn f s₂ t₂) (h₃ : s₂ ∩ f ⁻¹' t₁s₂ ∩ f ⁻¹' t₁ ⊆ s₁) :
    BijOn f (s₁ ∩ s₂) (t₁ ∩ t₂) :=
  inter_comm s₂ s₁ ▸ inter_comm t₂ t₁ ▸ h₂.inter_mapsTo h₁ h₃
Bijectivity of Intersection under MapsTo and BijOn Conditions
Informal description
Let $f : \alpha \to \beta$ be a function, and let $s_1, s_2 \subseteq \alpha$ and $t_1, t_2 \subseteq \beta$ be subsets. If $f$ maps $s_1$ into $t_1$, $f$ is a bijection from $s_2$ to $t_2$, and the intersection $s_2 \cap f^{-1}(t_1)$ is contained in $s_1$, then $f$ is a bijection from $s_1 \cap s_2$ to $t_1 \cap t_2$.
Set.BijOn.inter theorem
(h₁ : BijOn f s₁ t₁) (h₂ : BijOn f s₂ t₂) (h : InjOn f (s₁ ∪ s₂)) : BijOn f (s₁ ∩ s₂) (t₁ ∩ t₂)
Full source
theorem BijOn.inter (h₁ : BijOn f s₁ t₁) (h₂ : BijOn f s₂ t₂) (h : InjOn f (s₁ ∪ s₂)) :
    BijOn f (s₁ ∩ s₂) (t₁ ∩ t₂) :=
  ⟨h₁.mapsTo.inter_inter h₂.mapsTo, h₁.injOn.mono inter_subset_left,
    h₁.surjOn.inter_inter h₂.surjOn h⟩
Bijectivity Preserved Under Intersection for Injective Functions on Union
Informal description
Let $f : \alpha \to \beta$ be a function, and let $s_1, s_2 \subseteq \alpha$ and $t_1, t_2 \subseteq \beta$ be subsets. If $f$ is a bijection from $s_1$ to $t_1$ and from $s_2$ to $t_2$, and if $f$ is injective on $s_1 \cup s_2$, then $f$ is a bijection from $s_1 \cap s_2$ to $t_1 \cap t_2$.
Set.BijOn.union theorem
(h₁ : BijOn f s₁ t₁) (h₂ : BijOn f s₂ t₂) (h : InjOn f (s₁ ∪ s₂)) : BijOn f (s₁ ∪ s₂) (t₁ ∪ t₂)
Full source
theorem BijOn.union (h₁ : BijOn f s₁ t₁) (h₂ : BijOn f s₂ t₂) (h : InjOn f (s₁ ∪ s₂)) :
    BijOn f (s₁ ∪ s₂) (t₁ ∪ t₂) :=
  ⟨h₁.mapsTo.union_union h₂.mapsTo, h, h₁.surjOn.union_union h₂.surjOn⟩
Bijectivity Preserved Under Union for Injective Functions on Union
Informal description
Let $f : \alpha \to \beta$ be a function, and let $s_1, s_2 \subseteq \alpha$ and $t_1, t_2 \subseteq \beta$ be subsets. If $f$ is a bijection from $s_1$ to $t_1$ and from $s_2$ to $t_2$, and if $f$ is injective on $s_1 \cup s_2$, then $f$ is a bijection from $s_1 \cup s_2$ to $t_1 \cup t_2$.
Set.BijOn.subset_range theorem
(h : BijOn f s t) : t ⊆ range f
Full source
theorem BijOn.subset_range (h : BijOn f s t) : t ⊆ range f :=
  h.surjOn.subset_range
Bijection Implies Target Subset of Range
Informal description
If a function $f$ is a bijection from a set $s$ to a set $t$, then $t$ is a subset of the range of $f$, i.e., $t \subseteq \text{range}(f)$.
Set.InjOn.bijOn_image theorem
(h : InjOn f s) : BijOn f s (f '' s)
Full source
theorem InjOn.bijOn_image (h : InjOn f s) : BijOn f s (f '' s) :=
  BijOn.mk (mapsTo_image f s) h (Subset.refl _)
Injective Function Induces Bijection with Its Image
Informal description
Let $f : \alpha \to \beta$ be a function and $s \subseteq \alpha$. If $f$ is injective on $s$, then $f$ is a bijection between $s$ and its image $f(s) = \{f(x) \mid x \in s\}$.
Set.BijOn.congr theorem
(h₁ : BijOn f₁ s t) (h : EqOn f₁ f₂ s) : BijOn f₂ s t
Full source
theorem BijOn.congr (h₁ : BijOn f₁ s t) (h : EqOn f₁ f₂ s) : BijOn f₂ s t :=
  BijOn.mk (h₁.mapsTo.congr h) (h₁.injOn.congr h) (h₁.surjOn.congr h)
Preservation of Bijectivity under Function Equality on Domain
Informal description
Let $f_1, f_2 : \alpha \to \beta$ be functions and $s \subseteq \alpha$, $t \subseteq \beta$ be sets. If $f_1$ is a bijection from $s$ to $t$ and $f_1(x) = f_2(x)$ for all $x \in s$, then $f_2$ is also a bijection from $s$ to $t$.
Set.EqOn.bijOn_iff theorem
(H : EqOn f₁ f₂ s) : BijOn f₁ s t ↔ BijOn f₂ s t
Full source
theorem EqOn.bijOn_iff (H : EqOn f₁ f₂ s) : BijOnBijOn f₁ s t ↔ BijOn f₂ s t :=
  ⟨fun h => h.congr H, fun h => h.congr H.symm⟩
Bijectivity Equivalence under Function Equality on Domain
Informal description
Let $f_1, f_2 : \alpha \to \beta$ be functions and $s \subseteq \alpha$, $t \subseteq \beta$ be sets. If $f_1$ and $f_2$ are equal on $s$ (i.e., $f_1(x) = f_2(x)$ for all $x \in s$), then $f_1$ is a bijection from $s$ to $t$ if and only if $f_2$ is a bijection from $s$ to $t$.
Set.BijOn.image_eq theorem
(h : BijOn f s t) : f '' s = t
Full source
theorem BijOn.image_eq (h : BijOn f s t) : f '' s = t :=
  h.surjOn.image_eq_of_mapsTo h.mapsTo
Image of Domain under Bijection Equals Target Set
Informal description
If $f$ is a bijection from a set $s$ to a set $t$, then the image of $s$ under $f$ is equal to $t$, i.e., $f(s) = t$.
Set.BijOn.forall theorem
{p : β → Prop} (hf : BijOn f s t) : (∀ b ∈ t, p b) ↔ ∀ a ∈ s, p (f a)
Full source
lemma BijOn.forall {p : β → Prop} (hf : BijOn f s t) : (∀ b ∈ t, p b) ↔ ∀ a ∈ s, p (f a) where
  mp h _ ha := h _ <| hf.mapsTo ha
  mpr h b hb := by obtain ⟨a, ha, rfl⟩ := hf.surjOn hb; exact h _ ha
Universal Property of Bijections: $\forall b \in t, p(b) \leftrightarrow \forall a \in s, p(f(a))$
Informal description
Let $f$ be a bijection from a set $s$ to a set $t$, and let $p$ be a predicate on elements of $t$. Then for every $b \in t$, $p(b)$ holds if and only if for every $a \in s$, $p(f(a))$ holds.
Set.BijOn.exists theorem
{p : β → Prop} (hf : BijOn f s t) : (∃ b ∈ t, p b) ↔ ∃ a ∈ s, p (f a)
Full source
lemma BijOn.exists {p : β → Prop} (hf : BijOn f s t) : (∃ b ∈ t, p b) ↔ ∃ a ∈ s, p (f a) where
  mp := by rintro ⟨b, hb, h⟩; obtain ⟨a, ha, rfl⟩ := hf.surjOn hb; exact ⟨a, ha, h⟩
  mpr := by rintro ⟨a, ha, h⟩; exact ⟨f a, hf.mapsTo ha, h⟩
Existence Transfer via Bijection: $(\exists b \in t, p(b)) \leftrightarrow (\exists a \in s, p(f(a)))$
Informal description
Let $f$ be a bijection from set $s$ to set $t$. For any predicate $p$ on elements of $t$, there exists an element $b \in t$ satisfying $p(b)$ if and only if there exists an element $a \in s$ satisfying $p(f(a))$.
Equiv.image_eq_iff_bijOn theorem
(e : α ≃ β) : e '' s = t ↔ BijOn e s t
Full source
lemma _root_.Equiv.image_eq_iff_bijOn (e : α ≃ β) : e '' se '' s = t ↔ BijOn e s t :=
  ⟨fun h ↦ ⟨(mapsTo_image e s).mono_right h.subset, e.injective.injOn, h ▸ surjOn_image e s⟩,
  BijOn.image_eq⟩
Image Equivalence Criterion for Bijections: $e(s) = t \leftrightarrow \text{BijOn}\ e\ s\ t$
Informal description
For any equivalence (bijection) $e : \alpha \simeq \beta$ between types $\alpha$ and $\beta$, and for any subsets $s \subseteq \alpha$ and $t \subseteq \beta$, the image of $s$ under $e$ equals $t$ if and only if $e$ is a bijection from $s$ to $t$. In other words, $e(s) = t \leftrightarrow \text{BijOn}\ e\ s\ t$.
Set.bijOn_id theorem
(s : Set α) : BijOn id s s
Full source
lemma bijOn_id (s : Set α) : BijOn id s s := ⟨s.mapsTo_id, s.injOn_id, s.surjOn_id⟩
Identity Function is a Bijection on Any Set
Informal description
For any set $s$ in a type $\alpha$, the identity function $\mathrm{id} : \alpha \to \alpha$ is a bijection from $s$ to itself.
Set.BijOn.comp theorem
(hg : BijOn g t p) (hf : BijOn f s t) : BijOn (g ∘ f) s p
Full source
theorem BijOn.comp (hg : BijOn g t p) (hf : BijOn f s t) : BijOn (g ∘ f) s p :=
  BijOn.mk (hg.mapsTo.comp hf.mapsTo) (hg.injOn.comp hf.injOn hf.mapsTo) (hg.surjOn.comp hf.surjOn)
Composition of Bijections is a Bijection
Informal description
Let $f : \alpha \to \beta$ and $g : \beta \to \gamma$ be functions, and let $s \subseteq \alpha$, $t \subseteq \beta$, $p \subseteq \gamma$ be subsets. If $f$ is a bijection from $s$ to $t$ and $g$ is a bijection from $t$ to $p$, then the composition $g \circ f$ is a bijection from $s$ to $p$.
Set.bijOn_comp_iff theorem
(hf : InjOn f s) : BijOn (g ∘ f) s p ↔ BijOn g (f '' s) p
Full source
/-- If `f : α → β` and `g : β → γ` and if `f` is injective on `s`, then `f ∘ g` is a bijection
on `s` iff  `g` is a bijection on `f '' s`. -/
theorem bijOn_comp_iff (hf : InjOn f s) : BijOnBijOn (g ∘ f) s p ↔ BijOn g (f '' s) p := by
  simp only [BijOn, InjOn.comp_iff, surjOn_comp_iff, mapsTo_image_iff, hf]
Bijection of Composition iff Bijection on Image
Informal description
Let $f : \alpha \to \beta$ and $g : \beta \to \gamma$ be functions, and let $s \subseteq \alpha$ be a set. If $f$ is injective on $s$, then the composition $g \circ f$ is a bijection from $s$ to $p$ if and only if $g$ is a bijection from the image $f(s)$ to $p$.
Set.bijOn_image_image theorem
{p₁ : α → γ} {p₂ : β → δ} {g : γ → δ} (comm : ∀ a, p₂ (f a) = g (p₁ a)) (hbij : BijOn f s t) (hinj : InjOn g (p₁ '' s)) : BijOn g (p₁ '' s) (p₂ '' t)
Full source
/--
If we have a commutative square

```
α --f--> β
|        |
p₁       p₂
|        |
\/       \/
γ --g--> δ
```

and `f` induces a bijection from `s : Set α` to `t : Set β`, then `g`
induces a bijection from the image of `s` to the image of `t`, as long as `g` is
is injective on the image of `s`.
-/
theorem bijOn_image_image {p₁ : α → γ} {p₂ : β → δ} {g : γ → δ} (comm : ∀ a, p₂ (f a) = g (p₁ a))
    (hbij : BijOn f s t) (hinj: InjOn g (p₁ '' s)) : BijOn g (p₁ '' s) (p₂ '' t) := by
  obtain ⟨h1, h2, h3⟩ := hbij
  refine ⟨?_, hinj, ?_⟩
  · rintro _ ⟨a, ha, rfl⟩
    exact ⟨f a, h1 ha, by rw [comm a]⟩
  · rintro _ ⟨b, hb, rfl⟩
    obtain ⟨a, ha, rfl⟩ := h3 hb
    rw [← image_comp, comm]
    exact ⟨a, ha, rfl⟩
Bijection Preservation in Commutative Diagram
Informal description
Consider a commutative diagram of functions: \[ \begin{array}{ccc} \alpha & \xrightarrow{f} & \beta \\ p_1 \downarrow & & \downarrow p_2 \\ \gamma & \xrightarrow{g} & \delta \end{array} \] where $p_2 \circ f = g \circ p_1$ holds for all $a \in \alpha$. If $f$ is a bijection between sets $s \subseteq \alpha$ and $t \subseteq \beta$, and $g$ is injective on the image $p_1(s) \subseteq \gamma$, then $g$ induces a bijection between $p_1(s)$ and $p_2(t)$.
Set.BijOn.iterate theorem
{f : α → α} {s : Set α} (h : BijOn f s s) : ∀ n, BijOn f^[n] s s
Full source
lemma BijOn.iterate {f : α → α} {s : Set α} (h : BijOn f s s) : ∀ n, BijOn f^[n] s s
  | 0 => s.bijOn_id
  | (n + 1) => (h.iterate n).comp h
Iterated Bijection Preserves Bijectivity
Informal description
Let $f : \alpha \to \alpha$ be a function and $s \subseteq \alpha$ a subset. If $f$ is a bijection from $s$ to itself, then for any natural number $n$, the $n$-th iterate $f^{[n]}$ is also a bijection from $s$ to itself.
Set.bijOn_of_subsingleton' theorem
[Subsingleton α] [Subsingleton β] (f : α → β) (h : s.Nonempty ↔ t.Nonempty) : BijOn f s t
Full source
lemma bijOn_of_subsingleton' [Subsingleton α] [Subsingleton β] (f : α → β)
    (h : s.Nonempty ↔ t.Nonempty) : BijOn f s t :=
  ⟨mapsTo_of_subsingleton' _ h.1, injOn_of_subsingleton _ _, surjOn_of_subsingleton' _ h.2⟩
Bijection between Subsingleton Sets under Nonempty Condition
Informal description
Let $\alpha$ and $\beta$ be types with at most one element (subsingletons), and let $f : \alpha \to \beta$ be a function. If a subset $s \subseteq \alpha$ is nonempty if and only if a subset $t \subseteq \beta$ is nonempty, then $f$ is a bijection between $s$ and $t$.
Set.bijOn_of_subsingleton theorem
[Subsingleton α] (f : α → α) (s : Set α) : BijOn f s s
Full source
lemma bijOn_of_subsingleton [Subsingleton α] (f : α → α) (s : Set α) : BijOn f s s :=
  bijOn_of_subsingleton' _ Iff.rfl
Bijection on Subsingleton Sets
Informal description
For any type $\alpha$ with at most one element (subsingleton) and any function $f : \alpha \to \alpha$, the function $f$ is a bijection between any subset $s \subseteq \alpha$ and itself.
Set.BijOn.bijective theorem
(h : BijOn f s t) : Bijective (h.mapsTo.restrict f s t)
Full source
theorem BijOn.bijective (h : BijOn f s t) : Bijective (h.mapsTo.restrict f s t) :=
  ⟨fun x y h' => Subtype.ext <| h.injOn x.2 y.2 <| Subtype.ext_iff.1 h', fun ⟨_, hy⟩ =>
    let ⟨x, hx, hxy⟩ := h.surjOn hy
    ⟨⟨x, hx⟩, Subtype.eq hxy⟩⟩
Restriction of a Set Bijection is Bijective
Informal description
Given a function $f : \alpha \to \beta$ that is a bijection between sets $s \subseteq \alpha$ and $t \subseteq \beta$, the restriction of $f$ to $s$ (denoted $f|_s$) is a bijective function from $s$ to $t$.
Set.bijective_iff_bijOn_univ theorem
: Bijective f ↔ BijOn f univ univ
Full source
theorem bijective_iff_bijOn_univ : BijectiveBijective f ↔ BijOn f univ univ :=
  Iff.intro
    (fun h =>
      let ⟨inj, surj⟩ := h
      ⟨mapsTo_univ f _, inj.injOn, Iff.mp surjective_iff_surjOn_univ surj⟩)
    fun h =>
    let ⟨_map, inj, surj⟩ := h
    ⟨Iff.mpr injective_iff_injOn_univ inj, Iff.mpr surjective_iff_surjOn_univ surj⟩
Characterization of Bijectivity via Bijection on Universal Sets
Informal description
A function $f : \alpha \to \beta$ is bijective if and only if it is a bijection from the entire domain $\alpha$ to the entire codomain $\beta$.
Set.BijOn.compl theorem
(hst : BijOn f s t) (hf : Bijective f) : BijOn f sᶜ tᶜ
Full source
theorem BijOn.compl (hst : BijOn f s t) (hf : Bijective f) : BijOn f sᶜ tᶜ :=
  ⟨hst.surjOn.mapsTo_compl hf.1, hf.1.injOn, hst.mapsTo.surjOn_compl hf.2⟩
Bijection on Complements of Sets
Informal description
Let $f : \alpha \to \beta$ be a bijective function, and let $s \subseteq \alpha$ and $t \subseteq \beta$ be sets such that $f$ is a bijection from $s$ to $t$. Then $f$ is also a bijection from the complement of $s$ to the complement of $t$.
Set.BijOn.subset_right theorem
{r : Set β} (hf : BijOn f s t) (hrt : r ⊆ t) : BijOn f (s ∩ f ⁻¹' r) r
Full source
theorem BijOn.subset_right {r : Set β} (hf : BijOn f s t) (hrt : r ⊆ t) :
    BijOn f (s ∩ f ⁻¹' r) r := by
  refine ⟨inter_subset_right, hf.injOn.mono inter_subset_left, fun x hx ↦ ?_⟩
  obtain ⟨y, hy, rfl⟩ := hf.surjOn (hrt hx)
  exact ⟨y, ⟨hy, hx⟩, rfl⟩
Bijectivity Preserved Under Right Subset Restriction
Informal description
Let $f : \alpha \to \beta$ be a function, $s \subseteq \alpha$, $t \subseteq \beta$, and $r \subseteq t$. If $f$ is a bijection from $s$ to $t$, then $f$ is also a bijection from $s \cap f^{-1}(r)$ to $r$.
Set.BijOn.subset_left theorem
{r : Set α} (hf : BijOn f s t) (hrs : r ⊆ s) : BijOn f r (f '' r)
Full source
theorem BijOn.subset_left {r : Set α} (hf : BijOn f s t) (hrs : r ⊆ s) :
    BijOn f r (f '' r) :=
  (hf.injOn.mono hrs).bijOn_image
Bijectivity Preserved Under Left Subset Restriction
Informal description
Let $f : \alpha \to \beta$ be a function, $s \subseteq \alpha$, $t \subseteq \beta$, and $r \subseteq s$. If $f$ is a bijection from $s$ to $t$, then $f$ is also a bijection from $r$ to its image $f(r) = \{f(x) \mid x \in r\}$.
Set.BijOn.insert_iff theorem
(ha : a ∉ s) (hfa : f a ∉ t) : BijOn f (insert a s) (insert (f a) t) ↔ BijOn f s t
Full source
theorem BijOn.insert_iff (ha : a ∉ s) (hfa : f a ∉ t) :
    BijOnBijOn f (insert a s) (insert (f a) t) ↔ BijOn f s t where
  mp h := by
    have := congrArg (· \ {f a}) (image_insert_eq ▸ h.image_eq)
    simp only [mem_singleton_iff, insert_diff_of_mem] at this
    rw [diff_singleton_eq_self hfa, diff_singleton_eq_self] at this
    · exact ⟨by simp [← this, mapsTo'], h.injOn.mono (subset_insert ..),
        by simp [← this, surjOn_image]⟩
    simp only [mem_image, not_exists, not_and]
    intro x hx
    rw [h.injOn.eq_iff (by simp [hx]) (by simp)]
    exact ha ∘ (· ▸ hx)
  mpr h := by
    repeat rw [insert_eq]
    refine (bijOn_singleton.mpr rfl).union h ?_
    simp only [singleton_union, injOn_insert fun x ↦ (hfa (h.mapsTo x)), h.injOn, mem_image,
      not_exists, not_and, true_and]
    exact fun _ hx h₂ ↦ hfa (h₂ ▸ h.mapsTo hx)
Bijectivity Condition for Insertion of a New Element and Its Image
Informal description
Let $f : \alpha \to \beta$ be a function, $s \subseteq \alpha$ a subset, $a \in \alpha$ an element not in $s$, and $t \subseteq \beta$ a subset such that $f(a) \notin t$. Then $f$ is a bijection from $\{a\} \cup s$ to $\{f(a)\} \cup t$ if and only if $f$ is a bijection from $s$ to $t$.
Set.BijOn.insert theorem
(h₁ : BijOn f s t) (h₂ : f a ∉ t) : BijOn f (insert a s) (insert (f a) t)
Full source
theorem BijOn.insert (h₁ : BijOn f s t) (h₂ : f a ∉ t) :
    BijOn f (insert a s) (insert (f a) t) :=
  (insert_iff (h₂ <| h₁.mapsTo ·) h₂).mpr h₁
Bijection Extension by Adding a Point and Its Image
Informal description
Let $f : \alpha \to \beta$ be a function, $s \subseteq \alpha$, $t \subseteq \beta$, and $a \in \alpha$. If $f$ is a bijection from $s$ to $t$ and $f(a) \notin t$, then $f$ is also a bijection from $\{a\} \cup s$ to $\{f(a)\} \cup t$.
Set.BijOn.sdiff_singleton theorem
(h₁ : BijOn f s t) (h₂ : a ∈ s) : BijOn f (s \ { a }) (t \ {f a})
Full source
theorem BijOn.sdiff_singleton (h₁ : BijOn f s t) (h₂ : a ∈ s) :
    BijOn f (s \ {a}) (t \ {f a}) := by
  convert h₁.subset_left diff_subset
  simp [h₁.injOn.image_diff, h₁.image_eq, h₂, inter_eq_self_of_subset_right]
Bijectivity Preserved Under Removal of a Point and its Image
Informal description
Let $f : \alpha \to \beta$ be a function, $s \subseteq \alpha$, and $t \subseteq \beta$. If $f$ is a bijection from $s$ to $t$ and $a \in s$, then $f$ is also a bijection from the set difference $s \setminus \{a\}$ to the set difference $t \setminus \{f(a)\}$.
Set.LeftInvOn.eqOn theorem
(h : LeftInvOn f' f s) : EqOn (f' ∘ f) id s
Full source
theorem eqOn (h : LeftInvOn f' f s) : EqOn (f' ∘ f) id s :=
  h
Composition of Left Inverse with Function Equals Identity on Domain
Informal description
Let $f : \alpha \to \beta$ and $f' : \beta \to \alpha$ be functions, and let $s \subseteq \alpha$ be a set. If $f'$ is a left inverse of $f$ on $s$ (i.e., $f'(f(x)) = x$ for all $x \in s$), then the composition $f' \circ f$ is equal to the identity function $\text{id}$ on $s$.
Set.LeftInvOn.eq theorem
(h : LeftInvOn f' f s) {x} (hx : x ∈ s) : f' (f x) = x
Full source
theorem eq (h : LeftInvOn f' f s) {x} (hx : x ∈ s) : f' (f x) = x :=
  h hx
Left Inverse Property on a Set
Informal description
Let $f : \alpha \to \beta$ and $f' : \beta \to \alpha$ be functions, and let $s$ be a subset of $\alpha$. If $f'$ is a left inverse of $f$ on $s$ (i.e., for all $x \in s$, $f'(f(x)) = x$), then for any $x \in s$, we have $f'(f(x)) = x$.
Set.LeftInvOn.congr_left theorem
(h₁ : LeftInvOn f₁' f s) {t : Set β} (h₁' : MapsTo f s t) (heq : EqOn f₁' f₂' t) : LeftInvOn f₂' f s
Full source
theorem congr_left (h₁ : LeftInvOn f₁' f s) {t : Set β} (h₁' : MapsTo f s t)
    (heq : EqOn f₁' f₂' t) : LeftInvOn f₂' f s := fun _ hx => heq (h₁' hx) ▸ h₁ hx
Left Inverse Preservation under Function Equality on Range
Informal description
Let $f : \alpha \to \beta$ be a function, $s \subseteq \alpha$, and $f_1', f_2' : \beta \to \alpha$ be functions. Suppose that: 1. $f_1'$ is a left inverse of $f$ on $s$ (i.e., $f_1'(f(x)) = x$ for all $x \in s$), 2. $f$ maps $s$ into a set $t \subseteq \beta$ (i.e., $f(s) \subseteq t$), and 3. $f_1'$ and $f_2'$ agree on $t$ (i.e., $f_1'(y) = f_2'(y)$ for all $y \in t$). Then $f_2'$ is also a left inverse of $f$ on $s$.
Set.LeftInvOn.congr_right theorem
(h₁ : LeftInvOn f₁' f₁ s) (heq : EqOn f₁ f₂ s) : LeftInvOn f₁' f₂ s
Full source
theorem congr_right (h₁ : LeftInvOn f₁' f₁ s) (heq : EqOn f₁ f₂ s) : LeftInvOn f₁' f₂ s :=
  fun _ hx => heq hx ▸ h₁ hx
Left Inverse Preservation under Function Equality on a Set
Informal description
Let $f_1'$ be a left inverse of $f_1$ on a set $s$, meaning that $f_1'(f_1(x)) = x$ for all $x \in s$. If $f_1$ and $f_2$ are equal on $s$ (i.e., $f_1(x) = f_2(x)$ for all $x \in s$), then $f_1'$ is also a left inverse of $f_2$ on $s$.
Set.LeftInvOn.injOn theorem
(h : LeftInvOn f₁' f s) : InjOn f s
Full source
theorem injOn (h : LeftInvOn f₁' f s) : InjOn f s := fun x₁ h₁ x₂ h₂ heq =>
  calc
    x₁ = f₁' (f x₁) := Eq.symm <| h h₁
    _ = f₁' (f x₂) := congr_arg f₁' heq
    _ = x₂ := h h₂
Left Inverse Implies Injectivity on a Set
Informal description
If a function $f'$ is a left inverse of $f$ on a set $s$ (i.e., $f'(f(x)) = x$ for all $x \in s$), then $f$ is injective on $s$.
Set.LeftInvOn.surjOn theorem
(h : LeftInvOn f' f s) (hf : MapsTo f s t) : SurjOn f' t s
Full source
theorem surjOn (h : LeftInvOn f' f s) (hf : MapsTo f s t) : SurjOn f' t s := fun x hx =>
  ⟨f x, hf hx, h hx⟩
Surjectivity of Left Inverse on Restricted Sets
Informal description
Let $f : \alpha \to \beta$ and $f' : \beta \to \alpha$ be functions, and let $s \subseteq \alpha$, $t \subseteq \beta$ be sets. If $f'$ is a left inverse of $f$ on $s$ (i.e., $f'(f(x)) = x$ for all $x \in s$) and $f$ maps $s$ into $t$ (i.e., $f(s) \subseteq t$), then $f'$ is surjective from $t$ onto $s$.
Set.LeftInvOn.mapsTo theorem
(h : LeftInvOn f' f s) (hf : SurjOn f s t) : MapsTo f' t s
Full source
theorem mapsTo (h : LeftInvOn f' f s) (hf : SurjOn f s t) :
    MapsTo f' t s := fun y hy => by
  let ⟨x, hs, hx⟩ := hf hy
  rwa [← hx, h hs]
Left Inverse Maps Target to Source Under Surjectivity
Informal description
Let $f : \alpha \to \beta$ and $f' : \beta \to \alpha$ be functions, and let $s \subseteq \alpha$, $t \subseteq \beta$ be sets. If $f'$ is a left inverse of $f$ on $s$ (i.e., $f'(f(x)) = x$ for all $x \in s$) and $f$ maps $s$ surjectively onto $t$ (i.e., for every $y \in t$ there exists $x \in s$ such that $f(x) = y$), then $f'$ maps $t$ into $s$ (i.e., $f'(y) \in s$ for all $y \in t$).
Set.leftInvOn_id theorem
(s : Set α) : LeftInvOn id id s
Full source
lemma _root_.Set.leftInvOn_id (s : Set α) : LeftInvOn id id s := fun _ _ ↦ rfl
Identity Function is a Left Inverse of Itself on Any Set
Informal description
For any set $s$ in a type $\alpha$, the identity function $\text{id}$ is a left inverse of itself on $s$, meaning that for every $x \in s$, we have $\text{id}(\text{id}(x)) = x$.
Set.LeftInvOn.comp theorem
(hf' : LeftInvOn f' f s) (hg' : LeftInvOn g' g t) (hf : MapsTo f s t) : LeftInvOn (f' ∘ g') (g ∘ f) s
Full source
theorem comp (hf' : LeftInvOn f' f s) (hg' : LeftInvOn g' g t) (hf : MapsTo f s t) :
    LeftInvOn (f' ∘ g') (g ∘ f) s := fun x h =>
  calc
    (f' ∘ g') ((g ∘ f) x) = f' (f x) := congr_arg f' (hg' (hf h))
    _ = x := hf' h
Composition of Left Inverses on Sets
Informal description
Let $f : \alpha \to \beta$ and $g : \beta \to \gamma$ be functions, and let $f' : \beta \to \alpha$ and $g' : \gamma \to \beta$ be their respective left inverses on sets $s \subseteq \alpha$ and $t \subseteq \beta$. If $f$ maps $s$ into $t$ (i.e., $f(s) \subseteq t$), then the composition $f' \circ g'$ is a left inverse of $g \circ f$ on $s$. That is, for all $x \in s$, we have $(f' \circ g')((g \circ f)(x)) = x$.
Set.LeftInvOn.mono theorem
(hf : LeftInvOn f' f s) (ht : s₁ ⊆ s) : LeftInvOn f' f s₁
Full source
theorem mono (hf : LeftInvOn f' f s) (ht : s₁ ⊆ s) : LeftInvOn f' f s₁ := fun _ hx =>
  hf (ht hx)
Left Inverse Property Preserved Under Subset Restriction
Informal description
If a function $f'$ is a left inverse of $f$ on a set $s$, then for any subset $s_1 \subseteq s$, $f'$ is also a left inverse of $f$ on $s_1$. That is, for all $x \in s_1$, we have $f'(f(x)) = x$.
Set.LeftInvOn.image_inter' theorem
(hf : LeftInvOn f' f s) : f '' (s₁ ∩ s) = f' ⁻¹' s₁ ∩ f '' s
Full source
theorem image_inter' (hf : LeftInvOn f' f s) : f '' (s₁ ∩ s) = f' ⁻¹' s₁f' ⁻¹' s₁ ∩ f '' s := by
  apply Subset.antisymm
  · rintro _ ⟨x, ⟨h₁, h⟩, rfl⟩
    exact ⟨by rwa [mem_preimage, hf h], mem_image_of_mem _ h⟩
  · rintro _ ⟨h₁, ⟨x, h, rfl⟩⟩
    exact mem_image_of_mem _ ⟨by rwa [← hf h], h⟩
Image-Preimage Intersection Identity for Left Inverses on Sets
Informal description
Let $f : \alpha \to \beta$ be a function with a left inverse $f' : \beta \to \alpha$ on a set $s \subseteq \alpha$, meaning that for all $x \in s$, $f'(f(x)) = x$. Then for any subset $s_1 \subseteq \alpha$, the image of $s_1 \cap s$ under $f$ equals the intersection of the preimage of $s_1$ under $f'$ with the image of $s$ under $f$. In symbols: $$ f(s_1 \cap s) = f'^{-1}(s_1) \cap f(s). $$
Set.LeftInvOn.image_inter theorem
(hf : LeftInvOn f' f s) : f '' (s₁ ∩ s) = f' ⁻¹' (s₁ ∩ s) ∩ f '' s
Full source
theorem image_inter (hf : LeftInvOn f' f s) :
    f '' (s₁ ∩ s) = f' ⁻¹' (s₁ ∩ s)f' ⁻¹' (s₁ ∩ s) ∩ f '' s := by
  rw [hf.image_inter']
  refine Subset.antisymm ?_ (inter_subset_inter_left _ (preimage_mono inter_subset_left))
  rintro _ ⟨h₁, x, hx, rfl⟩; exact ⟨⟨h₁, by rwa [hf hx]⟩, mem_image_of_mem _ hx⟩
Image-Preimage Intersection Identity for Left Inverses on Sets with Restricted Domain
Informal description
Let $f : \alpha \to \beta$ be a function with a left inverse $f' : \beta \to \alpha$ on a set $s \subseteq \alpha$, meaning that for all $x \in s$, $f'(f(x)) = x$. Then for any subset $s_1 \subseteq \alpha$, the image of $s_1 \cap s$ under $f$ equals the intersection of the preimage of $s_1 \cap s$ under $f'$ with the image of $s$ under $f$. In symbols: $$ f(s_1 \cap s) = f'^{-1}(s_1 \cap s) \cap f(s). $$
Set.LeftInvOn.image_image theorem
(hf : LeftInvOn f' f s) : f' '' (f '' s) = s
Full source
theorem image_image (hf : LeftInvOn f' f s) : f' '' (f '' s) = s := by
  rw [Set.image_image, image_congr hf, image_id']
Image of Image under Left Inverse Equals Original Set
Informal description
Let $f : \alpha \to \beta$ and $f' : \beta \to \alpha$ be functions, and let $s \subseteq \alpha$ be a subset. If $f'$ is a left inverse of $f$ on $s$ (meaning $f'(f(x)) = x$ for all $x \in s$), then the image of $f''s$ under $f'$ equals $s$, i.e., $f'(f(s)) = s$.
Set.LeftInvOn.image_image' theorem
(hf : LeftInvOn f' f s) (hs : s₁ ⊆ s) : f' '' (f '' s₁) = s₁
Full source
theorem image_image' (hf : LeftInvOn f' f s) (hs : s₁ ⊆ s) : f' '' (f '' s₁) = s₁ :=
  (hf.mono hs).image_image
Left Inverse Preserves Image Equality on Subsets
Informal description
Let $f : \alpha \to \beta$ and $f' : \beta \to \alpha$ be functions, and let $s, s_1$ be subsets of $\alpha$ with $s_1 \subseteq s$. If $f'$ is a left inverse of $f$ on $s$ (i.e., $f'(f(x)) = x$ for all $x \in s$), then the image of $f''s_1$ under $f'$ equals $s_1$, i.e., $f'(f(s_1)) = s_1$.
Set.RightInvOn.eqOn theorem
(h : RightInvOn f' f t) : EqOn (f ∘ f') id t
Full source
theorem eqOn (h : RightInvOn f' f t) : EqOn (f ∘ f') id t :=
  h
Composition of Function with Right Inverse Equals Identity on Target Set
Informal description
Given a right inverse condition `RightInvOn f' f t`, meaning that for every `y ∈ t` we have `f (f' y) = y`, then the composition `f ∘ f'` is equal to the identity function on the set `t`. In other words, for all `y ∈ t`, we have $(f \circ f')(y) = y$.
Set.RightInvOn.eq theorem
(h : RightInvOn f' f t) {y} (hy : y ∈ t) : f (f' y) = y
Full source
theorem eq (h : RightInvOn f' f t) {y} (hy : y ∈ t) : f (f' y) = y :=
  h hy
Right Inverse Property: $f(f'(y)) = y$ for $y \in t$
Informal description
Given a right inverse function $f'$ of $f$ on a set $t$, for any element $y \in t$, we have $f(f'(y)) = y$.
Set.LeftInvOn.rightInvOn_image theorem
(h : LeftInvOn f' f s) : RightInvOn f' f (f '' s)
Full source
theorem _root_.Set.LeftInvOn.rightInvOn_image (h : LeftInvOn f' f s) : RightInvOn f' f (f '' s) :=
  fun _y ⟨_x, hx, heq⟩ => heq ▸ (congr_arg f <| h.eq hx)
Left Inverse on Set Implies Right Inverse on Image
Informal description
Let $f : \alpha \to \beta$ and $f' : \beta \to \alpha$ be functions, and let $s \subseteq \alpha$. If $f'$ is a left inverse of $f$ on $s$ (i.e., for all $x \in s$, $f'(f(x)) = x$), then $f'$ is a right inverse of $f$ on the image $f(s) \subseteq \beta$ (i.e., for all $y \in f(s)$, $f(f'(y)) = y$).
Set.RightInvOn.congr_left theorem
(h₁ : RightInvOn f₁' f t) (heq : EqOn f₁' f₂' t) : RightInvOn f₂' f t
Full source
theorem congr_left (h₁ : RightInvOn f₁' f t) (heq : EqOn f₁' f₂' t) :
    RightInvOn f₂' f t :=
  h₁.congr_right heq
Right Inverse Preservation under Function Equality on a Set
Informal description
Let $f_1'$ be a right inverse of $f$ on a set $t$, meaning that $f(f_1'(y)) = y$ for all $y \in t$. If $f_1'$ and $f_2'$ are equal on $t$ (i.e., $f_1'(y) = f_2'(y)$ for all $y \in t$), then $f_2'$ is also a right inverse of $f$ on $t$.
Set.RightInvOn.congr_right theorem
(h₁ : RightInvOn f' f₁ t) (hg : MapsTo f' t s) (heq : EqOn f₁ f₂ s) : RightInvOn f' f₂ t
Full source
theorem congr_right (h₁ : RightInvOn f' f₁ t) (hg : MapsTo f' t s) (heq : EqOn f₁ f₂ s) :
    RightInvOn f' f₂ t :=
  LeftInvOn.congr_left h₁ hg heq
Right Inverse Preservation under Function Equality on Domain
Informal description
Let $f' : \beta \to \alpha$ be a function, $t \subseteq \beta$, and $f_1, f_2 : \alpha \to \beta$ be functions. Suppose that: 1. $f'$ is a right inverse of $f_1$ on $t$ (i.e., $f_1(f'(y)) = y$ for all $y \in t$), 2. $f'$ maps $t$ into a set $s \subseteq \alpha$ (i.e., $f'(t) \subseteq s$), and 3. $f_1$ and $f_2$ agree on $s$ (i.e., $f_1(x) = f_2(x)$ for all $x \in s$). Then $f'$ is also a right inverse of $f_2$ on $t$.
Set.RightInvOn.surjOn theorem
(hf : RightInvOn f' f t) (hf' : MapsTo f' t s) : SurjOn f s t
Full source
theorem surjOn (hf : RightInvOn f' f t) (hf' : MapsTo f' t s) : SurjOn f s t :=
  LeftInvOn.surjOn hf hf'
Surjectivity from Right Inverse and Mapping Condition
Informal description
Let $f : \alpha \to \beta$ and $f' : \beta \to \alpha$ be functions, and let $s \subseteq \alpha$, $t \subseteq \beta$ be sets. If $f'$ is a right inverse of $f$ on $t$ (i.e., $f(f'(y)) = y$ for all $y \in t$) and $f'$ maps $t$ into $s$ (i.e., $f'(t) \subseteq s$), then $f$ is surjective from $s$ onto $t$.
Set.RightInvOn.mapsTo theorem
(h : RightInvOn f' f t) (hf : SurjOn f' t s) : MapsTo f s t
Full source
theorem mapsTo (h : RightInvOn f' f t) (hf : SurjOn f' t s) : MapsTo f s t :=
  LeftInvOn.mapsTo h hf
Right Inverse Maps Source to Target Under Surjectivity
Informal description
Let $f : \alpha \to \beta$ and $f' : \beta \to \alpha$ be functions, and let $s \subseteq \alpha$, $t \subseteq \beta$ be sets. If $f'$ is a right inverse of $f$ on $t$ (i.e., $f(f'(y)) = y$ for all $y \in t$) and $f'$ maps $t$ surjectively onto $s$ (i.e., for every $x \in s$ there exists $y \in t$ such that $f'(y) = x$), then $f$ maps $s$ into $t$ (i.e., $f(x) \in t$ for all $x \in s$).
Set.rightInvOn_id theorem
(s : Set α) : RightInvOn id id s
Full source
lemma _root_.Set.rightInvOn_id (s : Set α) : RightInvOn id id s := fun _ _ ↦ rfl
Identity Function is Its Own Right Inverse on Any Set
Informal description
For any set $s$ in a type $\alpha$, the identity function $\text{id}$ is a right inverse of itself on $s$, i.e., for every $x \in s$, we have $\text{id}(\text{id}(x)) = x$.
Set.RightInvOn.comp theorem
(hf : RightInvOn f' f t) (hg : RightInvOn g' g p) (g'pt : MapsTo g' p t) : RightInvOn (f' ∘ g') (g ∘ f) p
Full source
theorem comp (hf : RightInvOn f' f t) (hg : RightInvOn g' g p) (g'pt : MapsTo g' p t) :
    RightInvOn (f' ∘ g') (g ∘ f) p :=
  LeftInvOn.comp hg hf g'pt
Composition of Right Inverses on Sets
Informal description
Let $f : \beta \to \alpha$ and $g : \gamma \to \beta$ be functions with right inverses $f' : \alpha \to \beta$ on $t \subseteq \alpha$ and $g' : \beta \to \gamma$ on $p \subseteq \beta$ respectively. If $g'$ maps $p$ into $t$ (i.e., $g'(p) \subseteq t$), then the composition $f' \circ g'$ is a right inverse of $g \circ f$ on $p$. That is, for all $y \in p$, we have $(g \circ f)((f' \circ g')(y)) = y$.
Set.RightInvOn.mono theorem
(hf : RightInvOn f' f t) (ht : t₁ ⊆ t) : RightInvOn f' f t₁
Full source
theorem mono (hf : RightInvOn f' f t) (ht : t₁ ⊆ t) : RightInvOn f' f t₁ :=
  LeftInvOn.mono hf ht
Right Inverse Property Preserved Under Subset Restriction
Informal description
If a function $f'$ is a right inverse of $f$ on a set $t$, then for any subset $t_1 \subseteq t$, $f'$ is also a right inverse of $f$ on $t_1$. That is, for all $y \in t_1$, we have $f(f'(y)) = y$.
Set.InjOn.rightInvOn_of_leftInvOn theorem
(hf : InjOn f s) (hf' : LeftInvOn f f' t) (h₁ : MapsTo f s t) (h₂ : MapsTo f' t s) : RightInvOn f f' s
Full source
theorem InjOn.rightInvOn_of_leftInvOn (hf : InjOn f s) (hf' : LeftInvOn f f' t)
    (h₁ : MapsTo f s t) (h₂ : MapsTo f' t s) : RightInvOn f f' s := fun _ h =>
  hf (h₂ <| h₁ h) h (hf' (h₁ h))
Right Inverse from Left Inverse and Injectivity on Sets
Informal description
Let $f : s \to t$ and $f' : t \to s$ be functions between sets $s$ and $t$. If: 1. $f$ is injective on $s$ (i.e., $f$ is injective when restricted to $s$), 2. $f'$ is a left inverse of $f$ on $t$ (i.e., $f'(f(x)) = x$ for all $x \in s$), 3. $f$ maps $s$ into $t$ (i.e., $f(x) \in t$ for all $x \in s$), and 4. $f'$ maps $t$ into $s$ (i.e., $f'(y) \in s$ for all $y \in t$), then $f$ is a right inverse of $f'$ on $s$ (i.e., $f(f'(y)) = y$ for all $y \in s$).
Set.eqOn_of_leftInvOn_of_rightInvOn theorem
(h₁ : LeftInvOn f₁' f s) (h₂ : RightInvOn f₂' f t) (h : MapsTo f₂' t s) : EqOn f₁' f₂' t
Full source
theorem eqOn_of_leftInvOn_of_rightInvOn (h₁ : LeftInvOn f₁' f s) (h₂ : RightInvOn f₂' f t)
    (h : MapsTo f₂' t s) : EqOn f₁' f₂' t := fun y hy =>
  calc
    f₁' y = (f₁' ∘ f ∘ f₂') y := congr_arg f₁' (h₂ hy).symm
    _ = f₂' y := h₁ (h hy)
Agreement of Left and Right Inverses on Common Domain
Informal description
Let $f : \alpha \to \beta$ be a function, and let $f_1'$ and $f_2'$ be functions from $\beta$ to $\alpha$. Suppose that: 1. $f_1'$ is a left inverse of $f$ on $s \subseteq \alpha$ (i.e., $f_1'(f(x)) = x$ for all $x \in s$), 2. $f_2'$ is a right inverse of $f$ on $t \subseteq \beta$ (i.e., $f(f_2'(y)) = y$ for all $y \in t$), and 3. $f_2'$ maps $t$ into $s$ (i.e., $f_2'(y) \in s$ for all $y \in t$). Then $f_1'$ and $f_2'$ coincide on $t$ (i.e., $f_1'(y) = f_2'(y)$ for all $y \in t$).
Set.SurjOn.leftInvOn_of_rightInvOn theorem
(hf : SurjOn f s t) (hf' : RightInvOn f f' s) : LeftInvOn f f' t
Full source
theorem SurjOn.leftInvOn_of_rightInvOn (hf : SurjOn f s t) (hf' : RightInvOn f f' s) :
    LeftInvOn f f' t := fun y hy => by
  let ⟨x, hx, heq⟩ := hf hy
  rw [← heq, hf' hx]
Left Inverse from Right Inverse for Surjective Functions
Informal description
Let $f : s \to t$ be a surjective function from set $s$ to set $t$, and let $f' : t \to s$ be a right inverse of $f$ on $s$ (i.e., for every $y \in t$, $f(f'(y)) = y$). Then $f'$ is also a left inverse of $f$ on $t$ (i.e., for every $x \in t$, $f'(f(x)) = x$).
Set.invOn_id theorem
(s : Set α) : InvOn id id s s
Full source
lemma _root_.Set.invOn_id (s : Set α) : InvOn id id s s := ⟨s.leftInvOn_id, s.rightInvOn_id⟩
Identity Function is Its Own Two-Sided Inverse on Any Set
Informal description
For any set $s$ in a type $\alpha$, the identity function $\text{id}$ is a two-sided inverse of itself on $s$, meaning that: 1. For every $x \in s$, we have $\text{id}(\text{id}(x)) = x$ (left inverse property), and 2. For every $y \in s$, we have $\text{id}(\text{id}(y)) = y$ (right inverse property).
Set.InvOn.comp theorem
(hf : InvOn f' f s t) (hg : InvOn g' g t p) (fst : MapsTo f s t) (g'pt : MapsTo g' p t) : InvOn (f' ∘ g') (g ∘ f) s p
Full source
lemma comp (hf : InvOn f' f s t) (hg : InvOn g' g t p) (fst : MapsTo f s t)
    (g'pt : MapsTo g' p t) :
    InvOn (f' ∘ g') (g ∘ f) s p :=
  ⟨hf.1.comp hg.1 fst, hf.2.comp hg.2 g'pt⟩
Composition of Two-Sided Inverses on Sets
Informal description
Let $f : \alpha \to \beta$ and $g : \beta \to \gamma$ be functions with two-sided inverses $f' : \beta \to \alpha$ on sets $s \subseteq \alpha$ and $t \subseteq \beta$, and $g' : \gamma \to \beta$ on sets $t \subseteq \beta$ and $p \subseteq \gamma$ respectively. If $f$ maps $s$ into $t$ (i.e., $f(s) \subseteq t$) and $g'$ maps $p$ into $t$ (i.e., $g'(p) \subseteq t$), then the composition $f' \circ g'$ is a two-sided inverse of $g \circ f$ on $s$ and $p$. That is: 1. For all $x \in s$, we have $(f' \circ g')((g \circ f)(x)) = x$ (left inverse property), and 2. For all $y \in p$, we have $(g \circ f)((f' \circ g')(y)) = y$ (right inverse property).
Set.InvOn.symm theorem
(h : InvOn f' f s t) : InvOn f f' t s
Full source
@[symm]
theorem symm (h : InvOn f' f s t) : InvOn f f' t s :=
  ⟨h.right, h.left⟩
Symmetry of Two-Sided Inverse Relationship
Informal description
Given a two-sided inverse relationship between functions $f$ and $f'$ on sets $s$ and $t$ (i.e., $f'$ is both a left inverse of $f$ on $s$ and a right inverse of $f$ on $t$), then $f$ is also a two-sided inverse of $f'$ on $t$ and $s$. Specifically: 1. For every $y \in t$, $f(f'(y)) = y$ (right inverse property) 2. For every $x \in s$, $f'(f(x)) = x$ (left inverse property)
Set.InvOn.mono theorem
(h : InvOn f' f s t) (hs : s₁ ⊆ s) (ht : t₁ ⊆ t) : InvOn f' f s₁ t₁
Full source
theorem mono (h : InvOn f' f s t) (hs : s₁ ⊆ s) (ht : t₁ ⊆ t) : InvOn f' f s₁ t₁ :=
  ⟨h.1.mono hs, h.2.mono ht⟩
Two-Sided Inverse Property Preserved Under Subset Restriction
Informal description
Let $f : \alpha \to \beta$ and $f' : \beta \to \alpha$ be functions, and let $s, s_1 \subseteq \alpha$ and $t, t_1 \subseteq \beta$ be sets such that $s_1 \subseteq s$ and $t_1 \subseteq t$. If $f'$ is a two-sided inverse of $f$ on $s$ and $t$ (i.e., $f'(f(x)) = x$ for all $x \in s$ and $f(f'(y)) = y$ for all $y \in t$), then $f'$ is also a two-sided inverse of $f$ on $s_1$ and $t_1$.
Set.InvOn.bijOn theorem
(h : InvOn f' f s t) (hf : MapsTo f s t) (hf' : MapsTo f' t s) : BijOn f s t
Full source
/-- If functions `f'` and `f` are inverse on `s` and `t`, `f` maps `s` into `t`, and `f'` maps `t`
into `s`, then `f` is a bijection between `s` and `t`. The `mapsTo` arguments can be deduced from
`surjOn` statements using `LeftInvOn.mapsTo` and `RightInvOn.mapsTo`. -/
theorem bijOn (h : InvOn f' f s t) (hf : MapsTo f s t) (hf' : MapsTo f' t s) : BijOn f s t :=
  ⟨hf, h.left.injOn, h.right.surjOn hf'⟩
Two-Sided Inverse Implies Bijection on Specified Sets
Informal description
Let $f \colon \alpha \to \beta$ and $f' \colon \beta \to \alpha$ be functions, and let $s \subseteq \alpha$ and $t \subseteq \beta$ be sets. If $f'$ is a two-sided inverse of $f$ on $s$ and $t$ (i.e., $f'(f(x)) = x$ for all $x \in s$ and $f(f'(y)) = y$ for all $y \in t$), and $f$ maps $s$ into $t$ while $f'$ maps $t$ into $s$, then $f$ is a bijection between $s$ and $t$.
Function.invFunOn definition
[Nonempty α] (f : α → β) (s : Set α) (b : β) : α
Full source
/-- Construct the inverse for a function `f` on domain `s`. This function is a right inverse of `f`
on `f '' s`. For a computable version, see `Function.Embedding.invOfMemRange`. -/
noncomputable def invFunOn [Nonempty α] (f : α → β) (s : Set α) (b : β) : α :=
  open scoped Classical in
  if h : ∃ a, a ∈ s ∧ f a = b then Classical.choose h else Classical.choice ‹Nonempty α›
Right inverse function on a subset
Informal description
Given a nonempty type $\alpha$, a function $f \colon \alpha \to \beta$, a subset $s \subseteq \alpha$, and an element $b \in \beta$, the function $\text{invFunOn}$ constructs an element of $\alpha$ as follows: if there exists an element $a \in s$ such that $f(a) = b$, then it returns such an $a$; otherwise, it returns an arbitrary element of $\alpha$. This function serves as a right inverse of $f$ on the image $f(s)$.
Function.invFunOn_pos theorem
(h : ∃ a ∈ s, f a = b) : invFunOn f s b ∈ s ∧ f (invFunOn f s b) = b
Full source
theorem invFunOn_pos (h : ∃ a ∈ s, f a = b) : invFunOninvFunOn f s b ∈ sinvFunOn f s b ∈ s ∧ f (invFunOn f s b) = b := by
  rw [invFunOn, dif_pos h]
  exact Classical.choose_spec h
Right Inverse Property of $\text{invFunOn}$ on Nonempty Preimage
Informal description
Given a function $f \colon \alpha \to \beta$, a subset $s \subseteq \alpha$, and an element $b \in \beta$, if there exists an element $a \in s$ such that $f(a) = b$, then the right inverse function $\text{invFunOn}\, f\, s\, b$ satisfies both $\text{invFunOn}\, f\, s\, b \in s$ and $f(\text{invFunOn}\, f\, s\, b) = b$.
Function.invFunOn_mem theorem
(h : ∃ a ∈ s, f a = b) : invFunOn f s b ∈ s
Full source
theorem invFunOn_mem (h : ∃ a ∈ s, f a = b) : invFunOninvFunOn f s b ∈ s :=
  (invFunOn_pos h).left
Membership Property of the Right Inverse Function on Nonempty Preimage
Informal description
For a function $f \colon \alpha \to \beta$ and a subset $s \subseteq \alpha$, if there exists an element $a \in s$ such that $f(a) = b$, then the right inverse function $\text{invFunOn}\, f\, s\, b$ is an element of $s$.
Function.invFunOn_eq theorem
(h : ∃ a ∈ s, f a = b) : f (invFunOn f s b) = b
Full source
theorem invFunOn_eq (h : ∃ a ∈ s, f a = b) : f (invFunOn f s b) = b :=
  (invFunOn_pos h).right
Right Inverse Property of $\text{invFunOn}$ on Nonempty Preimage
Informal description
Given a function $f \colon \alpha \to \beta$ and a subset $s \subseteq \alpha$, if there exists an element $a \in s$ such that $f(a) = b$, then the right inverse function $\text{invFunOn}\, f\, s\, b$ satisfies $f(\text{invFunOn}\, f\, s\, b) = b$.
Function.invFunOn_neg theorem
(h : ¬∃ a ∈ s, f a = b) : invFunOn f s b = Classical.choice ‹Nonempty α›
Full source
theorem invFunOn_neg (h : ¬∃ a ∈ s, f a = b) : invFunOn f s b = Classical.choice ‹Nonempty α› := by
  rw [invFunOn, dif_neg h]
Behavior of Right Inverse Function Outside Image
Informal description
For a nonempty type $\alpha$, a function $f \colon \alpha \to \beta$, a subset $s \subseteq \alpha$, and an element $b \in \beta$, if there does not exist any element $a \in s$ such that $f(a) = b$, then the right inverse function $\text{invFunOn}$ evaluated at $b$ equals an arbitrary element of $\alpha$ (chosen via the axiom of choice).
Function.invFunOn_apply_mem theorem
(h : a ∈ s) : invFunOn f s (f a) ∈ s
Full source
@[simp]
theorem invFunOn_apply_mem (h : a ∈ s) : invFunOninvFunOn f s (f a) ∈ s :=
  invFunOn_mem ⟨a, h, rfl⟩
Membership Preservation of Right Inverse Function on Image
Informal description
For any function $f \colon \alpha \to \beta$ and subset $s \subseteq \alpha$, if an element $a$ belongs to $s$, then the right inverse function $\text{invFunOn}\, f\, s$ evaluated at $f(a)$ also belongs to $s$.
Function.invFunOn_apply_eq theorem
(h : a ∈ s) : f (invFunOn f s (f a)) = f a
Full source
theorem invFunOn_apply_eq (h : a ∈ s) : f (invFunOn f s (f a)) = f a :=
  invFunOn_eq ⟨a, h, rfl⟩
Right Inverse Property of $\text{invFunOn}$ on Image Elements
Informal description
For any function $f \colon \alpha \to \beta$ and subset $s \subseteq \alpha$, if an element $a$ belongs to $s$, then applying $f$ to the right inverse function $\text{invFunOn}\, f\, s$ evaluated at $f(a)$ yields $f(a)$, i.e., $f(\text{invFunOn}\, f\, s\, (f a)) = f a$.
Set.InjOn.leftInvOn_invFunOn theorem
[Nonempty α] (h : InjOn f s) : LeftInvOn (invFunOn f s) f s
Full source
theorem InjOn.leftInvOn_invFunOn [Nonempty α] (h : InjOn f s) : LeftInvOn (invFunOn f s) f s :=
  fun _a ha => h (invFunOn_apply_mem ha) ha (invFunOn_apply_eq ha)
Right Inverse Function is Left Inverse on Injective Subset
Informal description
Let $\alpha$ be a nonempty type and $f \colon \alpha \to \beta$ be a function. If $f$ is injective on a subset $s \subseteq \alpha$, then the right inverse function $\text{invFunOn}\, f\, s$ is a left inverse of $f$ on $s$, i.e., for all $x \in s$, we have $\text{invFunOn}\, f\, s\, (f x) = x$.
Set.InjOn.invFunOn_image theorem
[Nonempty α] (h : InjOn f s₂) (ht : s₁ ⊆ s₂) : invFunOn f s₂ '' (f '' s₁) = s₁
Full source
theorem InjOn.invFunOn_image [Nonempty α] (h : InjOn f s₂) (ht : s₁ ⊆ s₂) :
    invFunOninvFunOn f s₂ '' (f '' s₁) = s₁ :=
  h.leftInvOn_invFunOn.image_image' ht
Right Inverse Image Preservation under Injectivity: $\text{invFunOn}\, f\, s_2\, (f(s_1)) = s_1$ for $s_1 \subseteq s_2$ and $f$ injective on $s_2$
Informal description
Let $\alpha$ be a nonempty type, $f \colon \alpha \to \beta$ a function, and $s_1, s_2 \subseteq \alpha$ with $s_1 \subseteq s_2$. If $f$ is injective on $s_2$, then the image of $f(s_1)$ under the right inverse function $\text{invFunOn}\, f\, s_2$ equals $s_1$, i.e., $\text{invFunOn}\, f\, s_2\, (f(s_1)) = s_1$.
Function.leftInvOn_invFunOn_of_subset_image_image theorem
[Nonempty α] (h : s ⊆ (invFunOn f s) '' (f '' s)) : LeftInvOn (invFunOn f s) f s
Full source
theorem _root_.Function.leftInvOn_invFunOn_of_subset_image_image [Nonempty α]
    (h : s ⊆ (invFunOn f s) '' (f '' s)) : LeftInvOn (invFunOn f s) f s :=
  fun x hx ↦ by
    obtain ⟨-, ⟨x, hx', rfl⟩, rfl⟩ := h hx
    rw [invFunOn_apply_eq (f := f) hx']
Left Inverse Property of $\text{invFunOn}$ on Subset of Preimage of Its Image
Informal description
For a nonempty type $\alpha$, a function $f \colon \alpha \to \beta$, and a subset $s \subseteq \alpha$, if $s$ is contained in the preimage of its image under the right inverse function $\text{invFunOn}\, f\, s$, then $\text{invFunOn}\, f\, s$ is a left inverse of $f$ on $s$. That is, for all $x \in s$, we have $\text{invFunOn}\, f\, s\, (f x) = x$.
Set.injOn_iff_invFunOn_image_image_eq_self theorem
[Nonempty α] : InjOn f s ↔ (invFunOn f s) '' (f '' s) = s
Full source
theorem injOn_iff_invFunOn_image_image_eq_self [Nonempty α] :
    InjOnInjOn f s ↔ (invFunOn f s) '' (f '' s) = s :=
  ⟨fun h ↦ h.invFunOn_image Subset.rfl, fun h ↦
    (Function.leftInvOn_invFunOn_of_subset_image_image h.symm.subset).injOn⟩
Injectivity Characterization via Right Inverse Image Equality
Informal description
For a nonempty type $\alpha$, a function $f \colon \alpha \to \beta$, and a subset $s \subseteq \alpha$, the function $f$ is injective on $s$ if and only if the image of $f(s)$ under the right inverse function $\text{invFunOn}\, f\, s$ equals $s$, i.e., $\text{invFunOn}\, f\, s\, (f(s)) = s$.
Function.invFunOn_injOn_image theorem
[Nonempty α] (f : α → β) (s : Set α) : Set.InjOn (invFunOn f s) (f '' s)
Full source
theorem _root_.Function.invFunOn_injOn_image [Nonempty α] (f : α → β) (s : Set α) :
    Set.InjOn (invFunOn f s) (f '' s) := by
  rintro _ ⟨x, hx, rfl⟩ _ ⟨x', hx', rfl⟩ he
  rw [← invFunOn_apply_eq (f := f) hx, he, invFunOn_apply_eq (f := f) hx']
Injectivity of the Right Inverse Function on Its Image
Informal description
For any nonempty type $\alpha$, function $f \colon \alpha \to \beta$, and subset $s \subseteq \alpha$, the right inverse function $\text{invFunOn}\, f\, s$ is injective on the image $f(s)$.
Function.invFunOn_image_image_subset theorem
[Nonempty α] (f : α → β) (s : Set α) : (invFunOn f s) '' (f '' s) ⊆ s
Full source
theorem _root_.Function.invFunOn_image_image_subset [Nonempty α] (f : α → β) (s : Set α) :
    (invFunOn f s) '' (f '' s)(invFunOn f s) '' (f '' s) ⊆ s := by
  rintro _ ⟨_, ⟨x,hx,rfl⟩, rfl⟩; exact invFunOn_apply_mem hx
Image of Right Inverse on Function Image is Subset of Original Set
Informal description
For any nonempty type $\alpha$, function $f \colon \alpha \to \beta$, and subset $s \subseteq \alpha$, the image of the image of $s$ under $f$ through the right inverse function $\text{invFunOn}\, f\, s$ is a subset of $s$. In other words, if $y \in f(s)$ and $x = \text{invFunOn}\, f\, s\, y$, then $x \in s$.
Set.SurjOn.rightInvOn_invFunOn theorem
[Nonempty α] (h : SurjOn f s t) : RightInvOn (invFunOn f s) f t
Full source
theorem SurjOn.rightInvOn_invFunOn [Nonempty α] (h : SurjOn f s t) :
    RightInvOn (invFunOn f s) f t := fun _y hy => invFunOn_eq <| h hy
Right Inverse Property of $\text{invFunOn}$ for Surjective Functions
Informal description
Given a nonempty type $\alpha$, a function $f \colon \alpha \to \beta$, and subsets $s \subseteq \alpha$, $t \subseteq \beta$, if $f$ is surjective from $s$ to $t$ (i.e., for every $y \in t$, there exists $x \in s$ such that $f(x) = y$), then the right inverse function $\text{invFunOn}\, f\, s$ satisfies $f(\text{invFunOn}\, f\, s\, y) = y$ for all $y \in t$.
Set.BijOn.invOn_invFunOn theorem
[Nonempty α] (h : BijOn f s t) : InvOn (invFunOn f s) f s t
Full source
theorem BijOn.invOn_invFunOn [Nonempty α] (h : BijOn f s t) : InvOn (invFunOn f s) f s t :=
  ⟨h.injOn.leftInvOn_invFunOn, h.surjOn.rightInvOn_invFunOn⟩
Two-Sided Inverse Property of $\text{invFunOn}$ for Bijective Functions
Informal description
Let $\alpha$ be a nonempty type, $f \colon \alpha \to \beta$ a function, and $s \subseteq \alpha$, $t \subseteq \beta$ subsets. If $f$ is a bijection from $s$ to $t$, then the function $\text{invFunOn}\, f\, s$ is a two-sided inverse of $f$ on $s$ and $t$. That is: 1. For all $x \in s$, we have $\text{invFunOn}\, f\, s\, (f x) = x$ (left inverse property). 2. For all $y \in t$, we have $f(\text{invFunOn}\, f\, s\, y) = y$ (right inverse property).
Set.SurjOn.invOn_invFunOn theorem
[Nonempty α] (h : SurjOn f s t) : InvOn (invFunOn f s) f (invFunOn f s '' t) t
Full source
theorem SurjOn.invOn_invFunOn [Nonempty α] (h : SurjOn f s t) :
    InvOn (invFunOn f s) f (invFunOninvFunOn f s '' t) t := by
  refine ⟨?_, h.rightInvOn_invFunOn⟩
  rintro _ ⟨y, hy, rfl⟩
  rw [h.rightInvOn_invFunOn hy]
Two-Sided Inverse Property of $\text{invFunOn}$ for Surjective Functions
Informal description
Given a nonempty type $\alpha$, a function $f \colon \alpha \to \beta$, and subsets $s \subseteq \alpha$ and $t \subseteq \beta$, if $f$ is surjective from $s$ to $t$ (i.e., for every $y \in t$ there exists $x \in s$ such that $f(x) = y$), then the function $\text{invFunOn}\, f\, s$ is a two-sided inverse of $f$ on the sets $\text{invFunOn}\, f\, s\, ''\, t$ and $t$. That is, for all $y \in t$, we have $f(\text{invFunOn}\, f\, s\, y) = y$, and for all $x \in \text{invFunOn}\, f\, s\, ''\, t$, we have $\text{invFunOn}\, f\, s\, (f\, x) = x$.
Set.SurjOn.mapsTo_invFunOn theorem
[Nonempty α] (h : SurjOn f s t) : MapsTo (invFunOn f s) t s
Full source
theorem SurjOn.mapsTo_invFunOn [Nonempty α] (h : SurjOn f s t) : MapsTo (invFunOn f s) t s :=
  fun _y hy => mem_preimage.2 <| invFunOn_mem <| h hy
Right Inverse Maps Surjective Image Back to Domain
Informal description
Given a nonempty type $\alpha$, a function $f \colon \alpha \to \beta$, and subsets $s \subseteq \alpha$ and $t \subseteq \beta$, if $f$ is surjective from $s$ to $t$ (i.e., $\forall y \in t, \exists x \in s, f(x) = y$), then the right inverse function $\text{invFunOn}\, f\, s$ maps every element of $t$ back into $s$.
Set.SurjOn.image_invFunOn_image_of_subset theorem
[Nonempty α] {r : Set β} (hf : SurjOn f s t) (hrt : r ⊆ t) : f '' (f.invFunOn s '' r) = r
Full source
/-- This lemma is a special case of `rightInvOn_invFunOn.image_image'`; it may make more sense
to use the other lemma directly in an application. -/
theorem SurjOn.image_invFunOn_image_of_subset [Nonempty α] {r : Set β} (hf : SurjOn f s t)
    (hrt : r ⊆ t) : f '' (f.invFunOn s '' r) = r :=
  hf.rightInvOn_invFunOn.image_image' hrt
Image Preservation Under Right Inverse for Subsets of Surjective Functions
Informal description
Let $\alpha$ be a nonempty type, $f \colon \alpha \to \beta$ a function, $s \subseteq \alpha$ and $t, r \subseteq \beta$ subsets. If $f$ is surjective from $s$ to $t$ (i.e., for every $y \in t$ there exists $x \in s$ such that $f(x) = y$) and $r \subseteq t$, then the image of $r$ under the composition $f \circ (\text{invFunOn}\, f\, s)$ equals $r$, i.e., $f(\text{invFunOn}\, f\, s\, r) = r$.
Set.SurjOn.image_invFunOn_image theorem
[Nonempty α] (hf : SurjOn f s t) : f '' (f.invFunOn s '' t) = t
Full source
/-- This lemma is a special case of `rightInvOn_invFunOn.image_image`; it may make more sense
to use the other lemma directly in an application. -/
theorem SurjOn.image_invFunOn_image [Nonempty α] (hf : SurjOn f s t) :
    f '' (f.invFunOn s '' t) = t :=
  hf.rightInvOn_invFunOn.image_image
Image of Right Inverse Image Equals Target Set for Surjective Functions
Informal description
Let $\alpha$ be a nonempty type, $f \colon \alpha \to \beta$ a function, and $s \subseteq \alpha$, $t \subseteq \beta$ subsets. If $f$ is surjective from $s$ to $t$ (i.e., for every $y \in t$ there exists $x \in s$ such that $f(x) = y$), then the image of $t$ under the right inverse function $\text{invFunOn}\, f\, s$ followed by $f$ equals $t$, i.e., $f(\text{invFunOn}\, f\, s\, t) = t$.
Set.SurjOn.bijOn_subset theorem
[Nonempty α] (h : SurjOn f s t) : BijOn f (invFunOn f s '' t) t
Full source
theorem SurjOn.bijOn_subset [Nonempty α] (h : SurjOn f s t) : BijOn f (invFunOninvFunOn f s '' t) t := by
  refine h.invOn_invFunOn.bijOn ?_ (mapsTo_image _ _)
  rintro _ ⟨y, hy, rfl⟩
  rwa [h.rightInvOn_invFunOn hy]
Bijectivity of Surjective Functions via Right Inverse on Subset
Informal description
Let $\alpha$ be a nonempty type, $f \colon \alpha \to \beta$ a function, and $s \subseteq \alpha$, $t \subseteq \beta$ subsets. If $f$ is surjective from $s$ to $t$ (i.e., for every $y \in t$ there exists $x \in s$ such that $f(x) = y$), then $f$ is a bijection between the subset $\text{invFunOn}\, f\, s\, ''\, t \subseteq s$ and $t$.
Set.surjOn_iff_exists_bijOn_subset theorem
: SurjOn f s t ↔ ∃ s' ⊆ s, BijOn f s' t
Full source
theorem surjOn_iff_exists_bijOn_subset : SurjOnSurjOn f s t ↔ ∃ s' ⊆ s, BijOn f s' t := by
  constructor
  · rcases eq_empty_or_nonempty t with (rfl | ht)
    · exact fun _ => ⟨∅, empty_subset _, bijOn_empty f⟩
    · intro h
      haveI : Nonempty α := ⟨Classical.choose (h.comap_nonempty ht)⟩
      exact ⟨_, h.mapsTo_invFunOn.image_subset, h.bijOn_subset⟩
  · rintro ⟨s', hs', hfs'⟩
    exact hfs'.surjOn.mono hs' (Subset.refl _)
Surjectivity on Sets is Equivalent to Existence of Bijective Restriction
Informal description
A function $f \colon \alpha \to \beta$ is surjective from a set $s \subseteq \alpha$ to a set $t \subseteq \beta$ if and only if there exists a subset $s' \subseteq s$ such that $f$ is a bijection between $s'$ and $t$.
Set.exists_subset_bijOn theorem
: ∃ s' ⊆ s, BijOn f s' (f '' s)
Full source
lemma exists_subset_bijOn : ∃ s' ⊆ s, BijOn f s' (f '' s) :=
  surjOn_iff_exists_bijOn_subset.mp (surjOn_image f s)
Existence of Bijective Restriction to Image Subset
Informal description
For any function $f \colon \alpha \to \beta$ and any subset $s \subseteq \alpha$, there exists a subset $s' \subseteq s$ such that $f$ is a bijection between $s'$ and the image $f(s) := \{f(x) \mid x \in s\}$.
Set.exists_image_eq_and_injOn theorem
: ∃ u, f '' u = f '' s ∧ InjOn f u
Full source
lemma exists_image_eq_and_injOn : ∃ u, f '' u =  f '' s ∧ InjOn f u :=
  let ⟨u, _, hfu⟩ := exists_subset_bijOn s f
  ⟨u, hfu.image_eq, hfu.injOn⟩
Existence of Injective Subset with Same Image
Informal description
For any function $f \colon \alpha \to \beta$ and any subset $s \subseteq \alpha$, there exists a subset $u \subseteq \alpha$ such that the image of $u$ under $f$ equals the image of $s$ under $f$ (i.e., $f(u) = f(s)$) and $f$ is injective on $u$.
Set.exists_image_eq_injOn_of_subset_range theorem
(ht : t ⊆ range f) : ∃ s, f '' s = t ∧ InjOn f s
Full source
lemma exists_image_eq_injOn_of_subset_range (ht : t ⊆ range f) :
    ∃ s, f '' s = t ∧ InjOn f s :=
  image_preimage_eq_of_subset ht ▸ exists_image_eq_and_injOn _ _
Existence of Injective Preimage for Subset of Range
Informal description
For any function $f \colon \alpha \to \beta$ and any subset $t \subseteq \beta$ contained in the range of $f$, there exists a subset $s \subseteq \alpha$ such that the image of $s$ under $f$ equals $t$ (i.e., $f(s) = t$) and $f$ is injective on $s$.
Set.BijOn.exists_extend_of_subset theorem
{t' : Set β} (h : BijOn f s t) (hss₁ : s ⊆ s₁) (htt' : t ⊆ t') (ht' : SurjOn f s₁ t') : ∃ s', s ⊆ s' ∧ s' ⊆ s₁ ∧ Set.BijOn f s' t'
Full source
/-- If `f` maps `s` bijectively to `t` and a set `t'` is contained in the image of some `s₁ ⊇ s`,
then `s₁` has a subset containing `s` that `f` maps bijectively to `t'`. -/
theorem BijOn.exists_extend_of_subset {t' : Set β} (h : BijOn f s t) (hss₁ : s ⊆ s₁) (htt' : t ⊆ t')
    (ht' : SurjOn f s₁ t') : ∃ s', s ⊆ s' ∧ s' ⊆ s₁ ∧ Set.BijOn f s' t' := by
  obtain ⟨r, hrss, hbij⟩ := exists_subset_bijOn ((s₁ ∩ f ⁻¹' t') \ f ⁻¹' t) f
  rw [image_diff_preimage, image_inter_preimage] at hbij
  refine ⟨s ∪ r, subset_union_left, ?_, ?_, ?_, fun y hyt' ↦ ?_⟩
  · exact union_subset hss₁ <| hrss.trans <| diff_subset.trans inter_subset_left
  · rw [mapsTo', image_union, hbij.image_eq, h.image_eq, union_subset_iff]
    exact ⟨htt', diff_subset.trans inter_subset_right⟩
  · rw [injOn_union, and_iff_right h.injOn, and_iff_right hbij.injOn]
    · refine fun x hxs y hyr hxy ↦ (hrss hyr).2 ?_
      rw [← h.image_eq]
      exact ⟨x, hxs, hxy⟩
    exact (subset_diff.1 hrss).2.symm.mono_left h.mapsTo
  rw [image_union, h.image_eq, hbij.image_eq, union_diff_self]
  exact .inr ⟨ht' hyt', hyt'⟩
Extension of Bijection to Supersets with Surjectivity Condition
Informal description
Let $f \colon \alpha \to \beta$ be a function, $s \subseteq \alpha$, $t \subseteq \beta$, and suppose $f$ is a bijection from $s$ to $t$. Given a superset $s_1 \supseteq s$ and a superset $t' \supseteq t$ such that $f$ maps $s_1$ surjectively onto $t'$, there exists a subset $s' \subseteq s_1$ containing $s$ such that $f$ is a bijection from $s'$ to $t'$.
Set.BijOn.exists_extend theorem
{t' : Set β} (h : BijOn f s t) (htt' : t ⊆ t') (ht' : t' ⊆ range f) : ∃ s', s ⊆ s' ∧ BijOn f s' t'
Full source
/-- If `f` maps `s` bijectively to `t`, and `t'` is a superset of `t` contained in the range of `f`,
then `f` maps some superset of `s` bijectively to `t'`. -/
theorem BijOn.exists_extend {t' : Set β} (h : BijOn f s t) (htt' : t ⊆ t') (ht' : t' ⊆ range f) :
    ∃ s', s ⊆ s' ∧ BijOn f s' t' := by
  simpa using h.exists_extend_of_subset (subset_univ s) htt' (by simpa [SurjOn])
Extension of Bijection to Range-Contained Supersets
Informal description
Let $f \colon \alpha \to \beta$ be a function that is a bijection from a set $s \subseteq \alpha$ to a set $t \subseteq \beta$. Given any superset $t' \supseteq t$ that is contained in the range of $f$, there exists a superset $s' \supseteq s$ such that $f$ is a bijection from $s'$ to $t'$.
Set.InjOn.exists_subset_injOn_subset_range_eq theorem
{r : Set α} (hinj : InjOn f r) (hrs : r ⊆ s) : ∃ u : Set α, r ⊆ u ∧ u ⊆ s ∧ f '' u = f '' s ∧ InjOn f u
Full source
theorem InjOn.exists_subset_injOn_subset_range_eq {r : Set α} (hinj : InjOn f r) (hrs : r ⊆ s) :
    ∃ u : Set α, r ⊆ u ∧ u ⊆ s ∧ f '' u = f '' s ∧ InjOn f u := by
  obtain ⟨u, hru, hus, h⟩ := hinj.bijOn_image.exists_extend_of_subset hrs
    (image_subset f hrs) Subset.rfl
  exact ⟨u, hru, hus, h.image_eq, h.injOn⟩
Existence of Injective Extension Preserving Image
Informal description
Let $f : \alpha \to \beta$ be a function, $r \subseteq s \subseteq \alpha$, and suppose $f$ is injective on $r$. Then there exists a subset $u \subseteq \alpha$ such that: 1. $r \subseteq u \subseteq s$, 2. The image of $u$ under $f$ equals the image of $s$ under $f$, i.e., $f(u) = f(s)$, 3. $f$ is injective on $u$.
Set.preimage_invFun_of_mem theorem
[n : Nonempty α] {f : α → β} (hf : Injective f) {s : Set α} (h : Classical.choice n ∈ s) : invFun f ⁻¹' s = f '' s ∪ (range f)ᶜ
Full source
theorem preimage_invFun_of_mem [n : Nonempty α] {f : α → β} (hf : Injective f) {s : Set α}
    (h : Classical.choiceClassical.choice n ∈ s) : invFuninvFun f ⁻¹' s = f '' sf '' s ∪ (range f)ᶜ := by
  ext x
  rcases em (x ∈ range f) with (⟨a, rfl⟩ | hx)
  · simp only [mem_preimage, mem_union, mem_compl_iff, mem_range_self, not_true, or_false,
      leftInverse_invFun hf _, hf.mem_set_image]
  · simp only [mem_preimage, invFun_neg hx, h, hx, mem_union, mem_compl_iff, not_false_iff, or_true]
Preimage of Set Under Inverse Function for Injective Maps
Informal description
Let $\alpha$ be a nonempty type and $f : \alpha \to \beta$ be an injective function. For any subset $s \subseteq \alpha$ containing an arbitrarily chosen element of $\alpha$, the preimage of $s$ under the inverse function $\text{invFun}\, f$ is equal to the union of the image of $s$ under $f$ and the complement of the range of $f$. In other words: \[ (\text{invFun}\, f)^{-1}(s) = f(s) \cup (\text{range}\, f)^c \]
Set.preimage_invFun_of_not_mem theorem
[n : Nonempty α] {f : α → β} (hf : Injective f) {s : Set α} (h : Classical.choice n ∉ s) : invFun f ⁻¹' s = f '' s
Full source
theorem preimage_invFun_of_not_mem [n : Nonempty α] {f : α → β} (hf : Injective f) {s : Set α}
    (h : Classical.choiceClassical.choice n ∉ s) : invFuninvFun f ⁻¹' s = f '' s := by
  ext x
  rcases em (x ∈ range f) with (⟨a, rfl⟩ | hx)
  · rw [mem_preimage, leftInverse_invFun hf, hf.mem_set_image]
  · have : x ∉ f '' s := fun h' => hx (image_subset_range _ _ h')
    simp only [mem_preimage, invFun_neg hx, h, this]
Preimage of Set Under Inverse Function When Chosen Element Not in Set
Informal description
Let $\alpha$ be a nonempty type and $f : \alpha \to \beta$ be an injective function. For any subset $s \subseteq \alpha$ that does not contain an arbitrarily chosen element of $\alpha$, the preimage of $s$ under the inverse function $\text{invFun}\, f$ is equal to the image of $s$ under $f$, i.e., \[ (\text{invFun}\, f)^{-1}(s) = f(s). \]
Set.BijOn.symm theorem
{g : β → α} (h : InvOn f g t s) (hf : BijOn f s t) : BijOn g t s
Full source
lemma BijOn.symm {g : β → α} (h : InvOn f g t s) (hf : BijOn f s t) : BijOn g t s :=
  ⟨h.2.mapsTo hf.surjOn, h.1.injOn, h.2.surjOn hf.mapsTo⟩
Symmetry of Bijections with Two-Sided Inverses
Informal description
Let $f : \alpha \to \beta$ and $g : \beta \to \alpha$ be functions, and let $s \subseteq \alpha$ and $t \subseteq \beta$ be sets. If $g$ is a two-sided inverse of $f$ on $s$ and $t$ (i.e., $g(f(x)) = x$ for all $x \in s$ and $f(g(y)) = y$ for all $y \in t$), and $f$ is a bijection from $s$ to $t$, then $g$ is a bijection from $t$ to $s$.
Set.bijOn_comm theorem
{g : β → α} (h : InvOn f g t s) : BijOn f s t ↔ BijOn g t s
Full source
lemma bijOn_comm {g : β → α} (h : InvOn f g t s) : BijOnBijOn f s t ↔ BijOn g t s :=
  ⟨BijOn.symm h, BijOn.symm h.symm⟩
Bijection Equivalence via Two-Sided Inverse: $f$ bijective $\leftrightarrow$ $g$ bijective
Informal description
Let $f : \alpha \to \beta$ and $g : \beta \to \alpha$ be functions, and let $s \subseteq \alpha$ and $t \subseteq \beta$ be sets. If $g$ is a two-sided inverse of $f$ on $s$ and $t$ (i.e., $g(f(x)) = x$ for all $x \in s$ and $f(g(y)) = y$ for all $y \in t$), then $f$ is a bijection from $s$ to $t$ if and only if $g$ is a bijection from $t$ to $s$.
Function.Injective.comp_injOn theorem
(hg : Injective g) (hf : s.InjOn f) : s.InjOn (g ∘ f)
Full source
theorem Injective.comp_injOn (hg : Injective g) (hf : s.InjOn f) : s.InjOn (g ∘ f) :=
  hg.injOn.comp hf (mapsTo_univ _ _)
Composition of Injective Functions Preserves Injectivity on a Set
Informal description
Let $f : \alpha \to \beta$ and $g : \beta \to \gamma$ be functions, and let $s \subseteq \alpha$ be a set. If $g$ is injective and $f$ is injective on $s$, then the composition $g \circ f$ is injective on $s$.
Function.Surjective.surjOn theorem
(hf : Surjective f) (s : Set β) : SurjOn f univ s
Full source
theorem Surjective.surjOn (hf : Surjective f) (s : Set β) : SurjOn f univ s :=
  (surjective_iff_surjOn_univ.1 hf).mono (Subset.refl _) (subset_univ _)
Surjective Function Maps Entire Domain to Any Subset of Codomain
Informal description
If a function $f : \alpha \to \beta$ is surjective, then for any subset $s \subseteq \beta$, $f$ maps the entire domain $\alpha$ (represented as `univ`) surjectively onto $s$.
Function.LeftInverse.leftInvOn theorem
{g : β → α} (h : LeftInverse f g) (s : Set β) : LeftInvOn f g s
Full source
theorem LeftInverse.leftInvOn {g : β → α} (h : LeftInverse f g) (s : Set β) : LeftInvOn f g s :=
  fun x _ => h x
Left Inverse Property on Subsets
Informal description
Let $g : \beta \to \alpha$ and $f : \alpha \to \beta$ be functions such that $g$ is a left inverse of $f$ (i.e., $g(f(x)) = x$ for all $x \in \alpha$). Then for any subset $s \subseteq \beta$, $f$ is a left inverse of $g$ on $s$, meaning that for every $y \in s$, we have $f(g(y)) = y$.
Function.RightInverse.rightInvOn theorem
{g : β → α} (h : RightInverse f g) (s : Set α) : RightInvOn f g s
Full source
theorem RightInverse.rightInvOn {g : β → α} (h : RightInverse f g) (s : Set α) :
    RightInvOn f g s := fun x _ => h x
Right Inverse Property on Subsets for Right Inverse Functions
Informal description
Let $f : \alpha \to \beta$ and $g : \beta \to \alpha$ be functions such that $g$ is a right inverse of $f$ (i.e., $f(g(y)) = y$ for all $y \in \beta$). Then for any subset $s \subseteq \alpha$, $f$ is a right inverse of $g$ on $s$, meaning that for every $x \in s$, we have $f(g(x)) = x$.
Function.LeftInverse.rightInvOn_range theorem
{g : β → α} (h : LeftInverse f g) : RightInvOn f g (range g)
Full source
theorem LeftInverse.rightInvOn_range {g : β → α} (h : LeftInverse f g) :
    RightInvOn f g (range g) :=
  forall_mem_range.2 fun i => congr_arg g (h i)
Right Inverse Property on Range for Left Inverse Functions
Informal description
If a function $g : \beta \to \alpha$ is a left inverse of $f : \alpha \to \beta$ (i.e., $g(f(x)) = x$ for all $x \in \alpha$), then $f$ is a right inverse of $g$ on the range of $g$ (i.e., $f(g(y)) = y$ for all $y$ in the range of $g$).
Function.Semiconj.mapsTo_image theorem
(h : Semiconj f fa fb) (ha : MapsTo fa s t) : MapsTo fb (f '' s) (f '' t)
Full source
theorem mapsTo_image (h : Semiconj f fa fb) (ha : MapsTo fa s t) : MapsTo fb (f '' s) (f '' t) :=
  fun _y ⟨x, hx, hy⟩ => hy ▸ ⟨fa x, ha hx, h x⟩
Semiconjugate Functions Preserve Image Mappings
Informal description
Let $f : \alpha \to \beta$ be a function that semiconjugates $f_a : \alpha \to \alpha$ and $f_b : \beta \to \beta$, meaning $f \circ f_a = f_b \circ f$. If $f_a$ maps a set $s \subseteq \alpha$ to $t \subseteq \alpha$ (i.e., $f_a(s) \subseteq t$), then $f_b$ maps the image $f(s)$ to $f(t)$ (i.e., $f_b(f(s)) \subseteq f(t)$).
Function.Semiconj.mapsTo_image_right theorem
{t : Set β} (h : Semiconj f fa fb) (hst : MapsTo f s t) : MapsTo f (fa '' s) (fb '' t)
Full source
theorem mapsTo_image_right {t : Set β} (h : Semiconj f fa fb) (hst : MapsTo f s t) :
    MapsTo f (fa '' s) (fb '' t) :=
  mapsTo_image_iff.2 fun x hx ↦ ⟨f x, hst hx, (h x).symm⟩
Mapping Property of Semiconjugate Functions on Images
Informal description
Let $f : \alpha \to \beta$ be a function that semiconjugates $f_a : \alpha \to \alpha$ and $f_b : \beta \to \beta$, meaning $f \circ f_a = f_b \circ f$. If $f$ maps a set $s \subseteq \alpha$ into a set $t \subseteq \beta$, then $f$ also maps the image $f_a(s)$ into the image $f_b(t)$. In other words, if $f(s) \subseteq t$, then $f(f_a(s)) \subseteq f_b(t)$.
Function.Semiconj.mapsTo_range theorem
(h : Semiconj f fa fb) : MapsTo fb (range f) (range f)
Full source
theorem mapsTo_range (h : Semiconj f fa fb) : MapsTo fb (range f) (range f) := fun _y ⟨x, hy⟩ =>
  hy ▸ ⟨fa x, h x⟩
Semiconjugate Functions Preserve Range under Mapping
Informal description
Let $f : \alpha \to \beta$ be a function that semiconjugates functions $f_a : \alpha \to \alpha$ and $f_b : \beta \to \beta$, i.e., $f \circ f_a = f_b \circ f$. Then $f_b$ maps the range of $f$ to itself, i.e., for every $y$ in the range of $f$, $f_b(y)$ is also in the range of $f$.
Function.Semiconj.surjOn_image theorem
(h : Semiconj f fa fb) (ha : SurjOn fa s t) : SurjOn fb (f '' s) (f '' t)
Full source
theorem surjOn_image (h : Semiconj f fa fb) (ha : SurjOn fa s t) : SurjOn fb (f '' s) (f '' t) := by
  rintro y ⟨x, hxt, rfl⟩
  rcases ha hxt with ⟨x, hxs, rfl⟩
  rw [h x]
  exact mem_image_of_mem _ (mem_image_of_mem _ hxs)
Surjectivity Preservation under Semiconjugate Functions on Images
Informal description
Let $f : \alpha \to \beta$ be a function that semiconjugates $f_a : \alpha \to \alpha$ and $f_b : \beta \to \beta$, i.e., $f \circ f_a = f_b \circ f$. If $f_a$ is surjective from $s$ to $t$, then $f_b$ is surjective from the image $f(s)$ to the image $f(t)$.
Function.Semiconj.surjOn_range theorem
(h : Semiconj f fa fb) (ha : Surjective fa) : SurjOn fb (range f) (range f)
Full source
theorem surjOn_range (h : Semiconj f fa fb) (ha : Surjective fa) :
    SurjOn fb (range f) (range f) := by
  rw [← image_univ]
  exact h.surjOn_image (ha.surjOn univ)
Surjectivity of Semiconjugate Function on Range
Informal description
Let $f : \alpha \to \beta$ be a function that semiconjugates $f_a : \alpha \to \alpha$ and $f_b : \beta \to \beta$, i.e., $f \circ f_a = f_b \circ f$. If $f_a$ is surjective, then $f_b$ maps the range of $f$ surjectively onto itself.
Function.Semiconj.injOn_image theorem
(h : Semiconj f fa fb) (ha : InjOn fa s) (hf : InjOn f (fa '' s)) : InjOn fb (f '' s)
Full source
theorem injOn_image (h : Semiconj f fa fb) (ha : InjOn fa s) (hf : InjOn f (fa '' s)) :
    InjOn fb (f '' s) := by
  rintro _ ⟨x, hx, rfl⟩ _ ⟨y, hy, rfl⟩ H
  simp only [← h.eq] at H
  exact congr_arg f (ha hx hy <| hf (mem_image_of_mem fa hx) (mem_image_of_mem fa hy) H)
Injectivity Preservation under Semiconjugate Functions on Images
Informal description
Let $f : \alpha \to \beta$ be a function that semiconjugates $f_a : \alpha \to \alpha$ and $f_b : \beta \to \beta$, i.e., $f \circ f_a = f_b \circ f$. If $f_a$ is injective on a set $s \subseteq \alpha$ and $f$ is injective on the image $f_a(s)$, then $f_b$ is injective on the image $f(s)$.
Function.Semiconj.injOn_range theorem
(h : Semiconj f fa fb) (ha : Injective fa) (hf : InjOn f (range fa)) : InjOn fb (range f)
Full source
theorem injOn_range (h : Semiconj f fa fb) (ha : Injective fa) (hf : InjOn f (range fa)) :
    InjOn fb (range f) := by
  rw [← image_univ] at *
  exact h.injOn_image ha.injOn hf
Injectivity of Semiconjugate Function on Range under Injective Conditions
Informal description
Let $f : \alpha \to \beta$ be a function that semiconjugates $f_a : \alpha \to \alpha$ and $f_b : \beta \to \beta$, i.e., $f \circ f_a = f_b \circ f$. If $f_a$ is injective and $f$ is injective on the range of $f_a$, then $f_b$ is injective on the range of $f$.
Function.Semiconj.bijOn_image theorem
(h : Semiconj f fa fb) (ha : BijOn fa s t) (hf : InjOn f t) : BijOn fb (f '' s) (f '' t)
Full source
theorem bijOn_image (h : Semiconj f fa fb) (ha : BijOn fa s t) (hf : InjOn f t) :
    BijOn fb (f '' s) (f '' t) :=
  ⟨h.mapsTo_image ha.mapsTo, h.injOn_image ha.injOn (ha.image_eq.symm ▸ hf),
    h.surjOn_image ha.surjOn⟩
Bijectivity Preservation under Semiconjugate Functions on Images
Informal description
Let $f : \alpha \to \beta$ be a function that semiconjugates $f_a : \alpha \to \alpha$ and $f_b : \beta \to \beta$, i.e., $f \circ f_a = f_b \circ f$. If $f_a$ is a bijection from a set $s$ to a set $t$ and $f$ is injective on $t$, then $f_b$ is a bijection from the image $f(s)$ to the image $f(t)$.
Function.Semiconj.bijOn_range theorem
(h : Semiconj f fa fb) (ha : Bijective fa) (hf : Injective f) : BijOn fb (range f) (range f)
Full source
theorem bijOn_range (h : Semiconj f fa fb) (ha : Bijective fa) (hf : Injective f) :
    BijOn fb (range f) (range f) := by
  rw [← image_univ]
  exact h.bijOn_image (bijective_iff_bijOn_univ.1 ha) hf.injOn
Bijectivity of Semiconjugate Function on Range under Bijective and Injective Conditions
Informal description
Let $f : \alpha \to \beta$ be a function that semiconjugates $f_a : \alpha \to \alpha$ and $f_b : \beta \to \beta$, i.e., $f \circ f_a = f_b \circ f$. If $f_a$ is bijective and $f$ is injective, then $f_b$ is a bijection from the range of $f$ to itself.
Function.Semiconj.mapsTo_preimage theorem
(h : Semiconj f fa fb) {s t : Set β} (hb : MapsTo fb s t) : MapsTo fa (f ⁻¹' s) (f ⁻¹' t)
Full source
theorem mapsTo_preimage (h : Semiconj f fa fb) {s t : Set β} (hb : MapsTo fb s t) :
    MapsTo fa (f ⁻¹' s) (f ⁻¹' t) := fun x hx => by simp only [mem_preimage, h x, hb hx]
Semiconjugate Functions Preserve Preimages under MapsTo Condition
Informal description
Let $f : \alpha \to \beta$ be a function that semiconjugates $f_a : \alpha \to \alpha$ and $f_b : \beta \to \beta$, meaning $f \circ f_a = f_b \circ f$. For any subsets $s, t \subseteq \beta$, if $f_b$ maps $s$ into $t$, then $f_a$ maps the preimage $f^{-1}(s)$ into the preimage $f^{-1}(t)$.
Function.Semiconj.injOn_preimage theorem
(h : Semiconj f fa fb) {s : Set β} (hb : InjOn fb s) (hf : InjOn f (f ⁻¹' s)) : InjOn fa (f ⁻¹' s)
Full source
theorem injOn_preimage (h : Semiconj f fa fb) {s : Set β} (hb : InjOn fb s)
    (hf : InjOn f (f ⁻¹' s)) : InjOn fa (f ⁻¹' s) := by
  intro x hx y hy H
  have := congr_arg f H
  rw [h.eq, h.eq] at this
  exact hf hx hy (hb hx hy this)
Injectivity Preservation under Semiconjugation and Preimage Conditions
Informal description
Let $f : \alpha \to \beta$ be a function that semiconjugates $f_a : \alpha \to \alpha$ and $f_b : \beta \to \beta$, meaning $f \circ f_a = f_b \circ f$. For any subset $s \subseteq \beta$, if $f_b$ is injective on $s$ and $f$ is injective on the preimage $f^{-1}(s)$, then $f_a$ is injective on $f^{-1}(s)$.
Function.update_comp_eq_of_not_mem_range' theorem
{α : Sort*} {β : Type*} {γ : β → Sort*} [DecidableEq β] (g : ∀ b, γ b) {f : α → β} {i : β} (a : γ i) (h : i ∉ Set.range f) : (fun j => update g i a (f j)) = fun j => g (f j)
Full source
theorem update_comp_eq_of_not_mem_range' {α : Sort*} {β : Type*} {γ : β → Sort*} [DecidableEq β]
    (g : ∀ b, γ b) {f : α → β} {i : β} (a : γ i) (h : i ∉ Set.range f) :
    (fun j => update g i a (f j)) = fun j => g (f j) :=
  (update_comp_eq_of_forall_ne' _ _) fun x hx => h ⟨x, hx⟩
Composition with Updated Function Preserves Original When Update Point Not in Range
Informal description
Let $\alpha$ be a type, $\beta$ a type with decidable equality, and $\gamma$ a family of types indexed by $\beta$. Given a function $g : \forall b \in \beta, \gamma b$, a function $f : \alpha \to \beta$, an element $i \in \beta$, and a value $a \in \gamma i$, if $i$ is not in the range of $f$, then the composition of the updated function $\text{update } g \, i \, a$ with $f$ equals the composition of $g$ with $f$. That is, \[ (\lambda j, (\text{update } g \, i \, a)(f j)) = \lambda j, g (f j). \]
Function.update_comp_eq_of_not_mem_range theorem
{α : Sort*} {β : Type*} {γ : Sort*} [DecidableEq β] (g : β → γ) {f : α → β} {i : β} (a : γ) (h : i ∉ Set.range f) : update g i a ∘ f = g ∘ f
Full source
/-- Non-dependent version of `Function.update_comp_eq_of_not_mem_range'` -/
theorem update_comp_eq_of_not_mem_range {α : Sort*} {β : Type*} {γ : Sort*} [DecidableEq β]
    (g : β → γ) {f : α → β} {i : β} (a : γ) (h : i ∉ Set.range f) : updateupdate g i a ∘ f = g ∘ f :=
  update_comp_eq_of_not_mem_range' g a h
Composition with Updated Function Preserves Original When Update Point Not in Range
Informal description
Let $\alpha$, $\beta$, and $\gamma$ be types, with $\beta$ having decidable equality. Given a function $g : \beta \to \gamma$, a function $f : \alpha \to \beta$, an element $i \in \beta$, and a value $a \in \gamma$, if $i$ is not in the range of $f$, then the composition of the updated function $\text{update } g \, i \, a$ with $f$ equals the composition of $g$ with $f$. That is, \[ (\text{update } g \, i \, a) \circ f = g \circ f. \]
Function.insert_injOn theorem
(s : Set α) : sᶜ.InjOn fun a => insert a s
Full source
theorem insert_injOn (s : Set α) : sᶜ.InjOn fun a => insert a s := fun _a ha _ _ =>
  (insert_inj ha).1
Injectivity of Insertion Function on Complement Set
Informal description
For any set $s$ in a type $\alpha$, the function that maps each element $a$ in the complement of $s$ to the set $\{a\} \cup s$ is injective on $s^c$.
Function.apply_eq_of_range_eq_singleton theorem
{f : α → β} {b : β} (h : range f = { b }) (a : α) : f a = b
Full source
lemma apply_eq_of_range_eq_singleton {f : α → β} {b : β} (h : range f = {b}) (a : α) :
    f a = b := by
  simpa only [h, mem_singleton_iff] using mem_range_self (f := f) a
Function Values Equal When Range is Singleton
Informal description
Let $f : \alpha \to \beta$ be a function and $b \in \beta$ such that the range of $f$ is the singleton set $\{b\}$. Then for any $a \in \alpha$, we have $f(a) = b$.
Set.MapsTo.extendDomain theorem
(h : MapsTo g s t) : MapsTo (g.extendDomain f) ((↑) ∘ f '' s) ((↑) ∘ f '' t)
Full source
protected lemma MapsTo.extendDomain (h : MapsTo g s t) :
    MapsTo (g.extendDomain f) ((↑) ∘ f(↑) ∘ f '' s) ((↑) ∘ f(↑) ∘ f '' t) := by
  rintro _ ⟨a, ha, rfl⟩; exact ⟨_, h ha, by simp_rw [Function.comp_apply, extendDomain_apply_image]⟩
Preservation of Mapping Property under Domain Extension: $g.\text{extendDomain}\,f$ maps $f(s)$ to $f(t)$ when $g$ maps $s$ to $t$
Informal description
Let $g : \alpha \to \beta$ be a function and $f : \alpha \to \gamma$ an injective function. If $g$ maps every point in a set $s \subseteq \alpha$ to a point in a set $t \subseteq \beta$, then the extended function $g.\text{extendDomain}\,f$ maps every point in the image $f(s)$ to a point in the image $f(t)$.
Set.SurjOn.extendDomain theorem
(h : SurjOn g s t) : SurjOn (g.extendDomain f) ((↑) ∘ f '' s) ((↑) ∘ f '' t)
Full source
protected lemma SurjOn.extendDomain (h : SurjOn g s t) :
    SurjOn (g.extendDomain f) ((↑) ∘ f(↑) ∘ f '' s) ((↑) ∘ f(↑) ∘ f '' t) := by
  rintro _ ⟨a, ha, rfl⟩
  obtain ⟨b, hb, rfl⟩ := h ha
  exact ⟨_, ⟨_, hb, rfl⟩, by simp_rw [Function.comp_apply, extendDomain_apply_image]⟩
Surjectivity Preservation under Domain Extension: $g.\text{extendDomain}\,f$ is surjective from $f(s)$ to $f(t)$ when $g$ is surjective from $s$ to $t$
Informal description
Let $g : \alpha \to \beta$ be a function and $f : \alpha \to \gamma$ an injective function. If $g$ is surjective from a set $s \subseteq \alpha$ to a set $t \subseteq \beta$ (i.e., for every $y \in t$ there exists $x \in s$ such that $g(x) = y$), then the extended function $g.\text{extendDomain}\,f$ is surjective from the image $f(s) \subseteq \gamma$ to the image $f(t) \subseteq \gamma$.
Set.BijOn.extendDomain theorem
(h : BijOn g s t) : BijOn (g.extendDomain f) ((↑) ∘ f '' s) ((↑) ∘ f '' t)
Full source
protected lemma BijOn.extendDomain (h : BijOn g s t) :
    BijOn (g.extendDomain f) ((↑) ∘ f(↑) ∘ f '' s) ((↑) ∘ f(↑) ∘ f '' t) :=
  ⟨h.mapsTo.extendDomain, (g.extendDomain f).injective.injOn, h.surjOn.extendDomain⟩
Bijectivity Preservation under Domain Extension: $g.\text{extendDomain}\,f$ is bijective from $f(s)$ to $f(t)$ when $g$ is bijective from $s$ to $t$
Informal description
Let $g : \alpha \to \beta$ be a function and $f : \alpha \to \gamma$ an injective function. If $g$ is a bijection from a set $s \subseteq \alpha$ to a set $t \subseteq \beta$, then the extended function $g.\text{extendDomain}\,f$ is a bijection from the image $f(s) \subseteq \gamma$ to the image $f(t) \subseteq \gamma$.
Set.LeftInvOn.extendDomain theorem
(h : LeftInvOn g₁ g₂ s) : LeftInvOn (g₁.extendDomain f) (g₂.extendDomain f) ((↑) ∘ f '' s)
Full source
protected lemma LeftInvOn.extendDomain (h : LeftInvOn g₁ g₂ s) :
    LeftInvOn (g₁.extendDomain f) (g₂.extendDomain f) ((↑) ∘ f(↑) ∘ f '' s) := by
  rintro _ ⟨a, ha, rfl⟩; simp_rw [Function.comp_apply, extendDomain_apply_image, h ha]
Left Inverse Property Preserved Under Domain Extension
Informal description
Let $g₁$ and $g₂$ be functions such that $g₁$ is a left inverse of $g₂$ on a set $s$, meaning $g₁(g₂(x)) = x$ for all $x \in s$. Let $f$ be an injective function. Then the extended domain permutation $g₁.\text{extendDomain}\,f$ is a left inverse of $g₂.\text{extendDomain}\,f$ on the image of $s$ under $f$, i.e., $(g₁.\text{extendDomain}\,f)((g₂.\text{extendDomain}\,f)(y)) = y$ for all $y \in f(s)$.
Set.RightInvOn.extendDomain theorem
(h : RightInvOn g₁ g₂ t) : RightInvOn (g₁.extendDomain f) (g₂.extendDomain f) ((↑) ∘ f '' t)
Full source
protected lemma RightInvOn.extendDomain (h : RightInvOn g₁ g₂ t) :
    RightInvOn (g₁.extendDomain f) (g₂.extendDomain f) ((↑) ∘ f(↑) ∘ f '' t) := by
  rintro _ ⟨a, ha, rfl⟩; simp_rw [Function.comp_apply, extendDomain_apply_image, h ha]
Right Inverse Property Preserved Under Domain Extension
Informal description
Let $g_1$ and $g_2$ be functions such that $g_1$ is a right inverse of $g_2$ on a set $t$, meaning that for every $y \in t$, we have $g_2(g_1(y)) = y$. Given an injective function $f$, the extended functions $g_1.\text{extendDomain}\,f$ and $g_2.\text{extendDomain}\,f$ satisfy the right inverse property on the image of $t$ under $f$, i.e., for every $y$ in $f(t)$, we have $(g_2.\text{extendDomain}\,f)((g_1.\text{extendDomain}\,f)(y)) = y$.
Set.InvOn.extendDomain theorem
(h : InvOn g₁ g₂ s t) : InvOn (g₁.extendDomain f) (g₂.extendDomain f) ((↑) ∘ f '' s) ((↑) ∘ f '' t)
Full source
protected lemma InvOn.extendDomain (h : InvOn g₁ g₂ s t) :
    InvOn (g₁.extendDomain f) (g₂.extendDomain f) ((↑) ∘ f(↑) ∘ f '' s) ((↑) ∘ f(↑) ∘ f '' t) :=
  ⟨h.1.extendDomain, h.2.extendDomain⟩
Two-Sided Inverse Property Preserved Under Domain Extension
Informal description
Let $g_1$ and $g_2$ be functions such that $g_1$ is a two-sided inverse of $g_2$ on sets $s$ and $t$, meaning: 1. For all $x \in s$, $g_1(g_2(x)) = x$ (left inverse property), and 2. For all $y \in t$, $g_2(g_1(y)) = y$ (right inverse property). Given an injective function $f$, the extended functions $g_1.\text{extendDomain}\,f$ and $g_2.\text{extendDomain}\,f$ satisfy the two-sided inverse property on the images $f(s)$ and $f(t)$, i.e.: 1. For all $x \in f(s)$, $(g_1.\text{extendDomain}\,f)((g_2.\text{extendDomain}\,f)(x)) = x$, and 2. For all $y \in f(t)$, $(g_2.\text{extendDomain}\,f)((g_1.\text{extendDomain}\,f)(y)) = y$.
Set.InjOn.prodMap theorem
(h₁ : s₁.InjOn f₁) (h₂ : s₂.InjOn f₂) : (s₁ ×ˢ s₂).InjOn fun x ↦ (f₁ x.1, f₂ x.2)
Full source
lemma InjOn.prodMap (h₁ : s₁.InjOn f₁) (h₂ : s₂.InjOn f₂) :
    (s₁ ×ˢ s₂).InjOn fun x ↦ (f₁ x.1, f₂ x.2) :=
  fun x hx y hy ↦ by simp_rw [Prod.ext_iff]; exact And.imp (h₁ hx.1 hy.1) (h₂ hx.2 hy.2)
Product of Injective Functions is Injective on Cartesian Products
Informal description
Let $f_1 : s_1 \to t_1$ and $f_2 : s_2 \to t_2$ be injective functions on their respective domains. Then the product function $(f_1, f_2) : s_1 \times s_2 \to t_1 \times t_2$ defined by $(x_1, x_2) \mapsto (f_1(x_1), f_2(x_2))$ is injective on the Cartesian product $s_1 \times s_2$.
Set.SurjOn.prodMap theorem
(h₁ : SurjOn f₁ s₁ t₁) (h₂ : SurjOn f₂ s₂ t₂) : SurjOn (fun x ↦ (f₁ x.1, f₂ x.2)) (s₁ ×ˢ s₂) (t₁ ×ˢ t₂)
Full source
lemma SurjOn.prodMap (h₁ : SurjOn f₁ s₁ t₁) (h₂ : SurjOn f₂ s₂ t₂) :
    SurjOn (fun x ↦ (f₁ x.1, f₂ x.2)) (s₁ ×ˢ s₂) (t₁ ×ˢ t₂) := by
  rintro x hx
  obtain ⟨a₁, ha₁, hx₁⟩ := h₁ hx.1
  obtain ⟨a₂, ha₂, hx₂⟩ := h₂ hx.2
  exact ⟨(a₁, a₂), ⟨ha₁, ha₂⟩, Prod.ext hx₁ hx₂⟩
Product of Surjective Functions is Surjective on Cartesian Products
Informal description
Let $f_1 : s_1 \to t_1$ and $f_2 : s_2 \to t_2$ be surjective functions on their respective domains. Then the product function $(f_1, f_2) : s_1 \times s_2 \to t_1 \times t_2$ is surjective on the Cartesian product $s_1 \times s_2$ to $t_1 \times t_2$.
Set.MapsTo.prodMap theorem
(h₁ : MapsTo f₁ s₁ t₁) (h₂ : MapsTo f₂ s₂ t₂) : MapsTo (fun x ↦ (f₁ x.1, f₂ x.2)) (s₁ ×ˢ s₂) (t₁ ×ˢ t₂)
Full source
lemma MapsTo.prodMap (h₁ : MapsTo f₁ s₁ t₁) (h₂ : MapsTo f₂ s₂ t₂) :
    MapsTo (fun x ↦ (f₁ x.1, f₂ x.2)) (s₁ ×ˢ s₂) (t₁ ×ˢ t₂) :=
  fun _x hx ↦ ⟨h₁ hx.1, h₂ hx.2⟩
Product of MapsTo Functions Preserves Cartesian Product Mapping
Informal description
Let $f_1 : s_1 \to t_1$ and $f_2 : s_2 \to t_2$ be functions such that $f_1$ maps every point in $s_1$ to a point in $t_1$ and $f_2$ maps every point in $s_2$ to a point in $t_2$. Then the product function $(f_1, f_2) : s_1 \times s_2 \to t_1 \times t_2$ maps every point in the Cartesian product $s_1 \times s_2$ to a point in $t_1 \times t_2$.
Set.BijOn.prodMap theorem
(h₁ : BijOn f₁ s₁ t₁) (h₂ : BijOn f₂ s₂ t₂) : BijOn (fun x ↦ (f₁ x.1, f₂ x.2)) (s₁ ×ˢ s₂) (t₁ ×ˢ t₂)
Full source
lemma BijOn.prodMap (h₁ : BijOn f₁ s₁ t₁) (h₂ : BijOn f₂ s₂ t₂) :
    BijOn (fun x ↦ (f₁ x.1, f₂ x.2)) (s₁ ×ˢ s₂) (t₁ ×ˢ t₂) :=
  ⟨h₁.mapsTo.prodMap h₂.mapsTo, h₁.injOn.prodMap h₂.injOn, h₁.surjOn.prodMap h₂.surjOn⟩
Bijectivity of Product Function on Cartesian Products
Informal description
Let $f_1 : s_1 \to t_1$ and $f_2 : s_2 \to t_2$ be bijective functions on their respective domains. Then the product function $(f_1, f_2) : s_1 \times s_2 \to t_1 \times t_2$ defined by $(x_1, x_2) \mapsto (f_1(x_1), f_2(x_2))$ is bijective on the Cartesian product $s_1 \times s_2$ to $t_1 \times t_2$.
Set.LeftInvOn.prodMap theorem
(h₁ : LeftInvOn g₁ f₁ s₁) (h₂ : LeftInvOn g₂ f₂ s₂) : LeftInvOn (fun x ↦ (g₁ x.1, g₂ x.2)) (fun x ↦ (f₁ x.1, f₂ x.2)) (s₁ ×ˢ s₂)
Full source
lemma LeftInvOn.prodMap (h₁ : LeftInvOn g₁ f₁ s₁) (h₂ : LeftInvOn g₂ f₂ s₂) :
    LeftInvOn (fun x ↦ (g₁ x.1, g₂ x.2)) (fun x ↦ (f₁ x.1, f₂ x.2)) (s₁ ×ˢ s₂) :=
  fun _x hx ↦ Prod.ext (h₁ hx.1) (h₂ hx.2)
Product of Left Inverses is Left Inverse of Product Function
Informal description
Let $f_1 : s_1 \to t_1$ and $f_2 : s_2 \to t_2$ be functions with left inverses $g_1$ and $g_2$ respectively, meaning $g_1(f_1(x)) = x$ for all $x \in s_1$ and $g_2(f_2(y)) = y$ for all $y \in s_2$. Then the product function $(f_1, f_2) : s_1 \times s_2 \to t_1 \times t_2$ has a left inverse given by $(g_1, g_2)$, i.e., $(g_1, g_2)((f_1, f_2)(x,y)) = (x,y)$ for all $(x,y) \in s_1 \times s_2$.
Set.RightInvOn.prodMap theorem
(h₁ : RightInvOn g₁ f₁ t₁) (h₂ : RightInvOn g₂ f₂ t₂) : RightInvOn (fun x ↦ (g₁ x.1, g₂ x.2)) (fun x ↦ (f₁ x.1, f₂ x.2)) (t₁ ×ˢ t₂)
Full source
lemma RightInvOn.prodMap (h₁ : RightInvOn g₁ f₁ t₁) (h₂ : RightInvOn g₂ f₂ t₂) :
    RightInvOn (fun x ↦ (g₁ x.1, g₂ x.2)) (fun x ↦ (f₁ x.1, f₂ x.2)) (t₁ ×ˢ t₂) :=
  fun _x hx ↦ Prod.ext (h₁ hx.1) (h₂ hx.2)
Product of Right Inverses is Right Inverse of Product Function
Informal description
Let $f_1 : s_1 \to t_1$ and $f_2 : s_2 \to t_2$ be functions with right inverses $g_1$ and $g_2$ respectively, meaning $f_1(g_1(y)) = y$ for all $y \in t_1$ and $f_2(g_2(z)) = z$ for all $z \in t_2$. Then the product function $(f_1, f_2) : s_1 \times s_2 \to t_1 \times t_2$ has a right inverse given by $(g_1, g_2)$, i.e., $(f_1, f_2)((g_1, g_2)(y,z)) = (y,z)$ for all $(y,z) \in t_1 \times t_2$.
Set.InvOn.prodMap theorem
(h₁ : InvOn g₁ f₁ s₁ t₁) (h₂ : InvOn g₂ f₂ s₂ t₂) : InvOn (fun x ↦ (g₁ x.1, g₂ x.2)) (fun x ↦ (f₁ x.1, f₂ x.2)) (s₁ ×ˢ s₂) (t₁ ×ˢ t₂)
Full source
lemma InvOn.prodMap (h₁ : InvOn g₁ f₁ s₁ t₁) (h₂ : InvOn g₂ f₂ s₂ t₂) :
    InvOn (fun x ↦ (g₁ x.1, g₂ x.2)) (fun x ↦ (f₁ x.1, f₂ x.2)) (s₁ ×ˢ s₂) (t₁ ×ˢ t₂) :=
  ⟨h₁.1.prodMap h₂.1, h₁.2.prodMap h₂.2⟩
Product of Two-Sided Inverses is Two-Sided Inverse of Product Function
Informal description
Let $f_1 : s_1 \to t_1$ and $f_2 : s_2 \to t_2$ be functions with two-sided inverses $g_1$ and $g_2$ respectively, meaning: 1. $g_1(f_1(x)) = x$ for all $x \in s_1$ and $f_1(g_1(y)) = y$ for all $y \in t_1$, 2. $g_2(f_2(x)) = x$ for all $x \in s_2$ and $f_2(g_2(y)) = y$ for all $y \in t_2$. Then the product function $(f_1, f_2) : s_1 \times s_2 \to t_1 \times t_2$ has a two-sided inverse given by $(g_1, g_2)$, satisfying: 1. $(g_1, g_2)((f_1, f_2)(x,y)) = (x,y)$ for all $(x,y) \in s_1 \times s_2$, 2. $(f_1, f_2)((g_1, g_2)(y,z)) = (y,z)$ for all $(y,z) \in t_1 \times t_2$.
Equiv.bijOn' theorem
(h₁ : MapsTo e s t) (h₂ : MapsTo e.symm t s) : BijOn e s t
Full source
lemma bijOn' (h₁ : MapsTo e s t) (h₂ : MapsTo e.symm t s) : BijOn e s t :=
  ⟨h₁, e.injective.injOn, fun b hb ↦ ⟨e.symm b, h₂ hb, apply_symm_apply _ _⟩⟩
Equivalence Induces Bijection on Subsets with Inverse Mapping Condition
Informal description
Let $e : \alpha \simeq \beta$ be an equivalence between types $\alpha$ and $\beta$, and let $s \subseteq \alpha$, $t \subseteq \beta$. If $e$ maps every element of $s$ to $t$ (i.e., $e(x) \in t$ for all $x \in s$) and its inverse $e^{-1}$ maps every element of $t$ back to $s$ (i.e., $e^{-1}(y) \in s$ for all $y \in t$), then $e$ is a bijection between $s$ and $t$.
Equiv.bijOn theorem
(h : ∀ a, e a ∈ t ↔ a ∈ s) : BijOn e s t
Full source
protected lemma bijOn (h : ∀ a, e a ∈ te a ∈ t ↔ a ∈ s) : BijOn e s t :=
  e.bijOn' (fun _ ↦ (h _).2) fun b hb ↦ (h _).1 <| by rwa [apply_symm_apply]
Equivalence Induces Bijection on Subsets with Membership Condition
Informal description
Let $e : \alpha \simeq \beta$ be an equivalence between types $\alpha$ and $\beta$, and let $s \subseteq \alpha$, $t \subseteq \beta$. If for every $a \in \alpha$, $e(a) \in t$ if and only if $a \in s$, then $e$ restricts to a bijection between $s$ and $t$.
Equiv.invOn theorem
: InvOn e e.symm t s
Full source
lemma invOn : InvOn e e.symm t s :=
  ⟨e.rightInverse_symm.leftInvOn _, e.leftInverse_symm.leftInvOn _⟩
Two-Sided Inverse Property for Equivalences on Subsets
Informal description
For any equivalence $e : \alpha \simeq \beta$ between types $\alpha$ and $\beta$, the inverse function $e^{-1} : \beta \to \alpha$ is a two-sided inverse of $e$ on the sets $t \subseteq \alpha$ and $s \subseteq \beta$. That is, for all $x \in s$, we have $e^{-1}(e(x)) = x$ (left inverse property), and for all $y \in t$, we have $e(e^{-1}(y)) = y$ (right inverse property).
Equiv.bijOn_image theorem
: BijOn e s (e '' s)
Full source
lemma bijOn_image : BijOn e s (e '' s) := e.injective.injOn.bijOn_image
Equivalence Induces Bijection on Image of Subset
Informal description
For any equivalence $e : \alpha \simeq \beta$ and any subset $s \subseteq \alpha$, the function $e$ is a bijection between $s$ and its image $e(s) = \{e(x) \mid x \in s\}$.
Equiv.bijOn_symm_image theorem
: BijOn e.symm (e '' s) s
Full source
lemma bijOn_symm_image : BijOn e.symm (e '' s) s := e.bijOn_image.symm e.invOn
Inverse Equivalence Bijects Image with Original Subset
Informal description
For any equivalence $e : \alpha \simeq \beta$ and any subset $s \subseteq \alpha$, the inverse equivalence $e^{-1} : \beta \simeq \alpha$ is a bijection between the image $e(s) = \{e(x) \mid x \in s\}$ and the original subset $s$.
Equiv.bijOn_symm theorem
: BijOn e.symm t s ↔ BijOn e s t
Full source
@[simp] lemma bijOn_symm : BijOnBijOn e.symm t s ↔ BijOn e s t := bijOn_comm e.symm.invOn
Bijectivity of Inverse Equivalence on Subsets
Informal description
For any equivalence $e : \alpha \simeq \beta$ between types $\alpha$ and $\beta$, the inverse equivalence $e^{-1}$ is a bijection from $t \subseteq \beta$ to $s \subseteq \alpha$ if and only if $e$ is a bijection from $s$ to $t$. In other words, $e^{-1}$ restricts to a bijection between $t$ and $s$ precisely when $e$ restricts to a bijection between $s$ and $t$.
Equiv.bijOn_swap theorem
(ha : a ∈ s) (hb : b ∈ s) : BijOn (swap a b) s s
Full source
lemma bijOn_swap (ha : a ∈ s) (hb : b ∈ s) : BijOn (swap a b) s s :=
  (swap a b).bijOn fun x ↦ by
    obtain rfl | hxa := eq_or_ne x a <;>
    obtain rfl | hxb := eq_or_ne x b <;>
    simp [*, swap_apply_of_ne_of_ne]
Swap Permutation Bijects Subset Containing Both Elements
Informal description
Let $s$ be a subset of a type $\alpha$, and let $a, b \in s$. The permutation $\mathrm{swap}(a, b)$, which exchanges $a$ and $b$ while fixing all other elements of $\alpha$, restricts to a bijection from $s$ to itself.