<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>On the Syntax and Semantics of CAP</article-title>
      </title-group>
      <contrib-group>
        <aff id="aff0">
          <label>0</label>
          <institution>Sebastian Gutsche Sebastian Posur Department of Mathematics Department of Mathematics University of Siegen University of Siegen</institution>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2018</year>
      </pub-date>
      <abstract>
        <p>The Cap project (Categories, Algorithms, Programming) is a framework for implementing and computing with constructive categories. In this paper we explain the syntax and semantics of Cap by means of an example: the implementation of cokernels in the category of finitely presented modules. Although this example is quite simple, it reveals the necessary usage of dependent types for an appropriate specification of categorical constructions as well as the requirement to model homomorphisms as setoids rather than sets in our constructive framework for category theory.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>syntax for implementing generic categorical algorithms, such as the computation of specific differentials on a
page of a spectral sequence in the context of an arbitrary abelian category.</p>
      <p>The purpose of this paper is to explain the syntax and semantics of these templates by means of an example:
we look at the categorical construction of a cokernel in a model for the category of finitely presented modules over
a computable ring R. We will see that a convenient way to express the interdependencies in the specifications
of a cokernel can be conveniently addressed by the usage of dependent types (Section 2). Moreover, modeling
finitely presented modules in a constructive way will demonstrate the requirement to model homomorphisms as
setoids rather than sets (Section 3).</p>
      <p>The development of Cap started in December 2013. So far, four Cap related software packages1 are distributed
via the current GAP release2, more packages still under development are available on the GitHub page3 of the
Cap project. Even more packages developed for Cap can be found on the GitHub page4 of the homalg-project
[hom17], these packages are usually marked with the suffix ForCAP. For a deeper discussion of Cap and its
functionalities we refer the reader to [Gut17, Pos17b].
2</p>
    </sec>
    <sec id="sec-2">
      <title>Syntax</title>
      <p>Cap supports lots of important notions of category theory, which we also call categorical constructions. From
a theoretical point of view, the specifications of a categorical construction may be expressed using dependent
types. As a simple set-theoretic model for dependent functions and types in this paper, we will use the following
definition.</p>
      <p>Definition 2.1. Let A be a set and let pBaqaPA be an A-indexed family of sets. Then we denote the set of
all sections of the natural projection ZaPABa Ñ A by
¹ Ba :
aPA</p>
      <p>tσ : A Ñ ZaPABa | σpaq P Bau.</p>
      <p>An element σ P ±aPA Ba is called a dependent function of dependent type (or simply of type) ±aPA Ba.</p>
      <p>As an example of a categorical construction and its specifications, we will discuss the notion of a cokernel. Note
that a cokernel can be defined in the context of a category enriched over abelian groups, i.e., its homomorphism
sets are abelian groups, and composition of morphisms distributes over addition.</p>
      <p>Definition 2.2. Let A be a category enriched over abelian groups. Given objects A, B P A and a morphism
φ P HomApA, Bq, a cokernel of φ consists of the following data:
1. An object C P A.</p>
      <sec id="sec-2-1">
        <title>2. A morphism π : B Ñ C such that π</title>
        <p>φ</p>
        <p>0.
3. A dependent function u mapping any pair pT, τ q consisting of an object T P A and a morphism τ : B Ñ T
such that τ φ 0 to a morphism upT, τ q : C Ñ T which has to be uniquely determined by the property
τ upT, τ q π.</p>
        <p>The category A has cokernels if it comes equipped with a dependent function mapping any morphism φ P
HomApA, Bq for A, B P A to a cokernel pC, π, uq of φ.</p>
        <p>Cap provides the following three primitives accessing the three components of the triple pC, π, uq for an
additive category A having cokernels:</p>
        <sec id="sec-2-1-1">
          <title>1. CokernelObject :</title>
          <p>1 These packages are:
• CAP (the core system)</p>
          <p>HomApA, Bq Ñ ObjA : φ ÞÑ C.
• LinearAlgebraForCAP (an implementation of the category of finite dimensional vector spaces)
• ModulePresentationsForCAP (an implementation of the category of finitely presented modules)
• GeneralizedMorphismsForCAP (an implementation of additive relations in abelian categories)
2 Version 4.9.1, as of May 2018
3 https://github.com/homalg-project/CAP_project
4 https://github.com/homalg-project
2. CokernelProjection :</p>
        </sec>
        <sec id="sec-2-1-2">
          <title>3. CokernelColift :</title>
          <p>¹
φPHomApA,Bq
¹
φPHomApA,Bq
τPtσPHomApB,T q|σ φ 0u</p>
        </sec>
      </sec>
      <sec id="sec-2-2">
        <title>HomA pB, CokernelObjectpφqq : φ ÞÑ π.</title>
      </sec>
      <sec id="sec-2-3">
        <title>HomA pCokernelObjectpφq, T q : pφ, τ q ÞÑ upT, τ q.</title>
        <p>We also wrote down the dependent types of these primitives for given objects A, B, T , in order to highlight their
