Toric varieties - Schemes

Skip to content
Back to top
View this page
Edit this page

# Toric varieties

This module provides support for (normal) toric varieties, corresponding to `rational polyhedral fans`. See also `fano_variety` for a more restrictive class of (weak) Fano toric varieties.

An excellent reference on toric varieties is the book “Toric Varieties” by David A. Cox, John B. Little, and Hal Schenck [CLS2011].

The interface to this module is provided through functions `AffineToricVariety()` and `ToricVariety()`, although you may also be interested in `normalize_names()`.

Note

We do NOT build “general toric varieties” from affine toric varieties. Instead, we are using the quotient representation of toric varieties with the homogeneous coordinate ring (a.k.a. Cox’s ring or the total coordinate ring). This description works best for simplicial fans of the full dimension.

AUTHORS:

- Andrey Novoseltsev (2010-05-17): initial version.

- Volker Braun (2010-07-24): Cohomology and characteristic classes added.

EXAMPLES:

We start with constructing the affine plane as an affine toric variety. First, we need to have a corresponding cone:

Sage

    sage: quadrant = Cone([(1,0), (0,1)])

Python

    >>> from sage.all import *
    >>> quadrant = Cone([(Integer(1),Integer(0)), (Integer(0),Integer(1))])

If you don’t care about variable names and the base field, that’s all we need for now:

Sage

    sage: A2 = AffineToricVariety(quadrant)
    sage: A2
    2-d affine toric variety
    sage: origin = A2(0,0)
    sage: origin
    [0 : 0]

[Python]

    >>> from sage.all import *
    >>> A2 = AffineToricVariety(quadrant)
    >>> A2
    2-d affine toric variety
    >>> origin = A2(Integer(0),Integer(0))
    >>> origin
    [0 : 0]

Only affine toric varieties have points whose (homogeneous) coordinates are all zero.

Sage

    sage: parent(origin)
    Set of rational points of 2-d affine toric variety

Python

    >>> from sage.all import *
    >>> parent(origin)
    Set of rational points of 2-d affine toric variety

As you can see, by default toric varieties live over the field of rational numbers:

Sage

    sage: A2.base_ring()
    Rational Field

[Python]

    >>> from sage.all import *
    >>> A2.base_ring()
    Rational Field

While usually toric varieties are considered over the field of complex numbers, for computational purposes it is more convenient to work with fields that have exact representation on computers. You can also always do

Sage

    sage: C2 = AffineToricVariety(quadrant, base_field=CC)
    sage: C2.base_ring()
    Complex Field with 53 bits of precision
    sage: C2(1, 2+i)                                                                    # needs sage.symbolic
    [1.00000000000000 : 2.00000000000000 + 1.00000000000000*I]

Python

    >>> from sage.all import *
    >>> C2 = AffineToricVariety(quadrant, base_field=CC)
    >>> C2.base_ring()
    Complex Field with 53 bits of precision
    >>> C2(Integer(1), Integer(2)+i)                                                                    # needs sage.symbolic
    [1.00000000000000 : 2.00000000000000 + 1.00000000000000*I]

or even

Sage

    sage: F = CC["a, b"].fraction_field()
    sage: F.inject_variables()
    Defining a, b
    sage: A2 = AffineToricVariety(quadrant, base_field=F)
    sage: A2(a,b)
    [a : b]

[Python]

    >>> from sage.all import *
    >>> F = CC["a, b"].fraction_field()
    >>> F.inject_variables()
    Defining a, b
    >>> A2 = AffineToricVariety(quadrant, base_field=F)
    >>> A2(a,b)
    [a : b]

OK, if you need to work only with affine spaces, `AffineSpace()` may be a better way to construct them. Our next example is the product of two projective lines realized as the toric variety associated to the `face fan` of the “diamond”:

Sage

    sage: diamond = lattice_polytope.cross_polytope(2)
    sage: diamond.vertices()
    M( 1,  0),        M( 0,  1),
    M(-1,  0),        M( 0, -1)
    in 2-d lattice M
    sage: fan = FaceFan(diamond)
    sage: P1xP1 = ToricVariety(fan)
    sage: P1xP1
    2-d toric variety covered by 4 affine patches
    sage: P1xP1.fan().rays()
    M( 1,  0),        M( 0,  1),
    M(-1,  0),        M( 0, -1)
    in 2-d lattice M
    sage: P1xP1.gens()
    (z0, z1, z2, z3)

Python

    >>> from sage.all import *
    >>> diamond = lattice_polytope.cross_polytope(Integer(2))
    >>> diamond.vertices()
    M( 1,  0),        M( 0,  1),
    M(-1,  0),        M( 0, -1)
    in 2-d lattice M
    >>> fan = FaceFan(diamond)
    >>> P1xP1 = ToricVariety(fan)
    >>> P1xP1
    2-d toric variety covered by 4 affine patches
    >>> P1xP1.fan().rays()
    M( 1,  0),        M( 0,  1),
    M(-1,  0),        M( 0, -1)
    in 2-d lattice M
    >>> P1xP1.gens()
    (z0, z1, z2, z3)

We got four coordinates - two for each of the projective lines, but their names are perhaps not very well chosen. Let’s make \((x,y)\) to be coordinates on the first line and \((s,t)\) on the second one:

Sage

    sage: P1xP1 = ToricVariety(fan, coordinate_names="x s y t")
    sage: P1xP1.gens()
    (x, s, y, t)

[Python]

    >>> from sage.all import *
    >>> P1xP1 = ToricVariety(fan, coordinate_names="x s y t")
    >>> P1xP1.gens()
    (x, s, y, t)

Now, if we want to define subschemes of this variety, the defining polynomials must be homogeneous in each of these pairs:

Sage

    sage: P1xP1.inject_variables()
    Defining x, s, y, t
    sage: P1xP1.subscheme(x)
    Closed subscheme of 2-d toric variety covered by 4 affine patches defined by:
      x
    sage: P1xP1.subscheme(x^2 + y^2)
    Closed subscheme of 2-d toric variety covered by 4 affine patches defined by:
      x^2 + y^2
    sage: P1xP1.subscheme(x^2 + s^2)
    Traceback (most recent call last):
    ...
    ValueError: x^2 + s^2 is not homogeneous
    on 2-d toric variety covered by 4 affine patches
    sage: P1xP1.subscheme([x^2*s^2 + x*y*t^2 + y^2*t^2, s^3 + t^3])
    Closed subscheme of 2-d toric variety covered by 4 affine patches defined by:
      x^2*s^2 + x*y*t^2 + y^2*t^2,
      s^3 + t^3

Python

    >>> from sage.all import *
    >>> P1xP1.inject_variables()
    Defining x, s, y, t
    >>> P1xP1.subscheme(x)
    Closed subscheme of 2-d toric variety covered by 4 affine patches defined by:
      x
    >>> P1xP1.subscheme(x**Integer(2) + y**Integer(2))
    Closed subscheme of 2-d toric variety covered by 4 affine patches defined by:
      x^2 + y^2
    >>> P1xP1.subscheme(x**Integer(2) + s**Integer(2))
    Traceback (most recent call last):
    ...
    ValueError: x^2 + s^2 is not homogeneous
    on 2-d toric variety covered by 4 affine patches
    >>> P1xP1.subscheme([x**Integer(2)*s**Integer(2) + x*y*t**Integer(2) + y**Integer(2)*t**Integer(2), s**Integer(3) + t**Integer(3)])
    Closed subscheme of 2-d toric variety covered by 4 affine patches defined by:
      x^2*s^2 + x*y*t^2 + y^2*t^2,
      s^3 + t^3

While we don’t build toric varieties from affine toric varieties, we still can access the “building pieces”:

Sage

    sage: patch = P1xP1.affine_patch(2)
    sage: patch
    2-d affine toric variety
    sage: patch.fan().rays()
    M(1, 0),
    M(0, 1)
    in 2-d lattice M
    sage: patch.embedding_morphism()
    Scheme morphism:
      From: 2-d affine toric variety
      To:   2-d toric variety covered by 4 affine patches
      Defn: Defined on coordinates by sending [x : s] to [x : s : 1 : 1]

[Python]

    >>> from sage.all import *
    >>> patch = P1xP1.affine_patch(Integer(2))
    >>> patch
    2-d affine toric variety
    >>> patch.fan().rays()
    M(1, 0),
    M(0, 1)
    in 2-d lattice M
    >>> patch.embedding_morphism()
    Scheme morphism:
      From: 2-d affine toric variety
      To:   2-d toric variety covered by 4 affine patches
      Defn: Defined on coordinates by sending [x : s] to [x : s : 1 : 1]

The patch above was specifically chosen to coincide with our representation of the affine plane before, but you can get the other three patches as well. (While any cone of a fan will correspond to an affine toric variety, the main interest is usually in the generating fans as “the biggest” affine subvarieties, and these are precisely the patches that you can get from `affine_patch()`.)

All two-dimensional toric varieties are “quite nice” because any two-dimensional cone is generated by exactly two rays. From the point of view of the corresponding toric varieties, this means that they have at worst quotient singularities:

Sage

    sage: P1xP1.is_orbifold()
    True
    sage: P1xP1.is_smooth()
    True
    sage: TV = ToricVariety(NormalFan(diamond))
    sage: TV.fan().rays()
    N( 1,  1),        N( 1, -1),
    N(-1, -1),        N(-1,  1)
    in 2-d lattice N
    sage: TV.is_orbifold()
    True
    sage: TV.is_smooth()
    False

Python

    >>> from sage.all import *
    >>> P1xP1.is_orbifold()
    True
    >>> P1xP1.is_smooth()
    True
    >>> TV = ToricVariety(NormalFan(diamond))
    >>> TV.fan().rays()
    N( 1,  1),        N( 1, -1),
    N(-1, -1),        N(-1,  1)
    in 2-d lattice N
    >>> TV.is_orbifold()
    True
    >>> TV.is_smooth()
    False

In higher dimensions worse things can happen:

Sage

    sage: TV3 = ToricVariety(NormalFan(lattice_polytope.cross_polytope(3)))
    sage: TV3.fan().rays()
    N( 1, -1, -1),    N( 1,  1, -1),    N( 1,  1,  1),    N( 1, -1,  1),
    N(-1, -1,  1),    N(-1, -1, -1),    N(-1,  1, -1),    N(-1,  1,  1)
    in 3-d lattice N
    sage: TV3.is_orbifold()
    False

[Python]

    >>> from sage.all import *
    >>> TV3 = ToricVariety(NormalFan(lattice_polytope.cross_polytope(Integer(3))))
    >>> TV3.fan().rays()
    N( 1, -1, -1),    N( 1,  1, -1),    N( 1,  1,  1),    N( 1, -1,  1),
    N(-1, -1,  1),    N(-1, -1, -1),    N(-1,  1, -1),    N(-1,  1,  1)
    in 3-d lattice N
    >>> TV3.is_orbifold()
    False

Fortunately, we can perform a (partial) resolution:

Sage

    sage: TV3_res = TV3.resolve_to_orbifold()
    sage: TV3_res.is_orbifold()
    True
    sage: TV3_res.fan().ngenerating_cones()
    12
    sage: TV3.fan().ngenerating_cones()
    6

Python

    >>> from sage.all import *
    >>> TV3_res = TV3.resolve_to_orbifold()
    >>> TV3_res.is_orbifold()
    True
    >>> TV3_res.fan().ngenerating_cones()
    12
    >>> TV3.fan().ngenerating_cones()
    6

In this example we had to double the number of affine patches. The result is still singular:

Sage

    sage: TV3_res.is_smooth()
    False

[Python]

    >>> from sage.all import *
    >>> TV3_res.is_smooth()
    False

You can resolve it further using `resolve()` method, but (at least for now) you will have to specify which rays should be inserted into the fan. See also `CPRFanoToricVariety()`, which can construct some other “nice partial resolutions.”

The intersection theory on toric varieties is very well understood, and there are explicit algorithms to compute many quantities of interest. The most important tools are the `cohomology ring` and the `Chow group`. For \(d\)-dimensional compact toric varieties with at most orbifold singularities, the rational cohomology ring \(H^*(X,\QQ)\) and the rational Chow ring \(A^*(X,\QQ) = A_{d-*}(X)\otimes \QQ\) are isomorphic except for a doubling in degree. More precisely, the Chow group has the same rank

> \[A_{d-k}(X) \otimes \QQ \simeq H^{2k}(X,\QQ)\]

and the intersection in of Chow cycles matches the cup product in cohomology.

In this case, you should work with the cohomology ring description because it is much faster. For example, here is a weighted projective space with a curve of \(\ZZ_3\)-orbifold singularities:

Sage

    sage: P4_11133 = toric_varieties.P4_11133()
    sage: P4_11133.is_smooth(), P4_11133.is_orbifold()
    (False, True)
    sage: cone = P4_11133.fan(3)[9]
    sage: cone.is_smooth(), cone.is_simplicial()
    (False, True)
    sage: HH = P4_11133.cohomology_ring();  HH
    Rational cohomology ring of a 4-d CPR-Fano toric variety covered by 5 affine patches
    sage: P4_11133.cohomology_basis()                                                   # needs sage.libs.singular
    (([1],), ([z4],), ([z4^2],), ([z4^3],), ([z4^4],))

Python

    >>> from sage.all import *
    >>> P4_11133 = toric_varieties.P4_11133()
    >>> P4_11133.is_smooth(), P4_11133.is_orbifold()
    (False, True)
    >>> cone = P4_11133.fan(Integer(3))[Integer(9)]
    >>> cone.is_smooth(), cone.is_simplicial()
    (False, True)
    >>> HH = P4_11133.cohomology_ring();  HH
    Rational cohomology ring of a 4-d CPR-Fano toric variety covered by 5 affine patches
    >>> P4_11133.cohomology_basis()                                                   # needs sage.libs.singular
    (([1],), ([z4],), ([z4^2],), ([z4^3],), ([z4^4],))

Every cone defines a torus orbit closure, and hence a (co)homology class:

