Ticket #5048: trac_5048-rebased_for_11422.patch

File trac_5048-rebased_for_11422.patch, 9.1 KB (added by davidloeffler, 10 years ago)

version rebased to 4.7.1.alpha4 + #11422

  • sage/modular/arithgroup/arithgroup_element.py

    # HG changeset patch
    # User David Loeffler <d.loeffler.01@cantab.net>
    # Date 1291928574 0
    # Node ID 8a078f2d02d739d0b21bd924907c3752ef5d3ed2
    # Parent  b1087c12366f054104b73c198a06c151f201df0b
    #5048: fix coercion issues with elements of congruence subgroups
    
    diff -r b1087c12366f -r 8a078f2d02d7 sage/modular/arithgroup/arithgroup_element.py
    a b  
    2525
    2626class ArithmeticSubgroupElement(MultiplicativeGroupElement):
    2727    r"""
    28     An element of an arithmetic subgroup of `{\rm SL}_2(\ZZ)`.
     28    An element of the group `{\rm SL}_2(\ZZ)`, i.e. a 2x2 integer matrix of
     29    determinant 1.
    2930    """
    3031
    3132    def __init__(self, parent, x, check=True):
     
    3334        Create an element of an arithmetic subgroup.
    3435
    3536        INPUT:
     37
    3638        - parent - an arithmetic subgroup
    3739
    3840        - x - data defining a 2x2 matrix over ZZ
     
    4244          is an arithmetic subgroup, and that
    4345          x defines a matrix of determinant 1
    4446
     47        We tend not to create elements of arithmetic subgroups that aren't
     48        SL2Z, in order to avoid coercion issues (that is, the other arithmetic
     49        subgroups are "facade parents").
     50
    4551        EXAMPLES::
    4652
    4753            sage: G = Gamma0(27)
     
    162168            [ 3  2]
    163169            [28 19]
    164170            sage: x.parent()
    165             Congruence Subgroup Gamma0(7)
     171            Modular Group SL(2,Z)
     172
     173        We check that #5048 is fixed::
     174
     175            sage: a = Gamma0(10).1 * Gamma0(5).2; a # random
     176            sage: a.parent()
     177            Modular Group SL(2,Z)
     178
    166179        """
    167180        return self.parent()(self.__x * right.__x, check=False)
    168181
  • sage/modular/arithgroup/arithgroup_generic.py

    diff -r b1087c12366f -r 8a078f2d02d7 sage/modular/arithgroup/arithgroup_generic.py
    a b  
    4747    assuming that it has a working element testing routine.
    4848    """
    4949
     50    def __init__(self):
     51        r"""
     52        Standard init routine.
     53
     54        EXAMPLE::
     55
     56            sage: G = Gamma1(7)
     57            sage: G.category() # indirect doctest
     58            Category of groups
     59        """
     60        group.Group.__init__(self)
     61
    5062    def _repr_(self):
    5163        r"""
    5264        Return the string representation of self.
  • sage/modular/arithgroup/arithgroup_perm.py

    diff -r b1087c12366f -r 8a078f2d02d7 sage/modular/arithgroup/arithgroup_perm.py
    a b  
    972972            sage: m4 in P
    973973            False
    974974        """
    975         if x.parent() is self or x.parent() == self: return True
     975        #if x.parent() is self or x.parent() == self: return True
    976976        if x not in SL2Z: return False
    977977       
    978978        w = sl2z_word_problem(x)
     
    10621062            [1 1]
    10631063            [0 1]
    10641064        """
    1065         g = SL2Z(g)
     1065        g = SL2Z(g, check=check)
    10661066        if not check or g in self:
    1067             return ArithmeticSubgroupElement(parent=self,x=g,check=check)
     1067            return g
    10681068        raise TypeError, "The element is not in group"
    10691069
    10701070    #
  • sage/modular/arithgroup/congroup_gamma.py

    diff -r b1087c12366f -r 8a078f2d02d7 sage/modular/arithgroup/congroup_gamma.py
    a b  
    130130            TypeError: matrix must have diagonal entries (=1, 7) congruent to 1
    131131            modulo 5, and off-diagonal entries (=1,6) divisible by 5
    132132        """
    133         if isinstance(x, ArithmeticSubgroupElement) and x.parent() == self:
    134             return x
    135         x = ArithmeticSubgroupElement(self, x, check=check)
     133        from all import SL2Z
     134        x = SL2Z(x, check)
    136135        if not check:
    137136            return x
    138137
  • sage/modular/arithgroup/congroup_gamma0.py

    diff -r b1087c12366f -r 8a078f2d02d7 sage/modular/arithgroup/congroup_gamma0.py
    a b  
    446446            ...
    447447            TypeError: matrix must have lower left entry (=23) divisible by 12
    448448        """
    449         if isinstance(x, ArithmeticSubgroupElement) and x.parent() == self:
    450             return x
    451         x = ArithmeticSubgroupElement(self, x, check=check)
     449        from all import SL2Z
     450        x = SL2Z(x, check)
    452451        if not check:
    453452            return x
    454453       
  • sage/modular/arithgroup/congroup_gamma1.py

    diff -r b1087c12366f -r 8a078f2d02d7 sage/modular/arithgroup/congroup_gamma1.py
    a b  
    288288            ...
    289289            TypeError: matrix must have diagonal entries (=1, 7) congruent to 1 modulo 5, and lower left entry (=6) divisible by 5
    290290        """
    291         if isinstance(x, ArithmeticSubgroupElement) and x.parent() == self:
    292             return x
    293         x = ArithmeticSubgroupElement(self, x, check=check)
     291        from all import SL2Z
     292        x = SL2Z(x, check)
    294293        if not check:
    295294            return x
    296295       
     
    298297        c = x.c()
    299298        d = x.d()
    300299        N = self.level()
    301         if (a%N == 1) and (c%N == 0) and (d%N == 1):
     300        if (a%N == 1) and (c%N == 0):
    302301            return x
     302            # don't need to check d == 1 mod N as this is automatic from det
    303303        else:
    304304            raise TypeError, "matrix must have diagonal entries (=%s, %s) congruent to 1 modulo %s, and lower left entry (=%s) divisible by %s" %(a, d, N, c, N)
    305305
  • sage/modular/arithgroup/congroup_gammaH.py

    diff -r b1087c12366f -r 8a078f2d02d7 sage/modular/arithgroup/congroup_gammaH.py
    a b  
    871871            ...
    872872            TypeError: matrix must have lower right entry (=3) congruent modulo 10 to some element of H
    873873        """
    874         if isinstance(x, ArithmeticSubgroupElement) and x.parent() == self:
    875             return x
    876         x = ArithmeticSubgroupElement(self, x, check=check)
     874        from all import SL2Z
     875        x = SL2Z(x, check)
    877876        if not check:
    878877            return x
    879878       
  • sage/modular/arithgroup/congroup_generic.py

    diff -r b1087c12366f -r 8a078f2d02d7 sage/modular/arithgroup/congroup_generic.py
    a b  
    6666        if level <= 0:
    6767            raise ArithmeticError, "Congruence groups only defined for positive levels."
    6868        self.__level = level
     69        ArithmeticSubgroup.__init__(self)
    6970
    7071    def _repr_(self):
    7172        """
     
    201202        else:
    202203            raise NotImplementedError
    203204
    204     def __call__(self, x, check=True):
    205         """
    206         Coerce x into self.
    207 
    208         NOTE: This function should be overridden by any subclass the
    209         user will interact with directly.
    210 
    211         EXAMPLES::
    212 
    213             sage: sage.modular.arithgroup.congroup_generic.CongruenceSubgroup(5).__call__(0)
    214             Traceback (most recent call last):
    215             ...
    216             NotImplementedError
    217         """
    218         if isinstance(x, ArithmeticSubgroupElement) and x.parent() == self:
    219             return x
    220         raise NotImplementedError
  • sage/modular/arithgroup/congroup_sl2z.py

    diff -r b1087c12366f -r 8a078f2d02d7 sage/modular/arithgroup/congroup_sl2z.py
    a b  
    2020################################################################################
    2121
    2222from congroup_gamma0 import Gamma0_class
     23from arithgroup_element import ArithmeticSubgroupElement
    2324from sage.rings.integer_ring import ZZ
    2425from sage.modular.cusps import Cusp
    2526from sage.rings.arith import gcd
     
    9293        """
    9394        return _SL2Z_ref, ()
    9495
     96    def __call__(self, x, check=True):
     97        r"""
     98        Create an element of self from x. If check=True (the default), check
     99        that x really defines a 2x2 integer matrix of det 1.
     100        """
     101        return ArithmeticSubgroupElement(self, x, check=check)
     102
    95103    def _repr_(self):
    96104        """
    97105        Return the string representation of self.
  • sage/modular/modform/constructor.py

    diff -r b1087c12366f -r 8a078f2d02d7 sage/modular/modform/constructor.py
    a b  
    8484        (5, Congruence Subgroup Gamma0(5), 7, Integer Ring)
    8585        sage: type(v[0]), type(v[1]), type(v[2]), type(v[3])
    8686        (<type 'sage.rings.integer.Integer'>,
    87          <class 'sage.modular.arithgroup.congroup_gamma0.Gamma0_class'>,
     87         <class 'sage.modular.arithgroup.congroup_gamma0.Gamma0_class_with_category'>,
    8888         <type 'sage.rings.integer.Integer'>,
    8989         <type 'sage.rings.integer_ring.IntegerRing_class'>)
    9090        sage: canonical_parameters( 5, 7, 7, ZZ )