# Ticket #11599: trac_11599_reviewer.patch

File trac_11599_reviewer.patch, 16.7 KB (added by novoselt, 10 years ago)
• ## sage/schemes/generic/homset.py

# HG changeset patch
# User Andrey Novoseltsev <novoselt@gmail.com>
# Date 1328762167 25200
# Node ID cf7bcab00b65280dec499db809b8f97e99c68fd4
Reviewer changes to scheme morphisms refactoring.

diff --git a/sage/schemes/generic/homset.py b/sage/schemes/generic/homset.py
 a As a special case, the hom sets can also represent the points of a scheme. Recall that the K-rational points of a scheme X over k can be identified with the set of morphisms Spec(K) \to X. In Sage, can be identified with the set of morphisms Spec(K) \to X. In Sage the rational points are implemented by such scheme morphisms. This is done by :class:SchemeHomset_points and its subclasses. You should not create the homsets manually. Instead, use the :meth:~sage.structure.parent.Hom method that is inherited by all schemes. AUTHORS: - William Stein (2006): initial version. - Volker Braun (2011-08-11): significant improvement and refactoring. """ #***************************************************************************** #  Copyright (C) 2006 William Stein #       Copyright (C) 2011 Volker Braun #       Copyright (C) 2006 William Stein # #  Distributed under the terms of the GNU General Public License (GPL) #  as published by the Free Software Foundation; either version 2 of #  the License, or (at your option) any later version. #                  http://www.gnu.org/licenses/ #***************************************************************************** from sage.categories.homset import HomsetWithBase from sage.structure.factory import UniqueFactory sage: A2 = AffineSpace(QQ,2) sage: A3 = AffineSpace(QQ,3) sage: Hom = A3.Hom(A2) The Hom sets are unique:: sage: Hom is copy(Hom) True sage: Hom is A3.Hom(A2) sage: loads(Hom.dumps()) is Hom True Here is a tricy point. The Hom sets are not identical if domain/codomains are isomorphic but not identiacal:: Here is a tricky point. The Hom sets are not identical if domains/codomains are isomorphic but not identiacal:: sage: A3_iso = AffineSpace(QQ,3) sage: [ A3_iso is A3, A3_iso == A3 ] Integer Ring """ def create_key_and_extra_args(self, X, Y, category=None, check=True, base=ZZ): def create_key_and_extra_args(self, X, Y, category=None, base=ZZ, check=True): """ Create a key that uniquely determines the Hom set. - X -- a scheme. The domain of the morphisms. - Y -- a scheme. The codomain of the morphisms. - category -- a category for the Hom sets (default: schemes over given base). - base -- a scheme or a ring. The base scheme of domain and codomain schemes. If a ring is specified, the spectrum of that ring will be used as base scheme. - check -- boolean (default: True). - check -- boolean (default: True). EXAMPLES:: base_spec = Spec(base) base_ring = base else: raise ValueError('The base must be an affine scheme or a commutative ring.') raise ValueError( 'The base must be a commutative ring or its spectrum.') if not category: from sage.categories.schemes import Schemes category = Schemes(base_spec) EXAMPLES:: sage: A = AffineSpace(4, QQ) sage: A.structure_morphism()._repr_() 'Scheme morphism:\n  From: Affine Space of dimension 4 over Rational Field\n  To:   Spectrum of Rational Field\n  Defn: Structure map' sage: print A.structure_morphism()._repr_() Scheme morphism: From: Affine Space of dimension 4 over Rational Field To:   Spectrum of Rational Field Defn: Structure map """ s = 'Set of morphisms' s += '\n  From: %s' % self.domain() INPUT: - x -- a ring morphism, or a list or tuple of that define a - x -- a ring morphism, or a list or a tuple that define a ring morphism. - check -- boolean (default: True) passed onto functions called by this to be more careful about input argument type checking functions called by this one to be more careful about input argument type checking. EXAMPLES:: def value_ring(self): """ Returns R for a point homset X(Spec(R)) Return R for a point homset X(Spec(R)). OUTPUT: Rational Field """ dom = self.domain() assert is_Spec(dom) if not is_Spec(dom): raise ValueError("value rings are defined for Spec domains only!") return dom.coordinate_ring() sage: SchemeHomset_points_affine(Spec(QQ), AffineSpace(ZZ,2)) Set of rational points of Affine Space of dimension 2 over Rational Field """ def points(self, B=0): r""" Return some or all rational points of an affine scheme. INPUT: - B -- integer (optional, default=0). The bound for the - B -- integer (optional, default: 0). The bound for the height of the coordinates. OUTPUT: - If the base ring is a finite field: All points of the scheme, - If the base ring is a finite field: all points of the scheme, given by coordinate tuples. - If the base ring is \QQ or \ZZ: the subset of points whose sage: Hom.base_extend(QQ) Traceback (most recent call last): ... NotImplementedError: Abelian variety point sets not NotImplementedError: Abelian variety point sets are not implemented as modules over rings other than ZZ. """ if not R is ZZ: raise NotImplementedError('Abelian variety point sets not implemented ' 'as modules over rings other than ZZ.') if R is not ZZ: raise NotImplementedError('Abelian variety point sets are not ' 'implemented as modules over rings other than ZZ.') return self
• ## sage/schemes/generic/morphism.py

diff --git a/sage/schemes/generic/morphism.py b/sage/schemes/generic/morphism.py
 a all schemes. If you want to extend the Sage library with some new kind of scheme, your new class (say, myscheme) should provide a methods your new class (say, myscheme) should provide a method * myscheme._morphism_class(*args, **kwds) return a morphism between to schemes in your category, usually defined via polynomials. Your point class should derive from :class:SchemeMorphism_polynomial. They will usually be elements of the hom set * myscheme._morphism_class(*args, **kwds) returning a morphism between two schemes in your category, usually defined via polynomials. Your morphism class should derive from :class:SchemeMorphism_polynomial. These morphisms will usually be elements of the hom set :class:~sage.schemes.generic.homset.SchemeHomset_generic. Optionally, you can also provide a special hom set for your Optionally, you can also provide a special hom set class for your subcategory of schemes. If you want to do this, you should also provide a method * myscheme._homset_class(*args, **kwds) (optional) return the homset, which must be a derived class of * myscheme._homset_class(*args, **kwds) returning a homset, which must be an element of a derived class of class:~sage.schemes.generic.homset.SchemeHomset_generic. If your new homset class does not use myscheme._morphism_class then you do not have to provide it. typically use a different notation, so they are implemented in a different derived class. For this, you should implement a method * myscheme._point_class(*args, **kwds) return a point, that is, morphism Spec(K)\to X. Your point class should derive from * myscheme._point_class(*args, **kwds) returning a point, that is, a morphism Spec(K)\to X. Your point class should derive from :class:SchemeMorphism_point. Optionally, you can also provide a special hom set for the points, for example the point hom set can provide a method to enumerate all points. If you want to do this, you should also provide a method * myscheme._point_homset_class(*args, **kwds) (optional) return * myscheme._point_homset_class(*args, **kwds) returning the :mod:~sage.schemes.generic.homset of points. The hom sets of points are implemented in classes named SchemeHomset_points_.... If your new homset class does not use myscheme._point_class then # * _homset_class -> _point_homset_class #***************************************************************************** #  Copyright (C) 2006 David Kohel #  Copyright (C) 2006 William Stein #       Copyright (C) 2011 Volker Braun #       Copyright (C) 2006 David Kohel #       Copyright (C) 2006 William Stein # #  Distributed under the terms of the GNU General Public License (GPL) #  as published by the Free Software Foundation; either version 2 of #  the License, or (at your option) any later version. #                  http://www.gnu.org/licenses/ #***************************************************************************** from sage.rings.infinity import infinity from sage.structure.element   import AdditiveGroupElement, RingElement, Element, generic_power from sage.structure.sequence  import Sequence def _repr_defn(self): r""" Return a string representation of the type of self. Return a string representation of the definition of self. OUTPUT: sage: phi = R.hom([QQ(7)]) sage: X = Spec(QQ); Y = Spec(R) sage: f = X.hom(phi) sage: f._repr_type() 'Affine Scheme' sage: print f._repr_defn() Ring morphism: From: Univariate Polynomial Ring in x over Rational Field To:   Rational Field Defn: x |--> 7 """ return repr(self.ring_homomorphism()) sage: f = H([exp(x),exp(y)]) Traceback (most recent call last): ... TypeError: polys (=[e^x, e^y]) must be elements of Multivariate Polynomial Ring in x, y over Rational Field TypeError: polys (=[e^x, e^y]) must be elements of Multivariate Polynomial Ring in x, y over Rational Field """ def __init__(self, parent, polys, check=True): """
• ## sage/schemes/generic/scheme.py

diff --git a/sage/schemes/generic/scheme.py b/sage/schemes/generic/scheme.py
diff --git a/sage/schemes/generic/toric_morphism.py b/sage/schemes/generic/toric_morphism.py
 a The toric morphisms are perhaps the most mysterious at the beginning. Let us quickly review their definition (See Definition 3.3.3 of [CLS]_). Let \Sigma_1 a fan in N_{1,\RR} and \Sigma_2 a 3.3.3 of [CLS]_). Let \Sigma_1 be a fan in N_{1,\RR} and \Sigma_2 be a fan in N_{2,\RR}. A morphism \phi: X_{\Sigma_1} \to X_{\Sigma_2} of the associated toric varieties is toric if \phi maps the maximal torus T_{N_1} \subseteq X_{\Sigma_1} into T_{N_2} \subseteq [0 : u^2 + v^2 : u*v] This is a well-defined morphism of algebraic varieties because homogeneously rescaled points of \mathbb{P}^1 map to the same point in \mathbb{P}^2 up to its homogeneous rescalings. It is not homogeneously rescaled coordinates of a point of \mathbb{P}^1 map to the same point in \mathbb{P}^2 up to its homogeneous rescalings. It is not equivariant with respect to the torus actions .. math:: \CC^\times \times \mathbb{P}^1, (\mu,[u:v]) \mapsto [u:\mu v] ,\quad \CC^\times \times \mathbb{P}^2, (\alpha,\beta,[x:y:z]) \mapsto [x:\alpha y:\beta z] \quad\text{and}\quad \left(\CC^\times\right)^2 \times \mathbb{P}^2, ((\alpha,\beta),[x:y:z]) \mapsto [x:\alpha y:\beta z] , though. Hence it is not a toric morphism. Clearly, the problem is that hence it is not a toric morphism. Clearly, the problem is that the map in homogeneous coordinates contains summands that transform differently under the torus action. However, this is not the only difficulty. For example, consider :: Defn: Defined by sending the Rational polyhedral fan in 1-d lattice N to Rational polyhedral fan in 2-d lattice N. The fan morphism map is equivalent to the polynomial map:: The fan morphism map is equivalent to the following polynomial map:: sage: _.as_polynomial_map() Scheme morphism: [u : v : v] Finally, here is an example of a fan morphism that cannot be written with homogeneous polynomials. Consider the blowup O_{\mathbb{P}^1}(2) using homogeneous polynomials. Consider the blowup O_{\mathbb{P}^1}(2) \to \CC^2/\ZZ_2. In terms of toric data, this blowup is:: sage: A2_Z2 = toric_varieties.A2_Z2() OUTPUT: A :class:SchemeMorphism_polynomial_toric_variety. Raises a TypeError if the morphism cannot be written in terms of homogeneous polynomials. TypeError if the morphism cannot be written in such a way. EXAMPLES:: sage: patch.as_fan_morphism() Traceback (most recent call last): ... NotImplementedError NotImplementedError: expressing toric morphisms as fan morphisms is not implemented yet! """ raise NotImplementedError raise NotImplementedError("expressing toric morphisms as fan " "morphisms is not implemented yet!") ############################################################################
diff --git a/sage/schemes/generic/toric_variety.py b/sage/schemes/generic/toric_variety.py
 a True Note that by homogeneous, we mean well-defined with respect to the homogeneous rescalings. So a polynomial that you would the homogeneous rescalings of self`. So a polynomial that you would usually not call homogeneous can be homogeneous if there are no homogeneous rescalings, for example::