Sage

    sage: # needs sage.libs.singular
    sage: HH.gens()
    ([3*z4], [3*z4], [z4], [z4], [z4])
    sage: list(map(HH, P4_11133.fan(1)))
    [[3*z4], [3*z4], [z4], [z4], [z4]]
    sage: list(map(HH, P4_11133.fan(4)))
    [[9*z4^4], [9*z4^4], [9*z4^4], [9*z4^4], [9*z4^4]]
    sage: HH(cone)
    [3*z4^3]

[Python]

    >>> from sage.all import *
    >>> # needs sage.libs.singular
    >>> HH.gens()
    ([3*z4], [3*z4], [z4], [z4], [z4])
    >>> list(map(HH, P4_11133.fan(Integer(1))))
    [[3*z4], [3*z4], [z4], [z4], [z4]]
    >>> list(map(HH, P4_11133.fan(Integer(4))))
    [[9*z4^4], [9*z4^4], [9*z4^4], [9*z4^4], [9*z4^4]]
    >>> HH(cone)
    [3*z4^3]

We can compute intersection numbers by integrating top-dimensional cohomology classes:

Sage

    sage: # needs sage.libs.singular
    sage: D = P4_11133.divisor(0)
    sage: HH(D)
    [3*z4]
    sage: P4_11133.integrate(HH(D)^4)
    9
    sage: P4_11133.integrate(HH(D) * HH(cone))
    1

Python

    >>> from sage.all import *
    >>> # needs sage.libs.singular
    >>> D = P4_11133.divisor(Integer(0))
    >>> HH(D)
    [3*z4]
    >>> P4_11133.integrate(HH(D)**Integer(4))
    9
    >>> P4_11133.integrate(HH(D) * HH(cone))
    1

Although computationally less efficient, we can do the same computations with the rational Chow group:

Sage

    sage: AA = P4_11133.Chow_group(QQ)
    sage: list(map(AA, P4_11133.fan(1)))  # long time (5s on sage.math, 2012)
    [( 0 | 0 | 0 | 3 | 0 ), ( 0 | 0 | 0 | 3 | 0 ),
     ( 0 | 0 | 0 | 1 | 0 ), ( 0 | 0 | 0 | 1 | 0 ), ( 0 | 0 | 0 | 1 | 0 )]
    sage: list(map(AA, P4_11133.fan(4)))  # long time (5s on sage.math, 2012)
    [( 1 | 0 | 0 | 0 | 0 ), ( 1 | 0 | 0 | 0 | 0 ),
     ( 1 | 0 | 0 | 0 | 0 ), ( 1 | 0 | 0 | 0 | 0 ), ( 1 | 0 | 0 | 0 | 0 )]
    sage: AA(cone).intersection_with_divisor(D)  # long time (4s on sage.math, 2013)    # needs sage.libs.singular
    ( 1 | 0 | 0 | 0 | 0 )
    sage: AA(cone).intersection_with_divisor(D).count_points()  # long time             # needs sage.libs.singular
    1

[Python]

    >>> from sage.all import *
    >>> AA = P4_11133.Chow_group(QQ)
    >>> list(map(AA, P4_11133.fan(Integer(1))))  # long time (5s on sage.math, 2012)
    [( 0 | 0 | 0 | 3 | 0 ), ( 0 | 0 | 0 | 3 | 0 ),
     ( 0 | 0 | 0 | 1 | 0 ), ( 0 | 0 | 0 | 1 | 0 ), ( 0 | 0 | 0 | 1 | 0 )]
    >>> list(map(AA, P4_11133.fan(Integer(4))))  # long time (5s on sage.math, 2012)
    [( 1 | 0 | 0 | 0 | 0 ), ( 1 | 0 | 0 | 0 | 0 ),
     ( 1 | 0 | 0 | 0 | 0 ), ( 1 | 0 | 0 | 0 | 0 ), ( 1 | 0 | 0 | 0 | 0 )]
    >>> AA(cone).intersection_with_divisor(D)  # long time (4s on sage.math, 2013)    # needs sage.libs.singular
    ( 1 | 0 | 0 | 0 | 0 )
    >>> AA(cone).intersection_with_divisor(D).count_points()  # long time             # needs sage.libs.singular
    1

The real advantage of the Chow group is that

- it works just as well over \(\ZZ\), so torsion information is also easily available, and

- its combinatorial description also works over worse-than-orbifold singularities. By contrast, the cohomology groups can become very complicated to compute in this case, and one usually only has a spectral sequence but no toric algorithm.

Below you will find detailed descriptions of available functions. If you are familiar with toric geometry, you will likely see that many important objects and operations are unavailable. However, this module is under active development and hopefully will improve in future releases of Sage. If there are some particular features that you would like to see implemented ASAP, please consider reporting them to the Sage Development Team or even implementing them on your own as a patch for inclusion!

sage.schemes.toric.variety.AffineToricVariety(cone, *args, **kwds)

  Construct an affine toric variety.

  INPUT:

  - `cone` – `strictly convex rational polyhedral cone`

  This cone will be used to construct a `rational polyhedral fan`, which will be passed to `ToricVariety()` with the rest of positional and keyword arguments.

  OUTPUT: a `toric variety`

  Note

  The generating rays of the fan of this variety are guaranteed to be listed in the same order as the rays of the original cone.

  EXAMPLES:

  We will create the affine plane as an affine toric variety:

  Sage

      sage: quadrant = Cone([(1,0), (0,1)])
      sage: A2 = AffineToricVariety(quadrant)
      sage: origin = A2(0,0)
      sage: origin
      [0 : 0]
      sage: parent(origin)
      Set of rational points of 2-d affine toric variety

  Python

      >>> from sage.all import *
      >>> quadrant = Cone([(Integer(1),Integer(0)), (Integer(0),Integer(1))])
      >>> A2 = AffineToricVariety(quadrant)
      >>> origin = A2(Integer(0),Integer(0))
      >>> origin
      [0 : 0]
      >>> parent(origin)
      Set of rational points of 2-d affine toric variety

  Only affine toric varieties have points whose (homogeneous) coordinates are all zero.

class sage.schemes.toric.variety.CohomologyClass(cohomology_ring, representative)

  Bases: `QuotientRingElement`

  An element of the `CohomologyRing`.

  Warning

  You should not create instances of this class manually. The generators of the cohomology ring as well as the cohomology classes associated to cones of the fan can be obtained from `ToricVariety_field.cohomology_ring()`.

  EXAMPLES:

  Sage

      sage: # needs sage.libs.singular
      sage: P2 = toric_varieties.P2()
      sage: P2.cohomology_ring().gen(0)
      [z]
      sage: HH = P2.cohomology_ring()
      sage: HH.gen(0)
      [z]
      sage: cone = P2.fan(1)[0];  HH(cone)
      [z]

  Python

      >>> from sage.all import *
      >>> # needs sage.libs.singular
      >>> P2 = toric_varieties.P2()
      >>> P2.cohomology_ring().gen(Integer(0))
      [z]
      >>> HH = P2.cohomology_ring()
      >>> HH.gen(Integer(0))
      [z]
      >>> cone = P2.fan(Integer(1))[Integer(0)];  HH(cone)
      [z]

  deg()

    The degree of the cohomology class.

    OUTPUT:

    An integer \(d\) such that the cohomology class is in degree \(2d\). If the cohomology class is of mixed degree, the highest degree is returned.

    EXAMPLES:

    Sage

        sage: P2 = toric_varieties.P2()
        sage: P2.cohomology_ring().gen(0).deg()                                     # needs sage.libs.singular
        1
        sage: P2.cohomology_ring().zero().deg()                                     # needs sage.libs.singular
        -1

    Python

        >>> from sage.all import *
        >>> P2 = toric_varieties.P2()
        >>> P2.cohomology_ring().gen(Integer(0)).deg()                                     # needs sage.libs.singular
        1
        >>> P2.cohomology_ring().zero().deg()                                     # needs sage.libs.singular
        -1

  exp()

    Exponentiate `self`.

    Note

    The exponential \(\exp(x)\) of a rational number \(x\) is usually not rational. Therefore, the cohomology class must not have a constant (degree zero) part. The coefficients in the Taylor series of \(\exp\) are rational, so any cohomology class without constant term can be exponentiated.

    OUTPUT:

    The cohomology class \(\exp(\) `self` \()\) if the constant part vanishes, otherwise a `ValueError` is raised.

    EXAMPLES:

    Sage

        sage: # needs sage.libs.singular
        sage: P2 = toric_varieties.P2()
        sage: H_class = P2.cohomology_ring().gen(0)
        sage: H_class
        [z]
        sage: H_class.exp()
        [1/2*z^2 + z + 1]

    Python

        >>> from sage.all import *
        >>> # needs sage.libs.singular
        >>> P2 = toric_varieties.P2()
        >>> H_class = P2.cohomology_ring().gen(Integer(0))
        >>> H_class
        [z]
        >>> H_class.exp()
        [1/2*z^2 + z + 1]

  part_of_degree(d)

    Project the (mixed-degree) cohomology class to the given degree.

    \[\mathop{pr}\nolimits_d:~ H^\bullet(X_\Delta,\QQ) \to H^{2d}(X_\Delta,\QQ)\]

    INPUT:

    - An integer `d`

    OUTPUT: the degree-`2d` part of the cohomology class

    EXAMPLES:

    Sage

        sage: # needs sage.libs.singular
        sage: P1xP1 = toric_varieties.P1xP1()
        sage: t = P1xP1.cohomology_ring().gen(0)
        sage: y = P1xP1.cohomology_ring().gen(2)
        sage: 3*t + 4*t^2*y + y + t*y + t + 1
        [t*y + 4*t + y + 1]
        sage: (3*t + 4*t^2*y + y + t*y + t + 1).part_of_degree(1)
        [4*t + y]

    Python

        >>> from sage.all import *
        >>> # needs sage.libs.singular
        >>> P1xP1 = toric_varieties.P1xP1()
        >>> t = P1xP1.cohomology_ring().gen(Integer(0))
        >>> y = P1xP1.cohomology_ring().gen(Integer(2))
        >>> Integer(3)*t + Integer(4)*t**Integer(2)*y + y + t*y + t + Integer(1)
        [t*y + 4*t + y + 1]
        >>> (Integer(3)*t + Integer(4)*t**Integer(2)*y + y + t*y + t + Integer(1)).part_of_degree(Integer(1))
        [4*t + y]

class sage.schemes.toric.variety.CohomologyRing(variety)

  Bases: `QuotientRing_generic`, `UniqueRepresentation`

  The (even) cohomology ring of a toric variety.

  Irregardles of the variety’s base ring, we always work with the variety over \(\CC\) and its topology.

  The cohomology is always the singular cohomology with \(\QQ\)-coefficients. Note, however, that the cohomology of smooth toric varieties is torsion-free, so there is no loss of information in that case.

  Currently, the toric variety must not be “too singular”. See `ToricVariety_field.cohomology_ring()` for a detailed description of which toric varieties are admissible. For such varieties the odd-dimensional cohomology groups vanish.

  Warning

  You should not create instances of this class manually. Use `ToricVariety_field.cohomology_ring()` to generate the cohomology ring.

  INPUT:

  - `variety` – a toric variety. Currently, the toric variety must be at least an orbifold. See `ToricVariety_field.cohomology_ring()` for a detailed description of which toric varieties are admissible.

  EXAMPLES:

  Sage

      sage: P2 = toric_varieties.P2()
      sage: P2.cohomology_ring()
      Rational cohomology ring of a 2-d CPR-Fano toric variety covered by 3 affine patches

  Python

      >>> from sage.all import *
      >>> P2 = toric_varieties.P2()
      >>> P2.cohomology_ring()
      Rational cohomology ring of a 2-d CPR-Fano toric variety covered by 3 affine patches

  This is equivalent to:

  Sage

      sage: from sage.schemes.toric.variety import CohomologyRing
      sage: CohomologyRing(P2)
      Rational cohomology ring of a 2-d CPR-Fano toric variety covered by 3 affine patches

  [Python]

      >>> from sage.all import *
      >>> from sage.schemes.toric.variety import CohomologyRing
      >>> CohomologyRing(P2)
      Rational cohomology ring of a 2-d CPR-Fano toric variety covered by 3 affine patches

  gen(i)

    Return a generator of the cohomology ring.

    INPUT:

    - `i` – integer

    OUTPUT:

    The `i`-th generator of the cohomology ring. If we denote the toric variety by `X`, then this generator is associated to the ray `X.fan().ray(i)`, which spans the one-cone `X.fan(1)[i]`

    EXAMPLES:

    Sage

        sage: P2 = toric_varieties.P2()
        sage: P2.cohomology_ring().gen(2)                                           # needs sage.libs.singular
        [z]

    Python

        >>> from sage.all import *
        >>> P2 = toric_varieties.P2()
        >>> P2.cohomology_ring().gen(Integer(2))                                           # needs sage.libs.singular
        [z]

  gens()

    Return the generators of the cohomology ring.

    OUTPUT:

    A tuple of generators, one for each toric divisor of the toric variety `X`. The order is the same as the ordering of the rays of the fan `X.fan().rays()`, which is also the same as the ordering of the one-cones in `X.fan(1)`

    EXAMPLES:

    Sage

        sage: P2 = toric_varieties.P2()
        sage: P2.cohomology_ring().gens()                                           # needs sage.libs.singular
        ([z], [z], [z])

    Python

        >>> from sage.all import *
        >>> P2 = toric_varieties.P2()
        >>> P2.cohomology_ring().gens()                                           # needs sage.libs.singular
        ([z], [z], [z])

