Skip to content

Fix bug probabilistic linear algebra with a linear form#287

Open
jerebertho wants to merge 10 commits intoalgebraic-solving:masterfrom
jerebertho:fix_bug_linform
Open

Fix bug probabilistic linear algebra with a linear form#287
jerebertho wants to merge 10 commits intoalgebraic-solving:masterfrom
jerebertho:fix_bug_linform

Conversation

@jerebertho
Copy link
Contributor

@jerebertho jerebertho commented Mar 9, 2026

This PR fixes issue #284.

When a linear form is introduced, and thus the ideal is known to be 0-dimensional, probabilistic linear algebra may lead to a faulty Gröbner basis computation as it spans a positive-dimensional ideal. In this case, the computation is now restarted.

Taking the example of issue #284, verbose mode now indicates as follows

Adding a linear form with an extra variable (lowest w.r.t. monomial order)
[coefficients of linear form are k^1 for k looping over variable index 1...n]

--------------- INPUT DATA ---------------
#variables                       9
#equations                      10
#invalid equations               0
field characteristic             0
homogeneous input?               0
signature-based computation      0
monomial order                 DRL
basis hash table resetting     OFF
linear algebra option           44
initial hash table size     131072 (2^17)
max pair selection             ALL
reduce gb                        1
#threads                         1
info level                       2
generate pbm files               0
------------------------------------------
Initial prime is 1191100583

