Ticket #10052: trac_10052-steenrod.delta2to3.patch

File trac_10052-steenrod.delta2to3.patch, 36.9 KB (added by jhpalmieri, 11 years ago)

Diff between v2 and v3 (for reference only)

  • sage/algebras/steenrod/steenrod_algebra.py

    # HG changeset patch
    # User J. H. Palmieri <palmieri@math.washington.edu>
    # Date 1292438212 28800
    # Node ID 2dc0757a042f4bb2fade5df45e0e419c29f02363
    # Parent  23d55536e72d68862f27758cf9f3abaf714ecd96
    #10052: diff between v2 and v3
    
    diff -r 23d55536e72d -r 2dc0757a042f sage/algebras/steenrod/steenrod_algebra.py
    a b The list of exponents `(e_1, e_2, ...)`  
    188188function* for the sub-Hopf algebra.  The profile function must satisfy
    189189the condition
    190190
    191 - `e(r) \geq \min( e(r-i) - i, e(i))` for all `0 \leq i < r`.
     191- `e(r) \geq \min( e(r-i) - i, e(i))` for all `0 < i < r`.
    192192
    193193At odd primes, the situation is similar: the dual is isomorphic to the
    194194tensor product of a polynomial algebra and an exterior algebra,
    Here the profile function has two pieces 
    207207`k`, which maps the non-negative integers to the set `\{1, 2\}`.
    208208These must satisfy the following conditions:
    209209
    210 - `e(r) \geq \min( e(r-i) - i, e(i))` for all `0 \leq i < r`.
     210- `e(r) \geq \min( e(r-i) - i, e(i))` for all `0 < i < r`.
    211211
    212212- if `k(i+j) = 1`, then either `e(i) \leq j` or `k(j) = 1` for all `i
    213213  \geq 1`, `j \geq 0`.
    class SteenrodAlgebra_generic(Combinator 
    581581                and profile[0][0] < Infinity)
    582582            or (truncation_type < Infinity)):
    583583            if basis != 'milnor' and basis.find('pst') == -1:
    584                 raise NotImplementedError, "For sub-Hopf algebras of the Steenrod algebra, only the Milnor basis and the pst bases (when p=2) are implemented."
     584                raise NotImplementedError, "For sub-Hopf algebras of the Steenrod algebra, only the Milnor basis and the pst bases are implemented."
    585585        self._basis_name = basis
    586586        self._basis_fcn = partial(steenrod_algebra_basis,
    587587                                  p=p,
    class SteenrodAlgebra_generic(Combinator 
    10191019            AttributeError: 'CombinatorialFreeModule_with_category.element_class' object has no attribute 'antipode'
    10201020            sage: A(a).antipode() # convert to elt of A, then compute antipode
    10211021            Sq(2,1) + Sq(5)
     1022
     1023            sage: G = SteenrodAlgebra(p=5, profile=[[2,1], [2,2,2]], basis='pst')
     1024
     1025        TESTS:
     1026
     1027        The following sort of thing is also tested by the function
     1028        :func:`steenrod_basis_error_check
     1029        <sage.algebras.steenrod.steenrod_algebra_bases.steenrod_basis_error_check>`::
     1030
     1031            sage: H = SteenrodAlgebra(p=5, profile=[[2,1], [2,2,2]])
     1032            sage: G = SteenrodAlgebra(p=5, profile=[[2,1], [2,2,2]], basis='pst')
     1033            sage: max([H[n].dimension() - G[n].dimension() for n in range(100)])
     1034            0
    10221035        """
    10231036        from sage.rings.all import GF
    10241037        basis = self._basis_fcn(n)
    class SteenrodAlgebra_generic(Combinator 
    13021315            return result
    13031316
    13041317    def coproduct(self, x, algorithm='milnor'):
    1305         """
     1318        r"""
    13061319        Return the coproduct of an element ``x`` of this algebra.
    13071320
    13081321        INPUT:
    class SteenrodAlgebra_generic(Combinator 
    13241337            sage: SteenrodAlgebra().Sq(3).coproduct()
    13251338            1 # Sq(3) + Sq(1) # Sq(2) + Sq(2) # Sq(1) + Sq(3) # 1
    13261339
    1327         The element `Sq(0,1)` is primitive::
     1340        The element `\text{Sq}(0,1)` is primitive::
    13281341
    13291342            sage: SteenrodAlgebra(basis='adem').Sq(0,1).coproduct()
    13301343            1 # Sq^2 Sq^1 + 1 # Sq^3 + Sq^2 Sq^1 # 1 + Sq^3 # 1
    class SteenrodAlgebra_generic(Combinator 
    13371350            1 # P(4) + P(1) # P(3) + P(2) # P(2) + P(3) # P(1) + P(4) # 1
    13381351            sage: SteenrodAlgebra(p=3, basis='serre-cartan').P(4).coproduct()
    13391352            1 # P^4 + P^1 # P^3 + P^2 # P^2 + P^3 # P^1 + P^4 # 1
    1340             sage: SteenrodAlgebra(p=11).Q(0,2).coproduct()
     1353            sage: SteenrodAlgebra(p=11, profile=((), (2,1,2))).Q(0,2).coproduct()
    13411354            1 # Q_0 Q_2 + Q_0 # Q_2 + Q_0 Q_2 # 1 - Q_2 # Q_0
    13421355        """
    13431356        # taken from categories.coalgebras_with_basis, then modified
    class SteenrodAlgebra_generic(Combinator 
    14021415            sage: A5 = SteenrodAlgebra(p=5, basis='adem')
    14031416            sage: all([x.antipode().antipode() == x for x in A5.basis(25)])
    14041417            True
     1418            sage: H = SteenrodAlgebra(profile=[2,2,1])
     1419            sage: H.Sq(1,2).antipode() in H
     1420            True
    14051421        """
    14061422        p = self.prime()
    14071423        if self.basis_name() == 'serre-cartan':
    class SteenrodAlgebra_generic(Combinator 
    20242040            return True
    20252041        if (isinstance(x, self.Element)
    20262042            and x.prime() == p):
     2043            A = SteenrodAlgebra(p=p, basis=self.basis_name())
    20272044            if self._has_nontrivial_profile():
    20282045                return all([self._check_profile_on_basis(mono)
    2029                             for mono in x.support()])
     2046                            for mono in A(x).support()])
    20302047            return True  # trivial profile, so True
    20312048        return False
    20322049
    class SteenrodAlgebra_generic(Combinator 
    21442161        -  ``a, b, c, ...`` - non-negative integers
    21452162
    21462163        OUTPUT: element of the Steenrod algebra given by the Milnor
    2147         single basis element P(a, b, c, ...)
     2164        single basis element `P(a, b, c, ...)`
    21482165
    21492166        Note that at the prime 2, this is the same element as
    21502167        `\text{Sq}(a, b, c, ...)`.
    class SteenrodAlgebra_generic(Combinator 
    22672284            Q_1 Q_4
    22682285            sage: A5.Q(1,4) == A5.Q_exp(0,1,0,0,1)
    22692286            True
     2287            sage: H = SteenrodAlgebra(p=5, profile=[[2,1], [2,2,2]])
     2288            sage: H.Q(2)
     2289            Q_2
     2290            sage: H.Q(4)
     2291            Traceback (most recent call last):
     2292            ...
     2293            ValueError: Element not in this algebra
    22702294        """
    22712295        if len(nums) != len(set(nums)):
    22722296            return self(0)
    class SteenrodAlgebra_generic(Combinator 
    22852309                answer = self.one()
    22862310                for i in nums:
    22872311                    answer = answer * self.monomial(((i,), ()))
    2288                 return answer
     2312                t = answer.leading_support()
     2313                if self._check_profile_on_basis(t):
     2314                    return answer
     2315                raise ValueError, "Element not in this algebra"
    22892316
    22902317    def an_element(self):
    22912318        """
    22922319        An element of this Steenrod algebra. The element depends on
    2293         the basis.  (This is used by the automatic test suite, so
    2294         having different elements in different bases may help in
    2295         discovering bugs.)
     2320        the basis and whether there is a nontrivial profile function.
     2321        (This is used by the automatic test suite, so having different
     2322        elements in different bases may help in discovering bugs.)
    22962323
    22972324        EXAMPLES::
    22982325
    class SteenrodAlgebra_generic(Combinator 
    23032330            sage: SteenrodAlgebra(p=5).an_element()
    23042331            4 Q_1 Q_3 P(2,1)
    23052332            sage: SteenrodAlgebra(basis='pst').an_element()
    2306             P^3_1           
     2333            P^3_1
     2334            sage: SteenrodAlgebra(basis='pst', profile=[3,2,1]).an_element()
     2335            P^0_1
    23072336        """
    23082337        from sage.rings.all import GF
    23092338        basis = self.basis_name()
    23102339        p = self.prime()
    23112340
     2341        if self._has_nontrivial_profile():
     2342            if self.ngens() > 0:
     2343                return self.gen(0)
     2344            else:
     2345                return self.one()
     2346
    23122347        if basis == 'milnor' and p == 2:
    23132348            return self.monomial((2,1))
    23142349        if basis == 'milnor' and p > 2:
    class SteenrodAlgebra_generic(Combinator 
    24012436            +Infinity
    24022437            sage: SteenrodAlgebra(profile=[3,2,1]).ngens() # A(2)
    24032438            3
     2439            sage: SteenrodAlgebra(profile=[3,2,1], basis='pst').ngens()
     2440            3
    24042441            sage: SteenrodAlgebra(p=3, profile=[[3,2,1], [2,2,2,2]]).ngens() # A(3) at p=3
    24052442            4
    24062443            sage: SteenrodAlgebra(profile=[1,2,1,1]).ngens()
    class SteenrodAlgebra_generic(Combinator 
    24112448            return Infinity
    24122449        n = self.profile(1)
    24132450        p = self.prime()
    2414         if p == 2 and self == AA(n-1, p=p):
     2451        if p == 2 and self._profile == AA(n-1, p=p)._profile:
    24152452            return n
    2416         if p > 2 and self == AA(n, p=p):
     2453        if p > 2 and self._profile == AA(n, p=p)._profile:
    24172454            return n+1
    24182455        if p == 2:
    24192456            return sum(self._profile)
    class SteenrodAlgebra_generic(Combinator 
    24402477        algebra is `A(n)`, return the appropriate list of generators.
    24412478
    24422479        For other sub-Hopf algebras: return a non-minimal generating
    2443         set: the family of `P^s_t`'s contained in the algebra.
     2480        set: the family of `P^s_t`'s and `Q_n`'s contained in the
     2481        algebra.
    24442482
    24452483        EXAMPLES::
    24462484
    class SteenrodAlgebra_generic(Combinator 
    24932531        OUTPUT: the ith generator of this algebra
    24942532
    24952533        For the full Steenrod algebra, the `i^{th}` generator is
    2496         `Sq(2^i)` at the prime 2; when `p` is odd, the 0th generator
     2534        `\text{Sq}(2^i)` at the prime 2; when `p` is odd, the 0th generator
    24972535        is `\beta = Q(0)`, and for `i>0`, the `i^{th}` generator is
    24982536        `P(p^{i-1})`.
    24992537
    class SteenrodAlgebra_generic(Combinator 
    25172555            Sq(16)
    25182556            sage: A.gen(200)
    25192557            Sq(1606938044258990275541962092341162602522202993782792835301376)
     2558            sage: SteenrodAlgebra(2, basis='adem').gen(2)
     2559            Sq^4
     2560            sage: SteenrodAlgebra(2, basis='pst').gen(2)
     2561            P^2_1
    25202562            sage: B = SteenrodAlgebra(5)
    25212563            sage: B.gen(0)
    25222564            Q_0
    class SteenrodAlgebra_generic(Combinator 
    25412583            sage: D3 = SteenrodAlgebra(p=3, profile=(lambda n: n, lambda n: 1 if n<1 else 2))
    25422584            sage: [D3.gen(n) for n in range(9)]
    25432585            [P(1), Q_1, P(0,1), Q_2, P(0,3), P(0,0,1), Q_3, P(0,0,3), P(0,0,0,1)]
     2586            sage: SteenrodAlgebra(p=5, profile=[[2,1], [2,2,2]], basis='pst').gen(2)
     2587            P^1_1
    25442588        """
    25452589        from sage.rings.infinity import Infinity
    25462590        from sage.rings.all import Integer
    class SteenrodAlgebra_generic(Combinator 
    25532597                raise ValueError, "This algebra only has %s generators, so call gen(i) with 0 <= i < %s" % (num, num)
    25542598            # check to see if equal to A(n) for some n.
    25552599            n = self.profile(1)
    2556             if p == 2 and self == AA(n-1, p=p):
     2600            if p == 2 and self._profile == AA(n-1, p=p)._profile:
    25572601                return self.pst(i,1)
    2558             if p > 2 and self == AA(n, p=p):
     2602            if p > 2 and self._profile == AA(n, p=p)._profile:
    25592603                if i == 0:
    25602604                    return self.Q(0)
    25612605                return self.pst(i-1, 1)
    class SteenrodAlgebra_generic(Combinator 
    26462690
    26472691        Note that if the profile function is specified by a function,
    26482692        then by default it has infinite truncation type: the profile
    2649         function is assumed to grow without bound.  ::
     2693        function is assumed to be infinite after the 100th term.  ::
    26502694
    26512695            sage: SteenrodAlgebra(profile=lambda n: 1).is_commutative()
    26522696            False
    class SteenrodAlgebra_generic(Combinator 
    31093153   
    31103154            .. warning::
    31113155   
    3112                 Deprecated (July 2010). Use :meth:`change_basis` instead.
    3113    
     3156                Deprecated (December 2010). Use :meth:`change_basis` instead.
     3157
    31143158            EXAMPLES::
    3115    
     3159
    31163160                sage: c = Sq(2) * Sq(1)
    31173161                sage: c.basis('milnor')
    3118                 doctest:...: DeprecationWarning: The .basis() method is deprecated.  Use .change_basis() instead.
     3162                doctest:...: DeprecationWarning: (Since Sage 4.6.2) The .basis() method is deprecated.  Use .change_basis() instead.
    31193163                Sq(0,1) + Sq(3)
    31203164            """
    31213165            from sage.misc.misc import deprecation
    3122             deprecation('The .basis() method is deprecated. Use .change_basis() instead.')
     3166            deprecation('The .basis() method is deprecated. Use .change_basis() instead.',
     3167                        version='Sage 4.6.2')
    31233168            return self.change_basis(basis)
    31243169   
    31253170        def coproduct(self, algorithm='milnor'):
    class SteenrodAlgebra_generic(Combinator 
    34703515            The additive order of any nonzero element of the mod p
    34713516            Steenrod algebra is p.
    34723517   
    3473             OUTPUT: 0 or p
     3518            OUTPUT: 1 (for the zero element) or p (for anything else)
    34743519   
    34753520            EXAMPLES::
    34763521   
    def SteenrodAlgebra(p=2, basis='milnor', 
    35993644    there are also several other, less well-known, bases. See the
    36003645    documentation for this module (type
    36013646    ``sage.algebras.steenrod.steenrod_algebra?``) and the function
    3602     :func:`sage.algebras.steenrod.steenrod_algebra_bases.steenrod_algebra_basis`
     3647    :func:`steenrod_algebra_basis
     3648    <sage.algebras.steenrod.steenrod_algebra_bases.steenrod_algebra_basis_>`
    36033649    for full descriptions of each of the implemented bases.
    36043650
    36053651    This module implements the following bases at all primes:
    def SteenrodAlgebra(p=2, basis='milnor', 
    36273673    - 'arnon_c': Arnon's C basis.
    36283674
    36293675    When defining a Steenrod algebra, you can specify a basis. Then
    3630     elements of that Steenrod algebra are printed in that basis
    3631 
    3632     ::
     3676    elements of that Steenrod algebra are printed in that basis::
    36333677
    36343678        sage: adem = SteenrodAlgebra(2, 'adem')
    36353679        sage: x = adem.Sq(2,1)  # Sq(-) always means a Milnor basis element
    def SteenrodAlgebra(p=2, basis='milnor', 
    37113755
    37123756    The profile function `e` must satisfy the condition
    37133757
    3714     - `e(r) \geq \min( e(r-i) - i, e(i))` for all `0 \leq i < r`.
     3758    - `e(r) \geq \min( e(r-i) - i, e(i))` for all `0 < i < r`.
    37153759
    37163760    This is specified via ``profile``, and optionally ``precision``
    37173761    and ``truncation_type``.  First, ``profile`` must have one of the
    def SteenrodAlgebra(p=2, basis='milnor', 
    37573801        False
    37583802        sage: D2.is_finite()
    37593803        False
     3804        sage: E2 = SteenrodAlgebra(profile=lambda n: max(4-n, 0), truncation_type=Infinity)
     3805        sage: D2 == E2
     3806        True
    37603807
    37613808    The argument ``precision`` only needs to be specified if the
    37623809    profile function is defined by a function and you want to control
    def SteenrodAlgebra(p=2, basis='milnor', 
    37823829
    37833830    Together, the functions `e` and `k` must satisfy the conditions
    37843831
    3785     - `e(r) \geq \min( e(r-i) - i, e(i))` for all `0 \leq i < r`,
     3832    - `e(r) \geq \min( e(r-i) - i, e(i))` for all `0 < i < r`,
    37863833
    37873834    - if `k(i+j) = 1`, then either `e(i) \leq j` or `k(j) = 1` for all `i
    37883835      \geq 1`, `j \geq 0`.
    def SteenrodAlgebra(p=2, basis='milnor', 
    38383885        sage: SteenrodAlgebra(profile=[1,2,1,1], basis='adem')
    38393886        Traceback (most recent call last):
    38403887        ...
    3841         NotImplementedError: For sub-Hopf algebras of the Steenrod algebra, only the Milnor basis and the pst bases (when p=2) are implemented.
     3888        NotImplementedError: For sub-Hopf algebras of the Steenrod algebra, only the Milnor basis and the pst bases are implemented.
    38423889
    38433890    TESTS:
    38443891
  • sage/algebras/steenrod/steenrod_algebra_bases.py

    diff -r 23d55536e72d -r 2dc0757a042f sage/algebras/steenrod/steenrod_algebra_bases.py
    a b def convert_to_milnor_matrix_(n, basis,  
    145145    OUTPUT: ``matrix`` - change-of-basis matrix, a square matrix over
    146146    GF(p)
    147147
    148     (This is not really intended for casual users, so no error checking
    149     is made on the integer `n`, the basis name, or the prime.)
     148    .. note::
     149
     150        This is called internally.  It is not intended for casual
     151        users, so no error checking is made on the integer `n`, the
     152        basis name, or the prime.  Also, users should call
     153        :func:`convert_to_milnor_matrix` instead of this function
     154        (which has a trailing underscore in its name), because the
     155        former is the cached version of the latter.
    150156
    151157    EXAMPLES::
    152158
    def convert_from_milnor_matrix(n, basis, 
    215221    OUTPUT: ``matrix`` - change-of-basis matrix, a square matrix over
    216222    GF(p)
    217223
    218     (This is not really intended for casual users, so no error checking
    219     is made on the integer `n`, the basis name, or the prime.)
     224    .. note::
     225
     226        This is called internally.  It is not intended for casual
     227        users, so no error checking is made on the integer `n`, the
     228        basis name, or the prime.
    220229
    221230    EXAMPLES::
    222231
    def steenrod_algebra_basis_(n, basis='mi 
    281290    - ``p`` - positive prime number (optional, default = 2)
    282291
    283292    - ``profile`` - profile function (optional, default None).  This
    284       is just passed on to the function :func:`milnor_basis`.
     293      is just passed on to the functions :func:`milnor_basis` and
     294      :func:`pst_basis`.
    285295
    286296    - ``truncation_type`` - truncation type, either 0 or Infinity
    287       (optional Infinity).  This is just passed on to the function
     297      (optional, default Infinity if no profile function is specified,
     298      0 otherwise).  This is just passed on to the function
    288299      :func:`milnor_basis`.
    289300
    290301    OUTPUT: tuple of objects representing basis elements for the
    291302    Steenrod algebra in dimension n
    292303
     304    .. note::
     305   
     306        Users should use :func:`steenrod_algebra_basis` instead of
     307        this function (which has a trailing underscore in its name):
     308        :func:`steenrod_algebra_basis` is the cached version of this
     309        one, and so will be faster.
     310
    293311    The choices for the string ``basis`` are as follows; see the
    294312    documentation for :mod:`sage.algebras.steenrod.steenrod_algebra`
    295313    for details on each basis:
    def steenrod_algebra_basis_(n, basis='mi 
    317335        sage: steenrod_algebra_basis(5)   # milnor basis is the default
    318336        ((2, 1), (5,))
    319337
    320     Bases in negative dimension are empty::
     338    Bases in negative dimensions are empty::
    321339
    322340        sage: steenrod_algebra_basis(-2, 'wall')
    323341        ()
    def milnor_basis(n, p=2, **kwds): 
    531549      to be used; None means the profile function for the entire
    532550      Steenrod algebra.  See
    533551      :mod:`sage.algebras.steenrod.steenrod_algebra` and
    534       :func:`SteenrodAlgebra` for information on profile functions.
     552      :func:`SteenrodAlgebra <sage.algebras.steenrod.steenrod_algebra.SteenrodAlgebra>`
     553      for information on profile functions.
    535554
    536555    - ``truncation_type`` - truncation type, either 0 or Infinity
    537       (optional Infinity).
     556      (optional, default Infinity if no profile function is specified,
     557      0 otherwise)
    538558
    539559    OUTPUT: tuple of mod p Milnor basis elements in dimension n
    540560
    def milnor_basis(n, p=2, **kwds): 
    580600    from sage.rings.infinity import Infinity
    581601    from sage.combinat.integer_vector_weighted import WeightedIntegerVectors
    582602    profile = kwds.get("profile", None)
    583     trunc = kwds.get("truncation_type", Infinity)
     603    trunc = kwds.get("truncation_type", None)
     604    if profile is not None and trunc is None:
     605        trunc = 0
    584606
    585607    result = []
    586608    if p == 2:
    def milnor_basis(n, p=2, **kwds): 
    636658                            index += 1
    637659                        # check profile:
    638660                        okay = True
    639                         if profile is not None and len(profile[0]) > 0:
     661                        if profile is not None and (len(profile[0]) > 0
     662                                                    or len(profile[1]) > 0):
    640663                            # check profile function for q_mono
    641664                            for i in q_mono:
    642665                                if ((len(profile[1]) > i and profile[1][i] == 1)
    def serre_cartan_basis(n, p=2, bound=1): 
    674697    \geq 2m_{i+1}` for each `i`. At odd primes, it consists of
    675698    monomials `\beta^{e_0} P^{s_1} \beta^{e_1} P^{s_2} ...  P^{s_k}
    676699    \beta^{e_k}` with each `e_i` either 0 or 1, `s_i \geq p s_{i+1} +
    677     e_i`, and `s_k \geq 1`.
     700    e_i` for all `i`, and `s_k \geq 1`.
    678701
    679702    EXAMPLES::
    680703
    def serre_cartan_basis(n, p=2, bound=1): 
    686709        sage: serre_cartan_basis(50,5)
    687710        ((1, 5, 0, 1, 1), (1, 6, 1))
    688711
    689     If optional argument bound is present, include only those monomials
    690     whose last term is at least bound (when p=2), or those for which
    691     `s_k - epsilon_k >= bound` (when p is odd). ::
     712    If optional argument ``bound`` is present, include only those monomials
     713    whose last term is at least ``bound`` (when p=2), or those for which
     714    `s_k - e_k \geq bound` (when p is odd). ::
    692715
    693716        sage: serre_cartan_basis(7, bound=2)
    694717        ((7,), (5, 2))
    def atomic_basis(n, basis, **kwds): 
    747770    - ``n`` - non-negative integer
    748771    - ``basis`` - string, the name of the basis
    749772
     773    - ``profile`` - profile function (optional, default None).
     774      Together with ``truncation_type``, specify the profile function
     775      to be used; None means the profile function for the entire
     776      Steenrod algebra.  See
     777      :mod:`sage.algebras.steenrod.steenrod_algebra` and
     778      :func:`SteenrodAlgebra` for information on profile functions.
     779
     780    - ``truncation_type`` - truncation type, either 0 or Infinity
     781      (optional, default Infinity if no profile function is specified,
     782      0 otherwise).
     783
    750784    OUTPUT: tuple of basis elements in dimension n
    751785
    752786    The atomic bases include Wood's Y and Z bases, Wall's basis,
    def atomic_basis(n, basis, **kwds): 
    754788    bases. (All of these bases are constructed similarly, hence their
    755789    constructions have been consolidated into a single function. Also,
    756790    see the documentation for 'steenrod_algebra_basis' for
    757     descriptions of them.)
     791    descriptions of them.)  For `P^s_t`-bases, you may also specify a
     792    profile function and truncation type; profile functions are ignored
     793    for the other bases.
    758794
    759795    EXAMPLES::
    760796
    def atomic_basis(n, basis, **kwds): 
    873909    from sage.rings.infinity import Infinity
    874910    profile = kwds.get("profile", None)
    875911    trunc = kwds.get("truncation_type", None)
     912    if profile is not None and trunc is None:
     913        trunc = 0
    876914
    877915    if n == 0:
    878916        return ((),)
    def arnonC_basis(n,bound=1): 
    925963        sage: arnonC_basis(7)
    926964        ((7,), (2, 5), (4, 3), (4, 2, 1))
    927965
    928     If optional argument bound is present, include only those monomials
    929     whose first term is at least as large as bound::
     966    If optional argument ``bound`` is present, include only those monomials
     967    whose first term is at least as large as ``bound``::
    930968
    931969        sage: arnonC_basis(7,3)
    932970        ((7,), (4, 3), (4, 2, 1))
    def atomic_basis_odd(n, basis, p, **kwds 
    9671005      :func:`SteenrodAlgebra` for information on profile functions.
    9681006
    9691007    - ``truncation_type`` - truncation type, either 0 or Infinity
    970       (optional Infinity).
     1008      (optional, default Infinity if no profile function is specified,
     1009      0 otherwise).
    9711010
    9721011    OUTPUT: tuple of basis elements in dimension n
    9731012
    9741013    The only possible difference in the implementations for `P^s_t`
    9751014    bases and commutator bases is that the former make sense, and
    9761015    require filtering, if there is a nontrivial profile function.
    977     However, this function should not be called for commutator bases
    978     if there is a profile function, so we treat the two bases exactly
    979     the same.
     1016    This function is called by :func:`steenrod_algebra_basis`, and it
     1017    will not be called for commutator bases if there is a profile
     1018    function, so we treat the two bases exactly the same.
    9801019
    9811020    EXAMPLES::
    9821021
    9831022        sage: from sage.algebras.steenrod.steenrod_algebra_bases import atomic_basis_odd
    9841023        sage: atomic_basis_odd(8, 'pst_rlex', 3)
    9851024        (((), (((0, 1), 2),)),)
     1025
     1026        sage: atomic_basis_odd(18, 'pst_rlex', 3)
     1027        (((0, 2), ()), ((0, 1), (((1, 1), 1),)))
     1028        sage: atomic_basis_odd(18, 'pst_rlex', 3, profile=((), (2,2,2)))
     1029        (((0, 2), ()),)
    9861030    """
    9871031    def sorting_pair(s,t,basis):   # pair used for sorting the basis
    9881032        if basis.find('rlex') >= 0:
    def atomic_basis_odd(n, basis, p, **kwds 
    10041048    from sage.rings.infinity import Infinity
    10051049    from sage.combinat.integer_vector_weighted import WeightedIntegerVectors
    10061050    profile = kwds.get("profile", None)
    1007     trunc = kwds.get("truncation_type", None)
     1051    trunc = kwds.get("truncation_type", 0)
    10081052
    10091053    result = []
    10101054    for dim in range(n/(2*p-2) + 1):
    def atomic_basis_odd(n, basis, p, **kwds 
    10381082                        index += 1
    10391083                    # check profile:
    10401084                    okay = True
    1041 
    1042                     if profile is not None and profile != ((), ()) > 0:
     1085                    if profile is not None and profile != ((), ()):
    10431086                        # check profile function for q_mono
    10441087                        for i in q_mono:
    10451088                            if ((len(profile[1]) > i and profile[1][i] == 1)
    def atomic_basis_odd(n, basis, p, **kwds 
    10471090                                okay = False
    10481091                                break
    10491092
    1050                         for ((s,t), n) in p_mono:
    1051                             if ((len(profile) > t-1 and profile[t-1] <= s)
    1052                                 or (len(profile) <= t-1 and trunc < Infinity)):
     1093                        for ((s,t), exp) in p_mono:
     1094                            if ((len(profile[0]) > t-1 and profile[0][t-1] <= s)
     1095                                or (len(profile[0]) <= t-1 and trunc < Infinity)):
    10531096                                okay = False
    10541097                                break
    10551098
    def atomic_basis_odd(n, basis, p, **kwds 
    10601103    return tuple(result)
    10611104
    10621105#############################################################################
    1063 def steenrod_basis_error_check(dim, p, verbose=False):
     1106def steenrod_basis_error_check(dim, p):
    10641107    """
    10651108    This performs crude error checking.
    10661109
    def steenrod_basis_error_check(dim, p, v 
    10681111
    10691112    - ``dim`` - non-negative integer
    10701113    - ``p`` - positive prime number
    1071     - ``verbose`` - bool, optional (default False)
    10721114
    10731115    OUTPUT: None
    10741116
    def steenrod_basis_error_check(dim, p, v 
    10791121    This function checks at the prime ``p`` as the dimension goes up
    10801122    from 0 to ``dim``.
    10811123
    1082     If ``verbose`` is True, then print some messages along the way.
    1083     If ``verbose`` is False and all tests pass, then there should be
    1084     no output.
     1124    If you set the Sage verbosity level to a positive integer (using
     1125    ``set_verbose(n)``), then some extra messages will be printed.
    10851126
    10861127    EXAMPLES::
    10871128
    1088         sage: sage.algebras.steenrod.steenrod_algebra_bases.steenrod_basis_error_check(12,2)
    1089         sage: sage.algebras.steenrod.steenrod_algebra_bases.steenrod_basis_error_check(30,3)
     1129        sage: from sage.algebras.steenrod.steenrod_algebra_bases import steenrod_basis_error_check
     1130        sage: steenrod_basis_error_check(15,2) # long time
     1131        sage: steenrod_basis_error_check(40,3) # long time
     1132        sage: steenrod_basis_error_check(80,5) # long time
    10901133    """
     1134    import sage.misc.misc as misc
     1135
    10911136    if p == 2:
    10921137        bases = ('adem','woody', 'woodz', 'wall', 'arnona', 'arnonc',
    10931138                 'pst_rlex', 'pst_llex', 'pst_deg', 'pst_revz',
    10941139                 'comm_rlex', 'comm_llex', 'comm_deg', 'comm_revz')
    10951140    else:
    1096         bases = ('adem', 'milnor',
     1141        bases = ('adem',
    10971142                 'pst_rlex', 'pst_llex', 'pst_deg', 'pst_revz',
    10981143                 'comm_rlex', 'comm_llex', 'comm_deg', 'comm_revz')
    10991144
    1100     if verbose:
    1101         print "p=%s, checking up to dimension %s" % (p, dim)
    11021145    for i in range(dim):
    1103         if verbose and i % 5 == 0: print "up to dimension ", i
     1146        if i % 5 == 0:
     1147            misc.verbose("up to dimension %s"%i)
    11041148        milnor_dim = len(steenrod_algebra_basis_(i,'milnor',p=p))
    11051149        for B in bases:
    11061150            # use steenrod_algebra_basis_, the uncached version
    def steenrod_basis_error_check(dim, p, v 
    11111155            if mat.nrows() != 0 and not mat.is_invertible():
    11121156                print "%s invertibility problem in dim %s at p=%s" % (B, i, p)
    11131157
    1114     if verbose: print "done checking"
     1158    misc.verbose("done checking, no profiles")
     1159
     1160    bases = ('pst_rlex', 'pst_llex', 'pst_deg', 'pst_revz')
     1161    if p == 2:
     1162        profiles = [(4,3,2,1), (2,2,3,1,1), (0,0,0,2)]
     1163    else:
     1164        profiles = [((3,2,1), ()), ((), (2,1,2)), ((3,2,1), (2,2,2,2))]
     1165
     1166    for i in range(dim):
     1167        if i % 5 == 0:
     1168            misc.verbose("up to dimension %s"%i)
     1169        for pro in profiles:
     1170            milnor_dim = len(steenrod_algebra_basis_(i,'milnor',p=p,profile=pro))
     1171            for B in bases:
     1172                if milnor_dim != len(steenrod_algebra_basis_(i,B,p,profile=pro)):
     1173                    print "problem with milnor/%s in dimension %s with profile %s"%(B, i, pro)
     1174
     1175    misc.verbose("done checking with profiles")
  • sage/algebras/steenrod/steenrod_algebra_misc.py

    diff -r 23d55536e72d -r 2dc0757a042f sage/algebras/steenrod/steenrod_algebra_misc.py
    a b The main functions here are 
    2121
    2222- :func:`normalize_profile`.  This function returns the canonical (and
    2323  hashable) description of any profile function.  See
    24   :mod:`sage.algebras.steenrod.steenrod_algebra` and :func:`SteenrodAlgebra` for
    25   information on profile functions.
     24  :mod:`sage.algebras.steenrod.steenrod_algebra` and
     25  :func:`SteenrodAlgebra <sage.algebras.steenrod.steenrod_algebra.SteenrodAlgebra>`
     26  for information on profile functions.
    2627
    2728- functions named ``*_mono_to_string`` where ``*`` is a basis name
    2829  (:func:`milnor_mono_to_string`, etc.).  These convert tuples
    def is_valid_profile(profile, truncation 
    188189    sub-Hopf algebras of the Steenrod algebra.  Briefly: at the prime
    189190    2, a profile function `e` is valid if it satisfies the condition
    190191
    191     - `e(r) \geq \min( e(r-i) - i, e(i))` for all `0 \leq i < r`.
     192    - `e(r) \geq \min( e(r-i) - i, e(i))` for all `0 < i < r`.
    192193
    193194    At odd primes, a pair of profile functions `e` and `k` are valid
    194195    if they satisfy
    195196
    196     - `e(r) \geq \min( e(r-i) - i, e(i))` for all `0 \leq i < r`.
     197    - `e(r) \geq \min( e(r-i) - i, e(i))` for all `0 < i < r`.
    197198
    198199    - if `k(i+j) = 1`, then either `e(i) \leq j` or `k(j) = 1` for all
    199200      `i \geq 1`, `j \geq 0`.
    def is_valid_profile(profile, truncation 
    215216        False
    216217        sage: is_valid_profile([6,2,0], Infinity)
    217218        False
     219        sage: is_valid_profile([0,3], 0)
     220        False
     221        sage: is_valid_profile([0,0,4], 0)
     222        False
     223        sage: is_valid_profile([0,0,0,4,0], 0)
     224        True
    218225
    219226    Odd primes::
    220227
    def is_valid_profile(profile, truncation 
    228235        True
    229236    """
    230237    if p == 2:
    231         pro = list(profile) + [truncation_type]
     238        pro = list(profile) + [truncation_type]*len(profile)
    232239        r = 0
    233240        for pro_r in pro:
    234241            r += 1 # index of pro_r
    def is_valid_profile(profile, truncation 
    237244                    return False
    238245    else:
    239246        # p odd:
    240         e = list(profile[0]) + [truncation_type]
     247        e = list(profile[0]) + [truncation_type]*len(profile[0])
    241248        k = list(profile[1])
    242249        if truncation_type > 0:
    243250            k = k + [2]
    def normalize_profile(profile, precision 
    309316    terms (say, terms after the 100th), then they are given by
    310317    ``truncation_type`` if that is 0 or `\infty`.  If
    311318    ``truncation_type`` is 'auto', then in the case of a tuple, it
    312     gets set to 0, while for the other cases it gets set to '\infty'.
     319    gets set to 0, while for the other cases it gets set to `\infty`.
    313320
    314321    See the examples below.
    315322
    def comm_mono_to_string(mono, latex=Fals 
    923930    - ``latex`` - boolean (optional, default False), if true, output
    924931      LaTeX string
    925932
    926     - ``p`` - positive prime number (optional, default 2).  Unused.
     933    - ``p`` - positive prime number (optional, default 2)
    927934
    928935    OUTPUT: ``string`` - concatenation of strings of the form
    929936    ``c_{s,t}`` for each pair (s,t)
    def convert_perm(m): 
    10631070        sage: sage.algebras.steenrod.steenrod_algebra_misc.convert_perm((3,7,4))
    10641071        [1, 3, 2]
    10651072        sage: sage.algebras.steenrod.steenrod_algebra_misc.convert_perm((5,0,6,3))
    1066         [2, 4, 1, 3]
     1073        [3, 1, 4, 2]
    10671074    """   
    10681075    m2 = list(m)
    10691076    m2.sort()
    1070     return [list(m).index(x)+1 for x in m2]
     1077    return [list(m2).index(x)+1 for x in m]
  • sage/algebras/steenrod/steenrod_algebra_mult.py

    diff -r 23d55536e72d -r 2dc0757a042f sage/algebras/steenrod/steenrod_algebra_mult.py
    a b elements $Q_{f_1} Q_{f_2} ... \mathcal{P 
    7878
    7979Second, use the fact that the $Q_k$'s form an exterior algebra: $Q_k^2 =
    80800$ for all $k$, and if $i \neq j$, then $Q_i$ and $Q_j$ anticommute:
    81 $Q_i Q_j = -Q_j Q_i$.  After these two steps, the product is of the form
     81$Q_i Q_j = -Q_j Q_i$.  After these two steps, the product is a linear
     82combination of terms of the form
    8283
    8384.. math::
    8485
    85     \sum Q_{e_1} Q_{e_2} ... \mathcal{P}(r_1, r_2, ...) \mathcal{P}(s_1, s_2, ...).
     86    Q_{e_1} Q_{e_2} ... \mathcal{P}(r_1, r_2, ...) \mathcal{P}(s_1, s_2, ...).
    8687
    8788Finally, use Milnor matrices to multiply the pairs of
    8889$\mathcal{P}(...)$ terms, as at the prime 2: form all possible
    representing a sum of admissible monomia 
    193194
    194195REFERENCES:
    195196
    196 - [Mil] J. W. Milnor, "The Steenrod algebra and its dual, Ann. of Math.
    197   (2) \textbf{67} (1958), 150--171.
     197- [Mil] J. W. Milnor, "The Steenrod algebra and its dual", Ann. of Math.
     198  (2) 67 (1958), 150--171.
    198199
    199200- [SE] N. E. Steenrod, "Cohomology operations (Lectures by
    200   N. E. STeenrod written and revised by D. B. A.  Epstein). Annals of
     201  N. E. Steenrod written and revised by D. B. A.  Epstein)". Annals of
    201202  Mathematics Studies, No. 50, 1962, Princeton University Press.
    202203"""
    203204
    def milnor_multiplication(r,s): 
    248249
    249250        \text{Sq}(2,4) \text{Sq}(0,1) = \text{Sq}(2, 5) + \text{Sq}(2, 0, 0, 1)
    250251
    251     This uses the same algorithm Monks does in his Maple package.
     252    This uses the same algorithm Monks does in his Maple package: see
     253    http://mathweb.scranton.edu/monks/software/Steenrod/steen.html.
    252254    """
    253255    result = {}
    254256    rows = len(r) + 1
    def milnor_multiplication_odd(m1,m2,p): 
    431433        2 P(13,21,83) + P(14,24,82) + P(17,20,83) + P(25,18,83) + P(26,21,82) + P(36,15,80,1) + P(49,12,83) + 2 P(50,15,82) + 2 P(53,11,83) + 2 P(63,15,81)
    432434
    433435    This uses the same algorithm Monks does in his Maple package to
    434     iterate through the possible matrices.
     436    iterate through the possible matrices: see
     437    http://mathweb.scranton.edu/monks/software/Steenrod/steen.html.
    435438    """
    436439    from sage.rings.all import GF
    437440    F = GF(p)
    def adem_(a, b, c=0, p=2): 
    690693
    691694    OUTPUT: a dictionary representing the mod `p` Adem relations
    692695    applied to `P^a P^b` or (if `c` present) to `P^a \beta^b P^c`.
     696
     697    .. note::
     698
     699        Users should use :func:`adem` instead of this function (which
     700        has a trailing underscore in its name): :func:`adem`
     701        is the cached version of this one, and so will be faster.
    693702   
    694703    The mod `p` Adem relations for the mod `p` Steenrod algebra are as
    695704    follows: if `p=2`, then if `a < 2b`,
    def adem_(a, b, c=0, p=2): 
    730739    If `p` is given and is odd, then with two inputs `a` and `b`, the
    731740    Adem relation for `P^a P^b` is computed.  With three inputs `a`,
    732741    `b`, `c`, the Adem relation for `P^a \beta^b P^c` is computed.
    733     In either case, the keys in output are all tuples of odd length,
     742    In either case, the keys in the output are all tuples of odd length,
    734743    with ``(i_1, i_2, ..., i_m)`` representing
    735744
    736745    .. math::
    def make_mono_admissible_(mono, p=2): 
    846855    to the first pair (or triple when `p` is odd) where the sequence
    847856    is inadmissible, and then apply this function recursively to each
    848857    of the resulting tuples `(i_1, ..., i_{j-1}, NEW, i_{j+2}, ...)`,
    849     keeping track of the coefficients
     858    keeping track of the coefficients.
     859
     860    .. note::
     861
     862        Users should use :func:`make_mono_admissible` instead of this
     863        function (which has a trailing underscore in its name):
     864        :func:`make_mono_admissible` is the cached version of this
     865        one, and so will be faster.
    850866
    851867    EXAMPLES::
    852868
  • sage/categories/coalgebras_with_basis.py

    diff -r 23d55536e72d -r 2dc0757a042f sage/categories/coalgebras_with_basis.py
    a b class CoalgebrasWithBasis(Category_over_ 
    9191        @lazy_attribute
    9292        def coproduct(self):
    9393            """
    94             If :meth:`.coproduct_on_basis` is available, construct the
     94            If :meth:`coproduct_on_basis` is available, construct the
    9595            coproduct morphism from ``self`` to ``self`` `\otimes`
    9696            ``self`` by extending it by linearity
    9797
    class CoalgebrasWithBasis(Category_over_ 
    115115        @lazy_attribute
    116116        def counit(self):
    117117            """
    118             If :meth:`.counit_on_basis` is available, construct the
     118            If :meth:`counit_on_basis` is available, construct the
    119119            counit morphism from ``self`` to ``self`` `\otimes`
    120120            ``self`` by extending it by linearity
    121121