# 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)
def PartialFun :
Type (u_3 + 1)

The category of types equipped with partial functions.

Equations
Instances For

Turns a type into a PartialFun.

Equations
Instances For
Equations
@[simp]
theorem PartialFun.Iso.mk_inv {α : PartialFun} {β : PartialFun} (e : α β) (x : β) :
.inv x = (some (e.symm x))
@[simp]
theorem PartialFun.Iso.mk_hom {α : PartialFun} {β : PartialFun} (e : α β) (x : α) :
.hom x = (some (e x))
def PartialFun.Iso.mk {α : PartialFun} {β : PartialFun} (e : α β) :
α β

Constructs a partial function isomorphism between types from an equivalence between them.

Equations
• = { 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
Instances For
@[simp]
theorem pointedToPartialFun_map :
∀ {X Y : Pointed} (f : X Y) (a : { x : X.X // x X.point }), f a = (PFun.toSubtype (fun (x : Y.X) => x Y.point) f.toFun Subtype.val) a
@[simp]
theorem pointedToPartialFun_obj (X : Pointed) :
X = { x : X.X // x X.point }

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
@[simp]
theorem partialFunToPointed_obj (X : PartialFun) :
X = { X := , point := none }
@[simp]
theorem partialFunToPointed_map :
∀ {X Y : PartialFun} (f : X Y), f = { toFun := Option.elim' none fun (a : X) => (f a).toOption, map_point := }
noncomputable def partialFunToPointed :

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
@[simp]
theorem partialFunEquivPointed_unitIso_inv_app (X : PartialFun) :
partialFunEquivPointed.unitIso.inv.app X = CategoryTheory.CategoryStruct.comp ( { toFun := Option.elim' none fun (a : X) => some some a, , map_point := }) (CategoryTheory.CategoryStruct.comp ( ().hom) (PartialFun.Iso.mk { toFun := fun (a : X) => some a, , invFun := fun (a : { x : // ¬x = none }) => (a).get , left_inv := , right_inv := }).inv)
@[simp]
@[simp]
theorem partialFunEquivPointed_inverse_map_Dom :
∀ {X Y : Pointed} (f : X Y) (a : { x : X.X // x X.point }), (partialFunEquivPointed.inverse.map f a).Dom = ¬f.toFun a = Y.point
@[simp]
theorem partialFunEquivPointed_counitIso_hom_app_toFun (X : Pointed) (a : (.obj X).X) :
(partialFunEquivPointed.counitIso.hom.app X).toFun a = Option.casesOn' a X.point Subtype.val
@[simp]
theorem partialFunEquivPointed_inverse_obj (X : Pointed) :
partialFunEquivPointed.inverse.obj X = { x : X.X // ¬x = X.point }
@[simp]
theorem partialFunEquivPointed_unitIso_hom_app (X : PartialFun) :
partialFunEquivPointed.unitIso.hom.app X = CategoryTheory.CategoryStruct.comp (PartialFun.Iso.mk { toFun := fun (a : X) => some a, , invFun := fun (a : { x : // ¬x = none }) => (a).get , left_inv := , right_inv := }).hom (CategoryTheory.CategoryStruct.comp ( ().inv) ( { toFun := Option.elim' none fun (a : { x : // ¬x = none }) => a, map_point := }))
@[simp]
theorem partialFunEquivPointed_inverse_map_get_coe :
∀ {X Y : Pointed} (f : X Y) (a : { x : X.X // x X.point }) (property : f.toFun a Y.point), ((partialFunEquivPointed.inverse.map f a).get property) = f.toFun a
@[simp]
theorem partialFunEquivPointed_counitIso_inv_app_toFun (X : Pointed) (a : ( X).X) :
(partialFunEquivPointed.counitIso.inv.app X).toFun a = if h : a = X.point then none else some a, h
@[simp]
theorem partialFunEquivPointed_functor_map_toFun :
∀ {X Y : PartialFun} (f : X Y) (a : ), (partialFunEquivPointed.functor.map f).toFun a = Option.elim' none (fun (a : X) => (f a).toOption) a
noncomputable def partialFunEquivPointed :

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
@[simp]
theorem typeToPartialFunIsoPartialFunToPointed_inv_app_toFun (X : Type u_3) (a : (typeToPointed.obj X).X) :
().toFun a = a
@[simp]
theorem typeToPartialFunIsoPartialFunToPointed_hom_app_toFun (X : Type u_3) (a : (.obj X).X) :
().toFun a = a

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.
Instances For