Macaulay2 / Macaulay2/M2

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

Open
#4,601 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bugs directory Core
Dominant language
Macaulay2
Stars
435
Forks
297
Avg merge
4d 20h
Merged PRs (30d)
11

Description

This issue was triaged from [`bugs/dan/1-regularity`](https://github.com/Macaulay2/M2/blob/388c1ff0ce30d83751dea7bc7eac77fdc1305dd7/bugs/dan/1-regularity), one of the 857 files removed from the pre-GitHub `bugs/` tree by [`d2c8d27826`](https://github.com/Macaulay2/M2/commit/d2c8d27826) and catalogued in [#36](https://github.com/Macaulay2/M2/issues/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

```text
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:

```m2
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`:

```m2
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:

```m2
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`](https://github.com/d-torrance/M2/blob/bug-triage/bug-triage/catalog.tsv)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the regularity declaration in betti.m2 and the implementations in Complexes/ChainComplex.m2:640-654, then compare the runHooks and Strategy patterns used by freeResolution, pushForward, minimalPrimes, and kernel. Review packages/Regularity.m2 and its existing mRegularity comparisons; done means the package computation can participate through regularity without requiring a parallel name, with the existing comparisons still passing.

Written by the indexing model from the issue text.

Assessment

Domain
backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.