Skip to content

Commit 13cc5fd

Browse files
authored
Merge pull request #27 from RafaelDavidMohr/f5
Adds tests for `sig_groebner_basis`
2 parents 5e649f2 + aed7bb9 commit 13cc5fd

File tree

4 files changed

+43
-3
lines changed

4 files changed

+43
-3
lines changed

src/siggb/linear_algebra.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ function echelonize!(matrix::MacaulayMatrix,
100100
if !iszero(arit_ops)
101101
@info "$(arit_ops) submul's"
102102
end
103-
@assert is_triangular(matrix)
104103
end
105104

106105
# subtract mult

src/siggb/siggb.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function sig_groebner_basis(sys::Vector{T}; info_level::Int=0, degbound::Int=0)
6363
Rchar = characteristic(R)
6464

6565
# check if input is ok
66-
if Rchar > 2^31
66+
if Rchar > 2^31 || iszero(Rchar)
6767
error("At the moment we only support finite fields up to prime characteristic < 2^31.")
6868
end
6969
sysl = length(sys)
@@ -242,3 +242,15 @@ function _homogenize(F::Vector{P}) where {P <: MPolyRingElem}
242242
end
243243
return res
244244
end
245+
246+
# test against msolve
247+
function _is_gb(gb::Vector{Tuple{Tuple{Int, P}, P}}) where {P <: MPolyRingElem}
248+
gb_pols = [p[2] for p in gb]
249+
gb_msolve = groebner_basis(Ideal(gb_pols), complete_reduction = true)
250+
251+
lms_gb = (Nemo.leading_monomial).(gb_pols)
252+
lms_msolve = (Nemo.leading_monomial).(gb_msolve)
253+
res1 = all(u -> any(v -> divides(u, v)[1], lms_gb), lms_msolve)
254+
res2 = all(u -> any(v -> divides(u, v)[1], lms_msolve), lms_gb)
255+
return res1 && res2
256+
end

src/siggb/symbolic_pp.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,14 @@ function select_normal!(pairset::Pairset{N},
110110

111111
add_cond = !iszero(reducer_ind)
112112
if add_cond
113-
resize_pivots!(matrix, symbol_ht)
114113
mult = divide(monomial(reducer_sig),
115114
monomial(basis.sigs[reducer_ind]))
116115
lead_idx = write_to_matrix_row!(matrix, basis,
117116
reducer_ind,
118117
symbol_ht, ht, mult,
119118
reducer_sig)
120119
# set pivot
120+
resize_pivots!(matrix, symbol_ht)
121121
matrix.pivots[lead_idx] = matrix.nrows
122122
end
123123
end

test/algorithms/groebner-bases.jl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,32 @@
2626
@test L == H
2727
@test I.gb[2] == H
2828
end
29+
30+
@testset "Algorithms -> Sig Gröbner bases" begin
31+
R, (x,y,z) = polynomial_ring(QQ,["x","y","z"], ordering=:degrevlex)
32+
F = [x^2+1-3, x*y-z, x*z^2-3*y^2]
33+
#= not a finite field =#
34+
@test_throws ErrorException sig_groebner_basis(F)
35+
R, (x,y,z) = polynomial_ring(GF(17),["x","y","z"], ordering=:degrevlex)
36+
F = [x^2+1-3, x*y-z, x*z^2-3*y^2]
37+
#= not homogeneous =#
38+
@test_throws ErrorException sig_groebner_basis(F)
39+
40+
#= GB test 1 =#
41+
Fhom = AlgebraicSolving._homogenize(F)
42+
sgb = sig_groebner_basis(Fhom)
43+
@test AlgebraicSolving._is_gb(sgb)
44+
45+
#= GB test 2 =#
46+
R, (x,y,z,w) = polynomial_ring(GF(65521),["x","y","z","w"], ordering=:degrevlex)
47+
F = cyclic(R).gens
48+
Fhom = AlgebraicSolving._homogenize(F)
49+
sgb = sig_groebner_basis(Fhom)
50+
@test AlgebraicSolving._is_gb(sgb)
51+
52+
#= GB test 3 =#
53+
F = katsura(R).gens
54+
Fhom = AlgebraicSolving._homogenize(F)
55+
sgb = sig_groebner_basis(Fhom)
56+
@test AlgebraicSolving._is_gb(sgb)
57+
end

0 commit comments

Comments
 (0)