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 / V01. The language of Mathlib

Mathlib.Logic.Function.Basic

257 declarations and 3 deprecated aliases. Mathlib docs · Source

Miscellaneous function constructions and lemmas

Bijectivity of Eq.rec, Eq.mp, Eq.mpr, and cast

Note these lemmas apply to Type* not Sort*, as the latter interferes with simp, and is trivial anyway.

theorem Classical.arbitrary.congr_simp E1 #

∀ (α : Sort u_3) [h : Nonempty α], Classical.arbitrary α = Classical.arbitrary α

theorem Function.update.hcongr_6 E1 #

∀ (α α' : Sort u),
  α = α' →
    ∀ (β : α → Sort v) (β' : α' → Sort v),
      β ≍ β' →
        ∀ (inst : DecidableEq α) (inst' : DecidableEq α'),
          inst ≍ inst' →
            ∀ (f : (a : α) → β a) (f' : (a : α') → β' a),
              f ≍ f' →
                ∀ (a' : α) (a'' : α'),
                  a' ≍ a'' → ∀ (v : β a') (v' : β' a''), v ≍ v' → Function.update f a' v ≍ Function.update f' a'' v'

theorem Lean.Grind.leftInv.congr_simp E1 #

∀ {α : Sort u} {β : Sort v} (f f_1 : α → β) (e_f : f = f_1) (hf : Function.Injective f) [inst : Nonempty α] (a a_1 : β),
  a = a_1 → f⁻¹ a = f_1⁻¹ a_1

theorem Function.surjInv.congr_simp E1 #

∀ {α : Sort u} {β : Sort v} {f f_1 : α → β} (e_f : f = f_1) (h : Function.Surjective f) (b b_1 : β),
  b = b_1 → Function.surjInv h b = Function.surjInv ⋯ b_1

def Function.HasUncurry.ctorIdx E1 #

{α : Type u_5} → {β : outParam (Type u_6)} → {γ : outParam (Type u_7)} → Function.HasUncurry α β γ → ℕ

theorem Function.update.congr_simp E1 #

∀ {α : Sort u} {β : α → Sort v} {inst : DecidableEq α} [inst_1 : DecidableEq α] (f f_1 : (a : α) → β a),
  f = f_1 → ∀ (a' : α) (v v_1 : β a'), v = v_1 → ∀ (a : α), Function.update f a' v a = Function.update f_1 a' v_1 a

theorem Subtype.mk.hcongr_4 E1 #