sage.schemes.toric.variety.ToricVariety(fan, coordinate_names=None, names=None, coordinate_indices=None, base_ring=Rational Field, base_field=None)

  Construct a toric variety.

  INPUT:

  - `fan` – `rational polyhedral fan`

  - `coordinate_names` – names of variables for the coordinate ring, see `normalize_names()` for acceptable formats. If not given, indexed variable names will be created automatically.

  - `names` – an alias of `coordinate_names` for internal use. You may specify either `names` or `coordinate_names`, but not both.

  - `coordinate_indices` – list of integers, indices for indexed variables. If not given, the index of each variable will coincide with the index of the corresponding ray of the fan.

  - `base_ring` – base ring of the toric variety (default: \(\QQ\)); must be a field

  - `base_field` – alias for `base_ring`; takes precedence if both are specified

  OUTPUT: a `toric variety`

  EXAMPLES:

  We will create the product of two projective lines:

  Sage

      sage: fan = FaceFan(lattice_polytope.cross_polytope(2))
      sage: fan.rays()
      M( 1,  0),    M( 0,  1),
      M(-1,  0),    M( 0, -1)
      in 2-d lattice M
      sage: P1xP1 = ToricVariety(fan)
      sage: P1xP1.gens()
      (z0, z1, z2, z3)

  Python

      >>> from sage.all import *
      >>> fan = FaceFan(lattice_polytope.cross_polytope(Integer(2)))
      >>> fan.rays()
      M( 1,  0),    M( 0,  1),
      M(-1,  0),    M( 0, -1)
      in 2-d lattice M
      >>> P1xP1 = ToricVariety(fan)
      >>> P1xP1.gens()
      (z0, z1, z2, z3)

  Let’s create some points:

  Sage

      sage: P1xP1(1,1,1,1)
      [1 : 1 : 1 : 1]
      sage: P1xP1(0,1,1,1)
      [0 : 1 : 1 : 1]
      sage: P1xP1(0,1,0,1)
      Traceback (most recent call last):
      ...
      TypeError: coordinates (0, 1, 0, 1) are in the exceptional set

  [Python]

      >>> from sage.all import *
      >>> P1xP1(Integer(1),Integer(1),Integer(1),Integer(1))
      [1 : 1 : 1 : 1]
      >>> P1xP1(Integer(0),Integer(1),Integer(1),Integer(1))
      [0 : 1 : 1 : 1]
      >>> P1xP1(Integer(0),Integer(1),Integer(0),Integer(1))
      Traceback (most recent call last):
      ...
      TypeError: coordinates (0, 1, 0, 1) are in the exceptional set

  We cannot set to zero both coordinates of the same projective line!

  Let’s change the names of the variables. We have to re-create our toric variety:

  Sage

      sage: P1xP1 = ToricVariety(fan, "x s y t")
      sage: P1xP1.gens()
      (x, s, y, t)

  Python

      >>> from sage.all import *
      >>> P1xP1 = ToricVariety(fan, "x s y t")
      >>> P1xP1.gens()
      (x, s, y, t)

  Now \((x, y)\) correspond to one line and \((s, t)\) to the other one.

  Sage

      sage: P1xP1.inject_variables()
      Defining x, s, y, t
      sage: P1xP1.subscheme(x*s - y*t)
      Closed subscheme of 2-d toric variety covered by 4 affine patches defined by:
        x*s - y*t

  [Python]

      >>> from sage.all import *
      >>> P1xP1.inject_variables()
      Defining x, s, y, t
      >>> P1xP1.subscheme(x*s - y*t)
      Closed subscheme of 2-d toric variety covered by 4 affine patches defined by:
        x*s - y*t

  Here is a shorthand for defining the toric variety and homogeneous coordinates in one go:

  Sage

      sage: P1xP1.<a,b,c,d> = ToricVariety(fan)
      sage: (a^2+b^2) * (c+d)
      a^2*c + b^2*c + a^2*d + b^2*d

  Python

      >>> from sage.all import *
      >>> P1xP1 = ToricVariety(fan, names=('a', 'b', 'c', 'd',)); (a, b, c, d,) = P1xP1._first_ngens(4)
      >>> (a**Integer(2)+b**Integer(2)) * (c+d)
      a^2*c + b^2*c + a^2*d + b^2*d

class sage.schemes.toric.variety.ToricVariety_field(fan, coordinate_names, coordinate_indices, base_field)

  Bases: `AmbientSpace`

  Construct a toric variety associated to a rational polyhedral fan.

  Warning

  This class does not perform any checks of correctness of input. Use `ToricVariety()` and `AffineToricVariety()` to construct toric varieties.

  INPUT:

  - `fan` – `rational polyhedral fan`

  - `coordinate_names` – names of variables, see `normalize_names()` for acceptable formats. If `None`, indexed variable names will be created automatically.

  - `coordinate_indices` – list of integers, indices for indexed variables. If `None`, the index of each variable will coincide with the index of the corresponding ray of the fan.

  - `base_field` – base field of the toric variety

  OUTPUT: a `toric variety`

  Aut_dimension()

    Return the dimension of the automorphism group.

    There are three kinds of symmetries of toric varieties:

    > - Toric automorphisms (rescaling of homogeneous coordinates)

    > - Demazure roots. These are translations \(x_i \to x_i + \epsilon x^m\) of a homogeneous coordinate \(x_i\) by a monomial \(x^m\) of the same homogeneous degree.

    > - Symmetries of the fan. These yield discrete subgroups.

    OUTPUT:

    An integer. The dimension of the automorphism group. Equals the dimension of the \(M\)-lattice plus the number of Demazure roots.

    EXAMPLES:

    Sage

        sage: P2 = toric_varieties.P2()
        sage: P2.Aut_dimension()
        8

    Python

        >>> from sage.all import *
        >>> P2 = toric_varieties.P2()
        >>> P2.Aut_dimension()
        8

  Chern_character(deg=None)

    Return the Chern character (of the tangent bundle) of the toric variety.

    INPUT:

    - `deg` – integer (optional); the degree of the Chern character

    OUTPUT:

    - If the degree is specified, the degree-`deg` part of the Chern character.

    - If no degree is specified, the total Chern character.

    REFERENCES:

    - Wikipedia article Chern_character#The_Chern_character

    EXAMPLES:

    Sage

        sage: # needs sage.libs.singular
        sage: dP6 = toric_varieties.dP6()
        sage: dP6.Chern_character()
        [3*w^2 + y + 2*v + 2*z + w + 2]
        sage: dP6.ch()
        [3*w^2 + y + 2*v + 2*z + w + 2]
        sage: dP6.ch(1) == dP6.c(1)
        True

    Python

        >>> from sage.all import *
        >>> # needs sage.libs.singular
        >>> dP6 = toric_varieties.dP6()
        >>> dP6.Chern_character()
        [3*w^2 + y + 2*v + 2*z + w + 2]
        >>> dP6.ch()
        [3*w^2 + y + 2*v + 2*z + w + 2]
        >>> dP6.ch(Integer(1)) == dP6.c(Integer(1))
        True

  Chern_class(deg=None)

    Return Chern classes of the (tangent bundle of the) toric variety.

    INPUT:

    - `deg` – integer (optional); the degree of the Chern class

    OUTPUT: if the degree is specified, the `deg`-th Chern class

    - If no degree is specified, the total Chern class.

    REFERENCES:

    - Wikipedia article Chern_class

    EXAMPLES:

    Sage

        sage: # needs sage.libs.singular
        sage: X = toric_varieties.dP6()
        sage: X.Chern_class()
        [-6*w^2 + y + 2*v + 2*z + w + 1]
        sage: X.c()
        [-6*w^2 + y + 2*v + 2*z + w + 1]
        sage: X.c(1)
        [y + 2*v + 2*z + w]
        sage: X.c(2)
        [-6*w^2]
        sage: X.integrate( X.c(2) )
        6
        sage: X.integrate( X.c(2) ) == X.Euler_number()
        True

    Python

        >>> from sage.all import *
        >>> # needs sage.libs.singular
        >>> X = toric_varieties.dP6()
        >>> X.Chern_class()
        [-6*w^2 + y + 2*v + 2*z + w + 1]
        >>> X.c()
        [-6*w^2 + y + 2*v + 2*z + w + 1]
        >>> X.c(Integer(1))
        [y + 2*v + 2*z + w]
        >>> X.c(Integer(2))
        [-6*w^2]
        >>> X.integrate( X.c(Integer(2)) )
        6
        >>> X.integrate( X.c(Integer(2)) ) == X.Euler_number()
        True

  Chow_group(base_ring=Integer Ring)

    Return the toric Chow group.

    INPUT:

    - `base_ring` – either `ZZ` (default) or `QQ`; the coefficient ring of the Chow group

    OUTPUT: a `sage.schemes.toric.chow_group.ChowGroup_class`

    EXAMPLES:

    Sage

        sage: A = toric_varieties.P2().Chow_group(); A
        Chow group of 2-d CPR-Fano toric variety covered by 3 affine patches
        sage: A.gens()
        (( 0 | 0 | 1 ), ( 0 | 1 | 0 ), ( 1 | 0 | 0 ))

    Python

        >>> from sage.all import *
        >>> A = toric_varieties.P2().Chow_group(); A
        Chow group of 2-d CPR-Fano toric variety covered by 3 affine patches
        >>> A.gens()
        (( 0 | 0 | 1 ), ( 0 | 1 | 0 ), ( 1 | 0 | 0 ))

  Demazure_roots()

    Return the Demazure roots.

    OUTPUT: the roots as points of the \(M\)-lattice

    REFERENCES:

    - [De1970]

    - [Baz2011]

    EXAMPLES:

    Sage

        sage: P2 = toric_varieties.P2()
        sage: P2.Demazure_roots()
        (M(-1, 0), M(-1, 1), M(0, -1), M(0, 1), M(1, -1), M(1, 0))

    Python

        >>> from sage.all import *
        >>> P2 = toric_varieties.P2()
        >>> P2.Demazure_roots()
        (M(-1, 0), M(-1, 1), M(0, -1), M(0, 1), M(1, -1), M(1, 0))

    Here are the remaining three examples listed in [Baz2011], Example 2.1 and 2.3:

    Sage

        sage: s = 3
        sage: cones = [(0,1), (1,2), (2,3), (3,0)]
        sage: Hs = ToricVariety(Fan(rays=[(1,0), (0,-1), (-1,s), (0,1)], cones=cones))
        sage: Hs.Demazure_roots()
        (M(-1, 0), M(1, 0), M(0, 1), M(1, 1), M(2, 1), M(3, 1))

        sage: P11s = ToricVariety(Fan(rays=[(1,0), (0,-1), (-1,s)],
        ....:                         cones=[(0,1), (1,2), (2,0)]))
        sage: P11s.Demazure_roots()
        (M(-1, 0), M(1, 0), M(0, 1), M(1, 1), M(2, 1), M(3, 1))
        sage: P11s.Demazure_roots() == Hs.Demazure_roots()
        True

        sage: Bs = ToricVariety(Fan(rays=[(s,1), (s,-1), (-s,-1), (-s,1)], cones=cones))
        sage: Bs.Demazure_roots()
        ()

    [Python]

        >>> from sage.all import *
        >>> s = Integer(3)
        >>> cones = [(Integer(0),Integer(1)), (Integer(1),Integer(2)), (Integer(2),Integer(3)), (Integer(3),Integer(0))]
        >>> Hs = ToricVariety(Fan(rays=[(Integer(1),Integer(0)), (Integer(0),-Integer(1)), (-Integer(1),s), (Integer(0),Integer(1))], cones=cones))
        >>> Hs.Demazure_roots()
        (M(-1, 0), M(1, 0), M(0, 1), M(1, 1), M(2, 1), M(3, 1))

        >>> P11s = ToricVariety(Fan(rays=[(Integer(1),Integer(0)), (Integer(0),-Integer(1)), (-Integer(1),s)],
        ...                         cones=[(Integer(0),Integer(1)), (Integer(1),Integer(2)), (Integer(2),Integer(0))]))
        >>> P11s.Demazure_roots()
        (M(-1, 0), M(1, 0), M(0, 1), M(1, 1), M(2, 1), M(3, 1))
        >>> P11s.Demazure_roots() == Hs.Demazure_roots()
        True

        >>> Bs = ToricVariety(Fan(rays=[(s,Integer(1)), (s,-Integer(1)), (-s,-Integer(1)), (-s,Integer(1))], cones=cones))
        >>> Bs.Demazure_roots()
        ()

  Euler_number()

    Return the topological Euler number of the toric variety.

    Sometimes, this is also called the Euler characteristic. `chi()` is a synonym for `Euler_number()`.

    REFERENCES:

    - Wikipedia article Euler_characteristic

    EXAMPLES:

    Sage

        sage: # needs sage.libs.singular
        sage: P1xP1 = toric_varieties.P1xP1()
        sage: P1xP1.Euler_number()
        4
        sage: P1xP1.chi()
        4

    Python

        >>> from sage.all import *
        >>> # needs sage.libs.singular
        >>> P1xP1 = toric_varieties.P1xP1()
        >>> P1xP1.Euler_number()
        4
        >>> P1xP1.chi()
        4

  K()

    Return the canonical divisor of the toric variety.

    EXAMPLES:

    Lets test that the del Pezzo surface \(dP_6\) has degree 6, as its name implies:

    Sage

        sage: dP6 = toric_varieties.dP6()
        sage: HH = dP6.cohomology_ring()
        sage: dP6.K()
        -V(x) - V(u) - V(y) - V(v) - V(z) - V(w)
        sage: dP6.integrate( HH(dP6.K())^2 )                                        # needs sage.libs.singular
        6

    Python

        >>> from sage.all import *
        >>> dP6 = toric_varieties.dP6()
        >>> HH = dP6.cohomology_ring()
        >>> dP6.K()
        -V(x) - V(u) - V(y) - V(v) - V(z) - V(w)
        >>> dP6.integrate( HH(dP6.K())**Integer(2) )                                        # needs sage.libs.singular
        6

  Kaehler_cone()

    Return the closure of the Kähler cone of `self`.

    OUTPUT: `cone`

    Note

    This cone sits in the rational divisor class group of `self` and the choice of coordinates agrees with `rational_class_group()`.

    EXAMPLES:

    Sage

        sage: P1xP1 = toric_varieties.P1xP1()
        sage: Kc = P1xP1.Kaehler_cone()
        sage: Kc
        2-d cone in 2-d lattice
        sage: Kc.rays()
        Divisor class [0, 1],
        Divisor class [1, 0]
        in Basis lattice of The toric rational divisor class group
        of a 2-d CPR-Fano toric variety covered by 4 affine patches
        sage: [ divisor_class.lift() for divisor_class in Kc.rays() ]
        [V(y), V(t)]
        sage: Kc.lattice()
        Basis lattice of The toric rational divisor class group of a
        2-d CPR-Fano toric variety covered by 4 affine patches

    Python

        >>> from sage.all import *
        >>> P1xP1 = toric_varieties.P1xP1()
        >>> Kc = P1xP1.Kaehler_cone()
        >>> Kc
        2-d cone in 2-d lattice
        >>> Kc.rays()
        Divisor class [0, 1],
        Divisor class [1, 0]
        in Basis lattice of The toric rational divisor class group
        of a 2-d CPR-Fano toric variety covered by 4 affine patches
        >>> [ divisor_class.lift() for divisor_class in Kc.rays() ]
        [V(y), V(t)]
        >>> Kc.lattice()
        Basis lattice of The toric rational divisor class group of a
        2-d CPR-Fano toric variety covered by 4 affine patches

  Mori_cone()

    Return the Mori cone of `self`.

    OUTPUT: `cone`

    Note

    - The Mori cone is dual to the Kähler cone.

    - We think of the Mori cone as living inside the row span of the Gale transform matrix (computed by `self.fan().Gale_transform()`).

    - The points in the Mori cone are the effective curves in the variety.

    - The `i`-th entry in each Mori vector is the intersection number of the curve corresponding to the generator of the `i`-th ray of the fan with the corresponding divisor class. The very last entry is associated to the origin of the fan lattice.

    - The Mori vectors are also known as the gauged linear sigma model charge vectors.

    EXAMPLES:

    Sage

        sage: P4_11169 = toric_varieties.P4_11169_resolved()
        sage: P4_11169.Mori_cone()
        2-d cone in 7-d lattice
        sage: P4_11169.Mori_cone().rays()
        (3, 2, 0, 0, 0,  1, -6),
        (0, 0, 1, 1, 1, -3,  0)
        in Ambient free module of rank 7 over the principal ideal domain Integer Ring

    Python

        >>> from sage.all import *
        >>> P4_11169 = toric_varieties.P4_11169_resolved()
        >>> P4_11169.Mori_cone()
        2-d cone in 7-d lattice
        >>> P4_11169.Mori_cone().rays()
        (3, 2, 0, 0, 0,  1, -6),
        (0, 0, 1, 1, 1, -3,  0)
        in Ambient free module of rank 7 over the principal ideal domain Integer Ring

  Spec(cone=None, names=None)

    Return the spectrum associated to the dual cone.

    Let \(\sigma \in N_\RR\) be a cone and \(\sigma^\vee \cap M\) the associated semigroup of lattice points in the dual cone. Then

    \[S = \CC[\sigma^\vee \cap M]\]

    is a \(\CC\)-algebra. It is spanned over \(\CC\) by the points of \(\sigma \cap N\), addition is formal linear combination of lattice points, and multiplication of lattice points is the semigroup law (that is, addition of lattice points). The \(\CC\)-algebra \(S\) then defines a scheme \(\mathop{Spec}(S)\).

    For example, if \(\sigma=\{(x,y)|x\geq 0,y\geq 0\}\) is the first quadrant then \(S\) is the polynomial ring in two variables. The associated scheme is \(\mathop{Spec}(S) = \CC^2\).

    The same construction works over any base field, this introduction only used \(\CC\) for simplicity.

    INPUT:

    - `cone` – a `Cone`. Can be omitted for an affine toric variety, in which case the (unique) generating cone is used.

    - `names` – (optional). Names of variables for the semigroup ring, see `normalize_names()` for acceptable formats. If not given, indexed variable names will be created automatically.

    OUTPUT: the spectrum of the semigroup ring \(\CC[\sigma^\vee \cap M]\)

    EXAMPLES:

    Sage

        sage: quadrant = Cone([(1,0), (0,1)])
        sage: AffineToricVariety(quadrant).Spec()
        Spectrum of Multivariate Polynomial Ring in z0, z1 over Rational Field

    Python

        >>> from sage.all import *
        >>> quadrant = Cone([(Integer(1),Integer(0)), (Integer(0),Integer(1))])
        >>> AffineToricVariety(quadrant).Spec()
        Spectrum of Multivariate Polynomial Ring in z0, z1 over Rational Field

    A more interesting example:

    Sage

        sage: A2Z2 = Cone([(0,1), (2,1)])
        sage: AffineToricVariety(A2Z2).Spec(names='u,v,t')                          # needs fpylll sage.libs.singular
        Spectrum of Quotient of Multivariate Polynomial Ring
        in u, v, t over Rational Field by the ideal (-u*v + t^2)

    [Python]

        >>> from sage.all import *
        >>> A2Z2 = Cone([(Integer(0),Integer(1)), (Integer(2),Integer(1))])
        >>> AffineToricVariety(A2Z2).Spec(names='u,v,t')                          # needs fpylll sage.libs.singular
        Spectrum of Quotient of Multivariate Polynomial Ring
        in u, v, t over Rational Field by the ideal (-u*v + t^2)

  Stanley_Reisner_ideal()

    Return the Stanley-Reisner ideal.

    OUTPUT:

    - The Stanley-Reisner ideal in the polynomial ring over \(\QQ\) generated by the homogeneous coordinates.

    EXAMPLES:

    Sage

        sage: fan = Fan([[0,1,3], [3,4], [2,0], [1,2,4]],
        ....:           [(-3, -2, 1), (0, 0, 1), (3, -2, 1), (-1, -1, 1), (1, -1, 1)])
        sage: X = ToricVariety(fan, coordinate_names='A B C D E', base_field=GF(5))
        sage: SR = X.Stanley_Reisner_ideal(); SR
        Ideal (A*E, C*D, A*B*C, B*D*E) of
         Multivariate Polynomial Ring in A, B, C, D, E over Rational Field

    Python

        >>> from sage.all import *
        >>> fan = Fan([[Integer(0),Integer(1),Integer(3)], [Integer(3),Integer(4)], [Integer(2),Integer(0)], [Integer(1),Integer(2),Integer(4)]],
        ...           [(-Integer(3), -Integer(2), Integer(1)), (Integer(0), Integer(0), Integer(1)), (Integer(3), -Integer(2), Integer(1)), (-Integer(1), -Integer(1), Integer(1)), (Integer(1), -Integer(1), Integer(1))])
        >>> X = ToricVariety(fan, coordinate_names='A B C D E', base_field=GF(Integer(5)))
        >>> SR = X.Stanley_Reisner_ideal(); SR
        Ideal (A*E, C*D, A*B*C, B*D*E) of
         Multivariate Polynomial Ring in A, B, C, D, E over Rational Field

  Td(deg=None)

    alias of `Todd_class()`.

  Todd_class(deg=None)

    Return the Todd class (of the tangent bundle) of the toric variety.

    INPUT:

    - `deg` – integer (optional); the desired degree part

    OUTPUT:

    - If the degree is specified, the degree-`deg` part of the Todd class.

    - If no degree is specified, the total Todd class.

    REFERENCES:

    - Wikipedia article Todd_class

    EXAMPLES:

    Sage

        sage: # needs sage.libs.singular
        sage: dP6 = toric_varieties.dP6()
        sage: dP6.Todd_class()
        [-w^2 + 1/2*y + v + z + 1/2*w + 1]
        sage: dP6.Td()
        [-w^2 + 1/2*y + v + z + 1/2*w + 1]
        sage: dP6.integrate( dP6.Td() )
        1

    Python

        >>> from sage.all import *
        >>> # needs sage.libs.singular
        >>> dP6 = toric_varieties.dP6()
        >>> dP6.Todd_class()
        [-w^2 + 1/2*y + v + z + 1/2*w + 1]
        >>> dP6.Td()
        [-w^2 + 1/2*y + v + z + 1/2*w + 1]
        >>> dP6.integrate( dP6.Td() )
        1

  affine_algebraic_patch(cone=None, names=None)

    Return the patch corresponding to `cone` as an affine algebraic subvariety.

    INPUT:

    - `cone` – a `Cone` \(\sigma\) of the fan. It can be omitted for an affine toric variety, in which case the single generating cone is used.

    OUTPUT:

    A `affine algebraic subscheme` corresponding to the patch \(\mathop{Spec}(\sigma^\vee \cap M)\) associated to the cone \(\sigma\).

    See also `affine_patch()`, which expresses the patches as subvarieties of affine toric varieties instead.

    EXAMPLES:

    Sage

        sage: cone = Cone([(0,1), (2,1)])
        sage: A2Z2 = AffineToricVariety(cone)
        sage: A2Z2.affine_algebraic_patch()                                         # needs fpylll sage.libs.singular
        Closed subscheme of Affine Space of dimension 3 over Rational Field defined by:
          -z0*z1 + z2^2
        sage: A2Z2.affine_algebraic_patch(Cone([(0,1)]), names='x, y, t')           # needs fpylll sage.libs.singular
        Closed subscheme of Affine Space of dimension 3 over Rational Field defined by:
          1

    Python

        >>> from sage.all import *
        >>> cone = Cone([(Integer(0),Integer(1)), (Integer(2),Integer(1))])
        >>> A2Z2 = AffineToricVariety(cone)
        >>> A2Z2.affine_algebraic_patch()                                         # needs fpylll sage.libs.singular
        Closed subscheme of Affine Space of dimension 3 over Rational Field defined by:
          -z0*z1 + z2^2
        >>> A2Z2.affine_algebraic_patch(Cone([(Integer(0),Integer(1))]), names='x, y, t')           # needs fpylll sage.libs.singular
        Closed subscheme of Affine Space of dimension 3 over Rational Field defined by:
          1

  affine_patch(i)

    Return the `i`-th affine patch of `self`.

    INPUT:

    - `i` – integer; index of a generating cone of the fan of `self`

    OUTPUT:

    - affine `toric variety` corresponding to the `i`-th generating cone of the fan of `self`.

    The result is cached, so the `i`-th patch is always the same object in memory.

    See also `affine_algebraic_patch()`, which expresses the patches as subvarieties of affine space instead.

    EXAMPLES:

    Sage

        sage: fan = FaceFan(lattice_polytope.cross_polytope(2))
        sage: P1xP1 = ToricVariety(fan, "x s y t")
        sage: patch0 = P1xP1.affine_patch(0)
        sage: patch0
        2-d affine toric variety
        sage: patch0.embedding_morphism()
        Scheme morphism:
          From: 2-d affine toric variety
          To:   2-d toric variety covered by 4 affine patches
          Defn: Defined on coordinates by sending [y : t] to [1 : 1 : y : t]
        sage: patch1 = P1xP1.affine_patch(1)
        sage: patch1.embedding_morphism()
        Scheme morphism:
          From: 2-d affine toric variety
          To:   2-d toric variety covered by 4 affine patches
          Defn: Defined on coordinates by sending [s : y] to [1 : s : y : 1]
        sage: patch1 is P1xP1.affine_patch(1)
        True

    Python

        >>> from sage.all import *
        >>> fan = FaceFan(lattice_polytope.cross_polytope(Integer(2)))
        >>> P1xP1 = ToricVariety(fan, "x s y t")
        >>> patch0 = P1xP1.affine_patch(Integer(0))
        >>> patch0
        2-d affine toric variety
        >>> patch0.embedding_morphism()
        Scheme morphism:
          From: 2-d affine toric variety
          To:   2-d toric variety covered by 4 affine patches
          Defn: Defined on coordinates by sending [y : t] to [1 : 1 : y : t]
        >>> patch1 = P1xP1.affine_patch(Integer(1))
        >>> patch1.embedding_morphism()
        Scheme morphism:
          From: 2-d affine toric variety
          To:   2-d toric variety covered by 4 affine patches
          Defn: Defined on coordinates by sending [s : y] to [1 : s : y : 1]
        >>> patch1 is P1xP1.affine_patch(Integer(1))
        True

  c(deg=None)

    alias of `Chern_class()`.

  cartesian_product(other, coordinate_names=None, coordinate_indices=None)

    Return the Cartesian product of `self` with `other`.

    INPUT:

    - `other` – a `toric variety`

    - `coordinate_names` – names of variables for the coordinate ring, see `normalize_names()` for acceptable formats. If not given, indexed variable names will be created automatically.

    - `coordinate_indices` – list of integers, indices for indexed variables. If not given, the index of each variable will coincide with the index of the corresponding ray of the fan.

    OUTPUT: a `toric variety`

    EXAMPLES:

    Sage

        sage: P1 = ToricVariety(Fan([Cone([(1,)]), Cone([(-1,)])]))
        sage: P1xP1 = P1.cartesian_product(P1); P1xP1
        2-d toric variety covered by 4 affine patches
        sage: P1xP1.fan().rays()
        N+N(-1,  0),      N+N( 1,  0),
        N+N( 0, -1),      N+N( 0,  1)
        in 2-d lattice N+N

    Python

        >>> from sage.all import *
        >>> P1 = ToricVariety(Fan([Cone([(Integer(1),)]), Cone([(-Integer(1),)])]))
        >>> P1xP1 = P1.cartesian_product(P1); P1xP1
        2-d toric variety covered by 4 affine patches
        >>> P1xP1.fan().rays()
        N+N(-1,  0),      N+N( 1,  0),
        N+N( 0, -1),      N+N( 0,  1)
        in 2-d lattice N+N

  ch(deg=None)

    alias of `Chern_character()`.

  change_ring(F)

    Return a toric variety over `F` and otherwise the same as `self`.

    INPUT:

    - `F` – field

    OUTPUT: `toric variety` over `F`

    Note

    There is no need to have any relation between `F` and the base field of `self`. If you do want to have such a relation, use `base_extend()` instead.

    EXAMPLES:

    Sage

        sage: P1xA1 = toric_varieties.P1xA1()
        sage: P1xA1.base_ring()
        Rational Field
        sage: P1xA1_RR = P1xA1.change_ring(RR)
        sage: P1xA1_RR.base_ring()
        Real Field with 53 bits of precision
        sage: P1xA1_QQ = P1xA1_RR.change_ring(QQ)
        sage: P1xA1_QQ.base_ring()
        Rational Field
        sage: P1xA1_RR.base_extend(QQ)
        Traceback (most recent call last):
        ...
        ValueError: no natural map from the base ring
        (=Real Field with 53 bits of precision) to R (=Rational Field)!
        sage: R = PolynomialRing(QQ, 2, 'a')
        sage: P1xA1.change_ring(R)
        Traceback (most recent call last):
        ...
        TypeError: need a field to construct a toric variety;
        got Multivariate Polynomial Ring in a0, a1 over Rational Field

    Python

        >>> from sage.all import *
        >>> P1xA1 = toric_varieties.P1xA1()
        >>> P1xA1.base_ring()
        Rational Field
        >>> P1xA1_RR = P1xA1.change_ring(RR)
        >>> P1xA1_RR.base_ring()
        Real Field with 53 bits of precision
        >>> P1xA1_QQ = P1xA1_RR.change_ring(QQ)
        >>> P1xA1_QQ.base_ring()
        Rational Field
        >>> P1xA1_RR.base_extend(QQ)
        Traceback (most recent call last):
        ...
        ValueError: no natural map from the base ring
        (=Real Field with 53 bits of precision) to R (=Rational Field)!
        >>> R = PolynomialRing(QQ, Integer(2), 'a')
        >>> P1xA1.change_ring(R)
        Traceback (most recent call last):
        ...
        TypeError: need a field to construct a toric variety;
        got Multivariate Polynomial Ring in a0, a1 over Rational Field

  chi()

    alias of `Euler_number()`.

  cohomology_basis(d=None)

    Return a basis for the cohomology of the toric variety.

    INPUT:

    - `d` – (optional) integer

    OUTPUT:

    - Without the optional argument, a list whose \(d\)-th entry is a basis for \(H^{2d}(X,\QQ)\)

    - If the argument is an integer `d`, returns basis for \(H^{2d}(X,\QQ)\)

    EXAMPLES:

    Sage

        sage: # needs sage.libs.singular
        sage: X = toric_varieties.dP8()
        sage: X.cohomology_basis()
        (([1],), ([z], [y]), ([y*z],))
        sage: X.cohomology_basis(1)
        ([z], [y])
        sage: X.cohomology_basis(dimension(X))[0] == X.volume_class()
        True

    Python

        >>> from sage.all import *
        >>> # needs sage.libs.singular
        >>> X = toric_varieties.dP8()
        >>> X.cohomology_basis()
        (([1],), ([z], [y]), ([y*z],))
        >>> X.cohomology_basis(Integer(1))
        ([z], [y])
        >>> X.cohomology_basis(dimension(X))[Integer(0)] == X.volume_class()
        True

  cohomology_ring()

    Return the cohomology ring of the toric variety.

    OUTPUT:

    - If the toric variety is over \(\CC\) and has at most finite orbifold singularities: \(H^\bullet(X,\QQ)\) as a polynomial quotient ring.

    - Other cases are not handled yet.

    Note

    - Toric varieties over any field of characteristic 0 are treated as if they were varieties over \(\CC\).

    - The integral cohomology of smooth toric varieties is torsion-free, so in this case there is no loss of information when going to rational coefficients.

    - `self.cohomology_ring().gen(i)` is the divisor class corresponding to the `i`-th ray of the fan.

    EXAMPLES:

    Sage

        sage: X = toric_varieties.dP6()
        sage: X.cohomology_ring()
        Rational cohomology ring of a 2-d CPR-Fano toric variety covered by 6 affine patches
        sage: X.cohomology_ring().defining_ideal()
        Ideal (-u - y + z + w, x - y - v + w, x*y, x*v, x*z, u*v, u*z, u*w, y*z, y*w, v*w)
         of Multivariate Polynomial Ring in x, u, y, v, z, w over Rational Field
        sage: X.cohomology_ring().defining_ideal().ring()
        Multivariate Polynomial Ring in x, u, y, v, z, w over Rational Field
        sage: X.variable_names()
        ('x', 'u', 'y', 'v', 'z', 'w')
        sage: X.cohomology_ring().gens()                                            # needs sage.libs.singular
        ([y + v - w], [-y + z + w], [y], [v], [z], [w])

    Python

        >>> from sage.all import *
        >>> X = toric_varieties.dP6()
        >>> X.cohomology_ring()
        Rational cohomology ring of a 2-d CPR-Fano toric variety covered by 6 affine patches
        >>> X.cohomology_ring().defining_ideal()
        Ideal (-u - y + z + w, x - y - v + w, x*y, x*v, x*z, u*v, u*z, u*w, y*z, y*w, v*w)
         of Multivariate Polynomial Ring in x, u, y, v, z, w over Rational Field
        >>> X.cohomology_ring().defining_ideal().ring()
        Multivariate Polynomial Ring in x, u, y, v, z, w over Rational Field
        >>> X.variable_names()
        ('x', 'u', 'y', 'v', 'z', 'w')
        >>> X.cohomology_ring().gens()                                            # needs sage.libs.singular
        ([y + v - w], [-y + z + w], [y], [v], [z], [w])

  coordinate_ring()

    Return the coordinate ring of `self`.

    For toric varieties this is the homogeneous coordinate ring (a.k.a. Cox’s ring and total ring).

    OUTPUT: a polynomial ring

    EXAMPLES:

    Sage

        sage: P1xP1 = toric_varieties.P1xP1()
        sage: P1xP1.coordinate_ring()
        Multivariate Polynomial Ring in s, t, x, y over Rational Field

    Python

        >>> from sage.all import *
        >>> P1xP1 = toric_varieties.P1xP1()
        >>> P1xP1.coordinate_ring()
        Multivariate Polynomial Ring in s, t, x, y over Rational Field

  count_points()

    Return the number of points of `self`.

    This is an alias for `point_set().cardinality()`, see `cardinality()` for details.

    EXAMPLES:

    Sage

        sage: o = lattice_polytope.cross_polytope(3)
        sage: V = ToricVariety(FaceFan(o))
        sage: V2 = V.change_ring(GF(2))
        sage: V2.point_set().cardinality()
        27
        sage: V2.count_points()
        27

    Python

        >>> from sage.all import *
        >>> o = lattice_polytope.cross_polytope(Integer(3))
        >>> V = ToricVariety(FaceFan(o))
        >>> V2 = V.change_ring(GF(Integer(2)))
        >>> V2.point_set().cardinality()
        27
        >>> V2.count_points()
        27

  dimension_singularities()

    Return the dimension of the singular set.

    OUTPUT:

    Integer. The dimension of the singular set of the toric variety. Often the singular set is a reducible subvariety, and this method will return the dimension of the largest-dimensional component.

    This returns \(-1\) if the toric variety is smooth.

    EXAMPLES:

    Sage

        sage: toric_varieties.P4_11169().dimension_singularities()
        1
        sage: toric_varieties.Conifold().dimension_singularities()
        0
        sage: toric_varieties.P2().dimension_singularities()
        -1

    Python

        >>> from sage.all import *
        >>> toric_varieties.P4_11169().dimension_singularities()
        1
        >>> toric_varieties.Conifold().dimension_singularities()
        0
        >>> toric_varieties.P2().dimension_singularities()
        -1

  divisor(arg, base_ring=None, check=True, reduce=True)

    Return a divisor.

    INPUT:

    The arguments are the same as in `sage.schemes.toric.divisor.ToricDivisor()`, with the exception of defining a divisor with a single integer: this method considers it to be the index of a ray of the `fan()` of `self`.

    OUTPUT: a `sage.schemes.toric.divisor.ToricDivisor_generic`

    EXAMPLES:

    Sage

        sage: dP6 = toric_varieties.dP6()
        sage: dP6.coordinate_ring()
        Multivariate Polynomial Ring in x, u, y, v, z, w over Rational Field
        sage: dP6.divisor(list(range(6)))
        V(u) + 2*V(y) + 3*V(v) + 4*V(z) + 5*V(w)
        sage: dP6.inject_variables()
        Defining x, u, y, v, z, w
        sage: dP6.divisor(x*u^3)
        V(x) + 3*V(u)

    Python

        >>> from sage.all import *
        >>> dP6 = toric_varieties.dP6()
        >>> dP6.coordinate_ring()
        Multivariate Polynomial Ring in x, u, y, v, z, w over Rational Field
        >>> dP6.divisor(list(range(Integer(6))))
        V(u) + 2*V(y) + 3*V(v) + 4*V(z) + 5*V(w)
        >>> dP6.inject_variables()
        Defining x, u, y, v, z, w
        >>> dP6.divisor(x*u**Integer(3))
        V(x) + 3*V(u)

    You can also construct divisors based on ray indices:

    Sage

        sage: dP6.divisor(0)
        V(x)
        sage: for i in range(dP6.fan().nrays()):
        ....:     print('{} : generated by ray {}'.format(dP6.divisor(i),
        ....:           dP6.fan().ray(i)))
        V(x) : generated by ray N(0, 1)
        V(u) : generated by ray N(-1, 0)
        V(y) : generated by ray N(-1, -1)
        V(v) : generated by ray N(0, -1)
        V(z) : generated by ray N(1, 0)
        V(w) : generated by ray N(1, 1)

    [Python]

        >>> from sage.all import *
        >>> dP6.divisor(Integer(0))
        V(x)
        >>> for i in range(dP6.fan().nrays()):
        ...     print('{} : generated by ray {}'.format(dP6.divisor(i),
        ...           dP6.fan().ray(i)))
        V(x) : generated by ray N(0, 1)
        V(u) : generated by ray N(-1, 0)
        V(y) : generated by ray N(-1, -1)
        V(v) : generated by ray N(0, -1)
        V(z) : generated by ray N(1, 0)
        V(w) : generated by ray N(1, 1)

  divisor_group(base_ring=Integer Ring)

    Return the group of Weil divisors.

    INPUT:

    - `base_ring` – the coefficient ring, usually `ZZ` (default) or `QQ`

    OUTPUT:

    The (free abelian) group of Cartier divisors, that is, formal linear combinations of polynomial equations over the coefficient ring `base_ring`.

    These need not be toric (=defined by monomials), but allow general polynomials. The output will be an instance of `sage.schemes.generic.divisor_group.DivisorGroup_generic`.

    Warning

    You almost certainly want the group of toric divisors, see `toric_divisor_group()`. The toric divisor group is generated by the rays of the fan. The general divisor group has no toric functionality implemented.

    EXAMPLES:

    Sage

        sage: dP6 = toric_varieties.dP6()
        sage: Div = dP6.divisor_group(); Div
        Group of ZZ-Divisors on 2-d CPR-Fano toric variety covered by 6 affine patches
        sage: Div(x)                                                                # needs sage.symbolic
        V(x)

    Python

        >>> from sage.all import *
        >>> dP6 = toric_varieties.dP6()
        >>> Div = dP6.divisor_group(); Div
        Group of ZZ-Divisors on 2-d CPR-Fano toric variety covered by 6 affine patches
        >>> Div(x)                                                                # needs sage.symbolic
        V(x)

  embedding_morphism()

    Return the default embedding morphism of `self`.

    Such a morphism is always defined for an affine patch of a toric variety (which is also a toric varieties itself).

    OUTPUT:

    - `scheme morphism` if the default embedding morphism was defined for `self`, otherwise a `ValueError` exception is raised.

    EXAMPLES:

    Sage

        sage: fan = FaceFan(lattice_polytope.cross_polytope(2))
        sage: P1xP1 = ToricVariety(fan, "x s y t")
        sage: P1xP1.embedding_morphism()
        Traceback (most recent call last):
        ...
        ValueError: no default embedding was defined for this toric variety
        sage: patch = P1xP1.affine_patch(0)
        sage: patch
        2-d affine toric variety
        sage: patch.embedding_morphism()
        Scheme morphism:
          From: 2-d affine toric variety
          To:   2-d toric variety covered by 4 affine patches
          Defn: Defined on coordinates by sending [y : t] to [1 : 1 : y : t]

    Python

        >>> from sage.all import *
        >>> fan = FaceFan(lattice_polytope.cross_polytope(Integer(2)))
        >>> P1xP1 = ToricVariety(fan, "x s y t")
        >>> P1xP1.embedding_morphism()
        Traceback (most recent call last):
        ...
        ValueError: no default embedding was defined for this toric variety
        >>> patch = P1xP1.affine_patch(Integer(0))
        >>> patch
        2-d affine toric variety
        >>> patch.embedding_morphism()
        Scheme morphism:
          From: 2-d affine toric variety
          To:   2-d toric variety covered by 4 affine patches
          Defn: Defined on coordinates by sending [y : t] to [1 : 1 : y : t]

  fan(dim=None, codim=None)

    Return the underlying fan of `self` or its cones.

    INPUT:

    - `dim` – dimension of the requested cones

    - `codim` – codimension of the requested cones

    OUTPUT:

    - `rational polyhedral fan` if no parameters were given, `tuple` of `cones` otherwise.

    EXAMPLES:

    Sage

        sage: fan = FaceFan(lattice_polytope.cross_polytope(2))
        sage: P1xP1 = ToricVariety(fan)
        sage: P1xP1.fan()
        Rational polyhedral fan in 2-d lattice M
        sage: P1xP1.fan() is fan
        True
        sage: P1xP1.fan(1)[0]
        1-d cone of Rational polyhedral fan in 2-d lattice M

    Python

        >>> from sage.all import *
        >>> fan = FaceFan(lattice_polytope.cross_polytope(Integer(2)))
        >>> P1xP1 = ToricVariety(fan)
        >>> P1xP1.fan()
        Rational polyhedral fan in 2-d lattice M
        >>> P1xP1.fan() is fan
        True
        >>> P1xP1.fan(Integer(1))[Integer(0)]
        1-d cone of Rational polyhedral fan in 2-d lattice M

  inject_coefficients(scope=None, verbose=True)

    Inject generators of the base field of `self` into `scope`.

    This function is useful if the base field is the field of rational functions.

    INPUT:

    - `scope` – namespace (default: global, not just the scope from which this function was called)

    - `verbose` – if `True` (default), names of injected generators will be printed

    OUTPUT: none

    EXAMPLES:

    Sage

        sage: fan = FaceFan(lattice_polytope.cross_polytope(2))
        sage: F = QQ["a, b"].fraction_field()
        sage: P1xP1 = ToricVariety(fan, base_field=F)
        sage: P1xP1.inject_coefficients()
        Defining a, b

    Python

        >>> from sage.all import *
        >>> fan = FaceFan(lattice_polytope.cross_polytope(Integer(2)))
        >>> F = QQ["a, b"].fraction_field()
        >>> P1xP1 = ToricVariety(fan, base_field=F)
        >>> P1xP1.inject_coefficients()
        Defining a, b

    We check that we can use names `a` and `b`, Issue #10498 is fixed:

    Sage

        sage: a + b
        a + b
        sage: a + b in P1xP1.coordinate_ring()
        True

    [Python]

        >>> from sage.all import *
        >>> a + b
        a + b
        >>> a + b in P1xP1.coordinate_ring()
        True

  integrate(cohomology_class)

    Integrate a cohomology class over the toric variety.

    INPUT:

    - `cohomology_class` – a cohomology class given as a polynomial in `self.cohomology_ring()`

    OUTPUT:

    The integral of the cohomology class over the variety. The volume normalization is given by `volume_class()`, that is, `self.integrate(self.volume_class())` is always one (if the volume class exists).

    EXAMPLES:

    Sage

        sage: # needs sage.libs.singular
        sage: dP6 = toric_varieties.dP6()
        sage: HH = dP6.cohomology_ring()
        sage: D = [ HH(c) for c in dP6.fan(dim=1) ]
        sage: matrix([ [ D[i]*D[j] for i in range(0,6) ] for j in range(0,6) ])
        [ [w^2] [-w^2]    [0]    [0]    [0] [-w^2]]
        [[-w^2]  [w^2] [-w^2]    [0]    [0]    [0]]
        [   [0] [-w^2]  [w^2] [-w^2]    [0]    [0]]
        [   [0]    [0] [-w^2]  [w^2] [-w^2]    [0]]
        [   [0]    [0]    [0] [-w^2]  [w^2] [-w^2]]
        [[-w^2]    [0]    [0]    [0] [-w^2]  [w^2]]
        sage: matrix([ [ dP6.integrate(D[i]*D[j]) for i in range(0,6) ] for j in range(0,6) ])
        [-1  1  0  0  0  1]
        [ 1 -1  1  0  0  0]
        [ 0  1 -1  1  0  0]
        [ 0  0  1 -1  1  0]
        [ 0  0  0  1 -1  1]
        [ 1  0  0  0  1 -1]

    Python

        >>> from sage.all import *
        >>> # needs sage.libs.singular
        >>> dP6 = toric_varieties.dP6()
        >>> HH = dP6.cohomology_ring()
        >>> D = [ HH(c) for c in dP6.fan(dim=Integer(1)) ]
        >>> matrix([ [ D[i]*D[j] for i in range(Integer(0),Integer(6)) ] for j in range(Integer(0),Integer(6)) ])
        [ [w^2] [-w^2]    [0]    [0]    [0] [-w^2]]
        [[-w^2]  [w^2] [-w^2]    [0]    [0]    [0]]
        [   [0] [-w^2]  [w^2] [-w^2]    [0]    [0]]
        [   [0]    [0] [-w^2]  [w^2] [-w^2]    [0]]
        [   [0]    [0]    [0] [-w^2]  [w^2] [-w^2]]
        [[-w^2]    [0]    [0]    [0] [-w^2]  [w^2]]
        >>> matrix([ [ dP6.integrate(D[i]*D[j]) for i in range(Integer(0),Integer(6)) ] for j in range(Integer(0),Integer(6)) ])
        [-1  1  0  0  0  1]
        [ 1 -1  1  0  0  0]
        [ 0  1 -1  1  0  0]
        [ 0  0  1 -1  1  0]
        [ 0  0  0  1 -1  1]
        [ 1  0  0  0  1 -1]

    If the toric variety is an orbifold, the intersection numbers are usually fractional:

    Sage

        sage: # needs sage.libs.singular
        sage: P2_123 = toric_varieties.P2_123()
        sage: HH = P2_123.cohomology_ring()
        sage: D = [ HH(c) for c in P2_123.fan(dim=1) ]
        sage: matrix([ [ P2_123.integrate(D[i]*D[j]) for i in range(0,3) ] for j in range(0,3) ])
        [2/3   1 1/3]
        [  1 3/2 1/2]
        [1/3 1/2 1/6]
        sage: A = P2_123.Chow_group(QQ)
        sage: matrix([ [ A(P2_123.divisor(i))
        ....:            .intersection_with_divisor(P2_123.divisor(j))
        ....:            .count_points() for i in range(0,3) ] for j in range(0,3) ])
        [2/3   1 1/3]
        [  1 3/2 1/2]
        [1/3 1/2 1/6]

    [Python]

        >>> from sage.all import *
        >>> # needs sage.libs.singular
        >>> P2_123 = toric_varieties.P2_123()
        >>> HH = P2_123.cohomology_ring()
        >>> D = [ HH(c) for c in P2_123.fan(dim=Integer(1)) ]
        >>> matrix([ [ P2_123.integrate(D[i]*D[j]) for i in range(Integer(0),Integer(3)) ] for j in range(Integer(0),Integer(3)) ])
        [2/3   1 1/3]
        [  1 3/2 1/2]
        [1/3 1/2 1/6]
        >>> A = P2_123.Chow_group(QQ)
        >>> matrix([ [ A(P2_123.divisor(i))
        ...            .intersection_with_divisor(P2_123.divisor(j))
        ...            .count_points() for i in range(Integer(0),Integer(3)) ] for j in range(Integer(0),Integer(3)) ])
        [2/3   1 1/3]
        [  1 3/2 1/2]
        [1/3 1/2 1/6]

  is_affine()

    Check if `self` is an affine toric variety.

    An affine toric variety is a toric variety whose fan is the face lattice of a single cone. See also `AffineToricVariety()`.

    OUTPUT: boolean

    EXAMPLES:

    Sage

        sage: toric_varieties.A2().is_affine()
        True
        sage: toric_varieties.P1xA1().is_affine()
        False

    Python

        >>> from sage.all import *
        >>> toric_varieties.A2().is_affine()
        True
        >>> toric_varieties.P1xA1().is_affine()
        False

  is_complete()

    Check if `self` is complete.

    OUTPUT: `True` if `self` is complete and `False` otherwise

    EXAMPLES:

    Sage

        sage: P1xP1 = toric_varieties.P1xP1()
        sage: P1xP1.is_complete()
        True
        sage: P1xP1.affine_patch(0).is_complete()
        False

    Python

        >>> from sage.all import *
        >>> P1xP1 = toric_varieties.P1xP1()
        >>> P1xP1.is_complete()
        True
        >>> P1xP1.affine_patch(Integer(0)).is_complete()
        False

  is_homogeneous(polynomial)

    Check if `polynomial` is homogeneous.

    The coordinate ring of a toric variety is multigraded by relations between generating rays of the underlying fan.

    INPUT:

    - `polynomial` – polynomial in the coordinate ring of `self` or its quotient

    OUTPUT: `True` if `polynomial` is homogeneous and `False` otherwise

    EXAMPLES:

    We will use the product of two projective lines with coordinates \((x, y)\) for one and \((s, t)\) for the other:

    Sage

        sage: P1xP1.<x,y,s,t> = toric_varieties.P1xP1()
        sage: P1xP1.is_homogeneous(x - y)
        True
        sage: P1xP1.is_homogeneous(x*s + y*t)
        True
        sage: P1xP1.is_homogeneous(x - t)
        False
        sage: P1xP1.is_homogeneous(1)
        True

    Python

        >>> from sage.all import *
        >>> P1xP1 = toric_varieties.P1xP1(names=('x', 'y', 's', 't',)); (x, y, s, t,) = P1xP1._first_ngens(4)
        >>> P1xP1.is_homogeneous(x - y)
        True
        >>> P1xP1.is_homogeneous(x*s + y*t)
        True
        >>> P1xP1.is_homogeneous(x - t)
        False
        >>> P1xP1.is_homogeneous(Integer(1))
        True

    Note that by homogeneous, we mean well-defined with respect to 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:

    Sage

        sage: A1.<z> = toric_varieties.A1()
        sage: A1.is_homogeneous(z^3 + z^7)
        True

    [Python]

        >>> from sage.all import *
        >>> A1 = toric_varieties.A1(names=('z',)); (z,) = A1._first_ngens(1)
        >>> A1.is_homogeneous(z**Integer(3) + z**Integer(7))
        True

    Finally, the degree group is really the Chow group \(A_{d-1}(X)\) and can contain torsion. For example, take \(\CC^2/\ZZ_2\). Here, the Chow group is \(A_{d-1}(\CC^2/\ZZ_2) = \ZZ_2\) and distinguishes even-degree homogeneous polynomials from odd-degree homogeneous polynomials:

    Sage

        sage: A2_Z2.<x,y> = toric_varieties.A2_Z2()
        sage: A2_Z2.is_homogeneous(x + y + x^3 + y^5 + x^3*y^4)
        True
        sage: A2_Z2.is_homogeneous(x^2 + x*y + y^4 + (x*y)^5 + x^4*y^4)
        True
        sage: A2_Z2.is_homogeneous(x + y^2)
        False

    Python

        >>> from sage.all import *
        >>> A2_Z2 = toric_varieties.A2_Z2(names=('x', 'y',)); (x, y,) = A2_Z2._first_ngens(2)
        >>> A2_Z2.is_homogeneous(x + y + x**Integer(3) + y**Integer(5) + x**Integer(3)*y**Integer(4))
        True
        >>> A2_Z2.is_homogeneous(x**Integer(2) + x*y + y**Integer(4) + (x*y)**Integer(5) + x**Integer(4)*y**Integer(4))
        True
        >>> A2_Z2.is_homogeneous(x + y**Integer(2))
        False

  is_isomorphic(another)

    Check if `self` is isomorphic to `another`.

    INPUT:

    - `another` – `toric variety`

    OUTPUT:

    - `True` if `self` and `another` are isomorphic, `False` otherwise.

    EXAMPLES:

    Sage

        sage: TV1 = toric_varieties.P1xA1()
        sage: TV2 = toric_varieties.P1xP1()

    Python

        >>> from sage.all import *
        >>> TV1 = toric_varieties.P1xA1()
        >>> TV2 = toric_varieties.P1xP1()

    Only the most trivial case is implemented so far:

    Sage

        sage: TV1.is_isomorphic(TV1)
        True
        sage: TV1.is_isomorphic(TV2)
        Traceback (most recent call last):
        ...
        NotImplementedError: isomorphism check is not yet implemented

    [Python]

        >>> from sage.all import *
        >>> TV1.is_isomorphic(TV1)
        True
        >>> TV1.is_isomorphic(TV2)
        Traceback (most recent call last):
        ...
        NotImplementedError: isomorphism check is not yet implemented

  is_orbifold()

    Check if `self` has only quotient singularities.

    A toric variety with at most orbifold singularities (in this sense) is often called a simplicial toric variety. In this package, we generally try to avoid this term since it mixes up differential geometry and cone terminology.

    OUTPUT:

    - `True` if `self` has at most quotient singularities by finite groups, `False` otherwise.

    EXAMPLES:

    Sage

        sage: fan1 = FaceFan(lattice_polytope.cross_polytope(2))
        sage: P1xP1 = ToricVariety(fan1)
        sage: P1xP1.is_orbifold()
        True
        sage: fan2 = NormalFan(lattice_polytope.cross_polytope(3))
        sage: TV = ToricVariety(fan2)
        sage: TV.is_orbifold()
        False

    Python

        >>> from sage.all import *
        >>> fan1 = FaceFan(lattice_polytope.cross_polytope(Integer(2)))
        >>> P1xP1 = ToricVariety(fan1)
        >>> P1xP1.is_orbifold()
        True
        >>> fan2 = NormalFan(lattice_polytope.cross_polytope(Integer(3)))
        >>> TV = ToricVariety(fan2)
        >>> TV.is_orbifold()
        False

  is_smooth()

    Check if `self` is smooth.

    OUTPUT: `True` if `self` is smooth and `False` otherwise

    EXAMPLES:

    Sage

        sage: fan1 = FaceFan(lattice_polytope.cross_polytope(2))
        sage: P1xP1 = ToricVariety(fan1)
        sage: P1xP1.is_smooth()
        True
        sage: fan2 = NormalFan(lattice_polytope.cross_polytope(2))
        sage: TV = ToricVariety(fan2)
        sage: TV.is_smooth()
        False

    Python

        >>> from sage.all import *
        >>> fan1 = FaceFan(lattice_polytope.cross_polytope(Integer(2)))
        >>> P1xP1 = ToricVariety(fan1)
        >>> P1xP1.is_smooth()
        True
        >>> fan2 = NormalFan(lattice_polytope.cross_polytope(Integer(2)))
        >>> TV = ToricVariety(fan2)
        >>> TV.is_smooth()
        False

  linear_equivalence_ideal()

    Return the ideal generated by linear relations.

    OUTPUT:

    - The ideal generated by the linear relations of the rays in the polynomial ring over \(\QQ\) generated by the homogeneous coordinates.

    EXAMPLES:

    Sage

        sage: fan = Fan([[0,1,3], [3,4], [2,0], [1,2,4]],
        ....:           [(-3, -2, 1), (0, 0, 1), (3, -2, 1), (-1, -1, 1), (1, -1, 1)])
        sage: X = ToricVariety(fan, coordinate_names='A B C D E', base_field=GF(5))
        sage: lin = X.linear_equivalence_ideal(); lin
        Ideal (-3*A + 3*C - D + E, -2*A - 2*C - D - E, A + B + C + D + E) of
         Multivariate Polynomial Ring in A, B, C, D, E over Rational Field

    Python

        >>> from sage.all import *
        >>> fan = Fan([[Integer(0),Integer(1),Integer(3)], [Integer(3),Integer(4)], [Integer(2),Integer(0)], [Integer(1),Integer(2),Integer(4)]],
        ...           [(-Integer(3), -Integer(2), Integer(1)), (Integer(0), Integer(0), Integer(1)), (Integer(3), -Integer(2), Integer(1)), (-Integer(1), -Integer(1), Integer(1)), (Integer(1), -Integer(1), Integer(1))])
        >>> X = ToricVariety(fan, coordinate_names='A B C D E', base_field=GF(Integer(5)))
        >>> lin = X.linear_equivalence_ideal(); lin
        Ideal (-3*A + 3*C - D + E, -2*A - 2*C - D - E, A + B + C + D + E) of
         Multivariate Polynomial Ring in A, B, C, D, E over Rational Field

  orbit_closure(cone)

    Return the orbit closure of `cone`.

    The cones \(\sigma\) of a fan \(\Sigma\) are in one-to-one correspondence with the torus orbits \(O(\sigma)\) of the corresponding toric variety \(X_\Sigma\). Each orbit is isomorphic to a lower dimensional torus (of dimension equal to the codimension of \(\sigma\)). Just like the toric variety \(X_\Sigma\) itself, these orbits are (partially) compactified by lower-dimensional orbits. In particular, one can define the closure \(V(\sigma)\) of the torus orbit \(O(\sigma)\) in the ambient toric variety \(X_\Sigma\), which is again a toric variety.

    See Proposition 3.2.7 of [CLS2011] for more details.

    INPUT:

    - `cone` – a `cone` of the fan

    OUTPUT:

    - a torus orbit closure associated to `cone` as a `toric variety`.

    EXAMPLES:

    Sage

        sage: P1xP1 = toric_varieties.P1xP1()
        sage: H = P1xP1.fan(1)[0]
        sage: V = P1xP1.orbit_closure(H);  V
        1-d toric variety covered by 2 affine patches
        sage: V.embedding_morphism()
        Scheme morphism:
          From: 1-d toric variety covered by 2 affine patches
          To:   2-d CPR-Fano toric variety covered by 4 affine patches
          Defn: Defined by embedding the torus closure associated to the 1-d
                cone of Rational polyhedral fan in 2-d lattice N.
        sage: V.embedding_morphism().as_polynomial_map()
        Scheme morphism:
          From: 1-d toric variety covered by 2 affine patches
          To:   2-d CPR-Fano toric variety covered by 4 affine patches
          Defn: Defined on coordinates by sending [z0 : z1] to [0 : 1 : z1 : z0]

    Python

        >>> from sage.all import *
        >>> P1xP1 = toric_varieties.P1xP1()
        >>> H = P1xP1.fan(Integer(1))[Integer(0)]
        >>> V = P1xP1.orbit_closure(H);  V
        1-d toric variety covered by 2 affine patches
        >>> V.embedding_morphism()
        Scheme morphism:
          From: 1-d toric variety covered by 2 affine patches
          To:   2-d CPR-Fano toric variety covered by 4 affine patches
          Defn: Defined by embedding the torus closure associated to the 1-d
                cone of Rational polyhedral fan in 2-d lattice N.
        >>> V.embedding_morphism().as_polynomial_map()
        Scheme morphism:
          From: 1-d toric variety covered by 2 affine patches
          To:   2-d CPR-Fano toric variety covered by 4 affine patches
          Defn: Defined on coordinates by sending [z0 : z1] to [0 : 1 : z1 : z0]

  plot(**options)

    Plot `self`, i.e. the corresponding fan.

    INPUT:

    - any options for toric plots (see `toric_plotter.options`), none are mandatory.

    OUTPUT: a plot

    Note

    The difference between `X.plot()` and `X.fan().plot()` is that in the first case default ray labels correspond to variables of `X`.

    EXAMPLES:

    Sage

        sage: X = toric_varieties.Cube_deformation(4)
        sage: X.plot()                                                              # needs sage.plot
        Graphics3d Object

    Python

        >>> from sage.all import *
        >>> X = toric_varieties.Cube_deformation(Integer(4))
        >>> X.plot()                                                              # needs sage.plot
        Graphics3d Object

  rational_class_group()

    Return the rational divisor class group of `self`.

    Let \(X\) be a toric variety.

    The Weil divisor class group \(\mathop{Cl}(X)\) is a finitely generated abelian group and can contain torsion. Its rank equals the number of rays in the fan of \(X\) minus the dimension of \(X\).

    The rational divisor class group is \(\mathop{Cl}(X) \otimes_\ZZ \QQ\) and never includes torsion. If \(X\) is smooth, this equals the Picard group of \(X\), whose elements are the isomorphism classes of line bundles on \(X\). The group law (which we write as addition) is the tensor product of the line bundles. The Picard group of a toric variety is always torsion-free.

    OUTPUT: `rational divisor class group`.

    Note

    - Coordinates correspond to the rows of `self.fan().gale_transform()`.

    - `Kaehler_cone()` yields a cone in this group.

    EXAMPLES:

    Sage

        sage: P1xA1 = toric_varieties.P1xA1()
        sage: P1xA1.rational_class_group()
        The toric rational divisor class group
        of a 2-d toric variety covered by 2 affine patches

    Python

        >>> from sage.all import *
        >>> P1xA1 = toric_varieties.P1xA1()
        >>> P1xA1.rational_class_group()
        The toric rational divisor class group
        of a 2-d toric variety covered by 2 affine patches

  resolve(**kwds)

    Construct a toric variety whose fan subdivides the fan of `self`.

    The name of this function reflects the fact that usually such subdivisions are done for resolving singularities of the original variety.

    INPUT:

    This function accepts only keyword arguments, none of which are mandatory.

    - `coordinate_names` – names for coordinates of the new variety. If not given, will be constructed from the coordinate names of `self` and necessary indexed ones. See `normalize_names()` for the description of acceptable formats.

    - `coordinate_indices` – coordinate indices which should be used for indexed variables of the new variety

    - all other arguments will be passed to `subdivide()` method of the underlying `rational polyhedral fan`, see its documentation for the available options.

    OUTPUT: a `toric variety`

    EXAMPLES:

    First we will “manually” resolve a simple orbifold singularity:

    Sage

        sage: cone = Cone([(1,1), (-1,1)])
        sage: fan = Fan([cone])
        sage: TV = ToricVariety(fan)
        sage: TV.is_smooth()
        False
        sage: TV_res = TV.resolve(new_rays=[(0,1)])
        sage: TV_res.is_smooth()
        True
        sage: TV_res.fan().rays()
        N( 1, 1),
        N(-1, 1),
        N( 0, 1)
        in 2-d lattice N
        sage: [cone.ambient_ray_indices() for cone in TV_res.fan()]
        [(0, 2), (1, 2)]

    Python

        >>> from sage.all import *
        >>> cone = Cone([(Integer(1),Integer(1)), (-Integer(1),Integer(1))])
        >>> fan = Fan([cone])
        >>> TV = ToricVariety(fan)
        >>> TV.is_smooth()
        False
        >>> TV_res = TV.resolve(new_rays=[(Integer(0),Integer(1))])
        >>> TV_res.is_smooth()
        True
        >>> TV_res.fan().rays()
        N( 1, 1),
        N(-1, 1),
        N( 0, 1)
        in 2-d lattice N
        >>> [cone.ambient_ray_indices() for cone in TV_res.fan()]
        [(0, 2), (1, 2)]

    Now let’s “automatically” partially resolve a more complicated fan:

    Sage

        sage: fan = NormalFan(lattice_polytope.cross_polytope(3))
        sage: TV = ToricVariety(fan)
        sage: TV.is_smooth()
        False
        sage: TV.is_orbifold()
        False
        sage: TV.fan().nrays()
        8
        sage: TV.fan().ngenerating_cones()
        6
        sage: TV_res = TV.resolve(make_simplicial=True)
        sage: TV_res.is_smooth()
        False
        sage: TV_res.is_orbifold()
        True
        sage: TV_res.fan().nrays()
        8
        sage: TV_res.fan().ngenerating_cones()
        12
        sage: TV.gens()
        (z0, z1, z2, z3, z4, z5, z6, z7)
        sage: TV_res.gens()
        (z0, z1, z2, z3, z4, z5, z6, z7)
        sage: TV_res = TV.resolve(coordinate_names='x+',
        ....:                     make_simplicial=True)
        sage: TV_res.gens()
        (x0, x1, x2, x3, x4, x5, x6, x7)

    [Python]

        >>> from sage.all import *
        >>> fan = NormalFan(lattice_polytope.cross_polytope(Integer(3)))
        >>> TV = ToricVariety(fan)
        >>> TV.is_smooth()
        False
        >>> TV.is_orbifold()
        False
        >>> TV.fan().nrays()
        8
        >>> TV.fan().ngenerating_cones()
        6
        >>> TV_res = TV.resolve(make_simplicial=True)
        >>> TV_res.is_smooth()
        False
        >>> TV_res.is_orbifold()
        True
        >>> TV_res.fan().nrays()
        8
        >>> TV_res.fan().ngenerating_cones()
        12
        >>> TV.gens()
        (z0, z1, z2, z3, z4, z5, z6, z7)
        >>> TV_res.gens()
        (z0, z1, z2, z3, z4, z5, z6, z7)
        >>> TV_res = TV.resolve(coordinate_names='x+',
        ...                     make_simplicial=True)
        >>> TV_res.gens()
        (x0, x1, x2, x3, x4, x5, x6, x7)

  resolve_to_orbifold(**kwds)

    Construct an orbifold whose fan subdivides the fan of `self`.

    It is a synonym for `resolve()` with `make_simplicial=True` option.

    INPUT:

    - this function accepts only keyword arguments. See `resolve()` for documentation.

    OUTPUT: a `toric variety`

    EXAMPLES:

    Sage

        sage: fan = NormalFan(lattice_polytope.cross_polytope(3))
        sage: TV = ToricVariety(fan)
        sage: TV.is_orbifold()
        False
        sage: TV.fan().nrays()
        8
        sage: TV.fan().ngenerating_cones()
        6
        sage: TV_res = TV.resolve_to_orbifold()
        sage: TV_res.is_orbifold()
        True
        sage: TV_res.fan().nrays()
        8
        sage: TV_res.fan().ngenerating_cones()
        12

    Python

        >>> from sage.all import *
        >>> fan = NormalFan(lattice_polytope.cross_polytope(Integer(3)))
        >>> TV = ToricVariety(fan)
        >>> TV.is_orbifold()
        False
        >>> TV.fan().nrays()
        8
        >>> TV.fan().ngenerating_cones()
        6
        >>> TV_res = TV.resolve_to_orbifold()
        >>> TV_res.is_orbifold()
        True
        >>> TV_res.fan().nrays()
        8
        >>> TV_res.fan().ngenerating_cones()
        12

  property sheaves

    Return the factory object for sheaves on the toric variety.

    See `sage.schemes.toric.sheaf.constructor.SheafLibrary` for details.

    EXAMPLES:

    Sage

        sage: dP6 = toric_varieties.dP6()
        sage: dP6.sheaves
        Sheaf constructor on 2-d CPR-Fano toric variety covered by 6 affine patches
        sage: dP6.sheaves.trivial_bundle()
        Rank 1 bundle on 2-d CPR-Fano toric variety covered by 6 affine patches.

    Python

        >>> from sage.all import *
        >>> dP6 = toric_varieties.dP6()
        >>> dP6.sheaves
        Sheaf constructor on 2-d CPR-Fano toric variety covered by 6 affine patches
        >>> dP6.sheaves.trivial_bundle()
        Rank 1 bundle on 2-d CPR-Fano toric variety covered by 6 affine patches.

  subscheme(polynomials)

    Return the subscheme of `self` defined by `polynomials`.

    INPUT:

    - `polynomials` – list of polynomials in the coordinate ring of `self`

    OUTPUT: a `subscheme of a toric variety`.

    EXAMPLES:

    We will construct a subscheme of the product of two projective lines with coordinates \((x, y)\) for one and \((s, t)\) for the other:

    Sage

        sage: P1xP1.<x,y,s,t> = toric_varieties.P1xP1()
        sage: X = P1xP1.subscheme([x*s + y*t, x^3 + y^3])
        sage: X
        Closed subscheme of 2-d CPR-Fano toric variety
        covered by 4 affine patches defined by:
          x*s + y*t,
          x^3 + y^3
        sage: X.defining_polynomials()
        (x*s + y*t, x^3 + y^3)
        sage: X.defining_ideal()
        Ideal (x*s + y*t, x^3 + y^3) of
         Multivariate Polynomial Ring in x, y, s, t over Rational Field
        sage: X.base_ring()
        Rational Field
        sage: X.base_scheme()
        Spectrum of Rational Field
        sage: X.structure_morphism()
        Scheme morphism:
          From: Closed subscheme of 2-d CPR-Fano toric variety
                covered by 4 affine patches defined by: x*s + y*t, x^3 + y^3
          To:   Spectrum of Rational Field
          Defn: Structure map

    Python

        >>> from sage.all import *
        >>> P1xP1 = toric_varieties.P1xP1(names=('x', 'y', 's', 't',)); (x, y, s, t,) = P1xP1._first_ngens(4)
        >>> X = P1xP1.subscheme([x*s + y*t, x**Integer(3) + y**Integer(3)])
        >>> X
        Closed subscheme of 2-d CPR-Fano toric variety
        covered by 4 affine patches defined by:
          x*s + y*t,
          x^3 + y^3
        >>> X.defining_polynomials()
        (x*s + y*t, x^3 + y^3)
        >>> X.defining_ideal()
        Ideal (x*s + y*t, x^3 + y^3) of
         Multivariate Polynomial Ring in x, y, s, t over Rational Field
        >>> X.base_ring()
        Rational Field
        >>> X.base_scheme()
        Spectrum of Rational Field
        >>> X.structure_morphism()
        Scheme morphism:
          From: Closed subscheme of 2-d CPR-Fano toric variety
                covered by 4 affine patches defined by: x*s + y*t, x^3 + y^3
          To:   Spectrum of Rational Field
          Defn: Structure map

  toric_divisor_group(base_ring=Integer Ring)

    Return the group of toric (T-Weil) divisors.

    INPUT:

    - `base_ring` – the coefficient ring, usually `ZZ` (default) or `QQ`

    OUTPUT:

    The free Abelian agroup of toric Weil divisors, that is, formal `base_ring`-linear combinations of codimension-one toric subvarieties. The output will be an instance of `sage.schemes.toric.divisor.ToricDivisorGroup`.

    The \(i\)-th generator of the divisor group is the divisor where the \(i\)-th homogeneous coordinate vanishes, \(\{z_i=0\}\).

    EXAMPLES:

    Sage

        sage: dP6 = toric_varieties.dP6()
        sage: TDiv = dP6.toric_divisor_group(); TDiv
        Group of toric ZZ-Weil divisors on 2-d CPR-Fano toric variety
        covered by 6 affine patches
        sage: TDiv == dP6.toric_divisor_group()
        True
        sage: TDiv.gens()
        (V(x), V(u), V(y), V(v), V(z), V(w))
        sage: dP6.coordinate_ring()
        Multivariate Polynomial Ring in x, u, y, v, z, w over Rational Field

    Python

        >>> from sage.all import *
        >>> dP6 = toric_varieties.dP6()
        >>> TDiv = dP6.toric_divisor_group(); TDiv
        Group of toric ZZ-Weil divisors on 2-d CPR-Fano toric variety
        covered by 6 affine patches
        >>> TDiv == dP6.toric_divisor_group()
        True
        >>> TDiv.gens()
        (V(x), V(u), V(y), V(v), V(z), V(w))
        >>> dP6.coordinate_ring()
        Multivariate Polynomial Ring in x, u, y, v, z, w over Rational Field

  volume_class()

    Return the cohomology class of the volume form on the toric variety.

    Note that we are using cohomology with compact supports. If the variety is non-compact this is dual to homology without any support condition. In particular, for non-compact varieties the volume form \(\mathrm{dVol}=\wedge_i(dx_i \wedge dy_i)\) does not define a (nonzero) cohomology class.

    OUTPUT:

    A `CohomologyClass`. If it exists, it is the class of the (properly normalized) volume form, that is, it is the Poincaré dual of a single point. If it does not exist, a `ValueError` is raised.

    EXAMPLES:

    Sage

        sage: P2 = toric_varieties.P2()
        sage: P2.volume_class()                                                     # needs sage.libs.singular
        [z^2]

        sage: A2_Z2 = toric_varieties.A2_Z2()
        sage: A2_Z2.volume_class()                                                  # needs sage.libs.singular
        Traceback (most recent call last):
        ...
        ValueError: volume class does not exist

    Python

        >>> from sage.all import *
        >>> P2 = toric_varieties.P2()
        >>> P2.volume_class()                                                     # needs sage.libs.singular
        [z^2]

        >>> A2_Z2 = toric_varieties.A2_Z2()
        >>> A2_Z2.volume_class()                                                  # needs sage.libs.singular
        Traceback (most recent call last):
        ...
        ValueError: volume class does not exist

    If none of the maximal cones is smooth things get more tricky. In this case no torus-fixed point is smooth. If we want to count an ordinary point as \(1\), then a \(G\)-orbifold point needs to count as \(\frac{1}{|G|}\). For example, take \(\mathbb{P}^1\times\mathbb{P}^1\) with inhomogeneous coordinates \((t,y)\). Take the quotient by the action \((t,y)\mapsto (-t,-y)\). The \(\ZZ_2\)-invariant Weil divisors \(\{t=0\}\) and \(\{y=0\}\) intersect in a \(\ZZ_2\)-fixed point, so they ought to have intersection number \(\frac{1}{2}\). This means that the cohomology class \([t] \cap [y]\) should be \(\frac{1}{2}\) times the volume class. Note that this is different from the volume normalization chosen in [KS]:

    Sage

        sage: P1xP1_Z2 = toric_varieties.P1xP1_Z2()
        sage: Dt = P1xP1_Z2.divisor(1);  Dt
        V(t)
        sage: Dy = P1xP1_Z2.divisor(3);  Dy
        V(y)
        sage: P1xP1_Z2.volume_class()                                               # needs sage.libs.singular
        [2*t*y]

        sage: HH = P1xP1_Z2.cohomology_ring()
        sage: HH(Dt) * HH(Dy) == 1/2 * P1xP1_Z2.volume_class()                      # needs sage.libs.singular
        True

    [Python]

        >>> from sage.all import *
        >>> P1xP1_Z2 = toric_varieties.P1xP1_Z2()
        >>> Dt = P1xP1_Z2.divisor(Integer(1));  Dt
        V(t)
        >>> Dy = P1xP1_Z2.divisor(Integer(3));  Dy
        V(y)
        >>> P1xP1_Z2.volume_class()                                               # needs sage.libs.singular
        [2*t*y]

        >>> HH = P1xP1_Z2.cohomology_ring()
        >>> HH(Dt) * HH(Dy) == Integer(1)/Integer(2) * P1xP1_Z2.volume_class()                      # needs sage.libs.singular
        True

    The fractional coefficients are also necessary to match the normalization in the rational Chow group for simplicial toric varieties:

    Sage

        sage: A = P1xP1_Z2.Chow_group(QQ)
        sage: A(Dt).intersection_with_divisor(Dy).count_points()
        1/2

    Python

        >>> from sage.all import *
        >>> A = P1xP1_Z2.Chow_group(QQ)
        >>> A(Dt).intersection_with_divisor(Dy).count_points()
        1/2

sage.schemes.toric.variety.is_CohomologyClass(x)

  Check whether `x` is a cohomology class of a toric variety.

  INPUT:

  - `x` – anything

  OUTPUT:

  `True` or `False` depending on whether `x` is an instance of `CohomologyClass`

  EXAMPLES:

  Sage

      sage: P2 = toric_varieties.P2()
      sage: HH = P2.cohomology_ring()
      sage: from sage.schemes.toric.variety import is_CohomologyClass
      sage: is_CohomologyClass( HH.one() )                                            # needs sage.libs.singular
      doctest:warning...
      DeprecationWarning: The function is_CohomologyClass is deprecated;
      use 'isinstance(..., CohomologyClass)' instead.
      See https://github.com/sagemath/sage/issues/38277 for details.
      True
      sage: is_CohomologyClass( HH(P2.fan(1)[0]) )                                    # needs sage.libs.singular
      True
      sage: is_CohomologyClass('z')
      False

  Python

      >>> from sage.all import *
      >>> P2 = toric_varieties.P2()
      >>> HH = P2.cohomology_ring()
      >>> from sage.schemes.toric.variety import is_CohomologyClass
      >>> is_CohomologyClass( HH.one() )                                            # needs sage.libs.singular
      doctest:warning...
      DeprecationWarning: The function is_CohomologyClass is deprecated;
      use 'isinstance(..., CohomologyClass)' instead.
      See https://github.com/sagemath/sage/issues/38277 for details.
      True
      >>> is_CohomologyClass( HH(P2.fan(Integer(1))[Integer(0)]) )                                    # needs sage.libs.singular
      True
      >>> is_CohomologyClass('z')
      False

