The category of types with partial functions #
This defines PartialFun
, the category of types equipped with partial functions.
This category is classically equivalent to the category of pointed types. The reason it doesn't hold
constructively stems from the difference between Part
and Option
. Both can model partial
functions, but the latter forces a decidable domain.
Precisely, PartialFunToPointed
turns a partial function α →. β
into a function
Option α → Option β
by sending to none
the undefined values (and none
to none
). But being
defined is (generally) undecidable while being sent to none
is decidable. So it can't be
constructive.
References #
- [nLab, The category of sets and partial functions] (https://ncatlab.org/nlab/show/partial+function)
Equations
- PartialFun.instCoeSortType = { coe := id }
Equations
- PartialFun.instInhabited = { default := Type u_3 }
Constructs a partial function isomorphism between types from an equivalence between them.
Equations
- PartialFun.Iso.mk e = { hom := fun (x : α) => ↑(some (e x)), inv := fun (x : β) => ↑(some (e.symm x)), hom_inv_id := ⋯, inv_hom_id := ⋯ }
Instances For
The forgetful functor from Type
to PartialFun
which forgets that the maps are total.
Equations
- typeToPartialFun = { obj := id, map := @PFun.lift, map_id := typeToPartialFun.proof_1, map_comp := @typeToPartialFun.proof_2 }
Instances For
Equations
The functor which deletes the point of a pointed type. In return, this makes the maps partial.
This is the computable part of the equivalence PartialFunEquivPointed
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The functor which maps undefined values to a new point. This makes the maps total and creates
pointed types. This is the noncomputable part of the equivalence PartialFunEquivPointed
. It can't
be computable because = Option.none
is decidable while the domain of a general Part
isn't.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The equivalence induced by PartialFunToPointed
and PointedToPartialFun
.
Part.equivOption
made functorial.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Forgetting that maps are total and making them total again by adding a point is the same as just adding a point.
Equations
- One or more equations did not get rendered due to their size.