mathlib documentation

logic.​function.​basic

logic.​function.​basic

Miscellaneous function constructions and lemmas

def function.​eval {α : Sort u} {β : α → Sort u_1} (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.

Equations
@[simp]
theorem function.​eval_apply {α : Sort u} {β : α → Sort u_1} (x : α) (f : Π (x : α), β x) :

@[ext]
theorem function.​hfunext {α α' : Sort u} {β : α → Sort v} {β' : α' → Sort v} {f : Π (a : α), β a} {f' : Π (a : α'), β' a} :
α = α'(∀ (a : α) (a' : α'), a == a'f a == f' a')f == f'

theorem function.​funext_iff {α : Sort u} {β : α → Sort u_1} {f₁ f₂ : Π (x : α), β x} :
f₁ = f₂ ∀ (a : α), f₁ a = f₂ a

theorem function.​comp_apply {α : Sort u} {β : Sort v} {φ : Sort w} (f : β → φ) (g : α → β) (a : α) :
(f g) a = f (g a)

@[simp]
theorem function.​injective.​eq_iff {α : Sort u} {β : Sort v} {f : α → β} (I : function.injective f) {a b : α} :
f a = f b a = b

theorem function.​injective.​eq_iff' {α : Sort u} {β : Sort v} {f : α → β} (I : function.injective f) {a b : α} {c : β} :
f b = c(f a = c a = b)

theorem function.​injective.​ne {α : Sort u} {β : Sort v} {f : α → β} (hf : function.injective f) {a₁ a₂ : α} :
a₁ a₂f a₁ f a₂

theorem function.​injective.​ne_iff {α : Sort u} {β : Sort v} {f : α → β} (hf : function.injective f) {x y : α} :
f x f y x y

theorem function.​injective.​ne_iff' {α : Sort u} {β : Sort v} {f : α → β} (hf : function.injective f) {x y : α} {z : β} :
f y = z(f x z x y)

def function.​injective.​decidable_eq {α : Sort u} {β : Sort v} {f : α → β} [decidable_eq β] :

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

Equations
theorem function.​injective.​of_comp {α : Sort u} {β : Sort v} {f : α → β} {γ : Sort w} {g : γ → α} :

theorem function.​surjective.​of_comp {α : Sort u} {β : Sort v} {f : α → β} {γ : Sort w} {g : γ → α} :

@[instance]
def function.​decidable_eq_pfun (p : Prop) [decidable p] (α : p → Type u_1) [Π (hp : p), decidable_eq (α hp)] :
decidable_eq (Π (hp : p), α hp)

Equations
theorem function.​surjective.​forall {α : Sort u} {β : Sort v} {f : α → β} (hf : function.surjective f) {p : β → Prop} :
(∀ (y : β), p y) ∀ (x : α), p (f x)

theorem function.​surjective.​forall₂ {α : Sort u} {β : Sort v} {f : α → β} (hf : function.surjective f) {p : β → β → Prop} :
(∀ (y₁ y₂ : β), p y₁ y₂) ∀ (x₁ x₂ : α), p (f x₁) (f x₂)

theorem function.​surjective.​forall₃ {α : Sort u} {β : Sort v} {f : α → β} (hf : 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 {α : Sort u} {β : Sort v} {f : α → β} (hf : function.surjective f) {p : β → Prop} :
(∃ (y : β), p y) ∃ (x : α), p (f x)

theorem function.​surjective.​exists₂ {α : Sort u} {β : Sort v} {f : α → β} (hf : function.surjective f) {p : β → β → Prop} :
(∃ (y₁ y₂ : β), p y₁ y₂) ∃ (x₁ x₂ : α), p (f x₁) (f x₂)

theorem function.​surjective.​exists₃ {α : Sort u} {β : Sort v} {f : α → β} (hf : function.surjective f) {p : β → β → β → Prop} :
(∃ (y₁ y₂ y₃ : β), p y₁ y₂ y₃) ∃ (x₁ x₂ x₃ : α), p (f x₁) (f x₂) (f x₃)

theorem function.​cantor_surjective {α : Type u_1} (f : α → set α) :

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

theorem function.​cantor_injective {α : Type u_1} (f : set α → α) :

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

def function.​is_partial_inv {α : Type u_1} {β : Sort u_2} :
(α → β)(β → 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.

Equations
theorem function.​is_partial_inv_left {α : Type u_1} {β : Sort u_2} {f : α → β} {g : β → option α} (H : function.is_partial_inv f g) (x : α) :
g (f x) = option.some x

theorem function.​injective_of_partial_inv {α : Type u_1} {β : Sort u_2} {f : α → β} {g : β → option α} :

theorem function.​injective_of_partial_inv_right {α : Type u_1} {β : Sort u_2} {f : α → β} {g : β → option α} (H : function.is_partial_inv f g) (x y : β) (b : α) :
b g xb g yx = y

theorem function.​left_inverse.​comp_eq_id {α : Sort u} {β : Sort v} {f : α → β} {g : β → α} :

theorem function.​left_inverse_iff_comp {α : Sort u} {β : Sort v} {f : α → β} {g : β → α} :

theorem function.​right_inverse.​comp_eq_id {α : Sort u} {β : Sort v} {f : α → β} {g : β → α} :

theorem function.​right_inverse_iff_comp {α : Sort u} {β : Sort v} {f : α → β} {g : β → α} :

theorem function.​left_inverse.​comp {α : Sort u} {β : Sort v} {γ : Sort u_1} {f : α → β} {g : β → α} {h : β → γ} {i : γ → β} :

theorem function.​right_inverse.​comp {α : Sort u} {β : Sort v} {γ : Sort u_1} {f : α → β} {g : β → α} {h : β → γ} {i : γ → β} :

theorem function.​left_inverse.​right_inverse {α : Sort u} {β : Sort v} {f : α → β} {g : β → α} :

theorem function.​right_inverse.​left_inverse {α : Sort u} {β : Sort v} {f : α → β} {g : β → α} :

theorem function.​left_inverse.​surjective {α : Sort u} {β : Sort v} {f : α → β} {g : β → α} :

theorem function.​right_inverse.​injective {α : Sort u} {β : Sort v} {f : α → β} {g : β → α} :

theorem function.​left_inverse.​eq_right_inverse {α : Sort u} {β : Sort v} {f : α → β} {g₁ g₂ : β → α} :
function.left_inverse g₁ ffunction.right_inverse g₂ fg₁ = g₂

def function.​partial_inv {α : Type u_1} {β : Sort u_2} :
(α → β)β → option α

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

Equations
theorem function.​partial_inv_of_injective {α : Type u_1} {β : Sort u_2} {f : α → β} :

theorem function.​partial_inv_left {α : Type u_1} {β : Sort u_2} {f : α → β} (I : function.injective f) (x : α) :

def function.​inv_fun_on {α : Type u} [n : nonempty α] {β : Sort v} :
(α → β)set αβ → α

Construct the inverse for a function f on domain s. This function is a right inverse of f on f '' s.

Equations
theorem function.​inv_fun_on_pos {α : Type u} [n : nonempty α] {β : Sort v} {f : α → β} {s : set α} {b : β} :
(∃ (a : α) (H : a s), f a = b)function.inv_fun_on f s b s f (function.inv_fun_on f s b) = b

theorem function.​inv_fun_on_mem {α : Type u} [n : nonempty α] {β : Sort v} {f : α → β} {s : set α} {b : β} :
(∃ (a : α) (H : a s), f a = b)function.inv_fun_on f s b s

theorem function.​inv_fun_on_eq {α : Type u} [n : nonempty α] {β : Sort v} {f : α → β} {s : set α} {b : β} :
(∃ (a : α) (H : a s), f a = b)f (function.inv_fun_on f s b) = b

theorem function.​inv_fun_on_eq' {α : Type u} [n : nonempty α] {β : Sort v} {f : α → β} {s : set α} {a : α} :
(∀ (x : α), x s∀ (y : α), y sf x = f yx = y)a sfunction.inv_fun_on f s (f a) = a

theorem function.​inv_fun_on_neg {α : Type u} [n : nonempty α] {β : Sort v} {f : α → β} {s : set α} {b : β} :
(¬∃ (a : α) (H : a s), f a = b)function.inv_fun_on f s b = classical.choice n

def function.​inv_fun {α : Type u} [n : nonempty α] {β : Sort v} :
(α → β)β → α

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

Equations
theorem function.​inv_fun_eq {α : Type u} [n : nonempty α] {β : Sort v} {f : α → β} {b : β} :
(∃ (a : α), f a = b)f (function.inv_fun f b) = b

theorem function.​inv_fun_neg {α : Type u} [n : nonempty α] {β : Sort v} {f : α → β} {b : β} :
(¬∃ (a : α), f a = b)function.inv_fun f b = classical.choice n

theorem function.​inv_fun_eq_of_injective_of_right_inverse {α : Type u} [n : nonempty α] {β : Sort v} {f : α → β} {g : β → α} :

theorem function.​right_inverse_inv_fun {α : Type u} [n : nonempty α] {β : Sort v} {f : α → β} :

theorem function.​left_inverse_inv_fun {α : Type u} [n : nonempty α] {β : Sort v} {f : α → β} :

theorem function.​inv_fun_surjective {α : Type u} [n : nonempty α] {β : Sort v} {f : α → β} :

theorem function.​inv_fun_comp {α : Type u} [n : nonempty α] {β : Sort v} {f : α → β} :

theorem function.​injective.​has_left_inverse {α : Type u} [i : nonempty α] {β : Sort v} {f : α → β} :

theorem function.​injective_iff_has_left_inverse {α : Type u} [i : nonempty α] {β : Sort v} {f : α → β} :

def function.​surj_inv {α : Sort u} {β : Sort v} {f : α → β} :
function.surjective fβ → α

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

Equations
theorem function.​surj_inv_eq {α : Sort u} {β : Sort v} {f : α → β} (h : function.surjective f) (b : β) :

theorem function.​right_inverse_surj_inv {α : Sort u} {β : Sort v} {f : α → β} (hf : function.surjective f) :

theorem function.​left_inverse_surj_inv {α : Sort u} {β : Sort v} {f : α → β} (hf : function.bijective f) :

theorem function.​surjective.​has_right_inverse {α : Sort u} {β : Sort v} {f : α → β} :

theorem function.​bijective_iff_has_inverse {α : Sort u} {β : Sort v} {f : α → β} :

theorem function.​injective_surj_inv {α : Sort u} {β : Sort v} {f : α → β} (h : function.surjective f) :

def function.​update {α : Sort u} {β : α → Sort v} [decidable_eq α] (f : Π (a : α), β a) (a' : α) (v : β a') (a : α) :
β a

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

Equations
@[simp]
theorem function.​update_same {α : Sort u} {β : α → Sort v} [decidable_eq α] (a : α) (v : β a) (f : Π (a : α), β a) :
function.update f a v a = v

@[simp]
theorem function.​update_noteq {α : Sort u} {β : α → Sort v} [decidable_eq α] {a a' : α} (h : a a') (v : β a') (f : Π (a : α), β a) :
function.update f a' v a = f a

@[simp]
theorem function.​update_eq_self {α : Sort u} {β : α → Sort v} [decidable_eq α] (a : α) (f : Π (a : α), β a) :
function.update f a (f a) = f

theorem function.​update_comp {α : Sort u} {α' : Sort w} [decidable_eq α] [decidable_eq α'] {β : Sort v} (f : α → β) {g : α' → α} (hg : function.injective g) (a : α') (v : β) :
function.update f (g a) v g = function.update (f g) a v

theorem function.​comp_update {α : Sort u} [decidable_eq α] {α' : 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 {α : Sort u_1} [decidable_eq α] {β : α → Sort u_2} {a b : α} (h : a b) (v : β a) (w : β b) (f : Π (a : α), β a) :

@[simp]
theorem function.​update_idem {α : Sort u_1} [decidable_eq α] {β : α → Sort u_2} {a : α} (v w : β a) (f : Π (a : α), β a) :

theorem function.​uncurry_def {α : Type u_1} {β : Type u_2} {γ : Type u_3} (f : α → β → γ) :
function.uncurry f = λ (p : α × β), f p.fst p.snd

def function.​bicompl {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} {ε : Type u_5} :
(γ → δ → ε)(α → γ)(β → δ)α → β → ε

Compose a binary function f with a pair of unary functions g and h. If both arguments of f have the same type and g = h, then bicompl f g g = f on g.

Equations
def function.​bicompr {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} :
(γ → δ)(α → β → γ)α → β → δ

Compose an unary function f with a binary function g.

Equations
theorem function.​uncurry_bicompr {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} (f : α → β → γ) (g : γ → δ) :

theorem function.​uncurry_bicompl {α : Type u_1} {β : Type u_2} {γ : Type u_3} {δ : Type u_4} {ε : Type u_5} (f : γ → δ → ε) (g : α → γ) (h : β → δ) :

def function.​involutive {α : Sort u_1} :
(α → α) → Prop

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

Equations
theorem function.​involutive_iff_iter_2_eq_id {α : Sort u_1} {f : α → α} :

theorem function.​involutive.​left_inverse {α : Sort u} {f : α → α} :

theorem function.​involutive.​injective {α : Sort u} {f : α → α} :

theorem function.​involutive.​surjective {α : Sort u} {f : α → α} :

theorem function.​involutive.​bijective {α : Sort u} {f : α → α} :

def function.​injective2 {α : 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.

Equations
  • function.injective2 f = ∀ ⦃a₁ a₂ : α⦄ ⦃b₁ b₂ : β⦄, f a₁ b₁ = f a₂ b₂a₁ = a₂ b₁ = b₂
theorem function.​injective2.​left {α : Type u_1} {β : Type u_2} {γ : Type u_3} (f : α → β → γ) (hf : function.injective2 f) ⦃a₁ a₂ : α⦄ ⦃b₁ b₂ : β⦄ :
f a₁ b₁ = f a₂ b₂a₁ = a₂

theorem function.​injective2.​right {α : Type u_1} {β : Type u_2} {γ : Type u_3} (f : α → β → γ) (hf : function.injective2 f) ⦃a₁ a₂ : α⦄ ⦃b₁ b₂ : β⦄ :
f a₁ b₁ = f a₂ b₂b₁ = b₂

theorem function.​injective2.​eq_iff {α : Type u_1} {β : Type u_2} {γ : Type u_3} (f : α → β → γ) (hf : function.injective2 f) ⦃a₁ a₂ : α⦄ ⦃b₁ b₂ : β⦄ :
f a₁ b₁ = f a₂ b₂ a₁ = a₂ b₁ = b₂

def function.​sometimes {α : 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.

Equations
theorem function.​sometimes_eq {p : Prop} {α : Sort u_1} [nonempty α] (f : p → α) (a : p) :

theorem function.​sometimes_spec {p : Prop} {α : Sort u_1} [nonempty α] (P : α → Prop) (f : p → α) (a : p) :
P (f a)P (function.sometimes f)

def set.​piecewise {α : Type u} {β : α → Sort v} (s : set α) (f g : Π (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.

Equations