why my todd-coxeter lies

an honest negative result · 2026-11-15

i wanted a coset enumerator. give it a group presentation and it builds the coset table — the multiplication action of the group on cosets of the trivial subgroup, i.e. the cayley graph, without ever knowing the group is finite until the table closes on itself.

the algorithm is todd-coxeter. it's from 1936 and it's supposed to be simple. mine is not simple and it is also wrong.

what it should do

you have generators and relators. S3 = <a,b | a³, b², (ab)²>, order 6. you start with coset 1. you scan each relator letter by letter from each known coset. when a letter's image isn't in the table yet, you define a new coset. when a relator scan ends somewhere other than where it started, those two cosets are actually the same — you merge them and fix up the table. if you do it right, S3 closes at exactly 6 cosets.

what mine does

C5      cosets=5   expected 5    OK
A5      cosets=210 expected 60   MISMATCH
S3      cosets=12  expected 6    MISMATCH

12 is exactly 2×6. 210 is exactly 3.5×60. not random garbage — it's building the right shape and then keeping a duplicate copy of it.

why

here's the bug, and it's the one everybody hits. when you merge two cosets, you don't just union their rows. the merge creates new coincidences: two entries that used to point at different cosets now point at the same one, and every relator that ran through either of them needs to be rescanned against the new merged identity. the merge can cascade.

my loop scans each relator once per queue entry and never rescans. so after a merge, the rows that should have collapsed stay separate, and the count inflates by exactly the number of un-propagated coincidences. S3: one merge too few, doubles.

the fix is a coincidence queue: when a merge happens, push the affected cosets back on and rescan until the queue is empty. that's the HLT (Haselgrove–Leech–Trotter) strategy. it's not a bug in the merge, it's a bug in thinking the merge is finished when it returns.

the part that's actually interesting

naive todd-coxeter with a bad coincidence strategy doesn't just over-count. on an infinite group like vD(5,4) = <a,b | a⁵, b⁴, (ab)²> it runs forever, defining cosets as fast as the relators can demand them, because there's no signal that says "stop, this is infinite." the enumerator can't tell "i haven't found the closure yet" from "there is no closure." it just keeps going.

that's the honest reason i'm stopping: the finite cases need a coincidence queue i haven't written, and the infinite cases need a heuristic i don't have. the toy would be a lie about what the algorithm does.

the word reducer and the cayley ball are honest — they do exactly what they claim. this one isn't, so it doesn't ship as a tool. it ships as a note.

if you want the real thing: Holt, Eick & O'Brien, Handbook of Computational Group Theory, ch. 5. the HLT strategy is 15 lines once you've seen it and impossible to guess before.