interdependencies. For example, the dependent type of the primitive CokernelProjection tells us that given a
morphism φ : A Ñ B, the output CokernelProjectionpφq will be a morphism B Ñ CokernelObjectpφq, i.e., a
morphism with range depending on the primitive CokernelObject.</p>
        <p>These three primitives suffice for building up other functionalities of the cokernel, e.g., its functoriality.
Example 2.3. Given a commutative diagram in A of the form</p>
        <p>D :
ν</p>
        <p>A
A1
α
α1</p>
        <p>B
B1
μ
the functoriality of the cokernel is given by the term</p>
      </sec>
      <sec id="sec-2-4">
        <title>CokernelFunctorialpDq :</title>
      </sec>
      <sec id="sec-2-5">
        <title>CokernelColift α, CokernelProjectionpα1q</title>
        <p>μ .</p>
        <p>(:)
ν</p>
        <p>The primitives for categorical constructions provided by Cap are powerful enough for a functorial
implementation of a spectral sequence algorithm working in the context of an arbitrary abelian category. Such an algorithm
takes as arguments a morphism of (linearly) descending filtered cochain complexes F A Ñ F B and a triple
of integers pr, p, qq where r ¥ 0. The output is the pp, qq-th differential on the r-th page of the associated spectral
sequence connected in a commutative diagram of the form</p>
        <p>F A Erpq
F B Erpq</p>
        <p>B
B</p>
        <p>F A Erp r,q pr 1q
F B Erp r,q pr 1q
induced by the functoriality of spectral sequences. To see how an implementation of such a high-level categorical
construction can be realized with Cap’s primitives see [Pos17b, Chapter 2].
3</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>Semantics</title>
      <p>The purpose of Cap is to model categories. Classically, a set of objects ObjA and a set of morphisms HomApA, Bq
for all pairs A, B P ObjA are part of the data defining a (small) category A.</p>
      <p>Cap models a slightly more general and computer-friendlier notion of a category: homomorphisms
HomApA, Bq are not only sets but setoids, i.e., a set equipped with an equivalence relation on it as an
extra datum. The formal definition of this kind of category looks as follows:</p>
      <p>Definition 3.1. A Cap category A consists of the following data:
1. A set ObjA of objects.
4. For every A P ObjA, an identity morphism idA P HomApA, Aq.
5. For every triple A, B, C P ObjA, a composition function</p>
      <sec id="sec-3-1">
        <title>A,B on HomApA, Bq. If α</title>
        <p>A,B β for two morphisms
: HomApB, Cq</p>
        <p>HomApA, Bq Ñ HomApA, Cq
compatible with the equivalence relation, i.e., if α, α1 P HomApA, Bq, β, β1 P HomApB, Cq, α
β B,C β1, then β α A,C β1 α1.</p>
        <p>A,B α1 and</p>
      </sec>
      <sec id="sec-3-2">
        <title>6. For all A, B P ObjA, α P HomApA, Bq, we have</title>
        <p>and
pidB
αq</p>
        <p>A,B α
α</p>
        <p>A,B pα idAq .
ppγ
βq
αq</p>
        <p>A,D pγ
pβ
αqq
7. For all A, B, C, D P ObjA, α P HomApA, Bq, β P HomApB, Cq, γ P HomApC, Dq, we have
Remark 3.2. As it will be illustrated in Example 3.4, an implementation of a Cap category A does not need
data structures for the sets ObjA or HomApA, Bq for two A, B P ObjA, as they are not necessary to carry
out the computations Cap is designed for. A proper implementation of a category A needs a data structure
for the elements of these sets, i.e., for the objects A P ObjA and for the morphisms φ P HomApA, Bq for all
objects A, B P ObjA. Note that the data structure for φ P HomApA, Bq must be the same for all pairs of objects
A, B P ObjA.</p>
        <p>Remark 3.3. In terms of higher category theory, a Cap category is a 2-category such that the 2-morphism sets
