The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V03. Sets, finite structures and big operators

Mathlib.Data.Set.Restrict

61 declarations and 23 deprecated aliases. Mathlib docs · Source

Restrict the domain of a function to a set

Main definitions

  • Set.domRestrict f s : restrict the domain of f to the set s;
  • Set.codRestrict f s h : given h : ∀ x, f x ∈ s, restrict the codomain of f to the set s;

Domain restriction

Restriction onto preimage

Injectivity on a set

Surjectivity on a set

theorem Set.MapsTo.restrict.congr_simp E1 #

∀ {α : Type u} {β : Type v} (f f_1 : α → β) (e_f : f = f_1) (s : Set α) (t : Set β) (h : Set.MapsTo f s t) (a a_1 : ↑s),
  a = a_1 → Set.MapsTo.restrict f s t h a = Set.MapsTo.restrict f_1 s t ⋯ a_1

theorem Set.codRestrict.congr_simp E1 #

∀ {α : Type u_1} {ι : Sort u_4} (f f_1 : ι → α) (e_f : f = f_1) (s : Set α) (h : ∀ (x : ι), f x ∈ s) (a a_1 : ι),
  a = a_1 → Set.codRestrict f s h a = Set.codRestrict f_1 s ⋯ a_1

def Set.domRestrict E1 #

{α : Type u_1} → {π : α → Type u_5} → (s : Set α) → ((a : α) → π a) → (a : ↑s) → π ↑a

Restrict domain of a function f to a set s. Same as Subtype.restrict but this version takes an argument ↥s instead of Subtype s.

theorem Set.domRestrict_def E0 #

∀ {α : Type u_1} {π : α → Type u_5} (s : Set α), s.domRestrict = fun f x ↦ f ↑x

theorem Set.domRestrict_eq E0 #

∀ {α : Type u_1} {β : Type u_2} (f : α → β) (s : Set α), s.domRestrict f = f ∘ Subtype.val

theorem Set.domRestrict_id E0 #

∀ {α : Type u_1} (s : Set α), s.domRestrict id = Subtype.val

theorem Set.domRestrict_apply E0 #

∀ {α : Type u_1} {π : α → Type u_5} (f : (a : α) → π a) (s : Set α) (x : ↑s), s.domRestrict f x = f ↑x

theorem Set.domRestrict_eq_iff E0 #

∀ {α : Type u_1} {π : α → Type u_5} {f : (a : α) → π a} {s : Set α} {g : (a : ↑s) → π ↑a},
  s.domRestrict f = g ↔ ∀ (a : α) (ha : a ∈ s), f a = g ⟨a, ha⟩

theorem Set.range_domRestrict E0 #

∀ {α : Type u_1} {β : Type u_2} (f : α → β) (s : Set α), Set.range (s.domRestrict f) = f '' s

theorem Set.image_domRestrict E1 #

∀ {α : Type u_1} {β : Type u_2} (f : α → β) (s t : Set α), s.domRestrict f '' Subtype.val ⁻¹' t = f '' (t ∩ s)

theorem Set.domRestrict_dite E0 #

∀ {α : Type u_1} {β : Type u_2} {s : Set α} [inst : (x : α) → Decidable (x ∈ s)] (f : (a : α) → a ∈ s → β)
  (g : (a : α) → a ∉ s → β), (s.domRestrict fun a ↦ if h : a ∈ s then f a h else g a h) = fun a ↦ f ↑a ⋯

theorem Set.domRestrict_dite_compl E0 #

∀ {α : Type u_1} {β : Type u_2} {s : Set α} [inst : (x : α) → Decidable (x ∈ s)] (f : (a : α) → a ∈ s → β)
  (g : (a : α) → a ∉ s → β), (sᶜ.domRestrict fun a ↦ if h : a ∈ s then f a h else g a h) = fun a ↦ g ↑a ⋯

theorem Set.domRestrict_ite E0 #

∀ {α : Type u_1} {β : Type u_2} (f g : α → β) (s : Set α) [inst : (x : α) → Decidable (x ∈ s)],
  (s.domRestrict fun a ↦ if a ∈ s then f a else g a) = s.domRestrict f

theorem Set.domRestrict_ite_compl E0 #

∀ {α : Type u_1} {β : Type u_2} (f g : α → β) (s : Set α) [inst : (x : α) → Decidable (x ∈ s)],
  (sᶜ.domRestrict fun a ↦ if a ∈ s then f a else g a) = sᶜ.domRestrict g

theorem Set.domRestrict_piecewise E0 #

∀ {α : Type u_1} {β : Type u_2} (f g : α → β) (s : Set α) [inst : (x : α) → Decidable (x ∈ s)],
  s.domRestrict (s.piecewise f g) = s.domRestrict f

theorem Set.domRestrict_piecewise_compl E0 #

∀ {α : Type u_1} {β : Type u_2} (f g : α → β) (s : Set α) [inst : (x : α) → Decidable (x ∈ s)],
  sᶜ.domRestrict (s.piecewise f g) = sᶜ.domRestrict g

theorem Set.domRestrict_extend_range E1 #

∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} (f : α → β) (g : α → γ) (g' : β → γ),
  (Set.range f).domRestrict (Function.extend f g g') = fun x ↦ g (Exists.choose ⋯)

theorem Set.domRestrict_extend_compl_range E0 #

∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} (f : α → β) (g : α → γ) (g' : β → γ),
  (Set.range f)ᶜ.domRestrict (Function.extend f g g') = g' ∘ Subtype.val

def Set.domRestrict₂ E1 #

{α : Type u_1} → {π : α → Type u_5} → {s t : Set α} → s ⊆ t → ((a : ↑t) → π ↑a) → (a : ↑s) → π ↑a

If a function f is restricted to a set t, and s ⊆ t, this is the restriction to s.

theorem Set.domRestrict₂_def E0 #

∀ {α : Type u_1} {π : α → Type u_5} {s t : Set α} (hst : s ⊆ t), Set.domRestrict₂ hst = fun f x ↦ f ⟨↑x, ⋯⟩

theorem Set.domRestrict₂_comp_domRestrict E1 #

∀ {α : Type u_1} {π : α → Type u_5} {s t : Set α} (hst : s ⊆ t), Set.domRestrict₂ hst ∘ t.domRestrict = s.domRestrict

theorem Set.domRestrict₂_comp_domRestrict₂ E1 #

∀ {α : Type u_1} {π : α → Type u_5} {s t u : Set α} (hst : s ⊆ t) (htu : t ⊆ u),
  Set.domRestrict₂ hst ∘ Set.domRestrict₂ htu = Set.domRestrict₂ ⋯

theorem Set.range_extend_subset E1 #

∀ {β : Type u_2} {γ : Type u_3} {ι : Sort u_4} (f : ι → β) (g : ι → γ) (g' : β → γ),
  Set.range (Function.extend f g g') ⊆ Set.range g ∪ g' '' (Set.range f)ᶜ

theorem Set.range_extend E1 #

∀ {β : Type u_2} {γ : Type u_3} {ι : Sort u_4} {f : ι → β},
  Function.Injective f →
    ∀ (g : ι → γ) (g' : β → γ), Set.range (Function.extend f g g') = Set.range g ∪ g' '' (Set.range f)ᶜ

theorem Function.FactorsThrough.extend_injOn E1 #

∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {f : α → β} {g : α → γ} {j : β → γ},
  Function.FactorsThrough g f → Function.Injective g → Set.InjOn (Function.extend f g j) (Set.range f)

If g factors through f and g is injective, then extend f g j is injective on the range of f.

theorem Function.Injective.extend_injOn E1 #

∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {f : α → β} {g : α → γ} {j : β → γ},
  Function.Injective f → Function.Injective g → Set.InjOn (Function.extend f g j) (Set.range f)

If f and g are injective, then extend f g j is injective on the range of f.

theorem Function.Injective.extend_of_disjoint E1 #

∀ {α : Type u_1} {β : Type u_2} {γ : Type u_3} {f : α → β} {g : α → γ} {j : β → γ},
  Function.Injective f →
    Function.Injective g →
      Function.Injective j → Disjoint (Set.range g) (Set.range j) → Function.Injective (Function.extend f g j)

If f, g and j are injective and g and j have disjoint ranges, then extend f g j is injective.

def Set.codRestrict E1 #

{α : Type u_1} → {ι : Sort u_4} → (f : ι → α) → (s : Set α) → (∀ (x : ι), f x ∈ s) → ι → ↑s

Restrict codomain of a function f to a set s. Same as Subtype.coind but this version has codomain ↥s instead of Subtype s.

theorem Set.val_codRestrict_apply E0 #

∀ {α : Type u_1} {ι : Sort u_4} (f : ι → α) (s : Set α) (h : ∀ (x : ι), f x ∈ s) (x : ι),
  ↑(Set.codRestrict f s h x) = f x

theorem Set.domRestrict_comp_codRestrict E0 #

∀ {α : Type u_1} {β : Type u_2} {ι : Sort u_4} {f : ι → α} {g : α → β} {b : Set α} (h : ∀ (x : ι), f x ∈ b),
  b.domRestrict g ∘ Set.codRestrict f b h = g ∘ f

theorem Set.injective_codRestrict E0 #

∀ {α : Type u_1} {ι : Sort u_4} {f : ι → α} {s : Set α} (h : ∀ (x : ι), f x ∈ s),
  Function.Injective (Set.codRestrict f s h) ↔ Function.Injective f

theorem Function.Injective.codRestrict E1 #

∀ {α : Type u_1} {ι : Sort u_4} {f : ι → α} {s : Set α} (h : ∀ (x : ι), f x ∈ s),
  Function.Injective f → Function.Injective (Set.codRestrict f s h)

Alias of the reverse direction of Set.injective_codRestrict.

theorem Set.range_codRestrict E0 #

∀ {α : Type u_1} {ι : Sort u_4} {f : ι → α} {s : Set α} (h : ∀ (x : ι), f x ∈ s),
  Set.range (Set.codRestrict f s h) = Subtype.val ⁻¹' Set.range f

theorem Set.surjective_codRestrict E1 #

∀ {α : Type u_1} {ι : Sort u_4} {f : ι → α} {s : Set α} (h : ∀ (x : ι), f x ∈ s),
  Function.Surjective (Set.codRestrict f s h) ↔ Set.range f = s

theorem Set.codRestrict_range_surjective E1 #

∀ {α : Type u_1} {ι : Sort u_4} (f : ι → α), Function.Surjective (Set.codRestrict f (Set.range f) ⋯)

theorem Set.domRestrict_eq_domRestrict_iff E0 #

∀ {α : Type u_1} {β : Type u_2} {s : Set α} {f₁ f₂ : α → β}, s.domRestrict f₁ = s.domRestrict f₂ ↔ Set.EqOn f₁ f₂ s

theorem Set.MapsTo.restrict_commutes E1 #

∀ {α : Type u_1} {β : Type u_2} (f : α → β) (s : Set α) (t : Set β) (h : Set.MapsTo f s t),
  Subtype.val ∘ Set.MapsTo.restrict f s t h = f ∘ Subtype.val

theorem Set.MapsTo.val_restrict_apply E0 #

∀ {α : Type u_1} {β : Type u_2} {s : Set α} {t : Set β} {f : α → β} (h : Set.MapsTo f s t) (x : ↑s),
  ↑(Set.MapsTo.restrict f s t h x) = f ↑x

theorem Set.MapsTo.coe_iterate_restrict E0 #

∀ {α : Type u_1} {s : Set α} {f : α → α} (h : Set.MapsTo f s s) (x : ↑s) (k : ℕ),
  ↑((Set.MapsTo.restrict f s s h)^[k] x) = f^[k] ↑x

theorem Set.codRestrict_domRestrict E0 #

∀ {α : Type u_1} {β : Type u_2} {s : Set α} {t : Set β} {f : α → β} (h : ∀ (x : ↑s), f ↑x ∈ t),
  Set.codRestrict (s.domRestrict f) t h = Set.MapsTo.restrict f s t ⋯

Restricting the domain and then the codomain is the same as MapsTo.restrict.

theorem Set.MapsTo.restrict_eq_codRestrict E1 #

∀ {α : Type u_1} {β : Type u_2} {s : Set α} {t : Set β} {f : α → β} (h : Set.MapsTo f s t),
  Set.MapsTo.restrict f s t h = Set.codRestrict (s.domRestrict f) t ⋯

Reverse of Set.codRestrict_domRestrict.

theorem Set.MapsTo.coe_restrict E0 #

∀ {α : Type u_1} {β : Type u_2} {s : Set α} {t : Set β} {f : α → β} (h : Set.MapsTo f s t),
  Subtype.val ∘ Set.MapsTo.restrict f s t h = s.domRestrict f

theorem Set.MapsTo.range_restrict E1 #

∀ {α : Type u_1} {β : Type u_2} (f : α → β) (s : Set α) (t : Set β) (h : Set.MapsTo f s t),
  Set.range (Set.MapsTo.restrict f s t h) = Subtype.val ⁻¹' f '' s

theorem Set.mapsTo_iff_exists_map_subtype E1 #

∀ {α : Type u_1} {β : Type u_2} {s : Set α} {t : Set β} {f : α → β}, Set.MapsTo f s t ↔ ∃ g, ∀ (x : ↑s), f ↑x = ↑(g x)

theorem Set.surjective_mapsTo_image_restrict E1 #

∀ {α : Type u_1} {β : Type u_2} (f : α → β) (s : Set α), Function.Surjective (Set.MapsTo.restrict f s (f '' s) ⋯)

theorem Set.image_restrictPreimage E1 #

∀ {α : Type u_1} {β : Type u_2} (s : Set α) (t : Set β) (f : α → β),
  t.restrictPreimage f '' Subtype.val ⁻¹' s = Subtype.val ⁻¹' f '' s

theorem Set.range_restrictPreimage E1 #

∀ {α : Type u_1} {β : Type u_2} (t : Set β) (f : α → β), Set.range (t.restrictPreimage f) = Subtype.val ⁻¹' Set.range f

theorem Set.restrictPreimage_mk E0 #

∀ {α : Type u_1} {β : Type u_2} (t : Set β) {f : α → β} {a : α} (h : a ∈ f ⁻¹' t),
  t.restrictPreimage f ⟨a, h⟩ = ⟨f a, h⟩

theorem Set.image_val_preimage_restrictPreimage E1 #

∀ {α : Type u_1} {β : Type u_2} (t : Set β) {f : α → β} {u : Set ↑t},
  Subtype.val '' t.restrictPreimage f ⁻¹' u = f ⁻¹' Subtype.val '' u

theorem Set.preimage_restrictPreimage E1 #

∀ {α : Type u_1} {β : Type u_2} (t : Set β) {f : α → β} {u : Set ↑t},
  t.restrictPreimage f ⁻¹' u = (fun a ↦ f ↑a) ⁻¹' Subtype.val '' u

theorem Set.restrictPreimage_injective E1 #

∀ {α : Type u_1} {β : Type u_2} (t : Set β) {f : α → β},
  Function.Injective f → Function.Injective (t.restrictPreimage f)

theorem Set.restrictPreimage_surjective E1 #

∀ {α : Type u_1} {β : Type u_2} (t : Set β) {f : α → β},
  Function.Surjective f → Function.Surjective (t.restrictPreimage f)

theorem Set.restrictPreimage_bijective E1 #

∀ {α : Type u_1} {β : Type u_2} (t : Set β) {f : α → β},
  Function.Bijective f → Function.Bijective (t.restrictPreimage f)

theorem Function.Injective.restrictPreimage E1 #

∀ {α : Type u_1} {β : Type u_2} (t : Set β) {f : α → β},
  Function.Injective f → Function.Injective (t.restrictPreimage f)

Alias of Set.restrictPreimage_injective.

theorem Function.Surjective.restrictPreimage E1 #

∀ {α : Type u_1} {β : Type u_2} (t : Set β) {f : α → β},
  Function.Surjective f → Function.Surjective (t.restrictPreimage f)

Alias of Set.restrictPreimage_surjective.

theorem Function.Bijective.restrictPreimage E1 #

∀ {α : Type u_1} {β : Type u_2} (t : Set β) {f : α → β},
  Function.Bijective f → Function.Bijective (t.restrictPreimage f)

Alias of Set.restrictPreimage_bijective.

theorem Set.injOn_iff_injective E1 #

∀ {α : Type u_1} {β : Type u_2} {s : Set α} {f : α → β}, Set.InjOn f s ↔ Function.Injective (s.domRestrict f)

theorem Set.InjOn.injective E1 #

∀ {α : Type u_1} {β : Type u_2} {s : Set α} {f : α → β}, Set.InjOn f s → Function.Injective (s.domRestrict f)

Alias of the forward direction of Set.injOn_iff_injective.

theorem Set.MapsTo.restrict_inj E1 #

∀ {α : Type u_1} {β : Type u_2} {s : Set α} {t : Set β} {f : α → β} (h : Set.MapsTo f s t),
  Function.Injective (Set.MapsTo.restrict f s t h) ↔ Set.InjOn f s

theorem Set.surjOn_iff_surjective E1 #

∀ {α : Type u_1} {β : Type u_2} {s : Set α} {f : α → β}, Set.SurjOn f s Set.univ ↔ Function.Surjective (s.domRestrict f)

theorem Set.MapsTo.restrict_surjective_iff E0 #

∀ {α : Type u_1} {β : Type u_2} {s : Set α} {t : Set β} {f : α → β} (h : Set.MapsTo f s t),
  Function.Surjective (Set.MapsTo.restrict f s t h) ↔ Set.SurjOn f s t

Deprecated aliases

NameNew nameSince
Set.codRestrict_restrictSet.codRestrict_domRestrict2026-07-19
Set.image_restrictSet.image_domRestrict2026-07-19
Set.range_restrictSet.range_domRestrict2026-07-19
Set.restrictSet.domRestrict2026-07-19
Set.restrict_applySet.domRestrict_apply2026-07-19
Set.restrict_comp_codRestrictSet.domRestrict_comp_codRestrict2026-07-19
Set.restrict_defSet.domRestrict_def2026-07-19
Set.restrict_diteSet.domRestrict_dite2026-07-19
Set.restrict_dite_complSet.domRestrict_dite_compl2026-07-19
Set.restrict_eqSet.domRestrict_eq2026-07-19
Set.restrict_eq_iffSet.domRestrict_eq_iff2026-07-19
Set.restrict_eq_restrict_iffSet.domRestrict_eq_domRestrict_iff2026-07-19
Set.restrict_extend_compl_rangeSet.domRestrict_extend_compl_range2026-07-19
Set.restrict_extend_rangeSet.domRestrict_extend_range2026-07-19
Set.restrict_idSet.domRestrict_id2026-07-19
Set.restrict_iteSet.domRestrict_ite2026-07-19
Set.restrict_ite_complSet.domRestrict_ite_compl2026-07-19
Set.restrict_piecewiseSet.domRestrict_piecewise2026-07-19
Set.restrict_piecewise_complSet.domRestrict_piecewise_compl2026-07-19
Set.restrict₂Set.domRestrict₂2026-07-19
Set.restrict₂_comp_restrictSet.domRestrict₂_comp_domRestrict2026-07-19
Set.restrict₂_comp_restrict₂Set.domRestrict₂_comp_domRestrict₂2026-07-19
Set.restrict₂_defSet.domRestrict₂_def2026-07-19