Integration of the Kenzo System within SageMath for New Algebraic Topology Computations

This work integrates the Kenzo system within Sagemath as an interface and an optional package. Our work makes it possible to communicate both computer algebra programs and it enhances the SageMath system with new capabilities in algebraic topology, such as the computation of homotopy groups and some kind of spectral sequences, dealing in particular with simplicial objects of an infinite nature. The new interface allows computing homotopy groups that were not


Introduction
Computational algebraic topology is an active area of research in mathematics with numerous applications in different fields, ranging from data analysis [1] to image processing [2]. There exist several programs specialized in algebraic topology computations, such as ChomP [3], Perseus [4], and Javaplex [5]. Such programs are mainly focused on computing topological invariants of finite spaces (by finite, we mean complexes with a finite number of generators in each degree).
Effective homology is a technique developed by Sergeraert [6] which permits carrying out some kinds of computations over infinite structures, via a homotopy equivalence between chain complexes. Kenzo [7] is a computer algebra system that implements several algorithms to compute the homology of infinite structures using effective homology. Infinite spaces can arise in different areas of algebraic topology, for instance when loop spaces or Eilenberg-MacLane spaces are involved. In addition, it also permits one to compute algorithmically homotopy groups combining the Whitehead tower method [8] and the effective homology technique, although it is restricted to 1-reduced simplicial sets. In particular, let us remark that the Whitehead tower method requires the construction of infinite Eilenberg-MacLane spaces. As far as we know, Kenzo is the only program that is able to carry out this kind of computation over infinite structures, which makes it a powerful software. Indeed, Kenzo has obtained some results which had never been determined before [9]. However, it lacks a friendly interface and its use demands a deep knowledge on the Common Lisp programming language, which can be considered tedious. Moreover, the last official Kenzo release is specifically written in Allegro Common Lisp, and it is not fully compatible with other Common Lisp dialects. There exist additional modules for computing other algebraic topology structures such as spectral sequences, pushouts, or discrete vector fields but they are available only in the personal websites of the authors, usually for different outdated Kenzo versions, so that their installation is not simple. Thus, the community around Kenzo is rather small and its features remain unknown for many researchers in algebraic topology. The germ of this work was presented at conference papers [13,14] (the second one was distinguished with the Best Software Demonstration Award). At that point, the interface was very basic and only homology groups were computed. Now, the work has vastly been improved by adding new functionalities and computations: • Computation of the join of two simplicial sets, wedges, smash products, homotopy groups, spectral sequences, and finite topological spaces; • Connection between chain complexes, simplicial sets, and morphisms of chain complexes; • Improvements and fixes of serious flaws in external packages, which caused erroneous calculations; • Integration of an algorithm to compute homotopy groups of simply connected (not 1-reduced) simplicial sets from Kenzo to our interface, in order to be able to use it from Sagemath; • Presentation of some examples of computations combining both systems by means of the interface. That is, the interface allows us to carry out computations that would not be possible using Kenzo and SageMath separately; • We even show how we computed homotopy groups that were not known before.
The rest of the paper is organized as follows. In Section 2 both the Kenzo system and the effective homology theory are introduced. The SageMath features about algebraic topology are explained in detail in Section 3. The interface that we developed is explained in Section 4, showing computations involving both systems. In Section 5, we present how Kenzo computes homotopy groups, its integration within SageMath and, as an application of our work, the discovering of new homotopy groups. In Section 6, we explain the integration of some Kenzo external modules. Finally, Section 7 presents the conclusions and further work.

Effective Homology Theory and the Kenzo System
Kenzo [7] is a symbolic computation system devoted to algebraic topology. It was originally written in 1990 by Sergeraert and Rubio, under the name of EAT (Effective Algebraic Topology) [15]. In 1998 it was rewritten by Sergeraert and Dousson, with the current name of Kenzo. The last available version dates from 2008, but there exists a fork maintained by Heber with compatibility improvements and bugfixes [16].
The topological spaces considered in Kenzo are represented by means of simplicial sets (see [17] for definitions). The main feature of Kenzo is its ability to work with spaces of an infinite nature. To this aim, it uses the Common Lisp programming language and makes an intensive use of functional programming. The program allows in particular the computation of homology and homotopy groups of complicated spaces, for instance, iterated loop spaces of a loop space modified by a cell attachment, components of complex Postnikov towers, etc., which were not known before [9]. Homology and homotopy groups of infinite spaces are computed in Kenzo by means of the effective homology method, introduced in [6] and deeply explained in [9].
The effective homology method is based on the notion of reduction between two chain complexes C * and D * , denoted C * ⇒ ⇒ D * , which is given by three maps f : C * → D * , g : D * → C * , and h : C * → C * +1 satisfying some special properties (see [9] for details) such that the homology groups of C * and D * are canonically isomorphic. A homotopy equivalence in Kenzo, denoted C * ⇐ ⇐ ⇒ ⇒ D * , is a pair of reductions C * ⇐ ⇐Ĉ * ⇒ ⇒ D * (again, a canonical isomorphism H * (C) ∼ = H * (D) is obtained). When an object (for instance, a simplicial set) X is built in Kenzo, an equivalence C * (X) ⇐ ⇐ ⇒ ⇒ E * is automatically constructed, where C * (X) is the chain complex associated with X and E * is a chain complex of finite type (that is, finitely generated in each degree), so that the homology groups of E * can be determined by means of elementary operations on matrices. In this way, the homology groups of the object X, which can be of an infinite nature, can be obtained thanks to the isomorphism H * (X) ∼ = H * (C * (X)) ∼ = H * (E). Let us consider as a didactical example the "minimal" simplicial model of the Eilenberg-MacLane space K(Z, 1) (see [17]), defined by K(Z, 1) n = Z n , and constructed in Kenzo as follows.
> ( setf kz1 ( k-z 1)) [ K1 A b e l i a n -S i m p l i c i a l -G r o u p ] Let us observe the Common Lisp syntax, where the function setf is used to store in the variable kz1 the result of the function (k-z 1). The Kenzo function k-z receives an integer n (in our example, 1) and returns the Eilenberg-MacLane space K(Z, n).
The abelian simplicial group K(Z, 1) has an infinite number of simplices in every dimension ≥ 1, so that the homology groups of kz1 cannot be elementarily computed. But the effective homology of this object, automatically computed by Kenzo and stored in the slot efhm, is an equivalence with the circle: In this way, the homology groups of K(Z, 1) are computable through the finite equivalent object K 16 : The technique that Kenzo uses to produce automatically the effective homology of an object is based on the following ideas. If an object is of finite type, its effective homology is trivial. For some "primitive" spaces, there are theoretical results that give explicitely an equivalence with a chain complex of finite type (this is the case of the Eilenberg-MacLane space K(Z, 1), which is known to have the same homotopy type of the circle S 1 ). Moreover, for several topological constructions such as twisted cartesian products, tensor products, loop spaces, etc, the effective homology of the constructed object is determined from the effective homology of the initial spaces. In this way, we can construct recursively the effective homology of every space which can be obtained by applying the different algebraic topology constructions available in Kenzo to the primitive cases.
The computation of homotopy groups is dealt in Kenzo by means of the Whitehead tower method [8] (see Section 5 for the description of this algorithm), and it requires the construction of a sequence of fibrations involving spaces of infinite type. As an example, let us consider the Kenzo construction of the Whitehead tower for the computation of the (well-known) result π 6 (S 3 ) ∼ = Z/12Z. > ( progn ( setf X ( sphere 3)) ( setf k3 ( chml-clss X 3)) ( setf t3 ( z-whitehead X k3 )) ( setf X4 ( fibration-total t3 )) ( setf k4 ( chml-clss X4 4)) ( setf t4 ( z2-whitehead X4 k4 )) ( setf X5 ( fibration-total t4 )) ( setf k5 ( chml-clss X5 5)) ( setf t5 ( z2-whitehead X5 k5 )) ( setf X6 ( fibration-total t5 )) ( homology X6 6)) Homology in dimension 6: Component Z /12 Z ---done---Despite being the only program for algebraic topology able to carry out computations over infinite structures, the main problem of the Kenzo system is that it requires the use of a Common Lisp IDE and the user should be familiarized with functional programming, as has been seen with the previous examples. Furthermore, Kenzo has been enhanced by several authors with additional modules which are available on the personal websites of the authors, but there is not a stable version including these modules and their installation is not simple. In particular, there exists a module which automatizes the construction of the Whitehead tower of fibrations for the computation of homotopy groups using only one function [18]. In addition, there exists another module computing spectral sequences [19], a useful tool of algebraic topology which in general is not constructive. This module can be applied to determine spectral sequences associated with filtered complexes of infinite type and makes it possible to determine Serre and Eilenberg-Moore spectral sequences associated with fibrations when versions with effective homology are known for the initial spaces. Recently, a new Kenzo module has been developed for computing homotopical invariants of finite topological spaces [20], which can be considered a model for a wide variety of topological spaces.

SageMath and Algebraic Topology
SageMath includes modules for constructing and computing properties of topological objects in different flavors: Graphs, knots, braids, manifolds, and algebraic varieties. In particular, some of them overlap with the scope of Kenzo: Chain complexes and simplicial sets. In this section we will oversee a quick survey of the related capabilities.

Chain Complexes
SageMath supports finite chain complexes graded over a free abelian group. The graded parts of the complex may be free modules over a commutative ring. They can be created by providing the data that defines them in different formats. The simplest ones are either a dictionary with the differential matrices indexed by the elements of the grading group: Note that, in the last example, since the base ring is the field of two elements, the matrices are converted accordingly.
By default, the grading group is Z and the degree of the differential is 1. But we can specify a different one: Once a chain complex has been created, we can compute its homology: sage : C . homology (0) Z x Z sage : C . homology (1) Z x C3 sage : C . homology (2) 0

Simplicial Sets
Simplicial sets with finitely many simplices in each dimension can be created in SageMath either from a library, by applying operations to existing ones, or giving explicitly the non-degenerate simplices and their boundaries. For example, three ways to create the 2-sphere are: The library provides functions to construct some specific cases including classifying spaces, projective spaces (both real and complex), spheres, or the Klein bottle among others: sage : P2 = simplicial_sets . Co mpl ex Pro jec ti veS pa ce (2); P2 CP^2 Moreover, simplicial sets can be created from simplicial complexes or delta complexes, of which SageMath also has a predefined library: sage : from s a g e . homology . simplicial_set import SimplicialSet sage : S3 = simplicial_ c o m p l e x es . BarnetteSphere (); S3 Barnette's triangulation of the 3 -sphere sage : KS3 = SimplicialSet ( S3 ); KS3 Simplicial set with 92 non -degenerate simplices Some operations can be used to create new simplicial sets from existing ones, such as the cartesian product, wedge, smash, cone, and suspension. They are all implemented as methods that return a new simplicial set however, the returned object has some extra structure that "remembers" the fact that it was constructed from other pieces, so the different computations of properties and invariants are derived from the ones on the pieces: Several invariants and properties of simplicial sets can be computed by specific methods. Some of the most relevant ones are the underlying chain complex, homology, cohomology (both the cohomology groups and the ring structure), fundamental group, and the algebraic topological model: As we can see, SageMath is quite powerful at computing invariants and properties of simplicial sets. However, it is restricted to simplicial sets with a finite number of simplices in each dimension.

The SageMath-Kenzo Interface
In this section we present the optional package to install Kenzo within SageMath and the basics of the interface that connects both systems. The following sections will provide further details on the external packages that we have incorporated and the features.
Our Kenzo package for SageMath is based on the Kenzo version by Heber [16], which is an adapted version of the original Kenzo, but includes improvements to make it compatible with any Common Lisp system. We make it easy to install our Kenzo optional package in SageMath, simply by running: sage -i kenzo This command will download the source code of a fork of Heber's version of Kenzo that we maintain for this specific purpose, compile it inside the ECL interpreter that SageMath includes, and install it. Allegedly, this can be an easy way to install Kenzo even if we just plan to use it as a standalone program. More concretely, we can use Kenzo with an ECL session via the command sage -ecl. This way, we could use Kenzo as usual, i.e., by means of Lisp commands.
This Kenzo optional package can also be used within a SageMath session via the EclObject and ecl_eval functions, which are a wrapper around ECL objects and a function that evaluates a string in Lisp and returns the result, respectively. For instance, the following commands load Kenzo and define the Eilenberg-MacLane space K(Z, 3) by means of Lisp commands evaluated with ecl_eval in a SageMath session.
sage : from s a g e . libs . ecl import ecl_eval sage : ecl_eval ( " ( require : kenzo ) " ) sage : ecl_eval ( " ( in -package #: cat ) " ) sage : ecl_eval ( " ( setf K (k -z 3)) " ) < ECL : [ K25 Abelian -Simplicial -Group ] > In the previous example, the execution is carried out in Kenzo via the ECL library, but there is no proper connection to SageMath classes. In addition, this embedding of Kenzo within SageMath does not ease its use: The same Lisp syntax and Kenzo specific commands must be used.
Thus, we decided to develop an interface to communicate both systems. The interface is a Python file that we include in the SageMath distribution. This interface automatically loads Kenzo inside the ECL library, which is itself loaded as a C-library in SageMath. This way, the communication between both systems is done via a C-library interface. It is worth noting that there exist other alternatives to connect both systems, such as pseudoterminals or temporary files, but a C-library interface has a much lower overhead than them. Moreover, the interface provides functions to create Kenzo objects, and wrappers around them that allow one to create new objects (with the corresponding wrapper) and call functions on them. When it makes sense, the output of those functions is converted to the corresponding SageMath object.
The initial prototype of the interface was available in the SageMath distribution from version 8.7 and included some basic functionalities. In particular, this interface exposed functions to create spheres, Eilenberg-MacLane spaces, and Moore spaces. From these spaces, it allowed the construction of cartesian products, classifying spaces, suspensions, loop spaces, and tensor products. In addition, for each resulting space, the homology method can construct the corresponding homology groups.
From SageMath version 9.2, the package and the interface have been enhanced by adding some new functionalities. For instance, we have included some existing external modules of Kenzo that allow computing homotopy groups of 1-reduced simplicial sets (by using the Whitehead tower method) and some spectral sequences. In addition, we have also provided methods for translating objects (such as chain complexes and simplicial sets) both from SageMath to Kenzo and vice versa. This permits one to build simplicial objects in SageMath, translate them into Kenzo, and compute their homology and homotopy groups. This new version also updates the Kenzo package to fix bugs detected in an external module, to include an algorithm to compute homotopy groups of not 1-reduced simplicial sets, and other features that are explained in detail in the following sections. Furthermore, we also integrate in SageMath, a recent Kenzo module [20] about finite topological spaces. This part of the work (which will be presented in Section 6.3) is not included in SageMath 9.2, but it is currently under review by the Sagemath developers to include in future releases.
Additionally, we provide a website that permits the use of SageMath and Kenzo with the new version of the interface, including the work about finite topological spaces, in an interactive environment. The website permits one to execute commands and explore outputs (https://mybinder.org/v2/gh/jodivaso/examples-sage-kenzo/master?filepath= examples.ipynb accessed on 24 March 2021).
After having reached this link, a standard Jupyter notebook is displayed with the new package enabled and ready for use. This way, the last version of the interface to connect SageMath and Kenzo can be used online with no need to install any software. Such a website also contains all the SageMath code examples presented in this section and the next two ones. The documentation of the new package is available in the official SageMath reference manual [21].
The interface loads Kenzo and disables the standard output. It defines new classes and methods, which are mainly wrappers of the Kenzo ones. By means of Python commands (and calls to the EclObject and ecl_eval operators) it computes instructions in Kenzo and provides the output as SageMath objects in a transparent way to the user. Figure 1 presents the class diagram of the interface. The main class is KenzoObject, which inherits from SageObject, and is a wrapper to a Kenzo object (which is an ECL object). The other classes provide specific methods for each type of object (some of them are incorporated to connect the interface to Kenzo external modules). For instance, the KenzoSimplicialSet class possesses a method homotopy_group, which computes the n-th homotopy group of the simplicial set (via a call to the corresponding function in a Kenzo external package, see Section 5) and prints the result. The method also returns the result as an object of the AbelianGroup class, which is part of SageMath. This way, the user could invoke any operation provided by the AbelianGroup class over such an object.
It is worth distinguishing between two types of mathematical objects. On the one hand, there are objects (which are necessarily finite) that can be represented in both SageMath and Kenzo. Thus, they can be translated from SageMath to Kenzo and vice versa. For some of these objects that are available in both Kenzo and SageMath, both systems use the same representation and then the translation between them is easy. This is the case of simplicial sets: An object of the SageMath class SimplicialSet can be translated to the wrapper class KenzoSimplicialSet defined in the interface via a conversion function called KFiniteSimplicialSet. Nevertheless, there are other structures such as chain complexes for which the representations in SageMath and Kenzo are different. As we have explained in Section 3, SageMath can construct a finite chain complex by means of either a dictionary with the differential matrices indexed by the elements of the grading group or, if the grading group is Z, just a list of matrices. However, the Kenzo representation of a finite chain complex consists of a function that provides a list of generators for each degree and the differential maps described also as a function. Thus, both representations share the same information (they represent the same finite chain complex), but in a different format and then a conversion function must be provided. When dealing with this case of different representations, our choice has been to implement the major part of the conversion in Lisp. This permits us to keep the interface as simple as possible and the connection is made via basic data types (integers, strings, lists, etc.). This choice means that the development of the interface has required one to code in both SageMath and Kenzo. In the case of finite chain complexes, we have implemented in Kenzo a function to construct a finite chain complex from a dictionary whose values are the differential matrices, i.e., following the same representation as SageMath uses. Then, the interface just presents the wrapper to such a function.
On the other hand, there are objects that are of an infinite nature, and thus only Kenzo is able to represent them. In this case, the object that represents an infinite space is directly created in SageMath as a wrapper of the corresponding Kenzo object.
For instance, we have defined a function which returns the Eilenberg-MacLane space K(π, n) as a Kenzo simplicial group, being π a cyclic group. To do that, we first define in the interface the corresponding ECL objects for K(Z, n), K(Z/2Z, n), and K(Z/pZ, n).
Then, those functions are used in the implementation of the wrapper function, which returns an object that belongs to the class KenzoSimplicialGroup. That is, the implementation in SageMath internally calls the functions in Kenzo. Let us note again that we have had to develop code for SageMath (the interface, the wrapper functions), as well as for Kenzo: New functions have been added and some existing ones have been adapted in order to make the output compatible with the interface and SageMath. For example, we have created functions in Kenzo to create finite simplicial sets from the corresponding SageMath objects: Finally, let us present an example of execution in SageMath via Kenzo involving infinite structures. As we have already said, some direct computations of the interface of Kenzo in SageMath include the construction of different elements of algebraic topology which are available in Kenzo such as spheres, Eilenberg-MacLane spaces, cartesian products, tensor products, loop spaces, etc. Although some of them can also be constructed in SageMath as explained in Section 3, Kenzo makes it possible to work with elements of infinite nature so that it is interesting to include these functions in SageMath. For example, we can construct the cartesian product of the Eilenberg-MacLane space K(Z/2Z, 2) and the loop space of the sphere S 3 and compute its homology groups as follows (the Python function range(n) returns the sequence of numbers (0, 1, . . . , n − 1)):  (8) Let us remark that the loop space of S 3 is not of finite type and then the space X is also of an infinite nature. Moreover, the loop space constructor is not available in SageMath. Kenzo is able to compute the homology groups of our space X using the effective homology technique explained in Section 2.

Homotopy Groups
The computation of homotopy groups of topological spaces is known to be one of the most challenging problems in the field of algebraic topology. As said in Section 2, making use of the effective homology technique and the Whitehead method [8], Kenzo is able to compute homotopy groups of 1-reduced simplicial sets by means of a tower of fibrations (following the algorithm in [22]). In the Kenzo external module [18], a function is provided which automatizes this construction and computes the homotopy group of a 1-reduced simplicial set for a given dimension. However, this external module is not able to work with spaces which are not 1-reduced. Moreover, we have found several bugs in this module in different situations. Taking into account that SageMath users could be interested in computing homotopy groups of spaces which are not 1-reduced, we have decided not only to include the external module [18] in our interface, but also to correct it and enhance it so that we can compute homotopy groups of simply-connected spaces which are not necessarily 1-reduced.
In this way, if we are able to compute all homology groups H k (X k ), the homotopy groups π k (X) can be determined. However, let us emphasize that if some H k (X k ) appearing in the construction are not finite (for instance, Z), then the Eilenberg-MacLane space K(H k (X k ), k − 1) and then the corresponding total space X k+1 are not of finite type, so that its homology groups cannot be directly determined and the construction of the tower cannot always be completed. This problem is solved using the effective homology theory as follows. The Whitehead fibrations are implemented in the Kenzo system for simplicial sets X which are 1-reduced, that is, which have only one vertex (0-simplex) and no non-degenerate 1-simplex. More concretely, let X be a connected (n − 1)-reduced simplicial set, that is, it has only one 0-simplex and it does not contain any non-degenerate i-simplex for 1 ≤ i ≤ n − 1, which implies H 0 (X) = Z and H i (X) = 0 for 1 ≤ i ≤ n − 1. Let us suppose that H n (X) ∼ = Z or H n (X) ∼ = Z/mZ for some m ≥ 2. In both cases, (different) Kenzo functions are available which input the degree n and the simplicial set X and construct the Whitehead fibration: The process can be iterated to obtain the whole tower of fibrations. However, the only Eilenberg-MacLane spaces K(π, n), which are available in Kenzo and its external modules are those with π = Z or π = Z/mZ for some m ≥ 2. When some homology group H k (X k ) is obtained such that it is a sum of several factors Z or Z/mZ, H k (X k ) ≡ H 1 k (X k ) ⊕ · · · ⊕ H r k (X k ), then it is known that: and the fibration: in the tower can be simulated by several fibrations as follows: . . .
Again, let us observe that if some H k (X k ) or H j k (X k ) appearing in the construction are not finite then the space K(H k (X k ), k − 1) (or K(H j k (X k ), k − 1)) and the total space X k+1 are not of finite type. However, if the simplicial set X is finite or has effective homology, then Kenzo computes in an automatic way the effective homology of the spaces X k or X j k and then their homology groups can be determined. If we want to compute the s-th homotopy group π s (X), it is sufficient to construct the tower up to dimension s (the space X s satisfies π s (X) ∼ = π s (X s ) ∼ = H s (X s )).
The external module [18] automatizes the construction of all the fibrations in the tower in a recursive way and provides a function for computing the s-th homotopy group of a (1-reduced) space. However, we have found three bugs in that external module, which we have solved as follows: • When some homology group H k (X k ) in the tower is obtained such that it is a sum of several factors Z or Z/mZ, (1) are not (k − 1)-reduced. To solve this problem, it is necessary to introduce a new step in the algorithm to produce a reduction from K(H j k (X k ), k − 1) to a (k − 1)-reduced space. This step was already available in Kenzo but was not used in the external module [18], so that incorrect results were obtained. We have solved this problem by using the corresponding Kenzo function producing the necessary reduction; • When some homology group H k (X k ) is equal to zero, the external module [18] stops the construction of the tower and claims that π i (X) = 0 for every i ≥ k. This assumption is incorrect since there exist spaces with π k (X) = 0 but π i (X) = 0 for some i > k. We have solved this bug by continuing the construction of the tower from the following step such that H i (X k ) = 0; • Each fibration K(H k (X k ), k − 1) −→ X k+1 −→ X k in the tower is defined by means of a simplicial morphism of degree −1, called the twisting operator [17], τ k : X K → K(H k (X k ), k − 1). This simplicial morphism is described by a well-known and existing isomorphism between H k (X k ) and K(H k (X k ), k − 1) k−1 (the set of the (k − 1)-simplices of K(H k (X k ), k − 1)). In order to construct this twisting operator, Kenzo uses the Smith Normal Form (SNF) [24] of the differential matrix of degree k + 1 of the simplicial set X k , denoted D k k+1 . The SNF algorithm of a matrix A consists in computing a diagonal matrix D such that each diagonal element d i,i divides d i+1,i+1 and two invertible matrices (corresponding to the changes of bases), P and Q, such that PAQ = D. In particular, the SNF algorithm of D k k+1 produces a diagonal matrix whose entries describe the (factors of the) group H k (X k ). If H k (X k ) is a sum of several factors, the intermediate fibrations k+1 must be constructed considering the diagonal elements of the SNF (which is unique). However, the external module [18] uses a different decomposition of H k (X k ) (by means of a diagonal matrix which also describes the homology group but does not always satisfy the SNF property), so that in some situations an error is found. We have solved this bug by transforming the homology group factors used in the module into SNF, constructing the intermediate fibrations following the correct order.
After solving the previous bugs and enhancing the external module [18] for computing homotopy groups, we have included it in our interface for SageMath. To this aim, the first step has been to make the Lisp code valid for ECL. Later, we have written SageMath functions and wrappers, so that one can compute homotopy groups of (simply connected) simplicial sets in SageMath.
Then, we have also considered the situation where the initial simplicial set X is not 1-reduced but only simply connected (that is, such that H 1 (X) = 0 but there exist non-degenerate simplices of dimension 1). In that situation, the twisting operator τ k : X K → K(H k (X k ), k − 1) corresponding to the existing isomorphism between H k (X k ) and K(H k (X k ), k − 1) k−1 cannot be as easily determined as before. However, Kenzo's algorithm can be modified by considering the two differential matrices of X k of degrees k and k + 1, denoted D k k and D k k+1 respectively, and following the same steps used for computing homology groups. This new algorithm is described in the preprint [25] and can be of great interest for computing homotopy groups of spaces which are simply connected, but not 1-reduced. This is the case, as we will see in the following subsection, of simplicial complexes which can be constructed in SageMath coming from different areas. We also integrated it in our interface for SageMath.
In the following lines, we show an example of the computation of homotopy groups of the wedge of the sphere S 3 and the suspension of the torus (the Python function range(n,m) returns the sequence of numbers (n, n + 1, . . . , m − 1)).
Let us note that both systems are collaborating: The sphere, the torus, the suspension, and wedge product are computed by means of functions that are available in SageMath, whereas the computation of the homotopy groups of the constructed simplicial object is done in Kenzo, since the simplicial set library provided by SageMath cannot deal with that kind of computation. Let us also emphasize that the wedge construction produces a simplicial set wich is not 1-reduced.

Discovering New Homotopy Groups
In the following example, we will show how the collaboration of SageMath and Kenzo allowed us to compute some homotopy groups that were previously unknown.
Given a set V of n vertices, the set of possible pairs P has ( n 2 ) elements. A subset S ⊆ P determines a graph on the vertices (where the elements of S are the edges of the graph). For an integer i, a graph is said to be i-connected if it cannot become disconnected by removing less than i vertices. It is clear that if S ⊆ S and S is not i-connected, then S is also not i-connected. So, the set of all not i-connected graphs on n vertices forms a simplicial complex, denoted as ∆ i n . In [26], these simplicial complexes have been studied in relation to Knot Vasiliev invariants and some theoretical results about their homotopy type have been stated: • It is proved that ∆ 1 n has the homotopy type of a wedge of (n − 1)! spheres of dimension n − 3; • It is proved that, if n ≥ 3, ∆ 2 n has the homotopy type of a wedge of (n − 2)! spheres of dimension 2n − 5; • It is conjectured that ∆ 3 n has the homotopy type of a wedge of (n − 3)(n − 2)!/2 spheres of dimension 2n − 4.
SageMath can explicitely construct these complexes, and compute some of their invariants, such as the homology: Now, thanks to the interface with Kenzo, we can also compute its homotopy groups, but we must have some care to increase the size of the memory heap that will be used: sage : import s a g e . libs . ecl sage : from s a g e . homology . simplicial_set import SimplicialSet sage : from s a g e . interfaces . kenzo import KFiniteSimplicialSet sage : s a g e . libs . ecl . ecl_eval ( " ( ext : set -limit ' ext : heap -size 0) " ) sage : SNI = SimplicialSet ( NI ) sage : KNI = KFiniteSimplicialSet ( SNI ) sage : pi6 = KNI . homotopy_group (6); pi6 Multiplicative Abelian group isomorphic to Z x Z x Z x Z x Z x Z This is the expected result by Hurewicz's theorem [23], but we can go further: sage : pi7 = KNI . homotopy_group (7); pi7 Multiplicative Abelian group isomorphic to C2 x C2 x C2 x C2 x C2 x C2 which, to our knowledge, was not known up to now. This computation took more than 14 h in a computing node with Intel Xeon E5-2650 v4, 2.20GHz processors, and 512 GB of RAM.
Other homotopy groups π m of spaces ∆ i n obtained thanks to our Kenzo interface in SageMath and the integrated algorithm for computing (non 1-reduced) homotopy groups are shown in Table 1. Let us remark that the groups π m (∆ 2 4 ) could be theoretically determined thanks to the results of [26], but the group π 8 (∆ 3 6 ) was also unknown. One can also observe that all our results support the conjecture in [26]. Table 1. Homotopy groups of the complex of not i-connected graphs on n vertices.

Integration of Other External Modules
This section presents how we have integrated in our development other external Kenzo modules, concretely the following ones:
Spectral sequences [19], developed by the fourth author of this paper, 2006; 3.
Finite topological spaces [20], developed by the first author of this paper, 2020.
We also explain new Kenzo functions (and their integration in SageMath) for working with smash products. Some examples of execution are also shown.

Joins, Wedges, and Smash Products
The join and the wedge of two simplicial sets are two useful constructors in algebraic topology which are implemented in an external module of Kenzo as particular cases of pushout (see [27]). The wedge construction is also implemented in SageMath for finite simplicial sets (as seen in the first example in Section 5), but we have considered including the wedge Kenzo construction so that it can be applied to spaces of an infinite nature. In those cases, the effective homology method can be used to determine the homology groups and other topological invariants. The join construction is not available in SageMath, so that it is also convenient to include it in our interface.
Since Kenzo functions for wedge and join are included in an external module (and not in the standard version), again, the first step to make them available in SageMath has been to modify the Lisp code and make it valid for ECL. Then, we have defined SageMath functions for computing wedges and joins as follows.
First of all, we consider the wedge of the torus with the loop space of the sphere S 2 . Let us note that once again both systems are collaborating for the task: The torus is computed by means of a function which is available in SageMath (and not in Kenzo), whereas the sphere, the loop space, the wedge, and the computation of the homology groups of the constructed simplicial object are carried out via Kenzo. As in the last example of Section 4, the final object is of an infinite nature and then SageMath is not able to determine its homology groups; the effective homology method is used in Kenzo.
Similarly, we can construct the joins of simplicial sets of an infinite nature and determine their homology and, when the result space is simply connected, homotopy groups. For instance, we consider two Eilenberg-MacLane spaces. The smash product of two simplicial sets is another topological construction which can be considered as a particular example of pushout. This construction was not included in the external module [27], but we have used the general definition of pushout to develop new Kenzo functions producing the construction of the smash product of two simplicial sets and its effective homology, which makes it possible to determine its homology and homotopy groups. Considering again the two Eilenberg-MacLane spaces of the previous example, we obtain the following results. sage : E3 = E1 . smash_product ( E2 ) sage : [ E3 . homology ( i ) for i in range (11)] [Z , 0 , 0 , 0 , 0 , Z , 0 , Z x C2 , 0 , Z x C2 x C3 , C2 ] sage : [ E3 . homotopy_group ( i ) for i in range (5 , 9)] [ Multiplicative Abelian group isomorphic to Z , Trivial Abelian group , Multiplicative Abelian group isomorphic to Z , Multiplicative Abelian group isomorphic to C2 ]

Spectral Sequences
As we have already said in Section 2, there exists a Kenzo module [19] for computing spectral sequences, a tool of algebraic topology given by a family of "pages" of groups {E r p,q } r≥1,p∈Z,q∈Z and differential maps d r p,q : E r p,q → E r p−r,p+r−1 ( [28]). This module is able to determine spectral sequences of filtered complexes of infinite type and, in particular cases, it can compute Serre and Eilenberg-Moore spectral sequences of fibrations with objects of infinite type when versions with effective homology are known for the initial spaces. It can also compute the spectral sequence associated with a bicomplex (see [28] for the definition of these spectral sequences). The module determines not only the groups, but also the differential maps of every page of the spectral sequence.
We have integrated in SageMath the computation of the following spectral sequences: • Spectral sequence of a bicomplex given by a list of morphisms of chain complexes; • Serre spectral sequence associated with a cartesian product; • Serre spectral sequence associated with the first fibration in the Whitehead tower of a simplicial set; • Eilenberg-Moore spectral sequence associated with the loop space of a simplicial set.
To this aim, again, we have adapted the code of [19] so that it is compatible with ECL and have developed new functions in both Lisp and SageMath. In the four cases, the result is an object of a new class KenzoSpectralSequence, for which we can obtain groups, differential matrices, and tables showing the groups of a given level via suitable methods. Moreover, we have defined a new SageMath class called KenzoChainComplexMorphism (see Figure 1), which is used to construct the spectral sequence associated with a bicomplex as we will explain later, and a method to translate a chain complex morphism from SageMath to Kenzo.
First of all, we can compute spectral sequences associated with bicomplexes, a particular case of filtered complex from which many useful spectral sequences are defined. A bicomplex (or double complex) C * , * is a bigraded free Z-module C * , * = {C p,q } p,q∈Z provided with morphisms d p,q : C p,q → C p−1,q and d p,q : C p,q → C p,q−1 satisfying d p−1,q • d p,q = 0, d p,q−1 • d p,q = 0, and d p,q−1 • d p,q + d p−1,q • d p,q = 0. We consider as an example the bicomplex of Figure 2 where the differential maps d 1,1 , d 2,0 , and d 1,1 are given by the matrices D 1,1 = 2 0 0 2 , D 2,0 = 2 0 , and D 1,1 = 1 0 .

Spectral Sequences
As we have already said in Section 2, there exists a Kenzo module [19] for computing spectral sequences, a tool of algebraic topology given by a family of "pages" of groups {E r p,q } r≥1,p∈Z,q∈Z and differential maps d r p,q : E r p,q → E r p−r,p+r−1 ( [28]). This module is able to determine spectral sequences of filtered complexes of infinite type and, as particular cases, it can compute Serre and Eilenberg-Moore spectral sequences of fibrations with objects of infinite type when versions with effective homology are known for the initial spaces. It can also compute the spectral sequence associated with a bicomplex (see [28] for the definition of these spectral sequences). The module determines not only the groups, but also the differential maps of every page of the spectral sequence.
We have integrated in SageMath the computation of the following spectral sequences: • Spectral sequence of a bicomplex given by a list of morphisms of chain complexes. • Serre spectral sequence associated with a cartesian product. • Serre spectral sequence associated with the first fibration in the Whitehead tower of a simplicial set. • Eilenberg-Moore spectral sequence associated with the loop space of a simplicial set.
To this aim, again, we have adapted the code of [19] so that it is compatible with ECL and we have developed new functions in both Lisp and SageMath. In the four cases, the result is an object of a new class KenzoSpectralSequence, for which we can obtain groups, differential matrices and tables showing the groups of a given level via suitable methods. Moreover, we have defined a new SageMath class called KenzoChainComplexMorphism (see Figure 1), which is used to construct the spectral sequence associated with a bicomplex as we will explain later, and a method to translate a chain complex morphism from SageMath to Kenzo.
First of all, we can compute spectral sequences associated with bicomplexes, a particular case of filtered complex from which many useful spectral sequences are defined. A bicomplex (or double complex) C * , * is a bigraded free Z-module C * , * = {C p,q } p,q∈Z provided with morphisms d p,q : C p,q → C p−1,q and d p,q : C p,q → C p,q−1 satisfying d p−1,q • d p,q = 0, d p,q−1 • d p,q = 0, and d p,q−1 • d p,q + d p−1,q • d p,q = 0. We consider as an example the bicomplex of Figure 2 where the differential maps d 1,1 , d 2,0 , and d 1,1 are given by the matrices D 1,1 = 2 0 0 2 , D 2,0 = 2 0 , and D 1,1 = 1 0 .  The associated spectral sequence is represented in Figure 3, with differential maps given by the matrix  0  2 and d 2 2,0 : For the moment, we have made it possible to construct the spectral sequence of a bicomplex in SageMath by means of a list of chain complex morphisms, where each chain complex is a column of the bicomplex (with vertical differential maps) and horizontal differentials are given by the morphisms (with the corresponding signs for vertical maps such that the property of bicomplex is satisfied). Considering the example of Figure 2, we construct the chain complexes corresponding to the three columns and then two chain complex morphisms as follows: Let us emphasize that all of them are objects built using SageMath functions. Then, we use our new function BicomplexSpectralSequence, which produces an object of the class KenzoSpectralSequence, and we determine some of the groups and differential maps. In this class, the method group receives three parameters r, p, and q and computes the group E r p,q of the spectral sequence, in our examplex, E 2 0,2 = Z/2Z ⊕ Z. The method table inputs five integers: The page r and four indexes i1, i2, j1, and j2 corresponding to the first column, last column, first row, and last row to print; in this case we show some groups of the page E 3 . The method matrix computes the differential map d r p,q as a matrix and as said before, It would also be possible to define a class Bicomplex (which does not exist either in SageMath or Kenzo), providing methods for obtaining the bigraded list of generators, vertical and horizontal differentials, and the associated total chain complex.
Another type of spectral sequence that we have integrated in SageMath is the Serre spectral sequence [29], which provides information on the homology groups of the total space of a fibration from the homologies of the base and the fiber. A particular case is obtained for trivial fibrations, which correspond to cartesian products of two simplicial sets. Let us consider for example the cartesian product of two spheres, S 2 × S 3 . As it is well known, the page E 2 of the Serre spectral sequence is given by E 2 p,q = H p (S 3 , H q (S 2 )) and all differential maps are null (since the fibration is trivial). In the following lines, we compute for instance E 2 3,0 = Z, we show some of the groups of the page E 2 , and we determine the differential map d 3 3,0 which as expected is the null morphism. Let us consider now the Serre spectral sequence of the Whitehead tower of the sphere S 3 , which corresponds to a (non-trivial) fibration K(Z, 2) → X → S 3 . In this case, it is known that the E 2 page is given by E 2 p,q = H p (S 3 , H q (K(Z, 2))) and some non null differential maps can happen. In the following lines, we show the computation of the page E 2 and some differentials. We can observe that d 3 3,0 : E 3 3,0 → E 3 0,2 is an isomorphism and d 3 3,2 : E 3 3,2 → E 3 0,4 is the multiplication by 2.
sage : from s a g e . interfaces . kenzo import Sphere sage : S3 = Sphere (3) sage : E = S3 . sw_spectral_sequence () sage : E . Another classical example of spectral sequence is the Eilenberg-Moore spectral sequence [30], which is also associated with fibrations, and in particular the one related with the loop space of a simplicial set which is implemented in the Kenzo module [19] and has been also integrated in SageMath. This is a second quadrant spectral sequence, which means that the groups E r p,q which are different from zero satisfy p ≤ 0 and q ≥ 0. Let us consider as an example the computation of the Eilenberg-Moore spectral sequence of the sphere S 3 , where we can find for instance a differential map

Finite Topological Spaces
A finite topological space (or simply a finite space) is a topological space with finitely many points. Finite spaces and finite preordered sets are basically the same objects considered from different perspectives [31] (moreover, finite T 0 -spaces correspond to finite partially ordered sets or posets). This result allows us to study finite spaces by combining algebraic topology with the combinatorics arising from their intrinsic preorder structures.
The study of homotopical invariants can be restricted to the class of finite T 0 -spaces, since any finite topological space is known to be homotopy equivalent to a finite T 0space [32]. Given a finite T 0 -space, the incidence matrix corresponding to the order relation of its associated poset and the adjacency matrix of the Hasse diagram are called the topogenous matrix and Stong matrix of the space, respectively.
An external module of the Kenzo system has been recently developed in order to represent and compute some topological invariants of finite topological spaces [33]. Since many of the algorithms are based on manipulations of the topogenous and Stong matrices, finite spaces are represented in Kenzo as instances of the class FINITE-SPACE by using the slots top (the topogenous matrix), stong (the Stong matrix), and heights (a list of the elements of the space separated by heights). An instance of FINITE-SPACE can be defined by just declaring either the top slot or the stong slot, but it is preferable to keep both in order to facilitate the computations. For example, we can construct a finite T 0 -space by specifying the edges of the Hasse diagram of its associated poset and constructing the respective Stong matrix: > ( setf edges ( make-array 19 : initial-contents '(() () () () ( 1 2) (1 2) (2 3) (2 4) (2 3) (2 4) (3 4) (3 4) (5 6) (5 6 7)  (5 6 7 8) (7 8 11) (8 9 12) (9 10 11) (7 10 12)))) > ( setf finite-space ( b uil d-fi nit e-sp ace : stong ( e dg e s-t o-s t on g -m t r x edges ) : orgn '( example ))) [ K1 Finite-Space ] In a particular case, when a finite T 0 -space is h-regular, some algorithms to compute its homology have been developed in [33], where the use of discrete vector fields has been also considered in order to deal with smaller chain complexes when computing homology groups. Regarding finite-space (the space we have constructed above), we can prove that such a space is h-regular, and then we can compute its homology in Kenzo: > ( h -r egu la r-hom ol og y finite-space 0) Component Z > ( h -r egu la r-hom ol og y finite-space 1) Component Z /2 Z > ( h -r egu la r-hom ol og y finite-space 2) Component Z Component Z Despite the capabilities of Kenzo to compute topological invariants, it lacks a graphical interface, as mentioned before. Moreover, finite T 0 -spaces can be represented by their associated posets and since the class FinitePoset [34] in SageMath is devoted to posets, we have decided to integrate in SageMath the external Kenzo module dealing with finite spaces. By means of this integration, we can use the methods and functions implemented in the class FinitePoset, which in particular allows us to visualize the Hasse diagrams of the posets associated to finite T 0 -spaces by using graphic objects in SageMath and we enhanced SageMath with a new mathematical object, expanding the scope of this system.
In order to deal with finite spaces in SageMath, we have created a module implementing finite topological spaces and related concepts. The class FiniteTopologicalSpace has been created by taking as input the parameters elements (the list of elements of the finite space), minimal_basis (a dictionary where the keys are the points n in elements and minimal_basis[n] is the set of points in the minimal open set containing n), and topogenous (the topogenous matrix of the finite space induced by the order given in elements). Bearing in mind the importance of finite T 0 -spaces in the computation of invariants, we have created the subclass FiniteTopologicalSpace_T0, inheriting all the attributes above mentioned and, additionally, the parameter poset, a FinitePoset representing the poset corresponding to the finite T 0 -space.

Conclusions and Further Work
In this paper we presented an interface between the computer algebra systems Sage-Math and Kenzo, together with an optional Kenzo package for SageMath. Our work has made it possible to work with Kenzo in a friendlier way and has allowed both systems to collaborate in some computations which cannot be done independently in any of the programs. In addition, we enhanced SageMath with new functionalities in algebraic topology, allowing the representation and computation of topological invariants of spaces of an infinite nature; such type of spaces were not available in the system before. We have also integrated the first implemented algorithm to compute homotopy groups of not 1reduced simplicial sets. This led us to compute homotopy groups that have never been determined before.
The first prototype of our interface and the Kenzo package, presented in [13], are already available from version 8.7 of SageMath and include some basic functionalities of algebraic topology computations. The new version, which has recently been accepted by SageMath developers and is available from SageMath 9.2, integrates some Kenzo external modules (which led us to find several bugs on one of them which have been fixed) and adds new functionalities and computations: Joins of two simplicial sets, wedges of spaces of infinite nature, smash products, homotopy groups, spectral sequences, and connection between chain complexes, simplicial sets, and morphisms of chain complexes. We also provide new computation capabilities about invariants of finite topological spaces; this part of the work is currently under review by the SageMath developers to be included in future releases.
The optional Kenzo package for SageMath and the interface to communicate both systems possess many interesting features: • The package permits an easy installation of Kenzo and incorporates some of the external modules for Kenzo that are scattered in the personal websites of different authors. This has required the authors to update, adapt, polish, and correct flaws in the external code, since some of them were developed for outdated versions of the Kenzo system; • They spread Kenzo to a broad community by including it in SageMath. The interface also eases the use of Kenzo for users with no previous knowledge of functional programming, since the interface is transparent: The user does not notice that Kenzo is running withing SageMath and the computations are carried out in Kenzo via SageMath commands. No knowledge on functional programming is required; • Jupyter notebooks can be used as a friendly graphical user interface. Even more, it is possible to use SageMath with our Kenzo interface online with no software installation required; • The interface is efficient due to the use of a C-library interface, roughly equivalent to Kenzo in time and space efficiency; • They are extensible: New modules and features can be added to both the package and the interface; • It is an open-source software: Any user can explore and adapt the code.