∀ (α α' : Sort u),
  α = α' →
    ∀ (p : α → Prop) (p' : α' → Prop),
      p ≍ p' →
        ∀ (val : α) (val' : α'),
          val ≍ val' →
            ∀ (property : p val) (property' : p' val'), property ≍ property' → ⟨val, property⟩ ≍ ⟨val', property'⟩

def Function.eval E1 #

{α : Sort u_1} → {β : α → Sort u_4} → (x : α) → ((x : α) → β x) → β x

Evaluate a function at an argument. Useful if you want to talk about the partially applied Function.eval x : (∀ x, β x) → β x.

theorem Function.eval_apply E0 #

∀ {α : Sort u_1} {β : α → Sort u_4} (x : α) (f : (x : α) → β x), Function.eval x f = f x

theorem Function.const_def E0 #

∀ {α : Sort u_1} {β : Sort u_2} {y : β}, (fun x ↦ y) = Function.const α y

theorem Function.const_injective E1 #

∀ {α : Sort u_1} {β : Sort u_2} [Nonempty α], Function.Injective (Function.const α)

theorem Function.const_inj E0 #

∀ {α : Sort u_1} {β : Sort u_2} [Nonempty α] {y₁ y₂ : β}, Function.const α y₁ = Function.const α y₂ ↔ y₁ = y₂

theorem Function.onFun_apply E0 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} (f : β → β → γ) (g : α → β) (a b : α),
  Function.onFun f g a b = f (g a) (g b)

theorem Function.onFun_onFun_eq E0 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {δ : Sort u_4} (f : α → α → γ) (g : β → α) (h : δ → β),
  Function.onFun (Function.onFun f g) h = Function.onFun f (g ∘ h)

theorem Function.onFun_comp_eq E0 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {δ : Sort u_4} (f : α → α → γ) (g : β → α) (h : δ → β),
  Function.onFun f (g ∘ h) = Function.onFun (Function.onFun f g) h

instance Function.instReflOnFun E0 #

∀ {α : Sort u_1} {β : Sort u_2} (r : β → β → Prop) (f : α → β) [Std.Refl r], Std.Refl (Function.onFun r f)

instance Function.instIrreflOnFun E0 #

∀ {α : Sort u_1} {β : Sort u_2} (r : β → β → Prop) (f : α → β) [Std.Irrefl r], Std.Irrefl (Function.onFun r f)

instance Function.instSymmOnFun E0 #

∀ {α : Sort u_1} {β : Sort u_2} (r : β → β → Prop) (f : α → β) [Std.Symm r], Std.Symm (Function.onFun r f)

theorem Function.Injective.antisymm_onFun E1 #

∀ {α : Sort u_1} {β : Sort u_2} (r : β → β → Prop) {f : α → β},
  Function.Injective f → ∀ [Std.Antisymm r], Std.Antisymm (Function.onFun r f)

instance Function.instAsymmOnFun E0 #

∀ {α : Sort u_1} {β : Sort u_2} (r : β → β → Prop) (f : α → β) [Std.Asymm r], Std.Asymm (Function.onFun r f)

instance Function.instIsTransOnFun E0 #

∀ {α : Sort u_1} {β : Sort u_2} (r : β → β → Prop) (f : α → β) [IsTrans β r], IsTrans α (Function.onFun r f)

instance Function.instTotalOnFun E0 #

∀ {α : Sort u_1} {β : Sort u_2} (r : β → β → Prop) (f : α → β) [Std.Total r], Std.Total (Function.onFun r f)

theorem Function.Injective.trichotomous_onFun E1 #

∀ {α : Sort u_1} {β : Sort u_2} (r : β → β → Prop) {f : α → β},
  Function.Injective f → ∀ [Std.Trichotomous r], Std.Trichotomous (Function.onFun r f)

instance Function.instIsEquivOnFun E0 #

∀ {α : Sort u_1} {β : Sort u_2} (r : β → β → Prop) (f : α → β) [IsEquiv β r], IsEquiv α (Function.onFun r f)

instance Function.instIsPreorderOnFun E0 #

∀ {α : Sort u_1} {β : Sort u_2} (r : β → β → Prop) (f : α → β) [IsPreorder β r], IsPreorder α (Function.onFun r f)

theorem Function.Injective.isPartialOrder_onFun E1 #

∀ {α : Sort u_1} {β : Sort u_2} (r : β → β → Prop) {f : α → β},
  Function.Injective f → ∀ [IsPartialOrder β r], IsPartialOrder α (Function.onFun r f)

theorem Function.Injective.isLinearOrder_onFun E1 #

∀ {α : Sort u_1} {β : Sort u_2} (r : β → β → Prop) {f : α → β},
  Function.Injective f → ∀ [IsLinearOrder β r], IsLinearOrder α (Function.onFun r f)

instance Function.instIsStrictOrderOnFun E0 #

∀ {α : Sort u_1} {β : Sort u_2} (r : β → β → Prop) (f : α → β) [IsStrictOrder β r], IsStrictOrder α (Function.onFun r f)

instance Function.instIsStrictWeakOrderOnFun E0 #

∀ {α : Sort u_1} {β : Sort u_2} (r : β → β → Prop) (f : α → β) [IsStrictWeakOrder β r],
  IsStrictWeakOrder α (Function.onFun r f)

theorem Function.Injective.isStrictTotalOrder_onFun E1 #

∀ {α : Sort u_1} {β : Sort u_2} (r : β → β → Prop) {f : α → β},
  Function.Injective f → ∀ [IsStrictTotalOrder β r], IsStrictTotalOrder α (Function.onFun r f)

theorem Function.hfunext E1 #

∀ {α α' : Sort u} {β : α → Sort v} {β' : α' → Sort v} {f : (a : α) → β a} {f' : (a : α') → β' a},
  α = α' → (∀ (a : α) (a' : α'), a ≍ a' → f a ≍ f' a') → f ≍ f'

theorem Function.ne_iff E0 #

∀ {α : Sort u_1} {β : α → Sort u_4} {f₁ f₂ : (a : α) → β a}, f₁ ≠ f₂ ↔ ∃ a, f₁ a ≠ f₂ a

theorem Function.funext_iff_of_subsingleton E1 #

∀ {α : Sort u_1} {β : Sort u_2} {f : α → β} [Subsingleton α] {g : α → β} (x y : α), f x = g y ↔ f = g

theorem Function.swap_lt E1 #

∀ {α : Type u_4} [inst : LT α], (Function.swap fun x1 x2 ↦ x1 < x2) = fun x1 x2 ↦ x1 > x2

theorem Function.swap_le E1 #

∀ {α : Type u_4} [inst : LE α], (Function.swap fun x1 x2 ↦ x1 ≤ x2) = fun x1 x2 ↦ x1 ≥ x2

theorem Function.swap_gt E1 #

∀ {α : Type u_4} [inst : LT α], (Function.swap fun x1 x2 ↦ x1 > x2) = fun x1 x2 ↦ x1 < x2

theorem Function.swap_ge E1 #

∀ {α : Type u_4} [inst : LE α], (Function.swap fun x1 x2 ↦ x1 ≥ x2) = fun x1 x2 ↦ x1 ≤ x2

instance Function.instReflSwapProp E0 #

∀ {α : Sort u_1} (r : α → α → Prop) [Std.Refl r], Std.Refl (Function.swap r)

instance Function.instIrreflSwapProp E0 #

∀ {α : Sort u_1} (r : α → α → Prop) [Std.Irrefl r], Std.Irrefl (Function.swap r)

instance Function.instSymmSwapProp E0 #

∀ {α : Sort u_1} (r : α → α → Prop) [Std.Symm r], Std.Symm (Function.swap r)

instance Function.instAntisymmSwapProp E0 #

∀ {α : Sort u_1} (r : α → α → Prop) [Std.Antisymm r], Std.Antisymm (Function.swap r)

instance Function.instAsymmSwapProp E0 #

∀ {α : Sort u_1} (r : α → α → Prop) [Std.Asymm r], Std.Asymm (Function.swap r)

instance Function.instIsTransSwapProp E0 #

∀ {α : Sort u_1} (r : α → α → Prop) [IsTrans α r], IsTrans α (Function.swap r)

instance Function.instTotalSwapProp E0 #

∀ {α : Sort u_1} (r : α → α → Prop) [Std.Total r], Std.Total (Function.swap r)

instance Function.instTrichotomousSwapProp E0 #

∀ {α : Sort u_1} (r : α → α → Prop) [Std.Trichotomous r], Std.Trichotomous (Function.swap r)

instance Function.instIsEquivSwapProp E0 #

∀ {α : Sort u_1} (r : α → α → Prop) [IsEquiv α r], IsEquiv α (Function.swap r)

instance Function.instIsPreorderSwapProp E0 #

∀ {α : Sort u_1} (r : α → α → Prop) [IsPreorder α r], IsPreorder α (Function.swap r)

instance Function.instIsPartialOrderSwapProp E0 #

∀ {α : Sort u_1} (r : α → α → Prop) [IsPartialOrder α r], IsPartialOrder α (Function.swap r)

instance Function.instIsLinearOrderSwapProp E0 #

∀ {α : Sort u_1} (r : α → α → Prop) [IsLinearOrder α r], IsLinearOrder α (Function.swap r)

instance Function.instIsStrictOrderSwapProp E0 #

∀ {α : Sort u_1} (r : α → α → Prop) [IsStrictOrder α r], IsStrictOrder α (Function.swap r)

instance Function.instIsStrictWeakOrderSwapProp E0 #

∀ {α : Sort u_1} (r : α → α → Prop) [IsStrictWeakOrder α r], IsStrictWeakOrder α (Function.swap r)

instance Function.instIsStrictTotalOrderSwapProp E0 #

∀ {α : Sort u_1} (r : α → α → Prop) [IsStrictTotalOrder α r], IsStrictTotalOrder α (Function.swap r)

theorem Function.Bijective.injective E1 #

∀ {α : Sort u_1} {β : Sort u_2} {f : α → β}, Function.Bijective f → Function.Injective f

theorem Function.Bijective.surjective E2 #

∀ {α : Sort u_1} {β : Sort u_2} {f : α → β}, Function.Bijective f → Function.Surjective f

theorem Function.not_injective_iff E0 #

∀ {α : Sort u_1} {β : Sort u_2} {f : α → β}, ¬Function.Injective f ↔ ∃ a b, f a = f b ∧ a ≠ b

theorem Function.not_injective_const E0 #

∀ {α : Type u_4} {β : Type u_5} [Nontrivial α] {b : β}, ¬Function.Injective fun x ↦ b

def Function.Injective.decidableEq E1 #

{α : Sort u_1} → {β : Sort u_2} → {f : α → β} → [DecidableEq β] → Function.Injective f → DecidableEq α

If the co-domain β of an injective function f : α → β has decidable equality, then the domain α also has decidable equality.

theorem Function.Injective.of_comp E1 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {f : α → β} {g : γ → α},
  Function.Injective (f ∘ g) → Function.Injective g

theorem Function.Injective.of_comp_iff E0 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {f : α → β},
  Function.Injective f → ∀ (g : γ → α), Function.Injective (f ∘ g) ↔ Function.Injective g

theorem Function.Injective.of_comp_right E1 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {f : α → β} {g : γ → α},
  Function.Injective (f ∘ g) → Function.Surjective g → Function.Injective f

theorem Function.Surjective.bijective₂_of_injective E1 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {f : α → β} {g : γ → α},
  Function.Surjective f →
    Function.Surjective g → Function.Injective (f ∘ g) → Function.Bijective f ∧ Function.Bijective g

theorem Function.Injective.of_comp_iff' E0 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} (f : α → β) {g : γ → α},
  Function.Bijective g → (Function.Injective (f ∘ g) ↔ Function.Injective f)

theorem Function.Injective.piMap E1 #

∀ {ι : Sort u_4} {α : ι → Sort u_5} {β : ι → Sort u_6} {f : (i : ι) → α i → β i},
  (∀ (i : ι), Function.Injective (f i)) → Function.Injective (Pi.map f)

theorem Function.Injective.comp_left E1 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {g : β → γ}, Function.Injective g → Function.Injective fun x ↦ g ∘ x

Composition by an injective function on the left is itself injective.

theorem Function.injective_comp_left_iff E0 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} [Nonempty α] {g : β → γ},
  (Function.Injective fun x ↦ g ∘ x) ↔ Function.Injective g

theorem Function.injective_of_subsingleton E1 #

∀ {α : Sort u_1} {β : Sort u_2} [Subsingleton α] (f : α → β), Function.Injective f

theorem Function.bijective_of_subsingleton E1 #

∀ {α : Sort u_1} [Subsingleton α] (f : α → α), Function.Bijective f

theorem Function.Injective.dite E1 #

