#12969: Coercion failures in symmetric functions
-------------------------------------------------+-------------------------
       Reporter:  aschilling                     |        Owner:  sage-
           Type:  defect                         |  combinat
       Priority:  major                          |       Status:  closed
      Component:  coercion                       |    Milestone:  sage-5.3
       Keywords:  symmetric functions, coercion  |   Resolution:  fixed
        Authors:  Simon King                     |    Merged in:
Report Upstream:  N/A                            |  sage-5.3.beta0
         Branch:                                 |    Reviewers:  Anne
   Dependencies:                                 |  Schilling
                                                 |  Work issues:
                                                 |       Commit:
                                                 |     Stopgaps:
-------------------------------------------------+-------------------------
Description changed by chapoton:

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 #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] and
> [attachment:trac_12969-avoid_coercion_from_none.patch], if #5457 is not
> applied
>  * All three patches, if #5457 is applied

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] and
 [attachment:trac_12969-avoid_coercion_from_none.patch], if #5457 is not
 applied
  * All three patches, if #5457 is applied

--

--
Ticket URL: <http://trac.sagemath.org/ticket/12969#comment:41>
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to