are either empty or a singleton, and such that its underlying object class is a set. Using this point of view, we
can derive the notion of a functor between Cap categories: a Cap functor consists of an object and a morphism
function such that the usual axioms of a functor hold up to congruence.</p>
        <p>Given a Cap category A, passing to the quotient sets HomApA, Bq{ A,B gives rise to a classical category
A, because all constructions and axioms respect the congruence for morphisms. It is usually the case that we
actually want to compute with A, but that it is easier to implement a Cap category A giving rise to A. We
demonstrate this principle by means of an example.</p>
        <p>Example 3.4. Let R-fpmod be the category of finitely presented left R-modules for a computable ring R.
We are going to model R-fpmod by a Cap category R-fpres. We define ObjR-fpres as the set of all matrices with
entries in R. Note that each such matrix A P Rm n can be interpreted as a homomorphism between free modules
R1 m ÝAÑ R1 n P R-fpmod presenting its cokernel. For A P Rm n, B P Ro p, we define HomR-fpmodpA, Bq as
the set of matrices M P Rn p such that the following diagram can be completed to a commutative diagram by
inserting a matrix ν on the left:</p>
        <p>R1 m
Dν
Note that by the functoriality of the cokernel, such a diagram induces a morphism between the modules presented
by A and B independent of the choice of ν (since ν does not appear in the Cap term (Example 2.3, (:)) defining
CokernelFunctorial). Conversely, every morphism in R-fpmod between the cokernels can be lifted to such a
diagram since row modules are projective.</p>
        <p>In our definition of the homomorphism sets, two morphisms M, N P HomR-fprespA, Bq are equal if they are
equal as matrices. We say M and N are congruent if and only if they induce equal morphisms between the
modules presented by A and B, which is the case if and only if there exists a matrix rendering the diagram
commutative (this is a direct consequence of the comparison theorem [Wei94]).</p>
        <p>Thus, we equipped the homomorphism sets HomR-fprespA, Bq with an equivalence relation such that passing
to the quotient yields a category R-fpres equivalent to R-fpmod. We can see the advantage of the model R-fpres
over R-fpres when we start defining the function</p>
      </sec>
      <sec id="sec-3-3">
        <title>CokernelObject : HomR-fprespA, Bq Ñ ObjR-fpres</title>
        <p>for given A, B P R-fpres. In the case of R-fpres, for M P Rn p, we can simply set</p>
      </sec>
      <sec id="sec-3-4">
        <title>CokernelObjectpM q :</title>
        <p>M
B
which yields a function since equal input yields equal output. The same mapping rule in the context of R-fpres
does not yield a function: For example, M1 p0q and M2 p2q both represent the same module homomorphism
in</p>
        <p>0
Z1 1</p>
        <p>p2q
0
2 
on the level of matrices and thus on the level of objects in R-fpres. This issue can be fixed by making (possibly
unnatural) choices of representatives, but this can be very expensive in an actual implementation.</p>
        <p>We further define
where Ip denotes the p
p identity matrix, and</p>
      </sec>
      <sec id="sec-3-5">
        <title>CokernelProjectionpM q : Ip</title>
      </sec>
      <sec id="sec-3-6">
        <title>CokernelColiftpM, T q : T</title>
        <p>which are dependent functions of the correct types for our model R-fpres.</p>
        <p>The following interpretation underlines the naturality of our model R-fpres: not only is CokernelObject a
function in the context of R-fpres, but actually a functor between Cap categories. This can be made precise
as follows: HomR-fprespA, Bq equipped with its equivalence relation can be seen as a category, where there is a
morphism from M to N if and only if M N . Furthermore, every category trivially can be turned into a Cap
category, so HomR-fprespA, Bq is also a Cap category. The primitive CokernelObject can now be regarded as a
Cap functor</p>
      </sec>
      <sec id="sec-3-7">
        <title>CokernelObject : HomR-fprespA, Bq Ñ R-fpres</title>
        <p>whose action on morphisms CokernelObjectpM</p>
      </sec>
      <sec id="sec-3-8">
        <title>M 1q is given by</title>
      </sec>
      <sec id="sec-3-9">
        <title>CokernelObjectpM q</title>
      </sec>
      <sec id="sec-3-10">
        <title>CokernelColiftpM, CokernelProjectionpM 1qq</title>
      </sec>
      <sec id="sec-3-11">
        <title>CokernelObjectpM 1q.</title>
        <p>It is well-defined since it respects composition and identities up to congruence and thus defines a Cap functor.</p>
        <p>Problems similar to the issues with the cokernel arise when we want to deal with other categorical
constructions, like kernels, pullbacks, or pushout, and the Cap category R-fpres provides a natural solution for all
them.</p>
        <p>Remark 3.5. In Example 3.4 we described concrete constructions for the three primitives</p>
        <p>CokernelObject, CokernelProjection, CokernelColift
in a particular model of the category of finitely presented modules over a computable ring R. As we have seen
in Example 2.3, from these primitives we can derive a generic algorithm for the primitive CokernelFunctorial.
The core system of Cap offers various such automatic derivations, which come in handy in the implementation
of concrete instances of categories. However, note that whenever performance is crucial, it is wise to substitute a
primitive with a faster non-generic algorithm that might take advantage of attributes specific to the computational
model in question.</p>
        <p>Remark 3.6. The category of finitely presented modules can be seen as a special instance of the so-called Freyd
category, which first appeared in [Fre66]. For a given additive category P, its Freyd category ApPq can be
constructed as a certain quotient category of the category of arrows in P. The process of forming the Freyd
category can be seen as a category constructor, it takes an additive category as input and constructs an additive
category with cokernels as output:</p>
        <p>additive categories AÝpÑq additive categories with cokernels
If we apply this category constructor to RowsR, i.e., the full subcategory of left R-modules generated by row
modules R1 n for n P N0, we get the Cap category of finitely presented modules as output as it is modeled in
Example 3.4.</p>
        <p>The power of this abstraction lies in the fact that we can apply the category constructor Ap q not only to
RowsR, but to any additive category, in particular to ApRowsRq itself. One can show that ApApRowsRqq is
equivalent to the category of contravariant finitely presented functors on R-fpmod, i.e., contravariant functors
mapping from R-fpmod to the category of abelian groups that arise as cokernels of natural transformations
between representable functors. Thus, a proper implementation of the category constructor Ap q in Cap enables
us to work computationally with such functors. For a detailed discussion of the constructive aspects of Freyd
categories we refer the reader to [Pos17a].</p>
        <p>Acknowledgements
Sebastian Gutsche and Sebastian Posur are supported by Deutsche Forschungsgemeinschaft (DFG) grant
SFBTRR 195: Symbolic Tools in Mathematics and their Application.
[BLH11] Mohamed Barakat and Markus Lange-Hegermann, An axiomatic setup for algorithmic
homological algebra and an alternative approach to localization, J. Algebra Appl. 10 (2011), no. 2, 269–293,
(arXiv:1003.1943). MR 2795737 (2012f:18022)</p>
      </sec>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [Fre66]
          <string-name>
            <given-names>Peter</given-names>
            <surname>Freyd</surname>
          </string-name>
          ,
          <article-title>Representations in abelian categories</article-title>
          ,
          <source>Proc. Conf</source>
          . Categorical
          <string-name>
            <surname>Algebra (La Jolla</surname>
          </string-name>
          , Calif.,
          <year>1965</year>
          ), Springer, New York,
          <year>1966</year>
          , pp.
          <fpage>95</fpage>
          -
          <lpage>120</lpage>
          . MR 0209333
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [GAP18] The GAP Group, GAP - Groups, Algorithms, and Programming,
          <source>Version 4.9.1</source>
          ,
          <year>2018</year>
          , (http://www. gap-system.
          <source>org).</source>
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [GSP18]
          <string-name>
            <given-names>Sebastian</given-names>
            <surname>Gutsche</surname>
          </string-name>
          , Øystein Skartsaeterhagen, and
          <string-name>
            <given-names>Sebastian</given-names>
            <surname>Posur</surname>
          </string-name>
          ,
          <source>The CAP project - Categories</source>
          , Algorithms, Programming, (http://homalg-project.
          <source>github.io/CAP_project)</source>
          ,
          <fpage>2013</fpage>
          -
          <lpage>2018</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [Gut17]
          <string-name>
            <given-names>Sebastian</given-names>
            <surname>Gutsche</surname>
          </string-name>
          ,
          <article-title>Constructive category theory and applications to algebraic geometry</article-title>
          ,
          <source>Ph.D. thesis</source>
          , University of Siegen,
          <year>2017</year>
          , (http://dokumentix.ub.uni-siegen.de/opus/volltexte/2017/1241/).
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [hom17]
          <article-title>homalg project authors</article-title>
          ,
          <source>The homalg project - Algorithmic Homological Algebra</source>
          , (http:// homalg-project.
          <source>github.io)</source>
          ,
          <fpage>2003</fpage>
          -
          <lpage>2017</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          <string-name>
            <surname>[Pos17a] Sebastian</surname>
            <given-names>Posur</given-names>
          </string-name>
          , (arXiv:
          <fpage>1712</fpage>
          .03492).
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          <string-name>
            <surname>ArXiv</surname>
          </string-name>
          e-prints (
          <year>2017</year>
          ),
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [Pos17b]
          <string-name>
            <given-names>Sebastian</given-names>
            <surname>Posur</surname>
          </string-name>
          ,
          <article-title>Constructive category theory and applications to equivariant sheaves</article-title>
          ,
          <source>Ph.D. thesis</source>
          , University of Siegen,
          <year>2017</year>
          , (http://dokumentix.ub.uni-siegen.de/opus/volltexte/2017/1179/).
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          <string-name>
            <surname>[Wei94] Charles</surname>
            <given-names>A.</given-names>
          </string-name>
          <string-name>
            <surname>Weibel</surname>
          </string-name>
          ,
          <article-title>An introduction to homological algebra</article-title>
          , Cambridge Studies in Advanced Mathematics, Cambridge University Press,
          <year>1994</year>
          . MR MR1269324 (
          <year>95f</year>
          :
          <fpage>18001</fpage>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>