<!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>Realizability Models and Complexity Classes</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Eugenio Moggi</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>DIBRIS</institution>
          ,
          <addr-line>Genova Univ., v. Dodecaneso 35, 16146 Genova</addr-line>
          ,
          <country country="IT">Italy</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>Realizability models allow to define categories with very rich mathematical structure starting from untyped computational models, typically partial Combinatory Algebras (pCAs). We propose a generalization of realizability models, in which pCAs are replaced by monoids of maps (on a set of data), which allow to consider also restricted computational models, where complexity constrains can be taken into account (e.g., the monoid of maps on bit strings computable in linear time). We give some examples of monoids (on bit strings) based on complexity classes, and state how the mathematical structure of these categories relates to properties of the corresponding monoid.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;Realizability models</kwd>
        <kwd>Category theory</kwd>
        <kwd>Complexity theory</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>
        This communication is related to a journal submission, which proposes categories where one can
interpret calculi for collection types (aka bulk types), like those in [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]. These calculi provide a framework
for database query languages that go beyond traditional relational database, and have a lot in common
with metalanguages for computational types [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ], but there are also important diferences
• Equality of collections is decidable, and can be added as an operation with a boolean result, while
equality of programs is undecidable;
• Functional types and recursive definitions are available in most programming languages, but
they are unacceptable in database languages, since they are incompatible with decidable equality.
Calculi for collection types are interpreted in categories with finite products, and collection types are
interpreted by strong monads. In [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] Manes identifies certain finitary monads on the category S of
sets, called collection monads, as an appropriate semantics for collection types. These monads have a
well-behaved notion of membership, and collections have only finitely many members.
In the journal submission we propose to replace the category S of sets with (small) lextensive
subcategories  of S, whose arrows are maps computable by low complexity algorithms, e.g., working in
linear or polynomial time. In this communication we report only some results, that could be of interest
also for researchers focused on Complexity Theory, namely:
• The construction of categories associated to a monoid  of (total) maps on a set  (of data).
• Very weak conditions on  implying that the associated categories are lextensive and have a
lextensive faithful global section functor into S.
• More stringent conditions on  implying that the associated categories have a NNO (Natural
Number Object) N and a list monad L, i.e., a strong monad mapping an object  to the free
monoid over  .
      </p>
      <p>
        Realizability Models and Complexity Theory. The way realizability models use Category Theory
in relation to Computability Theory works as follows: 1) one starts from a computational model,
typically a pCA (, · ), where the elements of  can be interpreted as data or programs and the binary
application  ·  (when defined) returns the output produced by executing program  with input ;
2) then one defines a category  using the pCA; 3) and finally one studies how category-theoretic
properties of  relate to properties of the pCA. The seminal example of this approach is in [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ], where
Hyland defines the Efective topos using Kleene’s first applicative structure, and then studies this topos
and several of its sub-categories. In Complexity Theory the main focus is on complexity classes, i.e., sets
 of maps (or predicates) on a set  (e.g., the set of strings * on an alphabet), while computational
models play an ancillary role. Therefore, we consider a variant of realizability models, where the starting
point is a sub-monoid  of  →  (i.e.,  contains the identity on  and is closed under composition).
      </p>
    </sec>
    <sec id="sec-2">
      <title>2. Lextensive Categories</title>
      <p>
        Lextensive categories have finite limits (in particular products) and well-behaved finite sums, where the
definition of well-behaved is formalized by the notion of extensive category (see [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]). A lextensive functor
is a functor between lextensive categories preserving finite limits and finite sums, and a lextensive
sub-category is a sub-category whose inclusion functor is lextensive. We use also the terminology lex
category for a category with finite limits, and similarly for lex functor and lex sub-category.
From any (locally small) category  with a terminal object 1 (i.e., the product of zero objects) one can
define the global section functor Γ =Δ (1, − ):  &gt; S to the category of sets. Such functor preserves
all small limits existing in . We are mainly interested in lextensive categories such that Γ is faithful
and lextensive. The following result gives suficient conditions on  to have such a property.
Theorem 2.1. If  is lextensive, non-trivial (i.e., 0 ≁= 1) and has enough points (i.e., Γ is faithful), then
Γ:  &gt; S is lextensive, moreover the action Γ: (,  ) &gt; S(Γ, Γ ) of Γ on each hom-set is
bijective when  is a finite sum of 1s.
      </p>
      <p>The theorem above implies that a  satisfying the assumption is (equivalent to) a lextensive sub-category
of S, which contains the category S of finite sets as a full lextensive sub-category.</p>
      <p>The rational for considering lextensive categories is that in them one can define
