Skip to content

Use precomputed table of marks for functorial composition of species#42443

Open
mwhansen wants to merge 2 commits into
sagemath:developfrom
mwhansen:table-of-marks-tomlib
Open

Use precomputed table of marks for functorial composition of species#42443
mwhansen wants to merge 2 commits into
sagemath:developfrom
mwhansen:table-of-marks-tomlib

Conversation

@mwhansen

@mwhansen mwhansen commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Summary

The subgroup-based algorithm for functorial composition of species
(LazyCombinatorialSpeciesElement.functorial_composition(..., algorithm="subgroups"))
computes the table of marks of the symmetric group $S_n$ for every coefficient.
Currently this is computed from the group via libgap.TableOfMarks(S_n), which is
expensive and quickly becomes the limiting factor — it is effectively infeasible
past degree ~10.

GAP's tomlib package ships precomputed tables of marks for the symmetric groups,
which are essentially free to look up and available for a much larger range of degrees.

Measured cost of obtaining the table of marks of $S_n$:

$n$ from group tomlib lookup
6 1.6 s ~0 s
8 5.1 s ~0 s
10 infeasible ~0 s (1593 classes)
13 infeasible 2.0 s (20832 classes)

This PR adds a cached helper _table_of_marks_symmetric_group(n) that looks up the
library table when available and falls back to computing it from the group otherwise,
and uses it in _coefficient_subgroups. The library tables are representation-compatible
with the existing code (their underlying group is the natural symmetric group on
${1, \dots, n}$, and RepresentativeTom returns subgroups of it), so the change is
transparent.

Effect

  • Removes the table-of-marks bottleneck in the cases where it dominates, and raises the
    feasible degree for the "subgroups" algorithm from ~10 to ~13.
  • No change to results: all (long) doctests of sage/rings/lazy_species.py pass, and the
    coefficients are identical to those computed from the group.

Notes

  • tomlib covers a range of small degrees (roughly $S_4$–$S_{13}$); outside that range
    TableOfMarks returns fail and we fall back to computing from the group, so there is
    no behavioural regression for any degree.

The subgroup-based algorithm for functorial composition of species
computes the table of marks of the symmetric group `S_n` for each
coefficient.  Computing it from the group is expensive and quickly
becomes the limiting factor (and is infeasible past degree ~10).

GAP's `tomlib` package ships precomputed tables of marks for the
symmetric groups, which are essentially free to look up and available
for a much larger range of degrees.  Add a cached helper
`_table_of_marks_symmetric_group` that uses the library table when
available and falls back to computing it from the group otherwise, and
use it in `_coefficient_subgroups`.
@mwhansen mwhansen requested a review from mantepse June 28, 2026 08:57
@mantepse mantepse self-assigned this Jun 28, 2026
@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown

Documentation preview for this PR (built with commit ea38b53; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

`libgap.TableOfMarks("Sn")` raises a GAPError when the GAP tomlib
package is not installed, rather than returning `fail`.  Catch the
error so we fall back to computing the table from the symmetric group,
as we already do for degrees that are not in the library.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants