Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# -*- coding: utf-8 -*- r""" The set `\mathbb{P}^1(\QQ)` of cusps
EXAMPLES::
sage: Cusps Set P^1(QQ) of all cusps
::
sage: Cusp(oo) Infinity """
#***************************************************************************** # Copyright (C) 2005 William Stein <wstein@gmail.com> # # Distributed under the terms of the GNU General Public License (GPL) # # This code is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # The full text of the GPL is available at: # # http://www.gnu.org/licenses/ #***************************************************************************** from __future__ import print_function from six import integer_types
from sage.rings.all import Rational, Integer, ZZ, QQ from sage.rings.infinity import is_Infinite, Infinity
from sage.structure.parent_base import ParentWithBase from sage.structure.element import Element, is_InfinityElement from sage.structure.richcmp import richcmp
from sage.modular.modsym.p1list import lift_to_sl2z_llong from sage.structure.element import is_Matrix from sage.misc.cachefunc import cached_method from sage.misc.superseded import deprecated_function_alias
class Cusps_class(ParentWithBase): """ The set of cusps.
EXAMPLES::
sage: C = Cusps; C Set P^1(QQ) of all cusps sage: loads(C.dumps()) == C True """ def __init__(self): r""" The set of cusps, i.e. `\mathbb{P}^1(\QQ)`.
EXAMPLES::
sage: C = sage.modular.cusps.Cusps_class() ; C Set P^1(QQ) of all cusps sage: Cusps == C True """
def __eq__(self, right): """ Return equality only if ``right`` is the set of cusps.
EXAMPLES::
sage: Cusps == Cusps True sage: Cusps == QQ False """
def __ne__(self, right): """ Check that ``self`` is not equal to ``right``.
EXAMPLES::
sage: Cusps != Cusps False sage: Cusps != QQ True """
def _repr_(self): """ String representation of the set of cusps.
EXAMPLES::
sage: Cusps Set P^1(QQ) of all cusps sage: Cusps._repr_() 'Set P^1(QQ) of all cusps' sage: Cusps.rename('CUSPS'); Cusps CUSPS sage: Cusps.rename(); Cusps Set P^1(QQ) of all cusps sage: Cusps Set P^1(QQ) of all cusps """
def _latex_(self): """ Return latex representation of self.
EXAMPLES::
sage: latex(Cusps) \mathbf{P}^1(\QQ) sage: latex(Cusps) == Cusps._latex_() True """
def __call__(self, x): """ Coerce x into the set of cusps.
EXAMPLES::
sage: a = Cusps(-4/5); a -4/5 sage: Cusps(a) is a False sage: Cusps(1.5) 3/2 sage: Cusps(oo) Infinity sage: Cusps(I) Traceback (most recent call last): ... TypeError: unable to convert I to a cusp """
def _coerce_impl(self, x): """ Canonical coercion of x into the set of cusps.
EXAMPLES::
sage: Cusps._coerce_(7/13) 7/13 sage: Cusps._coerce_(GF(7)(3)) Traceback (most recent call last): ... TypeError: no canonical coercion of element into self sage: Cusps(GF(7)(3)) 3 sage: Cusps._coerce_impl(GF(7)(3)) Traceback (most recent call last): ... TypeError: no canonical coercion of element into self """ else:
@cached_method def zero(self): """ Return the zero cusp.
.. NOTE::
The existence of this method is assumed by some parts of Sage's coercion model.
EXAMPLES::
sage: Cusps.zero() 0 """
zero_element = deprecated_function_alias(17694, zero)
Cusps = Cusps_class()
class Cusp(Element): """ A cusp.
A cusp is either a rational number or infinity, i.e., an element of the projective line over Q. A Cusp is stored as a pair (a,b), where gcd(a,b)=1 and a,b are of type Integer.
EXAMPLES::
sage: a = Cusp(2/3); b = Cusp(oo) sage: a.parent() Set P^1(QQ) of all cusps sage: a.parent() is b.parent() True """ def __init__(self, a, b=None, parent=None, check=True): r""" Create the cusp a/b in `\mathbb{P}^1(\QQ)`, where if b=0 this is the cusp at infinity.
When present, b must either be Infinity or coercible to an Integer.
EXAMPLES::
sage: Cusp(2,3) 2/3 sage: Cusp(3,6) 1/2 sage: Cusp(1,0) Infinity sage: Cusp(infinity) Infinity sage: Cusp(5) 5 sage: Cusp(1/2) 1/2 sage: Cusp(1.5) 3/2 sage: Cusp(int(7)) 7 sage: Cusp(1, 2, check=False) 1/2 sage: Cusp('sage', 2.5, check=False) # don't do this! sage/2.50000000000000
::
sage: I**2 -1 sage: Cusp(I) Traceback (most recent call last): ... TypeError: unable to convert I to a cusp
::
sage: a = Cusp(2,3) sage: loads(a.dumps()) == a True
::
sage: Cusp(1/3,0) Infinity sage: Cusp((1,0)) Infinity
TESTS::
sage: Cusp("1/3", 5) 1/15 sage: Cusp(Cusp(3/5), 7) 3/35 sage: Cusp(5/3, 0) Infinity sage: Cusp(3,oo) 0 sage: Cusp((7,3), 5) 7/15 sage: Cusp(int(5), 7) 5/7
::
sage: Cusp(0,0) Traceback (most recent call last): ... TypeError: unable to convert (0, 0) to a cusp
::
sage: Cusp(oo,oo) Traceback (most recent call last): ... TypeError: unable to convert (+Infinity, +Infinity) to a cusp
::
sage: Cusp(Cusp(oo),oo) Traceback (most recent call last): ... TypeError: unable to convert (Infinity, +Infinity) to a cusp """
raise TypeError("unable to convert %r to a cusp" % a) except (ValueError, TypeError): raise TypeError("unable to convert %r to a cusp" % a) else:
self.__a = ZZ.one() self.__b = ZZ.zero() return else: self.__a = ZZ.one() self.__b = ZZ.zero() return raise TypeError("unable to convert (%r, %r) to a cusp" % (a, b)) else: except (ValueError, TypeError): raise TypeError("unable to convert (%r, %r) to a cusp" % (a, b))
def __hash__(self): """ EXAMPLES::
sage: hash(Cusp(1/3)) 1298787075 # 32-bit 3713081631933328131 # 64-bit sage: hash(Cusp(oo)) 1302034650 # 32-bit 3713081631936575706 # 64-bit """
def _richcmp_(self, right, op): """ Compare the cusps ``self`` and ``right``.
Comparison is as for rational numbers, except with the cusp oo greater than everything but itself.
The ordering in comparison is only really meaningful for infinity or elements that coerce to the rationals.
EXAMPLES::
sage: Cusp(2/3) == Cusp(oo) False
sage: Cusp(2/3) < Cusp(oo) True
sage: Cusp(2/3)> Cusp(oo) False
sage: Cusp(2/3) > Cusp(5/2) False
sage: Cusp(2/3) < Cusp(5/2) True
sage: Cusp(2/3) == Cusp(5/2) False
sage: Cusp(oo) == Cusp(oo) True
sage: 19/3 < Cusp(oo) True
sage: Cusp(oo) < 19/3 False
sage: Cusp(2/3) < Cusp(11/7) True
sage: Cusp(11/7) < Cusp(2/3) False
sage: 2 < Cusp(3) True """ else: else:
def is_infinity(self): """ Returns True if this is the cusp infinity.
EXAMPLES::
sage: Cusp(3/5).is_infinity() False sage: Cusp(1,0).is_infinity() True sage: Cusp(0,1).is_infinity() False """
def numerator(self): """ Return the numerator of the cusp a/b.
EXAMPLES::
sage: x=Cusp(6,9); x 2/3 sage: x.numerator() 2 sage: Cusp(oo).numerator() 1 sage: Cusp(-5/10).numerator() -1 """
def denominator(self): """ Return the denominator of the cusp a/b.
EXAMPLES::
sage: x=Cusp(6,9); x 2/3 sage: x.denominator() 3 sage: Cusp(oo).denominator() 0 sage: Cusp(-5/10).denominator() 2 """
def _rational_(self): """ Coerce to a rational number.
EXAMPLES::
sage: QQ(Cusp(oo)) Traceback (most recent call last): ... TypeError: cusp Infinity is not a rational number sage: QQ(Cusp(-3,7)) -3/7 sage: Cusp(11,2)._rational_() 11/2 """
def _integer_(self, ZZ=None): """ Coerce to an integer.
EXAMPLES::
sage: ZZ(Cusp(-19)) -19 sage: Cusp(4,2)._integer_() 2
::
sage: ZZ(Cusp(oo)) Traceback (most recent call last): ... TypeError: cusp Infinity is not an integer sage: ZZ(Cusp(-3,7)) Traceback (most recent call last): ... TypeError: cusp -3/7 is not an integer """
def _repr_(self): """ String representation of this cusp.
EXAMPLES::
sage: a = Cusp(2/3); a 2/3 sage: a._repr_() '2/3' sage: a.rename('2/3(cusp)'); a 2/3(cusp) """ else:
def _latex_(self): r""" Latex representation of this cusp.
EXAMPLES::
sage: latex(Cusp(-2/7)) \frac{-2}{7} sage: latex(Cusp(oo)) \infty sage: latex(Cusp(oo)) == Cusp(oo)._latex_() True """ else:
def __neg__(self): """ The negative of this cusp.
EXAMPLES::
sage: -Cusp(2/7) -2/7 sage: -Cusp(oo) Infinity """
def is_gamma0_equiv(self, other, N, transformation = None): r""" Return whether self and other are equivalent modulo the action of `\Gamma_0(N)` via linear fractional transformations.
INPUT:
- ``other`` - Cusp
- ``N`` - an integer (specifies the group Gamma_0(N))
- ``transformation`` - None (default) or either the string 'matrix' or 'corner'. If 'matrix', it also returns a matrix in Gamma_0(N) that sends self to other. The matrix is chosen such that the lower left entry is as small as possible in absolute value. If 'corner' (or True for backwards compatibility), it returns only the upper left entry of such a matrix.
OUTPUT:
- a boolean - True if self and other are equivalent
- a matrix or an integer- returned only if transformation is 'matrix' or 'corner', respectively.
EXAMPLES::
sage: x = Cusp(2,3) sage: y = Cusp(4,5) sage: x.is_gamma0_equiv(y, 2) True sage: _, ga = x.is_gamma0_equiv(y, 2, 'matrix'); ga [-1 2] [-2 3] sage: x.is_gamma0_equiv(y, 3) False sage: x.is_gamma0_equiv(y, 3, 'matrix') (False, None) sage: Cusp(1/2).is_gamma0_equiv(1/3,11,'corner') (True, 19)
sage: Cusp(1,0) Infinity sage: z = Cusp(1,0) sage: x.is_gamma0_equiv(z, 3, 'matrix') ( [-1 1] True, [-3 2] )
ALGORITHM: See Proposition 2.2.3 of Cremona's book 'Algorithms for Modular Elliptic Curves', or Prop 2.27 of Stein's Ph.D. thesis. """ raise ValueError("Value %s of the optional argument transformation is not valid.")
#if transformation : # transformation = "corner"
else:
# a necessary, but not sufficient condition unless N is square-free else:
else: else: else: else: else:
# Now we know the cusps are equivalent. Use the proof of Prop 2.2.3 # of Cremona to find a matrix in Gamma_0(N) relating them. if transformation == "matrix": return (True, matrix(ZZ,[[1,0],[0,1]])) else: return (True, one) else: return (True, matrix(ZZ, [[u2,r2],[v2,s2]]) ) else:
else: return (True, s1)
# solve x*v1*v2 + a = 0 (mod N). # so x0*v1*v2 - g = 0 (mod N) # now x*v1*v2 + a = 0 (mod N)
# the rest is all added in trac #10926
k = - C//(M*v1*v2) else:
# C += k*M*v1*v2 # is now the smallest in absolute value
else: # mainly for backwards compatibility and # for how it is used in modular symbols
def is_gamma1_equiv(self, other, N): """ Return whether self and other are equivalent modulo the action of Gamma_1(N) via linear fractional transformations.
INPUT:
- ``other`` - Cusp
- ``N`` - an integer (specifies the group Gamma_1(N))
OUTPUT:
- ``bool`` - True if self and other are equivalent
- ``int`` - 0, 1 or -1, gives further information about the equivalence: If the two cusps are u1/v1 and u2/v2, then they are equivalent if and only if v1 = v2 (mod N) and u1 = u2 (mod gcd(v1,N)) or v1 = -v2 (mod N) and u1 = -u2 (mod gcd(v1,N)) The sign is +1 for the first and -1 for the second. If the two cusps are not equivalent then 0 is returned.
EXAMPLES::
sage: x = Cusp(2,3) sage: y = Cusp(4,5) sage: x.is_gamma1_equiv(y,2) (True, 1) sage: x.is_gamma1_equiv(y,3) (False, 0) sage: z = Cusp(QQ(x) + 10) sage: x.is_gamma1_equiv(z,10) (True, 1) sage: z = Cusp(1,0) sage: x.is_gamma1_equiv(z, 3) (True, -1) sage: Cusp(0).is_gamma1_equiv(oo, 1) (True, 1) sage: Cusp(0).is_gamma1_equiv(oo, 3) (False, 0) """
def is_gamma_h_equiv(self, other, G): """ Return a pair (b, t), where b is True or False as self and other are equivalent under the action of G, and t is 1 or -1, as described below.
Two cusps `u1/v1` and `u2/v2` are equivalent modulo Gamma_H(N) if and only if `v1 = h*v2 (\mathrm{mod} N)` and `u1 = h^{(-1)}*u2 (\mathrm{mod} gcd(v1,N))` or `v1 = -h*v2 (mod N)` and `u1 = -h^{(-1)}*u2 (\mathrm{mod} gcd(v1,N))` for some `h \in H`. Then t is 1 or -1 as c and c' fall into the first or second case, respectively.
INPUT:
- ``other`` - Cusp
- ``G`` - a congruence subgroup Gamma_H(N)
OUTPUT:
- ``bool`` - True if self and other are equivalent
- ``int`` - -1, 0, 1; extra info
EXAMPLES::
sage: x = Cusp(2,3) sage: y = Cusp(4,5) sage: x.is_gamma_h_equiv(y,GammaH(13,[2])) (True, 1) sage: x.is_gamma_h_equiv(y,GammaH(13,[5])) (False, 0) sage: x.is_gamma_h_equiv(y,GammaH(5,[])) (False, 0) sage: x.is_gamma_h_equiv(y,GammaH(23,[4])) (True, -1)
Enumerating the cusps for a space of modular symbols uses this function.
::
sage: G = GammaH(25,[6]) ; M = G.modular_symbols() ; M Modular Symbols space of dimension 11 for Congruence Subgroup Gamma_H(25) with H generated by [6] of weight 2 with sign 0 and over Rational Field sage: M.cusps() [37/75, 1/2, 31/125, 1/4, -2/5, 2/5, -1/5, 1/10, -3/10, 1/15, 7/15, 9/20] sage: len(M.cusps()) 12
This is always one more than the associated space of weight 2 Eisenstein series.
::
sage: G.dimension_eis(2) 11 sage: M.cuspidal_subspace() Modular Symbols subspace of dimension 0 of Modular Symbols space of dimension 11 for Congruence Subgroup Gamma_H(25) with H generated by [6] of weight 2 with sign 0 and over Rational Field sage: G.dimension_cusp_forms(2) 0 """ other = Cusp(other) raise TypeError("G must be a group GammaH(N).")
def _acted_upon_(self, g, self_on_left): r""" Implements the left action of `SL_2(\ZZ)` on self.
EXAMPLES::
sage: g = matrix(ZZ, 2, [1,1,0,1]); g [1 1] [0 1] sage: g * Cusp(2,5) 7/5 sage: Cusp(2,5) * g Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for *: 'Set P^1(QQ) of all cusps' and 'Full MatrixSpace of 2 by 2 dense matrices over Integer Ring' sage: h = matrix(ZZ, 2, [12,3,-100,7]) sage: h * Cusp(2,5) -13/55 sage: Cusp(2,5)._acted_upon_(h, False) -13/55 sage: (h*g) * Cusp(3,7) == h * (g * Cusp(3,7)) True
sage: cm = sage.structure.element.get_coercion_model() sage: cm.explain(MatrixSpace(ZZ, 2), Cusps) Action discovered. Left action by Full MatrixSpace of 2 by 2 dense matrices over Integer Ring on Set P^1(QQ) of all cusps Result lives in Set P^1(QQ) of all cusps Set P^1(QQ) of all cusps """ and g.ncols() == 2 and g.nrows() == 2):
def apply(self, g): """ Return g(self), where g=[a,b,c,d] is a list of length 4, which we view as a linear fractional transformation.
EXAMPLES: Apply the identity matrix::
sage: Cusp(0).apply([1,0,0,1]) 0 sage: Cusp(0).apply([0,-1,1,0]) Infinity sage: Cusp(0).apply([1,-3,0,1]) -3 """
def galois_action(self, t, N): r""" Suppose this cusp is `\alpha`, `G` a congruence subgroup of level `N` and `\sigma` is the automorphism in the Galois group of `\QQ(\zeta_N)/\QQ` that sends `\zeta_N` to `\zeta_N^t`. Then this function computes a cusp `\beta` such that `\sigma([\alpha]) = [\beta]`, where `[\alpha]` is the equivalence class of `\alpha` modulo `G`.
This code only needs as input the level and not the group since the action of Galois for a congruence group `G` of level `N` is compatible with the action of the full congruence group `\Gamma(N)`.
INPUT:
- `t` -- integer that is coprime to N
- `N` -- positive integer (level)
OUTPUT:
- a cusp
.. WARNING::
In some cases `N` must fit in a long long, i.e., there are cases where this algorithm isn't fully implemented.
.. NOTE::
Modular curves can have multiple non-isomorphic models over `\QQ`. The action of Galois depends on such a model. The model over `\QQ` of `X(G)` used here is the model where the function field `\QQ(X(G))` is given by the functions whose Fourier expansion at `\infty` have their coefficients in `\QQ`. For `X(N):=X(\Gamma(N))` the corresponding moduli interpretation over `\ZZ[1/N]` is that `X(N)` parametrizes pairs `(E,a)` where `E` is a (generalized) elliptic curve and `a: \ZZ / N\ZZ \times \mu_N \to E` is a closed immersion such that the Weil pairing of `a(1,1)` and `a(0,\zeta_N)` is `\zeta_N`. In this parameterisation the point `z \in H` corresponds to the pair `(E_z,a_z)` with `E_z=\CC/(z \ZZ+\ZZ)` and `a_z: \ZZ / N\ZZ \times \mu_N \to E` given by `a_z(1,1) = z/N` and `a_z(0,\zeta_N) = 1/N`. Similarly `X_1(N):=X(\Gamma_1(N))` parametrizes pairs `(E,a)` where `a: \mu_N \to E` is a closed immersion.
EXAMPLES::
sage: Cusp(1/10).galois_action(3, 50) 1/170 sage: Cusp(oo).galois_action(3, 50) Infinity sage: c=Cusp(0).galois_action(3, 50); c 50/67 sage: Gamma0(50).reduce_cusp(c) 0
Here we compute the permutations of the action for t=3 on cusps for Gamma0(50). ::
sage: N = 50; t=3; G = Gamma0(N); C = G.cusps() sage: cl = lambda z: exists(C, lambda y:y.is_gamma0_equiv(z, N))[1] sage: for i in range(5): ....: print((i, t^i)) ....: print([cl(alpha.galois_action(t^i,N)) for alpha in C]) (0, 1) [0, 1/25, 1/10, 1/5, 3/10, 2/5, 1/2, 3/5, 7/10, 4/5, 9/10, Infinity] (1, 3) [0, 1/25, 7/10, 2/5, 1/10, 4/5, 1/2, 1/5, 9/10, 3/5, 3/10, Infinity] (2, 9) [0, 1/25, 9/10, 4/5, 7/10, 3/5, 1/2, 2/5, 3/10, 1/5, 1/10, Infinity] (3, 27) [0, 1/25, 3/10, 3/5, 9/10, 1/5, 1/2, 4/5, 1/10, 2/5, 7/10, Infinity] (4, 81) [0, 1/25, 1/10, 1/5, 3/10, 2/5, 1/2, 3/5, 7/10, 4/5, 9/10, Infinity]
TESTS:
Here we check that the Galois action is indeed a permutation on the cusps of Gamma1(48) and check that :trac:`13253` is fixed. ::
sage: G=Gamma1(48) sage: C=G.cusps() sage: for i in Integers(48).unit_gens(): ....: C_permuted = [G.reduce_cusp(c.galois_action(i,48)) for c in C] ....: assert len(set(C_permuted))==len(C)
We test that Gamma1(19) has 9 rational cusps and check that :trac:`8998` is fixed. ::
sage: G = Gamma1(19) sage: [c for c in G.cusps() if c.galois_action(2,19).is_gamma1_equiv(c,19)[0]] [2/19, 3/19, 4/19, 5/19, 6/19, 7/19, 8/19, 9/19, Infinity]
REFERENCES:
- Section 1.3 of Glenn Stevens, "Arithmetic on Modular Curves"
- There is a long comment about our algorithm in the source code for this function.
AUTHORS:
- William Stein, 2009-04-18
"""
# Our algorithm for computing the Galois action works as # follows (see Section 1.3 of Glenn Stevens "Arithmetic on # Modular Curves" for a proof that the action given below is # correct). We alternatively view the set of cusps as the # Gamma-equivalence classes of column vectors [a;b] with # gcd(a,b,N)=1, and the left action of Gamma by matrix # multiplication. The action of t is induced by [a;b] |--> # [a;t'*b], where t' is an inverse mod N of t. For [a;t'*b] # with gcd(a,t'*b)==1, the cusp corresponding to [a;t'*b] is # just the rational number a/(t'*b). Thus in this case, to # compute the action of t we just do a/b <--> [a;b] |---> # [a;t'*b] <--> a/(t'*b). IN the other case when we get # [a;t'*b] with gcd(a,t'*b) != 1, which can and does happen, # we have to work a bit harder. We need to find [c;d] such # that [c;d] is congruent to [a;t'*b] modulo N, and # gcd(c,d)=1. There is a standard lifting algorithm that is # implemented for working with P^1(Z/NZ) [it is needed for # modular symbols algorithms], so we just apply it to lift # [a,t'*b] to a matrix [A,B;c,d] in SL_2(Z) with lower two # entries congruent to [a,t'*b] modulo N. This exactly solves # our problem, since gcd(c,d)=1.
# Now that we've computed the Galois action, we efficiently # construct the corresponding cusp as a Cusp object. |