Given morphisms and with (i.e. ) but not necessarily , we call a section of and a retraction of ; is a retract of . ” and are almost — but not quite — inverses.”
Sources: 7 Sketches Example 3.34 (functions ); DaoFP §2.4–2.5; CTfS Definition 2.7.1.1, Exercise 2.7.1.2
Example 3.34. , and , : but . CTfS (Definition 2.7.1.1) calls a retract section and a retract projection. An olog example (CTfS Exercise 2.7.1.2): “a US state a city a US state” is the identity on states, but “a city a state a city” sends Boston to Boston and Cambridge to Boston, so it is not the identity: has as capital is a section, not an isomorphism.
A section is always a Monomorphism (split mono) and a retraction always an Epimorphism (split epi); a morphism that is both a section and a retraction of the same map is an Isomorphism. In every Surjection has a section (axiom of choice) and every injection out of a nonempty set has a retraction. The composite is idempotent, — a split idempotent, the categorical version of a Closure Operator together with its fixed points.
#check CategoryTheory.SplitMono -- structure with retraction, id
#check CategoryTheory.SplitEpi -- structure with section_, id-- a retract: embed then project is the identity on the smaller type
data Retract a b = Retract { embed :: a -> b, project :: b -> a } -- project . embed = id
boolInInt :: Retract Bool Int
boolInInt = Retract (\b -> if b then 1 else 0) (/= 0)