sage.schemes.toric.variety.is_ToricVariety(x)

  Check if `x` is a toric variety.

  INPUT:

  - `x` – anything

  OUTPUT:

  - `True` if `x` is a `toric variety` and `False` otherwise.

  Note

  While projective spaces are toric varieties mathematically, they are not toric varieties in Sage due to efficiency considerations, so this function will return `False`.

  EXAMPLES:

  Sage

      sage: from sage.schemes.toric.variety import is_ToricVariety
      sage: is_ToricVariety(1)
      doctest:warning...
      DeprecationWarning: The function is_ToricVariety is deprecated; use 'isinstance(..., ToricVariety_field)' instead.
      See https://github.com/sagemath/sage/issues/38022 for details.
      False
      sage: fan = FaceFan(lattice_polytope.cross_polytope(2))
      sage: P = ToricVariety(fan)
      sage: P
      2-d toric variety covered by 4 affine patches
      sage: is_ToricVariety(P)
      True
      sage: is_ToricVariety(ProjectiveSpace(2))
      False

  Python

      >>> from sage.all import *
      >>> from sage.schemes.toric.variety import is_ToricVariety
      >>> is_ToricVariety(Integer(1))
      doctest:warning...
      DeprecationWarning: The function is_ToricVariety is deprecated; use 'isinstance(..., ToricVariety_field)' instead.
      See https://github.com/sagemath/sage/issues/38022 for details.
      False
      >>> fan = FaceFan(lattice_polytope.cross_polytope(Integer(2)))
      >>> P = ToricVariety(fan)
      >>> P
      2-d toric variety covered by 4 affine patches
      >>> is_ToricVariety(P)
      True
      >>> is_ToricVariety(ProjectiveSpace(Integer(2)))
      False

sage.schemes.toric.variety.normalize_names(names=None, ngens=None, prefix=None, indices=None, return_prefix=False)

  Return a list of names in the standard form.

  INPUT:

  All input parameters are optional.

  - `names` – names given either as a single string (with individual names separated by commas or spaces) or a list of strings with each string specifying a name. If the last name ends with the plus sign, “+”, this name will be used as `prefix` (even if `prefix` was given explicitly).

  - `ngens` – number of names to be returned

  - `prefix` – prefix for the indexed names given as a string

  - `indices` – list of integers (default: `range(ngens)`) used as indices for names with `prefix`. If given, must be of length `ngens`.

  - `return_prefix` – if `True`, the last element of the returned list will contain the prefix determined from `names` or given as the parameter `prefix`. This is useful if you may need more names in the future.

  OUTPUT: list of names given as strings

  These names are constructed in the following way:

  1. If necessary, split `names` into separate names.

  2. If the last name ends with “+”, put it into `prefix`.

  3. If `ngens` was given, add to the names obtained so far as many indexed names as necessary to get this number. If the `k`-th name of the total list of names is indexed, it is `prefix + str(indices[k])`. If there were already more names than `ngens`, discard “extra” ones.

  4. Check if constructed names are valid. See `certify_names()` for details.

  5. If the option `return_prefix=True` was given, add `prefix` to the end of the list.

  EXAMPLES:

  As promised, all parameters are optional:

  Sage

      sage: from sage.schemes.toric.variety import normalize_names
      sage: normalize_names()
      []

  Python

      >>> from sage.all import *
      >>> from sage.schemes.toric.variety import normalize_names
      >>> normalize_names()
      []

  One of the most common uses is probably this one:

  Sage

      sage: normalize_names("x+", 4)
      ['x0', 'x1', 'x2', 'x3']

  [Python]

      >>> from sage.all import *
      >>> normalize_names("x+", Integer(4))
      ['x0', 'x1', 'x2', 'x3']

  Now suppose that you want to enumerate your variables starting with one instead of zero:

  Sage

      sage: normalize_names("x+", 4, indices=list(range(1,5)))
      ['x1', 'x2', 'x3', 'x4']

  Python

      >>> from sage.all import *
      >>> normalize_names("x+", Integer(4), indices=list(range(Integer(1),Integer(5))))
      ['x1', 'x2', 'x3', 'x4']

  You may actually have an arbitrary enumeration scheme:

  Sage

      sage: normalize_names("x+", 4, indices=[1, 10, 100, 1000])
      ['x1', 'x10', 'x100', 'x1000']

  [Python]

      >>> from sage.all import *
      >>> normalize_names("x+", Integer(4), indices=[Integer(1), Integer(10), Integer(100), Integer(1000)])
      ['x1', 'x10', 'x100', 'x1000']

  Now let’s add some “explicit” names:

  Sage

      sage: normalize_names("x y z t+", 4)
      ['x', 'y', 'z', 't3']

  Python

      >>> from sage.all import *
      >>> normalize_names("x y z t+", Integer(4))
      ['x', 'y', 'z', 't3']

  Note that the “automatic” name is `t3` instead of `t0`. This may seem weird, but the reason for this behaviour is that the fourth name in this list will be the same no matter how many explicit names were given:

  Sage

      sage: normalize_names("x y t+", 4)
      ['x', 'y', 't2', 't3']

  [Python]

      >>> from sage.all import *
      >>> normalize_names("x y t+", Integer(4))
      ['x', 'y', 't2', 't3']

  This is especially useful if you get `names` from a user but want to specify all default names:

  Sage

      sage: normalize_names("x, y", 4, prefix='t')
      ['x', 'y', 't2', 't3']

  Python

      >>> from sage.all import *
      >>> normalize_names("x, y", Integer(4), prefix='t')
      ['x', 'y', 't2', 't3']

  In this format, the user can easily override your choice for automatic names:

  Sage

      sage: normalize_names("x y s+", 4, prefix='t')
      ['x', 'y', 's2', 's3']

  [Python]

      >>> from sage.all import *
      >>> normalize_names("x y s+", Integer(4), prefix='t')
      ['x', 'y', 's2', 's3']

  Let’s now use all parameters at once:

  Sage

      sage: normalize_names("x, y, s+", 4, prefix='t',
      ....:     indices=list(range(1,5)), return_prefix=True)
      ['x', 'y', 's3', 's4', 's']

  Python

      >>> from sage.all import *
      >>> normalize_names("x, y, s+", Integer(4), prefix='t',
      ...     indices=list(range(Integer(1),Integer(5))), return_prefix=True)
      ['x', 'y', 's3', 's4', 's']

  Note that you still need to give indices for all names, even if some of the first ones will be “wasted” because of the explicit names. The reason is the same as before - this ensures consistency of automatically generated names, no matter how many explicit names were given.

  The prefix is discarded if `ngens` was not given:

  Sage

      sage: normalize_names("alpha, beta, gamma, zeta+")
      ['alpha', 'beta', 'gamma']

  [Python]

      >>> from sage.all import *
      >>> normalize_names("alpha, beta, gamma, zeta+")
      ['alpha', 'beta', 'gamma']

  Finally, let’s take a look at some possible mistakes:

  Sage

      sage: normalize_names("123")
      Traceback (most recent call last):
      ...
      ValueError: variable name '123' does not start with a letter

  Python

      >>> from sage.all import *
      >>> normalize_names("123")
      Traceback (most recent call last):
      ...
      ValueError: variable name '123' does not start with a letter

  A more subtle one:

  Sage

      sage: normalize_names("x1", 4, prefix='x')
      Traceback (most recent call last):
      ...
      ValueError: variable name 'x1' appears more than once

  [Python]

      >>> from sage.all import *
      >>> normalize_names("x1", Integer(4), prefix='x')
      Traceback (most recent call last):
      ...
      ValueError: variable name 'x1' appears more than once