Skip to content

Commit aa26ae5

Browse files
committed
feat: doc
1 parent fc53438 commit aa26ae5

File tree

2 files changed

+101
-16
lines changed

2 files changed

+101
-16
lines changed

src/Rings/walk.jl

+89-14
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
using Oscar
22

3-
global infoLevel = 1
3+
global infoLevel = 0
44

55
###############################################################
66
# Implementation of different variants of the Groebner Walk.
77
# The Groebner Walk is proposed by Collart, Kalkbrener & Mall (1997).
88
###############################################################
99
@doc raw"""
1010
groebnerwalk(
11-
I::MPolyIdeal; ordering::MonomialOrdering = default_ordering(base_ring(I)),
12-
startOrder::Symbol = :degrevlex,
13-
targetOrder::Symbol = :lex,
11+
I::MPolyIdeal;
12+
startOrder::MonomialOrdering = default_ordering(base_ring(I)),
13+
targetOrder::Symbol = lex(base_ring(I)),
1414
walktype::Symbol = :standard,
1515
perturbationDegree::Int = 2,
1616
)
@@ -25,7 +25,7 @@ Fractal Walk (:fractalcombined) computes the Walk like it´s presented in Amrhei
2525
Fractal Walk (:fractal) computes the Walk like it´s presented in Amrhein & Gloor (1998). Pertubes only the target vector.
2626
Set infoLevel to trace the walk:
2727
-'infoLevel=0': no detailed printout,
28-
-'infoLevel=1': intermediate weight vectors,
28+
-'infoLevel=1': adds intermediate weight vectors,
2929
-'infoLevel=2': adds information about the Groebner basis.
3030
3131
#Arguments
@@ -40,10 +40,48 @@ Set infoLevel to trace the walk:
4040
- `fractal`: standard-version of the Fractal Walk,
4141
- `fractalcombined`: combined Version of the Fractal Walk. Target monomial order needs to be lex,
4242
- `perturbationDegree::Int=2`: perturbationdegree for the perturbed Walk.
43+
44+
45+
# Examples
46+
47+
```jldoctest
48+
julia> R,(x,y) = polynomial_ring(QQ, ["x","y"], ordering = :degrevlex);
49+
50+
julia> I = ideal([y^4+ x^3-x^2+x,x^4]);
51+
52+
julia> groebnerwalk(I, degrevlex(R), lex(R), :standard)
53+
standard_walk results
54+
Crossed Cones in:
55+
[4, 3]
56+
[4, 1]
57+
[12, 1]
58+
[1, 0]
59+
Cones crossed: 4
60+
Gröbner basis with elements
61+
1 -> y^16
62+
2 -> x + y^12 - y^8 + y^4
63+
with respect to the ordering
64+
matrix_ordering([x, y], [1 0; 0 1])
65+
66+
julia> groebnerwalk(I, degrevlex(R), lex(R), :perturbed, 2)
67+
perturbed_walk results
68+
Crossed Cones in:
69+
[4, 3]
70+
[4, 1]
71+
[5, 1]
72+
[12, 1]
73+
[1, 0]
74+
Cones crossed: 5
75+
Gröbner basis with elements
76+
1 -> y^16
77+
2 -> x + y^12 - y^8 + y^4
78+
with respect to the ordering
79+
matrix_ordering([x, y], [1 0; 0 1])
80+
```
4381
"""
4482
function groebnerwalk(
4583
I::MPolyIdeal, startOrder::MonomialOrdering = default_ordering(base_ring(I)),
46-
targetOrder::MonomialOrdering = :lex,
84+
targetOrder::MonomialOrdering = lex(base_ring(I)),
4785
walktype::Symbol = :standard,
4886
perturbationDegree::Int = 2)
4987
S = canonical_matrix(startOrder)
@@ -74,7 +112,7 @@ Fractal Walk (:fractal) computes the Walk like it´s presented in Amrhein & Gloo
74112
Fractal Walk (:fractalcombined) computes the Walk like it´s presented in Amrhein & Gloor (1998) with multiple extensions. The target monomial order has to be lex. This version uses the Buchberger Algorithm to skip weightvectors with entries bigger than Int32.
75113
Set infoLevel to trace the walk:
76114
-'infoLevel=0': no detailed printout,
77-
-'infoLevel=1': intermediate weight vectors,
115+
-'infoLevel=1': adds intermediate weight vectors,
78116
-'infoLevel=2': adds information about the Groebner basis.
79117
80118
#Arguments
@@ -89,6 +127,43 @@ Set infoLevel to trace the walk:
89127
- `fractal`: standard-version of the Fractal Walk,
90128
- `fractalcombined`: combined version of the Fractal Walk. The target monomial order needs to be lex,
91129
-`p::Int=2`: perturbationdegree for the perturbed Walk.
130+
131+
# Examples
132+
133+
```jldoctest
134+
julia> R,(x,y) = polynomial_ring(QQ, ["x","y"], ordering = :degrevlex);
135+
136+
julia> I = ideal([y^4+ x^3-x^2+x,x^4]);
137+
138+
julia> groebnerwalk(I, [1 1; 0 -1], [1 0; 0 1], :standard)
139+
standard_walk results
140+
Crossed Cones in:
141+
[4, 3]
142+
[4, 1]
143+
[12, 1]
144+
[1, 0]
145+
Cones crossed: 4
146+
Gröbner basis with elements
147+
1 -> y^16
148+
2 -> x + y^12 - y^8 + y^4
149+
with respect to the ordering
150+
matrix_ordering([x, y], [1 0; 0 1])
151+
152+
julia> groebnerwalk(I, [1 1; 0 -1], [1 0; 0 1], :perturbed, 2)
153+
perturbed_walk results
154+
Crossed Cones in:
155+
[4, 3]
156+
[4, 1]
157+
[5, 1]
158+
[12, 1]
159+
[1, 0]
160+
Cones crossed: 5
161+
Gröbner basis with elements
162+
1 -> y^16
163+
2 -> x + y^12 - y^8 + y^4
164+
with respect to the ordering
165+
matrix_ordering([x, y], [1 0; 0 1])
166+
```
92167
"""
93168
function groebnerwalk(
94169
G::Union{Oscar.IdealGens, MPolyIdeal},
@@ -174,18 +249,18 @@ function standard_walk(
174249
tarweight::Vector{Int})
175250
while true
176251
G = standard_step(G, currweight, T)
252+
if currweight == tarweight
253+
return G
254+
else
255+
currweight = next_weight(G, currweight, tarweight)
256+
end
177257
if infoLevel >= 1
258+
raise_step_counter()
178259
println(currweight)
179260
if infoLevel == 2
180261
println(G)
181262
end
182263
end
183-
raise_step_counter()
184-
if currweight == tarweight
185-
return G
186-
else
187-
currweight = next_weight(G, currweight, tarweight)
188-
end
189264
end
190265
end
191266

@@ -227,7 +302,7 @@ function generic_walk(
227302
ordNew = matrix_ordering(base_ring(G), T)
228303
if infoLevel >= 1
229304
println("generic_walk results")
230-
println("Crossed Cones with: ")
305+
println("Facets crossed for: ")
231306
end
232307
while !isempty(v)
233308
G, Lm = generic_step(G, Lm, v, ordNew)

test/Rings/groebner_walk.jl

+12-2
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333

3434
ideals = []
3535
infoLevel = 1
36-
for i 2:nvars(R)-2
36+
for i 2:nvars(R)
3737
push!(ideals, groebnerwalk(id, degrevlex(R), lex(R), :perturbed, i))
3838
end
3939
push!(ideals, groebnerwalk(id, degrevlex(R), lex(R), :standard))
40-
#push!(ideals, groebnerwalk(id, degrevlex(R), lex(R), :tran))
40+
# push!(ideals, groebnerwalk(id, degrevlex(R), lex(R), :tran))
4141

4242
push!(ideals, groebnerwalk(id, degrevlex(R), lex(R), :fractal))
4343
push!(ideals, groebnerwalk(id, degrevlex(R), lex(R), :fractal_start_order))
@@ -53,6 +53,16 @@
5353
)
5454
end
5555

56+
R, (x, y) = polynomial_ring(QQ, ["x", "y"], ordering = :degrevlex)
57+
I = ideal([y^4 + x^3 - x^2 + x, x^4])
58+
id = groebnerwalk(I, degrevlex(R), lex(R), :tran)
59+
60+
s = groebner_basis(I, ordering = lex(R), complete_reduction = true)
61+
@test equalitytest(
62+
Oscar.IdealGens(R, gens(id), lex(R)),
63+
s,
64+
)
65+
5666
@testset "backend-functions for the Groebner Walk" begin
5767

5868
R, (x, y, z) = polynomial_ring(

0 commit comments

Comments
 (0)