passagemath-polyhedra 10.6.31rc3__cp314-cp314-macosx_13_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of passagemath-polyhedra might be problematic. Click here for more details.

Files changed (205) hide show
  1. passagemath_polyhedra-10.6.31rc3.dist-info/METADATA +368 -0
  2. passagemath_polyhedra-10.6.31rc3.dist-info/METADATA.bak +371 -0
  3. passagemath_polyhedra-10.6.31rc3.dist-info/RECORD +205 -0
  4. passagemath_polyhedra-10.6.31rc3.dist-info/WHEEL +6 -0
  5. passagemath_polyhedra-10.6.31rc3.dist-info/top_level.txt +2 -0
  6. passagemath_polyhedra.dylibs/libgmp.10.dylib +0 -0
  7. sage/all__sagemath_polyhedra.py +50 -0
  8. sage/game_theory/all.py +8 -0
  9. sage/game_theory/catalog.py +6 -0
  10. sage/game_theory/catalog_normal_form_games.py +923 -0
  11. sage/game_theory/cooperative_game.py +844 -0
  12. sage/game_theory/matching_game.py +1181 -0
  13. sage/game_theory/normal_form_game.py +2697 -0
  14. sage/game_theory/parser.py +275 -0
  15. sage/geometry/all__sagemath_polyhedra.py +22 -0
  16. sage/geometry/cone.py +6940 -0
  17. sage/geometry/cone_catalog.py +847 -0
  18. sage/geometry/cone_critical_angles.py +1027 -0
  19. sage/geometry/convex_set.py +1119 -0
  20. sage/geometry/fan.py +3743 -0
  21. sage/geometry/fan_isomorphism.py +389 -0
  22. sage/geometry/fan_morphism.py +1884 -0
  23. sage/geometry/hasse_diagram.py +202 -0
  24. sage/geometry/hyperplane_arrangement/affine_subspace.py +390 -0
  25. sage/geometry/hyperplane_arrangement/all.py +1 -0
  26. sage/geometry/hyperplane_arrangement/arrangement.py +3895 -0
  27. sage/geometry/hyperplane_arrangement/check_freeness.py +145 -0
  28. sage/geometry/hyperplane_arrangement/hyperplane.py +773 -0
  29. sage/geometry/hyperplane_arrangement/library.py +825 -0
  30. sage/geometry/hyperplane_arrangement/ordered_arrangement.py +642 -0
  31. sage/geometry/hyperplane_arrangement/plot.py +520 -0
  32. sage/geometry/integral_points.py +35 -0
  33. sage/geometry/integral_points_generic_dense.cpython-314-darwin.so +0 -0
  34. sage/geometry/integral_points_generic_dense.pyx +7 -0
  35. sage/geometry/lattice_polytope.py +5894 -0
  36. sage/geometry/linear_expression.py +773 -0
  37. sage/geometry/newton_polygon.py +767 -0
  38. sage/geometry/point_collection.cpython-314-darwin.so +0 -0
  39. sage/geometry/point_collection.pyx +1008 -0
  40. sage/geometry/polyhedral_complex.py +2616 -0
  41. sage/geometry/polyhedron/all.py +8 -0
  42. sage/geometry/polyhedron/backend_cdd.py +460 -0
  43. sage/geometry/polyhedron/backend_cdd_rdf.py +231 -0
  44. sage/geometry/polyhedron/backend_field.py +347 -0
  45. sage/geometry/polyhedron/backend_normaliz.py +2503 -0
  46. sage/geometry/polyhedron/backend_number_field.py +168 -0
  47. sage/geometry/polyhedron/backend_polymake.py +765 -0
  48. sage/geometry/polyhedron/backend_ppl.py +582 -0
  49. sage/geometry/polyhedron/base.py +1206 -0
  50. sage/geometry/polyhedron/base0.py +1444 -0
  51. sage/geometry/polyhedron/base1.py +886 -0
  52. sage/geometry/polyhedron/base2.py +812 -0
  53. sage/geometry/polyhedron/base3.py +1845 -0
  54. sage/geometry/polyhedron/base4.py +1262 -0
  55. sage/geometry/polyhedron/base5.py +2700 -0
  56. sage/geometry/polyhedron/base6.py +1741 -0
  57. sage/geometry/polyhedron/base7.py +997 -0
  58. sage/geometry/polyhedron/base_QQ.py +1258 -0
  59. sage/geometry/polyhedron/base_RDF.py +98 -0
  60. sage/geometry/polyhedron/base_ZZ.py +934 -0
  61. sage/geometry/polyhedron/base_mutable.py +215 -0
  62. sage/geometry/polyhedron/base_number_field.py +122 -0
  63. sage/geometry/polyhedron/cdd_file_format.py +155 -0
  64. sage/geometry/polyhedron/combinatorial_polyhedron/all.py +1 -0
  65. sage/geometry/polyhedron/combinatorial_polyhedron/base.cpython-314-darwin.so +0 -0
  66. sage/geometry/polyhedron/combinatorial_polyhedron/base.pxd +76 -0
  67. sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx +3859 -0
  68. sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.cpython-314-darwin.so +0 -0
  69. sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pxd +39 -0
  70. sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pyx +1038 -0
  71. sage/geometry/polyhedron/combinatorial_polyhedron/conversions.cpython-314-darwin.so +0 -0
  72. sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pxd +9 -0
  73. sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pyx +501 -0
  74. sage/geometry/polyhedron/combinatorial_polyhedron/face_data_structure.pxd +207 -0
  75. sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.cpython-314-darwin.so +0 -0
  76. sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pxd +102 -0
  77. sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx +2274 -0
  78. sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.cpython-314-darwin.so +0 -0
  79. sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pxd +370 -0
  80. sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pyx +84 -0
  81. sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.cpython-314-darwin.so +0 -0
  82. sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pxd +31 -0
  83. sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pyx +587 -0
  84. sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.cpython-314-darwin.so +0 -0
  85. sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pxd +52 -0
  86. sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pyx +560 -0
  87. sage/geometry/polyhedron/constructor.py +773 -0
  88. sage/geometry/polyhedron/double_description.py +753 -0
  89. sage/geometry/polyhedron/double_description_inhomogeneous.py +564 -0
  90. sage/geometry/polyhedron/face.py +1060 -0
  91. sage/geometry/polyhedron/generating_function.py +1810 -0
  92. sage/geometry/polyhedron/lattice_euclidean_group_element.py +178 -0
  93. sage/geometry/polyhedron/library.py +3502 -0
  94. sage/geometry/polyhedron/misc.py +121 -0
  95. sage/geometry/polyhedron/modules/all.py +1 -0
  96. sage/geometry/polyhedron/modules/formal_polyhedra_module.py +155 -0
  97. sage/geometry/polyhedron/palp_database.py +447 -0
  98. sage/geometry/polyhedron/parent.py +1279 -0
  99. sage/geometry/polyhedron/plot.py +1986 -0
  100. sage/geometry/polyhedron/ppl_lattice_polygon.py +556 -0
  101. sage/geometry/polyhedron/ppl_lattice_polytope.py +1257 -0
  102. sage/geometry/polyhedron/representation.py +1723 -0
  103. sage/geometry/pseudolines.py +515 -0
  104. sage/geometry/relative_interior.py +445 -0
  105. sage/geometry/toric_plotter.py +1103 -0
  106. sage/geometry/triangulation/all.py +2 -0
  107. sage/geometry/triangulation/base.cpython-314-darwin.so +0 -0
  108. sage/geometry/triangulation/base.pyx +963 -0
  109. sage/geometry/triangulation/data.h +147 -0
  110. sage/geometry/triangulation/data.pxd +4 -0
  111. sage/geometry/triangulation/element.py +914 -0
  112. sage/geometry/triangulation/functions.h +10 -0
  113. sage/geometry/triangulation/functions.pxd +4 -0
  114. sage/geometry/triangulation/point_configuration.py +2256 -0
  115. sage/geometry/triangulation/triangulations.h +49 -0
  116. sage/geometry/triangulation/triangulations.pxd +7 -0
  117. sage/geometry/voronoi_diagram.py +319 -0
  118. sage/interfaces/all__sagemath_polyhedra.py +1 -0
  119. sage/interfaces/polymake.py +2028 -0
  120. sage/numerical/all.py +13 -0
  121. sage/numerical/all__sagemath_polyhedra.py +11 -0
  122. sage/numerical/backends/all.py +1 -0
  123. sage/numerical/backends/all__sagemath_polyhedra.py +1 -0
  124. sage/numerical/backends/cvxopt_backend.cpython-314-darwin.so +0 -0
  125. sage/numerical/backends/cvxopt_backend.pyx +1006 -0
  126. sage/numerical/backends/cvxopt_backend_test.py +19 -0
  127. sage/numerical/backends/cvxopt_sdp_backend.cpython-314-darwin.so +0 -0
  128. sage/numerical/backends/cvxopt_sdp_backend.pyx +382 -0
  129. sage/numerical/backends/cvxpy_backend.cpython-314-darwin.so +0 -0
  130. sage/numerical/backends/cvxpy_backend.pxd +41 -0
  131. sage/numerical/backends/cvxpy_backend.pyx +934 -0
  132. sage/numerical/backends/cvxpy_backend_test.py +13 -0
  133. sage/numerical/backends/generic_backend_test.py +24 -0
  134. sage/numerical/backends/interactivelp_backend.cpython-314-darwin.so +0 -0
  135. sage/numerical/backends/interactivelp_backend.pxd +36 -0
  136. sage/numerical/backends/interactivelp_backend.pyx +1231 -0
  137. sage/numerical/backends/interactivelp_backend_test.py +12 -0
  138. sage/numerical/backends/logging_backend.py +391 -0
  139. sage/numerical/backends/matrix_sdp_backend.cpython-314-darwin.so +0 -0
  140. sage/numerical/backends/matrix_sdp_backend.pxd +15 -0
  141. sage/numerical/backends/matrix_sdp_backend.pyx +478 -0
  142. sage/numerical/backends/ppl_backend.cpython-314-darwin.so +0 -0
  143. sage/numerical/backends/ppl_backend.pyx +1126 -0
  144. sage/numerical/backends/ppl_backend_test.py +13 -0
  145. sage/numerical/backends/scip_backend.cpython-314-darwin.so +0 -0
  146. sage/numerical/backends/scip_backend.pxd +22 -0
  147. sage/numerical/backends/scip_backend.pyx +1289 -0
  148. sage/numerical/backends/scip_backend_test.py +13 -0
  149. sage/numerical/interactive_simplex_method.py +5338 -0
  150. sage/numerical/knapsack.py +665 -0
  151. sage/numerical/linear_functions.cpython-314-darwin.so +0 -0
  152. sage/numerical/linear_functions.pxd +31 -0
  153. sage/numerical/linear_functions.pyx +1648 -0
  154. sage/numerical/linear_tensor.py +470 -0
  155. sage/numerical/linear_tensor_constraints.py +448 -0
  156. sage/numerical/linear_tensor_element.cpython-314-darwin.so +0 -0
  157. sage/numerical/linear_tensor_element.pxd +6 -0
  158. sage/numerical/linear_tensor_element.pyx +459 -0
  159. sage/numerical/mip.cpython-314-darwin.so +0 -0
  160. sage/numerical/mip.pxd +40 -0
  161. sage/numerical/mip.pyx +3667 -0
  162. sage/numerical/sdp.cpython-314-darwin.so +0 -0
  163. sage/numerical/sdp.pxd +39 -0
  164. sage/numerical/sdp.pyx +1433 -0
  165. sage/rings/all__sagemath_polyhedra.py +3 -0
  166. sage/rings/polynomial/all__sagemath_polyhedra.py +10 -0
  167. sage/rings/polynomial/omega.py +982 -0
  168. sage/schemes/all__sagemath_polyhedra.py +2 -0
  169. sage/schemes/toric/all.py +10 -0
  170. sage/schemes/toric/chow_group.py +1248 -0
  171. sage/schemes/toric/divisor.py +2082 -0
  172. sage/schemes/toric/divisor_class.cpython-314-darwin.so +0 -0
  173. sage/schemes/toric/divisor_class.pyx +322 -0
  174. sage/schemes/toric/fano_variety.py +1606 -0
  175. sage/schemes/toric/homset.py +650 -0
  176. sage/schemes/toric/ideal.py +451 -0
  177. sage/schemes/toric/library.py +1322 -0
  178. sage/schemes/toric/morphism.py +1958 -0
  179. sage/schemes/toric/points.py +1032 -0
  180. sage/schemes/toric/sheaf/all.py +1 -0
  181. sage/schemes/toric/sheaf/constructor.py +302 -0
  182. sage/schemes/toric/sheaf/klyachko.py +921 -0
  183. sage/schemes/toric/toric_subscheme.py +905 -0
  184. sage/schemes/toric/variety.py +3460 -0
  185. sage/schemes/toric/weierstrass.py +1078 -0
  186. sage/schemes/toric/weierstrass_covering.py +457 -0
  187. sage/schemes/toric/weierstrass_higher.py +288 -0
  188. sage_wheels/share/reflexive_polytopes/Full2d/zzdb.info +10 -0
  189. sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v03 +0 -0
  190. sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v04 +0 -0
  191. sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v05 +1 -0
  192. sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v06 +1 -0
  193. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.info +22 -0
  194. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v04 +0 -0
  195. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v05 +0 -0
  196. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v06 +0 -0
  197. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v07 +0 -0
  198. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v08 +0 -0
  199. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v09 +0 -0
  200. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v10 +0 -0
  201. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v11 +1 -0
  202. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v12 +1 -0
  203. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v13 +1 -0
  204. sage_wheels/share/reflexive_polytopes/reflexive_polytopes_2d +80 -0
  205. sage_wheels/share/reflexive_polytopes/reflexive_polytopes_3d +37977 -0
@@ -0,0 +1,1958 @@
1
+ # sage_setup: distribution = sagemath-polyhedra
2
+ # sage.doctest: needs sage.geometry.polyhedron sage.graphs
3
+ r"""
4
+ Morphisms of toric varieties
5
+
6
+ There are three "obvious" ways to map toric varieties to toric
7
+ varieties:
8
+
9
+ 1. Polynomial maps in local coordinates, the usual morphisms in
10
+ algebraic geometry.
11
+
12
+ 2. Polynomial maps in the (global) homogeneous coordinates.
13
+
14
+ 3. Toric morphisms, that is, algebraic morphisms equivariant with
15
+ respect to the torus action on the toric variety.
16
+
17
+ Both 2 and 3 are special cases of 1, which is just to say that we
18
+ always remain within the realm of algebraic geometry. But apart from
19
+ that, none is included in one of the other cases. In the examples
20
+ below, we will explore some algebraic maps that can or can not be
21
+ written as a toric morphism. Often a toric morphism can be written
22
+ with polynomial maps in homogeneous coordinates, but sometimes it
23
+ cannot.
24
+
25
+ The toric morphisms are perhaps the most mysterious at the
26
+ beginning. Let us quickly review their definition (See Definition
27
+ 3.3.3 of [CLS2011]_). Let `\Sigma_1` be a fan in `N_{1,\RR}` and `\Sigma_2` be a
28
+ fan in `N_{2,\RR}`. A morphism `\phi: X_{\Sigma_1} \to X_{\Sigma_2}`
29
+ of the associated toric varieties is toric if `\phi` maps the maximal
30
+ torus `T_{N_1} \subseteq X_{\Sigma_1}` into `T_{N_2} \subseteq
31
+ X_{\Sigma_2}` and `\phi|_{T_N}` is a group homomorphism.
32
+
33
+ The data defining a toric morphism is precisely what defines a fan
34
+ morphism (see :mod:`~sage.geometry.fan_morphism`), extending the more
35
+ familiar dictionary between toric varieties and fans. Toric geometry
36
+ is a functor from the category of fans and fan morphisms to the
37
+ category of toric varieties and toric morphisms.
38
+
39
+ .. NOTE::
40
+
41
+ Do not create the toric morphisms (or any morphism of schemes)
42
+ directly from the ``SchemeMorphism...`` classes. Instead, use the
43
+ :meth:`~sage.schemes.generic.scheme.hom` method common to all
44
+ algebraic schemes to create new homomorphisms.
45
+
46
+ EXAMPLES:
47
+
48
+ First, consider the following embedding of `\mathbb{P}^1` into
49
+ `\mathbb{P}^2` ::
50
+
51
+ sage: P2.<x,y,z> = toric_varieties.P2()
52
+ sage: P1.<u,v> = toric_varieties.P1()
53
+ sage: P1.hom([0, u^2 + v^2, u*v], P2)
54
+ Scheme morphism:
55
+ From: 1-d CPR-Fano toric variety covered by 2 affine patches
56
+ To: 2-d CPR-Fano toric variety covered by 3 affine patches
57
+ Defn: Defined on coordinates by sending [u : v] to [0 : u^2 + v^2 : u*v]
58
+
59
+ This is a well-defined morphism of algebraic varieties because
60
+ homogeneously rescaled coordinates of a point of `\mathbb{P}^1` map to the same
61
+ point in `\mathbb{P}^2` up to its homogeneous rescalings. It is not
62
+ equivariant with respect to the torus actions
63
+
64
+ .. MATH::
65
+
66
+ \CC^\times \times \mathbb{P}^1,
67
+ (\mu,[u:v]) \mapsto [u:\mu v]
68
+ \quad\text{and}\quad
69
+ \left(\CC^\times\right)^2 \times \mathbb{P}^2,
70
+ ((\alpha,\beta),[x:y:z]) \mapsto [x:\alpha y:\beta z]
71
+ ,
72
+
73
+ hence it is not a toric morphism. Clearly, the problem is that
74
+ the map in homogeneous coordinates contains summands that transform
75
+ differently under the torus action. However, this is not the only
76
+ difficulty. For example, consider ::
77
+
78
+ sage: phi = P1.hom([0,u,v], P2); phi
79
+ Scheme morphism:
80
+ From: 1-d CPR-Fano toric variety covered by 2 affine patches
81
+ To: 2-d CPR-Fano toric variety covered by 3 affine patches
82
+ Defn: Defined on coordinates by sending [u : v] to [0 : u : v]
83
+
84
+ This map is actually the embedding of the
85
+ :meth:`~sage.schemes.toric.variety.ToricVariety_field.orbit_closure`
86
+ associated to one of the rays of the fan of `\mathbb{P}^2`. Now the
87
+ morphism is equivariant with respect to **some** map `\CC^\times \to
88
+ (\CC^\times)^2` of the maximal tori of `\mathbb{P}^1` and
89
+ `\mathbb{P}^2`. But this map of the maximal tori cannot be the same as
90
+ ``phi`` defined above. Indeed, the image of ``phi`` completely misses
91
+ the maximal torus `T_{\mathbb{P}^2} = \{ [x:y:z] | x\not=0, y\not=0,
92
+ z\not=0 \}` of `\mathbb{P}^2`.
93
+
94
+ Consider instead the following morphism of fans::
95
+
96
+ sage: fm = FanMorphism(matrix(ZZ, [[1,0]]), P1.fan(), P2.fan()); fm
97
+ Fan morphism defined by the matrix
98
+ [1 0]
99
+ Domain fan: Rational polyhedral fan in 1-d lattice N
100
+ Codomain fan: Rational polyhedral fan in 2-d lattice N
101
+
102
+ which also defines a morphism of toric varieties::
103
+
104
+ sage: P1.hom(fm, P2)
105
+ Scheme morphism:
106
+ From: 1-d CPR-Fano toric variety covered by 2 affine patches
107
+ To: 2-d CPR-Fano toric variety covered by 3 affine patches
108
+ Defn: Defined by sending Rational polyhedral fan in 1-d lattice N
109
+ to Rational polyhedral fan in 2-d lattice N.
110
+
111
+ The fan morphism map is equivalent to the following polynomial map::
112
+
113
+ sage: _.as_polynomial_map()
114
+ Scheme morphism:
115
+ From: 1-d CPR-Fano toric variety covered by 2 affine patches
116
+ To: 2-d CPR-Fano toric variety covered by 3 affine patches
117
+ Defn: Defined on coordinates by sending [u : v] to [u : v : v]
118
+
119
+ Finally, here is an example of a fan morphism that cannot be written
120
+ using homogeneous polynomials. Consider the blowup `O_{\mathbb{P}^1}(2)
121
+ \to \CC^2/\ZZ_2`. In terms of toric data, this blowup is::
122
+
123
+ sage: A2_Z2 = toric_varieties.A2_Z2()
124
+ sage: A2_Z2.fan().rays()
125
+ N(1, 0),
126
+ N(1, 2)
127
+ in 2-d lattice N
128
+ sage: O2_P1 = A2_Z2.resolve(new_rays=[(1,1)])
129
+ sage: blowup = O2_P1.hom(identity_matrix(2), A2_Z2)
130
+ sage: blowup.as_polynomial_map()
131
+ Traceback (most recent call last):
132
+ ...
133
+ TypeError: the fan morphism cannot be written in homogeneous polynomials
134
+
135
+ If we denote the homogeneous coordinates of `O_{\mathbb{P}^1}(2)` by
136
+ `x`, `t`, `y` corresponding to the rays `(1,2)`, `(1,1)`, and `(1,0)`
137
+ then the blow-up map is [BB2013]_:
138
+
139
+ .. MATH::
140
+
141
+ f: O_{\mathbb{P}^1}(2) \to \CC^2/\ZZ_2, \quad
142
+ (x,t,y) \mapsto \left( x\sqrt{t}, y\sqrt{t} \right)
143
+
144
+ which requires square roots.
145
+
146
+
147
+ Fibrations
148
+ ----------
149
+
150
+ If a toric morphism is :meth:`dominant
151
+ <SchemeMorphism_fan_toric_variety.is_dominant>`, then all fibers over
152
+ a fixed torus orbit in the base are isomorphic. Hence, studying the
153
+ fibers is again a combinatorial question and Sage implements
154
+ additional methods to study such fibrations that are not available
155
+ otherwise (however, note that you can always
156
+ :meth:`~SchemeMorphism_fan_toric_variety.factor` to pick out the part
157
+ that is dominant over the image or its closure).
158
+
159
+ For example, consider the blow-up restricted to one of the two
160
+ coordinate charts of `O_{\mathbb{P}^1}(2)` ::
161
+
162
+
163
+ sage: O2_P1_chart = ToricVariety(Fan([O2_P1.fan().generating_cones()[0]]))
164
+ sage: single_chart = O2_P1_chart.hom(identity_matrix(2), A2_Z2)
165
+ sage: single_chart.is_dominant()
166
+ True
167
+ sage: single_chart.is_surjective()
168
+ False
169
+
170
+ sage: fiber = single_chart.fiber_generic(); fiber
171
+ (0-d affine toric variety, 1)
172
+ sage: fiber[0].embedding_morphism().as_polynomial_map()
173
+ Scheme morphism:
174
+ From: 0-d affine toric variety
175
+ To: 2-d affine toric variety
176
+ Defn: Defined on coordinates by sending [] to [1 : 1]
177
+
178
+ The fibers are labeled by torus orbits in the base, that is, cones of
179
+ the codomain fan. In this case, the fibers over lower-dimensional
180
+ torus orbits are::
181
+
182
+ sage: A2_Z2_cones = flatten(A2_Z2.fan().cones())
183
+ sage: table([('cone', 'dim')] +
184
+ ....: [(cone.ambient_ray_indices(), single_chart.fiber_dimension(cone))
185
+ ....: for cone in A2_Z2_cones], header_row=True)
186
+ cone dim
187
+ ├────────┼─────┤
188
+ () 0
189
+ (0,) 0
190
+ (1,) -1
191
+ (0, 1) 1
192
+
193
+ Lets look closer at the one-dimensional fiber. Although not the case
194
+ in this example, connected components of fibers over higher-dimensional cones
195
+ (corresponding
196
+ to lower-dimensional torus orbits) of the base are often not
197
+ irreducible. The irreducible components are labeled by the
198
+ :meth:`~sage.geometry.fan_morphism.FanMorphism.primitive_preimage_cones`,
199
+ which are certain cones of the domain fan that map to the cone in the
200
+ base that defines the torus orbit::
201
+
202
+ sage: table([('base cone', 'primitive preimage cones')] +
203
+ ....: [(cone.ambient_ray_indices(),
204
+ ....: single_chart.fan_morphism().primitive_preimage_cones(cone))
205
+ ....: for cone in A2_Z2_cones], header_row=True)
206
+ base cone primitive preimage cones
207
+ ├───────────┼─────────────────────────────────────────────────────────┤
208
+ () (0-d cone of Rational polyhedral fan in 2-d lattice N,)
209
+ (0,) (1-d cone of Rational polyhedral fan in 2-d lattice N,)
210
+ (1,) ()
211
+ (0, 1) (1-d cone of Rational polyhedral fan in 2-d lattice N,)
212
+
213
+ The fiber over the trivial cone is the generic fiber that we have
214
+ already encountered. The interesting fiber is the one over the
215
+ 2-dimensional cone, which represents the exceptional set of the
216
+ blow-up in this single coordinate chart. Lets investigate further::
217
+
218
+ sage: fm = single_chart.fan_morphism()
219
+ sage: exceptional_cones = fm.primitive_preimage_cones(A2_Z2.fan(2)[0])
220
+ sage: exceptional_set = single_chart.fiber_component(exceptional_cones[0])
221
+ sage: exceptional_set
222
+ 1-d affine toric variety
223
+ sage: exceptional_set.embedding_morphism().as_polynomial_map()
224
+ Scheme morphism:
225
+ From: 1-d affine toric variety
226
+ To: 2-d affine toric variety
227
+ Defn: Defined on coordinates by sending [z0] to [z0 : 0]
228
+
229
+ So we see that the fiber over this point is an affine line. Together
230
+ with another affine line in the other coordinate patch, this covers
231
+ the exceptional `\mathbb{P}^1` of the blowup `O_{\mathbb{P}^1}(2) \to
232
+ \CC^2/\ZZ_2`.
233
+
234
+ Here is an example with higher dimensional varieties involved::
235
+
236
+ sage: A3 = toric_varieties.A(3)
237
+ sage: P3 = toric_varieties.P(3)
238
+ sage: m = matrix([(2,0,0), (1,1,0), (3,1,0)])
239
+ sage: phi = A3.hom(m, P3)
240
+ sage: phi.as_polynomial_map()
241
+ Scheme morphism:
242
+ From: 3-d affine toric variety
243
+ To: 3-d CPR-Fano toric variety covered by 4 affine patches
244
+ Defn: Defined on coordinates by sending [z0 : z1 : z2] to
245
+ [z0^2*z1*z2^3 : z1*z2 : 1 : 1]
246
+ sage: phi.fiber_generic()
247
+ Traceback (most recent call last):
248
+ ...
249
+ AttributeError: 'SchemeMorphism_fan_toric_variety' object
250
+ has no attribute 'fiber_generic'...
251
+
252
+ Let's use factorization mentioned above::
253
+
254
+ sage: phi_i, phi_b, phi_s = phi.factor()
255
+
256
+ It is possible to study fibers of the last two morphisms or their composition::
257
+
258
+ sage: phi_d = phi_b * phi_s
259
+ sage: phi_d
260
+ Scheme morphism:
261
+ From: 3-d affine toric variety
262
+ To: 2-d toric variety covered by 3 affine patches
263
+ Defn: Defined by sending Rational polyhedral fan in 3-d lattice N to
264
+ Rational polyhedral fan in Sublattice <N(1, 0, 0), N(0, 1, 0)>.
265
+ sage: phi_d.as_polynomial_map()
266
+ Scheme morphism:
267
+ From: 3-d affine toric variety
268
+ To: 2-d toric variety covered by 3 affine patches
269
+ Defn: Defined on coordinates by sending [z0 : z1 : z2] to
270
+ [1 : z1*z2 : z0^2*z1*z2^3]
271
+ sage: phi_d.codomain().fan().rays()
272
+ N(-1, -1, 0),
273
+ N( 0, 1, 0),
274
+ N( 1, 0, 0)
275
+ in Sublattice <N(1, 0, 0), N(0, 1, 0)>
276
+ sage: for c in phi_d.codomain().fan():
277
+ ....: c.ambient_ray_indices()
278
+ (0, 1)
279
+ (0, 2)
280
+ (1, 2)
281
+
282
+ We see that codomain fan of this morphism is a projective plane, which can be
283
+ verified by ::
284
+
285
+ sage: phi_d.codomain().fan().is_isomorphic(toric_varieties.P2().fan()) # known bug
286
+ True
287
+
288
+ (Unfortunately it cannot be verified correctly until :issue:`16012` is fixed.)
289
+
290
+ We now have access to fiber methods::
291
+
292
+ sage: fiber = phi_d.fiber_generic()
293
+ sage: fiber
294
+ (1-d affine toric variety, 2)
295
+ sage: fiber[0].embedding_morphism()
296
+ Scheme morphism:
297
+ From: 1-d affine toric variety
298
+ To: 3-d affine toric variety
299
+ Defn: Defined by sending
300
+ Rational polyhedral fan in Sublattice <N(1, 1, -1)> to
301
+ Rational polyhedral fan in 3-d lattice N.
302
+ sage: fiber[0].embedding_morphism().as_polynomial_map()
303
+ Traceback (most recent call last):
304
+ ...
305
+ NotImplementedError: polynomial representations for
306
+ fans with virtual rays are not implemented yet
307
+ sage: fiber[0].fan().rays()
308
+ Empty collection
309
+ in Sublattice <N(1, 1, -1)>
310
+
311
+ We see that generic fibers of this morphism consist of 2 one-dimensional tori
312
+ each. To see what happens over boundary points we can look at fiber components
313
+ corresponding to the cones of the domain fan::
314
+
315
+ sage: fm = phi_d.fan_morphism()
316
+ sage: for c in flatten(phi_d.domain().fan().cones()):
317
+ ....: fc, m = phi_d.fiber_component(c, multiplicity=True)
318
+ ....: print("{} |-> {} ({} rays, multiplicity {}) over {}".format(
319
+ ....: c.ambient_ray_indices(), fc, fc.fan().nrays(),
320
+ ....: m, fm.image_cone(c).ambient_ray_indices()))
321
+ () |-> 1-d affine toric variety (0 rays, multiplicity 2) over ()
322
+ (0,) |-> 1-d affine toric variety (0 rays, multiplicity 1) over (2,)
323
+ (1,) |-> 2-d affine toric variety (2 rays, multiplicity 1) over (1, 2)
324
+ (2,) |-> 2-d affine toric variety (2 rays, multiplicity 1) over (1, 2)
325
+ (0, 1) |-> 1-d affine toric variety (1 rays, multiplicity 1) over (1, 2)
326
+ (1, 2) |-> 1-d affine toric variety (1 rays, multiplicity 1) over (1, 2)
327
+ (0, 2) |-> 1-d affine toric variety (1 rays, multiplicity 1) over (1, 2)
328
+ (0, 1, 2) |-> 0-d affine toric variety (0 rays, multiplicity 1) over (1, 2)
329
+
330
+ Now we see that over one of the coordinate lines of the projective plane we also
331
+ have one-dimensional tori (but only one in each fiber), while over one of the
332
+ points fixed by torus action we have two affine planes intersecting along an
333
+ affine line. An alternative perspective is provided by cones of the codomain
334
+ fan::
335
+
336
+ sage: for c in flatten(phi_d.codomain().fan().cones()):
337
+ ....: print("{} connected components over {}, each with {} irreducible components.".format(
338
+ ....: fm.index(c), c.ambient_ray_indices(),
339
+ ....: len(fm.primitive_preimage_cones(c))))
340
+ 2 connected components over (), each with 1 irreducible components.
341
+ None connected components over (0,), each with 0 irreducible components.
342
+ None connected components over (1,), each with 0 irreducible components.
343
+ 1 connected components over (2,), each with 1 irreducible components.
344
+ None connected components over (0, 1), each with 0 irreducible components.
345
+ None connected components over (0, 2), each with 0 irreducible components.
346
+ 1 connected components over (1, 2), each with 2 irreducible components.
347
+ """
348
+
349
+ # ****************************************************************************
350
+ # Copyright (C) 2011 Volker Braun <vbraun.name@gmail.com>
351
+ # Copyright (C) 2010 Andrey Novoseltsev <novoselt@gmail.com>
352
+ # Copyright (C) 2006 William Stein <wstein@gmail.com>
353
+ #
354
+ # This program is free software: you can redistribute it and/or modify
355
+ # it under the terms of the GNU General Public License as published by
356
+ # the Free Software Foundation, either version 2 of the License, or
357
+ # (at your option) any later version.
358
+ # https://www.gnu.org/licenses/
359
+ # ****************************************************************************
360
+
361
+ # For now, the scheme morphism base class cannot derive from Morphism
362
+ # since this would clash with elliptic curves. So we derive only on
363
+ # the toric varieties level from Morphism. See
364
+ # https://groups.google.com/d/msg/sage-devel/qF4yU6Vdmao/wQlNrneSmWAJ
365
+ from sage.categories.morphism import Morphism
366
+ from sage.structure.richcmp import richcmp_not_equal, richcmp
367
+ from sage.structure.sequence import Sequence
368
+ from sage.rings.integer_ring import ZZ
369
+ from sage.arith.misc import GCD as gcd
370
+ from sage.misc.cachefunc import cached_method
371
+ from sage.matrix.constructor import matrix, identity_matrix
372
+ from sage.modules.free_module_element import vector
373
+ from sage.geometry.cone import Cone
374
+ from sage.geometry.fan import Fan
375
+
376
+ from sage.schemes.generic.scheme import Scheme
377
+ from sage.schemes.generic.morphism import (
378
+ SchemeMorphism, SchemeMorphism_point, SchemeMorphism_polynomial
379
+ )
380
+
381
+
382
+ ############################################################################
383
+ # A points on a toric variety determined by homogeneous coordinates.
384
+ class SchemeMorphism_point_toric_field(SchemeMorphism_point, Morphism):
385
+ """
386
+ A point of a toric variety determined by homogeneous coordinates
387
+ in a field.
388
+
389
+ .. WARNING::
390
+
391
+ You should not create objects of this class directly. Use the
392
+ :meth:`~sage.schemes.generic.scheme.hom` method of
393
+ :class:`toric varieties
394
+ <sage.schemes.toric.variety.ToricVariety_field>`
395
+ instead.
396
+
397
+ INPUT:
398
+
399
+ - ``X`` -- toric variety or subscheme of a toric variety
400
+
401
+ - ``coordinates`` -- list of coordinates in the base field of ``X``
402
+
403
+ - ``check`` -- if ``True`` (default), the input will be checked for
404
+ correctness
405
+
406
+ OUTPUT: a :class:`SchemeMorphism_point_toric_field`
407
+
408
+ TESTS::
409
+
410
+ sage: P1xP1 = toric_varieties.P1xP1()
411
+ sage: P1xP1(1,2,3,4)
412
+ [1 : 2 : 3 : 4]
413
+ """
414
+ # Mimicking affine/projective classes
415
+ def __init__(self, X, coordinates, check=True):
416
+ r"""
417
+ See :class:`SchemeMorphism_point_toric_field` for documentation.
418
+
419
+ TESTS::
420
+
421
+ sage: P1xP1 = toric_varieties.P1xP1()
422
+ sage: P1xP1(1,2,3,4)
423
+ [1 : 2 : 3 : 4]
424
+ """
425
+ # Convert scheme to its set of points over the base ring
426
+ if isinstance(X, Scheme):
427
+ X = X(X.base_ring())
428
+ super().__init__(X)
429
+ if check:
430
+ # Verify that there are the right number of coords
431
+ # Why is it not done in the parent?
432
+ if isinstance(coordinates, SchemeMorphism):
433
+ coordinates = list(coordinates)
434
+ if not isinstance(coordinates, (list, tuple)):
435
+ raise TypeError("coordinates must be a scheme point, list, "
436
+ "or tuple; got %s" % coordinates)
437
+ d = X.codomain().ambient_space().ngens()
438
+ if len(coordinates) != d:
439
+ raise ValueError("there must be %d coordinates; got only %d: "
440
+ "%s" % (d, len(coordinates), coordinates))
441
+ # Make sure the coordinates all lie in the appropriate ring
442
+ coordinates = Sequence(coordinates, X.value_ring())
443
+ # Verify that the point satisfies the equations of X.
444
+ X.codomain()._check_satisfies_equations(coordinates)
445
+ self._coords = coordinates
446
+
447
+
448
+ ############################################################################
449
+ # A morphism of toric varieties determined by homogeneous polynomials.
450
+ class SchemeMorphism_polynomial_toric_variety(SchemeMorphism_polynomial, Morphism):
451
+ """
452
+ A morphism determined by homogeneous polynomials.
453
+
454
+ .. WARNING::
455
+
456
+ You should not create objects of this class directly. Use the
457
+ :meth:`~sage.schemes.generic.scheme.hom` method of
458
+ :class:`toric varieties
459
+ <sage.schemes.toric.variety.ToricVariety_field>`
460
+ instead.
461
+
462
+ INPUT:
463
+
464
+ Same as for
465
+ :class:`~sage.schemes.toric.morphism.SchemeMorphism_polynomial`.
466
+
467
+ OUTPUT: a :class:`~sage.schemes.toric.morphism.SchemeMorphism_polynomial_toric_variety`
468
+
469
+ TESTS::
470
+
471
+ sage: P1xP1 = toric_varieties.P1xP1()
472
+ sage: P1xP1.inject_variables()
473
+ Defining s, t, x, y
474
+ sage: P1 = P1xP1.subscheme(s - t)
475
+ sage: H = P1xP1.Hom(P1)
476
+ sage: import sage.schemes.toric.morphism as MOR
477
+ sage: MOR.SchemeMorphism_polynomial_toric_variety(H, [s, s, x, y])
478
+ Scheme morphism:
479
+ From: 2-d CPR-Fano toric variety covered by 4 affine patches
480
+ To: Closed subscheme of 2-d CPR-Fano toric variety
481
+ covered by 4 affine patches defined by:
482
+ s - t
483
+ Defn: Defined on coordinates by sending [s : t : x : y] to
484
+ [s : s : x : y]
485
+ """
486
+
487
+ def __init__(self, parent, polynomials, check=True):
488
+ r"""
489
+ See :class:`SchemeMorphism_polynomial_toric_variety` for documentation.
490
+
491
+ TESTS::
492
+
493
+ sage: P1xP1 = toric_varieties.P1xP1()
494
+ sage: P1xP1.inject_variables()
495
+ Defining s, t, x, y
496
+ sage: P1 = P1xP1.subscheme(s - t)
497
+ sage: H = P1xP1.Hom(P1)
498
+ sage: import sage.schemes.toric.morphism as MOR
499
+ sage: MOR.SchemeMorphism_polynomial_toric_variety(H, [s, s, x, y])
500
+ Scheme morphism:
501
+ From: 2-d CPR-Fano toric variety covered by 4 affine patches
502
+ To: Closed subscheme of 2-d CPR-Fano toric variety
503
+ covered by 4 affine patches defined by:
504
+ s - t
505
+ Defn: Defined on coordinates by sending [s : t : x : y] to
506
+ [s : s : x : y]
507
+ """
508
+ SchemeMorphism_polynomial.__init__(self, parent, polynomials, check)
509
+ if check:
510
+ # Check that defining polynomials are homogeneous (degrees can be
511
+ # different if the target uses weighted coordinates)
512
+ for p in self.defining_polynomials():
513
+ if not self.domain().ambient_space().is_homogeneous(p):
514
+ raise ValueError("%s is not homogeneous" % p)
515
+
516
+ def as_fan_morphism(self):
517
+ """
518
+ Express the morphism as a map defined by a fan morphism.
519
+
520
+ OUTPUT: a :class:`SchemeMorphism_polynomial_toric_variety`
521
+
522
+ This raises a :exc:`TypeError` if the morphism cannot be written
523
+ in such a way.
524
+
525
+ EXAMPLES::
526
+
527
+ sage: A1.<z> = toric_varieties.A1()
528
+ sage: P1 = toric_varieties.P1()
529
+ sage: patch = A1.hom([1,z], P1)
530
+ sage: patch.as_fan_morphism()
531
+ Traceback (most recent call last):
532
+ ...
533
+ NotImplementedError: expressing toric morphisms as fan morphisms is
534
+ not implemented yet
535
+ """
536
+ raise NotImplementedError("expressing toric morphisms as fan "
537
+ "morphisms is not implemented yet")
538
+
539
+
540
+ ############################################################################
541
+ # The embedding morphism of an orbit closure
542
+ class SchemeMorphism_orbit_closure_toric_variety(SchemeMorphism, Morphism):
543
+ """
544
+ The embedding of an orbit closure.
545
+
546
+ INPUT:
547
+
548
+ - ``parent`` -- the parent homset
549
+
550
+ - ``defining_cone`` -- the defining cone
551
+
552
+ - ``ray_map`` -- dictionary ``{ambient ray generator: orbit ray
553
+ generator}``. Note that the image of the ambient ray generator
554
+ is not necessarily primitive.
555
+
556
+ .. WARNING::
557
+
558
+ You should not create objects of this class directly. Use the
559
+ :meth:`~sage.schemes.toric.variety.ToricVariety_field.orbit_closure`
560
+ method of :class:`toric varieties
561
+ <sage.schemes.toric.variety.ToricVariety_field>`
562
+ instead.
563
+
564
+ EXAMPLES::
565
+
566
+ sage: P1xP1 = toric_varieties.P1xP1()
567
+ sage: H = P1xP1.fan(1)[0]
568
+ sage: V = P1xP1.orbit_closure(H)
569
+ sage: V.embedding_morphism()
570
+ Scheme morphism:
571
+ From: 1-d toric variety covered by 2 affine patches
572
+ To: 2-d CPR-Fano toric variety covered by 4 affine patches
573
+ Defn: Defined by embedding the torus closure associated to the 1-d
574
+ cone of Rational polyhedral fan in 2-d lattice N.
575
+
576
+ TESTS::
577
+
578
+ sage: V.embedding_morphism()._reverse_ray_map()
579
+ {N(-1): 3, N(1): 2}
580
+ sage: V.embedding_morphism()._defining_cone
581
+ 1-d cone of Rational polyhedral fan in 2-d lattice N
582
+ """
583
+ def __init__(self, parent, defining_cone, ray_map):
584
+ """
585
+ The Python constructor.
586
+
587
+ EXAMPLES::
588
+
589
+ sage: P2 = toric_varieties.P2()
590
+ sage: P1 = P2.orbit_closure(P2.fan(1)[0])
591
+ sage: P1.embedding_morphism()
592
+ Scheme morphism:
593
+ From: 1-d toric variety covered by 2 affine patches
594
+ To: 2-d CPR-Fano toric variety covered by 3 affine patches
595
+ Defn: Defined by embedding the torus closure associated to the 1-d cone
596
+ of Rational polyhedral fan in 2-d lattice N.
597
+ """
598
+ SchemeMorphism.__init__(self, parent)
599
+ self._defining_cone = defining_cone
600
+ self._ray_map = ray_map
601
+
602
+ def defining_cone(self):
603
+ r"""
604
+ Return the cone corresponding to the torus orbit.
605
+
606
+ OUTPUT: a cone of the fan of the ambient toric variety
607
+
608
+ EXAMPLES::
609
+
610
+ sage: P2 = toric_varieties.P2()
611
+ sage: cone = P2.fan(1)[0]
612
+ sage: P1 = P2.orbit_closure(cone)
613
+ sage: P1.embedding_morphism().defining_cone()
614
+ 1-d cone of Rational polyhedral fan in 2-d lattice N
615
+ sage: _ is cone
616
+ True
617
+ """
618
+ return self._defining_cone
619
+
620
+ @cached_method
621
+ def _reverse_ray_map(self):
622
+ """
623
+ Reverse ``self._ray_map``.
624
+
625
+ OUTPUT:
626
+
627
+ A dictionary ``{orbit ray generator: preimage ray
628
+ index}``. Note that the orbit ray generator need not be
629
+ primitive. Also, the preimage ray is not necessarily unique.
630
+
631
+ EXAMPLES::
632
+
633
+ sage: P2_112 = toric_varieties.P2_112()
634
+ sage: P1 = P2_112.orbit_closure(Cone([(1,0)]))
635
+ sage: f = P1.embedding_morphism()
636
+ sage: f._ray_map
637
+ {N(-1, -2): (-2), N(0, 1): (1), N(1, 0): (0)}
638
+ sage: f._reverse_ray_map()
639
+ {N(-2): 2, N(1): 1}
640
+ """
641
+ orbit = self.parent().domain()
642
+ codomain_fan = self.parent().codomain().fan()
643
+ reverse_ray_dict = {}
644
+ for n1, n2 in self._ray_map.items():
645
+ ray_index = codomain_fan.rays().index(n1)
646
+ if n2.is_zero():
647
+ assert ray_index in self._defining_cone.ambient_ray_indices()
648
+ continue
649
+ n2 = orbit.fan().lattice()(n2)
650
+ n2.set_immutable()
651
+ reverse_ray_dict[n2] = ray_index
652
+ return reverse_ray_dict
653
+
654
+ def _repr_defn(self):
655
+ """
656
+ Return a string representation of the definition of ``self``.
657
+
658
+ OUTPUT: string
659
+
660
+ EXAMPLES::
661
+
662
+ sage: P2 = toric_varieties.P2()
663
+ sage: V = P2.orbit_closure(P2.fan(1)[0]); V
664
+ 1-d toric variety covered by 2 affine patches
665
+ sage: V.embedding_morphism()._repr_defn()
666
+ 'Defined by embedding the torus closure associated to the 1-d cone of
667
+ Rational polyhedral fan in 2-d lattice N.'
668
+ """
669
+ s = 'Defined by embedding the torus closure associated to the '
670
+ s += str(self._defining_cone)
671
+ s += '.'
672
+ return s
673
+
674
+ def as_polynomial_map(self):
675
+ """
676
+ Express the morphism via homogeneous polynomials.
677
+
678
+ OUTPUT: a :class:`SchemeMorphism_polynomial_toric_variety`
679
+
680
+ This raises a :exc:`TypeError` if the morphism cannot be
681
+ written in terms of homogeneous polynomials.
682
+
683
+ The defining polynomials are not necessarily unique. There are
684
+ choices if multiple ambient space ray generators project to
685
+ the same orbit ray generator, and one such choice is made
686
+ implicitly. The orbit embedding can be written as a polynomial
687
+ map if and only if each primitive orbit ray generator is the
688
+ image of at least one primitive ray generator of the ambient
689
+ toric variety.
690
+
691
+ EXAMPLES::
692
+
693
+ sage: P2 = toric_varieties.P2()
694
+ sage: V = P2.orbit_closure(P2.fan(1)[0]); V
695
+ 1-d toric variety covered by 2 affine patches
696
+ sage: V.embedding_morphism().as_polynomial_map()
697
+ Scheme morphism:
698
+ From: 1-d toric variety covered by 2 affine patches
699
+ To: 2-d CPR-Fano toric variety covered by 3 affine patches
700
+ Defn: Defined on coordinates by sending [z0 : z1] to [0 : z1 : z0]
701
+
702
+ If the toric variety is singular, then some orbit closure
703
+ embeddings cannot be written with homogeneous polynomials::
704
+
705
+ sage: P2_112 = toric_varieties.P2_112()
706
+ sage: P1 = P2_112.orbit_closure(Cone([(1,0)]))
707
+ sage: P1.embedding_morphism().as_polynomial_map()
708
+ Traceback (most recent call last):
709
+ ...
710
+ TypeError: the embedding cannot be written with homogeneous polynomials
711
+ """
712
+ orbit = self.domain()
713
+ codomain_fan = self.codomain().fan()
714
+ R = orbit.coordinate_ring()
715
+ polys = [R.one()] * codomain_fan.nrays()
716
+ for i in self._defining_cone.ambient_ray_indices():
717
+ polys[i] = R.zero()
718
+ ray_index_map = self._reverse_ray_map()
719
+ for i, ray in enumerate(orbit.fan().rays()):
720
+ try:
721
+ ray_index = ray_index_map[ray]
722
+ except KeyError:
723
+ raise TypeError('the embedding cannot be written with homogeneous polynomials')
724
+ polys[ray_index] = R.gen(i)
725
+ return SchemeMorphism_polynomial_toric_variety(self.parent(), polys)
726
+
727
+ def pullback_divisor(self, divisor):
728
+ r"""
729
+ Pull back a toric divisor.
730
+
731
+ INPUT:
732
+
733
+ - ``divisor`` -- a torus-invariant `\QQ`-Cartier divisor on the
734
+ codomain of the embedding map
735
+
736
+ OUTPUT:
737
+
738
+ A divisor on the domain of the embedding map (the orbit
739
+ closure) that is isomorphic to the pull-back divisor `f^*(D)`
740
+ but with possibly different linearization.
741
+
742
+ EXAMPLES::
743
+
744
+ sage: P2 = toric_varieties.P2()
745
+ sage: P1 = P2.orbit_closure(P2.fan(1)[0])
746
+ sage: f = P1.embedding_morphism()
747
+ sage: D = P2.divisor([1,2,3]); D
748
+ V(x) + 2*V(y) + 3*V(z)
749
+ sage: f.pullback_divisor(D)
750
+ 4*V(z0) + 2*V(z1)
751
+ """
752
+ from sage.schemes.toric.divisor import ToricDivisor_generic
753
+ if not (isinstance(divisor, ToricDivisor_generic) and divisor.is_QQ_Cartier()):
754
+ raise ValueError('the divisor must be torus-invariant and QQ-Cartier')
755
+ m = divisor.m(self._defining_cone)
756
+ values = []
757
+ codomain_rays = self.codomain().fan().rays()
758
+ for ray in self.domain().fan().rays():
759
+ ray = codomain_rays[self._reverse_ray_map()[ray]]
760
+ value = divisor.function_value(ray) - m * ray
761
+ values.append(value)
762
+ return self.domain().divisor(values)
763
+
764
+
765
+ ############################################################################
766
+ # A morphism of toric varieties determined by a fan morphism
767
+ class SchemeMorphism_fan_toric_variety(SchemeMorphism, Morphism):
768
+ """
769
+ Construct a morphism determined by a fan morphism.
770
+
771
+ .. WARNING::
772
+
773
+ You should not create objects of this class directly. Use the
774
+ :meth:`~sage.schemes.generic.scheme.hom` method of
775
+ :class:`toric varieties
776
+ <sage.schemes.toric.variety.ToricVariety_field>`
777
+ instead.
778
+
779
+ INPUT:
780
+
781
+ - ``parent`` -- Hom-set whose domain and codomain are toric varieties
782
+
783
+ - ``fan_morphism`` -- a morphism of fans whose domain and codomain
784
+ fans equal the fans of the domain and codomain in the ``parent``
785
+ Hom-set.
786
+
787
+ - ``check`` -- boolean (default: ``True``); whether to
788
+ check the input for consistency
789
+
790
+ .. WARNING::
791
+
792
+ A fibration is a dominant morphism; if you are interested in
793
+ these then you have to make sure that your fan morphism is
794
+ dominant. For example, this can be achieved by
795
+ :meth:`factoring the morphism
796
+ <sage.schemes.toric.morphism.SchemeMorphism_fan_toric_variety.factor>`. See
797
+ :class:`SchemeMorphism_fan_toric_variety_dominant` for
798
+ additional functionality for fibrations.
799
+
800
+ OUTPUT: a :class:`~sage.schemes.toric.morphism.SchemeMorphism_fan_toric_variety`
801
+
802
+ EXAMPLES::
803
+
804
+ sage: P1xP1 = toric_varieties.P1xP1()
805
+ sage: P1 = toric_varieties.P1()
806
+ sage: f = P1.hom(matrix([[1,0]]), P1xP1); f
807
+ Scheme morphism:
808
+ From: 1-d CPR-Fano toric variety covered by 2 affine patches
809
+ To: 2-d CPR-Fano toric variety covered by 4 affine patches
810
+ Defn: Defined by sending Rational polyhedral fan in 1-d lattice N
811
+ to Rational polyhedral fan in 2-d lattice N.
812
+ sage: type(f)
813
+ <class 'sage.schemes.toric.morphism.SchemeMorphism_fan_toric_variety'>
814
+
815
+ Slightly more explicit construction::
816
+
817
+ sage: P1xP1 = toric_varieties.P1xP1()
818
+ sage: P1 = toric_varieties.P1()
819
+ sage: hom_set = P1xP1.Hom(P1)
820
+ sage: fm = FanMorphism(matrix(ZZ, [[1],[0]]), P1xP1.fan(), P1.fan())
821
+ sage: hom_set(fm)
822
+ Scheme morphism:
823
+ From: 2-d CPR-Fano toric variety covered by 4 affine patches
824
+ To: 1-d CPR-Fano toric variety covered by 2 affine patches
825
+ Defn: Defined by sending Rational polyhedral fan in 2-d lattice N
826
+ to Rational polyhedral fan in 1-d lattice N.
827
+
828
+ sage: P1xP1.hom(fm, P1)
829
+ Scheme morphism:
830
+ From: 2-d CPR-Fano toric variety covered by 4 affine patches
831
+ To: 1-d CPR-Fano toric variety covered by 2 affine patches
832
+ Defn: Defined by sending Rational polyhedral fan in 2-d lattice N
833
+ to Rational polyhedral fan in 1-d lattice N.
834
+ """
835
+
836
+ def __init__(self, parent, fan_morphism, check=True):
837
+ r"""
838
+ See :class:`SchemeMorphism_polynomial_toric_variety` for documentation.
839
+
840
+ TESTS::
841
+
842
+ sage: P1xP1 = toric_varieties.P1xP1()
843
+ sage: P1 = toric_varieties.P1()
844
+ sage: hom_set = P1xP1.Hom(P1)
845
+ sage: fan_morphism = FanMorphism(matrix(ZZ, [[1],[0]]), P1xP1.fan(), P1.fan())
846
+ sage: from sage.schemes.toric.morphism import SchemeMorphism_fan_toric_variety
847
+ sage: SchemeMorphism_fan_toric_variety(hom_set, fan_morphism)
848
+ Scheme morphism:
849
+ From: 2-d CPR-Fano toric variety covered by 4 affine patches
850
+ To: 1-d CPR-Fano toric variety covered by 2 affine patches
851
+ Defn: Defined by sending Rational polyhedral fan in 2-d lattice N
852
+ to Rational polyhedral fan in 1-d lattice N.
853
+ """
854
+ SchemeMorphism.__init__(self, parent)
855
+ if check and self.domain().fan() != fan_morphism.domain_fan():
856
+ raise ValueError('the fan morphism domain must be the fan of the domain')
857
+ if check and self.codomain().fan() != fan_morphism.codomain_fan():
858
+ raise ValueError('the fan morphism codomain must be the fan of the codomain')
859
+ self._fan_morphism = fan_morphism
860
+
861
+ def _richcmp_(self, right, op):
862
+ r"""
863
+ Compare ``self`` and ``right``.
864
+
865
+ INPUT:
866
+
867
+ - ``right`` -- another toric morphism
868
+
869
+ OUTPUT: boolean
870
+
871
+ Comparison is done first by domain, then by codomain, then by
872
+ fan morphism.
873
+
874
+ TESTS::
875
+
876
+ sage: A2 = toric_varieties.A2()
877
+ sage: P3 = toric_varieties.P(3)
878
+ sage: m = matrix([(2,0,0), (1,1,0)])
879
+ sage: phi = A2.hom(m, P3)
880
+ sage: phi == phi
881
+ True
882
+ sage: phi == prod(phi.factor())
883
+ True
884
+ sage: phi == phi.factor()[0]
885
+ False
886
+ """
887
+ if not isinstance(right, SchemeMorphism_fan_toric_variety):
888
+ return NotImplemented
889
+
890
+ lx = self.domain()
891
+ rx = right.domain()
892
+ if lx != rx:
893
+ return richcmp_not_equal(lx, rx, op)
894
+
895
+ lx = self.codomain()
896
+ rx = right.codomain()
897
+ if lx != rx:
898
+ return richcmp_not_equal(lx, rx, op)
899
+
900
+ return richcmp(self.fan_morphism(), right.fan_morphism(), op)
901
+
902
+ def _composition_(self, right, homset):
903
+ """
904
+ Return the composition of ``self`` and ``right``.
905
+
906
+ INPUT:
907
+
908
+ - ``right`` -- a toric morphism defined by a fan morphism
909
+
910
+ OUTPUT: a toric morphism
911
+
912
+ EXAMPLES::
913
+
914
+ sage: A2 = toric_varieties.A2()
915
+ sage: P3 = toric_varieties.P(3)
916
+ sage: m = matrix([(2,0,0), (1,1,0)])
917
+ sage: phi = A2.hom(m, P3)
918
+ sage: phi1, phi2, phi3 = phi.factor()
919
+ sage: phi1 * phi2
920
+ Scheme morphism:
921
+ From: 2-d affine toric variety
922
+ To: 3-d CPR-Fano toric variety covered by 4 affine patches
923
+ Defn: Defined by sending Rational polyhedral fan in Sublattice
924
+ <N(1, 0, 0), N(0, 1, 0)> to Rational polyhedral fan in 3-d lattice N.
925
+ sage: phi1 * phi2 * phi3 == phi
926
+ True
927
+ """
928
+ f = self.fan_morphism() * right.fan_morphism()
929
+ return homset(f, self.codomain())
930
+
931
+ def _repr_defn(self):
932
+ """
933
+ Return a string representation of the definition of ``self``.
934
+
935
+ OUTPUT: string
936
+
937
+ EXAMPLES::
938
+
939
+ sage: P1xP1 = toric_varieties.P1xP1()
940
+ sage: P1 = toric_varieties.P1()
941
+ sage: f = P1xP1.hom(matrix([[1],[0]]), P1)
942
+ sage: f._repr_defn()
943
+ 'Defined by sending Rational polyhedral fan in 2-d lattice N to Rational polyhedral fan in 1-d lattice N.'
944
+ """
945
+ s = 'Defined by sending '
946
+ s += str(self.domain().fan())
947
+ s += ' to '
948
+ s += str(self.codomain().fan())
949
+ s += '.'
950
+ return s
951
+
952
+ def factor(self):
953
+ r"""
954
+ Factor ``self`` into injective * birational * surjective morphisms.
955
+
956
+ OUTPUT:
957
+
958
+ - a triple of toric morphisms `(\phi_i, \phi_b, \phi_s)`, such that
959
+ `\phi_s` is surjective, `\phi_b` is birational, `\phi_i` is injective,
960
+ and ``self`` is equal to `\phi_i \circ \phi_b \circ \phi_s`.
961
+
962
+ The intermediate varieties are universal in the following sense. Let
963
+ ``self`` map `X` to `X'` and let `X_s`, `X_i` sit in between, that is,
964
+
965
+ .. MATH::
966
+
967
+ X
968
+ \twoheadrightarrow
969
+ X_s
970
+ \to
971
+ X_i
972
+ \hookrightarrow
973
+ X'.
974
+
975
+ Then any toric morphism from `X` coinciding with ``self`` on the maximal
976
+ torus factors through `X_s` and any toric morphism into `X'` coinciding
977
+ with ``self`` on the maximal torus factors through `X_i`. In particular,
978
+ `X_i` is the closure of the image of ``self`` in `X'`.
979
+
980
+ See
981
+ :meth:`~sage.geometry.fan_morphism.FanMorphism.factor`
982
+ for a description of the toric algorithm.
983
+
984
+ EXAMPLES:
985
+
986
+ We map an affine plane into a projective 3-space in such a way, that it
987
+ becomes "a double cover of a chart of the blow up of one of the
988
+ coordinate planes"::
989
+
990
+ sage: A2 = toric_varieties.A2()
991
+ sage: P3 = toric_varieties.P(3)
992
+ sage: m = matrix([(2,0,0), (1,1,0)])
993
+ sage: phi = A2.hom(m, P3)
994
+ sage: phi.as_polynomial_map()
995
+ Scheme morphism:
996
+ From: 2-d affine toric variety
997
+ To: 3-d CPR-Fano toric variety covered by 4 affine patches
998
+ Defn: Defined on coordinates by sending [x : y] to
999
+ [x^2*y : y : 1 : 1]
1000
+
1001
+ sage: phi.is_surjective(), phi.is_birational(), phi.is_injective()
1002
+ (False, False, False)
1003
+ sage: phi_i, phi_b, phi_s = phi.factor()
1004
+ sage: phi_s.is_surjective(), phi_b.is_birational(), phi_i.is_injective()
1005
+ (True, True, True)
1006
+ sage: prod(phi.factor()) == phi
1007
+ True
1008
+
1009
+ Double cover (surjective)::
1010
+
1011
+ sage: phi_s.as_polynomial_map()
1012
+ Scheme morphism:
1013
+ From: 2-d affine toric variety
1014
+ To: 2-d affine toric variety
1015
+ Defn: Defined on coordinates by sending [x : y] to [x^2 : y]
1016
+
1017
+ Blowup chart (birational)::
1018
+
1019
+ sage: phi_b.as_polynomial_map()
1020
+ Scheme morphism:
1021
+ From: 2-d affine toric variety
1022
+ To: 2-d toric variety covered by 3 affine patches
1023
+ Defn: Defined on coordinates by sending [z0 : z1] to [1 : z1 : z0*z1]
1024
+
1025
+ Coordinate plane inclusion (injective)::
1026
+
1027
+ sage: phi_i.as_polynomial_map()
1028
+ Scheme morphism:
1029
+ From: 2-d toric variety covered by 3 affine patches
1030
+ To: 3-d CPR-Fano toric variety covered by 4 affine patches
1031
+ Defn: Defined on coordinates by sending [z0 : z1 : z2] to [z2 : z1 : z0 : z0]
1032
+ """
1033
+ phi_i, phi_b, phi_s = self.fan_morphism().factor()
1034
+ from sage.schemes.toric.variety import ToricVariety
1035
+ X = self.domain()
1036
+ X_s = ToricVariety(phi_s.codomain_fan())
1037
+ X_i = ToricVariety(phi_i.domain_fan())
1038
+ X_prime = self.codomain()
1039
+ return X_i.hom(phi_i, X_prime), X_s.hom(phi_b, X_i), X.hom(phi_s, X_s)
1040
+
1041
+ def fan_morphism(self):
1042
+ """
1043
+ Return the defining fan morphism.
1044
+
1045
+ OUTPUT: a :class:`~sage.geometry.fan_morphism.FanMorphism`
1046
+
1047
+ EXAMPLES::
1048
+
1049
+ sage: P1xP1 = toric_varieties.P1xP1()
1050
+ sage: P1 = toric_varieties.P1()
1051
+ sage: f = P1xP1.hom(matrix([[1],[0]]), P1)
1052
+ sage: f.fan_morphism()
1053
+ Fan morphism defined by the matrix
1054
+ [1]
1055
+ [0]
1056
+ Domain fan: Rational polyhedral fan in 2-d lattice N
1057
+ Codomain fan: Rational polyhedral fan in 1-d lattice N
1058
+ """
1059
+ return self._fan_morphism
1060
+
1061
+ def as_polynomial_map(self):
1062
+ """
1063
+ Express the morphism via homogeneous polynomials.
1064
+
1065
+ OUTPUT: a :class:`SchemeMorphism_polynomial_toric_variety`
1066
+
1067
+ This raises a :exc:`TypeError` if the morphism cannot be written
1068
+ in terms of homogeneous polynomials.
1069
+
1070
+ EXAMPLES::
1071
+
1072
+ sage: A1 = toric_varieties.A1()
1073
+ sage: square = A1.hom(matrix([[2]]), A1)
1074
+ sage: square.as_polynomial_map()
1075
+ Scheme endomorphism of 1-d affine toric variety
1076
+ Defn: Defined on coordinates by sending [z] to [z^2]
1077
+
1078
+ sage: P1 = toric_varieties.P1()
1079
+ sage: patch = A1.hom(matrix([[1]]), P1)
1080
+ sage: patch.as_polynomial_map()
1081
+ Scheme morphism:
1082
+ From: 1-d affine toric variety
1083
+ To: 1-d CPR-Fano toric variety covered by 2 affine patches
1084
+ Defn: Defined on coordinates by sending [z] to [z : 1]
1085
+ """
1086
+ R = self.domain().coordinate_ring()
1087
+ phi = self.fan_morphism()
1088
+ polys = [R.one()] * self.codomain().ngens()
1089
+ for rho, x in zip(phi.domain_fan(1), R.gens()):
1090
+ ray = rho.ray(0)
1091
+ sigma = phi.image_cone(rho)
1092
+ degrees = sigma.rays().matrix().solve_left(phi(ray))
1093
+ for i, d in zip(sigma.ambient_ray_indices(), degrees):
1094
+ try:
1095
+ d = ZZ(d)
1096
+ except TypeError:
1097
+ raise TypeError('the fan morphism cannot be written in '
1098
+ 'homogeneous polynomials')
1099
+ polys[i] *= x**d
1100
+ if phi.domain_fan().virtual_rays():
1101
+ raise NotImplementedError("polynomial representations for fans with"
1102
+ " virtual rays are not implemented yet")
1103
+ return SchemeMorphism_polynomial_toric_variety(self.parent(), polys)
1104
+
1105
+ def is_bundle(self):
1106
+ r"""
1107
+ Check if ``self`` is a bundle.
1108
+
1109
+ See :meth:`~sage.geometry.fan_morphism.FanMorphism.is_bundle`
1110
+ for fan morphisms for details.
1111
+
1112
+ OUTPUT: ``True`` if ``self`` is a bundle, ``False`` otherwise
1113
+
1114
+ EXAMPLES::
1115
+
1116
+ sage: P1xP1 = toric_varieties.P1xP1()
1117
+ sage: P1 = toric_varieties.P1()
1118
+ sage: P1xP1.hom(matrix([[1],[0]]), P1).is_bundle()
1119
+ True
1120
+ """
1121
+ return self.fan_morphism().is_bundle()
1122
+
1123
+ def is_fibration(self):
1124
+ r"""
1125
+ Check if ``self`` is a fibration.
1126
+
1127
+ See
1128
+ :meth:`~sage.geometry.fan_morphism.FanMorphism.is_fibration`
1129
+ for fan morphisms for details.
1130
+
1131
+ OUTPUT: ``True`` if ``self`` is a fibration, ``False`` otherwise
1132
+
1133
+ EXAMPLES::
1134
+
1135
+ sage: P1xP1 = toric_varieties.P1xP1()
1136
+ sage: P1 = toric_varieties.P1()
1137
+ sage: P1xP1.hom(matrix([[1],[0]]), P1).is_fibration()
1138
+ True
1139
+ """
1140
+ return self.fan_morphism().is_fibration()
1141
+
1142
+ def is_injective(self):
1143
+ r"""
1144
+ Check if ``self`` is injective.
1145
+
1146
+ See
1147
+ :meth:`~sage.geometry.fan_morphism.FanMorphism.is_injective`
1148
+ for fan morphisms for a description of the toric algorithm.
1149
+
1150
+ OUTPUT: boolean; whether ``self`` is injective
1151
+
1152
+ EXAMPLES::
1153
+
1154
+ sage: P1xP1 = toric_varieties.P1xP1()
1155
+ sage: P1 = toric_varieties.P1()
1156
+ sage: P1xP1.hom(matrix([[1],[0]]), P1).is_injective()
1157
+ False
1158
+
1159
+ sage: X = toric_varieties.A(2)
1160
+ sage: m = identity_matrix(2)
1161
+ sage: f = X.hom(m, X)
1162
+ sage: f.is_injective()
1163
+ True
1164
+
1165
+ sage: Y = ToricVariety(Fan([Cone([(1,0), (1,1)])]))
1166
+ sage: f = Y.hom(m, X)
1167
+ sage: f.is_injective()
1168
+ False
1169
+ """
1170
+ return self.fan_morphism().is_injective()
1171
+
1172
+ def is_surjective(self):
1173
+ r"""
1174
+ Check if ``self`` is surjective.
1175
+
1176
+ See
1177
+ :meth:`~sage.geometry.fan_morphism.FanMorphism.is_surjective`
1178
+ for fan morphisms for a description of the toric algorithm.
1179
+
1180
+ OUTPUT: boolean; whether ``self`` is surjective
1181
+
1182
+ EXAMPLES::
1183
+
1184
+ sage: P1xP1 = toric_varieties.P1xP1()
1185
+ sage: P1 = toric_varieties.P1()
1186
+ sage: P1xP1.hom(matrix([[1],[0]]), P1).is_surjective()
1187
+ True
1188
+
1189
+ sage: X = toric_varieties.A(2)
1190
+ sage: m = identity_matrix(2)
1191
+ sage: f = X.hom(m, X)
1192
+ sage: f.is_surjective()
1193
+ True
1194
+
1195
+ sage: Y = ToricVariety(Fan([Cone([(1,0), (1,1)])]))
1196
+ sage: f = Y.hom(m, X)
1197
+ sage: f.is_surjective()
1198
+ False
1199
+ """
1200
+ return self.fan_morphism().is_surjective()
1201
+
1202
+ def is_birational(self):
1203
+ r"""
1204
+ Check if ``self`` is birational.
1205
+
1206
+ See
1207
+ :meth:`~sage.geometry.fan_morphism.FanMorphism.is_birational`
1208
+ for fan morphisms for a description of the toric algorithm.
1209
+
1210
+ OUTPUT: boolean; whether ``self`` is birational
1211
+
1212
+ EXAMPLES::
1213
+
1214
+ sage: dP8 = toric_varieties.dP8()
1215
+ sage: P2 = toric_varieties.P2()
1216
+ sage: dP8.hom(identity_matrix(2), P2).is_birational()
1217
+ True
1218
+
1219
+ sage: X = toric_varieties.A(2)
1220
+ sage: Y = ToricVariety(Fan([Cone([(1,0), (1,1)])]))
1221
+ sage: m = identity_matrix(2)
1222
+ sage: f = Y.hom(m, X)
1223
+ sage: f.is_birational()
1224
+ True
1225
+ """
1226
+ return self.fan_morphism().is_birational()
1227
+
1228
+ def is_dominant(self):
1229
+ r"""
1230
+ Return whether ``self`` is dominant.
1231
+
1232
+ See
1233
+ :meth:`~sage.geometry.fan_morphism.FanMorphism.is_dominant`
1234
+ for fan morphisms for a description of the toric algorithm.
1235
+
1236
+ OUTPUT: boolean; whether ``self`` is a dominant scheme morphism
1237
+
1238
+ EXAMPLES::
1239
+
1240
+ sage: P1 = toric_varieties.P1()
1241
+ sage: A1 = toric_varieties.A1()
1242
+ sage: phi = A1.hom(identity_matrix(1), P1); phi
1243
+ Scheme morphism:
1244
+ From: 1-d affine toric variety
1245
+ To: 1-d CPR-Fano toric variety covered by 2 affine patches
1246
+ Defn: Defined by sending Rational polyhedral fan in 1-d lattice N
1247
+ to Rational polyhedral fan in 1-d lattice N.
1248
+ sage: phi.is_dominant()
1249
+ True
1250
+ sage: phi.is_surjective()
1251
+ False
1252
+ """
1253
+ return self.fan_morphism().is_dominant()
1254
+
1255
+ def pullback_divisor(self, divisor):
1256
+ r"""
1257
+ Pull back a toric divisor.
1258
+
1259
+ INPUT:
1260
+
1261
+ - ``divisor`` -- a torus-invariant `\QQ`-Cartier divisor on the
1262
+ codomain of ``self``
1263
+
1264
+ OUTPUT: the pull-back divisor `f^*(D)`
1265
+
1266
+ EXAMPLES::
1267
+
1268
+ sage: A2_Z2 = toric_varieties.A2_Z2()
1269
+ sage: A2 = toric_varieties.A2()
1270
+ sage: f = A2.hom(matrix([[1,0], [1,2]]), A2_Z2)
1271
+ sage: f.pullback_divisor(A2_Z2.divisor(0))
1272
+ V(x)
1273
+
1274
+ sage: A1 = toric_varieties.A1()
1275
+ sage: square = A1.hom(matrix([[2]]), A1)
1276
+ sage: D = A1.divisor(0); D
1277
+ V(z)
1278
+ sage: square.pullback_divisor(D)
1279
+ 2*V(z)
1280
+ """
1281
+ from sage.schemes.toric.divisor import ToricDivisor_generic
1282
+ if not (isinstance(divisor, ToricDivisor_generic) and divisor.is_QQ_Cartier()):
1283
+ raise ValueError('the divisor must be torus-invariant and QQ-Cartier')
1284
+ fm = self.fan_morphism()
1285
+ values = []
1286
+ for ray in self.domain().fan().rays():
1287
+ value = divisor.function_value(fm(ray))
1288
+ values.append(value)
1289
+ return self.domain().divisor(values)
1290
+
1291
+
1292
+ ############################################################################
1293
+ # A morphism of toric varieties determined by a dominant fan morphism
1294
+ class SchemeMorphism_fan_toric_variety_dominant(SchemeMorphism_fan_toric_variety):
1295
+ """
1296
+ Construct a morphism determined by a dominant fan morphism.
1297
+
1298
+ A dominant morphism is one that is surjective onto a dense
1299
+ subset. In the context of toric morphisms, this means that it is
1300
+ onto the big torus orbit.
1301
+
1302
+ .. WARNING::
1303
+
1304
+ You should not create objects of this class directly. Use the
1305
+ :meth:`~sage.schemes.generic.scheme.hom` method of
1306
+ :class:`toric varieties
1307
+ <sage.schemes.toric.variety.ToricVariety_field>`
1308
+ instead.
1309
+
1310
+ INPUT:
1311
+
1312
+ See :class:`SchemeMorphism_fan_toric_variety`. The given fan
1313
+ morphism :meth:`must be dominant
1314
+ <sage.geometry.fan_morphism.FanMorphism.is_dominant>`.
1315
+
1316
+ OUTPUT: a :class:`~sage.schemes.toric.morphism.SchemeMorphism_fan_toric_variety_dominant`
1317
+
1318
+ EXAMPLES::
1319
+
1320
+ sage: P2 = toric_varieties.P2()
1321
+ sage: dP8 = toric_varieties.dP8()
1322
+ sage: f = dP8.hom(identity_matrix(2), P2); f
1323
+ Scheme morphism:
1324
+ From: 2-d CPR-Fano toric variety covered by 4 affine patches
1325
+ To: 2-d CPR-Fano toric variety covered by 3 affine patches
1326
+ Defn: Defined by sending Rational polyhedral fan in 2-d lattice N
1327
+ to Rational polyhedral fan in 2-d lattice N.
1328
+ sage: type(f)
1329
+ <class 'sage.schemes.toric.morphism.SchemeMorphism_fan_toric_variety_dominant'>
1330
+ """
1331
+
1332
+ @cached_method
1333
+ def fiber_generic(self):
1334
+ r"""
1335
+ Return the generic fiber.
1336
+
1337
+ OUTPUT:
1338
+
1339
+ - a tuple `(X, n)`, where `X` is a :class:`toric variety
1340
+ <sage.schemes.toric.variety.ToricVariety_field>` with the
1341
+ embedding morphism into domain of ``self`` and `n` is an integer.
1342
+
1343
+ The fiber over the base point with homogeneous coordinates
1344
+ `[1:1:\cdots:1]` consists of `n` disjoint toric varieties isomorphic to
1345
+ `X`. Note that fibers of a dominant toric morphism are isomorphic over
1346
+ all points of a fixed torus orbit of its codomain, in particular over
1347
+ all points of the maximal torus, so it makes sense to talk about "the
1348
+ generic" fiber.
1349
+
1350
+ The embedding of `X` is a toric morphism with
1351
+ the :meth:`~sage.geometry.fan_morphism.FanMorphism.domain_fan`
1352
+ being the
1353
+ :meth:`~sage.geometry.fan_morphism.FanMorphism.kernel_fan` of
1354
+ the defining fan morphism. By contrast, embeddings of fiber components
1355
+ over lower-dimensional torus orbits of the image are not toric
1356
+ morphisms. Use :meth:`fiber_component` for the latter
1357
+ (non-generic) fibers.
1358
+
1359
+ EXAMPLES::
1360
+
1361
+ sage: P1xP1 = toric_varieties.P1xP1()
1362
+ sage: P1 = toric_varieties.P1()
1363
+ sage: fiber = P1xP1.hom(matrix([[1],[0]]), P1).fiber_generic()
1364
+ sage: fiber
1365
+ (1-d toric variety covered by 2 affine patches, 1)
1366
+ sage: f = fiber[0].embedding_morphism(); f
1367
+ Scheme morphism:
1368
+ From: 1-d toric variety covered by 2 affine patches
1369
+ To: 2-d CPR-Fano toric variety covered by 4 affine patches
1370
+ Defn: Defined by sending Rational polyhedral fan in Sublattice <N(0, 1)> to
1371
+ Rational polyhedral fan in 2-d lattice N.
1372
+ sage: f.as_polynomial_map()
1373
+ Scheme morphism:
1374
+ From: 1-d toric variety covered by 2 affine patches
1375
+ To: 2-d CPR-Fano toric variety covered by 4 affine patches
1376
+ Defn: Defined on coordinates by sending [z0 : z1] to [1 : 1 : z0 : z1]
1377
+
1378
+ sage: A1 = toric_varieties.A1()
1379
+ sage: fan = Fan([(0,1,2)], [(1,1,0), (1,0,1), (1,-1,-1)])
1380
+ sage: fan = fan.subdivide(new_rays=[(1,0,0)])
1381
+ sage: f = ToricVariety(fan).hom(matrix([[1],[0],[0]]), A1)
1382
+ sage: f.fiber_generic()
1383
+ (2-d affine toric variety, 1)
1384
+ sage: _[0].fan().generating_cones()
1385
+ (0-d cone of Rational polyhedral fan in Sublattice <N(0, 1, 0), N(0, 0, 1)>,)
1386
+ """
1387
+ from sage.schemes.toric.variety import ToricVariety
1388
+ fm = self.fan_morphism()
1389
+ X = ToricVariety(fm.kernel_fan())
1390
+ m = X.fan().lattice().echelonized_basis_matrix()
1391
+ N = fm.domain() # May be a sublattice as well
1392
+ m *= N.basis_matrix().solve_right(identity_matrix(N.dimension()))
1393
+ X._embedding_morphism = X.hom(m, self.domain())
1394
+ return X, fm.index()
1395
+
1396
+ def fiber_component(self, domain_cone, multiplicity=False):
1397
+ r"""
1398
+ Return a fiber component corresponding to ``domain_cone``.
1399
+
1400
+ INPUT:
1401
+
1402
+ - ``domain_cone`` -- a cone of the domain fan of ``self``
1403
+
1404
+ - ``multiplicity`` -- boolean (default: ``False``); whether to return
1405
+ the number of fiber components corresponding to ``domain_cone`` as well
1406
+
1407
+ OUTPUT:
1408
+
1409
+ - either `X` or a tuple `(X, n)`, where `X` is a :class:`toric variety
1410
+ <sage.schemes.toric.variety.ToricVariety_field>` with the
1411
+ embedding morphism into domain of ``self`` and `n` is an integer.
1412
+
1413
+ Let `\phi: \Sigma \to \Sigma'` be the :class:`fan morphism
1414
+ <sage.geometry.fan_morphism.FanMorphism>` corresponding to
1415
+ ``self``. Let `\sigma \in \Sigma` and `\sigma' \in \Sigma'` be
1416
+ the :meth:`~sage.geometry.fan_morphism.FanMorphism.image_cone`
1417
+ of `\sigma`. The fiber over any point of the torus orbit corresponding
1418
+ to `\sigma'` consists of `n` isomorphic connected components with each
1419
+ component being a union of toric varieties intersecting along
1420
+ their torus invariant subvarieties. The latter correspond to
1421
+ :meth:`~sage.geometry.fan_morphism.FanMorphism.preimage_cones` of
1422
+ `\sigma'` and `X` is one of the `n` components corresponding to
1423
+ `\sigma`. The irreducible components correspond to
1424
+ :meth:`~sage.geometry.fan_morphism.FanMorphism.primitive_preimage_cones`.
1425
+
1426
+ EXAMPLES::
1427
+
1428
+ sage: polytope = LatticePolytope(
1429
+ ....: [(-3,0,-1,-1),(-1,2,-1,-1),(0,-1,0,0),(0,0,0,1),(0,0,1,0),
1430
+ ....: (0,1,0,0),(0,2,-1,-1),(1,0,0,0),(2,0,-1,-1)])
1431
+ sage: coarse_fan = FaceFan(polytope)
1432
+ sage: P2 = toric_varieties.P2()
1433
+ sage: proj24 = matrix([[0,0], [1,0], [0,0], [0,1]])
1434
+ sage: fm = FanMorphism(proj24, coarse_fan, P2.fan(), subdivide=True)
1435
+ sage: fibration = ToricVariety(fm.domain_fan()).hom(fm, P2)
1436
+ sage: ffm = fibration.fan_morphism()
1437
+ sage: primitive_cones = ffm.primitive_preimage_cones(P2.fan(1)[0])
1438
+ sage: primitive_cone = primitive_cones[0]
1439
+ sage: fibration.fiber_component(primitive_cone)
1440
+ 2-d toric variety covered by 4 affine patches
1441
+ sage: fibration.fiber_component(primitive_cone, True)
1442
+ (2-d toric variety covered by 4 affine patches, 1)
1443
+
1444
+ sage: for primitive_cone in primitive_cones:
1445
+ ....: print(fibration.fiber_component(primitive_cone))
1446
+ 2-d toric variety covered by 4 affine patches
1447
+ 2-d toric variety covered by 3 affine patches
1448
+ 2-d toric variety covered by 3 affine patches
1449
+ """
1450
+ domain_cone = self.domain().fan().embed(domain_cone)
1451
+ if domain_cone.is_trivial():
1452
+ if multiplicity:
1453
+ return self.fiber_generic()
1454
+ else:
1455
+ return self.fiber_generic()[0]
1456
+ embedding = SchemeMorphism_fan_fiber_component_toric_variety(self, domain_cone)
1457
+ if multiplicity:
1458
+ return embedding.domain(), \
1459
+ self.fan_morphism().index(embedding.base_cone())
1460
+ else:
1461
+ return embedding.domain()
1462
+
1463
+ @cached_method
1464
+ def fiber_dimension(self, codomain_cone):
1465
+ r"""
1466
+ Return the dimension of the fiber over a particular torus
1467
+ orbit in the base.
1468
+
1469
+ INPUT:
1470
+
1471
+ - ``codomain_cone`` -- a cone `\sigma` of the codomain,
1472
+ specifying a torus orbit `O(\sigma)`
1473
+
1474
+ OUTPUT:
1475
+
1476
+ An integer. The dimension of the fiber over the torus orbit
1477
+ corresponding to ``codomain_cone``. If the fiber is the empty
1478
+ set, ``-1`` is returned. Note that all fibers over this torus
1479
+ orbit are isomorphic, and therefore have the same dimension.
1480
+
1481
+ EXAMPLES::
1482
+
1483
+ sage: P1xP1 = toric_varieties.P1xP1()
1484
+ sage: P1 = toric_varieties.P1()
1485
+ sage: f = P1xP1.hom(matrix([[1],[0]]), P1)
1486
+ sage: f.fiber_dimension(P1.fan(0)[0])
1487
+ 1
1488
+ sage: f.fiber_dimension(P1.fan(1)[0])
1489
+ 1
1490
+ sage: f.fiber_dimension(P1.fan(1)[1])
1491
+ 1
1492
+
1493
+ Here is a more complicated example that is not a flat fibration::
1494
+
1495
+ sage: A2_Z2 = toric_varieties.A2_Z2()
1496
+ sage: O2_P1 = A2_Z2.resolve(new_rays=[(1,1)])
1497
+ sage: blowup = O2_P1.hom(identity_matrix(2), A2_Z2)
1498
+ sage: blowup.fiber_dimension(A2_Z2.fan(0)[0])
1499
+ 0
1500
+ sage: blowup.fiber_dimension(A2_Z2.fan(1)[0])
1501
+ 0
1502
+ sage: blowup.fiber_dimension(A2_Z2.fan(2)[0])
1503
+ 1
1504
+
1505
+ This corresponds to the three different fibers::
1506
+
1507
+ sage: blowup.fiber_generic()
1508
+ (0-d affine toric variety, 1)
1509
+ sage: blowup.fiber_component(Cone([(1,0)]))
1510
+ 0-d affine toric variety
1511
+ sage: blowup.fiber_component(Cone([(1,1)]))
1512
+ 1-d toric variety covered by 2 affine patches
1513
+ """
1514
+ dim = []
1515
+ fm = self.fan_morphism()
1516
+ base_dim = codomain_cone.dim()
1517
+ dim.extend(base_dim - c.dim()
1518
+ for c in fm.primitive_preimage_cones(codomain_cone))
1519
+ if dim:
1520
+ return max(dim) + self.domain().dimension() - self.codomain().dimension()
1521
+ return ZZ(-1)
1522
+
1523
+ def fiber_graph(self, codomain_cone):
1524
+ r"""
1525
+ Return the fiber over a given torus orbit in the codomain.
1526
+
1527
+ INPUT:
1528
+
1529
+ - ``codomain_cone`` -- a cone `\sigma` of the codomain,
1530
+ specifying a torus orbit `O(\sigma)`
1531
+
1532
+ OUTPUT:
1533
+
1534
+ A graph whose nodes are the irreducible components of a connected
1535
+ component of the fiber over a point of `O(\sigma)`. If two irreducible
1536
+ components intersect, the
1537
+ corresponding nodes of the graph are joined by an edge. Note that
1538
+ irreducible components do not have to be of the same dimension.
1539
+
1540
+ .. SEEALSO::
1541
+
1542
+ :meth:`~SchemeMorphism_fan_toric_variety_dominant.fiber_component`.
1543
+
1544
+ EXAMPLES::
1545
+
1546
+ sage: polytope = Polyhedron(
1547
+ ....: [(-3,0,-1,-1),(-1,2,-1,-1),(0,-1,0,0),(0,0,0,1),(0,0,1,0),
1548
+ ....: (0,1,0,0),(0,2,-1,-1),(1,0,0,0),(2,0,-1,-1)])
1549
+ sage: coarse_fan = FaceFan(polytope, lattice=ToricLattice(4))
1550
+
1551
+ sage: P2 = toric_varieties.P2()
1552
+ sage: proj34 = block_matrix(2, 1, [zero_matrix(2,2),
1553
+ ....: identity_matrix(2)])
1554
+ sage: fm = FanMorphism(proj34, coarse_fan, P2.fan(), subdivide=True)
1555
+ sage: fibration = ToricVariety(fm.domain_fan()).hom(fm, P2)
1556
+
1557
+ sage: fibration.fiber_graph(P2.fan(0)[0])
1558
+ Graph on 1 vertex
1559
+ sage: for c1 in P2.fan(1):
1560
+ ....: fibration.fiber_graph(c1)
1561
+ Graph on 1 vertex
1562
+ Graph on 1 vertex
1563
+ Graph on 4 vertices
1564
+
1565
+ sage: fibration.fiber_graph(P2.fan(1)[2]).get_vertices()
1566
+ {0: 2-d toric variety covered by 4 affine patches,
1567
+ 1: 2-d toric variety covered by 3 affine patches,
1568
+ 2: 2-d toric variety covered by 3 affine patches,
1569
+ 3: 2-d toric variety covered by 4 affine patches}
1570
+
1571
+ sage: fibration
1572
+ Scheme morphism:
1573
+ From: 4-d toric variety covered by 18 affine patches
1574
+ To: 2-d CPR-Fano toric variety covered by 3 affine patches
1575
+ Defn: Defined by sending Rational polyhedral fan in 4-d lattice N
1576
+ to Rational polyhedral fan in 2-d lattice N.
1577
+ """
1578
+ fm = self.fan_morphism()
1579
+ prim = fm.primitive_preimage_cones(codomain_cone)
1580
+ n = len(prim)
1581
+
1582
+ def is_union_in_fan(self, c0, c1):
1583
+ indices = c0.ambient_ray_indices() + c1.ambient_ray_indices()
1584
+ try:
1585
+ fm.domain_fan().cone_containing(*indices)
1586
+ return True
1587
+ except ValueError:
1588
+ return False
1589
+
1590
+ m = matrix(ZZ, n, n, lambda i, j: is_union_in_fan(self, prim[i], prim[j]))
1591
+
1592
+ for i in range(n):
1593
+ m[i, i] = 0
1594
+ from sage.graphs.graph import Graph
1595
+ graph = Graph(m, loops=False, multiedges=False)
1596
+ for i in range(n):
1597
+ graph.set_vertex(i, self.fiber_component(prim[i]))
1598
+ return graph
1599
+
1600
+
1601
+ ############################################################################
1602
+ # The embedding morphism of a fiber component
1603
+ class SchemeMorphism_fan_fiber_component_toric_variety(SchemeMorphism):
1604
+ """
1605
+ The embedding of a fiber component of a toric morphism.
1606
+
1607
+ Note that the embedding map of a fiber component of a toric morphism is
1608
+ itself not a toric morphism!
1609
+
1610
+ INPUT:
1611
+
1612
+ - ``toric_morphism`` -- a toric morphism; the toric morphism whose
1613
+ fiber component we are describing
1614
+
1615
+ - ``defining_cone`` -- a cone of the fan of the domain of
1616
+ ``toric_morphism``; see
1617
+ :meth:`~SchemeMorphism_fan_toric_variety_dominant.fiber_component` for
1618
+ details
1619
+
1620
+ EXAMPLES::
1621
+
1622
+ sage: polytope = Polyhedron(
1623
+ ....: [(-3,0,-1,-1),(-1,2,-1,-1),(0,-1,0,0),(0,0,0,1),(0,0,1,0),
1624
+ ....: (0,1,0,0),(0,2,-1,-1),(1,0,0,0),(2,0,-1,-1)])
1625
+ sage: coarse_fan = FaceFan(polytope, lattice=ToricLattice(4))
1626
+ sage: P2 = toric_varieties.P2()
1627
+ sage: proj24 = matrix([[0,0],[1,0],[0,0],[0,1]])
1628
+ sage: fm = FanMorphism(proj24, coarse_fan, P2.fan(), subdivide=True)
1629
+ sage: fibration = ToricVariety(fm.domain_fan()).hom(fm, P2)
1630
+ sage: ffm = fibration.fan_morphism()
1631
+ sage: primitive_cones = ffm.primitive_preimage_cones(P2.fan(1)[0])
1632
+ sage: primitive_cone = primitive_cones[0]
1633
+ sage: fiber_component = fibration.fiber_component(primitive_cone)
1634
+ sage: fiber_component
1635
+ 2-d toric variety covered by 4 affine patches
1636
+ sage: fiber_component.embedding_morphism()
1637
+ Scheme morphism:
1638
+ From: 2-d toric variety covered by 4 affine patches
1639
+ To: 4-d toric variety covered by 23 affine patches
1640
+ Defn: Defined by embedding a fiber component corresponding to
1641
+ 1-d cone of Rational polyhedral fan in 4-d lattice N.
1642
+ sage: fiber_component.embedding_morphism().as_polynomial_map()
1643
+ Scheme morphism:
1644
+ From: 2-d toric variety covered by 4 affine patches
1645
+ To: 4-d toric variety covered by 23 affine patches
1646
+ Defn: Defined on coordinates by sending [z0 : z1 : z2 : z3] to
1647
+ [1 : 1 : 1 : 1 : z2 : 0 : 1 : z3 : 1 : 1 : 1 : z1 : z0 : 1 : 1]
1648
+ sage: type(fiber_component.embedding_morphism())
1649
+ <class 'sage.schemes.toric.morphism.SchemeMorphism_fan_fiber_component_toric_variety'>
1650
+ """
1651
+
1652
+ def __init__(self, toric_morphism, defining_cone):
1653
+ """
1654
+ The Python constructor.
1655
+
1656
+ TESTS::
1657
+
1658
+ sage: polytope = Polyhedron(
1659
+ ....: [(-3,0,-1,-1),(-1,2,-1,-1),(0,-1,0,0),(0,0,0,1),(0,0,1,0),
1660
+ ....: (0,1,0,0),(0,2,-1,-1),(1,0,0,0),(2,0,-1,-1)])
1661
+ sage: coarse_fan = FaceFan(polytope, lattice=ToricLattice(4))
1662
+ sage: P2 = toric_varieties.P2()
1663
+ sage: proj24 = matrix([[0,0], [1,0], [0,0], [0,1]])
1664
+ sage: fm = FanMorphism(proj24, coarse_fan, P2.fan(), subdivide=True)
1665
+ sage: fibration = ToricVariety(fm.domain_fan()).hom(fm, P2)
1666
+ sage: primitive_cone = Cone([(-1, 2, -1, 0)])
1667
+ sage: fibration.fiber_component(primitive_cone).embedding_morphism()
1668
+ Scheme morphism:
1669
+ From: 2-d toric variety covered by 3 affine patches
1670
+ To: 4-d toric variety covered by 23 affine patches
1671
+ Defn: Defined by embedding a fiber component corresponding to
1672
+ 1-d cone of Rational polyhedral fan in 4-d lattice N.
1673
+ """
1674
+ fm = toric_morphism.fan_morphism()
1675
+ self._fan_morphism = fm
1676
+ defining_cone = fm.domain_fan().embed(defining_cone)
1677
+ self._defining_cone = defining_cone
1678
+ self._base_cone = fm.image_cone(defining_cone)
1679
+ fc = self._make_fiber_component()
1680
+ fc._embedding_morphism = self
1681
+ parent = fc.Hom(toric_morphism.domain())
1682
+ SchemeMorphism.__init__(self, parent)
1683
+
1684
+ def _repr_defn(self):
1685
+ """
1686
+ Return a string representation of the definition of ``self``.
1687
+
1688
+ OUTPUT: string
1689
+
1690
+ EXAMPLES::
1691
+
1692
+ sage: P1xP1 = toric_varieties.P1xP1()
1693
+ sage: P1 = toric_varieties.P1()
1694
+ sage: fc = P1xP1.hom(matrix([[1],[0]]), P1).fiber_component(Cone([(1,0)]))
1695
+ sage: fc.embedding_morphism()._repr_defn()
1696
+ 'Defined by embedding a fiber component corresponding to 1-d cone of Rational polyhedral fan in 2-d lattice N.'
1697
+ """
1698
+ return 'Defined by embedding a fiber component corresponding to {}.'.format(self.defining_cone())
1699
+
1700
+ def as_polynomial_map(self):
1701
+ """
1702
+ Express the embedding morphism via homogeneous polynomials.
1703
+
1704
+ OUTPUT: a :class:`SchemeMorphism_polynomial_toric_variety`
1705
+
1706
+ This raises a :exc:`ValueError` if the morphism cannot be
1707
+ written in terms of homogeneous polynomials.
1708
+
1709
+ EXAMPLES::
1710
+
1711
+ sage: polytope = Polyhedron(
1712
+ ....: [(-3,0,-1,-1),(-1,2,-1,-1),(0,-1,0,0),(0,0,0,1),(0,0,1,0),
1713
+ ....: (0,1,0,0),(0,2,-1,-1),(1,0,0,0),(2,0,-1,-1)])
1714
+ sage: coarse_fan = FaceFan(polytope, lattice=ToricLattice(4))
1715
+ sage: P2 = toric_varieties.P2()
1716
+ sage: proj24 = matrix([[0,0], [1,0], [0,0], [0,1]])
1717
+ sage: fm = FanMorphism(proj24, coarse_fan, P2.fan(), subdivide=True)
1718
+ sage: fibration = ToricVariety(fm.domain_fan()).hom(fm, P2)
1719
+
1720
+ sage: primitive_cone = Cone([(0, 1, 0, 0)])
1721
+ sage: f = fibration.fiber_component(primitive_cone).embedding_morphism()
1722
+ sage: f.as_polynomial_map()
1723
+ Scheme morphism:
1724
+ From: 2-d toric variety covered by 4 affine patches
1725
+ To: 4-d toric variety covered by 23 affine patches
1726
+ Defn: Defined on coordinates by sending [z0 : z1 : z2 : z3] to
1727
+ [1 : 1 : 1 : 1 : z2 : 0 : 1 : z3 : 1 : 1 : 1 : z1 : z0 : 1 : 1]
1728
+
1729
+ sage: primitive_cone = Cone([(-1, 2, -1, 0)])
1730
+ sage: f = fibration.fiber_component(primitive_cone).embedding_morphism()
1731
+ sage: f.as_polynomial_map()
1732
+ Traceback (most recent call last):
1733
+ ...
1734
+ ValueError: the morphism cannot be written using homogeneous polynomials
1735
+ """
1736
+ fc = self.domain()
1737
+ toric_variety = self.codomain()
1738
+ R = fc.coordinate_ring()
1739
+ polys = [R.one()] * toric_variety.fan().nrays()
1740
+ for i in self.defining_cone().ambient_ray_indices():
1741
+ polys[i] = R.zero()
1742
+ for ray, x in zip(fc.fan().rays(), R.gens()):
1743
+ try:
1744
+ ray_index = self._ray_index_map[ray]
1745
+ except KeyError:
1746
+ raise ValueError('the morphism cannot be written using homogeneous polynomials')
1747
+ polys[ray_index] = x
1748
+ return SchemeMorphism_polynomial_toric_variety(self.parent(), polys)
1749
+
1750
+ def _make_fiber_component(self):
1751
+ """
1752
+ Construct the fiber component as a toric variety.
1753
+
1754
+ OUTPUT: the fiber component as a toric variety
1755
+
1756
+ EXAMPLES::
1757
+
1758
+ sage: P1xP1 = toric_varieties.P1xP1()
1759
+ sage: P1 = toric_varieties.P1()
1760
+ sage: fc = P1xP1.hom(matrix([[1],[0]]), P1).fiber_component(Cone([(1,0)]))
1761
+ sage: f = fc.embedding_morphism()
1762
+ sage: f._ray_index_map # indirect doctest
1763
+ {N(-1): 3, N(1): 2}
1764
+
1765
+ TESTS::
1766
+
1767
+ sage: A2_Z2 = toric_varieties.A2_Z2()
1768
+ sage: O2_P1 = A2_Z2.resolve(new_rays=[(1,1)])
1769
+ sage: blowup = O2_P1.hom(identity_matrix(2), A2_Z2)
1770
+ sage: blowup.fiber_generic()
1771
+ (0-d affine toric variety, 1)
1772
+ sage: blowup.fiber_component(Cone([(1,0)]))
1773
+ 0-d affine toric variety
1774
+ sage: blowup.fiber_component(Cone([(1,1)]))
1775
+ 1-d toric variety covered by 2 affine patches
1776
+
1777
+ sage: P1 = toric_varieties.P1()
1778
+ sage: f = P1.hom(matrix([2]), P1)
1779
+ sage: f.fiber_component(P1.fan(1)[0])
1780
+ 0-d affine toric variety
1781
+ sage: f.fan_morphism().index(P1.fan(1)[0])
1782
+ 1
1783
+ sage: f.fiber_generic()
1784
+ (0-d affine toric variety, 2)
1785
+ """
1786
+ fm = self._fan_morphism
1787
+ defining_cone = self._defining_cone
1788
+ base_cone = self._base_cone
1789
+
1790
+ ker = fm.kernel().basis()
1791
+ m = fm.matrix() * base_cone.lattice().basis_matrix()
1792
+ base_cone_preimg = [m.solve_left(r) for r in base_cone.rays()]
1793
+ L = fm.domain_fan().lattice().span(ker + base_cone_preimg).saturation()
1794
+
1795
+ cone_L = Cone([L.coordinates(r) for r in defining_cone.rays()])
1796
+ L_quotient = cone_L.sublattice_quotient()
1797
+
1798
+ def projection(ray):
1799
+ ray_L = L.coordinates(ray)
1800
+ return vector(ZZ, L_quotient(ray_L))
1801
+
1802
+ cones = []
1803
+ star_rays = set()
1804
+ for cone in fm.relative_star_generators(defining_cone):
1805
+ star_rays.update(cone.rays())
1806
+ projected_rays = [projection(r) for r in cone.rays()]
1807
+ cones.append(Cone(projected_rays))
1808
+ fiber_fan = Fan(cones)
1809
+
1810
+ ray_index_map = {}
1811
+ for ray in star_rays:
1812
+ ray_index = fm.domain_fan().rays().index(ray)
1813
+ projected_ray = fiber_fan.lattice()(projection(ray))
1814
+ if projected_ray.is_zero():
1815
+ assert ray in defining_cone.rays()
1816
+ continue
1817
+ projected_ray.set_immutable()
1818
+ ray_index_map[projected_ray] = ray_index
1819
+ self._ray_index_map = ray_index_map
1820
+
1821
+ from sage.schemes.toric.variety import ToricVariety
1822
+ return ToricVariety(fiber_fan)
1823
+
1824
+ def defining_cone(self):
1825
+ r"""
1826
+ Return the cone corresponding to the fiber torus orbit.
1827
+
1828
+ OUTPUT: a cone of the fan of the total space of the toric fibration
1829
+
1830
+ EXAMPLES::
1831
+
1832
+ sage: P1xP1 = toric_varieties.P1xP1()
1833
+ sage: P1 = toric_varieties.P1()
1834
+ sage: fc = P1xP1.hom(matrix([[1],[0]]), P1).fiber_component(Cone([(1,0)]))
1835
+ sage: f = fc.embedding_morphism()
1836
+ sage: f.defining_cone().rays()
1837
+ N(1, 0)
1838
+ in 2-d lattice N
1839
+ sage: f.base_cone().rays()
1840
+ N(1)
1841
+ in 1-d lattice N
1842
+ """
1843
+ return self._defining_cone
1844
+
1845
+ def base_cone(self):
1846
+ r"""
1847
+ Return the base cone `\sigma`.
1848
+
1849
+ The fiber is constant over the base orbit closure `V(\sigma)`.
1850
+
1851
+ OUTPUT: a cone of the base of the toric fibration
1852
+
1853
+ EXAMPLES::
1854
+
1855
+ sage: P1xP1 = toric_varieties.P1xP1()
1856
+ sage: P1 = toric_varieties.P1()
1857
+ sage: fc = P1xP1.hom(matrix([[1],[0]]), P1).fiber_component(Cone([(1,0)]))
1858
+ sage: f = fc.embedding_morphism()
1859
+ sage: f.defining_cone().rays()
1860
+ N(1, 0)
1861
+ in 2-d lattice N
1862
+ sage: f.base_cone().rays()
1863
+ N(1)
1864
+ in 1-d lattice N
1865
+ """
1866
+ return self._base_cone
1867
+
1868
+ def _image_ray_multiplicity(self, fiber_ray):
1869
+ """
1870
+ Find the image ray of ``fiber_ray`` with multiplicity in the relative star.
1871
+
1872
+ INPUT:
1873
+
1874
+ - ``fiber_ray`` -- a ray of the domain fan (the fiber component)
1875
+
1876
+ OUTPUT: a pair ``(codomain ray index, multiplicity)``
1877
+
1878
+ EXAMPLES::
1879
+
1880
+ sage: polytope = Polyhedron(
1881
+ ....: [(-3,0,-1,-1),(-1,2,-1,-1),(0,-1,0,0),(0,0,0,1),(0,0,1,0),
1882
+ ....: (0,1,0,0),(0,2,-1,-1),(1,0,0,0),(2,0,-1,-1)])
1883
+ sage: coarse_fan = FaceFan(polytope, lattice=ToricLattice(4))
1884
+ sage: P2 = toric_varieties.P2()
1885
+ sage: proj24 = matrix([[0,0], [1,0], [0,0], [0,1]])
1886
+ sage: fm = FanMorphism(proj24, coarse_fan, P2.fan(), subdivide=True)
1887
+ sage: fibration = ToricVariety(fm.domain_fan()).hom(fm, P2)
1888
+ sage: primitive_cone = Cone([(-1, 2, -1, 0)])
1889
+ sage: fc = fibration.fiber_component(primitive_cone)
1890
+ sage: f = fc.embedding_morphism()
1891
+ sage: for r in fc.fan().rays():
1892
+ ....: print("{} {}".format(r, f._image_ray_multiplicity(r)))
1893
+ N(-1, -1) (9, 2)
1894
+ N(0, 1) (5, 1)
1895
+ N(1, 0) (11, 1)
1896
+ sage: f._ray_index_map
1897
+ {N(-2, -2): 9, N(-1, 2): 4, N(0, 1): 5, N(1, 0): 11, N(3, -2): 10}
1898
+ """
1899
+ try:
1900
+ image_ray_index = self._ray_index_map[fiber_ray]
1901
+ return (image_ray_index, 1)
1902
+ except KeyError:
1903
+ pass
1904
+ multiplicity = None
1905
+ image_ray_index = None
1906
+ for ray, index in self._ray_index_map.items():
1907
+ d = gcd(ray)
1908
+ if d * fiber_ray != ray:
1909
+ continue
1910
+ if multiplicity is not None and d > multiplicity:
1911
+ continue
1912
+ multiplicity = d
1913
+ image_ray_index = index
1914
+ return (image_ray_index, multiplicity)
1915
+
1916
+ def pullback_divisor(self, divisor):
1917
+ r"""
1918
+ Pull back a toric divisor.
1919
+
1920
+ INPUT:
1921
+
1922
+ - ``divisor`` -- a torus-invariant `\QQ`-Cartier divisor on the
1923
+ codomain of the embedding map
1924
+
1925
+ OUTPUT:
1926
+
1927
+ A divisor on the domain of the embedding map (irreducible
1928
+ component of a fiber of a toric morphism) that is isomorphic
1929
+ to the pull-back divisor `f^*(D)` but with possibly different
1930
+ linearization.
1931
+
1932
+ EXAMPLES::
1933
+
1934
+ sage: A1 = toric_varieties.A1()
1935
+ sage: fan = Fan([(0,1,2)], [(1,1,0),(1,0,1),(1,-1,-1)]).subdivide(new_rays=[(1,0,0)])
1936
+ sage: f = ToricVariety(fan).hom(matrix([[1],[0],[0]]), A1)
1937
+ sage: D = f.domain().divisor([1,1,3,4]); D
1938
+ V(z0) + V(z1) + 3*V(z2) + 4*V(z3)
1939
+ sage: fc = f.fiber_component(Cone([(1,1,0)]))
1940
+ sage: fc.embedding_morphism().pullback_divisor(D)
1941
+ 4*V(z0) + V(z1) + 4*V(z2)
1942
+ sage: fc = f.fiber_component(Cone([(1,0,0)]))
1943
+ sage: fc.embedding_morphism().pullback_divisor(D)
1944
+ -V(z0) - 3*V(z1) - 3*V(z2)
1945
+ """
1946
+ from sage.schemes.toric.divisor import ToricDivisor_generic
1947
+ if not (isinstance(divisor, ToricDivisor_generic) and divisor.is_QQ_Cartier()):
1948
+ raise ValueError('the divisor must be torus-invariant and QQ-Cartier')
1949
+ m = divisor.m(self.defining_cone())
1950
+ values = []
1951
+ codomain_rays = self.codomain().fan().rays()
1952
+ for ray in self.domain().fan().rays():
1953
+ image_ray_index, multiplicity = self._image_ray_multiplicity(ray)
1954
+ image_ray = codomain_rays[image_ray_index]
1955
+ value = divisor.function_value(image_ray) - m * image_ray
1956
+ value /= multiplicity
1957
+ values.append(value)
1958
+ return self.domain().divisor(values)