/
Constructors.jl
698 lines (551 loc) · 20.8 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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
export affine_space
export closure
export hypersurface_complement
export standard_spec
export subscheme
########################################################
# (1) Generic constructors
########################################################
@doc Markdown.doc"""
Spec(R::MPolyRing, I::MPolyIdeal)
Constructs the affine scheme of the ideal ``I`` in the ring ``R``.
This is the spectrum of the quotient ring ``R/I``.
# Examples
```jldoctest
julia> R, (x, y) = PolynomialRing(QQ, ["x", "y"]);
julia> I = ideal(R, [x]);
julia> Spec(R, I)
Spec of Quotient of Multivariate Polynomial Ring in x, y over Rational Field by ideal(x)
```
"""
Spec(R::MPolyRing, I::MPolyIdeal) = Spec(quo(R, I)[1])
@doc Markdown.doc"""
Spec(R::MPolyRing, U::AbsMPolyMultSet)
Given a polynomial ring ``R``, we can localize that polynomial
ring at a multiplicatively closed subset ``U`` of ``R``. The spectrum
of the localized ring $U^{-1} R$ is computed by this method.
# Examples
```jldoctest
julia> R, (x, y) = PolynomialRing(QQ, ["x", "y"]);
julia> I = ideal(R, [x]);
julia> U = complement_of_ideal(I);
julia> Spec(R, U)
Spec of localization of Multivariate Polynomial Ring in x, y over Rational Field at the complement of ideal(x)
```
"""
Spec(R::MPolyRing, U::AbsMPolyMultSet) = Spec(Localization(R, U)[1])
@doc Markdown.doc"""
Spec(R::MPolyRing, I::MPolyIdeal, U::AbsMPolyMultSet)
We allow to combine quotients and localizations at the same time.
That is, consider a polynomial ring ``R``, an ideal ``I`` of ``R`` and
a multiplicatively closed subset ``U`` of ``R``. The spectrum of the
localized ring $U^{-1} (R/I)$ is computed by this method.
# Examples
```jldoctest
julia> R, (x, y) = PolynomialRing(QQ, ["x", "y"]);
julia> I = ideal(R, [x]);
julia> U = complement_of_ideal(ideal(R, [y]));
julia> Spec(R, I, U)
Spec of Localization of Quotient of Multivariate Polynomial Ring in x, y over Rational Field by ideal(x) at the multiplicative set complement of ideal(y)
```
"""
Spec(R::MPolyRing, I::MPolyIdeal, U::AbsMPolyMultSet) = Spec(MPolyQuoLocalizedRing(R, I, U))
########################################################
# (2) Copy constructors
########################################################
#TODO: Do we need this? It is quite unusual.
@doc Markdown.doc"""
Spec(X::Spec)
For convenience, an affine spectrum can be passed to `Spec`
to create a new spectrum. This can be particularly useful
when in need to copy an affine spectrum.
# Examples
```jldoctest
julia> R, (x, y) = PolynomialRing(QQ, ["x", "y"]);
julia> I = ideal(R, [x]);
julia> X = Spec(R, I)
Spec of Quotient of Multivariate Polynomial Ring in x, y over Rational Field by ideal(x)
julia> Y = Spec(X)
Spec of Quotient of Multivariate Polynomial Ring in x, y over Rational Field by ideal(x)
```
"""
Spec(X::Spec) = Spec(OO(X))
Base.deepcopy_internal(X::Spec, dict::IdDict) = Spec(deepcopy_internal(OO(X), dict))
########################################################
# (3) Affine n-dimensional space
########################################################
@doc Markdown.doc"""
affine_space(kk::BRT, n::Int; variable_name="x") where {BRT<:Ring}
The ``n``-dimensional affine space over a ring ``kk`` is created
by this method. By default, the variable names are chosen as $x_1$, $x_2$
and so on. This choice can be overwritten with a third optional argument.
# Examples
```jldoctest
julia> affine_space(QQ, 5)
Spec of Multivariate Polynomial Ring in x1, x2, x3, x4, x5 over Rational Field
julia> affine_space(QQ,5,variable_name="y")
Spec of Multivariate Polynomial Ring in y1, y2, y3, y4, y5 over Rational Field
```
"""
function affine_space(kk::BRT, n::Int; variable_name="x") where {BRT<:Ring}
R, _ = PolynomialRing(kk, [variable_name * "$i" for i in 1:n])
return Spec(R)
end
@doc Markdown.doc"""
affine_space(kk::BRT, var_symbols::Vector{Symbol}) where {BRT<:Ring}
Creates the ``n``-dimensional affine space over a ring ``kk``,
but allows more flexibility in the choice of variable names.
The following example demonstrates this.
# Examples
```jldoctest
julia> affine_space(QQ,[:y1,:z2,:a])
Spec of Multivariate Polynomial Ring in y1, z2, a over Rational Field
```
"""
function affine_space(kk::BRT, var_symbols::Vector{Symbol}) where {BRT<:Ring}
R, _ = PolynomialRing(kk, var_symbols)
return Spec(R)
end
########################################################
# (4) StdSpec (needed?)
########################################################
@doc Markdown.doc"""
standard_spec(X::AbsSpec)
For an affine spectrum with coordinate ring of type `MPolyRing`,
`MPolyQuo`, or `MPolyLocalizedRing`, this returns the canonical
transform to a `Spec` of an `MPolyQuoLocalizedRing`.
# Examples
```jldoctest
julia> standard_spec(affine_space(QQ,5))
Spec of Localization of Quotient of Multivariate Polynomial Ring in x1, x2, x3, x4, x5 over Rational Field by ideal(0) at the multiplicative set powers of fmpq_mpoly[1]
```
"""
function standard_spec(X::AbsSpec)
error("not implemented for input of type $(typeof(X))")
end
standard_spec(X::AbsSpec{<:Any, <:MPolyRing}) = Spec(MPolyQuoLocalizedRing(OO(X), ideal(OO(X), [zero(OO(X))]), units_of(OO(X))))
#@doc Markdown.doc"""
# standard_spec(X::AbsSpec{<:Any, <:MPolyQuo})
#
#For an affine spectrum whose coordinate ring is the
#quotient of a polynomial ring, this method computes
#the standard spectrum.
#
## Examples
#```jldoctest
#julia> R, (x, y) = PolynomialRing(QQ, ["x", "y"]);
#
#julia> I = ideal(R, [x]);
#
#julia> X = Spec(R, I)
#Spec of Quotient of Multivariate Polynomial Ring in x, y over Rational Field by ideal(x)
#
#julia> standard_spec(X)
#Spec of Localization of Quotient of Multivariate Polynomial Ring in x, y over Rational Field by ideal(x) at the multiplicative set powers of fmpq_mpoly[1]
#```
#"""
function standard_spec(X::AbsSpec{<:Any, <:MPolyQuo})
A = OO(X)
R = base_ring(A)
return Spec(MPolyQuoLocalizedRing(R, modulus(A), units_of(R)))
end
#@doc Markdown.doc"""
# standard_spec(X::AbsSpec{<:Any, <:MPolyLocalizedRing})
#
#For an affine spectrum whose coordinate ring is the
#quotient of a polynomial ring, this method computes
#the standard spectrum.
#
## Examples
#```jldoctest
#julia> R, (x, y) = PolynomialRing(QQ, ["x", "y"]);
#
#julia> I = ideal(R, [x]);
#
#julia> U = complement_of_ideal(I);
#
#julia> X = Spec(R, U)
#Spec of localization of Multivariate Polynomial Ring in x, y over Rational Field at the complement of ideal(x)
#
#julia> standard_spec(X)
#Spec of Localization of Quotient of Multivariate Polynomial Ring in x, y over Rational Field by ideal(0) at the multiplicative set complement of ideal(x)
#```
#"""
standard_spec(X::AbsSpec{<:Any, <:MPolyLocalizedRing}) = Spec(MPolyQuoLocalizedRing(ambient_coordinate_ring(X), ideal(ambient_coordinate_ring(X), [zero(ambient_coordinate_ring(X))]), inverted_set(OO(X))))
#@doc Markdown.doc"""
# standard_spec(X::AbsSpec{<:Any, <:MPolyQuoLocalizedRing})
#
#For an affine spectrum whose coordinate ring is the
#quotient of a polynomial ring, this method computes
#the standard spectrum.
#
## Examples
#```jldoctest
#julia> R, (x, y) = PolynomialRing(QQ, ["x", "y"]);
#
#julia> I = ideal(R, [x]);
#
#julia> U = complement_of_ideal(ideal(R, [y]));
#
#julia> X = Spec(R, I, U)
#Spec of Localization of Quotient of Multivariate Polynomial Ring in x, y over Rational Field by ideal(x) at the multiplicative set complement of ideal(y)
#
#julia> standard_spec(X)
#Spec of Localization of Quotient of Multivariate Polynomial Ring in x, y over Rational Field by ideal(x) at the multiplicative set complement of ideal(y)
#```
#"""
standard_spec(X::AbsSpec{<:Any, <:MPolyQuoLocalizedRing}) = Spec(OO(X))
########################################################
# (5) Closed subschemes
########################################################
@doc Markdown.doc"""
subscheme(X::AbsSpec, f::Vector{<:RingElem})
For an affine spectrum ``X`` and elements ``f_1``, ``f_2``,
etc. of the coordinate ring of ``X``, this method computes
the subscheme ``V(f_1, f_2, \dots)`` of ``X``.
# Examples
```jldoctest
julia> X = affine_space(QQ,3)
Spec of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field
julia> R = OO(X)
Multivariate Polynomial Ring in x1, x2, x3 over Rational Field
julia> (x1,x2,x3) = gens(R)
3-element Vector{fmpq_mpoly}:
x1
x2
x3
julia> subscheme(X,x1)
Spec of Quotient of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field by ideal(x1)
julia> subscheme(X,[x1,x2])
Spec of Quotient of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field by ideal(x1, x2)
```
"""
subscheme(X::AbsSpec, f::Vector{<:RingElem}) = subscheme(X, ideal(OO(X), f))
function subscheme(X::Spec, f::Vector{<:RingElem})
all(x->(parent(x) == OO(X)), f) || return subscheme(X, OO(X).(f))
return subscheme(X, ideal(OO(X), f))
end
subscheme(X::AbsSpec, f::RingElem) = subscheme(X, ideal(OO(X), [f]))
@Markdown.doc """
subscheme(X::AbsSpec, I::Ideal)
For a scheme ``X = Spec(R)`` and an ideal ``I ⊂ 𝒪(X)``
this returns the closed subscheme defined by ``I``.
# Examples
```jldoctest
julia> X = affine_space(QQ,3)
Spec of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field
julia> R = OO(X)
Multivariate Polynomial Ring in x1, x2, x3 over Rational Field
julia> (x1,x2,x3) = gens(R)
3-element Vector{fmpq_mpoly}:
x1
x2
x3
julia> subscheme(X,ideal(R,[x1*x2]))
Spec of Quotient of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field by ideal(x1*x2)
```
"""
function subscheme(X::AbsSpec, I::Ideal)
base_ring(I) == OO(X) || return subscheme(X, ideal(OO(X), OO(X).(gens(I)))) # this will throw if coercion is not possible
Y = Spec(quo(OO(X), I)[1])
set_attribute!(Y, :ambient_space, ambient_space(X))
return Y
end
########################################################
# (6) Open subschemes
########################################################
@Markdown.doc """
hypersurface_complement(X::AbsSpec, f::RingElem)
For a scheme ``X = Spec(R)`` and an element ``f ∈ R``
this returns the open subscheme ``U = Spec(R[f⁻¹]) = X ∖ V(f)``
defined by the complement of the vanishing locus of ``f``.
# Examples
```jldoctest
julia> X = affine_space(QQ,3)
Spec of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field
julia> R = OO(X)
Multivariate Polynomial Ring in x1, x2, x3 over Rational Field
julia> (x1, x2, x3) = gens(R)
3-element Vector{fmpq_mpoly}:
x1
x2
x3
julia> hypersurface_complement(X, x1)
Spec of localization of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field at the powers of fmpq_mpoly[x1]
```
"""
function hypersurface_complement(X::AbsSpec, f::RingElem)
return hypersurface_complement(underlying_scheme(X), f)::AbsSpec
end
function hypersurface_complement(X::SpecType, f::RingElem) where {SpecType<:AbsSpec{<:Any, <:MPolyQuoLocalizedRing}}
parent(f) == OO(X) || return hypersurface_complement(X, OO(X)(f))
h = lifted_numerator(f)
U = MPolyPowersOfElement(h)
W, _ = Localization(OO(X), U)
Y = Spec(W)
set_attribute!(Y, :ambient_space, ambient_space(X))
return Y
end
function hypersurface_complement(X::SpecType, f::RingElem) where {SpecType<:AbsSpec{<:Any, <:MPolyLocalizedRing}}
parent(f) == OO(X) || return hypersurface_complement(X, OO(X)(f))
h = numerator(f)
U = MPolyPowersOfElement(h)
W, _ = Localization(OO(X), U)
Y = Spec(W)
set_attribute!(Y, :ambient_space, ambient_space(X))
return Y
end
function hypersurface_complement(X::SpecType, f::RingElem) where {SpecType<:AbsSpec{<:Any, <:MPolyRing}}
parent(f) == OO(X) || return hypersurface_complement(X, OO(X)(f))
U = MPolyPowersOfElement(f)
W, _ = Localization(OO(X), U)
Y = Spec(W)
set_attribute!(Y, :ambient_space, ambient_space(X))
return Y
end
function hypersurface_complement(X::SpecType, f::RingElem) where {SpecType<:AbsSpec{<:Any, <:MPolyQuo}}
parent(f) == OO(X) || return hypersurface_complement(X, OO(X)(f))
U = MPolyPowersOfElement(lift(f))
W, _ = Localization(OO(X), U)
Y = Spec(W)
set_attribute!(Y, :ambient_space, ambient_space(X))
return Y
end
@Markdown.doc """
hypersurface_complement(X::AbsSpec, f::Vector{<:RingElem})
For a scheme ``X = Spec(R)`` and elements ``f₁, f₂, ... ∈ R``
this returns the open subscheme ``U = Spec(R[f₁⁻¹,f₂⁻¹, ...]) = X ∖ V(f₁⋅f₂⋅…)``
defined by the complement of the vanishing locus of the product ``f₁⋅f₂⋅…``.
# Examples
```jldoctest
julia> X = affine_space(QQ,3)
Spec of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field
julia> R = OO(X)
Multivariate Polynomial Ring in x1, x2, x3 over Rational Field
julia> (x1,x2,x3) = gens(R)
3-element Vector{fmpq_mpoly}:
x1
x2
x3
julia> hypersurface_complement(X,[x1,x2])
Spec of localization of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field at the powers of fmpq_mpoly[x1, x2]
```
"""
function hypersurface_complement(X::AbsSpec, f::Vector{<:RingElem})
return hypersurface_complement(underlying_scheme(X), f)::AbsSpec
end
function hypersurface_complement(X::SpecType, f::Vector{<:RingElem}) where {SpecType<:AbsSpec{<:Any, <:MPolyQuoLocalizedRing}}
all(x->(parent(x) == OO(X)), f) || return hypersurface_complement(X, OO(X).(f))
h = lifted_numerator.(f)
U = MPolyPowersOfElement(ambient_coordinate_ring(X), h)
W, _ = Localization(OO(X), U)
Y = Spec(W)
set_attribute!(Y, :ambient_space, ambient_space(X))
return Y
end
function hypersurface_complement(X::SpecType, f::Vector{<:RingElem}) where {SpecType<:AbsSpec{<:Any, <:MPolyLocalizedRing}}
all(x->(parent(x) == OO(X)), f) || return hypersurface_complement(X, OO(X).(f))
h = numerator.(f)
U = MPolyPowersOfElement(ambient_coordinate_ring(X), h)
W, _ = Localization(OO(X), U)
Y = Spec(W)
set_attribute!(Y, :ambient_space, ambient_space(X))
return Y
end
function hypersurface_complement(X::SpecType, f::Vector{<:RingElem}) where {SpecType<:AbsSpec{<:Any, <:MPolyRing}}
all(x->(parent(x) == OO(X)), f) || return hypersurface_complement(X, OO(X).(f))
U = MPolyPowersOfElement(ambient_coordinate_ring(X), f)
W, _ = Localization(OO(X), U)
Y = Spec(W)
set_attribute!(Y, :ambient_space, ambient_space(X))
return Y
end
function hypersurface_complement(X::SpecType, f::Vector{<:RingElem}) where {SpecType<:AbsSpec{<:Any, <:MPolyQuo}}
all(x->(parent(x) == OO(X)), f) || return hypersurface_complement(X, OO(X).(f))
U = MPolyPowersOfElement(ambient_coordinate_ring(X), lift.(f))
W, _ = Localization(OO(X), U)
Y = Spec(W)
set_attribute!(Y, :ambient_space, ambient_space(X))
return Y
end
########################################################
# (7) Intersections of (affine) schemes
########################################################
# 7.1 Intersection methods involving an empty scheme
Base.intersect(E::EmptyScheme{BRT}, X::Scheme{BRT}) where {BRT<:Ring} = E
Base.intersect(X::Scheme{BRT}, E::EmptyScheme{BRT}) where {BRT<:Ring} = E
Base.intersect(X::EmptyScheme{BRT}, E::EmptyScheme{BRT}) where {BRT<:Ring} = E
# 7.2 Intersection methods not involving empty schemes
### For Specs of MPolyRings
# TODO intersect X,Y for X<Y should return a copy of X with === ambient_coordinate_rings
# Spec(X) does not apply for instance to principal open subsets hence a change
# is necessary
@Markdown.doc """
Base.intersect(X::AbsSpec, Y::AbsSpec)
This method computes the intersection to two affine
schemes that reside in the same ambient affine space.
# Examples
```jldoctest
julia> X = affine_space(QQ,3)
Spec of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field
julia> R = OO(X)
Multivariate Polynomial Ring in x1, x2, x3 over Rational Field
julia> (x1,x2,x3) = gens(R)
3-element Vector{fmpq_mpoly}:
x1
x2
x3
julia> Y1 = subscheme(X,[x1])
Spec of Quotient of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field by ideal(x1)
julia> Y2 = subscheme(X,[x2])
Spec of Quotient of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field by ideal(x2)
julia> intersect(Y1, Y2)
Spec of Quotient of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field by ideal(x1, x2)
```
"""
function Base.intersect(X::AbsSpec{BRT, <:Ring}, Y::AbsSpec{BRT, <:Ring}) where {BRT<:Ring}
error("method not implemted for arguments of type $(typeof(X)) and $(typeof(Y))")
end
function Base.intersect(
X::AbsSpec{BRT, <:MPolyRing},
Y::AbsSpec{BRT, <:MPolyRing}
) where {BRT<:Ring}
R = OO(X)
R == OO(Y) || error("schemes can not be compared")
return Spec(X)
end
function Base.intersect(
X::AbsSpec{BRT, <:MPolyRing},
Y::AbsSpec{BRT, <:MPolyQuo}
) where {BRT<:Ring}
R = OO(X)
R === ambient_coordinate_ring(Y) || error("schemes can not be compared")
return Spec(Y)
end
function Base.intersect(
X::AbsSpec{BRT, <:MPolyRing},
Y::AbsSpec{BRT, <:MPolyLocalizedRing}
) where {BRT<:Ring}
R = OO(X)
R === ambient_coordinate_ring(Y) || error("schemes can not be compared")
return Spec(Y)
end
function Base.intersect(
X::AbsSpec{BRT, <:MPolyRing},
Y::AbsSpec{BRT, <:MPolyQuoLocalizedRing}
) where {BRT<:Ring}
R = OO(X)
R === ambient_coordinate_ring(Y) || error("schemes can not be compared")
return Spec(Y)
end
function Base.intersect(
Y::AbsSpec{BRT, <:Ring},
X::AbsSpec{BRT, <:MPolyRing}
) where {BRT<:Ring}
return intersect(X, Y)
end
### For Specs of MPolyQuos
function Base.intersect(
X::AbsSpec{BRT, <:MPolyQuo},
Y::AbsSpec{BRT, <:MPolyQuo}
) where {BRT<:Ring}
R = ambient_coordinate_ring(X)
R === ambient_coordinate_ring(Y) || error("schemes can not be compared")
return Spec(quo(R, modulus(OO(X)) + modulus(OO(Y)))[1])
end
function Base.intersect(
X::AbsSpec{BRT, <:MPolyQuo},
Y::AbsSpec{BRT, <:MPolyLocalizedRing}
) where {BRT<:Ring}
R = ambient_coordinate_ring(X)
R === ambient_coordinate_ring(Y) || error("schemes can not be compared")
return Spec(quo(OO(Y), OO(Y)(modulus(OO(X))))[1])
end
function Base.intersect(
X::AbsSpec{BRT, <:MPolyQuo},
Y::AbsSpec{BRT, <:MPolyQuoLocalizedRing}
) where {BRT<:Ring}
R = ambient_coordinate_ring(X)
R === ambient_coordinate_ring(Y) || error("schemes can not be compared")
return Spec(quo(OO(Y), OO(Y)(modulus(OO(X))))[1])
end
function Base.intersect(
Y::AbsSpec{BRT, <:Ring},
X::AbsSpec{BRT, <:MPolyQuo}
) where {BRT<:Ring}
return intersect(X, Y)
end
### For Specs of MPolyLocalizedRings
function Base.intersect(
X::AbsSpec{BRT, <:MPolyLocalizedRing},
Y::AbsSpec{BRT, <:MPolyLocalizedRing}
) where {BRT<:Ring}
R = ambient_coordinate_ring(X)
R === ambient_coordinate_ring(Y) || error("schemes can not be compared")
return Spec(Localization(R, inverted_set(OO(X)) * inverted_set(OO(Y)))[1])
end
function Base.intersect(
X::AbsSpec{BRT, <:MPolyLocalizedRing},
Y::AbsSpec{BRT, <:MPolyQuoLocalizedRing}
) where {BRT<:Ring}
R = ambient_coordinate_ring(X)
R === ambient_coordinate_ring(Y) || error("schemes can not be compared")
return Spec(R, modulus(underlying_quotient(OO(Y))), inverted_set(OO(X))*inverted_set(OO(Y)))
end
function Base.intersect(
Y::AbsSpec{BRT, <:Ring},
X::AbsSpec{BRT, <:MPolyLocalizedRing}
) where {BRT<:Ring}
return intersect(X, Y)
end
### For Specs of MPolyQuoLocalizedRings
function Base.intersect(
X::AbsSpec{BRT, <:MPolyQuoLocalizedRing},
Y::AbsSpec{BRT, <:MPolyQuoLocalizedRing}
) where {BRT<:Ring}
R = ambient_coordinate_ring(X)
R === ambient_coordinate_ring(Y) || error("schemes can not be compared")
# Q, _ = quo(R, modulus(underlying_quotient(OO(X))) + modulus(underlying_quotient(OO(Y))))
return Spec(R, modulus(underlying_quotient(OO(X))) + modulus(underlying_quotient(OO(Y))),
inverted_set(OO(X)) * inverted_set(OO(Y)))
end
########################################################
# (8) Closure of affine scheme in another affine scheme
########################################################
#TODO: Add more cross-type methods as needed.
@Markdown.doc """
closure(X::AbsSpec, Y::AbsSpec)
Returns the closure of ``X`` in ``Y``.
# Examples
```jldoctest
julia> X = affine_space(QQ,3)
Spec of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field
julia> R = OO(X)
Multivariate Polynomial Ring in x1, x2, x3 over Rational Field
julia> (x1,x2,x3) = gens(R)
3-element Vector{fmpq_mpoly}:
x1
x2
x3
julia> H = subscheme(X,ideal(R,[x1]))
Spec of Quotient of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field by ideal(x1)
julia> closure(H, X)
Spec of Localization of Quotient of Multivariate Polynomial Ring in x1, x2, x3 over Rational Field by ideal(x1) at the multiplicative set powers of fmpq_mpoly[1]
```
"""
function closure(X::AbsSpec, Y::AbsSpec)
return closure(standard_spec(X), standard_spec(Y))
end
function closure(
X::Spec{BRT, RT},
Y::Spec{BRT, RT}
) where {BRT, RT<:MPolyQuoLocalizedRing{<:Any, <:Any, <:Any, <:Any,
<:MPolyPowersOfElement}}
issubset(X, Y) || error("the first argument is not a subset of the second")
is_closed_embedding(X, Y) && return X
W, _ = Localization(inverted_set(OO(X))*inverted_set(OO(Y)))
I = ideal(W, W.(gens(modulus(OO(X)))))
Isat = saturated_ideal(I)
R = ambient_coordinate_ring(Y)
return Spec(MPolyQuoLocalizedRing(R, Isat, inverted_set(OO(Y))))
end