• an object of booleans, namely 2 =Δ 1 + 1
• decidable predicates1 on an object , i.e., arrows  &gt; 2
• when an object  has a decidable equality, i.e., a (necessarily unique) arrow :  ×  &gt; 2
classifying the diagonal sub-object  ⊂ &gt;  × .</p>
      <p>In a lextensive category  some objects may not have a decidable equality, The following constructions
define lextensive full sub-categories of , where all objects have a decidable equality.
Theorem 2.2. If  is lextensive, let  be the full sub-category of the objects  ∈  with a decidable
equality, then  is a lextensive sub-category of .</p>
      <p>Theorem 2.3. If  is lextensive and  ∈  has a decidable equality and the objects 1,  +  and  × 
are retracts of , let P[] be the full sub-category of  consisting of the decidable sub-objects2 of , then
P[] is a lextensive sub-category of .</p>
      <p>In a lextensive category, where all objects have a decidable equality, one can interpret a typed language,
where the BNF for types is  : : =  | 0 | 1 |  1 +  2 |  1 *  2 | {:  |}, with  base type and 
boolean formula (or equivalently a term of type 1 + 1). A possible BNF for boolean formulas is
: : = ⊤ | 1 = 2 | 1 ∧ 2 | ¬, with 1 and 2 terms of the same type. Note that the last clause
{:  |} in the BNF for types means that the language has dependent types.</p>
      <sec id="sec-2-1">
        <title>1This notion of decidability is not related to that in Computability Theory.</title>
        <p>2Alternatively decidable predicates on .</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>3. Category of Assemblies &amp; co.</title>
      <p>
        We introduce the category of assemblies A[] for a sub-monoid  of the monoid  →  of total
maps on a set , and some of its full sub-categories. The aim is to provide realizability-like models for
low-complexity Domain Specific Languages (DSL), where  is the set of data manipulated by programs
in the DSL, and  are the maps computed by such programs. The idea (following [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ]) is to replace
application with composition and to abstract from programs in favor of functions, in order to achieve
greater flexibility over realizability models based on pCA, like the Efective topos [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. The definition of
A[], given below, is an instance of a construction in [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ] based on computability structures.
Definition 3.1 (Assemblies). The category A[] of -assemblies is defined as follows
• an object  is a pair (||, ⊢ ) with || set and ⊢ ⊆  × | | surjective, i.e., ∀ ∈ ||.∃ ∈
. ⊢ ; a  s.t.  ⊢  is called an encoding of .
• an arrow  :  &gt;  is a map  : || → | | s.t.  ⊢  =⇒  ′() ⊢  () for some  ′ ∈ 
called a realizer of  (notation  ′ ⊢  ).
      </p>
      <p>The faithful forgetful functor  from A[] to S maps  to ||.</p>
      <p>
        Remark 3.2. If  is a sub-monoid of  → , then one can define a computability structure C with
one datatype  and the set of relations C(, ) consisting of the graphs of maps in . In this way
A[] coincides with the category of assemblies for the computability structure C [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]. If (, · ) is a (total)
Combinatory Algebra (CA), let  be the set of computed maps on  (i.e., the  s.t.  () =  ·  for
some  ∈ ), then  is a sub-monoid of  → , and the category of -assemblies coincides with
the category of assemblies for the CA (, · ). More generally, if (, · ) is an applicative structure with
identity and composition combinators, then the set of computed maps is a sub-monoid of  → .
We now give some examples of  (and ) that do not arise from a CA.
      </p>
      <p>Example 3.3. Examples of monoids on the set N of natural numbers are:
1. the set TR of total recursive maps
2. the set PR of primitive recursive maps
3. the set E of maps in the -th level of Grzegorczyk hierarchy.</p>
      <p>The following inclusions hold: E ⊂ E+1 ⊂ ⋃︀ E = PR ⊂ TR. E3 coincides with the set of Kalmar
elementary maps, that are defined without using bounded recursion.</p>
      <p>
        Before giving examples of monoids on the set * of bit-strings, where  = {0, 1}, we recall some
notions and results from Computational Complexity (see [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ])3. We consider three types of complexity
classes: output (size), time and space.
      </p>
      <p>Definition 3.4. If  : * → * and : N → N (monotone and ≥ 1), then</p>
      <p>Δ
1.  ∈   () ⇐⇒ the map  ↦→ max||≤  | ()| is in ()</p>
      <p>Δ
2.  ∈   () ⇐⇒ there is a TM computing  and working in time ()</p>
      <p>Δ
3.  ∈  () ⇐⇒ there is a TM computing  and working in space ()4.
3We assume that a TM  computing a partial map on * has one read-only input tape (where the input is written before the
computation starts), one write-only output tape (where the output is written before the end of the computation), several
working tapes (on which  may use symbols from a larger alphabet  ⊇ ).
4For space complexity only the cells on working tapes used in the computation count, the cells on the read-only input tape
and the write-only output tape are ignored.</p>
      <p>LO =   ()
⊃</p>
      <p>LS =  () ∩ LO
⊃</p>
      <p>LT =   ()</p>
      <p>The output classes contain also non-computable maps, but they are useful in combination with the
classes defined in terms of Turing Machines. For instance, the class   () is not closed under
composition when  &gt; 1, while   () ∩   () is a sub-monoid of * → * .
We recall well-known inclusions between diferent types of complexity classes (see [8, Thm 9.4]):
  () ⊆  () ∩   () and  () ⊆
⋃︁   ( * ())
&gt;0
Lemma 3.5. If all maps , , : N → N are monotone, then the following hold:
1. If  ∈   () for  = 1, 2, then ∃ &gt; 0.2 ∘ 1 ∈   (2( * 1())).
2. If  ∈   () ∩   () for  = 1, 2, then</p>
      <p>∃ &gt; 0.2 ∘ 1 ∈   (1() + 1() + 2( * 1())).
3. If  ∈  () ∩   () for  = 1, 2, then</p>
      <p>∃ &gt; 0.2 ∘ 1 ∈  (1() + log 1() + 2( * 1())).</p>
      <p>Example 3.6. By Lemma 3.5, the subsets in Figure 1 are sub-monoids of * → * .
We consider two remarkable full sub-categories of A[]: M[] of modest sets and P[] of predicates.
Definition 3.7 (Special assemblies).</p>
      <p>Given an assembly  ∈ A[] we say that
Δ
1.  is a modest set ( ∈ M[]) ⇐⇒ ⊢ is the graph of a partial surjective map from  to | |.</p>
      <p>Δ
2.  is a predicate ( ∈ P[]) ⇐⇒ | | ⊆  and ⊢ is the identity relation Δ|| on | |.
M[] is replete (i.e., an assembly isomorphic in A[] to a modest set is a modest set) and essentially
small, because it is equivalent to the small category of PERs (Partial Equivalence Relations) on . P[]
is small, but not replete. However, one can modify the definition of P[] to make it replete.
The following properties of  imply that A[], M[] and P[] satisfy the assumptions of Thm 2.1.
Definition 3.8. Given a sub-monoid  ⊆  →  we consider the properties:
K  has at least two elements (say 0 and 1) and  : . ∈  for every  ∈ 
P there is a map : 2 →  and two maps 0, 1 ∈  s.t.</p>
      <p>• ((0, 1)) =  for every 0, 1 ∈ 
•  : .(0, 1) ∈  for every 0, 1 ∈ 
E there is a map  ∈  s.t. (((0, 1), (2, 3))) = (2 if 0 = 1 else 3).</p>
      <p>Property (P), i.e., encoding of pairs, is needed to express (E), i.e., equality testing; (K) and (P) implies
that  is infinite. All monoids in Examples 3.3 and 3.6 satisfy properties (K,P,E).</p>
      <p>Theorem 3.9. If a sub-monoid  ⊆  →  has properties (K,P,E), then:
1. A[], M[] and P[] are lextensive categories, and Γ is lextensive.
2. In P[] every object has a decidable equality.
3. The forgetful functor  : A[] &gt; S is isomorphic to Γ.</p>
      <p>4. A map  is epi in A[] (M[] or P[]) ⇐⇒ Γ is epi in S.</p>
      <p>When  ̸= ∅, the following relations among categories hold, where  ⊣  means “F left-adjoint to ”
Moreover, under the assumptions of Theorem 3.9, one has the following lextensive functors, where S
is the category of countable sets. Moreover, P[] and M[] are equivalnet to S when  =  → 
with  countable.</p>
      <p>&gt; S ⊂
S ⊂
∩
∨
P[] ⊂
&gt; S
∧

&gt; M[] ⊂
&gt; A[]
If  has finite products, then one can ask whether  has a NNO 1 &gt;  &gt;  or a list monad L,
given by the adjuntion between  and the category of monoids in  (in this case L1 is a NNO).
0

Theorem 3.10. If a sub-monoid  ⊆  →  has properties (K,P,E) and is closed under primitive
recursion, then A[], M[] and P[] have a parametric NNO and a strong list monad L.
Among the monoids in Example 3.3 and 3.6 only TR and PR are closed under primitive recursion, in all
other cases the category A[] (M[] and P[]) fails to have a NNO (and consequently a list monad).
A lex sub-category  of S may have a NNO-structure 1 0 &gt;   &gt;  , which does not have the
universal property of a NNO in , but it does in S. In this case we say that the structure behaves
like a NNO. Similarly, we say that a (strong) monad L on  behaves like a list monad, when it is the
restriction of a list monad on S. Since structures satisfying a universal property are unique up to
(unique) isomorphism, NNO-structures in  that behave like a NNO are isomorphic in S, but may fail
to be isomorphic in . However, some of these unique isomorphisms in S are morphisms in , thus
these structures form a preorder. For instance, in P[], where  is any of the monoids in Figure 1, the
unary and binary encodings, N1 and N2, of the natural numbers behave like a NNO. However, only the
isomorphism from N1 to N2 in S is a morphism also in P[].</p>
      <p>It is relatively easy to prove (basically an encoding exercise), that for all  in Examples 3.3 and 3.6 the
category A[] (M[] and P[]) have structures that behave like a NNO and like a list monad, with the
caveat that for the monoid LO and its sub-monoid LS and LT, the obvious monad L behaving like a list
monad is not strong, i.e., it does not have a tensorial strength 1 × L(2) &gt; L(1 × 2).
Declaration on Generative AI</p>
      <sec id="sec-3-1">
        <title>The author have not employed any Generative AI tools. (1) (2)</title>
      </sec>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>P.</given-names>
            <surname>Buneman</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S. A.</given-names>
            <surname>Naqvi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V.</given-names>
            <surname>Tannen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Wong</surname>
          </string-name>
          ,
          <article-title>Principles of Programming with Complex Objects and Collection Types</article-title>
          ,
          <source>Theoretical Computer Science</source>
          <volume>149</volume>
          (
          <year>1995</year>
          )
          <fpage>3</fpage>
          -
          <lpage>48</lpage>
          . doi:
          <volume>10</volume>
          .1016/
          <fpage>0304</fpage>
          -
          <lpage>3975</lpage>
          (
          <issue>95</issue>
          )
          <fpage>00024</fpage>
          -
          <lpage>Q</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>E.</given-names>
            <surname>Moggi</surname>
          </string-name>
          ,
          <source>Notions of Computation and Monads, Information and Computation/information and Control</source>
          <volume>93</volume>
          (
          <year>1991</year>
          )
          <fpage>55</fpage>
          -
          <lpage>92</lpage>
          . doi:
          <volume>10</volume>
          .1016/
          <fpage>0890</fpage>
          -
          <lpage>5401</lpage>
          (
          <issue>91</issue>
          )
          <fpage>90052</fpage>
          -
          <lpage>4</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>E. G.</given-names>
            <surname>Manes</surname>
          </string-name>
          ,
          <article-title>Implementing Collection Classes with Monads</article-title>
          ,
          <source>Mathematical Structures in Computer Science</source>
          <volume>8</volume>
          (
          <year>1998</year>
          )
          <fpage>231</fpage>
          -
          <lpage>276</lpage>
          . doi:
          <volume>10</volume>
          .1017/S0960129598002515.
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <surname>J. M. E. Hyland,</surname>
          </string-name>
          <article-title>The efective topos</article-title>
          ,
          <source>in: Studies in Logic and the Foundations of Mathematics</source>
          , volume
          <volume>110</volume>
          ,
          <string-name>
            <surname>Elsevier</surname>
          </string-name>
          ,
          <year>1982</year>
          , pp.
          <fpage>165</fpage>
          -
          <lpage>216</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>A.</given-names>
            <surname>Carboni</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Lack</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Walters</surname>
          </string-name>
          ,
          <article-title>Introduction to extensive and distributive categories</article-title>
          ,
          <source>Journal of Pure and Applied Algebra</source>
          <volume>84</volume>
          (
          <year>1993</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>D. S.</given-names>
            <surname>Scott</surname>
          </string-name>
          ,
          <article-title>Relating theories of the lambda calculus</article-title>
          , To HB Curry:
          <article-title>Essays on combinatory logic, lambda calculus and formalism (</article-title>
          <year>1980</year>
          )
          <fpage>403</fpage>
          -
          <lpage>450</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>J.</given-names>
            <surname>Longley</surname>
          </string-name>
          ,
          <article-title>Computability structures, simulations and realizability</article-title>
          ,
          <source>Mathematical Structures in Computer Science</source>
          <volume>24</volume>
          (
          <year>2014</year>
          )
          <article-title>e240201</article-title>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>C. H.</given-names>
            <surname>Papadimitriou</surname>
          </string-name>
          , Computational Complexity, Addison Wesley,
          <year>1994</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>