-
Notifications
You must be signed in to change notification settings - Fork 113
/
properties.jl
38 lines (30 loc) · 1.21 KB
/
properties.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
@attr Bool is_trivial(tdc::ToricDivisorClass) = iszero(divisor_class(tdc))
@doc raw"""
is_effective(tdc::ToricDivisorClass)
Determines whether the toric divisor class `tdc` is effective, that is if a toric divisor
in this divisor class is linearly equivalent to an effective toric divisor.
# Examples
```jldoctest
julia> P2 = projective_space(NormalToricVariety,2)
Normal toric variety
julia> tdc = toric_divisor_class(P2, [1])
Divisor class on a normal toric variety
julia> is_effective(tdc)
true
julia> tdc2 = toric_divisor_class(P2, [-1])
Divisor class on a normal toric variety
julia> is_effective(tdc2)
false
```
"""
@attr Bool function is_effective(tdc::ToricDivisorClass)
amb = toric_variety(tdc)
pi = matrix(map_from_torusinvariant_weil_divisor_group_to_class_group(amb))
coeffs = coefficients(toric_divisor(tdc))
P = polyhedron((-identity_matrix(QQ, nrows(pi)), zeros(QQ, nrows(pi))), (transpose(pi), transpose(pi)*coeffs))
# If the polyhedron is empty, there cannot be a effective representative.
is_feasible(P) || return false
# We check whether there is an integral point using a MILP
milp = mixed_integer_linear_program(P, ones(QQFieldElem, nrows(pi)))
return !isnothing(optimal_solution(milp))
end