Macaulay2 / Macaulay2/M2

issue with promote and ancestry of CC_53 and SheafOfRings

Open
#4,194 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

There's an issue involving `promote` which I haven't been able to resolve.

Currently, `RingElement * ComplexMap` starts with:
```m2
RingElement * ComplexMap := ComplexMap => (r,f) -> (
if ring r =!= ring f then
try r = promote(r,ring f)
else error "can't promote scalar to ring of complex homomorphism";
```
This is fine for complexes of modules, but in the next update of the Varieties package we would like to support the same for complexes of coherent sheaves. In this case, `ring f` will return not the base ring, but the structure sheaf `OO_X` which has type `SheafOfRings`, with ancestry `SheafOfRings, Ring, Type, MutableHashTable, HashTable, Thing`.

The problem is that we need `promote(r,ring f)` to promote `r` to the underlying ring of `OO_X`, which we can get from `OO_X.ring`, but I can't figure out how to cleanly do this.

A kludge I found is to add:
```m2
promote(RingElement, Nothing) := RingElement => (r, O) -> try promote(r, O.ring) else r
```
However, doing so causes this to fail:
```m2
i8 : map(CC_53, CC_53[x,y])
stdio:8:3:(3): error: no method found for applying promote to:
argument 1 : | x y | (of class Matrix)
argument 2 : CC [x..y]
53
argument 3 : CC
53
```
As far as I can tell, this is affected because ancestry of `C_53` is `C_53, Nothing, Thing` (This is part of a test in `NAGtypes` package, but that package is irrelevant here.) Oddly, without that kludge, `map(CC_53, CC_53[x,y])` doesn't get routed to this non-existent method at all (in fact, `S = CC_53[x]; promote(vars S, S, CC_53)` already fails). So I'm not sure what's going on.

I hope there's a simple fix involving SheafOfRings or its ancestry that I just haven't thought of, but I'm worried this requires more changes to either promote or C_53.

cc:
- @pzinn since you're interested in promote issues.
- @btotaro since you've pointed out this issue as well.

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 by reproducing the promote failures with the shown CC_53, SheafOfRings, and map examples, then trace promote method dispatch and the ancestry definitions for Ring, SheafOfRings, and Nothing. Done means the intended promotion to the underlying ring works for coherent-sheaf complexes without breaking map(CC_53, CC_53[x,y]).

Written by the indexing model from the issue text.

Assessment

Domain
tooling
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.