Ticket #7729: trac_7729_iwahori-hecke-algebra.3.patch

File trac_7729_iwahori-hecke-algebra.3.patch, 21.2 KB (added by bump, 13 years ago)

Implements Iwahori Hecke algebras

  • sage/algebras/all.py

    #7729: Iwahori Hecke algebras in the T basis
    
    diff --git a/sage/algebras/all.py b/sage/algebras/all.py
    a b  
    3535
    3636from group_algebra import GroupAlgebra, GroupAlgebraElement
    3737
    38    
     38from iwahori_hecke_algebra import IwahoriHeckeAlgebraT
     39   
    3940def is_R_algebra(Q, R):
    4041    # TODO: do something nontrivial when morphisms are defined.
    4142    return True
  • new file sage/algebras/iwahori_hecke_algebra.py

    diff --git a/sage/algebras/iwahori_hecke_algebra.py b/sage/algebras/iwahori_hecke_algebra.py
    new file mode 100644
    - +  
     1"""
     2Iwahori Hecke Algebras
     3"""
     4#*****************************************************************************
     5#  Copyright (C) 2010 Daniel Bump <bump at match.stanford.edu>
     6#                     Nicolas M. Thiery <nthiery at users.sf.net>
     7#
     8#  Distributed under the terms of the GNU General Public License (GPL)
     9#                  http://www.gnu.org/licenses/
     10#*****************************************************************************
     11from sage.categories.all import AlgebrasWithBasis, FiniteDimensionalAlgebrasWithBasis, CoxeterGroups
     12import sage.combinat.root_system.cartan_type
     13from sage.combinat.root_system.cartan_type import CartanType
     14from sage.combinat.root_system.weyl_group import WeylGroup
     15from sage.structure.element import is_Element
     16from sage.rings.all import ZZ
     17from sage.misc.misc import repr_lincomb
     18from sage.algebras.algebra_element import AlgebraElement
     19from sage.combinat.family import Family
     20import sage.rings.polynomial.laurent_polynomial
     21from sage.combinat.free_module import CombinatorialFreeModule, CombinatorialFreeModuleElement
     22from sage.misc.cachefunc import cached_method
     23
     24class IwahoriHeckeAlgebraT(CombinatorialFreeModule):
     25    r"""
     26    INPUT:
     27
     28     - ``W`` -- A CoxeterGroup or CartanType
     29     - ``q1`` -- a parameter.
     30
     31    OPTIONAL ARGUMENTS:
     32
     33     - ``q2`` -- another parameter (default -1)
     34     - ``base_ring`` -- A ring containing q1 and q2 (default q1.parent())
     35     - ``prefix`` -- a label for the generators (default "T")
     36
     37    The Iwahori Hecke algebra is defined in:
     38
     39    Nagayoshi Iwahori, On the structure of a Hecke ring of a Chevalley group
     40    over a finite field.  J. Fac. Sci. Univ. Tokyo Sect. I 10 1964 215--236
     41    (1964).
     42
     43    The Iwahori Hecke algebra is a deformation of the group algebra of
     44    the Weyl/Coxeter group. Taking the deformation parameter `q=1` as in the
     45    following example gives a ring isomorphic to that group
     46    algebra. The parameter `q` is a deformation parameter.
     47
     48    EXAMPLES::
     49
     50        sage: H = IwahoriHeckeAlgebraT("A3",1,prefix = "s")
     51        sage: [s1,s2,s3] = H.algebra_generators()
     52        sage: s1*s2*s3*s1*s2*s1 == s3*s2*s1*s3*s2*s3
     53        True
     54        sage: w0 = H(H.coxeter_group().long_element())
     55        sage: w0
     56        s1*s2*s3*s1*s2*s1
     57        sage: H.an_element()
     58        3*s1*s2 + 3*s1 + 1
     59
     60    Iwahori Hecke algebras have proved to be fundamental. See for example:
     61
     62    Kazhdan and Lusztig, Representations of Coxeter groups and Hecke algebras.
     63    Invent. Math. 53 (1979), no. 2, 165--184.
     64
     65    Iwahori-Hecke Algebras: Thomas J. Haines, Robert E. Kottwitz,
     66    Amritanshu Prasad, http://front.math.ucdavis.edu/0309.5168
     67
     68    V. Jones, Hecke algebra representations of braid groups and link
     69    polynomials.  Ann. of Math. (2) 126 (1987), no. 2, 335--388.
     70
     71    For every simple reflection `s_i` of the Coxeter group, there is a
     72    corresponding generator `T_i` of the Iwahori Hecke algebra. These
     73    are subject to the relations
     74
     75        `(T_i-q_1)*(T_i-q_2) == 0`
     76
     77    together with the braid relations `T_i T_j T_i ... == T_j T_i T_j ...`,
     78    where the number of terms on both sides is `k/2` with `k` the order of
     79    `s_i s_j` in the Coxeter group.
     80
     81    Weyl group elements form a basis of the Iwahori Hecke algebra `H`
     82    with the property that if `w1` and `w2` are Coxeter group elements
     83    such that ``(w1*w2).length() == w1.length() + w2.length()`` then
     84    ``H(w1*w2) == H(w1)*H(w2)``.
     85
     86    With the default value `q_2 = -1` and with `q_1 = q` the
     87    generating relation may be written `T_i^2 = (q-1)*T_i + q*1` as in
     88    Iwahori's paper.
     89
     90    EXAMPLES::
     91
     92        sage: R.<q>=PolynomialRing(ZZ)
     93        sage: H=IwahoriHeckeAlgebraT("B3",q); H
     94        The Iwahori Hecke Algebra of Type B3 in q,-1 over Univariate Polynomial Ring in q over Integer Ring and prefix T
     95        sage: T1,T2,T3 = H.algebra_generators()
     96        sage: T1*T1
     97        (q-1)*T1 + q
     98
     99    It is useful to define ``T1,T2,T3 = H.algebra_generators()`` as above
     100    so that H can parse its own output::
     101
     102        sage: H(T1)
     103        T1
     104
     105    The Iwahori Hecke algebra associated with an affine Weyl group is
     106    called an affine Hecke algebra. These may be implemented as follows::
     107
     108        sage: R.<q>=QQ[]
     109        sage: H=IwahoriHeckeAlgebraT(['A',2,1],q)
     110        sage: [T0,T1,T2]=H.algebra_generators()
     111        sage: T1*T2*T1*T0*T1*T0
     112        (q-1)*T1*T2*T0*T1*T0 + q*T1*T2*T0*T1
     113        sage: T1*T2*T1*T0*T1*T1
     114        q*T1*T2*T1*T0 + (q-1)*T1*T2*T0*T1*T0
     115        sage: T1*T2*T1*T0*T1*T2
     116        T1*T2*T0*T1*T0*T2
     117        sage: (T1*T2*T0*T1*T0*T2).support_of_monomial() # get the underlying Weyl group element
     118        [ 2  1 -2]
     119        [ 3  1 -3]
     120        [ 2  2 -3]
     121
     122        sage: R = IwahoriHeckeAlgebraT("A3",0,0,prefix = "s")
     123        sage: [s1,s2,s3] = R.algebra_generators()
     124        sage: s1*s1
     125        0
     126
     127    TESTS::
     128
     129        sage: H1 = IwahoriHeckeAlgebraT("A2",1)
     130        sage: H2 = IwahoriHeckeAlgebraT("A2",1)
     131        sage: H3 = IwahoriHeckeAlgebraT("A2",-1)
     132        sage: H1 == H1, H1 == H2, H1 is H2
     133        (True, True, True)
     134        sage: H1 == H3
     135        False
     136
     137        sage: R.<q>=PolynomialRing(QQ)
     138        sage: IwahoriHeckeAlgebraT("A3",q).base_ring() == R
     139        True
     140
     141        sage: R.<q>=QQ[]; H=IwahoriHeckeAlgebraT("A2",q)
     142        sage: 1+H(q)
     143        (q+1)
     144
     145        sage: R.<q>=QQ[]
     146        sage: H = IwahoriHeckeAlgebraT("A2",q)
     147        sage: T1,T2 = H.algebra_generators()
     148        sage: H(T1+2*T2)
     149        T1 + 2*T2
     150
     151    .. rubric:: Design discussion
     152
     153    This is a preliminary implementation. For work in progress, see:
     154    http://wiki.sagemath.org/HeckeAlgebras.
     155
     156     - Should we use q in QQ['q'] as default parameter for q_1?
     157
     158    """
     159
     160    @staticmethod
     161    def __classcall__(cls, W, q1, q2=-1, base_ring=None, prefix="T"):
     162        """
     163        TESTS::
     164
     165            sage: H = IwahoriHeckeAlgebraT("A2", 1)
     166            sage: H.coxeter_group() == WeylGroup("A2")
     167            True
     168            sage: H.cartan_type() == CartanType("A2")
     169            True
     170            sage: H.base_ring() == ZZ
     171            True
     172            sage: H._q2 == -1
     173            True
     174        """
     175        if W not in CoxeterGroups():
     176            W = WeylGroup(W)
     177        if base_ring is None:
     178            base_ring = q1.parent()
     179        q2 = base_ring(q2)
     180        return super(IwahoriHeckeAlgebraT, cls).__classcall__(cls, W, q1=q1, q2=q2, base_ring=base_ring, prefix=prefix)
     181
     182    def __init__(self, W, q1, q2, base_ring, prefix):
     183         """
     184        EXAMPLES ::
     185
     186            sage: R.<q1,q2>=QQ[]
     187            sage: H = IwahoriHeckeAlgebraT("A2",q1,q2,base_ring=Frac(R),prefix="t"); H
     188            The Iwahori Hecke Algebra of Type A2 in q1,q2 over Fraction Field of Multivariate Polynomial Ring in q1, q2 over Rational Field and prefix t
     189            sage: TestSuite(H).run()
     190
     191         """
     192         self._cartan_type = W.cartan_type()
     193         self._prefix = prefix
     194         self._index_set = W.index_set()
     195         self._q1 = base_ring(q1)
     196         self._q2 = base_ring(q2)
     197
     198         if W.is_finite():
     199             category = FiniteDimensionalAlgebrasWithBasis(base_ring)
     200         else:
     201             category = AlgebrasWithBasis(base_ring)
     202         CombinatorialFreeModule.__init__(self, base_ring, W, category = category)
     203
     204    def _element_constructor_(self, w):
     205        """
     206        Construct a basis element from an element of the Weyl group
     207
     208        EXAMPLES ::
     209
     210            sage: R.<q>=QQ[]
     211            sage: H = IwahoriHeckeAlgebraT("A2",q)
     212            sage: [H(x) for x in H.coxeter_group()]   # indirect doctest
     213            [1, T1, T1*T2, T1*T2*T1, T2, T2*T1]
     214
     215        """
     216        assert w in self.basis().keys()
     217        return self.term(w)
     218
     219    @cached_method
     220    def one_basis(self):
     221        """
     222        Returns the unit of the underlying Coxeter group, which indexes
     223        the one of this algebra, as per
     224        :meth:`AlgebrasWithBasis.ParentMethods.one_basis`.
     225
     226        EXAMPLES::
     227
     228            sage: H = IwahoriHeckeAlgebraT("B3", 1)
     229            sage: H.one_basis()
     230            [1 0 0]
     231            [0 1 0]
     232            [0 0 1]
     233            sage: H.one_basis() == H.coxeter_group().one()
     234            True
     235            sage: H.one()
     236            1
     237        """
     238        return self.coxeter_group().one()
     239
     240    def _repr_(self):
     241        """
     242        EXAMPLES ::
     243
     244            sage: R.<q1,q2>=QQ[]
     245            sage: IwahoriHeckeAlgebraT("A2",q1,-q2,base_ring=Frac(R),prefix="Z") # indirect doctest
     246            The Iwahori Hecke Algebra of Type A2 in q1,-q2 over Fraction Field of Multivariate Polynomial Ring in q1, q2 over Rational Field and prefix Z
     247
     248        """
     249        return "The Iwahori Hecke Algebra of Type %s in %s,%s over %s and prefix %s"%(self._cartan_type._repr_(compact=True), self._q1, self._q2, self.base_ring(), self._prefix)
     250
     251    def cartan_type(self):
     252        """
     253        EXAMPLES ::
     254
     255            sage: IwahoriHeckeAlgebraT("D4",0).cartan_type()
     256            ['D', 4]
     257
     258        """
     259        return self._cartan_type
     260
     261    def coxeter_group(self):
     262        """
     263        EXAMPLES::
     264
     265            sage: IwahoriHeckeAlgebraT("B2",1).coxeter_group()
     266            Weyl Group of type ['B', 2] (as a matrix group acting on the ambient space)
     267
     268        """
     269        return self.basis().keys()
     270
     271    def index_set(self):
     272        """
     273        EXAMPLES::
     274
     275            sage: IwahoriHeckeAlgebraT("B2",1).index_set()
     276            [1, 2]
     277        """
     278        return self._index_set
     279
     280    @cached_method
     281    def algebra_generators(self):
     282        """
     283        Returns the generators. They do not have order two but satisfy
     284        a quadratic relation. They coincide with the simple
     285        reflections in the Coxeter group when `q_1=1` and `q_2=-1`. In
     286        this special case, the Iwahori Hecke algebra is identified
     287        with the group algebra of the Coxeter group.
     288
     289        EXAMPLES ::
     290
     291            sage: R.<q>=QQ[]
     292            sage: H = IwahoriHeckeAlgebraT("A3",q)
     293            sage: T=H.algebra_generators(); T
     294            Finite family {1: T1, 2: T2, 3: T3}
     295            sage: T.list()
     296            [T1, T2, T3]
     297            sage: [T[i] for i in [1,2,3]]
     298            [T1, T2, T3]
     299            sage: [T1, T2, T3] = H.algebra_generators()
     300            sage: T1
     301            T1
     302            sage: H = IwahoriHeckeAlgebraT(['A',2,1],q)
     303            sage: T=H.algebra_generators(); T
     304            Finite family {0: T0, 1: T1, 2: T2}
     305            sage: T.list()
     306            [T0, T1, T2]
     307            sage: [T[i] for i in [0,1,2]]
     308            [T0, T1, T2]
     309            sage: [T0, T1, T2] = H.algebra_generators()
     310            sage: T0
     311            T0
     312        """
     313        return self.coxeter_group().simple_reflections().map(self.term)
     314
     315    def algebra_generator(self, i):
     316        """
     317        EXAMPLES ::
     318
     319            sage: R.<q>=QQ[]
     320            sage: H = IwahoriHeckeAlgebraT("A3",q)
     321            sage: [H.algebra_generator(i) for i in H.index_set()]
     322            [T1, T2, T3]
     323
     324        """
     325        return self.algebra_generators()[i]
     326
     327    def inverse_generator(self, i):
     328        """
     329        This method is only available if q1 and q2 are invertible. In
     330        that case, the algebra generators are also invertible and this
     331        method returns the inverse of self.algebra_generator(i). The
     332        base ring should be either a field or a Laurent polynomial ring.
     333
     334        EXAMPLES::
     335
     336            sage: P.<q1,q2>=QQ[]
     337            sage: F=Frac(P)
     338            sage: H = IwahoriHeckeAlgebraT("A2",q1,q2,base_ring=F)
     339            sage: H.base_ring()
     340            Fraction Field of Multivariate Polynomial Ring in q1, q2 over Rational Field
     341            sage: H.inverse_generator(1)
     342            ((-1)/(q1*q2))*T1 + ((q1+q2)/(q1*q2))
     343            sage: H = IwahoriHeckeAlgebraT("A2",q1,-1,base_ring=F)
     344            sage: H.inverse_generator(2)
     345            ((-1)/(-q1))*T2 + ((q1-1)/(-q1))
     346            sage: P1.<r1,r2>=LaurentPolynomialRing(QQ)
     347            sage: H1 = IwahoriHeckeAlgebraT("B2",r1,r2,base_ring=P1)
     348            sage: H1.base_ring()
     349            Multivariate Laurent Polynomial Ring in r1, r2 over Rational Field
     350            sage: H1.inverse_generator(2)
     351            (-r1^-1*r2^-1)*T2 + (r2^-1+r1^-1)
     352            sage: H2 = IwahoriHeckeAlgebraT("C2",r1,-1,base_ring=P1)
     353            sage: H2.inverse_generator(2)
     354            (r1^-1)*T2 + (-1+r1^-1)
     355
     356        """
     357        try:
     358            # This currently works better than ~(self._q1) if
     359            # self.base_ring() is a Laurent polynomial ring since it
     360            # avoids accidental coercion into a field of fractions.
     361            i1 = self._q1.__pow__(-1)
     362            i2 = self._q2.__pow__(-1)
     363        except:
     364            raise ValueError, "%s and %s must be invertible."%(self._q1, self._q2)
     365        return (-i1*i2)*self.algebra_generator(i)+(i1+i2)
     366
     367    @cached_method
     368    def inverse_generators(self):
     369        """
     370        This method is only available if q1 and q2 are invertible. In
     371        that case, the algebra generators are also invertible and this
     372        method returns their inverses.
     373
     374        EXAMPLES ::
     375            sage: P.<q> = PolynomialRing(QQ)
     376            sage: F = Frac(P)
     377            sage: H = IwahoriHeckeAlgebraT("A2",q,base_ring=F)
     378            sage: [T1,T2]=H.algebra_generators()
     379            sage: [U1,U2]=H.inverse_generators()
     380            sage: U1*T1,T1*U1
     381            (1, 1)
     382            sage: P1.<q> = LaurentPolynomialRing(QQ)
     383            sage: H1 = IwahoriHeckeAlgebraT("A2",q,base_ring=P1,prefix="V")
     384            sage: [V1,V2]=H1.algebra_generators()
     385            sage: [W1,W2]=H1.inverse_generators()
     386            sage: [W1,W2]
     387            [(q^-1)*V1 + (-1+q^-1), (q^-1)*V2 + (-1+q^-1)]
     388            sage: V1*W1, W2*V2
     389            (1, 1)
     390
     391        """
     392        return Family(self.index_set(), self.inverse_generator)
     393
     394    def product_on_basis(self, w1, w2):
     395        """
     396
     397        Returns `T_w1 T_w2`, where `w_1` and `w_2` are in the Coxeter group
     398
     399        EXAMPLES::
     400
     401            sage: R.<q>=QQ[]; H = IwahoriHeckeAlgebraT("A2",q)
     402            sage: s1,s2 = H.coxeter_group().simple_reflections()
     403            sage: [H.product_on_basis(s1,x) for x in [s1,s2]]
     404            [(q-1)*T1 + q, T1*T2]
     405
     406        """
     407        result = self.term(w1)
     408        for i in w2.reduced_word():
     409            result = self.product_by_generator(result, i)
     410        return result
     411
     412    def product_by_generator_on_basis(self, w, i, side = "right"):
     413        """
     414        INPUT:
     415         - ``w`` - an element of the Coxeter group
     416         - ``i`` - an element of the index set
     417         - ``side`` - "left" or "right" (default: "right")
     418
     419        Returns the product `T_w T_i` (resp. `T_i T_w`) if ``side`` is "right" (resp. "left")
     420
     421        EXAMPLES::
     422
     423            sage: R.<q>=QQ[]; H = IwahoriHeckeAlgebraT("A2",q)
     424            sage: s1,s2 = H.coxeter_group().simple_reflections()
     425            sage: [H.product_by_generator_on_basis(w, 1) for w in [s1,s2,s1*s2]]
     426            [(q-1)*T1 + q, T2*T1, T1*T2*T1]
     427            sage: [H.product_by_generator_on_basis(w, 1, side = "left") for w in [s1,s2,s1*s2]]
     428            [(q-1)*T1 + q, T1*T2, (q-1)*T1*T2 + q*T2]
     429        """
     430        wi = w.apply_simple_reflection(i, side = side)
     431        if w.has_descent(i, side = side):
     432            return self.monomial(w ,  self._q1+self._q2) + \
     433                   self.monomial(wi, -self._q1*self._q2)
     434        else:
     435            return self.term(wi)
     436
     437    def product_by_generator(self, x, i, side = "right"):
     438        """
     439        Returns T_i*x, where T_i is the i-th generator. This is coded
     440        individually for use in x._mul_().
     441
     442        EXAMPLES ::
     443            sage: R.<q>=QQ[]; H = IwahoriHeckeAlgebraT("A2",q)
     444            sage: [T1,T2] = H.algebra_generators()
     445            sage: [H.product_by_generator(x, 1, side = "left") for x in [T1,T2]]
     446            [(q-1)*T1 + q, T2*T1]
     447
     448        """
     449        return self.sum(self.product_by_generator_on_basis(w, i)._acted_upon_(c) for (w,c) in x)
     450
     451    def _repr_term(self, t):
     452        """
     453        EXAMPLES ::
     454
     455            sage: R.<q>=QQ[]
     456            sage: H = IwahoriHeckeAlgebraT("A3",q)
     457            sage: W=H.coxeter_group()
     458            sage: H._repr_term(W.from_reduced_word([1,2,3]))
     459            'T1*T2*T3'
     460
     461        """
     462        redword = t.reduced_word()
     463        if len(redword) == 0:
     464            return "1"
     465        else:
     466            return "*".join("%s%d"%(self._prefix, i) for i in redword)
     467
     468    class Element(CombinatorialFreeModuleElement):
     469        """
     470        A class for elements of an IwahoriHeckeAlgebra
     471
     472        TESTS::
     473
     474            sage: R.<q>=QQ[]
     475            sage: H=IwahoriHeckeAlgebraT("B3",q)
     476            sage: [T1, T2, T3] = H.algebra_generators()
     477            sage: T1+2*T2*T3
     478            T1 + 2*T2*T3
     479
     480            sage: R.<q1,q2>=QQ[]
     481            sage: H=IwahoriHeckeAlgebraT("A2",q1,q2,prefix="x")
     482            sage: sum(H.algebra_generators())^2
     483            x1*x2 + x2*x1 + (q1+q2)*x1 + (q1+q2)*x2 + (-2*q1*q2)
     484
     485            sage: H=IwahoriHeckeAlgebraT("A2",q1,q2,prefix="t")
     486            sage: [t1,t2] = H.algebra_generators()
     487            sage: (t1-t2)^3
     488            (q1^2-q1*q2+q2^2)*t1 + (-q1^2+q1*q2-q2^2)*t2
     489
     490            sage: R.<q>=QQ[]
     491            sage: H=IwahoriHeckeAlgebraT("G2",q)
     492            sage: [T1, T2] = H.algebra_generators()
     493            sage: T1*T2*T1*T2*T1*T2 == T2*T1*T2*T1*T2*T1
     494            True
     495            sage: T1*T2*T1 == T2*T1*T2
     496            False
     497
     498            sage: H = IwahoriHeckeAlgebraT("A2",1)
     499            sage: [T1,T2]=H.algebra_generators()
     500            sage: T1+T2
     501            T1 + T2
     502
     503            sage: -(T1+T2)
     504            -T1 - T2
     505
     506            sage: 1-T1
     507            -T1 + 1
     508
     509            sage: T1.parent()
     510            The Iwahori Hecke Algebra of Type A2 in 1,-1 over Integer Ring and prefix T
     511        """
     512
     513        def inverse(self):
     514            """
     515            If the element is a basis element, that is, an element of the
     516            form self(w) with w in the Weyl group, this method computes
     517            its inverse. The base ring must be a field or Laurent
     518            polynomial ring. Other elements of the ring have inverses but
     519            the inverse method is only implemented for the basis elements.
     520
     521            EXAMPLES::
     522
     523                sage: R.<q>=LaurentPolynomialRing(QQ)
     524                sage: H = IwahoriHeckeAlgebraT("A2",q)
     525                sage: [T1,T2]=H.algebra_generators()
     526                sage: x = (T1*T2).inverse(); x
     527                (q^-2)*T2*T1 + (-q^-1+q^-2)*T1 + (-q^-1+q^-2)*T2 + (1-2*q^-1+q^-2)
     528                sage: x*T1*T2
     529                1
     530
     531            """
     532            if len(self) != 1:
     533                raise NotImplementedError, "inverse only implemented for basis elements (monomials in the generators)"%self
     534            H = self.parent()
     535            w = self.support_of_monomial()
     536
     537            return H.prod(H.inverse_generator(i) for i in reversed(w.reduced_word()))
  • sage/categories/modules_with_basis.py

    diff --git a/sage/categories/modules_with_basis.py b/sage/categories/modules_with_basis.py
    a b  
    239239
    240240    # TODO: find something better to get this inheritance from CategoryWithTensorProduct.Element
    241241    class ElementMethods(CategoryWithTensorProduct.ElementMethods, CategoryWithCartesianProduct.ElementMethods):
    242         pass
     242
     243        def support_of_monomial(self):
     244            """
     245            INPUT:
     246
     247             - ``self`` - a monomial
     248
     249            Returns the support of ``self``.
     250
     251            EXAMPLES::
     252
     253                sage: X = CombinatorialFreeModule(QQ, [1,2,3,4]); X.rename("X")
     254                sage: X.term(2).support_of_monomial()
     255                2
     256                sage: X.monomial(3, 2).support_of_monomial()
     257                3
     258
     259            An exception is raised if ``self`` has more than one term:
     260
     261                sage: (X.term(2) + X.term(3)).support_of_monomial()
     262                Traceback (most recent call last):
     263                ...
     264                ValueError: B[2] + B[3] is not a monomial
     265
     266            """
     267            if len(self) == 1:
     268                return self.support()[0]
     269            else:
     270                raise ValueError, "%s is not a monomial"%(self)
    243271
    244272#         def _neg_(self):
    245273#             """
  • sage/categories/pushout.py

    diff --git a/sage/categories/pushout.py b/sage/categories/pushout.py
    a b  
    310310        if self.multi_variate and is_LaurentPolynomialRing(R):
    311311            return LaurentPolynomialRing(R.base_ring(), (list(R.variable_names()) + [self.var]))
    312312        else:
     313            from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
    313314            return PolynomialRing(R, self.var)
    314315    def __cmp__(self, other):
    315316        c = cmp(type(self), type(other))