diff --git a/docs/make.jl b/docs/make.jl index 36de936..04fc94f 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -29,7 +29,7 @@ makedocs(; "UniversalBundles" => "api/universal_bundles.md", "Cohomology" => "api/cohomology.md", "Projections" => "api/projections.md", - "Hodge & Hochschild" => "api/hodge.md", + "Hodge, Betti & Hochschild" => "api/hodge.md", "ZeroLoci" => "api/zero_loci.md", "Koszul Algebra" => "api/koszul.md", "Constructions" => "api/constructions.md", diff --git a/docs/src/api/hodge.md b/docs/src/api/hodge.md index f5ab58d..e800a1e 100644 --- a/docs/src/api/hodge.md +++ b/docs/src/api/hodge.md @@ -1,6 +1,6 @@ -# Hodge & Hochschild +# Hodge, Betti & Hochschild -Hodge numbers, twisted Hodge numbers, and Hochschild cohomology. +Hodge numbers, Betti numbers, twisted Hodge numbers, and Hochschild cohomology. See the [mathematical background](../math.md#Hochschild-cohomology-of-zero-loci) for a detailed description of the algorithm, including why both twisted Hodge matrices ``M_1`` and ``M_2`` @@ -29,6 +29,14 @@ twisted_hodge_numbers print_hodge_diamond ``` +## Betti numbers + +[`betti_numbers`](@ref) returns a zero-based vector of all Betti numbers, +with `b[k]` equal to ``b_k(X)`` for `k` in `0:2*dimension(X)`. +For a partial flag variety, odd entries vanish. +For a smooth zero locus, the entries are sums of Hodge numbers with fixed total degree; +any unresolved parameters are retained as [`AffineExpr`](@ref)s. + ## Hochschild cohomology The Hochschild–Kostant–Rosenberg decomposition gives diff --git a/docs/src/conventions.md b/docs/src/conventions.md index 3008a75..44d91ec 100644 --- a/docs/src/conventions.md +++ b/docs/src/conventions.md @@ -75,8 +75,8 @@ Cohomological indices start at zero: 3. The Hochschild [`PolyvectorParallelogram`](@ref) is **0-indexed**: `P[p, q]` is ``\mathrm{h}^q(X, \bigwedge\nolimits^p \mathrm{T}_X)`` and `P[n]` is ``\dim \mathrm{HH}^n``. -4. [`betti_numbers`](@ref) returns a **zero-based** vector containing only even degrees. - For `b = betti_numbers(X)`, `b[p]` is ``b_{2p}(X)``, with indices `0:dimension(X)`. +4. [`betti_numbers`](@ref) returns a **zero-based** vector containing all cohomological degrees. + For `b = betti_numbers(X)`, `b[k]` is ``b_k(X)``, with indices `0:2*dimension(X)`. For example: diff --git a/examples/FanoFourfolds.jl b/examples/FanoFourfolds.jl index 31de123..0f05570 100644 --- a/examples/FanoFourfolds.jl +++ b/examples/FanoFourfolds.jl @@ -37,6 +37,7 @@ const BATCH_SIZE = parse( @everywhere begin using PartialFlagVarieties + using OffsetArrays: OffsetMatrix using JSON const WORKER_GC_EVERY = parse(Int, get(ENV, "FANO4_WORKER_GC_EVERY", "16")) @@ -236,26 +237,21 @@ const BATCH_SIZE = parse( Fills by Serre duality h^{p,q} = h^{d-p,d-q} for d=4. """ function parse_reference_hodge(hodge_data::Vector) - H = Matrix{AffineExpr}(undef, 5, 5) - for i in eachindex(H) - H[i] = AffineExpr(0) - end - known = falses(5, 5) + H = OffsetMatrix(fill(AffineExpr(0), 5, 5), 0:4, 0:4) + known = OffsetMatrix(falses(5, 5), 0:4, 0:4) for (q, row) in enumerate(hodge_data) for (p, val) in enumerate(row) - H[p, q] = parse_hodge_value(val) - known[p, q] = true + H[p - 1, q - 1] = parse_hodge_value(val) + known[p - 1, q - 1] = true end end # Fill by Serre duality: h^{p,q} = h^{d-p,d-q} for p in 0:4, q in 0:4 - pi, qi = p + 1, q + 1 - sp, sq = 4 - p + 1, 4 - q + 1 - if !known[pi, qi] && sp >= 1 && sq >= 1 && known[sp, sq] - H[pi, qi] = H[sp, sq] - known[pi, qi] = true + if !known[p, q] && known[4 - p, 4 - q] + H[p, q] = H[4 - p, 4 - q] + known[p, q] = true end end @@ -309,7 +305,7 @@ const BATCH_SIZE = parse( Returns `(matches, mapping)`. """ function find_variable_mapping( - computed::Matrix{AffineExpr}, reference::Matrix{AffineExpr} + computed::AbstractMatrix{AffineExpr}, reference::AbstractMatrix{AffineExpr} ) c_var_set = Set{Int}() r_var_set = Set{Int}() @@ -390,15 +386,7 @@ const BATCH_SIZE = parse( function ambient_hodge_numbers(X) d = dimension(X) d == 4 || error("ambient dimension $d != 4") - betti = betti_numbers(X) - H = Matrix{AffineExpr}(undef, 5, 5) - for i in eachindex(H) - H[i] = AffineExpr(0) - end - for p in 0:4 - H[p + 1, p + 1] = AffineExpr(betti[p]) - end - H + AffineExpr.(hodge_numbers(X)) end # ============================================================================= @@ -452,8 +440,7 @@ const BATCH_SIZE = parse( Z = zero_locus(E) t_hodge = time_ns() - # The reference data uses ordinary one-based matrices. - H = parent(hodge_numbers_symbolic(Z)) + H = hodge_numbers_symbolic(Z) hodge_elapsed = (time_ns() - t_hodge) / 1e9 polyvector = maybe_compute_polyvector(Z) @@ -492,13 +479,13 @@ end # @everywhere # Pretty-print helpers # ============================================================================= -function format_hodge_matrix(H::Matrix{AffineExpr}) +function format_hodge_matrix(H::AbstractMatrix{AffineExpr}) d = size(H, 1) - 1 lines = String[] for q in 0:d entries = String[] for p in 0:d - push!(entries, sprint(show, H[p + 1, q + 1])) + push!(entries, sprint(show, H[p, q])) end push!(lines, join(entries, " ")) end diff --git a/src/Constructions.jl b/src/Constructions.jl index 2636406..8d334f1 100644 --- a/src/Constructions.jl +++ b/src/Constructions.jl @@ -76,11 +76,15 @@ julia> dimension(V) 4 julia> betti_numbers(V) -5-element OffsetArray(::Vector{BigInt}, 0:4) with eltype BigInt with indices 0:4: +9-element OffsetArray(::Vector{BigInt}, 0:8) with eltype BigInt with indices 0:8: 1 + 0 1 + 0 1 + 0 1 + 0 1 ``` """ @@ -252,11 +256,15 @@ julia> dimension(V) 4 julia> betti_numbers(V) -5-element OffsetArray(::Vector{BigInt}, 0:4) with eltype BigInt with indices 0:4: +9-element OffsetArray(::Vector{BigInt}, 0:8) with eltype BigInt with indices 0:8: 1 + 0 1 + 0 2 + 0 1 + 0 1 ``` """ diff --git a/src/Hodge.jl b/src/Hodge.jl index d118fa6..8a8be34 100644 --- a/src/Hodge.jl +++ b/src/Hodge.jl @@ -59,12 +59,11 @@ function hodge_numbers(X::PartialFlagVariety) betti = betti_numbers(X) # For G/P: h^{p,q} = δ_{p,q} * b_{2p} - # betti_numbers returns only even Betti numbers: betti[p] = b_{2p} - H = zeros(BigInt, d + 1, d + 1) - for p in 0:min(d, length(betti) - 1) - H[p + 1, p + 1] = betti[p] + H = OffsetMatrix(zeros(BigInt, d + 1, d + 1), 0:d, 0:d) + for p in 0:d + H[p, p] = betti[2 * p] end - OffsetArray(H, -1, -1) + H end # ═══════════════════════════════════════════════════════════════════════════════ @@ -123,7 +122,7 @@ function twisted_hodge_numbers(X::PartialFlagVariety, L::CompletelyReducibleBund rank(L) == 1 || throw(ArgumentError("the twist must be a line bundle")) d = dimension(X) H = _filtered_hodge_matrix(d, p -> tensor_product(_filtered_cotangent_power(X, p), L)) - OffsetArray(_collapse_determined(H), -1, -1) + OffsetMatrix(_collapse_determined(H), -1, -1) end function twisted_hodge_numbers(X::PartialFlagVariety, j::Integer) @@ -401,7 +400,7 @@ function hodge_numbers(Z::ZeroLocus) if n_factors(Z) >= 2 diamonds = map(hodge_numbers, factors(Z)) all(diamond -> all(is_determined, diamond), diamonds) && - return OffsetArray(_kunneth_bigraded(parent.(diamonds)), -1, -1) + return OffsetMatrix(_kunneth_bigraded(parent.(diamonds)), -1, -1) end d = dimension(Z) @@ -425,7 +424,7 @@ function hodge_numbers(Z::ZeroLocus) # to the zero diamond explicitly (matching hochschild_cohomology, which already # returns the zero parallelogram for an empty zero locus). if is_determined(M[1, 1]) && M[1, 1].constant == 0 - return OffsetArray(fill(AffineExpr(0), d + 1, d + 1), -1, -1) + return OffsetMatrix(fill(AffineExpr(0), d + 1, d + 1), -1, -1) end # The Lefschetz hyperplane theorem can pin down entries the long exact @@ -439,7 +438,37 @@ function hodge_numbers(Z::ZeroLocus) M[p + 1, q + 1] = M[d - p + 1, d - q + 1] end - OffsetArray(_renumber_variables!(M), -1, -1) + OffsetMatrix(_renumber_variables!(M), -1, -1) +end + +""" + betti_numbers(Z::ZeroLocus) -> OffsetVector{AffineExpr} + +Return the Betti numbers ``b_k(Z) = \\dim \\mathrm{H}^k(Z, \\mathbb{Q})`` +in all degrees, indexed by `0:2*dimension(Z)`. + +Sum the entries of [`hodge_numbers`](@ref) with total degree ``k``: +``b_k(Z) = \\sum_{p+q=k} \\mathrm{h}^{p,q}(Z)``. +Entries are [`AffineExpr`](@ref)s, retaining any unresolved parameters. +As for Hodge numbers, this assumes a smooth zero locus of a regular section. + +# Examples +```jldoctest +julia> using PartialFlagVarieties + +julia> Z = zero_locus(line_bundle(projective_space(4), 3)); + +julia> b = betti_numbers(Z); + +julia> b[3] +10 +``` +""" +function betti_numbers(Z::ZeroLocus) + H = hodge_numbers(Z) + d = dimension(Z) + b = [sum(H[p, k - p] for p in max(0, k - d):min(d, k)) for k in 0:(2 * d)] + OffsetVector(b, -1) end """ @@ -963,7 +992,7 @@ function twisted_hodge_numbers( Z::ZeroLocus, L::CompletelyReducibleBundle ) M = _twisted_hodge_symbolic(Z, L, Ref(0)) - OffsetArray(_renumber_variables!(M), -1, -1) + OffsetMatrix(_renumber_variables!(M), -1, -1) end """ diff --git a/src/PartialFlagVarieties.jl b/src/PartialFlagVarieties.jl index 72d9221..716631e 100644 --- a/src/PartialFlagVarieties.jl +++ b/src/PartialFlagVarieties.jl @@ -17,7 +17,7 @@ module PartialFlagVarieties using Semisimple using LRUCache -using OffsetArrays: OffsetArray +using OffsetArrays: OffsetMatrix, OffsetVector using Preferences using PrettyTables using StaticArrays @@ -173,6 +173,7 @@ end Z = zero_locus(L) euler_characteristic(Z) hodge_numbers(Z) + betti_numbers(Z) end end diff --git a/src/PartialFlagVariety.jl b/src/PartialFlagVariety.jl index 543e8ab..a5201b4 100644 --- a/src/PartialFlagVariety.jl +++ b/src/PartialFlagVariety.jl @@ -242,15 +242,15 @@ end """ betti_numbers(X::PartialFlagVariety) -> OffsetVector{BigInt} -Return the Betti numbers of `X` in even degrees, i.e. -``[b_0, b_2, b_4, \\ldots, b_{2d}]``. +Return the Betti numbers ``b_k(X) = \\dim \\mathrm{H}^k(X, \\mathbb{Q})`` +in all degrees, indexed by `0:2*dimension(X)`. -Since ``\\mathrm{G}/\\mathrm{P}`` has no odd cohomology this completely describes ``\\mathrm{H}^\\bullet(X, \\mathbb{Z})``. -Computed from the ratio of the Poincaré polynomials of the Weyl groups -``\\mathrm{W}_{\\mathrm{G}}`` and ``\\mathrm{W}_{\\mathrm{L}}``. +The odd entries vanish for a partial flag variety. +The even entries are computed from the ratio of the Poincaré polynomials +of the Weyl groups ``\\mathrm{W}_{\\mathrm{G}}`` and ``\\mathrm{W}_{\\mathrm{L}}``. -The indices run from `0` to `dimension(X)`: the entry `b[p]` is ``b_{2p}``. -Use `parent(b)` to access the underlying one-based vector. +For `b = betti_numbers(X)`, `b[k]` is ``b_k(X)``. +Use `parent(b)` to access the underlying ordinary one-based vector. """ function betti_numbers(X::PartialFlagVariety) degs_G = collect(degrees_fundamental_invariants(dynkin_type(X))) @@ -262,7 +262,10 @@ function betti_numbers(X::PartialFlagVariety) num = foldl((p, d) -> _poly_mul(p, ones(BigInt, d)), degs_G; init=BigInt[1]) den = foldl((p, d) -> _poly_mul(p, ones(BigInt, d)), degs_L; init=BigInt[1]) - OffsetArray(_poly_div(num, den), -1) + even = _poly_div(num, den) + b = zeros(BigInt, 2 * length(even) - 1) + b[1:2:end] = even + OffsetVector(b, -1) end function _poly_mul(a, b) diff --git a/test/runtests.jl b/test/runtests.jl index 04bf989..738f47d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -276,24 +276,23 @@ mdt(::Type{DT}, marked) where {DT<:DynkinType} = MarkedDynkinType(DT, marked) # ═══════════════════════════════════════════════════════════════════════════ @testset "Betti numbers" begin - # ℙⁿ: all Betti numbers = 1 - @test parent(betti_numbers(projective_space(2))) == [1, 1, 1] - @test parent(betti_numbers(projective_space(4))) == [1, 1, 1, 1, 1] + # ℙⁿ has one class in each even degree. + @test parent(betti_numbers(projective_space(2))) == [1, 0, 1, 0, 1] + @test parent(betti_numbers(projective_space(4))) == [1, 0, 1, 0, 1, 0, 1, 0, 1] b = betti_numbers(Gr(2, 4)) - @test axes(b) == (0:4,) + @test axes(b) == (0:8,) @test b[0] == 1 - @test b[1] == 1 - @test b[2] == 2 - @test b[4] == 1 + @test b[1] == 0 + @test b[2] == 1 + @test b[4] == 2 + @test b[8] == 1 @test_throws BoundsError b[-1] - @test_throws BoundsError b[5] + @test_throws BoundsError b[9] - # Gr(2,4): Betti = 1, 1, 2, 1, 1 - @test parent(betti_numbers(Gr(2, 4))) == [1, 1, 2, 1, 1] + @test parent(betti_numbers(Gr(2, 4))) == [1, 0, 1, 0, 2, 0, 1, 0, 1] - # Gr(2,5): Betti = 1, 1, 2, 2, 2, 1, 1 - @test parent(betti_numbers(Gr(2, 5))) == [1, 1, 2, 2, 2, 1, 1] + @test parent(betti_numbers(Gr(2, 5))) == [1, 0, 1, 0, 2, 0, 2, 0, 2, 0, 1, 0, 1] # Sum of Betti = χ @test sum(betti_numbers(cayley_plane())) == 27 @@ -979,7 +978,7 @@ mdt(::Type{DT}, marked) where {DT<:DynkinType} = MarkedDynkinType(DT, marked) @testset "Projective space" begin V = projective_space(4) @test dimension(V) == 4 - @test parent(betti_numbers(V)) == [1, 1, 1, 1, 1] + @test parent(betti_numbers(V)) == [1, 0, 1, 0, 1, 0, 1, 0, 1] end @testset "Flag varieties" begin @@ -2537,6 +2536,45 @@ mdt(::Type{DT}, marked) where {DT<:DynkinType} = MarkedDynkinType(DT, marked) @test H_tw[0] == AffineExpr(1) end + @testset "ZeroLocus: Betti numbers" begin + for (n, degree, expected) in ( + (2, 3, [1, 2, 1]), + (3, 4, [1, 0, 22, 0, 1]), + (4, 3, [1, 0, 1, 10, 1, 0, 1]), + (4, 5, [1, 0, 1, 204, 1, 0, 1]), + (5, 3, [1, 0, 1, 0, 23, 0, 1, 0, 1]), + ) + Z = zero_locus(line_bundle(projective_space(n), degree)) + b = betti_numbers(Z) + @test axes(b) == (0:(2 * dimension(Z)),) + @test eltype(b) == AffineExpr + @test all(is_determined, b) + @test parent(b) == expected + @test sum((-1)^k * b[k] for k in axes(b, 1)) == euler_characteristic(Z) + end + + points = zero_locus(line_bundle(projective_space(1), 2)) + b = betti_numbers(points) + @test axes(b) == (0:0,) + @test b[0] == 2 + @test_throws BoundsError b[1] + + W = zero_locus(line_bundle(projective_space(4), 3)) + P1 = zero_locus(zero_bundle(projective_space(1))) + @test parent(betti_numbers(product(W, P1))) == [1, 0, 2, 10, 2, 10, 2, 0, 1] + + G = Gr(2, 6) + Z = zero_locus(symmetric_power(dual(universal_subbundle(G)), 3)) + b = betti_numbers(Z) + @test !is_determined(b[3]) + @test b[0] == b[8] == 1 + @test sum((-1)^k * b[k] for k in axes(b, 1)) == 324 + + G = product(projective_space(1), projective_space(5)) + Z = zero_locus(2 * line_bundle(G, [1, 0])) + @test all(is_zero_expr, betti_numbers(Z)) + end + @testset "ZeroLocus: Hodge numbers (CY3)" begin # Quintic CY3: h^{1,1}=1, h^{2,1}=101 X = projective_space(4) @@ -3331,7 +3369,7 @@ mdt(::Type{DT}, marked) where {DT<:DynkinType} = MarkedDynkinType(DT, marked) H = cohomology(exterior_power(Omega, p)) for q in 0:dimension(X) if is_determined(H[q]) - @test H[q] == (p == q ? betti[p] : 0) + @test H[q] == (p == q ? betti[2 * p] : 0) end end end @@ -3720,7 +3758,7 @@ mdt(::Type{DT}, marked) where {DT<:DynkinType} = MarkedDynkinType(DT, marked) h = hodge_numbers(zero_locus(line_bundle(X, 1))) for p in 0:6, q in 0:6 p + q < 6 || continue - @test h[p, q] == (p == q ? betti[p] : 0) + @test h[p, q] == (p == q ? betti[2 * p] : 0) end @test h[3, 3] == 4