Opened 8 years ago

Closed 7 years ago

# Morphisms cannot be applied to too-simple elements of a multivariate power series ring

Reported by: Owned by: darij major sage-6.3 algebra rings, power series, polynomials SimonKing, niles Darij Grinberg Peter Bruin N/A 99a7fb6 99a7fb62fcabcf9babb5839df3c144f68cb918c8

### Description

```sage: M.<u,v> = PowerSeriesRing(GF(5))
sage: s = M.hom([u, u+v])
sage: s(M.one())
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-4-754f257583fc> in <module>()
----> 1 s(M.one())

/home/darij/sage-5.11.beta3/local/lib/python2.7/site-packages/sage/categories/map.so in sage.categories.map.Map.__call__ (sage/categories/map.c:4018)()

/home/darij/sage-5.11.beta3/local/lib/python2.7/site-packages/sage/rings/morphism.so in sage.rings.morphism.RingHomomorphism_im_gens._call_ (sage/rings/morphism.c:7481)()

/home/darij/sage-5.11.beta3/local/lib/python2.7/site-packages/sage/rings/multi_power_series_ring_element.pyc in _im_gens_(self, codomain, im_gens)
611             x + 2*y + 12*x*y^2 + O(x, y)^5
612         """
--> 613         return codomain(self(*im_gens))
614
615     def __getitem__(self,n):

/home/darij/sage-5.11.beta3/local/lib/python2.7/site-packages/sage/rings/multi_power_series_ring_element.pyc in __call__(self, *x, **kwds)
462         else:
463             newprec = self.prec()*min(valn_list)
465
466     def _subs_formal(self, *x, **kwds):

/home/darij/sage-5.11.beta3/local/lib/python2.7/site-packages/sage/structure/element.so in sage.structure.element.Element.__getattr__ (sage/structure/element.c:3871)()

/home/darij/sage-5.11.beta3/local/lib/python2.7/site-packages/sage/structure/misc.so in sage.structure.misc.getattr_from_other_class (sage/structure/misc.c:1696)()

AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object has no attribute 'add_bigoh'
```

(Alternatively, the same error can be caught by calling `M.one()._im_gens_(M, [u,u+v])` without ever defining `s`.)

Note that `s(u)` and `s(v)` work fine.

### comment:1 Changed 8 years ago by darij

Fixed. The patch was uploaded twice due to connection issues; it's one and the same file nevertheless.

The issue at hand was that the `__call__` method of class `MPowerSeries` (elements of multivariate power series rings) calls the `subs` method of polynomials, but this method behaves somewhat unpredictably as concerning the parent of its output: If the input is a constant polynomial, it does not change the base ring (even if the substitution should send polynomials from ZZ to polynomials from ZZ/5ZZ):

```sage: K.<x,y> = PolynomialRing(ZZ)
sage: T.<u,v> = PolynomialRing(Integers(5))
sage: parent(x.subs(x=u, y=v))
Multivariate Polynomial Ring in u, v over Ring of integers modulo 5
sage: parent(K.one().subs(x=u, y=v))
Integer Ring
```

Note that this issue only appears with multivariate polynomials. Univariate ones substitute fine.

Is my fix misguided in that it fixes the symptom rather than the cause?

patchbot:

apply trac_15059-multivariate_fix-dg.patch​

### comment:2 Changed 8 years ago by darij

• Status changed from new to needs_review

### comment:4 Changed 8 years ago by darij

• Cc niles added; nilesj removed

### comment:5 Changed 8 years ago by vbraun_spam

• Milestone changed from sage-6.1 to sage-6.2

### comment:6 Changed 7 years ago by pbruin

• Authors set to Darij Grinberg
• Branch set to u/pbruin/15059-MPowerSeries_call
• Commit set to 99a7fb62fcabcf9babb5839df3c144f68cb918c8
• Reviewers set to Peter Bruin
• Status changed from needs_review to positive_review

Looks good; the patch applied without conflicts, I only converted it into a Git branch to delete trailing whitespace. It fixes the bug and passes all tests. I don't want to think about deciding where the result of `subs()` should live in general...

### comment:7 Changed 7 years ago by darij

Thank you! I'm just hoping it doesn't conflict with the ongoing category revamp...

### comment:8 Changed 7 years ago by vbraun_spam

• Milestone changed from sage-6.2 to sage-6.3

### comment:9 Changed 7 years ago by vbraun

• Branch changed from u/pbruin/15059-MPowerSeries_call to 99a7fb62fcabcf9babb5839df3c144f68cb918c8
• Resolution set to fixed
• Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.