Skip to main content

Fast Semigroup Homology

This is a Python package for computing the integral homology of finite semigroups. It is very fast in most cases:

$ python -m fast_semigroup_homology -i "010100;010100;232322;232322;010100;010100" -d 12
H_0: Z
H_1: trivial
H_2: Z
H_3: Z^2
H_4: Z^4
H_5: Z^8
H_6: Z^16
H_7: Z^32
H_8: Z^64
H_9: Z^128
H_10: Z^256
H_11: Z^512
H_12: Z^1024
Elapsed (wall) time: 0:00:00.001716

The above even quickly finishes if you pass -d 10_000 to compute the homology group in dimensions up to 10,000!

Installation:

Install with pip: pip install fast_semigroup_homology

Usage

Homology of one semigroup from the command line:

To compute the homology of an individual semigroup with the command line, run python -m fast_semigroup_homology -i "01;10" -d 10 as above, replacing the string that follows -i with the multiplication table for some semigroup. Such a multiplication table must be entered as strings of digits separated by semicolons, all wrapped in quotes. Letters (as in hexadecimal) are also supported to allow semigroups of size at most 10+26=36 to be passed in quotes after -i. The integer following -d indicates the maximum dimension to compute to.

As a Python Function

With this package installed, you can use the fast_integral_semigroup_homology function from python code:

>>> from fast_semigroup_homology import fast_integral_semigroup_homology as h
>>> h([[0,1],[1,0]], 10) # Homology of C2
[{0: 1}, {2: 1}, {}, {2: 1}, {}, {2: 1}, {}, {2: 1}, {}, {2: 1}, {}]

The result of fast_integral_semigroup_homology(table, maxdim) is a list of length maxdim+1 of dictionaries representing the multisets of invariant factors of the homology groups in dimensions 0 up through maxdim, inclusive. For example {0: 1} represents one copy of the infinite cyclic group Z, while {2: 1} represents one copy of the cyclic group Z/2Z.

Homology of HDF5 files of semigroup tables:

If you have a folder of HDF5 files like those produced by Semisearch, you can run:

python -m fast_semigroup_homology -f /PATH/TO/FOLDER -o MAXORDER -d MAXDIM -c NUM_CORES

This will make a folder called results in the current working directory with .hdf5 files containing the homology groups [H_0, ... H_MAXDIM] of the semigroups from the files order1.hdf5 through orderMAXORDER.hdf5 in the folder passed after -f. If NUM_CORES is specified, that many processes will compute in parallel.

My results folder is also stored in the git repository for this package, which you can browse and download. This is not included when pip installs this package.

Refining an existing HDF5 calculation

If you've already computed homology from a folder of HDF5 files as above, you can attempt to extend these computations with the -r flag:

python -m fast_semigroup_homology -f /PATH/TO/FOLDER -r ./results/EXISTING.hdf5 -d MAXDIM -c NUM_CORES -k KERNEL_BOUND

This creates a new file "refined_EXISTING.hdf5" in which calculations from "EXISTING.hdf5" are re-attempted, organized into bins of semigroups whose homology computed so far has been identical. If the calculations are found to be distinct, then the semigroups are separated into bins accordingly and the homology of these bins is extended in the same way recursively.

If any calculation within a bin attempts to compute the kernel of some integer matrix larger than KERNEL_BOUND, then the calculation fails and the bin is not refined any further. Therefore no list of homology groups produced by this refinement process is a prefix of any other.

The final format of refined_EXISTING.hdf5 is identical to the input EXISTING.hdf5, and a similar refined_EXISTING.md is generated to summarize the calculation. Question mark emojis ("❓") in the markdown files indicate computations that were abandoned for exceeding KERNEL_BOUND.

How It Works

We compute semigroup homology by first reducing to monoid homology, adjoining a unit as necessary. Then, according to Theorem 2 of (Adams, W. and Rieffel, M. Adjoint functors and derived functors with an application to the cohomology of semigroups. J. Algebra, 7 (1967), 25-34), we can get the same homology groups by reducing from a monoid S to the monoid eSe for some idempotent e of S, so long as eSe is a left ideal or right ideal of S.

