From 098e3733eee52b05ed0b5a77c67f5197ce4067cb Mon Sep 17 00:00:00 2001 From: Rafael Mohr Date: Tue, 3 Sep 2024 17:10:56 +0200 Subject: [PATCH 1/6] add dummy function --- src/AlgebraicSolving.jl | 1 + src/algorithms/other-algorithms.jl | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 src/algorithms/other-algorithms.jl diff --git a/src/AlgebraicSolving.jl b/src/AlgebraicSolving.jl index 8c65390..8bbf1d9 100644 --- a/src/AlgebraicSolving.jl +++ b/src/AlgebraicSolving.jl @@ -12,6 +12,7 @@ include("interfaces/nemo.jl") include("algorithms/groebner-bases.jl") include("algorithms/normal-forms.jl") include("algorithms/solvers.jl") +include("algorithms/other-algorithms.jl") #= siggb =# include("siggb/siggb.jl") #= examples =# diff --git a/src/algorithms/other-algorithms.jl b/src/algorithms/other-algorithms.jl new file mode 100644 index 0000000..801879d --- /dev/null +++ b/src/algorithms/other-algorithms.jl @@ -0,0 +1,3 @@ +function dimension(I::Ideal{T}) where T <: MPolyRingElem + +end From 72e78a121e39a04fb23fb6436c2392fda2e7f35d Mon Sep 17 00:00:00 2001 From: Rafael Mohr Date: Tue, 3 Sep 2024 17:19:58 +0200 Subject: [PATCH 2/6] adds function for dim computation --- src/algorithms/other-algorithms.jl | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/algorithms/other-algorithms.jl b/src/algorithms/other-algorithms.jl index 801879d..edd906c 100644 --- a/src/algorithms/other-algorithms.jl +++ b/src/algorithms/other-algorithms.jl @@ -1,3 +1,31 @@ function dimension(I::Ideal{T}) where T <: MPolyRingElem + gb = isempty(values(I.gb)) ? groebner_basis(I) : first(values(I.gb)) + R = parent(first(gb)) + res = [trues(ngens(R))] + + lms = (Nemo.leading_monomial).(gb) + for lm in lms + to_del = Int[] + new_miss = BitVector[] + for (i, mis) in enumerate(res) + nz_exps_inds = findall(e -> !iszero(e), + first(Nemo.exponent_vectors(lm))) + ind_var_inds = findall(mis) + if issubset(nz_exps_inds, ind_var_inds) + for j in nz_exps_inds + new_mis = copy(mis) + new_mis[j] = false + push!(new_miss, new_mis) + end + push!(to_del, i) + end + end + deleteat!(res, to_del) + append!(res, new_miss) + unique!(res) + end + + max_length = maximum(mis -> length(findall(mis)), res) + return max_length end From f862ce3ca488645672b8a66852afe08b17112f32 Mon Sep 17 00:00:00 2001 From: Rafael Mohr Date: Tue, 3 Sep 2024 17:28:51 +0200 Subject: [PATCH 3/6] adds docu and export --- src/algorithms/other-algorithms.jl | 19 +++++++++++++++++++ src/exports.jl | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/algorithms/other-algorithms.jl b/src/algorithms/other-algorithms.jl index edd906c..5164a89 100644 --- a/src/algorithms/other-algorithms.jl +++ b/src/algorithms/other-algorithms.jl @@ -1,3 +1,22 @@ +@doc Markdown.doc""" + dimension(I::Ideal{T}) where T <: MPolyRingElem + +Compute the Krull dimension of a given polynomial ideal `I`. + +**Note**: This requires a Gröbner basis of `I`. + +# Examples +```jldoctest +julia> using AlgebraicSolving + +julia> R, (x, y, z) = polynomial_ring(QQ, ["x", "y", "z"]); + +julia> I = Ideal([x*y,x*z,y*z]); + +julia> dimension(I) +1 +``` +""" function dimension(I::Ideal{T}) where T <: MPolyRingElem gb = isempty(values(I.gb)) ? groebner_basis(I) : first(values(I.gb)) diff --git a/src/exports.jl b/src/exports.jl index af80d89..e93b3a3 100644 --- a/src/exports.jl +++ b/src/exports.jl @@ -1,4 +1,4 @@ export polynomial_ring, MPolyRing, GFElem, MPolyRingElem, finite_field, GF, fpMPolyRingElem, characteristic, degree, ZZ, QQ, vars, nvars, ngens, ZZRingElem, QQFieldElem, QQMPolyRingElem, base_ring, coefficient_ring, evaluate, prime_field, sig_groebner_basis, cyclic, leading_coefficient, - FqMPolyRingElem + FqMPolyRingElem, dimension From 0d820a6e25249d9b0d54e6fb9c7ad253eac62d68 Mon Sep 17 00:00:00 2001 From: Rafael Mohr Date: Tue, 3 Sep 2024 17:32:02 +0200 Subject: [PATCH 4/6] adds tests --- test/algorithms/other-algorithms.jl | 9 +++++++++ test/runtests.jl | 1 + 2 files changed, 10 insertions(+) create mode 100644 test/algorithms/other-algorithms.jl diff --git a/test/algorithms/other-algorithms.jl b/test/algorithms/other-algorithms.jl new file mode 100644 index 0000000..d8cab64 --- /dev/null +++ b/test/algorithms/other-algorithms.jl @@ -0,0 +1,9 @@ +@testset "dimension" begin + R, (x,y) = polynomial_ring(QQ,["x","y"]) + I = Ideal([x^2,x*y]) + @test isone(dimension(I)) + + R, (x,y,z) = polynomial_ring(GF(101),["x","y","z"]) + I = Ideal([x+2*y+2*z-1, x^2+2*y^2+2*z^2-x, 2*x*y+2*y*z-y]) + @test iszero(dimension(I)) +end diff --git a/test/runtests.jl b/test/runtests.jl index 11a1d92..d7c5f44 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -6,5 +6,6 @@ include("interfaces/nemo.jl") include("algorithms/groebner-bases.jl") include("algorithms/normal-forms.jl") include("algorithms/solvers.jl") +include("algorithms/other-algorithms.jl") include("examples/katsura.jl") end From 5b2b73d78e1286ddf938168face9212f72849ec5 Mon Sep 17 00:00:00 2001 From: Rafael Mohr Date: Tue, 3 Sep 2024 17:47:16 +0200 Subject: [PATCH 5/6] fix tests --- test/algorithms/other-algorithms.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/algorithms/other-algorithms.jl b/test/algorithms/other-algorithms.jl index d8cab64..265d576 100644 --- a/test/algorithms/other-algorithms.jl +++ b/test/algorithms/other-algorithms.jl @@ -5,5 +5,5 @@ R, (x,y,z) = polynomial_ring(GF(101),["x","y","z"]) I = Ideal([x+2*y+2*z-1, x^2+2*y^2+2*z^2-x, 2*x*y+2*y*z-y]) - @test iszero(dimension(I)) + @test isone(dimension(I)) end From 5cb97908527b1d2b05a1073c070592b4e5b6a0de Mon Sep 17 00:00:00 2001 From: Rafael Mohr Date: Tue, 24 Sep 2024 10:29:59 +0200 Subject: [PATCH 6/6] rename files --- src/AlgebraicSolving.jl | 2 +- src/algorithms/{other-algorithms.jl => dimension.jl} | 0 test/algorithms/{other-algorithms.jl => dimension.jl} | 0 test/runtests.jl | 2 +- 4 files changed, 2 insertions(+), 2 deletions(-) rename src/algorithms/{other-algorithms.jl => dimension.jl} (100%) rename test/algorithms/{other-algorithms.jl => dimension.jl} (100%) diff --git a/src/AlgebraicSolving.jl b/src/AlgebraicSolving.jl index 8bbf1d9..67728dc 100644 --- a/src/AlgebraicSolving.jl +++ b/src/AlgebraicSolving.jl @@ -12,7 +12,7 @@ include("interfaces/nemo.jl") include("algorithms/groebner-bases.jl") include("algorithms/normal-forms.jl") include("algorithms/solvers.jl") -include("algorithms/other-algorithms.jl") +include("algorithms/dimension.jl") #= siggb =# include("siggb/siggb.jl") #= examples =# diff --git a/src/algorithms/other-algorithms.jl b/src/algorithms/dimension.jl similarity index 100% rename from src/algorithms/other-algorithms.jl rename to src/algorithms/dimension.jl diff --git a/test/algorithms/other-algorithms.jl b/test/algorithms/dimension.jl similarity index 100% rename from test/algorithms/other-algorithms.jl rename to test/algorithms/dimension.jl diff --git a/test/runtests.jl b/test/runtests.jl index d7c5f44..184f88f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -6,6 +6,6 @@ include("interfaces/nemo.jl") include("algorithms/groebner-bases.jl") include("algorithms/normal-forms.jl") include("algorithms/solvers.jl") -include("algorithms/other-algorithms.jl") +include("algorithms/dimension.jl") include("examples/katsura.jl") end