-
Notifications
You must be signed in to change notification settings - Fork 113
/
Types.jl
696 lines (607 loc) · 28.9 KB
/
Types.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
export AbsPreSheaf
export AbsProjectiveScheme
export EmptyScheme
export IdealSheaf
export ProjectiveScheme
export ProjectiveSchemeMor
export VarietyFunctionField
export VarietyFunctionFieldElem
########################################################################
# Rational functions on irreducible varieties #
########################################################################
mutable struct VarietyFunctionField{BaseRingType<:Field,
FracFieldType<:AbstractAlgebra.Generic.FracField,
CoveredSchemeType<:AbsCoveredScheme,
AffineSchemeType<:AbsAffineScheme
} <: Field
kk::BaseRingType
X::CoveredSchemeType
U::AffineSchemeType # representative patch to represent rational functions
KK::FracFieldType
function VarietyFunctionField(
X::AbsCoveredScheme;
check::Bool=true,
representative_patch::AbsAffineScheme=default_covering(X)[1]
)
@check is_irreducible(X) "variety is not irreducible"
representative_patch in default_covering(X) || error("representative patch not found")
KK = fraction_field(ambient_coordinate_ring(representative_patch))
kk = base_ring(X)
return new{typeof(kk), typeof(KK), typeof(X), typeof(representative_patch)}(kk, X, representative_patch, KK)
end
end
########################################################################
# Elements of VarietyFunctionFields #
########################################################################
mutable struct VarietyFunctionFieldElem{FracType<:AbstractAlgebra.Generic.FracFieldElem,
ParentType<:VarietyFunctionField
}
KK::ParentType
f::FracType
function VarietyFunctionFieldElem(
KK::VarietyFunctionField,
f::AbstractAlgebra.Generic.FracFieldElem;
check::Bool=true
)
representative_field(KK) == parent(f) || error("element does not have the correct parent")
return new{typeof(f), typeof(KK)}(KK, f)
end
function VarietyFunctionFieldElem(
KK::VarietyFunctionField,
a::RingElem, b::RingElem;
check::Bool=true
)
R = parent(a)
R == parent(b) || error("parent rings not compatible")
R == base_ring(representative_field(KK))
f = representative_field(KK)(a, b)
return new{typeof(f), typeof(KK)}(KK, f)
end
end
########################################################################
# Sheaves #
########################################################################
@doc raw"""
AbsPreSheaf{SpaceType, OpenType, OutputType, RestrictionType}
Abstract type for a sheaf ℱ on a space X.
* `SpaceType` is a parameter for the type of the space ``X`` on which ``ℱ`` is defined.
* `OpenType` is a type (most probably abstract!) for the open sets ``U ⊂ X`` which are admissible as input for ``ℱ(U)``.
* `OutputType` is a type (most probably abstract!) for the values that ``ℱ`` takes on admissible open sets ``U``.
* `RestrictionType` is a parameter for the type of the restriction maps ``ℱ(V) → ℱ(U)`` for ``U ⊂ V ⊂ X`` open.
For any instance `F` of `AbsPreSheaf` on a topological space `X` the following methods are implemented:
* `F(U)` for *admissible* open subsets ``U ⊂ X``: This returns the value ``ℱ(U)`` of the sheaf `F` on `U`. Note that due to technical limitations, not every type of open subset might be admissible.
* `restriction_map(F, U, V)` for *admissible* open subsets ``V ⊂ U ⊂ X``: This returns the restriction map ``ρ : ℱ(U) → ℱ(V)``.
"""
abstract type AbsPreSheaf{SpaceType, OpenType, OutputType, RestrictionType} end
########################################################################
# A minimal implementation of the sheaf interface on a scheme #
########################################################################
@doc raw"""
PreSheafOnScheme
A basic minimal implementation of the interface for `AbsPreSheaf`; to be used internally.
"""
@attributes mutable struct PreSheafOnScheme{SpaceType, OpenType, OutputType, RestrictionType,
} <: AbsPreSheaf{
SpaceType, OpenType,
OutputType, RestrictionType
}
X::SpaceType
# caches
obj_cache::IdDict{<:OpenType, <:OutputType} # To cache values that have already been computed
#res_cache::IdDict{<:Tuple{<:OpenType, <:OpenType}, <:RestrictionType} # To cache already computed restrictions
# production functions for new objects
is_open_func::Function # To check whether one set is open in the other
production_func::Union{Function, Nothing} # To produce ℱ(U) for U ⊂ X
restriction_func::Union{Function, Nothing} # To produce the restriction maps ℱ(U) → ℱ(V) for V ⊂ U ⊂ X open
function PreSheafOnScheme(X::Scheme,
production_func::Union{Function, Nothing}=nothing,
restriction_func::Union{Function, Nothing}=nothing;
OpenType=AbsAffineScheme, OutputType=Any, RestrictionType=Any,
is_open_func::Any=is_open_embedding
)
return new{typeof(X), OpenType, OutputType, RestrictionType,
}(X, IdDict{OpenType, OutputType}(),
#IdDict{Tuple{OpenType, OpenType}, RestrictionType}(),
is_open_func, production_func, restriction_func
)
end
end
########################################################################
# Simplified Spectra #
########################################################################
@attributes mutable struct SimplifiedAffineScheme{BaseRingType, RingType<:Ring} <: AbsAffineScheme{BaseRingType, RingType}
X::AbsAffineScheme
Y::AbsAffineScheme
f::AbsAffineSchemeMor
g::AbsAffineSchemeMor
function SimplifiedAffineScheme(X::AbsAffineScheme, Y::AbsAffineScheme, f::AbsAffineSchemeMor, g::AbsAffineSchemeMor;
check::Bool=true
)
domain(f) === X || error("map is not compatible")
codomain(f) === Y || error("map is not compatible")
domain(g) === Y || error("map is not compatible")
codomain(g) === X || error("map is not compatible")
@check is_identity_map(compose(f, g)) && is_identity_map(compose(g, f)) "maps are not inverse to each other"
result = new{typeof(base_ring(X)), typeof(OO(X))}(X, Y)
# We need to rewrap the identification maps so that the (co-)domains match
fwrap = morphism(result, Y, pullback(f), check=false)
gwrap = morphism(Y, result, pullback(g), check=false)
set_attribute!(fwrap, :inverse, gwrap)
set_attribute!(gwrap, :inverse, fwrap)
result.f = fwrap
result.g = gwrap
return result
end
end
########################################################################
# The structure sheaf of affine and covered schemes #
########################################################################
@doc raw"""
StructureSheafOfRings <: AbsPreSheaf
On an `AbsCoveredScheme` ``X`` this returns the sheaf ``𝒪`` of rings of
regular functions on ``X``.
Note that due to technical reasons, the admissible open subsets are restricted
to the following:
* `U::AbsAffineScheme` among the `basic_patches` of the `default_covering` of `X`;
* `U::PrincipalOpenSubset` with `ambient_scheme(U)` in the `basic_patches` of the `default_covering` of `X`;
* `W::AffineSchemeOpenSubscheme` with `ambient_scheme(W)` in the `basic_patches` of the `default_covering` of `X`.
One can call the restriction maps of ``𝒪`` across charts, implicitly using the
identifications given by the gluings in the `default_covering`.
"""
@attributes mutable struct StructureSheafOfRings{SpaceType, OpenType, OutputType,
RestrictionType
} <: AbsPreSheaf{
SpaceType, OpenType,
OutputType, RestrictionType
}
OO::PreSheafOnScheme
### Structure sheaf on affine schemes
function StructureSheafOfRings(X::AbsAffineScheme)
function is_open_func(U::AbsAffineScheme, V::AbsAffineScheme)
return is_subset(V, X) && is_open_embedding(U, V) # Note the restriction to subsets of X
end
function production_func(F::AbsPreSheaf, U::AbsAffineScheme)
return OO(U)
end
function restriction_func(F::AbsPreSheaf, V::AbsAffineScheme, U::AbsAffineScheme)
OU = F(U) # assumed to be previously cached
OV = F(V) # same as above
return hom(OV, OU, gens(OU), check=false) # check=false assures quicker computation
end
R = PreSheafOnScheme(X, production_func, restriction_func,
OpenType=AbsAffineScheme, OutputType=Ring,
RestrictionType=Map,
is_open_func=is_open_func
)
return new{typeof(X), Union{AbsAffineScheme, AffineSchemeOpenSubscheme}, Ring, Map}(R)
end
### Structure sheaf on covered schemes
function StructureSheafOfRings(X::AbsCoveredScheme)
R = PreSheafOnScheme(X,
OpenType=Union{AbsAffineScheme, AffineSchemeOpenSubscheme}, OutputType=Ring,
RestrictionType=Map,
is_open_func=_is_open_func_for_schemes(X)
)
return new{typeof(X), Union{AbsAffineScheme, AffineSchemeOpenSubscheme}, Ring, Map}(R)
end
end
########################################################################
# Ideal sheaves on covered schemes #
########################################################################
@doc raw"""
AbsIdealSheaf <: AbsPreSheaf
A sheaf of ideals ``I`` on an `AbsCoveredScheme` ``X``.
For an affine open subset ``U ⊂ X`` call ``I(U)`` to obtain an ideal
in `OO(U)` representing `I`.
"""
abstract type AbsIdealSheaf{SpaceType, OpenType, OutputType,
RestrictionType
} <: AbsPreSheaf{
SpaceType, OpenType,
OutputType, RestrictionType
}
end
@doc raw"""
IdealSheaf <: AbsIdealSheaf
A sheaf of ideals ``ℐ`` on an `AbsCoveredScheme` ``X`` which is specified
by a collection of concrete ideals on some open covering of ``X``.
"""
@attributes mutable struct IdealSheaf{SpaceType, OpenType, OutputType,
RestrictionType
} <: AbsIdealSheaf{
SpaceType, OpenType,
OutputType, RestrictionType
}
ID::IdDict{AbsAffineScheme, Ideal} # the ideals on the patches of some covering of X
OOX::StructureSheafOfRings # the structure sheaf on X
I::PreSheafOnScheme # the underlying presheaf of ideals for caching
### Ideal sheaves on covered schemes
function IdealSheaf(X::AbsCoveredScheme, ID::IdDict{AbsAffineScheme, Ideal};
check::Bool=true
)
Ipre = PreSheafOnScheme(X,
OpenType=AbsAffineScheme, OutputType=Ideal,
RestrictionType=Map,
is_open_func=_is_open_func_for_schemes_without_affine_scheme_open_subscheme(X)
)
I = new{typeof(X), AbsAffineScheme, Ideal, Map}(ID, OO(X), Ipre)
@check begin
# Check that all ideal sheaves are compatible on the overlaps.
# TODO: eventually replace by a check that on every basic
# affine patch, the ideal sheaf can be inferred from what is
# given on one dense open subset.
C = default_covering(X)
for U in basic_patches(default_covering(X))
for V in basic_patches(default_covering(X))
G = C[U, V]
A, B = gluing_domains(G)
for i in 1:number_of_complement_equations(A)
I(A[i]) == ideal(OO(X)(A[i]), I(V, A[i]).(gens(I(V)))) || error("ideals do not coincide on overlap")
end
for i in 1:number_of_complement_equations(B)
I(B[i]) == ideal(OO(X)(B[i]), I(U, B[i]).(gens(I(U)))) || error("ideals do not coincide on overlap")
end
end
end
end
return I
end
end
@attributes mutable struct PrimeIdealSheafFromChart{SpaceType, OpenType, OutputType,
RestrictionType
} <: AbsIdealSheaf{
SpaceType, OpenType,
OutputType, RestrictionType
}
X::AbsCoveredScheme
U::AbsAffineScheme
P::Ideal
F::PreSheafOnScheme
cheap_sub_ideals::WeakKeyIdDict{<:AbsAffineScheme, <:Ideal}
function PrimeIdealSheafFromChart(
X::AbsCoveredScheme,
U::AbsAffineScheme,
P::Ideal
)
@assert base_ring(P) === OO(U)
@assert has_ancestor(x->any(y->y===x, affine_charts(X)), U) "the given affine scheme can not be matched with the affine charts of the covered scheme"
Ipre = PreSheafOnScheme(X,
OpenType=AbsAffineScheme, OutputType=Ideal,
RestrictionType=Map,
is_open_func=_is_open_func_for_schemes_without_affine_scheme_open_subscheme(X)
)
cheap_sub_ideals = WeakKeyIdDict{AbsAffineScheme, Ideal}()
I = new{typeof(X), AbsAffineScheme, Ideal, Map}(X, U, P, Ipre, cheap_sub_ideals)
return I
end
end
@attributes mutable struct SumIdealSheaf{SpaceType, OpenType, OutputType,
RestrictionType
} <: AbsIdealSheaf{
SpaceType, OpenType,
OutputType, RestrictionType
}
summands::Vector{<:AbsIdealSheaf}
underlying_presheaf::AbsPreSheaf
function SumIdealSheaf(
summands::Vector{<:AbsIdealSheaf}
)
@assert !isempty(summands) "list of summands must not be empty"
X = scheme(first(summands))
@assert all(x->scheme(x) === X, summands)
Ipre = PreSheafOnScheme(X,
OpenType=AbsAffineScheme, OutputType=Ideal,
RestrictionType=Map,
is_open_func=_is_open_func_for_schemes_without_affine_scheme_open_subscheme(X)
)
I = new{typeof(X), AbsAffineScheme, Ideal, Map}(summands, Ipre)
return I
end
end
@attributes mutable struct ProductIdealSheaf{SpaceType, OpenType, OutputType,
RestrictionType
} <: AbsIdealSheaf{
SpaceType, OpenType,
OutputType, RestrictionType
}
factors::Vector{<:AbsIdealSheaf}
underlying_presheaf::AbsPreSheaf
function ProductIdealSheaf(
factors::Vector{<:AbsIdealSheaf}
)
@assert !isempty(factors) "list of summands must not be empty"
X = scheme(first(factors))
@assert all(x->scheme(x) === X, factors)
Ipre = PreSheafOnScheme(X,
OpenType=AbsAffineScheme, OutputType=Ideal,
RestrictionType=Map,
is_open_func=_is_open_func_for_schemes_without_affine_scheme_open_subscheme(X)
)
I = new{typeof(X), AbsAffineScheme, Ideal, Map}(factors, Ipre)
return I
end
end
@attributes mutable struct SimplifiedIdealSheaf{SpaceType, OpenType, OutputType,
RestrictionType
} <: AbsIdealSheaf{
SpaceType, OpenType,
OutputType, RestrictionType
}
orig::AbsIdealSheaf
underlying_presheaf::AbsPreSheaf
function SimplifiedIdealSheaf(
orig::AbsIdealSheaf
)
X = scheme(orig)
Ipre = PreSheafOnScheme(X,
OpenType=AbsAffineScheme, OutputType=Ideal,
RestrictionType=Map,
is_open_func=_is_open_func_for_schemes_without_affine_scheme_open_subscheme(X)
)
I = new{typeof(X), AbsAffineScheme, Ideal, Map}(orig, Ipre)
return I
end
end
@attributes mutable struct PullbackIdealSheaf{SpaceType, OpenType, OutputType,
RestrictionType
} <: AbsIdealSheaf{
SpaceType, OpenType,
OutputType, RestrictionType
}
f::AbsCoveredSchemeMorphism
orig::AbsIdealSheaf
Ipre::PreSheafOnScheme
function PullbackIdealSheaf(
f::AbsCoveredSchemeMorphism,
orig::AbsIdealSheaf
)
X = domain(f)
Y = codomain(f)
@assert Y === scheme(orig)
Ipre = PreSheafOnScheme(X,
OpenType=AbsAffineScheme, OutputType=Ideal,
RestrictionType=Map,
is_open_func=_is_open_func_for_schemes_without_affine_scheme_open_subscheme(X)
)
I = new{typeof(X), AbsAffineScheme, Ideal, Map}(f, orig, Ipre)
return I
end
end
@attributes mutable struct RadicalOfIdealSheaf{SpaceType, OpenType, OutputType,
RestrictionType
} <: AbsIdealSheaf{
SpaceType, OpenType,
OutputType, RestrictionType
}
orig::AbsIdealSheaf
Ipre::PreSheafOnScheme
function RadicalOfIdealSheaf(
orig::AbsIdealSheaf
)
X = scheme(orig)
Ipre = PreSheafOnScheme(X,
OpenType=AbsAffineScheme, OutputType=Ideal,
RestrictionType=Map,
is_open_func=_is_open_func_for_schemes_without_affine_scheme_open_subscheme(X)
)
I = new{typeof(X), AbsAffineScheme, Ideal, Map}(orig, Ipre)
set_attribute!(I, :is_radical=>true) # Some methods might be blind to is_radical and only want to check `is_known_to_be_radical` via attributes. Setting this makes sure they get it.
return I
end
end
@attributes mutable struct ToricIdealSheafFromCoxRingIdeal{SpaceType, OpenType, OutputType,
RestrictionType
} <: AbsIdealSheaf{
SpaceType, OpenType,
OutputType, RestrictionType
}
X::NormalToricVariety
I::MPolyIdeal
underlying_presheaf::PreSheafOnScheme
function ToricIdealSheafFromCoxRingIdeal(X::NormalToricVariety, I::MPolyIdeal)
@assert cox_ring(X) === base_ring(I) "incompatible rings"
Ipre = PreSheafOnScheme(X,
OpenType=AbsAffineScheme, OutputType=Ideal,
RestrictionType=Map,
is_open_func=_is_open_func_for_schemes_without_affine_scheme_open_subscheme(X)
)
I = new{typeof(X), AbsAffineScheme, Ideal, Map}(X, I, Ipre)
return I
end
end
########################################################################
# Singular locus ideal sheaf
########################################################################
@attributes mutable struct SingularLocusIdealSheaf{SpaceType, OpenType, OutputType,
RestrictionType
} <: AbsIdealSheaf{
SpaceType, OpenType,
OutputType, RestrictionType
}
focus::AbsIdealSheaf
non_radical_ideals::IdDict{<:AbsAffineScheme, <:Ideal}
underlying_presheaf::AbsPreSheaf
function SingularLocusIdealSheaf(
X::AbsCoveredScheme;
focus::AbsIdealSheaf=zero_ideal_sheaf(X)
)
Ipre = PreSheafOnScheme(X,
OpenType=AbsAffineScheme, OutputType=Ideal,
RestrictionType=Map,
is_open_func=_is_open_func_for_schemes_without_affine_scheme_open_subscheme(X)
)
I = new{typeof(X), AbsAffineScheme, Ideal, Map}(focus, IdDict{AbsAffineScheme, Ideal}(), Ipre)
return I
end
end
underlying_presheaf(I::SingularLocusIdealSheaf) = I.underlying_presheaf
focus(I::SingularLocusIdealSheaf) = I.focus
########################################################################
# Closed embeddings #
########################################################################
@attributes mutable struct CoveredClosedEmbedding{
DomainType<:AbsCoveredScheme,
CodomainType<:AbsCoveredScheme,
BaseMorphismType
} <: AbsCoveredSchemeMorphism{
DomainType,
CodomainType,
BaseMorphismType,
CoveredSchemeMorphism
}
f::CoveredSchemeMorphism
I::AbsIdealSheaf
function CoveredClosedEmbedding(
X::DomainType,
Y::CodomainType,
f::CoveringMorphism{<:Any, <:Any, MorphismType, BaseMorType};
check::Bool=true,
ideal_sheaf::AbsIdealSheaf=IdealSheaf(Y, f, check=check)
) where {
DomainType<:AbsCoveredScheme,
CodomainType<:AbsCoveredScheme,
MorphismType<:ClosedEmbedding,
BaseMorType
}
ff = CoveredSchemeMorphism(X, Y, f; check)
if has_decomposition_info(codomain(f))
for U in patches(domain(f))
floc = f[U]
phi = pullback(floc)
V = codomain(floc)
g = Vector{elem_type(OO(V))}(decomposition_info(codomain(f))[V])
set_decomposition_info!(domain(f), U, Vector{elem_type(OO(U))}(phi.(g)))
end
end
#all(x->(x isa ClosedEmbedding), values(morphisms(f))) || error("the morphisms on affine patches must be `ClosedEmbedding`s")
return new{DomainType, CodomainType, BaseMorType}(ff, ideal_sheaf)
end
end
########################################################################
# PushforwardIdealSheaf #
########################################################################
@attributes mutable struct PushforwardIdealSheaf{SpaceType, OpenType, OutputType,
RestrictionType
} <: AbsIdealSheaf{
SpaceType, OpenType,
OutputType, RestrictionType
}
f::CoveredClosedEmbedding
orig::AbsIdealSheaf
Ipre::PreSheafOnScheme
function PushforwardIdealSheaf(
f::CoveredClosedEmbedding,
orig::AbsIdealSheaf
)
X = domain(f)
Y = codomain(f)
@assert X === scheme(orig)
Ipre = PreSheafOnScheme(Y,
OpenType=AbsAffineScheme, OutputType=Ideal,
RestrictionType=Map,
is_open_func=_is_open_func_for_schemes_without_affine_scheme_open_subscheme(X)
)
I = new{typeof(Y), AbsAffineScheme, Ideal, Map}(f, orig, Ipre)
return I
end
end
########################################################################
# Morphisms from rational functions #
########################################################################
@doc raw"""
MorphismFromRationalFunctions{DomainType<:AbsCoveredScheme, CodomainType<:AbsCoveredScheme}
A lazy type for a dominant morphism ``φ : X → Y`` of `AbsCoveredScheme`s which is given
by a set of rational functions ``a₁,…,aₙ`` in the fraction field of the `base_ring`
of ``𝒪(U)`` for one of the dense open `affine_chart`s ``U`` of ``X``.
The ``aᵢ`` represent the pullbacks of the coordinates (`gens`) of some
`affine_chart` ``V`` of the codomain ``Y`` under this map.
```jldoctest
julia> IP1 = covered_scheme(projective_space(QQ, [:s, :t]))
Scheme
over rational field
with default covering
described by patches
1: affine 1-space
2: affine 1-space
in the coordinate(s)
1: [(t//s)]
2: [(s//t)]
julia> IP2 = projective_space(QQ, [:x, :y, :z]);
julia> S = homogeneous_coordinate_ring(IP2);
julia> x, y, z = gens(S);
julia> IPC, inc_IPC = sub(IP2, ideal(S, [x^2 - y*z]));
julia> C = covered_scheme(IPC);
julia> U = first(affine_charts(IP1))
Spectrum
of multivariate polynomial ring in 1 variable (t//s)
over rational field
julia> V = first(affine_charts(C))
Spectrum
of quotient
of multivariate polynomial ring in 2 variables (y//x), (z//x)
over rational field
by ideal (-(y//x)*(z//x) + 1)
julia> t = first(gens(OO(U)))
(t//s)
julia> Phi = MorphismFromRationalFunctions(IP1, C, U, V, [t//one(t), 1//t]);
julia> realizations = Oscar.realize_on_patch(Phi, U);
julia> realizations[3]
Affine scheme morphism
from [(t//s)] AA^1
to [(x//z), (y//z)] scheme((x//z)^2 - (y//z))
given by the pullback function
(x//z) -> (t//s)
(y//z) -> (t//s)^2
```
"""
@attributes mutable struct MorphismFromRationalFunctions{DomainType<:AbsCoveredScheme,
CodomainType<:AbsCoveredScheme
} <: AbsCoveredSchemeMorphism{DomainType, CodomainType,
MorphismFromRationalFunctions, Nothing}
domain::DomainType
codomain::CodomainType
domain_covering::Covering
codomain_covering::Covering
domain_chart::AbsAffineScheme
codomain_chart::AbsAffineScheme
coord_imgs::Vector{<:FieldElem}
run_internal_checks::Bool
### Various fields for caching
patch_representatives::IdDict{<:AbsAffineScheme, <:Tuple{<:AbsAffineScheme, <:Vector{<:FieldElem}}}
realizations::IdDict{<:AbsAffineScheme, <:Vector{<:AffineSchemeMor}}
realization_previews::IdDict{<:Tuple{<:AbsAffineScheme, <:AbsAffineScheme}, <:Vector{<:FieldElem}}
maximal_extensions::IdDict{<:Tuple{<:AbsAffineScheme, <:AbsAffineScheme}, <:Vector{<:AbsAffineSchemeMor}}
cheap_realizations::IdDict{<:Tuple{<:AbsAffineScheme, <:AbsAffineScheme}, <:AbsAffineSchemeMor}
full_realization::CoveredSchemeMorphism
function MorphismFromRationalFunctions(
X::AbsCoveredScheme, Y::AbsCoveredScheme,
U::AbsAffineScheme, V::AbsAffineScheme,
a::Vector{<:FieldElem};
check::Bool=true,
domain_covering::Covering=default_covering(X),
codomain_covering::Covering=default_covering(Y)
)
@check is_irreducible(X) "domain must be irreducible"
@check is_irreducible(Y) "codomain must be irreducible"
@check dim(Y) <= dim(X) "cannot be dominant"
#_find_chart(U, default_covering(X)) !== nothing || error("patch not found in domain")
#_find_chart(V, default_covering(Y)) !== nothing || error("patch not found in codomain")
any(x->x===U, patches(default_covering(X))) || error("patch not found in domain")
any(x->x===V, patches(default_covering(Y))) || error("patch not found in codomain")
F = parent(first(a))
R = base_ring(F)
all(x->parent(x)===F, a) || error("coordinate images must be elements of the same field")
R === ambient_coordinate_ring(U) || error("images of pullback of the coordinates do not live in the correct ring")
patch_repr = IdDict{AbsAffineScheme, Tuple{AbsAffineScheme, Vector{FieldElem}}}()
patch_repr[U] = (V, a)
realizations = IdDict{AbsAffineScheme, Vector{AffineSchemeMor}}()
realization_previews = IdDict{Tuple{AbsAffineScheme, AbsAffineScheme}, Vector{FieldElem}}()
maximal_extensions = IdDict{Tuple{AbsAffineScheme, AbsAffineScheme}, Vector{AbsAffineSchemeMor}}()
cheap_realizations = IdDict{Tuple{AbsAffineScheme, AbsAffineScheme}, AbsAffineSchemeMor}()
return new{typeof(X), typeof(Y)}(X, Y, domain_covering, codomain_covering,
U, V, a, check, patch_repr, realizations,
realization_previews, maximal_extensions,
cheap_realizations
)
end
end