Skip to content

Add an infinite weyl algebra class #40263

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

Merged
merged 24 commits into from
Aug 2, 2025

Conversation

jmcdonough98
Copy link
Contributor

This PR adds a class InfiniteDifferentialWeylAlgebra, the infinite analog of the currently existing DifferentialWeylAlgebra class. It is an algebra generated by two countable families of symbols x_i, dx_i subject to the relations [x_i, x_j] = [dx_i, dx_j] = 0 and [x_i, dx_j] = \delta_{i, j}

Part of #40241

cc: @tscrim

📝 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.

⌛ Dependencies

Copy link

github-actions bot commented Jun 16, 2025

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

Comment on lines 638 to 639
elif isinstance(R, InfinitePolynomialRing_dense):
return InfiniteDifferentialWeylAlgebra(R, names)
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
elif isinstance(R, InfinitePolynomialRing_dense):
return InfiniteDifferentialWeylAlgebra(R, names)
elif isinstance(R, InfinitePolynomialRing_dense) and names is None:
return InfiniteDifferentialWeylAlgebra(R.base_ring(), R.variable_names())

What if the base ring for a finitely generated Weyl algebra is an infinite polynomial ring? (Add a test checking this works as expected.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This seems to work as expected (added some tests to make sure both infinite over finite and finite over infinite work as expected.
One issue I noticed is that the InfinitePolynomialRing class collapses things down, so it would be tricky to define an infinite weyl algebra over and infinite polynomial ring. For instance, here it forgets that R is the base ring.
sage: R.<x> = InfinitePolynomialRing(QQ)
sage: R2.<y> = InfinitePolynomialRing(R)
sage: R2.base_ring()
Rational Field

Comment on lines 1287 to 1293
if isinstance(R, InfinitePolynomialRing_dense):
names = R.variable_names()
if len(names) > 1:
raise NotImplementedError("only one set of variables supported")
R = R.base_ring()
elif names is None:
names = ('x',)
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
if isinstance(R, InfinitePolynomialRing_dense):
names = R.variable_names()
if len(names) > 1:
raise NotImplementedError("only one set of variables supported")
R = R.base_ring()
elif names is None:
names = ('x',)
if isinstance(R, InfinitePolynomialRing_dense) and names is None:
names = R.variable_names()
if len(names) > 1:
raise NotImplementedError("only one set of variables supported")
R = R.base_ring()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removing this causes an error when you construct via
sage: W = DifferentialWeylAlgebra(QQ, n=oo)
I moved the check to the differential weyl classcall to handle this case.

@jmcdonough98 jmcdonough98 marked this pull request as ready for review July 3, 2025 01:36
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.

Just some little details.

"""
An element of an infinitely generated differential Weyl algebra.

TESTS::
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
TESTS::
EXAMPLES::

for _ in range(p):
next = []
for m, c in cur:
diff = dict(m[1].dict())
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
diff = dict(m[1].dict())
diff = m[1].dict()

The extra dict call should not be necessary.

Comment on lines 1306 to 1307
We can construct an Infinite Weyl algebra by using the ``n=oo`` parameter in
the constructor for DifferentialWeylAlgebra::
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
We can construct an Infinite Weyl algebra by using the ``n=oo`` parameter in
the constructor for DifferentialWeylAlgebra::
We construct an infinite Weyl algebra by using the ``n=oo`` in
:class:`DifferentialWeylAlgebra`::

Comment on lines 1322 to 1332
Due to a bug in ``InfinitePolynomialRing`` (see :issue:`36788`) trying to define the infinite Weyl
algebra of an infinite polynomial ring with coefficients in another infinite
polynomial ring will result in unexpected behavior::

sage: R.<x> = InfinitePolynomialRing(QQ)
sage: R2.<y> = InfinitePolynomialRing(R)
sage: W = DifferentialWeylAlgebra(R2); W # known bug
Differential Weyl algebra in countably many variables z over Infinite
polynomial ring in x over Rational Field


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
Due to a bug in ``InfinitePolynomialRing`` (see :issue:`36788`) trying to define the infinite Weyl
algebra of an infinite polynomial ring with coefficients in another infinite
polynomial ring will result in unexpected behavior::
sage: R.<x> = InfinitePolynomialRing(QQ)
sage: R2.<y> = InfinitePolynomialRing(R)
sage: W = DifferentialWeylAlgebra(R2); W # known bug
Differential Weyl algebra in countably many variables z over Infinite
polynomial ring in x over Rational Field
Due to a bug in ``InfinitePolynomialRing`` (:issue:`36788`) trying to define the infinite Weyl
algebra of an infinite polynomial ring with coefficients in another infinite
polynomial ring will result in unexpected behavior::
sage: R.<x> = InfinitePolynomialRing(QQ)
sage: R2.<y> = InfinitePolynomialRing(R)
sage: W = DifferentialWeylAlgebra(R2); W # known bug
Differential Weyl algebra in countably many variables z over Infinite
polynomial ring in x over Rational Field

sage: W = DifferentialWeylAlgebra(R); W
Differential Weyl algebra in countably many variables x over Rational Field

.. WARNING:
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
.. WARNING:
.. WARNING::


OUTPUT: A nonnegative integer

EXAMPLE::
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
EXAMPLE::
EXAMPLES::

We generally make it plural, even if there is only 1 test/example.

@jmcdonough98
Copy link
Contributor Author

should be good to go now!

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.

Let's get this in. Positive review.

vbraun pushed a commit to vbraun/sage that referenced this pull request Jul 18, 2025
sagemathgh-40263: Add an infinite weyl algebra class
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

This PR adds a class ``InfiniteDifferentialWeylAlgebra``, the infinite
analog of the currently existing ``DifferentialWeylAlgebra`` class.  It
is an algebra generated by two countable families of symbols x_i, dx_i
subject to the relations [x_i, x_j] = [dx_i, dx_j] = 0 and [x_i, dx_j] =
\delta_{i, j}

Part of sagemath#40241

cc: @tscrim

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

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

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#40263
Reported by: Joe McDonough
Reviewer(s): Joe McDonough, Travis Scrimshaw
@vbraun
Copy link
Member

vbraun commented Jul 20, 2025

Fails with the same error as the CI

@jmcdonough98
Copy link
Contributor Author

jmcdonough98 commented Jul 21, 2025

@vbraun I'm a bit confused by the cause of this error. Somehow importing sage.monoids.indexed_free_monoid is causing a test in an unrelated file to fail. I changed the import statement to a lazy_import and it fixed the failing test (locally, anyway), but I'm not sure why. Regardless, it should be good to go now, though if what I've done is not best practice I'm happy to attempt to fix it some other way.

Also cc'ing @tscrim in case he needs to re positive review the PR.

edit: it seems like one of the CI tests is now failing on a doctest for singular, but I'm not sure how to go about diagnosing why.

@tscrim
Copy link
Collaborator

tscrim commented Jul 30, 2025

Now it is passing all of the builds.

@vbraun vbraun merged commit a47ad86 into sagemath:develop Aug 2, 2025
24 of 30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: algebra gsoc: 2025 Tag for GSoC2025 issues/PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants