def value_ring(self): """ Returns S for a homset X(T) where T = Spec(S). """ T = self.domain() if is_Spec(T): return T.coordinate_ring() else: raise TypeError("Domain of argument must be of the form Spec(S).")
def create_key_and_extra_args(self, X, Y, category=None, base=ZZ, check=True): """ Create a key that uniquely determines the Hom-set. INPUT: - ``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``). EXAMPLES:: sage: A2 = AffineSpace(QQ,2) sage: A3 = AffineSpace(QQ,3) sage: A3.Hom(A2) # indirect doctest Set of morphisms From: Affine Space of dimension 3 over Rational Field To: Affine Space of dimension 2 over Rational Field sage: from sage.schemes.generic.homset import SchemeHomsetFactory sage: SHOMfactory = SchemeHomsetFactory('test') sage: key, extra = SHOMfactory.create_key_and_extra_args(A3,A2,check=False) sage: key (..., ..., Category of schemes over Integer Ring) sage: extra {'Y': Affine Space of dimension 2 over Rational Field, 'X': Affine Space of dimension 3 over Rational Field, 'base_ring': Integer Ring, 'check': False} """ if not is_Scheme(X) and is_CommutativeRing(X): X = Spec(X) if not is_Scheme(Y) and is_CommutativeRing(Y): Y = Spec(Y) if is_Spec(base): base_spec = base base_ring = base.coordinate_ring() elif is_CommutativeRing(base): base_spec = Spec(base) base_ring = base else: 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) key = tuple([id(X), id(Y), category]) extra = {'X':X, 'Y':Y, 'base_ring':base_ring, 'check':check} return key, extra
def _repr_object_names(self): """ EXAMPLES:: sage: Schemes(Spec(ZZ)) # indirect doctest Category of schemes over Integer Ring """ # To work around the name of the class (schemes_over_base) from sage.schemes.generic.spec import is_Spec if is_Spec(self.base_scheme()): return "schemes over %s" % self.base_scheme().coordinate_ring() else: return "schemes over %s" % self.base_scheme()
def create_object(self, version, key, **extra_args): """ Create a :class:`SchemeHomset_generic`. INPUT: - ``version`` -- object version. Currently not used. - ``key`` -- a key created by :meth:`create_key_and_extra_args`. - ``extra_args`` -- a dictionary of extra keyword arguments. EXAMPLES:: sage: A2 = AffineSpace(QQ,2) sage: A3 = AffineSpace(QQ,3) sage: A3.Hom(A2) is A3.Hom(A2) # indirect doctest True sage: from sage.schemes.generic.homset import SchemeHomsetFactory sage: SHOMfactory = SchemeHomsetFactory('test') sage: SHOMfactory.create_object(0, [id(A3),id(A2),A3.category()], check=True, ... X=A3, Y=A2, base_ring=QQ) Set of morphisms From: Affine Space of dimension 3 over Rational Field To: Affine Space of dimension 2 over Rational Field """ category = key[2] X = extra_args.pop('X') Y = extra_args.pop('Y') base_ring = extra_args.pop('base_ring') if is_Spec(X): return Y._point_homset(X, Y, category=category, base=base_ring, **extra_args) try: return X._homset(X, Y, category=category, base=base_ring, **extra_args) except AttributeError: return SchemeHomset_generic(X, Y, category=category, base=base_ring, **extra_args)
def __init__(self, X, Y, category=None, check=True, base=ZZ): """ Python constructor. INPUT: See :class:`SchemeHomset_generic`. EXAMPLES:: sage: from sage.schemes.generic.homset import SchemeHomset_points sage: SchemeHomset_points(Spec(QQ), AffineSpace(ZZ,2)) Set of rational points of Affine Space of dimension 2 over Rational Field """ if check and not is_Spec(X): raise ValueError('The domain must be an affine scheme.') SchemeHomset_generic.__init__(self, X, Y, category=category, check=check, base=base)
def value_ring(self): """ Return `R` for a point Hom-set `X(Spec(R))`. OUTPUT: A commutative ring. EXAMPLES:: sage: P2 = ProjectiveSpace(ZZ,2) sage: P2(QQ).value_ring() Rational Field """ dom = self.domain() if not is_Spec(dom): raise ValueError("value rings are defined for Spec domains only!") return dom.coordinate_ring()
def natural_map(self): r""" Return a natural map in the Hom space. OUTPUT: A :class:`SchemeMorphism` if there is a natural map from domain to codomain. Otherwise, a ``NotImplementedError`` is raised. EXAMPLES:: sage: A = AffineSpace(4, QQ) sage: A.structure_morphism() # indirect doctest Scheme morphism: From: Affine Space of dimension 4 over Rational Field To: Spectrum of Rational Field Defn: Structure map """ X = self.domain() Y = self.codomain() if is_Spec(Y) and Y.coordinate_ring() == X.base_ring(): return SchemeMorphism_structure_map(self) raise NotImplementedError