∀ {α : Sort u_1} {β : Sort u_2} (p : α → Prop) [inst : DecidablePred p] {f : { a // p a } → β} {f' : { a // ¬p a } → β},
  Function.Injective f →
    Function.Injective f' →
      (∀ {x x' : α} {hx : p x} {hx' : ¬p x'}, f ⟨x, hx⟩ ≠ f' ⟨x', hx'⟩) →
        Function.Injective fun x ↦ if h : p x then f ⟨x, h⟩ else f' ⟨x, h⟩

theorem Function.Surjective.of_comp E1 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {f : α → β} {g : γ → α},
  Function.Surjective (f ∘ g) → Function.Surjective f

theorem Function.Surjective.of_comp_iff E0 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} (f : α → β) {g : γ → α},
  Function.Surjective g → (Function.Surjective (f ∘ g) ↔ Function.Surjective f)

theorem Function.Surjective.of_comp_left E1 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {f : α → β} {g : γ → α},
  Function.Surjective (f ∘ g) → Function.Injective f → Function.Surjective g

theorem Function.Injective.bijective₂_of_surjective E1 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {f : α → β} {g : γ → α},
  Function.Injective f →
    Function.Injective g → Function.Surjective (f ∘ g) → Function.Bijective f ∧ Function.Bijective g

theorem Function.Surjective.of_comp_iff' E0 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {f : α → β},
  Function.Bijective f → ∀ (g : γ → α), Function.Surjective (f ∘ g) ↔ Function.Surjective g

instance Function.decidableEqPFun E0 #

(p : Prop) → [Decidable p] → (α : p → Type u_4) → [(hp : p) → DecidableEq (α hp)] → DecidableEq ((hp : p) → α hp)

theorem Function.Surjective.forall E1 #

∀ {α : Sort u_1} {β : Sort u_2} {f : α → β},
  Function.Surjective f → ∀ {p : β → Prop}, (∀ (y : β), p y) ↔ ∀ (x : α), p (f x)

theorem Function.Surjective.forall₂ E1 #

∀ {α : Sort u_1} {β : Sort u_2} {f : α → β},
  Function.Surjective f → ∀ {p : β → β → Prop}, (∀ (y₁ y₂ : β), p y₁ y₂) ↔ ∀ (x₁ x₂ : α), p (f x₁) (f x₂)

theorem Function.Surjective.forall₃ E1 #

∀ {α : Sort u_1} {β : Sort u_2} {f : α → β},
  Function.Surjective f →
    ∀ {p : β → β → β → Prop}, (∀ (y₁ y₂ y₃ : β), p y₁ y₂ y₃) ↔ ∀ (x₁ x₂ x₃ : α), p (f x₁) (f x₂) (f x₃)

theorem Function.Surjective.exists E1 #

∀ {α : Sort u_1} {β : Sort u_2} {f : α → β}, Function.Surjective f → ∀ {p : β → Prop}, (∃ y, p y) ↔ ∃ x, p (f x)

theorem Function.Surjective.exists₂ E1 #

∀ {α : Sort u_1} {β : Sort u_2} {f : α → β},
  Function.Surjective f → ∀ {p : β → β → Prop}, (∃ y₁ y₂, p y₁ y₂) ↔ ∃ x₁ x₂, p (f x₁) (f x₂)

theorem Function.Surjective.exists₃ E1 #

∀ {α : Sort u_1} {β : Sort u_2} {f : α → β},
  Function.Surjective f → ∀ {p : β → β → β → Prop}, (∃ y₁ y₂ y₃, p y₁ y₂ y₃) ↔ ∃ x₁ x₂ x₃, p (f x₁) (f x₂) (f x₃)

theorem Function.Surjective.injective_comp_right E1 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {f : α → β}, Function.Surjective f → Function.Injective fun g ↦ g ∘ f

theorem Function.injective_comp_right_iff_surjective E1 #

∀ {α : Sort u_1} {β : Sort u_2} {f : α → β} {γ : Type u_4} [Nontrivial γ],
  (Function.Injective fun g ↦ g ∘ f) ↔ Function.Surjective f

theorem Function.Surjective.right_cancellable E1 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {f : α → β},
  Function.Surjective f → ∀ {g₁ g₂ : β → γ}, g₁ ∘ f = g₂ ∘ f ↔ g₁ = g₂

theorem Function.surjective_of_right_cancellable_Prop E1 #

∀ {α : Sort u_1} {β : Sort u_2} {f : α → β}, (∀ (g₁ g₂ : β → Prop), g₁ ∘ f = g₂ ∘ f → g₁ = g₂) → Function.Surjective f

theorem Function.Injective.existsUnique_iff_exists E1 #

∀ {α : Sort u_1} {β : Sort u_2} {f : α → β}, Function.Injective f → ∀ {b : β}, (∃! a, f a = b) ↔ ∃ a, f a = b

theorem Function.bijective_iff_existsUnique E1 #

∀ {α : Sort u_1} {β : Sort u_2} (f : α → β), Function.Bijective f ↔ ∀ (b : β), ∃! a, f a = b

theorem Function.Bijective.existsUnique E1 #

∀ {α : Sort u_1} {β : Sort u_2} {f : α → β}, Function.Bijective f → ∀ (b : β), ∃! a, f a = b

Shorthand for using projection notation with Function.bijective_iff_existsUnique.

theorem Function.Bijective.existsUnique_iff E0 #

∀ {α : Sort u_1} {β : Sort u_2} {f : α → β}, Function.Bijective f → ∀ {p : β → Prop}, (∃! y, p y) ↔ ∃! x, p (f x)

theorem Function.Bijective.of_comp_iff E0 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} (f : α → β) {g : γ → α},
  Function.Bijective g → (Function.Bijective (f ∘ g) ↔ Function.Bijective f)

theorem Function.Bijective.of_comp_iff' E1 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {f : α → β},
  Function.Bijective f → ∀ (g : γ → α), Function.Bijective (f ∘ g) ↔ Function.Bijective g

theorem Function.Bijective.of_comp_left E1 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {f : α → β} {g : γ → α},
  Function.Bijective (f ∘ g) → Function.Injective f → Function.Bijective g

theorem Function.exists_fixed_point_of_surjective E1 #

∀ {α : Type u_4} {β : Type u_5} (f : α → α → β), Function.Surjective f → ∀ (g : β → β), ∃ x, g x = x

If f : α → α → β is surjective, then every endofunction on β has a fixed point. This is an instance of Lawvere's fixed-point theorem applied to the category of types and functions. It is the diagonal argument underlying cantor_surjective and cantor_injective.

theorem Function.cantor_surjective E3 #

∀ {α : Type u_4} (f : α → Set α), ¬Function.Surjective f

Cantor's diagonal argument implies that there are no surjective functions from α to Set α.

theorem Function.cantor_injective E1 #

∀ {α : Type u_4} (f : Set α → α), ¬Function.Injective f

Cantor's diagonal argument implies that there are no injective functions from Set α to α.

theorem Function.not_surjective_Type E2 #

∀ {α : Type u} (f : α → Type (max u v)), ¬Function.Surjective f

There is no surjection from α : Type u into Type (max u v). This theorem demonstrates why Type : Type would be inconsistent in Lean.

def Function.IsPartialInv E1 #

{α : Type u_4} → {β : Sort u_5} → (α → β) → (β → Option α) → Prop

g is a partial inverse to f (an injective but not necessarily surjective function) if g y = some x implies f x = y, and g y = none implies that y is not in the range of f.

theorem Function.IsPartialInv.eq E1 #

∀ {α : Type u_4} {β : Sort u_5} {f : α → β} {g : β → Option α}, Function.IsPartialInv f g → ∀ (x : α), g (f x) = some x

theorem Function.IsPartialInv.get_eq E0 #

∀ {α : Type u_4} {β : Sort u_5} {f : α → β} {g : β → Option α},
  Function.IsPartialInv f g → ∀ (x : β) (h : (g x).isSome = true), f ((g x).get h) = x

theorem Function.IsPartialInv.surjective_getD E1 #

∀ {α : Type u_4} {β : Sort u_5} {f : α → β} {g : β → Option α},
  Function.IsPartialInv f g → ∀ (x : α), Function.Surjective fun x_1 ↦ (g x_1).getD x

theorem Function.IsPartialInv.injective E1 #

∀ {α : Type u_4} {β : Sort u_5} {f : α → β} {g : β → Option α}, Function.IsPartialInv f g → Function.Injective f

theorem Function.injective_of_isPartialInv_right E1 #

∀ {α : Type u_4} {β : Sort u_5} {f : α → β} {g : β → Option α},
  Function.IsPartialInv f g → ∀ (x y : β), ∀ b ∈ g x, b ∈ g y → x = y

theorem Function.IsPartialInv.comp E1 #

∀ {α : Type u_4} {β : Type u_5} {γ : Sort u_6} {f : α → β} {g : β → Option α} {h : β → γ} {i : γ → Option β},
  Function.IsPartialInv f g → Function.IsPartialInv h i → Function.IsPartialInv (h ∘ f) fun x ↦ (i x).bind g

theorem Function.LeftInverse.eq E1 #

∀ {α : Sort u_1} {β : Sort u_2} {g : β → α} {f : α → β}, Function.LeftInverse g f → ∀ (x : α), g (f x) = x

theorem Function.RightInverse.eq E1 #

∀ {α : Sort u_1} {β : Sort u_2} {g : β → α} {f : α → β}, Function.RightInverse g f → ∀ (x : β), f (g x) = x

theorem Function.LeftInverse.comp_eq_id E1 #

∀ {α : Sort u_1} {β : Sort u_2} {f : α → β} {g : β → α}, Function.LeftInverse f g → f ∘ g = id

theorem Function.leftInverse_iff_comp E1 #

∀ {α : Sort u_1} {β : Sort u_2} {f : α → β} {g : β → α}, Function.LeftInverse f g ↔ f ∘ g = id

theorem Function.RightInverse.comp_eq_id E1 #

∀ {α : Sort u_1} {β : Sort u_2} {f : α → β} {g : β → α}, Function.RightInverse f g → g ∘ f = id

theorem Function.rightInverse_iff_comp E1 #

∀ {α : Sort u_1} {β : Sort u_2} {f : α → β} {g : β → α}, Function.RightInverse f g ↔ g ∘ f = id

theorem Function.LeftInverse.comp E1 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {f : α → β} {g : β → α} {h : β → γ} {i : γ → β},
  Function.LeftInverse f g → Function.LeftInverse h i → Function.LeftInverse (h ∘ f) (g ∘ i)

theorem Function.RightInverse.comp E1 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {f : α → β} {g : β → α} {h : β → γ} {i : γ → β},
  Function.RightInverse f g → Function.RightInverse h i → Function.RightInverse (h ∘ f) (g ∘ i)

theorem Function.LeftInverse.rightInverse E1 #

∀ {α : Sort u_1} {β : Sort u_2} {f : α → β} {g : β → α}, Function.LeftInverse g f → Function.RightInverse f g

theorem Function.RightInverse.leftInverse E1 #

∀ {α : Sort u_1} {β : Sort u_2} {f : α → β} {g : β → α}, Function.RightInverse g f → Function.LeftInverse f g

theorem Function.LeftInverse.surjective E1 #

∀ {α : Sort u_1} {β : Sort u_2} {f : α → β} {g : β → α}, Function.LeftInverse f g → Function.Surjective f

theorem Function.RightInverse.injective E1 #

∀ {α : Sort u_1} {β : Sort u_2} {f : α → β} {g : β → α}, Function.RightInverse f g → Function.Injective f

theorem Function.LeftInverse.rightInverse_of_injective E1 #

∀ {α : Sort u_1} {β : Sort u_2} {f : α → β} {g : β → α},
  Function.LeftInverse f g → Function.Injective f → Function.RightInverse f g

theorem Function.LeftInverse.rightInverse_of_surjective E1 #

∀ {α : Sort u_1} {β : Sort u_2} {f : α → β} {g : β → α},
  Function.LeftInverse f g → Function.Surjective g → Function.RightInverse f g

theorem Function.RightInverse.leftInverse_of_surjective E1 #

∀ {α : Sort u_1} {β : Sort u_2} {f : α → β} {g : β → α},
  Function.RightInverse f g → Function.Surjective f → Function.LeftInverse f g

theorem Function.RightInverse.leftInverse_of_injective E1 #

∀ {α : Sort u_1} {β : Sort u_2} {f : α → β} {g : β → α},
  Function.RightInverse f g → Function.Injective g → Function.LeftInverse f g

def Function.partialInv E1 #

{α : Type u_4} → {β : Sort u_5} → (α → β) → β → Option α

We can use choice to construct explicitly a partial inverse for a given injective function f.

theorem Function.Injective.isPartialInv E1 #

∀ {α : Type u_4} {β : Sort u_5} {f : α → β}, Function.Injective f → Function.IsPartialInv f (Function.partialInv f)

theorem Function.partialInv_left E1 #

∀ {α : Type u_4} {β : Sort u_5} {f : α → β}, Function.Injective f → ∀ (x : α), Function.partialInv f (f x) = some x

def Function.invFun E1 #

{α : Sort u} → {β : Sort u_3} → [Nonempty α] → (α → β) → β → α

The inverse of a function (which is a left inverse if f is injective and a right inverse if f is surjective).

theorem Function.invFun_eq E0 #

∀ {α : Sort u_1} {β : Sort u_2} [inst : Nonempty α] {f : α → β} {b : β}, (∃ a, f a = b) → f (Function.invFun f b) = b

theorem Function.apply_invFun_apply E0 #

∀ {α : Type u_3} {β : Type u_4} {f : α → β} {a : α}, f (Function.invFun f (f a)) = f a

theorem Function.invFun_neg E1 #

∀ {α : Sort u_1} {β : Sort u_2} [inst : Nonempty α] {f : α → β} {b : β},
  (¬∃ a, f a = b) → Function.invFun f b = Classical.choice inst

theorem Function.invFun_eq_of_injective_of_rightInverse E1 #

∀ {α : Sort u_1} {β : Sort u_2} [inst : Nonempty α] {f : α → β} {g : β → α},
  Function.Injective f → Function.RightInverse g f → Function.invFun f = g

theorem Function.rightInverse_invFun E1 #

∀ {α : Sort u_1} {β : Sort u_2} [inst : Nonempty α] {f : α → β},
  Function.Surjective f → Function.RightInverse (Function.invFun f) f

theorem Function.leftInverse_invFun E1 #

∀ {α : Sort u_1} {β : Sort u_2} [inst : Nonempty α] {f : α → β},
  Function.Injective f → Function.LeftInverse (Function.invFun f) f

theorem Function.invFun_surjective E1 #

∀ {α : Sort u_1} {β : Sort u_2} [inst : Nonempty α] {f : α → β},
  Function.Injective f → Function.Surjective (Function.invFun f)

theorem Function.invFun_comp E1 #

∀ {α : Sort u_1} {β : Sort u_2} [inst : Nonempty α] {f : α → β}, Function.Injective f → Function.invFun f ∘ f = id

theorem Function.Injective.hasLeftInverse E1 #

∀ {α : Sort u_1} {β : Sort u_2} [Nonempty α] {f : α → β}, Function.Injective f → Function.HasLeftInverse f

theorem Function.injective_iff_hasLeftInverse E1 #

∀ {α : Sort u_1} {β : Sort u_2} [Nonempty α] {f : α → β}, Function.Injective f ↔ Function.HasLeftInverse f

def Function.surjInv E1 #

{α : Sort u} → {β : Sort v} → {f : α → β} → Function.Surjective f → β → α

The inverse of a surjective function. (Unlike invFun, this does not require α to be inhabited.)

theorem Function.surjInv_eq E0 #

∀ {α : Sort u} {β : Sort v} {f : α → β} (h : Function.Surjective f) (b : β), f (Function.surjInv h b) = b

theorem Function.comp_surjInv E0 #

∀ {α : Sort u} {β : Sort v} {f : α → β} (hf : Function.Surjective f), f ∘ Function.surjInv hf = id

theorem Function.rightInverse_surjInv E1 #

∀ {α : Sort u} {β : Sort v} {f : α → β} (hf : Function.Surjective f), Function.RightInverse (Function.surjInv hf) f

theorem Function.leftInverse_surjInv E1 #

∀ {α : Sort u} {β : Sort v} {f : α → β} (hf : Function.Bijective f), Function.LeftInverse (Function.surjInv ⋯) f

theorem Function.Surjective.hasRightInverse E1 #

∀ {α : Sort u} {β : Sort v} {f : α → β}, Function.Surjective f → Function.HasRightInverse f

theorem Function.surjective_iff_hasRightInverse E1 #

∀ {α : Sort u} {β : Sort v} {f : α → β}, Function.Surjective f ↔ Function.HasRightInverse f

theorem Function.bijective_iff_has_inverse E1 #

∀ {α : Sort u} {β : Sort v} {f : α → β},
  Function.Bijective f ↔ ∃ g, Function.LeftInverse g f ∧ Function.RightInverse g f

theorem Function.injective_surjInv E1 #

∀ {α : Sort u} {β : Sort v} {f : α → β} (h : Function.Surjective f), Function.Injective (Function.surjInv h)

theorem Function.surjective_to_subsingleton E1 #

∀ {α : Sort u} {β : Sort v} [na : Nonempty α] [Subsingleton β] (f : α → β), Function.Surjective f

theorem Function.bijective_of_subsingleton' E1 #

∀ {α : Sort u} {β : Sort v} [Nonempty α] [Subsingleton α] [Subsingleton β] (f : α → β), Function.Bijective f

theorem Function.Surjective.piMap E1 #

∀ {ι : Sort u_1} {α : ι → Sort u_2} {β : ι → Sort u_3} {f : (i : ι) → α i → β i},
  (∀ (i : ι), Function.Surjective (f i)) → Function.Surjective (Pi.map f)

theorem Function.Surjective.comp_left E1 #

∀ {α : Sort u} {β : Sort v} {γ : Sort w} {g : β → γ}, Function.Surjective g → Function.Surjective fun x ↦ g ∘ x

Composition by a surjective function on the left is itself surjective.

theorem Function.surjective_comp_left_iff E0 #

∀ {α : Sort u} {β : Sort v} {γ : Sort w} [Nonempty α] {g : β → γ},
  (Function.Surjective fun x ↦ g ∘ x) ↔ Function.Surjective g

theorem Function.Bijective.piMap E1 #

∀ {ι : Sort u_1} {α : ι → Sort u_2} {β : ι → Sort u_3} {f : (i : ι) → α i → β i},
  (∀ (i : ι), Function.Bijective (f i)) → Function.Bijective (Pi.map f)

theorem Function.Bijective.comp_left E1 #

∀ {α : Sort u} {β : Sort v} {γ : Sort w} {g : β → γ}, Function.Bijective g → Function.Bijective fun x ↦ g ∘ x

Composition by a bijective function on the left is itself bijective.

def Function.update E1 #

{α : Sort u} → {β : α → Sort v} → [DecidableEq α] → ((a : α) → β a) → (a' : α) → β a' → (a : α) → β a

Replacing the value of a function at a given point by a given value.

theorem Function.update_self E0 #

∀ {α : Sort u} {β : α → Sort v} [inst : DecidableEq α] (a : α) (v : β a) (f : (a : α) → β a),
  Function.update f a v a = v

theorem Function.update_of_ne E0 #

∀ {α : Sort u} {β : α → Sort v} [inst : DecidableEq α] {a a' : α},
  a ≠ a' → ∀ (v : β a') (f : (a : α) → β a), Function.update f a' v a = f a

theorem Function.update_congr E1 #

∀ {α : Sort u} [inst : DecidableEq α] {β : Sort u_1} {f₁ f₂ : α → β},
  f₁ = f₂ →
    ∀ {a'₁ a'₂ : α},
      a'₁ = a'₂ →
        ∀ {v₁ v₂ : β}, v₁ = v₂ → ∀ {a₁ a₂ : α}, a₁ = a₂ → Function.update f₁ a'₁ v₁ a₁ = Function.update f₂ a'₂ v₂ a₂

A congruence lemma for Function.update, specialized for the non-dependent case. Without this, simp can't rewrite in the fourth argument a because the result type depends on a. See also https://github.com/leanprover/lean4/issues/12478.

theorem Function.update_apply E0 #

∀ {α : Sort u} [inst : DecidableEq α] {β : Sort u_1} (f : α → β) (a' : α) (b : β) (a : α),
  Function.update f a' b a = if a = a' then b else f a

On non-dependent functions, Function.update can be expressed as an ite

theorem Function.update_eq_const_of_subsingleton E1 #

∀ {α : Sort u} {α' : Sort w} [inst : DecidableEq α] [Subsingleton α] (a : α) (v : α') (f : α → α'),
  Function.update f a v = Function.const α v

theorem Function.surjective_eval E1 #

∀ {α : Sort u} {β : α → Sort v} [h : ∀ (a : α), Nonempty (β a)] (a : α), Function.Surjective (Function.eval a)

theorem Function.update_injective E1 #

∀ {α : Sort u} {β : α → Sort v} [inst : DecidableEq α] (f : (a : α) → β a) (a' : α),
  Function.Injective (Function.update f a')

theorem Function.forall_update_iff E0 #

∀ {α : Sort u} {β : α → Sort v} [inst : DecidableEq α] (f : (a : α) → β a) {a : α} {b : β a} (p : (a : α) → β a → Prop),
  (∀ (x : α), p x (Function.update f a b x)) ↔ p a b ∧ ∀ (x : α), x ≠ a → p x (f x)

theorem Function.exists_update_iff E0 #

∀ {α : Sort u} {β : α → Sort v} [inst : DecidableEq α] (f : (a : α) → β a) {a : α} {b : β a} (p : (a : α) → β a → Prop),
  (∃ x, p x (Function.update f a b x)) ↔ p a b ∨ ∃ x, x ≠ a ∧ p x (f x)

theorem Function.update_eq_iff E0 #

∀ {α : Sort u} {β : α → Sort v} [inst : DecidableEq α] {a : α} {b : β a} {f g : (a : α) → β a},
  Function.update f a b = g ↔ b = g a ∧ ∀ (x : α), x ≠ a → f x = g x

theorem Function.update_eq_self_iff E0 #

∀ {α : Sort u} {β : α → Sort v} [inst : DecidableEq α] {f : (a : α) → β a} {a : α} {b : β a},
  Function.update f a b = f ↔ b = f a

theorem Function.ne_update_self_iff E0 #

∀ {α : Sort u} {β : α → Sort v} [inst : DecidableEq α] {f : (a : α) → β a} {a : α} {b : β a},
  f ≠ Function.update f a b ↔ f a ≠ b

theorem Function.update_ne_self_iff E0 #

∀ {α : Sort u} {β : α → Sort v} [inst : DecidableEq α] {f : (a : α) → β a} {a : α} {b : β a},
  Function.update f a b ≠ f ↔ b ≠ f a

theorem Function.update_eq_self E0 #

∀ {α : Sort u} {β : α → Sort v} [inst : DecidableEq α] (a : α) (f : (a : α) → β a), Function.update f a (f a) = f

theorem Function.update_comp_eq_of_forall_ne' E1 #

∀ {α : Sort u} {β : α → Sort v} [inst : DecidableEq α] {α' : Sort u_1} (g : (a : α) → β a) {f : α' → α} {i : α}
  (a : β i), (∀ (x : α'), f x ≠ i) → (fun j ↦ Function.update g i a (f j)) = fun j ↦ g (f j)

theorem Function.update_comp_eq_of_forall_ne E1 #

∀ {α' : Sort w} [inst : DecidableEq α'] {α : Sort u_1} {β : Sort u_2} (g : α' → β) {f : α → α'} {i : α'} (a : β),
  (∀ (x : α), f x ≠ i) → Function.update g i a ∘ f = g ∘ f

Non-dependent version of Function.update_comp_eq_of_forall_ne'

theorem Function.update_comp_eq_of_injective' E1 #

∀ {α : Sort u} {β : α → Sort v} {α' : Sort w} [inst : DecidableEq α] [inst_1 : DecidableEq α'] (g : (a : α) → β a)
  {f : α' → α},
  Function.Injective f →
    ∀ (i : α') (a : β (f i)), (fun j ↦ Function.update g (f i) a (f j)) = Function.update (fun i ↦ g (f i)) i a

theorem Function.update_apply_of_injective E1 #

∀ {α : Sort u} {β : α → Sort v} {α' : Sort w} [inst : DecidableEq α] [inst_1 : DecidableEq α'] (g : (a : α) → β a)
  {f : α' → α},
  Function.Injective f →
    ∀ (i : α') (a : β (f i)) (j : α'), Function.update g (f i) a (f j) = Function.update (fun i ↦ g (f i)) i a j

theorem Function.update_comp_eq_of_injective E1 #

∀ {α : Sort u} {α' : Sort w} [inst : DecidableEq α] [inst_1 : DecidableEq α'] {β : Sort u_1} (g : α' → β) {f : α → α'},
  Function.Injective f → ∀ (i : α) (a : β), Function.update g (f i) a ∘ f = Function.update (g ∘ f) i a

Non-dependent version of Function.update_comp_eq_of_injective'

theorem Function.rec_update E1 #

∀ {ι : Sort u_1} {κ : Sort u_2} {α : κ → Sort u_3} [inst : DecidableEq ι] [inst_1 : DecidableEq κ] {ctor : ι → κ}
  (recursor : ((i : ι) → α (ctor i)) → (i : κ) → α i),
  (∀ (f : (i : ι) → α (ctor i)) (i : ι), recursor f (ctor i) = f i) →
    (∀ (f₁ f₂ : (i : ι) → α (ctor i)) (k : κ), (∀ (i : ι), ctor i ≠ k) → recursor f₁ k = recursor f₂ k) →
      ∀ (f : (i : ι) → α (ctor i)) (i : ι) (x : α (ctor i)),
        recursor (Function.update f i x) = Function.update (recursor f) (ctor i) x

Recursors can be pushed inside Function.update.

The ctor argument should be a one-argument constructor like Sum.inl, and recursor should be an inductive recursor partially applied in all but that constructor, such as (Sum.rec · g).

In future, we should build some automation to generate applications like Option.rec_update for all inductive types.

theorem Option.rec_update E0 #

∀ {α : Type u_1} {β : Option α → Sort u_2} [inst : DecidableEq α] (f : β none) (g : (a : α) → β (some a)) (a : α)
  (x : β (some a)),
  (fun t ↦ Option.rec f (Function.update g a x) t) = Function.update (fun t ↦ Option.rec f g t) (some a) x

theorem Function.apply_update E1 #

∀ {ι : Sort u_1} [inst : DecidableEq ι] {α : ι → Sort u_2} {β : ι → Sort u_3} (f : (i : ι) → α i → β i)
  (g : (i : ι) → α i) (i : ι) (v : α i) (j : ι),
  f j (Function.update g i v j) = Function.update (fun k ↦ f k (g k)) i (f i v) j

theorem Function.apply_update₂ E1 #

∀ {ι : Sort u_1} [inst : DecidableEq ι] {α : ι → Sort u_2} {β : ι → Sort u_3} {γ : ι → Sort u_4}
  (f : (i : ι) → α i → β i → γ i) (g : (i : ι) → α i) (h : (i : ι) → β i) (i : ι) (v : α i) (w : β i) (j : ι),
  f j (Function.update g i v j) (Function.update h i w j) = Function.update (fun k ↦ f k (g k) (h k)) i (f i v w) j

theorem Function.pred_update E1 #

∀ {α : Sort u} {β : α → Sort v} [inst : DecidableEq α] (P : ⦃a : α⦄ → β a → Prop) (f : (a : α) → β a) (a' : α)
  (v : β a') (a : α), P (Function.update f a' v a) ↔ a = a' ∧ P v ∨ a ≠ a' ∧ P (f a)

theorem Function.comp_update E1 #

∀ {α : Sort u} [inst : DecidableEq α] {α' : Sort u_1} {β : Sort u_2} (f : α' → β) (g : α → α') (i : α) (v : α'),
  f ∘ Function.update g i v = Function.update (f ∘ g) i (f v)

theorem Function.update_comm E1 #

∀ {α : Sort u_2} [inst : DecidableEq α] {β : α → Sort u_1} {a b : α},
  a ≠ b →
    ∀ (v : β a) (w : β b) (f : (a : α) → β a),
      Function.update (Function.update f a v) b w = Function.update (Function.update f b w) a v

theorem Function.update_idem E0 #

∀ {α : Sort u_2} [inst : DecidableEq α] {β : α → Sort u_1} {a : α} (v w : β a) (f : (a : α) → β a),
  Function.update (Function.update f a v) a w = Function.update f a w

theorem Function.update_eq_update_iff E0 #

∀ {α : Sort u} [inst : DecidableEq α] {ι : Sort u_1} {f : α → ι} {i j : α} {a b : ι},
  Function.update f i a = Function.update f j b ↔ i = j ∧ a = b ∨ a = f i ∧ b = f j

theorem Function.update_left_injective E1 #

∀ {α : Sort u} [inst : DecidableEq α] {ι : Sort u_1} {f : α → ι} {a : ι},
  (∀ (i : α), f i ≠ a) → Function.Injective fun i ↦ Function.update f i a

theorem Function.update_left_inj E1 #

∀ {α : Sort u} [inst : DecidableEq α] {ι : Sort u_1} {f : α → ι} {i j : α} {a : ι},
  (∀ (i : α), f i ≠ a) → (Function.update f i a = Function.update f j a ↔ i = j)

theorem Pi.map_update E0 #

∀ {ι : Sort u_1} [inst : DecidableEq ι] {α : ι → Sort u_2} {β : ι → Sort u_3} {f : (i : ι) → α i → β i}
  (g : (i : ι) → α i) (i : ι) (a : α i), Pi.map f (Function.update g i a) = Function.update (Pi.map f g) i (f i a)

theorem Pi.map_injective E0 #

∀ {ι : Sort u_1} {α : ι → Sort u_2} {β : ι → Sort u_3} [∀ (i : ι), Nonempty (α i)] {f : (i : ι) → α i → β i},
  Function.Injective (Pi.map f) ↔ ∀ (i : ι), Function.Injective (f i)

def Function.extend E1 #

{α : Sort u_1} → {β : Sort u_2} → {γ : Sort u_3} → (α → β) → (α → γ) → (β → γ) → β → γ

Extension of a function g : α → γ along a function f : α → β.

For every a : α, f a is sent to g a. f might not be surjective, so we use an auxiliary function j : β → γ by sending b : β not in the range of f to j b. If you do not care about the behavior outside the range, j can be used as a junk value by setting it to be 0 or Classical.arbitrary (assuming γ is nonempty).

This definition is mathematically meaningful only when f a₁ = f a₂ → g a₁ = g a₂ (spelled g.FactorsThrough f). In particular this holds if f is injective.

A typical use case is extending a function from a subtype to the entire type. If you wish to extend g : {b : β // p b} → γ to a function β → γ, you should use Function.extend Subtype.val g j.

def Function.FactorsThrough E1 #

{α : Sort u_1} → {β : Sort u_2} → {γ : Sort u_3} → (α → γ) → (α → β) → Prop

g factors through f : f a = f b → g a = g b

theorem Function.extend_def E0 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} (f : α → β) (g : α → γ) (e' : β → γ) (b : β)
  [inst : Decidable (∃ a, f a = b)],
  Function.extend f g e' b = if h : ∃ a, f a = b then g (Classical.choose h) else e' b

theorem Function.Injective.factorsThrough E1 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {f : α → β},
  Function.Injective f → ∀ (g : α → γ), Function.FactorsThrough g f

theorem Function.FactorsThrough.extend_apply E0 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {f : α → β} {g : α → γ},
  Function.FactorsThrough g f → ∀ (e' : β → γ) (a : α), Function.extend f g e' (f a) = g a

theorem Function.Injective.extend_apply E0 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {f : α → β},
  Function.Injective f → ∀ (g : α → γ) (e' : β → γ) (a : α), Function.extend f g e' (f a) = g a

theorem Function.extend_apply' E0 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {f : α → β} (g : α → γ) (e' : β → γ) (b : β),
  (¬∃ a, f a = b) → Function.extend f g e' b = e' b

theorem Function.extend_id E0 #

∀ {α : Sort u_1} {γ : Sort u_3} (g e' : α → γ), Function.extend id g e' = g

theorem Function.Injective.extend_comp E1 #

∀ {γ : Sort u_3} {α₁ : Sort u_4} {α₂ : Sort u_5} {α₃ : Sort u_6} {f₁₂ : α₁ → α₂},
  Function.Injective f₁₂ →
    ∀ {f₂₃ : α₂ → α₃},
      Function.Injective f₂₃ →
        ∀ (g : α₁ → γ) (e' : α₃ → γ),
          Function.extend (f₂₃ ∘ f₁₂) g e' = Function.extend f₂₃ (Function.extend f₁₂ g (e' ∘ f₂₃)) e'

theorem Function.factorsThrough_iff E0 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {f : α → β} (g : α → γ) [Nonempty γ],
  Function.FactorsThrough g f ↔ ∃ e, g = e ∘ f

theorem Function.apply_extend E1 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {δ : Sort u_4} {g : α → γ} (F : γ → δ) (f : α → β) (e' : β → γ) (b : β),
  F (Function.extend f g e' b) = Function.extend f (F ∘ g) (F ∘ e') b

theorem Function.extend_injective E1 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {f : α → β},
  Function.Injective f → ∀ (e' : β → γ), Function.Injective fun g ↦ Function.extend f g e'

theorem Function.FactorsThrough.extend_comp E1 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {f : α → β} {g : α → γ} (e' : β → γ),
  Function.FactorsThrough g f → Function.extend f g e' ∘ f = g

theorem Function.extend_const E0 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} (f : α → β) (c : γ),
  (Function.extend f (fun x ↦ c) fun x ↦ c) = fun x ↦ c

theorem Function.extend_comp E0 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {f : α → β},
  Function.Injective f → ∀ (g : α → γ) (e' : β → γ), Function.extend f g e' ∘ f = g

theorem Function.Injective.extend_update E1 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {f : α → β} [inst : DecidableEq α] [inst_1 : DecidableEq β],
  Function.Injective f →
    ∀ (g : α → γ) (e : β → γ) (i : α) (a : γ),
      Function.extend f (Function.update g i a) e = Function.update (Function.extend f g e) (f i) a

theorem Function.Injective.surjective_comp_right' E1 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {f : α → β},
  Function.Injective f → ∀ (g₀ : β → γ), Function.Surjective fun g ↦ g ∘ f

theorem Function.Injective.surjective_comp_right E1 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {f : α → β} [Nonempty γ],
  Function.Injective f → Function.Surjective fun g ↦ g ∘ f

theorem Function.surjective_comp_right_iff_injective E1 #

∀ {α : Sort u_1} {β : Sort u_2} {f : α → β} {γ : Type u_4} [Nontrivial γ],
  (Function.Surjective fun g ↦ g ∘ f) ↔ Function.Injective f

theorem Function.Bijective.comp_right E1 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {f : α → β}, Function.Bijective f → Function.Bijective fun g ↦ g ∘ f

theorem Function.FactorsThrough.rfl E1 #

∀ {α : Sort u_1} {β : Sort u_2} {f : α → β}, Function.FactorsThrough f f

theorem Function.FactorsThrough.comp_left E1 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {δ : Sort u_4} {f : α → β} {g : α → γ},
  Function.FactorsThrough g f → ∀ (g' : γ → δ), Function.FactorsThrough (g' ∘ g) f

theorem Function.FactorsThrough.comp_right E1 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {δ : Sort u_4} {f : α → β} {g : α → γ},
  Function.FactorsThrough g f → ∀ (g' : δ → α), Function.FactorsThrough (g ∘ g') (f ∘ g')

theorem Function.uncurry_def E0 #

∀ {α : Type u_1} {β : Type u_2} {γ : Sort u_3} (f : α → β → γ), Function.uncurry f = fun p ↦ f p.1 p.2

theorem Function.uncurry_injective E1 #

∀ {α : Type u_1} {β : Type u_2} {γ : Sort u_3}, Function.Injective Function.uncurry

theorem Function.curry_injective E1 #

∀ {α : Type u_1} {β : Type u_2} {γ : Sort u_3}, Function.Injective Function.curry

theorem Function.uncurry_flip E1 #

∀ {α : Type u_1} {β : Type u_2} {γ : Sort u_3} (f : α → β → γ),
  Function.uncurry (flip f) = Function.uncurry f ∘ Prod.swap

theorem Function.flip_curry E1 #

∀ {α : Type u_1} {β : Type u_2} {γ : Sort u_3} (f : α × β → γ), flip (Function.curry f) = Function.curry (f ∘ Prod.swap)

theorem Function.curry_update E1 #

∀ {α : Type u_1} {α' : Type u_2} {β : Type u_3} [inst : DecidableEq α] [inst_1 : DecidableEq α'] (f : α × α' → β)
  (aa' : α × α') (b : β),
  Function.curry (Function.update f aa' b) =
    Function.update (Function.curry f) aa'.1 (Function.update (Function.curry f aa'.1) aa'.2 b)

theorem Function.uncurry_update_update E1 #

∀ {α : Type u_1} {α' : Type u_2} {β : Type u_3} [inst : DecidableEq α] [inst_1 : DecidableEq α'] (f : α → α' → β)
  (a : α) (a' : α') (b : β),
  Function.uncurry (Function.update f a (Function.update (f a) a' b)) = Function.update (Function.uncurry f) (a, a') b

class Function.HasUncurry E1 #

Type u_5 → outParam (Type u_6) → outParam (Type u_7) → Type (max (max u_5 u_6) u_7)

Records a way to turn an element of α into a function from β to γ. The most generic use is to recursively uncurry. For instance f : α → β → γ → δ will be turned into ↿f : α × β × γ → δ. One can also add instances for bundled maps.

ctor Function.HasUncurry.mk E0 #

{α : Type u_5} → {β : outParam (Type u_6)} → {γ : outParam (Type u_7)} → (α → β → γ) → Function.HasUncurry α β γ

abbrev Function.HasUncurry.uncurry E1 #

{α : Type u_5} → {β : outParam (Type u_6)} → {γ : outParam (Type u_7)} → [self : Function.HasUncurry α β γ] → α → β → γ

Uncurrying operator. The most generic use is to recursively uncurry. For instance f : α → β → γ → δ will be turned into ↿f : α × β × γ → δ. One can also add instances for bundled maps.

def Function.«term↿_» E1 #

Lean.ParserDescr

Uncurrying operator. The most generic use is to recursively uncurry. For instance f : α → β → γ → δ will be turned into ↿f : α × β × γ → δ. One can also add instances for bundled maps.

instance Function.hasUncurryBase E0 #

{α : Type u_1} → {β : Type u_2} → Function.HasUncurry (α → β) α β

instance Function.hasUncurryInduction E0 #

{α : Type u_1} →
  {β : Type u_2} → {γ : Type u_3} → {δ : Type u_4} → [Function.HasUncurry β γ δ] → Function.HasUncurry (α → β) (α × γ) δ

def Function.Involutive E1 #

{α : Sort u_1} → (α → α) → Prop

A function is involutive, if f ∘ f = id.

theorem Bool.involutive_not E1 #

Function.Involutive not

theorem Function.Involutive.comp_self E0 #

∀ {α : Sort u} {f : α → α}, Function.Involutive f → f ∘ f = id

theorem Function.Involutive.leftInverse E1 #

∀ {α : Sort u} {f : α → α}, Function.Involutive f → Function.LeftInverse f f

theorem Function.Involutive.leftInverse_iff E0 #

∀ {α : Sort u} {f : α → α}, Function.Involutive f → ∀ {g : α → α}, Function.LeftInverse g f ↔ g = f

theorem Function.Involutive.rightInverse E1 #

∀ {α : Sort u} {f : α → α}, Function.Involutive f → Function.RightInverse f f

theorem Function.Involutive.injective E1 #

∀ {α : Sort u} {f : α → α}, Function.Involutive f → Function.Injective f

theorem Function.Involutive.surjective E1 #

∀ {α : Sort u} {f : α → α}, Function.Involutive f → Function.Surjective f

theorem Function.Involutive.bijective E1 #

∀ {α : Sort u} {f : α → α}, Function.Involutive f → Function.Bijective f

theorem Function.Involutive.ite_not E1 #

∀ {α : Sort u} {f : α → α},
  Function.Involutive f → ∀ (P : Prop) [inst : Decidable P] (x : α), f (if P then x else f x) = if ¬P then x else f x

Involuting an ite of an involuted value x : α negates the Prop condition in the ite.

theorem Function.not_involutive E1 #

Function.Involutive Not

theorem Function.not_injective E1 #

Function.Injective Not

theorem Function.not_surjective E1 #

Function.Surjective Not

theorem Function.not_bijective E1 #

Function.Bijective Not

theorem Function.symm_apply_eq_iff E0 #

∀ {α : Sort u_1} {f : α → α}, (Std.Symm fun x1 x2 ↦ f x1 = x2) ↔ Function.Involutive f

def Function.Injective2 E1 #

{α : Sort u_1} → {β : Sort u_2} → {γ : Sort u_3} → (α → β → γ) → Prop

The property of a binary function f : α → β → γ being injective. Mathematically this should be thought of as the corresponding function α × β → γ being injective.

theorem Function.Injective2.left E1 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {f : α → β → γ},
  Function.Injective2 f → ∀ (b : β), Function.Injective fun a ↦ f a b

A binary injective function is injective when only the left argument varies.

theorem Function.Injective2.right E1 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {f : α → β → γ},
  Function.Injective2 f → ∀ (a : α), Function.Injective (f a)

A binary injective function is injective when only the right argument varies.

theorem Function.Injective2.uncurry E1 #

∀ {α : Type u_4} {β : Type u_5} {γ : Type u_6} {f : α → β → γ},
  Function.Injective2 f → Function.Injective (Function.uncurry f)

theorem Function.Injective2.left' E1 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {f : α → β → γ},
  Function.Injective2 f → ∀ [Nonempty β], Function.Injective f

As a map from the left argument to a unary function, f is injective.

theorem Function.Injective2.right' E1 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : Sort u_3} {f : α → β → γ},
  Function.Injective2 f → ∀ [Nonempty α], Function.Injective fun b a ↦ f a b

As a map from the right argument to a unary function, f is injective.

def Function.sometimes E1 #

{α : Sort u_1} → {β : Sort u_2} → [Nonempty β] → (α → β) → β

sometimes f evaluates to some value of f, if it exists. This function is especially interesting in the case where α is a proposition, in which case f is necessarily a constant function, so that sometimes f = f a for all a.

theorem Function.sometimes_eq E0 #

∀ {p : Prop} {α : Sort u_1} [inst : Nonempty α] (f : p → α) (a : p), Function.sometimes f = f a

theorem Function.sometimes_spec E1 #

∀ {p : Prop} {α : Sort u_1} [inst : Nonempty α] (P : α → Prop) (f : p → α) (a : p), P (f a) → P (Function.sometimes f)

theorem forall_existsUnique_iff E0 #

∀ {α : Sort u_1} {β : Sort u_2} {r : α → β → Prop}, (∀ (a : α), ∃! b, r a b) ↔ ∃ f, ∀ {a : α} {b : β}, r a b ↔ f a = b

A relation r : α → β → Prop is "function-like" (for each a there exists a unique b such that r a b) if and only if it is (f · = ·) for some function f.

theorem forall_existsUnique_iff' E1 #

∀ {α : Sort u_1} {β : Sort u_2} {r : α → β → Prop}, (∀ (a : α), ∃! b, r a b) ↔ ∃ f, r = fun x1 x2 ↦ f x1 = x2

A relation r : α → β → Prop is "function-like" (for each a there exists a unique b such that r a b) if and only if it is (f · = ·) for some function f.

theorem Std.Symm.forall_existsUnique_iff' E1 #

∀ {α : Sort u_1} {r : α → α → Prop} [Std.Symm r],
  (∀ (a : α), ∃! b, r a b) ↔ ∃ f, Function.Involutive f ∧ r = fun x1 x2 ↦ f x1 = x2

A symmetric relation r : α → α → Prop is "function-like" (for each a there exists a unique b such that r a b) if and only if it is (f · = ·) for some involutive function f.

theorem Std.Symm.forall_existsUnique_iff E0 #

∀ {α : Sort u_1} {r : α → α → Prop} [Std.Symm r],
  (∀ (a : α), ∃! b, r a b) ↔ ∃ f, Function.Involutive f ∧ ∀ {a b : α}, r a b ↔ f a = b

A symmetric relation r : α → α → Prop is "function-like" (for each a there exists a unique b such that r a b) if and only if it is (f · = ·) for some involutive function f.

def Set.piecewise E1 #

{α : Type u} →
  {β : α → Sort v} → (s : Set α) → ((i : α) → β i) → ((i : α) → β i) → [(j : α) → Decidable (j ∈ s)] → (i : α) → β i

s.piecewise f g is the function equal to f on the set s, and to g on its complement.

theorem cast_bijective E1 #

∀ {α β : Sort u_3} (h : α = β), Function.Bijective (cast h)

theorem cast_inj E0 #

∀ {α β : Type u} (h : α = β) {x y : α}, cast h x = cast h y ↔ x = y

theorem Function.LeftInverse.cast_eq E0 #

∀ {α : Sort u_1} {β : Sort u_2} {γ : β → Sort v} {f : α → β} {g : β → α} (h : Function.LeftInverse g f)
  (C : (a : α) → γ (f a)) (a : α), cast ⋯ (C (g (f a))) = C a

def Set.SeparatesPoints E1 #

{α : Type u_3} → {β : Type u_4} → Set (α → β) → Prop

A set of functions "separates points" if for each pair of distinct points there is a function taking different values on them.

theorem Set.separatesPoints_mono E1 #

∀ {α : Type u_3} {β : Type u_4} {A B : Set (α → β)}, A ⊆ B → A.SeparatesPoints → B.SeparatesPoints

theorem InvImage.equivalence E1 #

∀ {α : Sort u} {β : Sort v} (r : β → β → Prop) (f : α → β), Equivalence r → Equivalence (InvImage r f)

instance instDecidableUncurryOfFstSnd_mathlib E0 #

{α : Type u_3} →
  {β : Type u_4} → {r : α → β → Prop} → {x : α × β} → [Decidable (r x.1 x.2)] → Decidable (Function.uncurry r x)

instance instDecidableCurryOfMk_mathlib E0 #

{α : Type u_3} →
  {β : Type u_4} → {r : α × β → Prop} → {a : α} → {b : β} → [Decidable (r (a, b))] → Decidable (Function.curry r a b)

theorem Pi.map_id E0 #

∀ {ι : Type u_3} {α : ι → Type u_4}, (Pi.map fun i ↦ id) = id

theorem Pi.map_id' E0 #

∀ {ι : Type u_3} {α : ι → Type u_4}, (Pi.map fun i a ↦ a) = fun x ↦ x

theorem Pi.map_comp_map E0 #

∀ {ι : Type u_3} {α : ι → Type u_4} {β : ι → Type u_5} {γ : ι → Type u_6} (f : (i : ι) → α i → β i)
  (g : (i : ι) → β i → γ i), Pi.map g ∘ Pi.map f = Pi.map fun i ↦ g i ∘ f i

Deprecated aliases

NameNew nameSince
Function.symmetric_apply_eq_iffFunction.symm_apply_eq_iff2026-06-10
Symmetric.forall_existsUnique_iffStd.Symm.forall_existsUnique_iff2026-06-10
Symmetric.forall_existsUnique_iff'Std.Symm.forall_existsUnique_iff'2026-06-10