コード例 #1
0
    def __init__(self, X, category=None):
        """
        A scheme.
        
        TESTS::
        
            sage: R.<x, y> = QQ[]
            sage: I = (x^2 - y^2)*R
            sage: RmodI = R.quotient(I)
            sage: X = Spec(RmodI)
            sage: TestSuite(X).run(skip = ["_test_an_element", "_test_elements", "_test_some_elements", "_test_category"]) # See #7946

        A scheme is in the category of all schemes over the base scheme of self::

            sage: ProjectiveSpace(4, QQ).category()
            Category of schemes over Spectrum of Rational Field
        """
        if spec.is_Spec(X):
            self._base_ring = X.coordinate_ring()
            base = self._base_ring
        else:
            self._base_scheme = X
            base = self._base_scheme

        from sage.categories.schemes import Schemes
        default_category = Schemes(self.base_scheme())
        if category is None:
            category = default_category
        else:
            assert category.is_subcategory(
                default_category), "%s is not a subcategory of %s" % (
                    category, default_category)

        Parent.__init__(self, base, category=category)
コード例 #2
0
    def __init__(self, X=None, category=None):
        """
        Construct a scheme.

        TESTS:

        The full test suite works since :trac:`7946`::

            sage: R.<x, y> = QQ[]
            sage: I = (x^2 - y^2)*R
            sage: RmodI = R.quotient(I)
            sage: X = Spec(RmodI)
            sage: TestSuite(X).run()

        """
        from sage.schemes.generic.morphism import is_SchemeMorphism
        from sage.categories.map import Map
        from sage.categories.all import Rings

        if X is None:
            self._base_ring = ZZ
        elif is_Scheme(X):
            self._base_scheme = X
        elif is_SchemeMorphism(X):
            self._base_morphism = X
        elif isinstance(X, CommutativeRing):
            self._base_ring = X
        elif isinstance(X, Map) and X.category_for().is_subcategory(Rings()):
            # X is a morphism of Rings
            self._base_ring = X.codomain()
        else:
            raise ValueError('The base must be define by a scheme, '
                             'scheme morphism, or commutative ring.')

        from sage.categories.schemes import Schemes
        if X is None:
            default_category = Schemes()
        else:
            default_category = Schemes(self.base_scheme())
        if category is None:
            category = default_category
        else:
            assert category.is_subcategory(default_category), \
                "%s is not a subcategory of %s"%(category, default_category)

        Parent.__init__(self, self.base_ring(), category=category)
コード例 #3
0
ファイル: scheme.py プロジェクト: shrutig/sage
    def __init__(self, X=None, category=None):
        """
        Construct a scheme.

        TESTS::

            sage: R.<x, y> = QQ[]
            sage: I = (x^2 - y^2)*R
            sage: RmodI = R.quotient(I)
            sage: X = Spec(RmodI)
            sage: TestSuite(X).run(skip = ["_test_an_element", "_test_elements",
            ...                            "_test_some_elements", "_test_category"]) # See #7946
        """
        from sage.schemes.generic.spec import is_Spec
        from sage.schemes.generic.morphism import is_SchemeMorphism

        if X is None:
            try:
                from sage.schemes.generic.spec import SpecZ
                self._base_scheme = SpecZ
            except ImportError:  # we are currently constructing SpecZ
                self._base_ring = ZZ
        elif is_Scheme(X):
            self._base_scheme = X
        elif is_SchemeMorphism(X):
            self._base_morphism = X
        elif is_CommutativeRing(X):
            self._base_ring = X
        elif is_RingHomomorphism(X):
            self._base_ring = X.codomain()
        else:
            raise ValueError('The base must be define by a scheme, '
                             'scheme morphism, or commutative ring.')

        from sage.categories.schemes import Schemes
        if not X:
            default_category = Schemes()
        else:
            default_category = Schemes(self.base_scheme())
        if category is None:
            category = default_category
        else:
            assert category.is_subcategory(default_category), \
                "%s is not a subcategory of %s"%(category, default_category)

        Parent.__init__(self, self.base_ring(), category=category)
コード例 #4
0
ファイル: homset.py プロジェクト: thalespaiva/sagelib
    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
コード例 #5
0
    def __init__(self, n, R=ZZ):
        """
        TEST::

            sage: from sage.schemes.generic.ambient_space import AmbientSpace
            sage: A = AmbientSpace(5, ZZ)
            sage: TestSuite(A).run() # not tested (abstract scheme with no elements?)
        """
        if not is_CommutativeRing(R):
            raise TypeError, "R (=%s) must be a commutative ring" % R
        n = Integer(n)
        if n < 0:
            raise ValueError, "n (=%s) must be nonnegative" % n
        self.__n = n
        self._base_ring = R
        # NT: this seems to set improperly self._base_scheme to X instead of Spec(X)????
        # scheme.Scheme.__init__(self, R)
        # This should be cleaned up by someone who knows about schemes (not me!)
        from sage.categories.schemes import Schemes
        Parent.__init__(self, R, category=Schemes(self.base_scheme()))
コード例 #6
0
ファイル: scheme.py プロジェクト: shalec/sage
    def base_morphism(self):
        """
        Return the structure morphism from ``self`` to its base
        scheme.

        OUTPUT:

        A scheme morphism.

        EXAMPLES::

            sage: A = AffineSpace(4, QQ)
            sage: A.base_morphism()
            Scheme morphism:
              From: Affine Space of dimension 4 over Rational Field
              To:   Spectrum of Rational Field
              Defn: Structure map

            sage: X = Spec(QQ)
            sage: X.base_morphism()
            Scheme morphism:
              From: Spectrum of Rational Field
              To:   Spectrum of Integer Ring
              Defn: Structure map
        """
        try:
            return self._base_morphism
        except AttributeError:
            from sage.categories.schemes import Schemes
            from sage.schemes.generic.spec import SpecZ
            SCH = Schemes()
            if hasattr(self, '_base_scheme'):
                self._base_morphism = self.Hom(self._base_scheme,
                                               category=SCH).natural_map()
            elif hasattr(self, '_base_ring'):
                self._base_morphism = self.Hom(AffineScheme(self._base_ring),
                                               category=SCH).natural_map()
            else:
                self._base_morphism = self.Hom(SpecZ,
                                               category=SCH).natural_map()
            return self._base_morphism