definition example

A subobject of an object in a Category is (an isomorphism class of) a Monomorphism . Two monos , define the same subobject when there is an Isomorphism with . Subobjects of are preordered by factorization ( iff for some ), giving the poset .

Sources: 7 Sketches §7.2.2 (“it will do no harm to think of monomorphisms into as subobjects of ”), Definition 7.12, §7.4.3 (“The poset of subobjects”); Kittenlab Lecture 14 (subsets as injections vs. as characteristic functions); DaoFP §2.4.

Docs: FinSets · C-set morphisms · Graphs · Vignette: subgraphs — Kittenlab Lecture 14

using Catlab
Y = FinSet(5)
A = Subobject(Y, [1, 2, 4])            # a subobject of a finite set
hom(A)                                  # the mono FinFunction([1, 2, 4], 5)
B = Subobject(Y, [2, 4, 5])
A ∧ B, A ∨ B                            # Sub(Y) is a lattice (here: a Boolean algebra)
G = path_graph(Graph, 3)
H = Subobject(G, V=[1, 2], E=[1])       # a subgraph as a subobject
force(hom(H))                           # the monic ACSetTransformation H ↪ G
import Mathlib
open CategoryTheory
#check @CategoryTheory.Subobject          -- Subobject X := quotient of MonoOver X by iso
#check @CategoryTheory.MonoOver
#check @CategoryTheory.Subobject.pullback -- f^* : Subobject Y ⥤ Subobject X
#check @CategoryTheory.Subobject.inf      -- meets via pullback (needs HasPullbacks)
-- a subobject of a finite type, two ways (Kittenlab): as a list of elements or as a predicate
newtype Sub a = Sub [a]
toPred :: Eq a => Sub a -> (a -> Bool)
toPred (Sub xs) = (`elem` xs)
fromPred :: [a] -> (a -> Bool) -> Sub a
fromPred univ p = Sub (filter p univ)