Legend for f4 information
--------------------------------------------------------
deg       current degree of pairs selected in this round
sel       number of pairs selected in this round
pairs     total number of pairs in pair list
mat       matrix dimensions (# rows x # columns)
density   density of the matrix
new data  # new elements for basis in this round
          # zero reductions during linear algebra
time(rd)  time of the current f4 round in seconds given
          for real and cpu time
--------------------------------------------------------

deg     sel   pairs        mat          density            new data         time(rd) in sec (real|cpu)
------------------------------------------------------------------------------------------------------
  1       5       9       6 x 9          35.19%        5 new       0 zero         0.00 | 0.00         
  2       4       4      19 x 21         12.78%        2 new       2 zero         0.00 | 0.00         
  3       1       1       4 x 9          44.44%        1 new       0 zero         0.00 | 0.00         
  3       1       1       7 x 12         38.10%        0 new       1 zero         0.00 | 0.00         
------------------------------------------------------------------------------------------------------
reduce final basis        9 x 14         27.78%        9 new       0 zero         0.00 | 0.00         
------------------------------------------------------------------------------------------------------

---------------- TIMINGS ----------------
overall(elapsed)        0.00 sec
overall(cpu)            0.00 sec
select                  0.00 sec   4.2%
symbolic prep.          0.00 sec   1.9%
update                  0.00 sec  58.7%
convert                 0.00 sec   6.1%
linear algebra          0.00 sec   3.0%
reduce gb               0.00 sec   0.0%
-----------------------------------------

---------- COMPUTATIONAL DATA -----------
size of basis                     9
#terms in basis                  28
#pairs reduced                   11
#GM criterion                   142
#redundant elements               9
#rows reduced                    31
#zero reductions                  3
max. matrix data                 19 x 21 (12.782%)
max. symbolic hash table size  2^11
max. basis hash table size     2^16
-----------------------------------------


---------------- TIMINGS ----------------
rational param(elapsed)         0.00 sec
rational param(cpu)             0.00 sec
-----------------------------------------

The Groebner basis is not 0-dimensional
Restarting with the same linear form

--------------- INPUT DATA ---------------
#variables                       9
#equations                      10
#invalid equations               0
field characteristic             0
homogeneous input?               0
signature-based computation      0
monomial order                 DRL
basis hash table resetting     OFF
linear algebra option           44
initial hash table size     131072 (2^17)
max pair selection             ALL
reduce gb                        1
#threads                         1
info level                       2
generate pbm files               0
------------------------------------------
Initial prime is 1285201079

Legend for f4 information
--------------------------------------------------------
deg       current degree of pairs selected in this round
sel       number of pairs selected in this round
pairs     total number of pairs in pair list
mat       matrix dimensions (# rows x # columns)
density   density of the matrix
new data  # new elements for basis in this round
          # zero reductions during linear algebra
time(rd)  time of the current f4 round in seconds given
          for real and cpu time
--------------------------------------------------------

deg     sel   pairs        mat          density            new data         time(rd) in sec (real|cpu)
------------------------------------------------------------------------------------------------------
  1       5       9       6 x 9          35.19%        5 new       0 zero         0.00 | 0.00         
  2       4       4      19 x 21         12.78%        3 new       1 zero         0.00 | 0.00         
  3       3       3       9 x 12         33.33%        3 new       0 zero         0.00 | 0.00         
  2       3       6       9 x 9          39.51%        1 new       2 zero         0.00 | 0.00         
  3       4       4      15 x 13         26.15%        0 new       4 zero         0.00 | 0.00         
------------------------------------------------------------------------------------------------------
reduce final basis       10 x 12         28.33%       10 new       0 zero         0.00 | 0.00         
------------------------------------------------------------------------------------------------------

---------------- TIMINGS ----------------
overall(elapsed)        0.00 sec
overall(cpu)            0.00 sec
select                  0.00 sec   5.6%
symbolic prep.          0.00 sec   2.4%
update                  0.00 sec  50.6%
convert                 0.00 sec   8.4%
linear algebra          0.00 sec   4.4%
reduce gb               0.00 sec   0.0%
-----------------------------------------

---------- COMPUTATIONAL DATA -----------
size of basis                    10
#terms in basis                  28
#pairs reduced                   19
#GM criterion                   212
#redundant elements              12
#rows reduced                    48
#zero reductions                  7
max. matrix data                 19 x 21 (12.782%)
max. symbolic hash table size  2^11
max. basis hash table size     2^16
-----------------------------------------

The unexpected behavior is printed and the computation restarted.

As a side note, in some instances, including this example, two runs of FGLM were needed to ensure the correctness of the parametrizations. This second run had completely wrong timings so that verbose mode is now disabled during this run.

@jerebertho jerebertho marked this pull request as ready for review March 9, 2026 23:09
@jerebertho jerebertho changed the title Fix bug linform Fix bug probabilistic linear algebra with a linear form Mar 10, 2026
@jerebertho
Copy link
Contributor Author

Small rebase
The PR also now handles the fact that the faulty Gröbner basis may span a 0-dimensional ideal of wrong degree. The message about this has been changed to

Wrong dimension or degree
Restarting with the same linear form

@jerebertho
Copy link
Contributor Author

After discussing with @vneiger, we concluded that this last commit could yield an infinite loop: assume that the first F4 run is faulty and yields a Gröbner basis spanning a 0-dimension ideal of degree D', distinct from the correct degree D. All the successive runs outputting a Gb of degree D will be seen as wrong and thus this creates a (potential) infinite loop.

However, since the algorithm only deals with polynomials in the ideal, D' > D so I will provide a new commit that takes this information into account to avoid the potential inifinite loop.

@jerebertho
Copy link
Contributor Author

This new commit should fix the new issue of #66.
Verbose mode indicates this now

---------- COMPUTATIONAL DATA -----------
degree of ideal                  70
#dense rows                      14
#normal forms                     0
total density                    20.0%
density of the free part         20.0%
deg. elim. pol.                  69
deg. sqfr. elim. pol.            69
-----------------------------------------


---------------- TIMINGS ----------------
overall(elapsed)        0.00 sec
overall(cpu)            0.00 sec
-----------------------------------------

---------- COMPUTATIONAL DATA -----------
degree of ideal                  70
#dense rows                      14
#normal forms                     0
total density                    20.0%
density of the free part         20.0%
deg. elim. pol.                  70
deg. sqfr. elim. pol.            70
-----------------------------------------


---------------- TIMINGS ----------------
rational param(elapsed)         0.00 sec
rational param(cpu)             0.00 sec
-----------------------------------------
[0, [65521, 
6, 
70, 
['x1', 'x2', 'x3', 'x4', 'x5', 'A'],
[1,2,3,4,5,1],
[1,
[[70,
[29283, 0, 0, 0, 0, 0, 0, 0, 0, 0, 56156, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49834, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55317, 0, 0, 0, 0, 0, 0, 0, 0, 0, 35312, 0, 0, 0, 0, 0, 0, 0, 0, 0, 54706, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51142, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]],
[0,
[1]],
[
[[66,
[0, 28714, 0, 0, 0, 0, 55665, 0, 0, 0, 0, 58261, 0, 0, 0, 0, 8202, 0, 0, 0, 0, 27827, 0, 0, 0, 0, 19529, 0, 0, 0, 0, 19553, 0, 0, 0, 0, 64648, 0, 0, 0, 0, 25504, 0, 0, 0, 0, 17534, 0, 0, 0, 0, 9427, 0, 0, 0, 0, 57135, 0, 0, 0, 0, 26938, 0, 0, 0, 0, 59017]]],
[[66,
[0, 40853, 0, 0, 0, 0, 24738, 0, 0, 0, 0, 14520, 0, 0, 0, 0, 64311, 0, 0, 0, 0, 9867, 0, 0, 0, 0, 64466, 0, 0, 0, 0, 26415, 0, 0, 0, 0, 16657, 0, 0, 0, 0, 14513, 0, 0, 0, 0, 51619, 0, 0, 0, 0, 46667, 0, 0, 0, 0, 60717, 0, 0, 0, 0, 11645, 0, 0, 0, 0, 20457]]],
[[66,
[0, 0, 0, 0, 0, 0, 35757, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51537, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28573, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33953, 0, 0, 0, 0, 0, 0, 0, 0, 0, 58257, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26380, 0, 0, 0, 0, 0, 0, 0, 0, 0, 37615]]],
[[66,
[0, 24668, 0, 0, 0, 0, 24738, 0, 0, 0, 0, 51001, 0, 0, 0, 0, 64311, 0, 0, 0, 0, 55654, 0, 0, 0, 0, 64466, 0, 0, 0, 0, 39106, 0, 0, 0, 0, 16657, 0, 0, 0, 0, 51008, 0, 0, 0, 0, 51619, 0, 0, 0, 0, 18854, 0, 0, 0, 0, 60717, 0, 0, 0, 0, 53876, 0, 0, 0, 0, 20457]]],
[[66,
[0, 36807, 0, 0, 0, 0, 55665, 0, 0, 0, 0, 7260, 0, 0, 0, 0, 8202, 0, 0, 0, 0, 37694, 0, 0, 0, 0, 19529, 0, 0, 0, 0, 45968, 0, 0, 0, 0, 64648, 0, 0, 0, 0, 40017, 0, 0, 0, 0, 17534, 0, 0, 0, 0, 56094, 0, 0, 0, 0, 57135, 0, 0, 0, 0, 38583, 0, 0, 0, 0, 59017]]]
]]]]]:

The second run of FGLM now finds an elimination polynomial of degree 70, which means the ideal is in shape position. No random linear form is introduced and the output is the expect one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant