General operations on functions
Composition of functions: (f ∘ g) x = f (g x)
.
Composition of dependent functions: (f ∘' g) x = f (g x)
, where type of g x
depends on x
and type of f (g x)
depends on x
and g x
.
Equations
- function.comp_right f g = λ (b : β) (a : α), f b (g a)
Equations
- function.comp_left f g = λ (a : α) (b : β), f (g a) b
Given functions f : β → β → φ
and g : α → β
, produce a function α → α → φ
that evaluates
g
on each argument, then applies f
to the results. Can be used, e.g., to transfer a relation
from β
to α
.
Constant λ _, a
.
Equations
- function.const β a = λ (x : β), a
Equations
- function.swap f = λ (y : β) (x : α), f x y
Equations
- function.app f x = f x
A function f : α → β
is called injective if f x = f y
implies x = y
.
Equations
- function.injective f = ∀ ⦃a₁ a₂ : α⦄, f a₁ = f a₂ → a₁ = a₂
A function f : α → β
is calles surjective if every b : β
is equal to f a
for some a : α
.
Equations
- function.surjective f = ∀ (b : β), ∃ (a : α), f a = b
A function is called bijective if it is both injective and surjective.
Equations
left_inverse g f
means that g is a left inverse to f. That is, g ∘ f = id
.
Equations
- function.left_inverse g f = ∀ (x : α), g (f x) = x
has_left_inverse f
means that f
has an unspecified left inverse.
Equations
- function.has_left_inverse f = ∃ (finv : β → α), function.left_inverse finv f
right_inverse g f
means that g is a right inverse to f. That is, f ∘ g = id
.
Equations
has_right_inverse f
means that f
has an unspecified right inverse.
Equations
- function.has_right_inverse f = ∃ (finv : β → α), function.right_inverse finv f
Interpret a function on α × β
as a function with two arguments.
Equations
- function.curry = λ (f : α × β → φ) (a : α) (b : β), f (a, b)
Interpret a function with two arguments as a function on α × β
Equations
- function.uncurry = λ (f : α → β → φ) (a : α × β), f a.fst a.snd
Equations
- _ = _