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

Calling a lazy power series ring twice summons demons from hell #15248

Closed
darijgr opened this issue Oct 1, 2013 · 12 comments
Closed

Calling a lazy power series ring twice summons demons from hell #15248

darijgr opened this issue Oct 1, 2013 · 12 comments

Comments

@darijgr
Copy link
Contributor

darijgr commented Oct 1, 2013

sage: R = LazyPowerSeriesRing(QQ)
sage: x = R.gen()
sage: x
x
sage: M = Matrix(R, [[x, x], [1, x]])
sage: M.det()
Uninitialized lazy power series

Sounds good so far. Now let's do this all again, in the same session:

sage: R = LazyPowerSeriesRing(QQ)
sage: x = R.gen()
sage: x
x
sage: M = Matrix(R, [[x, x], [1, x]])
sage: M.det()
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-10-90e0c7c30c91> in <module>()
----> 1 M.det()

/home/darij/sage-5.12.beta5/local/lib/python2.7/site-packages/sage/matrix/matrix2.so in sage.matrix.matrix2.Matrix.det (sage/matrix/matrix2.c:10774)()

/home/darij/sage-5.12.beta5/local/lib/python2.7/site-packages/sage/matrix/matrix2.so in sage.matrix.matrix2.Matrix.determinant (sage/matrix/matrix2.c:8701)()

/home/darij/sage-5.12.beta5/local/lib/python2.7/site-packages/sage/structure/element.so in sage.structure.element.RingElement.__mul__ (sage/structure/element.c:14531)()

/home/darij/sage-5.12.beta5/local/lib/python2.7/site-packages/sage/structure/coerce.so in sage.structure.coerce.CoercionModel_cache_maps.bin_op (sage/structure/coerce.c:7330)()

/home/darij/sage-5.12.beta5/local/lib/python2.7/site-packages/sage/structure/coerce.so in sage.structure.coerce.CoercionModel_cache_maps.canonical_coercion (sage/structure/coerce.c:8800)()

/home/darij/sage-5.12.beta5/local/lib/python2.7/site-packages/sage/structure/coerce.so in sage.structure.coerce.CoercionModel_cache_maps._coercion_error (sage/structure/coerce.c:14607)()

RuntimeError: There is a bug in the coercion code in Sage.
Both x (=1) and y (=x) are supposed to have identical parents but they don't.
In fact, x has parent 'Lazy Power Series Ring over Rational Field'
whereas y has parent 'Lazy Power Series Ring over Rational Field'
Original elements 1 (parent Lazy Power Series Ring over Rational Field) and x (parent Lazy Power Series Ring over Rational Field) and maps
<type 'NoneType'> None
<type 'sage.categories.morphism.CallMorphism'> Call morphism:
  From: Lazy Power Series Ring over Rational Field
  To:   Lazy Power Series Ring over Rational Field

This error does not persist if I set M to be Matrix(R, [[x, x], [x, x]]) instead, so the coercion of 1 from integers to lazy power series seems to trigger the issue.

CC: @simon-king-jena @mantepse

Component: coercion

Keywords: LazyPowerSeries

Issue created by migration from https://trac.sagemath.org/ticket/15248

@darijgr darijgr added this to the sage-6.1 milestone Oct 1, 2013
@darijgr

This comment has been minimized.

@nbruin
Copy link
Contributor

nbruin commented Oct 1, 2013

comment:2

Classic example of constructing "unique" objects over "non-identical-but-equal" bases. Excellent find! It's well-known this is bound to give problems, but I'm not sure we had such a clear example yet.

sage: R.<x>=LazyPowerSeriesRing(QQ)
sage: S.<x>=LazyPowerSeriesRing(QQ)
sage: R is S
False
sage: R == S
True
sage: MR=MatrixSpace(R,2,2)
sage: MS=MatrixSpace(S,2,2)
sage: MR is MS
True

Since R==S, the construction of MS will return MR again. So MS has R as a base, not S:

sage: MS.base() is R, MS.base() is S
(True, False)

After this it's unavoidable:

sage: S.0 + R.0
RuntimeError: There is a bug in the coercion code in Sage.
Both x (=x) and y (=x) are supposed to have identical parents but they don't.

and you're hitting a more insidious form with

sage: MR(R.0)
[x 0]
[0 x]
sage: MS(S.0)
RuntimeError: There is a bug in the coercion code in Sage.

@darijgr
Copy link
Contributor Author

darijgr commented Oct 1, 2013

comment:3

Great job tracing this to its origins in 15 minutes!

@jdemeyer
Copy link

comment:4

Just saw this ticket by chance: funniest title ever :-) I should try that to my own tickets too...

@mantepse
Copy link
Collaborator

Changed keywords from lazy-power-series to LazyPowerSeries

@mwhansen
Copy link
Contributor

comment:6

This can be fixed by moving LazyPowerSeriesRing over to the new parent framework. I'll do this this evening.

@mwhansen
Copy link
Contributor

comment:7

A fix is in #15673

@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.1, sage-6.2 Jan 30, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.2, sage-6.3 May 6, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.3, sage-6.4 Aug 10, 2014
@mantepse
Copy link
Collaborator

comment:11

This works now, since #32367.

@mantepse mantepse removed this from the sage-6.4 milestone Sep 21, 2022
@fchapoton
Copy link
Contributor

comment:12

is this doctested ? where exactly ?

@tscrim
Copy link
Collaborator

tscrim commented Oct 22, 2022

comment:13

This isn't something specific to lazy power series, it is an issue for any ring where we can have equal-but-not-identical instances as per Nil's comment:2. We just need to find another instance of this with a different base ring.

@tscrim
Copy link
Collaborator

tscrim commented Sep 7, 2023

This has been fixed in the current version (likely by the switch to the new parent/element structure). I don't think there is a reasonable doctest to add here. @darijgr @mantepse What do you think>

@mantepse
Copy link
Collaborator

mantepse commented Sep 8, 2023

I agree. Moreover, I don't think it is helpful to keep this open.

@tscrim tscrim closed this as completed Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants