Macaulay2 / Macaulay2/M2

map should accept option-style destinations, as substitute already does

Open
#4,592 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-map, 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
It would be nice to make this work:

    Macaulay2, version 1.3.1.1
    with packages: ConwayPolynomials, Elimination, IntegralClosure, LLLBases, PrimaryDecomposition, ReesAlgebra, SchurRings, TangentCone

    i1 : R = QQ[a]

    o1 = R

    o1 : PolynomialRing

    i2 : S = R[b]

    o2 = S

    o2 : PolynomialRing

    i3 : map(R,S,{b=>a})
    stdio:3:1:(3):[0]: error: destinations not specified for every generator
Where it stands today

Option-style destinations are already supported — but only when the source and target are the same
ring, which is why the file's example fails.

What works today
i1 : R = QQ[a,b];

i2 : map(R, R, {a => a^2})
o2 = map(R,R,{a^2, b})          -- b is left alone, which is the useful default
What does not
i3 : T = QQ[a]; U = T[b];

i4 : map(T, U, {b => a})
stdio:4:1:(3): error: destinations not specified for every generator

i5 : S = QQ[c];
i6 : map(S, R, {a => c})
stdio:6:1:(3): error: destinations not specified for every generator
Why

Core/ringmap.m2:495-501. The option list is parsed either way, into a destination list carrying
symbol dummy for each generator the caller did not mention. What differs is the handling of those
placeholders:

else if R === S and S === ring commonzero then (
     -- if source==target, then the default is to leave generators alone
     for i from 0 to #m-1 do if m#i === symbol dummy then m#i = g#i;
     )
else (
     if any(m,x -> x === symbol dummy) then error "destinations not specified for every generator";
     );

So the notation and the "leave it alone" rule both exist; they are simply gated on the source and
target being identical.

The case for widening the gate

In the file's example the unspecified generator is a, and a is a generator of the target
T = QQ[a] — so "leave it alone" is not merely convenient there, it is well defined. The same holds
whenever the omitted generators lie in a ring the target shares, which is the common situation for a
map out of a tower R[b] -> R.

Where it is genuinely undefined — map(QQ[c], QQ[a,b], {a => c}), with b having no meaning in the
target — the present error is the right answer, and should stay.

substitute accepts the same spelling unconditionally, since it rewrites an element rather than
defining a homomorphism:

i7 : substitute(b^2, {b => a})
o7 = a^2
One thing to be careful about

The positional form fills in silently, so a caller who miscounts gets a map rather than an error:

i8 : map(T, U, {a})
o8 = map(T,U,{a, a})            -- one destination supplied, two generators mapped

That is an argument for the option form rather than against it, but it also means any change here
should not extend the silent filling to more cases.

open · disposition issue · source of truth: 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 in Core/ringmap.m2 around lines 495-501, where option-style destinations are parsed and unspecified generators are handled. Reproduce the examples in the issue, especially maps between shared ring towers, and verify that omitted generators are retained only when they exist in the target while genuinely undefined destinations still raise an error.

Written by the indexing model from the issue text.

Assessment

Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.