sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.44k stars 481 forks source link

Polybori doctest failure #37732

Closed mantepse closed 7 months ago

mantepse commented 7 months ago

Steps To Reproduce

This test failure is reproducible:

sage -t --random-seed=53322096094394940204738795464999058924 src/sage/rings/polynomial/pbori/pbori.pyx
**********************************************************************
File "src/sage/rings/polynomial/pbori/pbori.pyx", line 7644, in sage.rings.polynomial.pbori.pbori.gauss_on_polys
Failed example:
    E == A.echelon_form()
Expected:
    True
Got:
    False

Expected Behavior

Test should pass

Actual Behavior

Test fails

Additional Information

No response

Environment

- **OS**: Ubuntu 22.04
- **Sage Version**: 10.4.beta1

Checklist

S17A05 commented 7 months ago

The issue is that for the given seed the code

B.<a,b,c,d,e,f> = BooleanPolynomialRing()
from sage.rings.polynomial.pbori.pbori import *
l = [B.random_element() for _ in range(B.ngens())]
A, v = Sequence(l, B).coefficients_monomials()

creates a $6 \times 15$ matrix, but two of the random elements in l are actually the same. This redundant element is removed by .gauss_on_polys, which is why the associated matrix of the resulting sequence is of size $5 \times 15$; the difference between the two matrices is then one additional row of zeroes in A.echelon_form().

Since it's most likely the intended behavior to remove redundant polynomials, the doctest should probably include a rank check on the matrix A.