-
Notifications
You must be signed in to change notification settings - Fork 112
/
Constructors.jl
140 lines (119 loc) · 4.18 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
################################################################################
# Lower case constructors
################################################################################
projective_scheme(S::MPolyDecRing) = ProjectiveScheme(S)
proj(S::MPolyDecRing) = ProjectiveScheme(S)
projective_scheme(Q::MPolyQuoRing{<:MPolyDecRingElem}) = ProjectiveScheme(Q)
proj(Q::MPolyQuoRing{<:MPolyDecRingElem}) = ProjectiveScheme(Q)
proj(S::MPolyDecRing, I::MPolyIdeal{T}) where {T<:MPolyDecRingElem} = ProjectiveScheme(S, I)
projective_scheme(S::MPolyDecRing, I::MPolyIdeal{T}) where {T<:MPolyDecRingElem} = ProjectiveScheme(S, I)
proj(I::MPolyIdeal{<:MPolyDecRingElem}) = ProjectiveScheme(base_ring(I), I)
projective_scheme(I::MPolyIdeal{<:MPolyDecRingElem}) = ProjectiveScheme(base_ring(I), I)
################################################################################
# Subschemes
################################################################################
function subscheme(P::AbsProjectiveScheme, f::RingElem)
S = homogeneous_coordinate_ring(P)
parent(f) === S || return subscheme(P, S(f))
Q, _ = quo(S, ideal(S, [f]))
result = proj(Q)
if isdefined(P, :Y)
set_base_scheme!(result, base_scheme(P))
end
set_attribute!(result, :ambient_space, ambient_space(P))
return result
end
function subscheme(
P::AbsProjectiveScheme,
f::Vector{T}
) where {T<:RingElem}
length(f) == 0 && return P #TODO: Replace P by an honest copy!
S = homogeneous_coordinate_ring(P)
for i in 1:length(f)
parent(f[i]) === S || return subscheme(P, S.(f))
end
Q, _ = quo(S, ideal(S, f))
result = proj(Q)
if isdefined(P, :Y)
set_base_scheme!(result, base_scheme(P))
end
set_attribute!(result, :ambient_space, ambient_space(P))
return result
end
function subscheme(P::AbsProjectiveScheme,
I::Ideal{T}
) where {T<:RingElem}
S = homogeneous_coordinate_ring(P)
base_ring(I) === S || error("ideal does not belong to the correct ring")
Q, _ = quo(S, I)
result = proj(Q)
if isdefined(P, :Y)
set_base_scheme!(result, base_scheme(P))
end
set_attribute!(result, :ambient_space, ambient_space(P))
return result
end
################################################################################
# Projective space
################################################################################
@doc raw"""
projective_space(A::Ring, var_symb::Vector{VarName})
Create the (relative) projective space `Proj(A[x₀,…,xₙ])` over `A`
where `x₀,…,xₙ` is a list of variable names.
# Examples
```jldoctest
julia> projective_space(QQ, [:x, :PPP, :?])
Projective space of dimension 2
over rational field
with homogeneous coordinates [x, PPP, ?]
julia> homogeneous_coordinate_ring(ans)
Multivariate polynomial ring in 3 variables over QQ graded by
x -> [1]
PPP -> [1]
? -> [1]
```
"""
function projective_space(A::Ring, var_symb::Vector{<:VarName})
n = length(var_symb)
S, _ = graded_polynomial_ring(A, Symbol.(var_symb))
return proj(S)
end
@doc raw"""
projective_space(A::Ring, r::Int; var_name::VarName=:s)
Create the (relative) projective space `Proj(A[s₀,…,sᵣ])` over `A`
where `s` is a string for the variable names.
"""
function projective_space(A::Ring, r::Int; var_name::VarName=:s)
S, _ = graded_polynomial_ring(A, [Symbol(var_name, i) for i in 0:r])
return proj(S)
end
function projective_space(
W::Union{<:AffineSchemeOpenSubscheme, <:AbsAffineScheme},
r::Int;
var_name::VarName=:s
)
P = projective_space(OO(W), r, var_name=var_name)
set_base_scheme!(P, W)
return P
end
function projective_space(
W::Union{<:AffineSchemeOpenSubscheme, <:AbsAffineScheme},
var_names::Vector{<:VarName}
)
P = projective_space(OO(W), var_names)
set_base_scheme!(P, W)
return P
end
################################################################################
# reduced scheme
################################################################################
function reduced_scheme(X::AbsProjectiveScheme)
I = defining_ideal(X)
Irad = radical(I)
Xred = subscheme(ambient_space(X), Irad)
set_attribute!(Xred, :is_reduced=>true)
return Xred
end
function reduced_scheme(X::AbsProjectiveScheme{S,T}) where {S, T<:MPolyDecRing}
return X
end