Miscellaneous function constructions and lemmas #
Evaluate a function at an argument. Useful if you want to talk about the partially applied
Function.eval x : (∀ x, β x) → β x
.
Equations
- Function.eval x f = f x
Instances For
If the co-domain β
of an injective function f : α → β
has decidable equality, then
the domain α
also has decidable equality.
Equations
- Function.Injective.decidableEq I x x = decidable_of_iff (f x = f x) (_ : f x = f x ↔ x = x)
Instances For
Composition by an injective function on the left is itself injective.
Equations
- Function.decidableEqPfun p α x x = match x, x with | f, g => decidable_of_iff (∀ (hp : p), f hp = g hp) (_ : (∀ (a : p), f a = g a) ↔ (fun hp => f hp) = fun hp => g hp)
Shorthand for using projection notation with Function.bijective_iff_existsUnique
.
Cantor's diagonal argument implies that there are no surjective functions from α
to Set α
.
Cantor's diagonal argument implies that there are no injective functions from Set α
to α
.
There is no surjection from α : Type u
into Type (max u v)
. This theorem
demonstrates why Type : Type
would be inconsistent in Lean.
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
.
Instances For
We can use choice to construct explicitly a partial inverse for
a given injective function f
.
Equations
- Function.partialInv f b = if h : ∃ a, f a = b then some (Classical.choose h) else none
Instances For
The inverse of a function (which is a left inverse if f
is injective
and a right inverse if f
is surjective).
Equations
- Function.invFun f y = if h : ∃ x, f x = y then Exists.choose h else Classical.arbitrary α
Instances For
The inverse of a surjective function. (Unlike invFun
, this does not require
α
to be inhabited.)
Equations
- Function.surjInv h b = Classical.choose (h b)
Instances For
Composition by a surjective function on the left is itself surjective.
Composition by a bijective function on the left is itself bijective.
Replacing the value of a function at a given point by a given value.
Equations
- Function.update f a' v a = if h : a = a' then (_ : a' = a) ▸ v else f a
Instances For
On non-dependent functions, Function.update
can be expressed as an ite
Non-dependent version of Function.update_comp_eq_of_forall_ne'
Non-dependent version of Function.update_comp_eq_of_injective'
extend f g e'
extends a function g : α → γ
along a function f : α → β
to a function β → γ
,
by using the values of g
on the range of f
and the values of an auxiliary function e' : β → γ
elsewhere.
Mostly useful when f
is injective, or more generally when g.factors_through f
Equations
- Function.extend f g e' b = if h : ∃ a, f a = b then g (Classical.choose h) else e' b
Instances For
g factors through f : f a = f b → g a = g b
Equations
- Function.FactorsThrough g f = ∀ ⦃a b : α⦄, f a = f b → g a = g b
Instances For
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
- Function.bicompl f g h a b = f (g a) (h b)
Instances For
Compose a unary function f
with a binary function g
.
Equations
- Function.bicompr f g a b = f (g a b)
Instances For
- uncurry : α → β → γ
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.
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.
Instances
Equations
- Function.«term↿_» = Lean.ParserDescr.node `Function.term↿_ 1023 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol "↿") (Lean.ParserDescr.cat `term 1023))
Instances For
Equations
- Function.hasUncurryBase = { uncurry := id }
A function is involutive, if f ∘ f = id
.
Equations
- Function.Involutive f = ∀ (x : α), f (f x) = x
Instances For
Involuting an ite
of an involuted value x : α
negates the Prop
condition in the ite
.
An involution commutes across an equality. Compare to Function.Injective.eq_iff
.
The property of a binary function f : α → β → γ
being injective.
Mathematically this should be thought of as the corresponding function α × β → γ
being injective.
Instances For
A binary injective function is injective when only the left argument varies.
A binary injective function is injective when only the right argument varies.
As a map from the left argument to a unary function, f
is injective.
As a map from the right argument to a unary function, f
is injective.
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
- Function.sometimes f = if h : Nonempty α then f (Classical.choice h) else Classical.choice inst
Instances For
s.piecewise f g
is the function equal to f
on the set s
, and to g
on its complement.
Equations
- Set.piecewise s f g i = if i ∈ s then f i else g i
Instances For
Note these lemmas apply to Type*
not Sort*
, as the latter interferes with simp
, and
is trivial anyway.
Equations
- instDecidableUncurryProp = inst
Equations
- instDecidableCurryProp = inst