Ticket #12892: trac_12892_orbit_closure_morphism.patch

File trac_12892_orbit_closure_morphism.patch, 11.2 KB (added by Volker Braun, 11 years ago)

Updated patch

  • sage/schemes/toric/morphism.py

    # HG changeset patch
    # User Volker Braun <vbraun@stp.dias.ie>
    # Date 1338160202 25200
    # Node ID d5be015ca434de4a48d2bf4a779b2f1faa5496e2
    # Parent  daae3bf2ee84b57d5f1a57f5001562772cc7580b
    Trac #12892: Toric fibration morphisms
    
    This patch implements the embedding of a toric orbit
    closure as a scheme morphism.
    
    diff --git a/sage/schemes/toric/morphism.py b/sage/schemes/toric/morphism.py
    a b  
    167167    is_SchemeMorphism,
    168168    SchemeMorphism, SchemeMorphism_point, SchemeMorphism_polynomial
    169169)
    170 
     170from sage.misc.cachefunc import cached_method
    171171
    172172
    173173############################################################################
     
    338338
    339339       
    340340############################################################################
     341# The embedding morphism of an orbit closure
     342class SchemeMorphism_orbit_closure_toric_variety(SchemeMorphism):
     343    """
     344    The embedding of an orbit closure.
     345
     346    INPUT:
     347
     348    - ``parent`` -- the parent homset.
     349
     350    - ``defining_cone`` -- the defining cone.
     351
     352    - ``ray_map`` -- a dictionary ``{ambient ray generator: orbit ray
     353      generator}``. Note that the image of the ambient ray generator
     354      is not necessarily primitive.
     355
     356    .. WARNING::
     357
     358        You should not create objects of this class directly. Use the
     359        :meth:`~sage.schemes.generic.toric_variety.ToricVariety_field.orbit_closure`
     360        method of :class:`toric varieties
     361        <sage.schemes.generic.toric_variety.ToricVariety_field>`
     362        instead.
     363
     364    EXAMPLES::
     365
     366        sage: P1xP1 = toric_varieties.P1xP1()
     367        sage: H = P1xP1.fan(1)[0]
     368        sage: V = P1xP1.orbit_closure(H)
     369        sage: V.embedding_morphism()
     370        Scheme morphism:
     371          From: 1-d toric variety covered by 2 affine patches
     372          To:   2-d CPR-Fano toric variety covered by 4 affine patches
     373          Defn: Defined by embedding the torus closure associated to the 1-d
     374                cone of Rational polyhedral fan in 2-d lattice N.
     375
     376    TESTS::
     377   
     378        sage: V.embedding_morphism()._reverse_ray_map()
     379        {N(-1): 3, N(1): 2}
     380        sage: V.embedding_morphism()._defining_cone
     381        1-d cone of Rational polyhedral fan in 2-d lattice N
     382    """
     383    def __init__(self, parent, defining_cone, ray_map):
     384        """
     385        The Python constructor.
     386
     387        EXAMPLES::
     388
     389            sage: P2 = toric_varieties.P2()
     390            sage: P1 = P2.orbit_closure(P2.fan(1)[0])
     391            sage: P1.embedding_morphism()
     392            Scheme morphism:
     393              From: 1-d toric variety covered by 2 affine patches
     394              To:   2-d CPR-Fano toric variety covered by 3 affine patches
     395              Defn: Defined by embedding the torus closure associated to the 1-d cone
     396                    of Rational polyhedral fan in 2-d lattice N.
     397        """
     398        SchemeMorphism.__init__(self, parent)
     399        self._defining_cone = defining_cone
     400        self._ray_map = ray_map
     401
     402    def defining_cone(self):
     403        r"""
     404        Return the cone corresponding to the torus orbit.
     405       
     406        OUTPUT:
     407       
     408        A cone of the fan of the ambient toric variety.
     409       
     410        EXAMPLES::
     411
     412            sage: P2 = toric_varieties.P2()
     413            sage: cone = P2.fan(1)[0]
     414            sage: P1 = P2.orbit_closure(cone)
     415            sage: P1.embedding_morphism().defining_cone()
     416            1-d cone of Rational polyhedral fan in 2-d lattice N
     417            sage: _ is cone
     418            True
     419        """
     420        return self._defining_cone
     421
     422    @cached_method
     423    def _reverse_ray_map(self):
     424        """
     425        Reverse ``self._ray_map``.
     426
     427        OUTPUT:
     428
     429        Return a dictionary `{orbit ray generator : preimage ray
     430        index}`. Note that the orbit ray generator need not be
     431        primitive. Also, the preimage ray is not necessarily unique.
     432
     433        EXAMPLES::
     434
     435            sage: P2_112 = toric_varieties.P2_112()
     436            sage: P1 = P2_112.orbit_closure(Cone([(1,0)]))
     437            sage: f = P1.embedding_morphism()
     438            sage: f._ray_map
     439            {N(0, 1): (1), N(1, 0): (0), N(-1, -2): (-2)}
     440            sage: f._reverse_ray_map()
     441            {N(-2): 2, N(1): 1}
     442        """
     443        orbit = self.parent().domain()
     444        codomain_fan = self.parent().codomain().fan()
     445        reverse_ray_dict = dict()
     446        defining_cone_indices = []
     447        for n1,n2 in self._ray_map.iteritems():
     448            ray_index = codomain_fan.rays().index(n1)
     449            if n2.is_zero():
     450                assert ray_index in self._defining_cone.ambient_ray_indices()
     451                continue
     452            n2 = orbit.fan().lattice()(n2)
     453            n2.set_immutable()
     454            reverse_ray_dict[n2] = ray_index
     455        return reverse_ray_dict
     456
     457    def _repr_defn(self):
     458        """
     459        Return a string representation of the definition of ``self``.
     460
     461        OUTPUT:
     462
     463        String.
     464
     465        EXAMPLES::
     466
     467            sage: P2 = toric_varieties.P2()
     468            sage: V = P2.orbit_closure(P2.fan(1)[0]);  V
     469            1-d toric variety covered by 2 affine patches
     470            sage: V.embedding_morphism()._repr_defn()
     471            'Defined by embedding the torus closure associated to the 1-d cone of
     472             Rational polyhedral fan in 2-d lattice N.'
     473        """
     474        s  = 'Defined by embedding the torus closure associated to the '
     475        s += str(self._defining_cone)
     476        s += '.'
     477        return s
     478
     479    def as_polynomial_map(self):
     480        """
     481        Express the morphism via homogeneous polynomials.
     482
     483        OUTPUT:
     484
     485        A :class:`SchemeMorphism_polynomial_toric_variety`. Raises a
     486        ``TypeError`` if the morphism cannot be written in terms of
     487        homogeneous polynomials.
     488
     489        The defining polynomials are not necessarily unique. There are
     490        choices if multiple ambient space ray generators project to
     491        the same orbit ray generator, and one such choice is made
     492        implicitly. The orbit embedding can be written as a polynomial
     493        map if and only if each primitive orbit ray generator is the
     494        image of at least one primitive ray generator of the ambient
     495        toric variety.
     496       
     497        EXAMPLES::
     498
     499            sage: P2 = toric_varieties.P2()
     500            sage: V = P2.orbit_closure(P2.fan(1)[0]);  V
     501            1-d toric variety covered by 2 affine patches
     502            sage: V.embedding_morphism().as_polynomial_map()
     503            Scheme morphism:
     504              From: 1-d toric variety covered by 2 affine patches
     505              To:   2-d CPR-Fano toric variety covered by 3 affine patches
     506              Defn: Defined on coordinates by sending [z0 : z1] to
     507                    [0 : z1 : z0]
     508
     509        If the toric variety is singular, then some orbit closure
     510        embeddings cannot be written with homogeneous polynomials::
     511
     512            sage: P2_112 = toric_varieties.P2_112()
     513            sage: P1 = P2_112.orbit_closure(Cone([(1,0)]))
     514            sage: P1.embedding_morphism().as_polynomial_map()
     515            Traceback (most recent call last):
     516            ...
     517            TypeError: The embedding cannot be written with homogeneous polynomials.
     518        """
     519        orbit = self.domain()
     520        codomain_fan = self.codomain().fan()
     521        R = orbit.coordinate_ring()
     522        polys = [ R.one() ] * codomain_fan.nrays()
     523        for i in self._defining_cone.ambient_ray_indices():
     524            polys[i] = R.zero()
     525        ray_index_map = self._reverse_ray_map()
     526        for i, ray in enumerate(orbit.fan().rays()):
     527            try:
     528                ray_index = ray_index_map[ray]
     529            except KeyError:
     530                raise TypeError('The embedding cannot be written with homogeneous polynomials.')
     531            polys[ray_index] = R.gen(i)
     532        return SchemeMorphism_polynomial_toric_variety(self.parent(), polys)
     533       
     534
     535############################################################################
    341536# A morphism of toric varieties determined by a fan morphism
    342537class SchemeMorphism_fan_toric_variety(SchemeMorphism):
    343538    """
  • sage/schemes/toric/variety.py

    diff --git a/sage/schemes/toric/variety.py b/sage/schemes/toric/variety.py
    a b  
    26082608        patch_cover = AffineSpace(R)
    26092609        patch = patch_cover.subscheme(I)
    26102610        return patch
    2611 
    26122611   
    26132612    def _orbit_closure_projection(self, cone, x):
    26142613        r"""
     
    26382637       
    26392638            Due to incomplete support of quotient lattices (as of 12-07-2011),
    26402639            this function actually operates with a generic toric lattice of the
    2641             same dimension as the qppropriate quotient lattice. This behaviour
     2640            same dimension as the appropriate quotient lattice. This behaviour
    26422641            is likely to change in the future releases of Sage.
    26432642   
    26442643        EXAMPLES::
     
    26532652        cone = self.fan().embed(cone)
    26542653        quot = cone.sublattice_quotient()
    26552654        if x in cone.lattice():
    2656             return vector(quot(x))
     2655            result = vector(ZZ, quot(x))
     2656            result.set_immutable()
     2657            return result
    26572658
    26582659        assert is_Cone(x)
    26592660        rays = [ vector(quot(r)) for r in x.rays() ]
     
    26652666        #assert is_Cone(x)
    26662667        #return Cone(x.rays(), lattice=quot)
    26672668
    2668 
    26692669    def orbit_closure(self, cone):
    26702670        r"""
    26712671        Return the orbit closure of ``cone``.
     
    26952695
    26962696            sage: P1xP1 = toric_varieties.P1xP1()
    26972697            sage: H = P1xP1.fan(1)[0]
    2698             sage: P1xP1.orbit_closure(H)
     2698            sage: V = P1xP1.orbit_closure(H);  V
    26992699            1-d toric variety covered by 2 affine patches
     2700            sage: V.embedding_morphism()
     2701            Scheme morphism:
     2702              From: 1-d toric variety covered by 2 affine patches
     2703              To:   2-d CPR-Fano toric variety covered by 4 affine patches
     2704              Defn: Defined by embedding the torus closure associated to the 1-d
     2705                    cone of Rational polyhedral fan in 2-d lattice N.
     2706            sage: V.embedding_morphism().as_polynomial_map()
     2707            Scheme morphism:
     2708              From: 1-d toric variety covered by 2 affine patches
     2709              To:   2-d CPR-Fano toric variety covered by 4 affine patches
     2710              Defn: Defined on coordinates by sending [z0 : z1] to
     2711                    [0 : 1 : z1 : z0]
    27002712        """
    27012713        cone = self.fan().embed(cone)
    27022714        cones = []
    27032715        for star_cone in cone.star_generators():
    27042716            cones.append( self._orbit_closure_projection(cone, star_cone) )
    27052717        from sage.geometry.fan import discard_faces
    2706         return ToricVariety(Fan(discard_faces(cones), check=False))
    2707 
    2708 
     2718        fan = Fan(discard_faces(cones), check=False)
     2719        orbit_closure = ToricVariety(fan)
     2720
     2721        star_rays = set()
     2722        for star_cone in cone.star_generators():
     2723            star_rays.update(star_cone.rays())
     2724        ray_map = dict( (ray, self._orbit_closure_projection(cone, ray)) for ray in star_rays)
     2725        from sage.schemes.toric.morphism import SchemeMorphism_orbit_closure_toric_variety
     2726        orbit_closure._embedding_morphism = \
     2727            SchemeMorphism_orbit_closure_toric_variety(orbit_closure.Hom(self), cone, ray_map)
     2728
     2729        return orbit_closure
    27092730
    27102731
    27112732def normalize_names(names=None, ngens=None, prefix=None, indices=None,