Skip to content

Add Chow package for intersection theory #40023

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 24 commits into
base: develop
Choose a base branch
from

Conversation

giannipetrella
Copy link

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation and checked the documentation preview.

Description

This PR merges the Chow library, written by Christoph Sorger (@sorger-c) and Manfred Lehn, into Sagemath.
The library is otherwise only accessible by checking out a specific commit of Sage, which is not ideal for users who are not git-savy.

This completes the integration discussed in #27228 by @sorger-c and @fchapoton.

@fchapoton
Copy link
Contributor

new files must be added to the meson.build files in their directory

fix rst syntax in doc there
@fchapoton
Copy link
Contributor

fchapoton commented Apr 29, 2025

I allowed myself to make a direct commit on the branch, so please pull before working further.

Copy link

github-actions bot commented Apr 29, 2025

Documentation preview for this PR (built with commit 23c9d4e; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

Copy link
Collaborator

@tscrim tscrim left a comment

Choose a reason for hiding this comment

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

Thank you for adding this. This will be a great addition to have. Right now, from a quick look I have some general comments/questions:

  1. You should not import many of the things into the global namespace (in particular, those in chow/all.py). This could create some conflicts with things already in Sage and pollutes the namespace. There should be better ways to access these objects. See below for some suggestions.
  2. I don't quite see a reason for having a ChowScheme class. I understand the basic principle, that it is for schemes that know their Chow ring. However, I think this is best directly added into the Scheme class (and related constructions) that call the chow_ring() method. For the schemes where this is known. You would still have the specific subclasses. The input to scheme constructions perhaps could then be extended to accept the Chow ring data.
  3. The readme file is better as the thematic tutorial or the top-level documentation of one of the chow/* files (preferably some "main" or highly-likely-to-be-accessed file).
  4. For the schemes where the Chow ring is known, I would create a "catalog" like how we have for, e.g., algebras.
  5. It would be good if this could fit in with the toric varieties Chow group (I believe they are related, but I am not an expert): https://doc.sagemath.org/html/en/reference/schemes/sage/schemes/toric/chow_group.html
  6. General Returns -> Return and EXAMPLE:: -> EXAMPLES:: following our doc conventions.

sage: x.truncate(1, 2)
4*E^2 + 3*H - E
"""
return sum([x for x in self.by_degrees()[a:b + 1]])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
return sum([x for x in self.by_degrees()[a:b + 1]])
return self.parent().sum(x for x in self.by_degrees()[a:b + 1])

In case the result is 0 in order to have the correct parent.

sage: x = 2 + 3*h - 5*h^3
sage: TestSuite(x).run()
"""
self._parentchowring = parent
Copy link
Collaborator

Choose a reason for hiding this comment

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

You don't need to set this attribute since it is accessible via self.parent().

"""
A = self._parentchowring
if A.ngens() == 0:
return richcmp(QQ(str(self)), QQ(str(other)), op)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why does this need a special case? Also, going via strings seems like a very slow way to do it.

Comment on lines +187 to +189
- ``a`` -- an optional integer (defaults to 0)

- ``b`` -- an optional integer (defaults to 0)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- ``a`` -- an optional integer (defaults to 0)
- ``b`` -- an optional integer (defaults to 0)
- ``a`` -- (default: 0) integer
- ``b`` -- (default: 0) integer

return self.lift().degree()

@cached_method
def _expp(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't understand these internal method docstrings. Please rewrite.

@giannipetrella
Copy link
Author

Thank you both for the useful comments and suggestions!

I am not the author of this code, so I can’t comment on design choices made by the authors several years ago;
I will take your input in consideration and improve as I can.

@fchapoton
Copy link
Contributor

You still need to add two new "meson.build" files, one inside chow/ and one inside library (I think).

@tscrim
Copy link
Collaborator

tscrim commented May 2, 2025

Indeed, but I think we should make sure it is done in a good way before we integrate it in. I can help, but I don’t know how much time I will have in the next few weeks to do a significant amount on this. I can definitely discuss things on here if you have any questions.

@fchapoton
Copy link
Contributor

I allowed myself again to make a direct commit on the branch, so please pull before working further.

@giannipetrella
Copy link
Author

Dear all,

Thank you both again. I have thought about your remarks, and I am implementing most of your suggestions. However, I believe there is a design choice to be made to properly address your remark 2 @tscrim (and consequently remark 5): see below.

The issue is that schemes do not, in general, admit a Chow group; only varieties, which are a special case of schemes, do. This means that for mathematical consistency, one would need a Variety type (which would be a subtype of Schemes), with a Chow_group attribute. If the variety is smooth, the Chow group also admits a ring structure, which is what here is called “Chow ring”. The already existing ToricVariety class would then be a subtype of this Variety.

Introducing the ChowRing as an attribute of Variety, or Scheme for that matter, would however introduce an ambiguity I am not sure how to handle. The fact is that once one defines a morphism of varieties, there is (afaik) no general method to compute the induced morphism of Chow groups. This means that a morphism of Varieties would not necessarily carry the datum of the corresponding morphism of Chow rings, unless this is known or manually set by the user.

I would like to ask for advice on such a design choice, since I think it would go beyond the scope of this library alone…

@fchapoton
Copy link
Contributor

probably you should remove the empty __init__ files

@fchapoton
Copy link
Contributor

@tobiasdiez : what needs to be done here about the meson.build files so that it works, please ?

@tobiasdiez
Copy link
Contributor

tobiasdiez commented May 7, 2025

Judging from the log, it should be enough to simply add the autogenerated __init__.py to gitignore. Alternatively (and perhaps better), don't generate the init file but just commit it directly (i.e revert 83af662 but instead revert the changes to the top-level meson build file)

@fchapoton
Copy link
Contributor

I would go for the first option : please add one line to the file .gitignore

@giannipetrella
Copy link
Author

Thank you for the help, now it builds (but still fails a test in the thematic tutorial, will fix that).

The necessary design choice of ChowSchemes vs Variety as a subtype of Scheme mentioned above still persists: what would be a good way to handle it? I am not that familiar with Sage development, so I am not sure what the best approach would be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants