Skip to content

Commit 44c7b8c

Browse files
authored
Merge pull request #74 from RafaelDavidMohr/rm/dimension
Adds function for dimension computation
2 parents d7f4912 + 5cb9790 commit 44c7b8c

File tree

5 files changed

+62
-1
lines changed

5 files changed

+62
-1
lines changed

src/AlgebraicSolving.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ include("interfaces/nemo.jl")
1212
include("algorithms/groebner-bases.jl")
1313
include("algorithms/normal-forms.jl")
1414
include("algorithms/solvers.jl")
15+
include("algorithms/dimension.jl")
1516
#= siggb =#
1617
include("siggb/siggb.jl")
1718
#= examples =#

src/algorithms/dimension.jl

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
@doc Markdown.doc"""
2+
dimension(I::Ideal{T}) where T <: MPolyRingElem
3+
4+
Compute the Krull dimension of a given polynomial ideal `I`.
5+
6+
**Note**: This requires a Gröbner basis of `I`.
7+
8+
# Examples
9+
```jldoctest
10+
julia> using AlgebraicSolving
11+
12+
julia> R, (x, y, z) = polynomial_ring(QQ, ["x", "y", "z"]);
13+
14+
julia> I = Ideal([x*y,x*z,y*z]);
15+
16+
julia> dimension(I)
17+
1
18+
```
19+
"""
20+
function dimension(I::Ideal{T}) where T <: MPolyRingElem
21+
22+
gb = isempty(values(I.gb)) ? groebner_basis(I) : first(values(I.gb))
23+
R = parent(first(gb))
24+
res = [trues(ngens(R))]
25+
26+
lms = (Nemo.leading_monomial).(gb)
27+
for lm in lms
28+
to_del = Int[]
29+
new_miss = BitVector[]
30+
for (i, mis) in enumerate(res)
31+
nz_exps_inds = findall(e -> !iszero(e),
32+
first(Nemo.exponent_vectors(lm)))
33+
ind_var_inds = findall(mis)
34+
if issubset(nz_exps_inds, ind_var_inds)
35+
for j in nz_exps_inds
36+
new_mis = copy(mis)
37+
new_mis[j] = false
38+
push!(new_miss, new_mis)
39+
end
40+
push!(to_del, i)
41+
end
42+
end
43+
deleteat!(res, to_del)
44+
append!(res, new_miss)
45+
unique!(res)
46+
end
47+
48+
max_length = maximum(mis -> length(findall(mis)), res)
49+
return max_length
50+
end

src/exports.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export polynomial_ring, MPolyRing, GFElem, MPolyRingElem, finite_field, GF, fpMPolyRingElem,
22
characteristic, degree, ZZ, QQ, vars, nvars, ngens, ZZRingElem, QQFieldElem, QQMPolyRingElem,
33
base_ring, coefficient_ring, evaluate, prime_field, sig_groebner_basis, cyclic, leading_coefficient,
4-
FqMPolyRingElem
4+
FqMPolyRingElem, dimension

test/algorithms/dimension.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@testset "dimension" begin
2+
R, (x,y) = polynomial_ring(QQ,["x","y"])
3+
I = Ideal([x^2,x*y])
4+
@test isone(dimension(I))
5+
6+
R, (x,y,z) = polynomial_ring(GF(101),["x","y","z"])
7+
I = Ideal([x+2*y+2*z-1, x^2+2*y^2+2*z^2-x, 2*x*y+2*y*z-y])
8+
@test isone(dimension(I))
9+
end

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ include("interfaces/nemo.jl")
66
include("algorithms/groebner-bases.jl")
77
include("algorithms/normal-forms.jl")
88
include("algorithms/solvers.jl")
9+
include("algorithms/dimension.jl")
910
include("examples/katsura.jl")
1011
end

0 commit comments

Comments
 (0)