Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hilbert series integration #2698

Merged
merged 81 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
16ee3a8
Preliminary tests for unified hilbert_series
JohnAAbbott Aug 7, 2023
a961ce5
Include tests.
HechtiDerLachs Aug 7, 2023
3bb7d08
Hooked in Abbott code
JohnAAbbott Aug 7, 2023
6f2fadd
Merge branch 'Hilbert_series_integration' of github.com:JohnAAbbott/O…
JohnAAbbott Aug 7, 2023
0735b9d
Extract my implementation of hilbert series into a separate file.
HechtiDerLachs Aug 7, 2023
67dee24
Add some comments.
HechtiDerLachs Aug 7, 2023
346255d
Merge branch 'Hilbert_series_integration' of github.com:JohnAAbbott/O…
HechtiDerLachs Aug 7, 2023
dc227fc
New scope for verbosity in hilbert series numerator code
JohnAAbbott Aug 7, 2023
8fdacae
Extensive cleaning; working towards OSCAR coding stds
JohnAAbbott Aug 7, 2023
b190fe8
Fixed minor typos
JohnAAbbott Aug 7, 2023
dd5fb6a
Minor modification in method selection and cwlean up of docstrings.
HechtiDerLachs Aug 7, 2023
9cc8462
Return the denominator for the hilbert series in factorized form.
HechtiDerLachs Aug 7, 2023
73f0d19
Adjust tests.
HechtiDerLachs Aug 7, 2023
33ec78f
Merge branch 'Hilbert_series_integration' of github.com:JohnAAbbott/O…
HechtiDerLachs Aug 7, 2023
f54e2ef
Renaming (to OSCAR conventions); syntactic cleaning
JohnAAbbott Aug 8, 2023
c3aa506
Fixed bug in ideal(0) short-cut
JohnAAbbott Aug 8, 2023
fad4434
First implementation of hilbert series numerator for modules; more cl…
JohnAAbbott Aug 8, 2023
62d034a
Fixed small typo
JohnAAbbott Aug 9, 2023
7893ac1
First step towards unifying hilbert_series interface
JohnAAbbott Aug 9, 2023
88b389b
Corrected doc; renamed local var
JohnAAbbott Aug 9, 2023
96ca8f6
Added kwarg parent; corrected indentation
JohnAAbbott Aug 9, 2023
25f2205
Get rid of restrictive types.
HechtiDerLachs Aug 9, 2023
536903e
Clean up the multi_hilbert_series.
HechtiDerLachs Aug 9, 2023
2964068
Update tests.
HechtiDerLachs Aug 9, 2023
08f6e91
Merge branch 'Hilbert_series_integration' of github.com:JohnAAbbott/O…
HechtiDerLachs Aug 9, 2023
fb8903d
Clean up the original hilbert_series.
HechtiDerLachs Aug 9, 2023
f1cb501
Add some cleanup.
HechtiDerLachs Aug 9, 2023
0588ca5
Update tests.
HechtiDerLachs Aug 9, 2023
375c09c
Added test_throws
JohnAAbbott Aug 9, 2023
d45ac8b
Handle R^0 correctly; new UI to allow freemodule as arg
JohnAAbbott Aug 9, 2023
92dd69c
Now allow R/ideal() as input; partial prototype for denom
JohnAAbbott Aug 9, 2023
fda8825
Commented out short-cut for ideal(0) because it got denom wrong
JohnAAbbott Aug 9, 2023
3714388
Merge branch 'oscar-system:master' into Hilbert_series_integration
JohnAAbbott Aug 9, 2023
a6a3e0c
Renamed HSNum_fudge to HSNum_abbott
JohnAAbbott Aug 10, 2023
3f0576f
First phase of refactoring
JohnAAbbott Aug 10, 2023
72289f2
Main fn is now called hilbert_series; cannot handle non ZZ^m grading
JohnAAbbott Aug 10, 2023
56c32cb
Tidying & renaming; internal fns now require HSRing arg
JohnAAbbott Aug 10, 2023
327ae9c
Scattered tidying inside multi_hilbert_series
JohnAAbbott Aug 10, 2023
d56a2fe
hilbert_series: Now has kwargs backend & parent; not yet working for …
JohnAAbbott Aug 10, 2023
446face
Better comment
JohnAAbbott Aug 10, 2023
59e718a
Improved example in doc; removed cruft
JohnAAbbott Aug 10, 2023
db05ab2
Merge branch 'oscar-system:master' into Hilbert_series_integration
JohnAAbbott Aug 10, 2023
13ec90e
Removed cruft
JohnAAbbott Aug 10, 2023
2d08095
Removed cruft
JohnAAbbott Aug 10, 2023
ff019d2
Fixed rank 0 case; added comments
JohnAAbbott Aug 10, 2023
11fa50b
Disabled MPolyBuildCtx in HS_denominator: gives error for univariate …
JohnAAbbott Aug 11, 2023
84b6194
Merge branch 'oscar-system:master' into Hilbert_series_integration
JohnAAbbott Aug 11, 2023
0ecea3a
Syntactic cleaning
JohnAAbbott Aug 11, 2023
d5cce04
Improved comment
JohnAAbbott Aug 11, 2023
17a640e
Added new test hilbert.jl
JohnAAbbott Aug 11, 2023
aa69d1c
Now have hilbert_series and multi_hilbert_series (for modules)
JohnAAbbott Aug 11, 2023
34c1266
Merge branch 'Hilbert_series_integration' of github.com:JohnAAbbott/O…
JohnAAbbott Aug 11, 2023
b9e7e03
Changed fn prototype for graded_map (line 575): AbstractFreeModElem i…
JohnAAbbott Aug 11, 2023
fa8dc41
Corrected doc string; added new doc string
JohnAAbbott Aug 11, 2023
6ce8b6f
Merge branch 'oscar-system:master' into Hilbert_series_integration
JohnAAbbott Aug 11, 2023
41472e1
Corrected doctest
JohnAAbbott Aug 11, 2023
25e42d9
New tests (for hilbert_series)
JohnAAbbott Aug 11, 2023
a7ccd49
Merge branch 'oscar-system:master' into Hilbert_series_integration
JohnAAbbott Aug 11, 2023
490e4cc
Use univariate laurent polynomials as default in the module case.
HechtiDerLachs Aug 11, 2023
7ec551d
Fix doctests.
HechtiDerLachs Aug 11, 2023
a148caf
Fix doctests once more.
HechtiDerLachs Aug 11, 2023
61b0ace
Merge branch 'master' into Hilbert_series_integration
HechtiDerLachs Aug 11, 2023
9ec9662
Merge branch 'oscar-system:master' into Hilbert_series_integration
JohnAAbbott Aug 14, 2023
fa091da
Merge branch 'oscar-system:master' into Hilbert_series_integration
JohnAAbbott Aug 15, 2023
1e4ebcf
Corrected typo in comment; removed cruft
JohnAAbbott Aug 15, 2023
15ac9ff
Added new fn HSNum_check_weights to check for possible infinite Hilbe…
JohnAAbbott Aug 15, 2023
9c406d1
Renamed & corrected _hilbert_series_check_weights
JohnAAbbott Aug 15, 2023
3a6721f
Inserted missing kwarg in recursive call; added comment
JohnAAbbott Aug 15, 2023
5bd3993
Added 2 tests to check for error-case detection
JohnAAbbott Aug 15, 2023
3bc4cfd
Merge branch 'oscar-system:master' into Hilbert_series_integration
JohnAAbbott Aug 16, 2023
256cd05
Merge branch 'oscar-system:master' into Hilbert_series_integration
JohnAAbbott Aug 17, 2023
124cdf2
Merge branch 'oscar-system:master' into Hilbert_series_integration
JohnAAbbott Aug 17, 2023
383f668
Added comment (_hilbert_series_check_weights is obsol)
JohnAAbbott Aug 18, 2023
eecf605
Corrected weights for HS & free res test
JohnAAbbott Aug 18, 2023
85dc15e
Improved handling in try..catch block
JohnAAbbott Aug 18, 2023
b626740
Check in catch block improved (taken from is_positively_graded)
JohnAAbbott Aug 18, 2023
d54bc70
Merge branch 'oscar-system:master' into Hilbert_series_integration
JohnAAbbott Aug 18, 2023
1dfd778
Replace HSNum...check_weights by earlier calls to is_positively_graded.
HechtiDerLachs Aug 23, 2023
da6c742
Fix call to is_positive_grading_matrix.
HechtiDerLachs Aug 23, 2023
9ed1761
Fix tests.
HechtiDerLachs Aug 23, 2023
6e6259c
Update src/Rings/mpoly-affine-algebras.jl
wdecker Aug 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions src/Modules/hilbert.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function HSNum_module(SubM::SubquoModule{T}, HSRing::Ring, backend::Symbol=:Abbo
return multi_hilbert_series(quo(P,ideal(P,[1]))[1]; parent=HSRing, backend=backend)[1][1]
end
GensLM = gens(LM);
L = [[] for _ in 1:r]; # L[k] will be list of monomial gens for k-th cooord
L = [[] for _ in 1:r]; # L[k] will be list of monomial gens for k-th coord
# Nested loop below extracts the coordinate monomial ideals -- is there a better way?
for g in GensLM
SR = coordinates(ambient_representative(g)); # should have length = 1
Expand All @@ -37,19 +37,12 @@ function HSNum_module(SubM::SubquoModule{T}, HSRing::Ring, backend::Symbol=:Abbo
@vprintln :hilbert 1 "HSNum_module: shifts are $(shifts)";
shift_expv = [gen_repr(d) for d in shifts];
@vprintln :hilbert 1 "HSNum_module: shift_expv are $(shift_expv)";
### HSeriesRing = parent(HSeriesList[1]);
### @vprintln :hilbert 1 "HSNum_module: HSeriesRing = $(HSeriesRing)";
t = gens(HSRing);
ScaleFactor = [_power_product(t,e) for e in shift_expv];
result = sum([ScaleFactor[k]*HSeriesList[k] for k in 1:r]);
return result;
end

# No longer needed
# function HSNum_module(F::FreeMod{T}; parent::Union{Nothing,Ring} = nothing) where T <: MPolyRingElem
# # ASSUME F is graded free module
# return HSNum_module(sub(F,gens(F))[1]; parent=parent)
# end

@doc raw"""
multi_hilbert_series(M::SubquoModule; parent::Union{Nothing,Ring} = nothing)
Expand Down Expand Up @@ -93,6 +86,7 @@ julia> den
function multi_hilbert_series(SubM::SubquoModule{T}; parent::Union{Nothing, Ring} = nothing, backend::Symbol = :Abbott) where T <: MPolyRingElem
R = base_ring(SubM)
@req coefficient_ring(R) isa AbstractAlgebra.Field "The coefficient ring must be a field"
@req is_positively_graded(R) "ring must be positively graded"

# Wrap the case where G is abstractly isomorphic to ℤᵐ, but not realized as a
# free Abelian group.
Expand Down Expand Up @@ -126,6 +120,7 @@ function multi_hilbert_series(SubM::SubquoModule{T}; parent::Union{Nothing, Ring
end

function multi_hilbert_series(F::FreeMod{T}; parent::Union{Nothing,Ring} = nothing, backend::Symbol = :Abbott) where T <: MPolyRingElem
@req is_positively_graded(base_ring(F)) "ring must be positively graded"
return multi_hilbert_series(sub(F,gens(F))[1]; parent=parent, backend=backend)
end

Expand Down
23 changes: 23 additions & 0 deletions src/Rings/hilbert.jl
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,29 @@ function separate_simple_pps(gens::Vector{PP})
end


# !!!OBSOLESCENT!!! 2023-08-17 this fn will no be needed after Wolfram's PR is merged
# Returns nothing; throws if ker(W) contains a non-zero vector >= 0
#function _hilbert_series_check_weights(W::Vector{Vector{Int}})
# # assumes W is rectangular (and at least 1x1)
# # Transpose while converting:
# ncols = length(W);
# nrows = length(W[1]);
# A = zero_matrix(FlintZZ, nrows,ncols);
# for i in 1:nrows for j in 1:ncols A[i,j] = W[j][i]; end; end;
# b = zero_matrix(FlintZZ, nrows,1);
# try
# solve_non_negative(A, b); # any non-zero soln gives rise to infinitely many, which triggers an exception
# catch e
# if !(e isa ArgumentError && e.msg == "Polyhedron not bounded")
# rethrow(e)
# end
# # solve_non_negative must have thrown because there is a non-zero soln
# error("given weights permit infinite dimensional homogeneous spaces")
# end
# return nothing # otherwise it returns the result of solve_non_negative (Doh!!)
#end


# Check args: either throws or returns nothing.
function HSNum_check_args(gens::Vector{PP}, W::Vector{Vector{Int}})
if isempty(W)
Expand Down
4 changes: 3 additions & 1 deletion src/Rings/mpoly-affine-algebras.jl
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ function multi_hilbert_series(
R = base_ring(A)
I = modulus(A)
@req coefficient_ring(R) isa AbstractAlgebra.Field "The coefficient ring must be a field"
@req is_positively_graded(A) "the ring must be positively graded"

# Wrap the case where G is abstractly isomorphic to ℤᵐ, but not realized as a
# free Abelian group.
Expand All @@ -561,7 +562,7 @@ function multi_hilbert_series(
map_into_S = hom(R, S, gens(S))
J = map_into_S(I)
AA, _ = quo(S, J)
(numer, denom), _ = multi_hilbert_series(AA; algorithm, parent)
(numer, denom), _ = multi_hilbert_series(AA; algorithm, backend, parent)
return (numer, denom), (H, iso)
end

Expand Down Expand Up @@ -735,6 +736,7 @@ G
```
"""
function multi_hilbert_series_reduced(A::MPolyQuoRing; algorithm::Symbol=:BayerStillmanA)
@req is_positively_graded(A) "ring must be positively graded"
(p, q), (H, iso) = multi_hilbert_series(A, algorithm=algorithm)
f = p//evaluate(q)
p = numerator(f)
Expand Down
2 changes: 1 addition & 1 deletion src/Rings/mpoly-graded.jl
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ false
is_free(G) || return false
if ngens(G) == rank(G)
W = vcat([x.coeff for x = R.d])
if is_positive_grading_matrix(W)
if is_positive_grading_matrix(transpose(W))
return true
end
end
Expand Down
4 changes: 2 additions & 2 deletions test/Modules/hilbert.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
@testset "Hilbert series and free resolution" begin
R, _ = polynomial_ring(QQ, ["x", "y", "z"]);
Z = abelian_group(0);
Rg, (x, y, z) = grade(R, [3*Z[1],Z[1],-Z[1]]);
Rg, (x, y, z) = grade(R, [3*Z[1],Z[1],Z[1]]);
F = graded_free_module(Rg, 1);
A = Rg[x; y];
B = Rg[x^2+y^6; y^7; z^4];
M = SubquoModule(F, A, B);
fr = free_resolution(M)

# There is no length(fr), so instead we do the following
# 2023-08-18 There is no length(fr), so instead we do the following
indexes = range(fr.C);
fr_len = first(indexes)

Expand Down
8 changes: 8 additions & 0 deletions test/Rings/hilbert.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,11 @@ end
@test numer1 == evaluate(numer2, T)
@test numer3 == evaluate(numer2, first(gens(parent(numer3))))
end

@testset "Hilbert series part 3" begin
R, (x, y) = graded_polynomial_ring(QQ, ["x", "y"], [1, -1]);
I = ideal(R, [x]);
RmodI, _ = quo(R, I);
@test_throws ArgumentError hilbert_series(RmodI); # weights must be non-neg
@test_throws ArgumentError multi_hilbert_series(RmodI); # possible infinite dimension
end
Loading