Types with a unique term #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
In this file we define a typeclass unique
,
which expresses that a type has a unique term.
In other words, a type that is inhabited
and a subsingleton
.
Main declaration #
unique
: a typeclass that expresses that a type has a unique term.
Main statements #
-
unique.mk'
: an inhabited subsingleton type isunique
. This can not be an instance because it would lead to loops in typeclass inference. -
function.surjective.unique
: if the domain of a surjective function isunique
, then its codomain isunique
as well. -
function.injective.subsingleton
: if the codomain of an injective function issubsingleton
, then its domain issubsingleton
as well. -
function.injective.unique
: if the codomain of an injective function issubsingleton
and its domain isinhabited
, then its domain isunique
.
Implementation details #
The typeclass unique α
is implemented as a type,
rather than a Prop
-valued predicate,
for good definitional properties of the default term.
- to_inhabited : inhabited α
- uniq : ∀ (a : α), a = inhabited.default
unique α
expresses that α
is a type with a unique term default
.
This is implemented as a type, rather than a Prop
-valued predicate,
for good definitional properties of the default term.
Instances of this typeclass
- subsingleton.unique_topological_space
- punit.unique
- true.unique
- fin.unique
- pi.unique
- pi.unique_of_is_empty
- option.unique
- unique.subtype_eq
- unique.subtype_eq'
- equiv.perm_unique
- mul_opposite.unique
- add_opposite.unique
- units.unique
- add_units.unique
- mul_equiv.unique
- add_equiv.unique
- set.unique_empty
- set.unique_singleton
- order_hom.unique
- nat.unique_ring_hom
- nat.unique_units
- nat.unique_add_units
- ring_equiv.unique
- plift.unique
- ulift.unique
- associates.unique
- associates.unique_units
- unique_normalization_monoid_of_unique_units
- fin.order_iso_unique
- list.unique_of_is_empty
- finset.unique
- submonoid.unique
- add_submonoid.unique
- subgroup.has_bot.bot.unique
- add_subgroup.has_bot.bot.unique
- subgroup.unique
- add_subgroup.unique
- submodule.unique_bot
- sym.unique_zero
- sym.unique
- dfinsupp.unique
- dfinsupp.unique_of_is_empty
- finsupp.unique_of_right
- finsupp.unique_of_left
- linear_map.unique_of_left
- linear_map.unique_of_right
- submodule.unique
- submodule.unique'
- linear_equiv.unique
- linear_equiv.unique_of_subsingleton
- flag.unique
- submodule.quotient_top.unique
- unique_basis
- basis.empty_unique
- ideal.unique_units
- subalgebra.unique
- monoid_algebra.unique
- add_monoid_algebra.unique
- ideal.quotient.has_quotient.quotient.unique
- direct_sum.unique
- direct_sum.unique_of_is_empty
- matrix.unique
- ordinal.unique_Iio_one
- ordinal.unique_out_one
- equiv.perm.vectors_prod_eq_one.zero_unique
- equiv.perm.vectors_prod_eq_one.one_unique
- mv_polynomial.unique
- polynomial.unique
- localization.unique
- fraction_ring.unique
- filter.unique
- ennreal.add_units.unique
- continuous_linear_map.unique_of_left
- continuous_linear_map.unique_of_right
- category_theory.discrete.unique
- category_theory.unique_to_top
- category_theory.unique_from_bot
- category_theory.limits.unique_to_terminal
- category_theory.limits.unique_from_initial
- Group.of_unique
- AddGroup.of_unique
- CommGroup.of_unique
- AddCommGroup.of_unique
- Module.of_unique
- Cliff.quiver.hom.unique
Instances of other typeclasses for unique
- unique.has_sizeof_inst
- unique.subsingleton_unique
- equiv_functor_unique
Given an explicit a : α
with [subsingleton α]
, we can construct
a [unique α]
instance. This is a def because the typeclass search cannot
arbitrarily invent the a : α
term. Nevertheless, these instances are all
equivalent by unique.subsingleton.unique
.
See note [reducible non-instances].
Equations
- unique_of_subsingleton a = {to_inhabited := {default := a}, uniq := _}
Equations
- punit.unique = {to_inhabited := {default := punit.star}, uniq := punit.unique._proof_1}
Every provable proposition is unique, as all proofs are equal.
Equations
- unique_prop h = {to_inhabited := {default := h}, uniq := _}
Equations
Equations
- fin.inhabited = {default := 0}
Equations
Equations
- unique.inhabited = _inst_1.to_inhabited
Construct unique
from inhabited
and subsingleton
. Making this an instance would create
a loop in the class inheritance graph.
Equations
- unique.mk' α = {to_inhabited := {default := inhabited.default h₁}, uniq := _}
There is a unique function on an empty domain.
Equations
- pi.unique_of_is_empty β = {to_inhabited := {default := is_empty_elim (λ (a : α), β a)}, uniq := _}
If the codomain of an injective function is a subsingleton, then the domain is a subsingleton as well.
If the domain of a surjective function is a subsingleton, then the codomain is a subsingleton as well.
If the domain of a surjective function is a singleton, then the codomain is a singleton as well.
Equations
- hf.unique = unique.mk' β
If α
is inhabited and admits an injective map to a subsingleton type, then α
is unique
.
Equations
- hf.unique = unique.mk' α
If a constant function is surjective, then the codomain is a singleton.
Equations
option α
is a subsingleton
if and only if α
is empty.
Equations
Equations
- unique.subtype_eq y = {to_inhabited := {default := ⟨y, _⟩}, uniq := _}
Equations
- unique.subtype_eq' y = {to_inhabited := {default := ⟨y, _⟩}, uniq := _}