Skip to content

Commit

Permalink
ToricVarieties bugfix: is_effective(ToricDivisor)
Browse files Browse the repository at this point in the history
It checks if a divisor is lin. equivalent to an effective divisor.
But it should check if the divisor is effective.
  • Loading branch information
HereAround committed Feb 8, 2023
1 parent 6607511 commit 9bbc6ab
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 9 deletions.
4 changes: 4 additions & 0 deletions docs/src/ToricVarieties/ToricDivisorClasses.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ Equality of toric divisor classes can be tested via `==`.

To check if a toric divisor class is trivial, one can invoke `is_trivial`.

```@docs
is_effective(tdc::ToricDivisorClass)
```


## Attributes

Expand Down
1 change: 1 addition & 0 deletions docs/src/ToricVarieties/ToricDivisors.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ is_ample(td::ToricDivisor)
is_basepoint_free(td::ToricDivisor)
is_cartier(td::ToricDivisor)
is_effective(td::ToricDivisor)
is_linearly_equivalent_to_effective_toric_divisor(td::ToricDivisor)
is_integral(td::ToricDivisor)
is_nef(td::ToricDivisor)
is_prime(td::ToricDivisor)
Expand Down
28 changes: 28 additions & 0 deletions src/ToricVarieties/ToricDivisorClasses/properties.jl
Original file line number Diff line number Diff line change
@@ -1,2 +1,30 @@
@attr Bool is_trivial(tdc::ToricDivisorClass) = iszero(divisor_class(tdc))
export is_trivial


@doc Markdown.doc"""
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)
A normal, non-affine, smooth, projective, gorenstein, fano, 2-dimensional toric variety without torusfactor
julia> tdc = ToricDivisorClass(P2, [1])
A divisor class on a normal toric variety
julia> is_effective(tdc)
true
julia> tdc2 = ToricDivisorClass(P2, [-1])
A divisor class on a normal toric variety
julia> is_effective(tdc2)
false
```
"""
@attr Bool is_effective(tdc::ToricDivisorClass) = is_effective(toric_divisor(tdc))
export is_effective
43 changes: 37 additions & 6 deletions src/ToricVarieties/ToricDivisors/properties.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,55 @@ export is_basepoint_free
@doc Markdown.doc"""
is_effective(td::ToricDivisor)
Determine whether the toric divisor `td` is effective.
Determine whether the toric divisor `td` is effective,
i.e. if all of its coefficients are non-negative.
# Examples
```jldoctest
julia> F4 = hirzebruch_surface(4)
A normal, non-affine, smooth, projective, gorenstein, non-fano, 2-dimensional toric variety without torusfactor
julia> P2 = projective_space(NormalToricVariety,2)
A normal, non-affine, smooth, projective, gorenstein, fano, 2-dimensional toric variety without torusfactor
julia> td = ToricDivisor(F4, [1,0,0,0])
A torus-invariant, prime divisor on a normal toric variety
julia> td = ToricDivisor(P2, [1,-1,0])
A torus-invariant, non-prime divisor on a normal toric variety
julia> is_effective(td)
false
julia> td2 = ToricDivisor(P2, [1,2,3])
A torus-invariant, non-prime divisor on a normal toric variety
julia> is_effective(td2)
true
```
"""
@attr Bool is_effective(td::ToricDivisor) = pm_tdivisor(td).EFFECTIVE
@attr Bool is_effective(td::ToricDivisor) = all(c -> (c >= 0), coefficients(td))
export is_effective


@doc Markdown.doc"""
is_linearly_equivalent_to_effective_toric_divisor(td::ToricDivisor)
Determine whether the toric divisor `td` is linearly equivalent to an effective toric divisor.
# Examples
```jldoctest
julia> P2 = projective_space(NormalToricVariety,2)
A normal, non-affine, smooth, projective, gorenstein, fano, 2-dimensional toric variety without torusfactor
julia> td = ToricDivisor(P2, [1,-1,0])
A torus-invariant, non-prime divisor on a normal toric variety
julia> is_effective(td)
false
julia> is_linearly_equivalent_to_effective_toric_divisor(td)
true
```
"""
@attr Bool is_linearly_equivalent_to_effective_toric_divisor(td::ToricDivisor) = pm_tdivisor(td).EFFECTIVE
export is_linearly_equivalent_to_effective_toric_divisor


@doc Markdown.doc"""
is_integral(td::ToricDivisor)
Expand Down
9 changes: 7 additions & 2 deletions test/ToricVarieties/divisor_classes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,24 @@

F5 = NormalToricVariety([[1, 0], [0, 1], [-1, 5], [0, -1]], [[1, 2], [2, 3], [3, 4], [4, 1]])
dP3 = NormalToricVariety([[1, 0], [1, 1], [0, 1], [-1, 0], [-1, -1], [0, -1]], [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]])
P2 = projective_space(NormalToricVariety,2)
DC = ToricDivisorClass(F5, [fmpz(0), fmpz(0)])
DC2 = ToricDivisorClass(F5, [1, 2])
DC3 = ToricDivisorClass(dP3, [4, 3, 2, 1])
DC4 = canonical_divisor_class(dP3)
DC5 = anticanonical_divisor_class(dP3)
DC6 = trivial_divisor_class(dP3)

DC7 = ToricDivisorClass(P2, [1])
DC8 = ToricDivisorClass(P2, [-1])

@testset "Basic properties" begin
@test is_trivial(toric_divisor(DC2)) == false
@test rank(parent(divisor_class(DC2))) == 2
@test dim(toric_variety(DC2)) == 2
@test is_effective(DC7) == true
@test is_effective(DC8) == false
end

@testset "Arithmetic" begin
@test is_trivial(fmpz(2)*DC+DC2) == false
@test is_trivial(2*DC-DC2) == false
Expand Down
11 changes: 10 additions & 1 deletion test/ToricVarieties/divisors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@

F5 = NormalToricVariety([[1, 0], [0, 1], [-1, 5], [0, -1]], [[1, 2], [2, 3], [3, 4], [4, 1]])
dP3 = NormalToricVariety([[1, 0], [1, 1], [0, 1], [-1, 0], [-1, -1], [0, -1]], [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]])
P2 = projective_space(NormalToricVariety,2)
D=ToricDivisor(F5, [0, 0, 0, 0])
D2 = DivisorOfCharacter(F5, [1, 2])
D3 = ToricDivisor(dP3, [1, 0, 0, 0, 0, 0])
D4 = canonical_divisor(dP3)
D5 = anticanonical_divisor(dP3)
D6 = trivial_divisor(dP3)

D7 = ToricDivisor(P2, [1,1,0])
D8 = ToricDivisor(P2, [1,-1,0])
D9 = ToricDivisor(P2, [0,-1,0])

@testset "Should fail" begin
@test_throws ArgumentError ToricDivisor(F5, [0, 0, 0])
@test_throws ArgumentError D+D3
Expand Down Expand Up @@ -43,6 +47,11 @@
@test is_prime(D2) == false
@test coefficients(D2) == [1, 2, 9, -2]
@test is_prime(D3) == true
@test is_effective(D7) == true
@test is_effective(D8) == false
@test is_linearly_equivalent_to_effective_toric_divisor(D7) == true
@test is_linearly_equivalent_to_effective_toric_divisor(D8) == true
@test is_linearly_equivalent_to_effective_toric_divisor(D9) == false
end

@testset "Arithmetic" begin
Expand Down

0 comments on commit 9bbc6ab

Please sign in to comment.