Note that partially ordered sets, or posets, are isomorphic to directed acyclic graphs, or DAGs. A poset's elements are a DAG's vertices, and the less-than-or-equal relation becomes the path relation. This isomorphism actually relates a poset to a family of DAGs. We will select the transitive reduction from amongst them; this is the smallest member of the family. (Proof of all of this is left to the reader.) We can represent a poset/DAG as an upper triangular matrix in the Booleans. The matrix's rows and columns are the elements/vertices, and each member of the matrix indicates whether there is an arrow from the given row-element to the given column-element. To ensure that there are no arrows outside the upper triangular region, the elements must be ordered as a linear extension, also known as a topological sorting. As an example, suppose we have a poset with three elements, X, Y, and Z, and arrows X -> Y and X -> Z. A valid linear extension is [ X Y Z ]. The resulting matrix is: [ 1 1 1 ] [ 0 1 0 ] [ 0 0 1 ] Note that all elements relate to themselves, so that the diagonal is implicitly always 1. [ \ 1 1 ] [ \ 0 ] [ \ ] \11 \0 \ Thus, we may store any poset/DAG as a bitstring and a cardinality of elements. --- https://www.mta.ca/uploadedFiles/Community/Bios/Geoff_Cruttwell/ams2014CruttwellCountingFiniteCats.pdf We can encode a category as a matrix of its objects and arrows. Suppose again that we have a diagram as above, with objects X, Y, and Z, as well as arrows f and g, from X to Y and to Z respectively. We do not need a linear extension; we need only ensure that the objects come before the arrows. Thus a valid listing is [ X Y Z f g ] and the resulting matrix is: [ X * * f g ] [ * Y * * * ] [ * * Z * * ] [ * f * * * ] [ * * g * * ] Thus, we may store any category as a bitstring and the cardinalities of its arrows and objects. Now, suppose that we have a 2-category. Then we may carry through an identical construction on the 1-categories and functors, representing each 1-category with its identity functor and its arrow matrix. Each non-identity functor must also store an arrow-to-arrow map. Thus, we may store any n-category as a bitstring, the cardinalities of its arrows and objects, for each arrow a map of its components, and for each object its representation as a (n-1)-category.