#12969: Coercion failures in symmetric functions
-------------------------------------------------+--------------------------
       Reporter:  aschilling                     |         Owner:  sage-combinat
           Type:  defect                         |        Status:  needs_review 
       Priority:  major                          |     Milestone:  sage-5.3     
      Component:  combinatorics                  |    Resolution:               
       Keywords:  symmetric functions, coercion  |   Work issues:               
Report Upstream:  N/A                            |     Reviewers:               
        Authors:  Simon King                     |     Merged in:               
   Dependencies:                                 |      Stopgaps:               
-------------------------------------------------+--------------------------

Old description:

> The following code triggers a coercion failure in the symmetric function
> code
>
> {{{
>     sage: H = MacdonaldPolynomialsH(QQ)
>     sage: P = MacdonaldPolynomialsP(QQ)
>     sage: m = SFAMonomial(P.base_ring())
>     sage: Ht = MacdonaldPolynomialsHt(QQ)
>     sage: m(P.one())
>     m[]
>     sage: Ht(P.one())
> }}}
>
> The coercion path does exist, however!
>
> This can also be checked with the new syntax using the patches in
> [http://trac.sagemath.org/sage_trac/ticket/5457] as follows:
>
> {{{
>     sage: R = QQ['q,t'].fraction_field()
>     sage: Sym = sage.combinat.sf.sf.SymmetricFunctions(R)
>     sage: H = Sym.macdonald().H();
>     sage: P = Sym.macdonald().P();
>     sage: m = Sym.monomial();
>     sage: Ht = Sym.macdonald().Ht();
>     sage: m(P.one())
>     sage: Ht(P.one())
> }}}
>
> The bug is in the coercion system. Sage does
> not find a path from P to Ht, whereas there definitely is one:
>
> {{{
>     def coercion_graph(self, G = None):
>         if G is None:
>             G = DiGraph()
>         if self not in G.vertices():
>             G.add_vertex(self)
>             for h in self._introspect_coerce()['_coerce_from_list']:
>                 coercion_graph(h.domain(), G)
>                 G.add_edge(h.domain(), self)
>         return G
>
>     R = QQ['q,t'].fraction_field()
>     R.rename("R")
>     Sym = sage.combinat.sf.sf.SymmetricFunctions(R); Sym.rename("Sym")
>     p = Sym.p();               p.rename("p")
>     s = Sym.schur();           s.rename("s")
>     e = Sym.elementary();      e.rename("e")
>     m = Sym.monomial();        m.rename("m")
>     h = Sym.complete();        h.rename("h")
>     H = Sym.macdonald().H();   H.rename("H")
>     P = Sym.macdonald().P();   P.rename("P")
>     J = Sym.macdonald().J();   J.rename("J")
>     S = Sym.macdonald().S();   S.rename("S")
>     Ht = Sym.macdonald().Ht(); Ht.rename("Ht")
>     m.coerce_map_from(P);
>     print Ht.coerce_map_from(P)
>     G = coercion_graph(Ht)
>     G.show()
> }}}

New description:

 The following code triggers a coercion failure in the symmetric function
 code

 {{{
     sage: H = MacdonaldPolynomialsH(QQ)
     sage: P = MacdonaldPolynomialsP(QQ)
     sage: m = SFAMonomial(P.base_ring())
     sage: Ht = MacdonaldPolynomialsHt(QQ)
     sage: m(P.one())
     m[]
     sage: Ht(P.one())
 }}}

 The coercion path does exist, however!

 This can also be checked with the new syntax using the patches in #5457 as
 follows:

 {{{
     sage: R = QQ['q,t'].fraction_field()
     sage: Sym = sage.combinat.sf.sf.SymmetricFunctions(R)
     sage: H = Sym.macdonald().H();
     sage: P = Sym.macdonald().P();
     sage: m = Sym.monomial();
     sage: Ht = Sym.macdonald().Ht();
     sage: m(P.one())
     sage: Ht(P.one())
 }}}

 The bug is in the coercion system. Sage does
 not find a path from P to Ht, whereas there definitely is one:

 {{{
     def coercion_graph(self, G = None):
         if G is None:
             G = DiGraph()
         if self not in G.vertices():
             G.add_vertex(self)
             for h in self._introspect_coerce()['_coerce_from_list']:
                 coercion_graph(h.domain(), G)
                 G.add_edge(h.domain(), self)
         return G

     R = QQ['q,t'].fraction_field()
     R.rename("R")
     Sym = sage.combinat.sf.sf.SymmetricFunctions(R); Sym.rename("Sym")
     p = Sym.p();               p.rename("p")
     s = Sym.schur();           s.rename("s")
     e = Sym.elementary();      e.rename("e")
     m = Sym.monomial();        m.rename("m")
     h = Sym.complete();        h.rename("h")
     H = Sym.macdonald().H();   H.rename("H")
     P = Sym.macdonald().P();   P.rename("P")
     J = Sym.macdonald().J();   J.rename("J")
     S = Sym.macdonald().S();   S.rename("S")
     Ht = Sym.macdonald().Ht(); Ht.rename("Ht")
     m.coerce_map_from(P);
     print Ht.coerce_map_from(P)
     G = coercion_graph(Ht)
     G.show()
 }}}

 __Apply__

  * [attachment:trac12969_fix_coercion_cache.patch], if #5457 is not
 applied
  * Both patches, if #5457 is applied

--

Comment (by SimonKing):

 I have attached a second patch. It is ''only'' needed if #5457 is applied.

 Since there seems to be no regression, I think it can now be reviewed.

 For the release manager: Use the second patch on top of that, as soon as
 #5457 is merged.

 For the patchbot:

 Apply trac12969_fix_coercion_cache.patch

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12969#comment:30>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to