Skip to content
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

Implicit function solver for lazy series #38108

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

Conversation

mantepse
Copy link
Contributor

@mantepse mantepse commented May 29, 2024

This pull request provides a method define_implicitly for lazy rings that allows to produce lazy power series solutions for systems of functional equations, in relatively great generality, superseding #37033.

We use a special action to make sure that coercion between CoefficientRing and its base ring works as desired. However, it is a local change, if the current approach eventually shows its shortcomings. (Alternative approach previously considered: Using a special functor to control the pushout behaviors. The action approach was chosen as a way to prevent potential conflicts with other construction functors that may appear in the future.)

Dependencies: #38729

tscrim and others added 30 commits October 10, 2023 12:21
… of cache may contain variable, add failing test
…s, use 'is' for equality when finding input streams in Stream_uninitialized
vbraun pushed a commit to vbraun/sage that referenced this pull request Jan 25, 2025
    
In an effort to make sagemath#38108 more usable, we optimize the computation of
gcd's in generic polynomial rings.
    
URL: sagemath#38924
Reported by: Martin Rubey
Reviewer(s): Martin Rubey, mathzeta, Travis Scrimshaw
vbraun pushed a commit to vbraun/sage that referenced this pull request Jan 26, 2025
    
In an effort to make sagemath#38108 more usable, we optimize the computation of
gcd's in generic polynomial rings.
    
URL: sagemath#38924
Reported by: Martin Rubey
Reviewer(s): Martin Rubey, mathzeta, Travis Scrimshaw
@tscrim tscrim changed the title lazy series/pushout experiment Implicit function solver for lazy series Feb 11, 2025
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. There just a few more details I have seen when giving this another look over.

I have one additional question. This gets rid of the old implicit definition, correct? I expect this to be slower than the "solver" we have before for f = G(f). Thus, I am thinking we should keep that implementation for that special case. It's possible I missed something when looking at the code.

Comment on lines 669 to 677

If ``self`` is a univariate Laurent, power, or Dirichlet
series, this is the list containing the one of the base ring.

If ``self`` is a multivariate power series, this is the list
of monomials of total degree ``n``.

If ``self`` is a lazy symmetric function, this is the list
of basis elements of total degree ``n``.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This data/explanation is better with the concrete implementations as this could fall out of date as new implementations are added.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The specifications are also in the concrete implementations. I slightly reworded to make it clear that this is intended as an explanation of the purpose of the (abstract) method.

Comment on lines 1922 to 1923
- ``var``, a variable in ``self._P``
- ``val``, the value that should replace the variable
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
- ``var``, a variable in ``self._P``
- ``val``, the value that should replace the variable
- ``var`` -- a variable in ``self._P``
- ``val`` -- the value that should replace the variable

@mantepse
Copy link
Contributor Author

Thank you. There just a few more details I have seen when giving this another look over.

I have one additional question. This gets rid of the old implicit definition, correct? I expect this to be slower than the "solver" we have before for f = G(f). Thus, I am thinking we should keep that implementation for that special case. It's possible I missed something when looking at the code.

No, the special case is treated as before - although it is also handled by Stream_uninitialized. The distinction is made by checking whether self._target is None, see Stream_uninitialized.__getitem__.

Yes, f.define(G(f)) is much faster, whenever it works.

@tscrim
Copy link
Collaborator

tscrim commented Feb 12, 2025

Ah, okay, thank you. Then once the other details are addressed, then this will be a positive review.

@mantepse
Copy link
Contributor Author

Cool, I'm on it. Good evening? :-)

@tscrim
Copy link
Collaborator

tscrim commented Feb 12, 2025

Still the afternoon, but getting late. Greetings from Singapore. I hope you are feeling better now.

@mantepse
Copy link
Contributor Author

thank you, well, better indeed, but still somewhat so-so :-)

Currently running tests. Short summary: is_prime_field is now indeed unnecessary, QQ in Stream_function(lambda n: QQ(n), True, 1) is necessary, because we expect elements of the stream to be in a correct parent, and lambda n: n in fact produces int.

@mantepse
Copy link
Contributor Author

I cannot reproduce the failure in symmetric_ideal.py.

@mantepse
Copy link
Contributor Author

I marked the one doctest failure on macos as random. Apparently, the order of the variables is different on macos than on linux. However, it is more valuable to have the full output of the doctest, and, since it is an error message, I do not want to try to make the error message less random, which would involve some work and introduce more brittleness.

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 the changes. This now LGTM. Thank you for all of your hard work in getting this implemented. This is a major new feature.

One last thing before a positive review.

@mantepse
Copy link
Contributor Author

After #39523, the doctests after The Frobenius character of labelled Dyck words, lines 895-905, will not be slow anymore.

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. Let's get this in. Any additional improvements or fixes can be done on later on followup PRs.

vbraun pushed a commit to vbraun/sage that referenced this pull request Feb 18, 2025
    
This pull request provides a method `define_implicitly` for lazy rings
that allows to produce lazy power series solutions for systems of
functional equations, in relatively great generality, superseding
sagemath#37033.

We use a special action to make sure that coercion between
`CoefficientRing` and its base ring works as desired. However, it is a
local change, if the current approach eventually shows its shortcomings.
(Alternative approach previously considered: Using a special functor to
control the pushout behaviors. The action approach was chosen as a way
to prevent potential conflicts with other construction functors that may
appear in the future.)

Dependencies: sagemath#38729
    
URL: sagemath#38108
Reported by: Martin Rubey
Reviewer(s): Martin Rubey, Travis Scrimshaw
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.

2 participants