After reducing to smaller monoids as applicable, the computation computes the homology H_i(S) as a Tor group Tor^Z[S]_i(Z, Z), where Z[S] is the monoid ring for S, and Z is a Z[S]-module with trivial S-action. To do this, we need a projective resolution for Z as a Z[S]-module.

Forming such a projective resolution is an alternating process of taking kernels and covering those kernels with maps from a new projective Z[S]-module. The projective modules we use are direct sums of modules of the form Z[S]e, where e is some idempotent of S. Kernels of integer matrices are computed using the implementation in ./fast_semigroup_homology/kernels.py, and those kernels are then covered by maps from a new module using the implementation in ./fast_semigroup_homology/find_generating_subset.py.

We apply two major additional optimizations in ./fast_semigroup_homology/projective_resolution.py:

  1. We use the mutable_lattice.Lattice.decompose() method to identify when a kernel splits along the Z[S]e summands, so we can cover the two summands of the kernel independently, thus "forking" the projective resolution into multiple branches of a tree.

  2. We cache and re-use parts of the resolution already computed, so that infinite resolutions can be represented as finite graphs with cycles. This is what allows large calculations like the 1000th homology group of the semigroup from the top of this README.

Performance Notes

  • Computing homology is extremely fast for many semigroups, but much slower for others. The time spent calculating homology for a big list of semigroups might be dominated by a tiny handful of the most difficult examples. In these most difficult cases, the complexity of the computation is exponential in MAXDIM.

  • The fast_integral_semigroup_homology function aims to provide shortcuts and sensible default thresholds to minimize the computation time expended finding small projective resolutions. You can get more fine-grained control by using the ProjectiveResolution class directly.

  • It appears that the majority of calculation time occurs in computing the kernels of integer matrices. The mutable_lattice.relations_among function proved to be the fastest for the data provided by actual semigroups, which appear to usually small integer entries including many zeros. However, ProjectiveResolution allows dependency-injecting your own kernel function. See ./fast_semigroup_homology/kernels.py for some commented-out examples of alternate implementations. This dependency-injection also allows bounding the size of kernel computation that is allowed, as is done in ./fast_semigroup_homology/refine_hdf5.py.

  • The most intensive calculations tend to take lots of memory, and this is especially relevant if you are running multiple processes in parallel with the -c flag. Adding swap space can help offload some of the required memory onto your hard drive and extend the computations your computer can complete without crashing.

Metadata

Release files for fast-semigroup-homology 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fast-semigroup-homology 0.2.1
File Size Uploaded Provenance
fast_semigroup_homology-0.2.1.tar.gz 40.9 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for fast-semigroup-homology 0.2.1
File Interpreter ABI Platform
fast_semigroup_homology-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 77.2 kB

Release files / fast_semigroup_homology-0.2.1.tar.gz

Download URL fast_semigroup_homology-0.2.1.tar.gz
Size 40.9 kB
Tags Source
SHA-256 checksum
How to use checksums
55e13057ccaac9c305f3e2cac054e58188c4e0f95b18a31dc54e62bdec2acd2c
BLAKE2b-256 checksum
How to use checksums
ddb2b6bbb90dbd0a61cb2722eaba503400e149e3cf9b6093e4ca4797aa161209
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 8, 2026.

Transparency log

Release files / fast_semigroup_homology-0.2.1-py3-none-any.whl

Download URL fast_semigroup_homology-0.2.1-py3-none-any.whl
Size 36.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9172cd71b9248af26ac47b6f66503bfa47822baf7453bcb8666ae4156709c241
BLAKE2b-256 checksum
How to use checksums
3facad743c26995a7c75a9c005de0990fe52a0369f28fd06cb4b326cb3ab42f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 8, 2026.

Transparency log

Security for fast-semigroup-homology 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for fast_semigroup_homology-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 8, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page