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

Unexpected AttributeError: 'PowerSeriesRing_over_field_with_category' object has no attribute '_pseudo_fraction_field' #39684

Open
2 tasks done
maxale opened this issue Mar 12, 2025 · 9 comments · May be fixed by #39713
Open
2 tasks done
Labels

Comments

@maxale
Copy link
Contributor

maxale commented Mar 12, 2025

Steps To Reproduce

sage: K.<z> = PowerSeriesRing(QQ,default_prec=10)
sage: R.<x> = PowerSeriesRing(K,default_prec=6)
sage: 1/(1-z)
1 + z + z^2 + z^3 + z^4 + z^5 + z^6 + z^7 + z^8 + z^9 + O(z^10)
sage: x*(1/(1-z))
(1 + z + z^2 + z^3 + z^4 + z^5 + z^6 + z^7 + z^8 + z^9 + O(z^10))*x
sage: x/(1-z)
...
AttributeError: 'PowerSeriesRing_over_field_with_category' object has no attribute '_pseudo_fraction_field'

Expected Behavior

x/(1-z) should work similarly to x*(1/(1-z)).

Actual Behavior

It errors out.

Additional Information

The code works fine in Sage 10.2, and so it was broken some time recently.

Environment

  • OS: 10.6.beta7
  • Sage Version: Ubuntu 24.04.2 LTS

Checklist

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.
  • I have read the documentation and troubleshoot guide
@nbruin
Copy link
Contributor

nbruin commented Mar 13, 2025

datapoint: this still seems to work fine in 10.5.beta6 and indeed takes a fraction field for the scalar:

sage: K.<z> = PowerSeriesRing(QQ,default_prec=10)
sage: R.<x> = PowerSeriesRing(K,default_prec=6)
sage: x/(1-z)
(1 + z + z^2 + z^3 + z^4 + z^5 + z^6 + z^7 + z^8 + z^9 + O(z^10))*x
sage: parent(x/(1-z))
Power Series Ring in x over Laurent Series Ring in z over Rational Field 

@maxale
Copy link
Contributor Author

maxale commented Mar 13, 2025

sage: parent(x/(1-z))
Power Series Ring in x over Laurent Series Ring in z over Rational Field

Oh, I'm not sure if the change to Laurent Series Ring should be welcomed here.

@nbruin
Copy link
Contributor

nbruin commented Mar 13, 2025

Yes, the change to Laurent series ring is as advertised: inverting an element of K leads to an element in its fraction field. You can use

(1-z).inverse_of_unit()

if you want the inverse of an element you know is a unit, as an element of the ring.

@maxale
Copy link
Contributor Author

maxale commented Mar 13, 2025

@nbruin: Ok, it seems that what I really miss here is the ability to compute x//(1-z), which should end up in the same ring as x. It gives me

TypeError: unsupported operand parent(s) for //: 'Power Series Ring in z over Rational Field' and 'Power Series Ring in z over Rational Field'

There is a related issue #38570, which is however about multivariate power series, while here we have a univariate one.

@nbruin
Copy link
Contributor

nbruin commented Mar 13, 2025

There is a related issue #38570, which is however about multivariate power series, while here we have a univariate one.

That issue is about // with units from the base ring (and definitely something that can be fixed). Here it's about // with a power series itself. Over a field, k[[x]] is a euclidean ring, so // and % can definitely work. In fact their operations are already implemented:

sage: R.<z>=QQ[[]]
sage: (z).__divmod__(1-z)
(z + z^2 + z^3 + z^4 + z^5 + z^6 + z^7 + z^8 + z^9 + z^10 + z^11 + z^12 + z^13 + z^14 + z^15 + z^16 + z^17 + z^18 + z^19 + z^20 + O(z^21),
 0)
sage: (1-z).__divmod__(z)
(0, 1 - z)

they just need to be exposed under // and %.

For multivariate power series rings it's a little trickier because these are not euclidean rings. One can define "remainder" in those cases by imposing an appropriate (local) monomial ordering. Alternatively, we could just have // as a partial operation, which only produces a result if the denominator divides the numerator (which is always if the denominator is a unit) and produces an error otherwise.

@maxale
Copy link
Contributor Author

maxale commented Mar 13, 2025

Alternatively, we could just have // as a partial operation, which only produces a result if the denominator divides the numerator (which is always if the denominator is a unit) and produces an error otherwise.

This is what I have in mind for multivariate power series. I'd really appreciate it implemented.

@vidipsingh vidipsingh linked a pull request Mar 15, 2025 that will close this issue
5 tasks
@vidipsingh
Copy link

Alternatively, we could just have // as a partial operation, which only produces a result if the denominator divides the numerator (which is always if the denominator is a unit) and produces an error otherwise.

This is what I have in mind for multivariate power series. I'd really appreciate it implemented.

Hi @maxale,
I’ve tried implementing the changes for division by handling elements in the base ring as units.
Do you think this is the right approach, or should I consider an alternative method? Would appreciate your feedback!

@maxale
Copy link
Contributor Author

maxale commented Mar 15, 2025

@vidipsingh testing for unit may be a bad idea - please see discussion in #39318 (comment) Anyway, @nbruin is an expert here and can provide much better feedback.

@vidipsingh
Copy link

@vidipsingh testing for unit may be a bad idea - please see discussion in #39318 (comment) Anyway, @nbruin is an expert here and can provide much better feedback.

Hi @maxale, Thanks for the feedback! I'll check out the discussion.

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

Successfully merging a pull request may close this issue.

3 participants