Skip to content

regularity has no hook or Strategy, so the Regularity package must export mRegularity as a parallel name #4601

Description

@d-torrance

This issue was triaged from bugs/dan/1-regularity, one of the 857 files removed from the pre-GitHub bugs/ tree by d2c8d27826 and catalogued in #36. The commentary below was written by Claude (Claude Opus 5, via Claude Code), not by @d-torrance, whose account posted it -- please weigh it accordingly.

The original file, verbatim

For Alexandra:

  install a hook in "regularity" so after the Regularity is loaded,
  there will be a new Strategy or Algorithm that causes the new 
  algorithm to be used.  The value of Strategy should be checked, somehow.

Where it stands today

Unmet in every particular, and the mechanism it asks for has since become M2's standard way of doing
this — so it is cheaper now than when the note was written.

There is no dispatch point

regularity is declared in Core with one option:

regularity = method(TypicalValue => ZZ, Options => { Weights => null })   -- betti.m2:244

No Strategy, no Algorithm, and no addHook/runHooks anywhere for it. The working methods live in
Complexes:

regularity Ideal   := opts -> I -> ... 1 + regularity betti(freeResolution liftModule comodule I, opts)
regularity Module  := opts -> M -> regularity betti(freeResolution liftModule minimalPresentation M, opts)
regularity Complex := opts -> C -> ...

(Complexes/ChainComplex.m2:640-654.) Every route goes through betti(freeResolution …), hard-coded,
with nowhere for an alternative algorithm to attach.

So the package has to use a different name

packages/Regularity.m2 exists and exports mRegularity, CM, MonCurve (:22). A user who writes
regularity I cannot reach it. The package's own tests compare the two by hand:

assert(mRegularity(I, MonCurve => true) == regularity I)

which is the shape of thing a Strategy exists to avoid.

The fragmentation is still growing: #4191 is an open pull request adding weightedRegularity to
Depth.m2, a third name for a closely related computation.

Why this is easier than in 2009

When the note was written, hooks were a new idea. They are now the conventional pattern for exactly this
situation — freeResolution, pushForward, minimalPrimes and kernel all dispatch through
runHooks, and each lets a package register an algorithm under a Strategy name without touching the
caller. Making regularity one of them is following a paved road.

It also answers the note's second clause for free — "The value of Strategy should be checked, somehow"
since runHooks reports when no registered strategy accepts the input, rather than silently doing
something else.

Related

#3321 (closed) was about regularity for modules over quotient rings, not about dispatch.

open · disposition issue · source of truth: bug-triage/catalog.tsv

Metadata

Metadata

Assignees

No one assigned

    Labels

    CoreIssues involving the Core scripts.bugs directoryConverted from a file in the old `bugs` directoryfeature request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions