-
Notifications
You must be signed in to change notification settings - Fork 113
/
constructors.jl
261 lines (219 loc) · 7.69 KB
/
constructors.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
@doc raw"""
blow_up(m::NormalToricVariety, I::ToricIdealSheafFromCoxRingIdeal; coordinate_name::String = "e")
Blow up the toric variety along the center given by a toric ideal sheaf.
# Examples
```jldoctest
julia> P3 = projective_space(NormalToricVariety, 3)
Normal toric variety
julia> x1, x2, x3, x4 = gens(cox_ring(P3))
4-element Vector{MPolyDecRingElem{QQFieldElem, QQMPolyRingElem}}:
x1
x2
x3
x4
julia> II = ideal_sheaf(P3, ideal([x1*x2]))
Sheaf of ideals
on normal toric variety
with restrictions
1: Ideal (x_1_1*x_2_1)
2: Ideal (x_2_2)
3: Ideal (x_1_3)
4: Ideal (x_1_4*x_2_4)
julia> blow_down_morphism = blow_up(P3, II)
Blowup
of normal toric variety
in sheaf of ideals with restrictions
1b: Ideal (x_1_1*x_2_1)
2b: Ideal (x_2_2)
3b: Ideal (x_1_3)
4b: Ideal (x_1_4*x_2_4)
with domain
scheme over QQ covered with 4 patches
1a: [x_1_1, x_2_1, x_3_1] scheme(0)
2a: [x_1_2, x_2_2, x_3_2] scheme(0)
3a: [x_1_3, x_2_3, x_3_3] scheme(0)
4a: [x_1_4, x_2_4, x_3_4] scheme(0)
and exceptional divisor
effective cartier divisor defined by
sheaf of ideals with restrictions
1a: Ideal (x_1_1*x_2_1)
2a: Ideal (x_2_2)
3a: Ideal (x_1_3)
4a: Ideal (x_1_4*x_2_4)
```
"""
function blow_up(m::NormalToricVariety, I::ToricIdealSheafFromCoxRingIdeal; coordinate_name::String = "e")
defining_ideal = ideal_in_cox_ring(I)
if all(x -> x in gens(base_ring(defining_ideal)), gens(defining_ideal))
return blow_up(m, defining_ideal; coordinate_name) # Apply toric method
else
return blow_up(I) # Reroute to scheme theory
end
end
@doc raw"""
blow_up(v::NormalToricVariety, new_ray::AbstractVector{<:IntegerUnion}; coordinate_name::String = "e")
Blow up the toric variety by subdividing the fan of the variety with the
provided new ray. Note that this ray must be a primitive element in the
lattice Z^d, with d the dimension of the fan. This function returns the
corresponding blowdown morphism.
By default, we pick "e" as the name of the homogeneous coordinate for
the exceptional divisor. As third optional argument one can supply
a custom variable name.
# Examples
```jldoctest
julia> P3 = projective_space(NormalToricVariety, 3)
Normal toric variety
julia> blow_down_morphism = blow_up(P3, [0, 1, 1])
Toric blowdown morphism
julia> bP3 = domain(blow_down_morphism)
Normal toric variety
julia> cox_ring(bP3)
Multivariate polynomial ring in 5 variables over QQ graded by
x1 -> [1 0]
x2 -> [0 1]
x3 -> [0 1]
x4 -> [1 0]
e -> [1 -1]
julia> typeof(center(blow_down_morphism))
Oscar.ToricIdealSheafFromCoxRingIdeal{NormalToricVariety, AbsAffineScheme, Ideal, Map}
julia> Oscar.ideal_in_cox_ring(center(blow_down_morphism))
Ideal generated by
x2
x3
```
Notice that in the above example, the blowup center is not just an ideal sheaf.
Rather, it is an ideal sheaf that knows its datum, in the form of an ideal,
in the Cox ring. Sadly, we cannot always (at least not yet) compute such a datum.
The following example demonstrates such a case.
# Examples
```jldoctest
julia> rs = [1 1; -1 1]
2×2 Matrix{Int64}:
1 1
-1 1
julia> max_cones = IncidenceMatrix([[1, 2]])
1×2 IncidenceMatrix
[1, 2]
julia> v = normal_toric_variety(max_cones, rs)
Normal toric variety
julia> bu = blow_up(v, [0, 1])
Toric blowdown morphism
julia> center(bu)
Sheaf of ideals
on normal, non-smooth toric variety
with restriction
1: Ideal (x_3_1, x_2_1, x_1_1)
julia> typeof(center(bu))
IdealSheaf{NormalToricVariety, AbsAffineScheme, Ideal, Map}
```
"""
function blow_up(v::NormalToricVariety, new_ray::AbstractVector{<:IntegerUnion}; coordinate_name::String = "e")
new_variety = normal_toric_variety(star_subdivision(v, new_ray))
@req n_rays(v) != n_rays(new_variety) "New ray already a ray of the given toric variety"
if is_smooth(v) == false
return ToricBlowdownMorphism(v, new_variety, coordinate_name, new_ray)
end
inx = _get_maximal_cones_containing_vector(polyhedral_fan(v), new_ray)
old_rays = matrix(ZZ, rays(v))
cone_generators = matrix(ZZ, [old_rays[i,:] for i in 1:nrows(old_rays) if ray_indices(maximal_cones(v))[inx[1], i]])
powers = solve_non_negative(ZZMatrix, transpose(cone_generators), transpose(matrix(ZZ, [new_ray])))
if nrows(powers) != 1
return ToricBlowdownMorphism(v, new_variety, coordinate_name, new_ray)
end
gens_S = gens(cox_ring(v))
variables = [gens_S[i] for i in 1:nrows(old_rays) if ray_indices(maximal_cones(v))[inx[1], i]]
list_of_gens = [variables[i]^powers[i] for i in 1:length(powers) if powers[i] != 0]
center = ideal_sheaf(v, ideal([variables[i]^powers[i] for i in 1:length(powers) if powers[i] != 0]))
return ToricBlowdownMorphism(v, new_variety, coordinate_name, center, new_ray)
end
@doc raw"""
blow_up(v::NormalToricVariety, n::Int; coordinate_name::String = "e")
Blow up the toric variety by subdividing the n-th cone in the list
of *all* cones of the fan of `v`. This cone need not be maximal.
This function returns the corresponding blowdown morphism.
By default, we pick "e" as the name of the homogeneous coordinate for
the exceptional divisor. As third optional argument one can supply
a custom variable name.
# Examples
```jldoctest
julia> P3 = projective_space(NormalToricVariety, 3)
Normal toric variety
julia> blow_down_morphism = blow_up(P3, 5)
Toric blowdown morphism
julia> bP3 = domain(blow_down_morphism)
Normal toric variety
julia> cox_ring(bP3)
Multivariate polynomial ring in 5 variables over QQ graded by
x1 -> [1 0]
x2 -> [0 1]
x3 -> [0 1]
x4 -> [1 0]
e -> [1 -1]
```
"""
function blow_up(v::NormalToricVariety, n::Int; coordinate_name::String = "e")
gens_S = gens(cox_ring(v))
center = ideal_sheaf(v, ideal([gens_S[i] for i in 1:number_of_rays(v) if cones(v)[n,i]]))
new_variety = normal_toric_variety(star_subdivision(v, n))
rays_of_variety = matrix(ZZ, rays(v))
new_ray = vec(sum([rays_of_variety[i, :] for i in 1:number_of_rays(v) if cones(v)[n, i]]))
return ToricBlowdownMorphism(v, new_variety, coordinate_name, center, new_ray)
end
@doc raw"""
blow_up(v::NormalToricVariety, I::MPolyIdeal; coordinate_name::String = "e")
Blow up the toric variety by subdividing the cone in the list
of *all* cones of the fan of `v` which corresponds to the
provided ideal `I`. Note that this cone need not be maximal.
By default, we pick "e" as the name of the homogeneous coordinate for
the exceptional divisor. As third optional argument one can supply
a custom variable name.
# Examples
```jldoctest
julia> P3 = projective_space(NormalToricVariety, 3)
Normal toric variety
julia> (x1,x2,x3,x4) = gens(cox_ring(P3))
4-element Vector{MPolyDecRingElem{QQFieldElem, QQMPolyRingElem}}:
x1
x2
x3
x4
julia> I = ideal([x2,x3])
Ideal generated by
x2
x3
julia> bP3 = domain(blow_up(P3, I))
Normal toric variety
julia> cox_ring(bP3)
Multivariate polynomial ring in 5 variables over QQ graded by
x1 -> [1 0]
x2 -> [0 1]
x3 -> [0 1]
x4 -> [1 0]
e -> [1 -1]
julia> I2 = ideal([x2 * x3])
Ideal generated by
x2*x3
julia> b2P3 = blow_up(P3, I2);
julia> codomain(b2P3) == P3
true
```
"""
function blow_up(v::NormalToricVariety, I::MPolyIdeal; coordinate_name::String = "e")
cox = cox_ring(v)
indices = [findfirst(y -> y == x, gens(cox)) for x in gens(I)]
if all(index -> index !== nothing, indices)
rs = matrix(ZZ, rays(v))
new_ray = vec(sum(rs[index, :] for index in indices))
new_ray = new_ray ./ gcd(new_ray)
new_variety = normal_toric_variety(star_subdivision(v, new_ray))
return ToricBlowdownMorphism(v, new_variety, coordinate_name, ideal_sheaf(v, I), new_ray)
else
return _generic_blow_up(v, I)
end
end
function _generic_blow_up(v::Any, I::Any)
error("Not yet supported")
end
function _generic_blow_up(v::NormalToricVariety, I::MPolyIdeal)
return blow_up(ideal_sheaf(v, I))
end