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'
- units.unique
- add_units.unique
- equiv.perm_unique
- mul_opposite.unique
- add_opposite.unique
- set.unique_empty
- set.unique_singleton
- mul_equiv.unique
- add_equiv.unique
- order_hom.unique
- nat.unique_ring_hom
- fin.order_iso_unique
- list.unique_of_is_empty
- plift.unique
- ulift.unique
- finset.unique
- nat.unique_units
- nat.unique_add_units
- sym.unique_zero
- sym.unique
- ring_equiv.unique
- associates.unique
- associates.unique_units
- unique_normalization_monoid_of_unique_units
- submonoid.unique
- add_submonoid.unique
- subgroup.has_bot.bot.unique
- add_subgroup.has_bot.bot.unique
- subgroup.unique
- add_subgroup.unique
- submodule.unique_bot
- 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
- monoid_algebra.unique
- add_monoid_algebra.unique
- polynomial.unique
- submodule.quotient_top.unique
- unique_basis
- basis.empty_unique
- ideal.unique_units
- subalgebra.unique
- localization.unique
- fraction_ring.unique
- mv_polynomial.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
- dmatrix.unique
- cardinal.units.unique
- filter.unique
- ennreal.add_units.unique
- continuous_linear_map.unique_of_left
- continuous_linear_map.unique_of_right
- polynomial.gal.unique
- polynomial.gal.unique_gal_zero
- polynomial.gal.unique_gal_one
- polynomial.gal.unique_gal_C
- polynomial.gal.unique_gal_X
- polynomial.gal.unique_gal_X_sub_C
- polynomial.gal.unique_gal_X_pow
- free_abelian_group.pempty_unique
- 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
- quiver.single_obj.unique
- Module.of_unique
- category_theory.cech_nerve_terminal_from.unique_to_wide_cospan_none
- pre_lp.unique
- sym2.unique
- category_theory.with_terminal.quiver.hom.unique
- category_theory.with_initial.quiver.hom.unique
- Mon_.unique_hom_from_trivial
- CommMon_.unique_hom_from_trivial
- SemiNormedGroup.of_unique
- SemiNormedGroup₁.of_unique
- prime_spectrum.unique
- interval.unique
- finpartition.unique
- pgame.unique_one_left_moves
- pgame.unique_star_left_moves
- pgame.unique_star_right_moves
- pgame.unique_inv_ty
- ordinal.unique_one_to_pgame_left_moves
- pgame.unique_pow_half_left_moves
- pgame.unique_pow_half_succ_right_moves
- pgame.unique_nim_one_left_moves
- pgame.unique_nim_one_right_moves
- sym_alg.unique
- linear_ordered_field.order_ring_hom.unique
- linear_ordered_field.order_ring_iso.unique
- real.ring_hom.unique
- quiver.path.unique
- simple_graph.unique
- simple_graph.hom.unique
- first_order.language.Structure.unique
- first_order.language.Lhom.unique
- algebraic_geometry.quiver.hom.unique
- alternating_group.unique
- sensitivity.Q.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 := _}