Repository: sagemath/sage

Issue:
msolve interface is missing support for non-finite fields
### Problem Description

While `msolve` well support equations over `QQ`, Sage's interface does not support anything besides finite fields of bounded characteristic:
```
File /usr/local/sage/sage/src/sage/rings/polynomial/msolve.py:106, in groebner_basis_degrevlex(ideal)
    103 base = ideal.base_ring()
    104 if not (isinstance(base, FiniteField) and base.is_prime_field() and
    105         base.characteristic() < 2**31):
--> 106     raise NotImplementedError(f"unsupported base field: {base}")
    108 drlpolring = ideal.ring().change_ring(order='degrevlex')
    109 msolve_out = _run_msolve(ideal, ["-g", "2"])

NotImplementedError: unsupported base field: Rational Field
```

### Proposed Solution

Add to Sage's interface support for every field that is supported by `msolve`.

### Alternatives Considered

N/A

### Additional Information

_No response_

### Is there an existing issue for this?

- [X] I have searched the existing issues for a bug report that matches the one I want to file, without success.


Discussion:
Actually the interface does support all fields that were supported by msolve 0.4.9, that is, if I recall correctly:
- for computing zero-dimensional varieties, small prime fields and ℝ (ℚ and its extensions, as well as extensions of small prime fields, are not supported natively by msolve but supported by the interface by combining msolve's support for parameterizations with Sage's rootfinders),
- for computing Gröbner bases, small prime fields only.
msolve 0.5.0 added support (or at least some support?) for Gröbner bases over the rationals. I believe this is the only feature for which the interface is not up to date. Were you thinking of anything else?

Resolving patch:
diff --git a/src/sage/rings/polynomial/msolve.py b/src/sage/rings/polynomial/msolve.py
--- a/src/sage/rings/polynomial/msolve.py
+++ b/src/sage/rings/polynomial/msolve.py
@@ -64,7 +64,7 @@ def _run_msolve(ideal, options):
 
     return msolve_out.stdout
 
-def groebner_basis_degrevlex(ideal):
+def groebner_basis_degrevlex(ideal, proof=True):
     r"""
     Compute a degrevlex Gröbner basis using msolve
 
@@ -85,25 +85,27 @@ def groebner_basis_degrevlex(ideal):
         [c^4 + 38*c^3 - 6*c^2 - 6*c, 30*c^3 + 32*c^2 + b - 14*c,
         a + 2*b + 2*c - 1]
 
-    TESTS::
-
-        sage: R.<foo, bar> = PolynomialRing(GF(536870909), 2)
-        sage: I = Ideal([ foo^2 - 1, bar^2 - 1 ])
-        sage: I.groebner_basis(algorithm='msolve') # optional - msolve
-        [bar^2 - 1, foo^2 - 1]
+    Gröbner bases over the rationals require `proof=False`::
 
         sage: R.<x, y> = PolynomialRing(QQ, 2)
         sage: I = Ideal([ x*y - 1, (x-2)^2 + (y-1)^2 - 1])
         sage: I.groebner_basis(algorithm='msolve') # optional - msolve
         Traceback (most recent call last):
         ...
-        NotImplementedError: unsupported base field: Rational Field
+        ValueError: msolve relies on heuristics; please use proof=False
+        sage: I.groebner_basis(algorithm='msolve', proof=False) # optional - msolve
+        [x*y - 1, x^2 + y^2 - 4*x - 2*y + 4, y^3 - 2*y^2 + x + 4*y - 4]
+
+    TESTS::
+
+        sage: R.<foo, bar> = PolynomialRing(GF(536870909), 2)
+        sage: I = Ideal([ foo^2 - 1, bar^2 - 1 ])
+        sage: I.groebner_basis(algorithm='msolve') # optional - msolve
+        [bar^2 - 1, foo^2 - 1]
     """
 
-    base = ideal.base_ring()
-    if not (isinstance(base, FiniteField) and base.is_prime_field() and
-            base.characteristic() < 2**31):
-        raise NotImplementedError(f"unsupported base field: {base}")
+    if ideal.base_ring() is QQ and sage.structure.proof.proof.get_flag(proof, "polynomial"):
+            raise ValueError("msolve relies on heuristics; please use proof=False")
 
     drlpolring = ideal.ring().change_ring(order='degrevlex')
     msolve_out = _run_msolve(ideal, ["-g", "2"])
diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal.py b/src/sage/rings/polynomial/multi_polynomial_ideal.py
--- a/src/sage/rings/polynomial/multi_polynomial_ideal.py
+++ b/src/sage/rings/polynomial/multi_polynomial_ideal.py
@@ -4269,8 +4269,7 @@ def groebner_basis(self, algorithm='', deg_bound=None, mult_bound=None, prot=Fal
             Macaulay2's ``GroebnerBasis`` command with the strategy "MGB" (if available)
 
         ``'msolve'``
-            `optional package msolve <../spkg/msolve.html>`_ (degrevlex order,
-            prime fields)
+            `optional package msolve <../spkg/msolve.html>`_ (degrevlex order)
 
         ``'magma:GroebnerBasis'``
             Magma's ``Groebnerbasis`` command (if available)


Test patch: