Skip to content

Center of skew rings and kernel of RingMap to skew rings - #4485

Merged
d-torrance merged 15 commits into
Macaulay2:developmentfrom
joel-dodge:skew-kernels
Oct 22, 2026
Merged

d-torrance merged 15 commits into
Macaulay2:developmentfrom
joel-dodge:skew-kernels

Conversation

@joel-dodge

@joel-dodge joel-dodge commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Add centerRing method to compute the center of a ring. Currently supports skew polynomial rings (and commutative rings 😂 ).

Then adds a new strategy for computing the kernel of a RingMap whose target is SkewCommutative by reducing to a map to the center of the target.

This requires some awkward packaging since kernel is in the core and the strategy for computing the center of a skew commutative ring depends on the PushForward package. We rely here on the "hack" of calling needsPackage inside the hook only when needed although @d-torrance says "I'm not sure if this is a very elegant solution" and I am inclined to agree.

Note while editing ringmap.m2 I took the opportunity to clean up ws formatting in the block declaring different kernel strategies for RingMap. Consider toggling the "hide whitespace" option while reviewing this PR.

@joel-dodge
joel-dodge marked this pull request as ready for review July 31, 2026 17:53
@d-torrance d-torrance added the Core Issues involving the Core scripts. label Aug 2, 2026
d-torrance added a commit to d-torrance/M2 that referenced this pull request Aug 7, 2026
bugs/dan/1-jacobian through 1-loadPackage.  Six fixed, two duplicates, two
wontfix, two filed.

Filed:

* Macaulay2#4589 1-join-hash -- the guess in the file is right and the saving is real.
  Every List construction folds the whole list (basic.d:114-117 does
  r.hash = hash(r); the fold is at :82-85), so join of two 200k lists costs
  11.2ms of which 7.5-8.5ms is hashing -- measurable because a Sequence's hash
  is not cached and refolds on demand.  The fold is combinable:
  h(L++M) = 1299833^#M * (hash L - c) + hash M mod 2^64, c = hash class L +
  23407, verified on seven cases.  My first attempt used the Sequence constants
  and failed all five, which is how the two folds turned out to differ.
* Macaulay2#4590 1-kernel-ringmap -- Mike's 2008 recipe, unevenly landed.  The Hilbert
  hint is implemented for degree-preserving maps (ringmap.m2:320-332, verified
  live: gb records rawGBSetHilbertFunction log), the inhomogeneous case it was
  written for is skipped because canUseHilbertHint requires isHomogeneous
  (gb.m2:271), and the recipe's forceGB step is Macaulay2#686.  PR Macaulay2#4485 is adding
  another strategy to the same table.

Duplicates, both with comments posted: 1-kernel-ringmap-ZZ -> Macaulay2#1518 (the message
moved to methods.m2:695, and ringmap.m2:336's ZZ strategy only fires when the
source is ZZ itself), 1-line-wrapping-with-negative-numbers -> Macaulay2#4149 (the same
splitcolumn gap one character class over; three lines still end in a bare
hyphen).

Fixed: 1-leadTerm-crash.m2 (the ignored engine error is propagated, so
enginering.m2:496 errors instead of smoking), 1-lift-RR-CC (both spellings
return precision 53), 1-lift-modules (lift((QQ[x])^3, QQ) is QQ^3), 1-lifting
(.3 * id_(QQ^3) is over RR_53 now, and promote(.3, QQ) errors -- the direction
PR Macaulay2#62 on MichaelABurr/M2 is formalising), 1-lcm-needed (implemented, gcd
compiled at 14.3us on 700-digit inputs, and the Binary ask declined on
measurement: 9.7ms through Binary against 13.8ms for a hand fold), 1-loadPackage
(PR Macaulay2#3852's warning meets the need; the file's own example is invalid today for
a rank reason and fails identically with no reload).

Wontfix: 1-jacobian (the intrinsic object is one line away, and jacobian-doc
documents the present behaviour as "identical to jacobian generators I"),
1-list-of-ideals-of-R (asked and declined in PR Macaulay2#3328).

dan/1 todo 154 -> 142, settled 351 -> 363.
@joel-dodge

Copy link
Copy Markdown
Contributor Author

@MichaelABurr @ggsmith any progress reviewing this?

Comment thread M2/Macaulay2/m2/centerRing.m2 Outdated
Z.formation = FunctionApplication {centerRing, R};

map(R, Z, phi^-1 matrix {ximages | yimages})
)) No newline at end of file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a newline at the end of the file.

@MichaelABurr MichaelABurr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me for the most part. There are a few stylistic changes that should be made. It includes some tests and has documentation.

Comment thread M2/Macaulay2/m2/exports.m2 Outdated
"capture",
"catch",
"ceiling",
"centerRing",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix spacing

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changing to 4 spaces instead of 8. the formatting of this file looks crazy to me in vscode so it was hard to tell what the right indentation was.

(F',r) := flattenRing(F, CoefficientRing => k);
if R' === R and F' === F then return null;
p^-1 kernel (r * f * p^-1)
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the only difference here the removal of the final comma?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right. Outside of the addition of the new hook method, the only non-ws change to this file is the removal of this final comma in the definition.

)
)
),
(F, R) := (target f, source f);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there wasn't a change here - perhaps only a change to spacing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, as i said in the pr description:

Note while editing ringmap.m2 I took the opportunity to clean up ws formatting in the block declaring different kernel strategies for RingMap. Consider toggling the "hide whitespace" option while reviewing this PR.

assert (not chh or G#?"rawGBSetHilbertFunction log"); -- ensure the Hilbert function hint was actually used in gb.m2
ideal mapback selectInSubring(1,generators G)
),
(F, R) := (target f, source f);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also not seeing a change in this section either - again, it might be due to a spacing change.

if R' === R and F' === F then return null;
p^-1 kernel (r * f * p^-1)
),
(F, R) := (target f, source f);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the only change here was the removal of a comma.

Comment thread M2/Macaulay2/tests/normal/centerRing.m2 Outdated
assert(map(kk, kk) === centerRing kk)

R = kk[a..c] / ideal {a^2 + b, b^2 + c^3, c^2 - a*b^2}
assert(map(R, R) === centerRing R) No newline at end of file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing newline at end of file

Comment thread M2/Macaulay2/tests/normal/ker9.m2 Outdated

-- inhomogeneous
g = map(R, S, {a*b*c*d + 2*a*b, c*d + 1})
assert(ker g == ideal(t^2-2*t+1,s^2)) No newline at end of file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing newline at end of file

SeeAlso
isCommutative
isSkewAffineRing
/// No newline at end of file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing newline at end of file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i missed that it is standard to have a newline at the end of files. Is this part of a style guide somewhere?

@joel-dodge

Copy link
Copy Markdown
Contributor Author

@MichaelABurr ty so much for review and I am sorry for the confusion about the whitespace changes! I think I have responded to all of the stylistic changes you requested. I did ask one question about whether is a style guide of some sort that I have not seen. ty again!

@MichaelABurr

Copy link
Copy Markdown
Member

@MichaelABurr ty so much for review and I am sorry for the confusion about the whitespace changes! I think I have responded to all of the stylistic changes you requested. I did ask one question about whether is a style guide of some sort that I have not seen. ty again!

I didn't know that you could view the changes without the whitespace, I really appreciate knowing about that option!

The newline at the end of a file isn't strictly necessary/part of our style guide, but it is part of the POSIX style. My understanding is that some software expects newlines at the ends of files (and, without it, unexpected behaviors can occur).

@joel-dodge

Copy link
Copy Markdown
Contributor Author

@MichaelABurr one thing that I fussed with a bit in putting this together was whether to call the method centerRing or to just use the more mathematically usual notation of center. What I ran into when using plain center was that there are several packages that implement their own notion of center currently, each of them defining

center = method()

in their own package. I guess that if multiple of these were used at once there would be problems wiht redefinition of the global symbol center. Trying to unify all of these methods and keeping the functionality separate via the usual method of different overrides (because indeed they all operate on different types) would be technically functional but would run into the problem of all center methods having awareness of any of the options that any of them accept. For example, my new centerRing accepts a Strategy but I think none of the other ones currently do. This sort of leakiness in the abstraction was enough to make me want to just rename the method to centerRing.

Do you have any thoughts about these problems and concerns?

@d-torrance

Copy link
Copy Markdown
Member

I think center is absolutely a great candidate for moving to Core

@joel-dodge

Copy link
Copy Markdown
Contributor Author

@d-torrance awesome. I am very happy to rebase this on top of your change when it is merged and rename centerRing to center.

@joel-dodge

joel-dodge commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Any idea what is going on here with this failure @d-torrance?

In file included from /Users/runner/work/M2/M2/M2/Macaulay2/e/mathic/mathic.h:13:
/Users/runner/work/M2/M2/M2/Macaulay2/e/mathic/mathic/DivList.h:595:36: fatal error: no member named 'back_inserter' in namespace 'std'
  595 |     std::copy(begin(), end(), std::back_inserter<TmpContainer>(tmpCopy));
      |                                    ^~~~~~~~~~~~~
1 error generated.

I see something in my local diff against development about the mathic submodule having an updated commit hash and I never really know how to think about submodules so don't know if that could be related.

@d-torrance

Copy link
Copy Markdown
Member

Yeah, it looks like you accidentally committed a change to the mathic submodule, rewinding it to an earlier commit that's missing the fix from Macaulay2/mathic#28

@joel-dodge

Copy link
Copy Markdown
Contributor Author

ugh got it ty so much for your help!

@d-torrance
d-torrance merged commit 80e3b9b into Macaulay2:development Oct 22, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Core Issues involving the Core scripts.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants