Skip to content
Proyectos

Acerca de

Library for Polynomial System Solving through Algebraic Methods

Ciencia e ingeniería

Cómo se miden estas cifras

Crecimiento de estrellas medido

in 24h
0
in 7 days
0
in 15 days
+1
in 1 month
Recopilando historial

Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.

README.md

Original

MSOLVE: Multivariate polynomial system solver

Documentation

https://msolve.lip6.fr/

msolve is an open source C library implementing computer algebra algorithms for solving polynomial systems (with rational coefficients or coefficients in a prime field).

Currently, with msolve, you can basically solve multivariate polynomial systems. This encompasses:

  • the computation of Groebner bases
  • real root isolation of the solutions to polynomial systems
  • the computation of the dimension and the degree of the solution set and many other things you can do using msolve.

A tutorial is available here

Some of the functionalities of msolve are already available in the computer algebra systems Oscar and SageMath. See below for some more information about this.

Install Instructions

See the INSTALL file. At the moment, msolve does not support 32 bit architectures.

For a local build optimized for the build machine, run ./configure CFLAGS="-O2 -march=native". Omit -march=native when building binaries for other machines; use the intended compiler target instead.

On x86 CPUs msolve is compiled with -Wa,-mbranches-within-32B-boundaries if the assembler supports this option, i.e. with GNU binutils 2.34 or newer. It aligns jumps to 32 byte boundaries, which avoids a slowdown of up to about 10% on CPUs affected by the Intel JCC erratum (Skylake to Cascade Lake). With older binutils msolve is built without it.

Input File Format

More informations are given in the tutorial (see https://msolve.lip6.fr)

msolve input files need to be of the following format:

1st line: variables as commata separated list, e.g. x1,x2,x3,x4,y1,y2.
2nd line: field characteristic, e.g. 0.
following lines: generating polynomials, all but the last one need to terminate by a ,, e.g.

x1,x2,x3,x4,y1,y2
101
x1+x2+x3+x4,
2*y1-145*y2

Polynomials may be multiline, thus , as a separator.

Coefficients can be rational, using /, e.g. -2/3*x2*y1^2+....

In each polynomial, a single occurrence of each monomial is expected; the behaviour of msolve's parser is undefined if some monomial is repeated, as in x1+x2+x3+x4-x1.

Basic usage

Some basic commands are as follows:

./msolve -f in.ms -o out.ms

will:

  • detect if the input system has dimension at most 0
  • when the system has dimension at most 0 and the coefficients are rational numbers, msolve will isolate the real solutions
  • when the system has dimension at most 0 and the coefficients are in a prime field, msolve will compute a parametrization of the solutions

All output data are displayed in the file out.ms

The -vflag allows you to control the verbosity, giving insight on what msolve is doing. Try this.

./msolve -v 2 -f in.ms -o out.ms

Computing Groebner bases

msolve computes Groebner bases when the base field is either the field of rational numbers or a prime field (characteristic should be less than 2^52; for characteristics of at least 2^31 only Groebner bases can be computed), or GF(16) resp. GF(256), see below. It also computes Groebner bases in the boolean ring over GF(2), see below.

The following command

./msolve -g 1 -f in.ms -o out.ms

will compute the leading monomials of the reduced Groebner basis of the ideal generated by the input system in in.ms for the so-called graded reverse lexicographic ordering. This allows you to deduce the dimension of the solution set to the input polynomials (in an algebraic closure of the base field) as well as the degree of the ideal they generate.

Using the -g 2 flag as follows

./msolve -g 2 -f in.ms -o out.ms

will return the reduced Groebner basis for the graded reverse lexicographic ordering.

msolve also allows you to perform Groebner bases computations using one-block elimination monomial order thanks to the -e flag. The following command

./msolve -e 1 -g 2 -f in.ms -o out.ms

will perform the Groebner basis computation eliminating the first variable. More generally, using -e k will eliminate the first k variables.

Groebner bases (options -g 1 and -g 2) can also be computed over the binary extension fields GF(16) and GF(256), the 2nd line of the input file is then 2^4 resp. 2^8 (16 resp. 256 are accepted as well). Field elements are written in hexadecimal notation as bytes: bit i is the coefficient of t^i in GF(2)[t]/(t^4+t+1) resp. GF(2)[t]/(t^8+t^4+t^3+t+1), e.g. 0x1b is t^4+t^3+t+1. Field elements have to be reduced, i.e. less than 0x10 resp. 0x100, msolve stops with an error otherwise. An integer coefficient n stands for n*1, i.e. for n modulo 2, as usual in characteristic 2. For example, 0x1b*x1^2+3*x2+x3 has the coefficients t^4+t^3+t+1, 1 and 1. The Groebner basis is printed with hexadecimal coefficients. If all coefficients lie in GF(2), e.g. if they are all integers, the Groebner basis is computed over GF(2), which is faster.

Groebner bases (options -g 1 and -g 2) can also be computed in the boolean ring over GF(2), i.e. with x^2 = x for all variables x, the 2nd line of the input file is then boolean. Alternatively, the option --boolean computes in the boolean ring for an input file over GF(2). Powers of variables in the input are reduced, e.g. x1^3*x2^2+x1*x2 is 0. The reduced Groebner basis of the ideal in the boolean ring is the one of the ideal with the field equations x^2+x added, without the field equations themselves.

For input systems in few variables (at most 32), e.g. a single polynomial describing a set of points, the option --boolean-zeros computes the reduced Groebner basis in the boolean ring via the common zeros of the input polynomials: the ideal in the boolean ring consists of all polynomials vanishing on these zeros, its Groebner basis is computed by the Buchberger-Moeller algorithm. All 2^n points are evaluated, so the time and memory needed grow with 2^n and with the square of the number of common zeros. With the option --lex the basis is computed w.r.t. the lexicographical order instead of the graded reverse lexicographical one, only together with --boolean-zeros.

Signature-based F4

For Groebner bases w.r.t. the graded reverse lexicographical order (-g 1 and -g 2) msolve can run a signature-based variant of F4 (a batched F5: each round builds one F4 matrix from all pending signatures of least degree, rows reducing to zero give syzygy signatures and are never computed again). It is selected by the flag

./msolve -g 2 --signature-f4 SIG -f in.ms -o out.ms

with SIG one of

  • -1 the signature-based F4 is used for computations over prime fields (over GF(16) and GF(256) only on request, see below), but not for learning traces over the rationals;
  • 0 never, plain F4 is used;
  • 1 also for learning the traces of computations over the rationals;
  • 2 as 1, but without handing over to F4 (for testing);
  • 3 as -1 over prime fields; over the rationals the trace is learned by F4, which only selects the S-pairs not reducing to zero in a signature-based run (guided learning, see below).

The default is -1; for Groebner bases over the rationals it is 3 with the default lifting --gb-lifting 2, and 1 with --gb-lifting 0 or 1. The signature-based F4 is only used for the graded reverse lexicographical order, i.e. not with elimination orders (-e), not in the boolean ring, and only for prime fields below 2^31. Where it does not pay off it hands over: the run is stopped and the plain F4 starts again from the input generators. The reason is printed with -v 1 as signature-based F4 hands over to F4 (...): e.g. the S-pairs of an update become too many compared to the work done, too few zero reductions or too many divisible new elements in the first rounds past the lead degree, a dense matrix, a degree beyond what the packed monomials hold, or a round whose reductions grow too fast. With --signature-f4 2 it never hands over. The result is the same reduced Groebner basis as with F4, only the computation differs.

With -v 2 the rounds are printed in the table of the F4 rounds, with one legend for both parts: sel is then the number of signatures in the matrix and pairs the number of pending signatures. After a hand-over the rows of F4 continue in the same table. Details of each round are printed from -v 3 on.

Prime fields, GF(16) and GF(256)

Over prime fields below 2^31 the signature-based F4 is on by default. Over the binary extension fields GF(16) and GF(256) F4 is about as fast on average and much faster on some inputs, so the signature-based F4 is only run there with --signature-f4 1 or 2. Over GF(2) and in the boolean ring it is not available.

Groebner bases over the rationals

Over the rationals msolve computes the Groebner basis modulo primes: the computation at a first prime learns a trace, which is applied at more primes (unlucky primes are detected and skipped). The coefficients are reconstructed from the images by the Chinese remainder theorem and rational reconstruction, and each reconstructed polynomial is checked against its images at further primes (a probabilistic check, not a certificate that the result is a Groebner basis). By default the trace is learned by F4 guided by a signature-based run: F4 only reduces the S-pairs whose lcms are lead terms of that run, so that it reduces few rows to zero, and its trace is cheaper to apply than the record of the signature-based run. With --gb-lifting 0 or 1 and the default --signature-f4 1 the trace is the record of the signature-based run, which is replayed at the other primes: rows reducing to zero are not computed again. The replay uses 31 bit primes or, where the first applications show that this pays off, 61 bit primes (fewer primes are needed). Where many primes are needed, the signature-based trace is replaced by a trace learned by F4 guided by it, as that one is cheaper to apply. If the signature-based run hands over to F4, the trace is learned by F4 as usual. --signature-f4 3 always learns the trace by guided F4, as the default lifting does (this costs more where the signature-based run is expensive), --signature-f4 0 by plain F4.

The lifting of the coefficients is selected by

./msolve -g 2 --gb-lifting GBL -f in.ms -o out.ms

where GBL=0 reconstructs each coefficient by CRT and rational reconstruction, and GBL=1 computes the mixed radix digits of the coefficients times their common denominator, so that a coefficient costs as many primes as it has bits, and uses rational reconstruction only for new denominators. GBL=2 (default) selects the lifting of the multi-threaded version of msolve, which is also used for the strong Groebner bases over the integers: by default the traces are learned by F4 guided by a signature-based run, as with --signature-f4 3 (by plain F4 with --signature-f4 0 or -1, by the signature-based F4 with 1 or 2), the coefficients are reconstructed by CRT and rational reconstruction, or by LLL for the coefficients missed by the witness denominators, with primes of 31 or 52 bits (--gb-prime-bits), and the primes of a batch can be applied on threads of their own (--local-threads). Where a trial shows that this costs less per bit of the modulus, a trace learned by F4 is applied at eight primes of 31 bits at once (with several threads, each thread applies it at eight primes, but only where an application at one prime is short). The options --gb-prime-bits and --local-threads are only known to this lifting, which is used whenever one of them is given. All values of GBL give the same Groebner basis.

Linear algebra

The flag -l LIN (--linear-algebra) selects the linear algebra of the Groebner basis computations over prime fields: 1 exact sparse / dense, 2 exact sparse (default), 42 and 44 probabilistic (sparse / dense resp. sparse linearization), 45 as 44, but the basis is then proven exactly and computed again with 2 if the proof fails, so the result is exact (faster where many rows reduce to zero, else up to several times slower; as 2 over the rationals), 46 as 44, where with one thread the combinations are formed in blocks of rows that grow while they give no new pivots (probabilistic).

Solving over the real numbers

When the input polynomial system has rational coefficients and when it has finitely many complex solutions, msolve will, by default, compute the real solutions to the input system. Those are encoded with isolating boxes for all coordinates to all real solutions.

For instance, on input file in.ms as follows

x, y
0
x^2+y^2-4,
x*y-1

the call ./msolve -f in.ms -o out.ms will display in the file out.ms the following output

[0, [1,
[[[-41011514734338452707966945920 / 2^96, -41011514734338452707966945917 / 2^96], [-153057056683910732545430822374 / 2^96, -153057056683910732545430822373 / 2^96]], 
[[-612228226735642930181723289497 / 2^98, -612228226735642930181723289492 / 2^98], [-164046058937353810831867783675 / 2^98, -164046058937353810831867783674 / 2^98]], 
[[612228226735642930181723289492 / 2^98, 612228226735642930181723289497 / 2^98], [164046058937353810831867783674 / 2^98, 164046058937353810831867783675 / 2^98]], 
[[41011514734338452707966945917 / 2^96, 41011514734338452707966945920 / 2^96], [153057056683910732545430822373 / 2^96, 153057056683910732545430822374 / 2^96]]]
]]:

which are the 4 isolating boxes of the 4 exact roots whose numerical approximations are (-0.5176380902, -1.931851653), (-1.931851653, -0.5176380902), (1.931851653, 0.5176380902) and (0.5176380902, 1.931851653).

Multi-threading

Several components of msolve are parallelized through multi-threading. Typing

./msolve -t 4 -f in.ms -o out.ms

tells msolve to use 4 threads. Multi-threading in msolve is used in

  • linear algebra algorithms used for Groebner bases computations over prime fields
  • multi-modular computations for solving over the reals (all intermediate and independent prime computations are run in parallel)
  • algorithms for real root isolation.

msolve in AlgebraicSolving

AlgebraicSolving is a Julia package that wraps msolve and provides some more functionality like normal form computations, Hilbert series and Krull dimension, or computing rational solutions to zero-dimensional systems of polynomial equations.

It contains also some more contributions by Rafel Mohr and Rémi Prébet providing advanced algorithms for computing equidimensional decomposition of polynomial ideals as well as algorithms for analyzing the connectivity of real algebraic sets.

See here for more information and documentation.

msolve in Oscar

msolve is used in Oscar to solve polynomial systems with rational coefficients.

It will detect if the input system has finitely many complex solutions, in which case it will output a rational parametrization of the solution set as well as the real solutions to the input system (see msolve's tutorial here).

You can have a look at this and the documentation of Oscar.

Here is how you can use it.

julia> R,(x1,x2,x3) = PolynomialRing(QQ, ["x1","x2","x3"])
(Multivariate Polynomial Ring in x1, x2, x3 over Rational Field, fmpq_mpoly[x1, x2, x3])
julia> I = ideal(R, [x1+2*x2+2*x3-1, x1^2+2*x2^2+2*x3^2-x1, 2*x1*x2+2*x2*x3-x2])
ideal(x1 + 2*x2 + 2*x3 - 1, x1^2 - x1 + 2*x2^2 + 2*x3^2, 2*x1*x2 + 2*x2*x3 - x2)
julia> real_solutions(I)
((84*x^4 - 40*x^3 + x^2 + x, 336*x^3 - 120*x^2 + 2*x + 1, PolyElem[-184*x^3 + 80*x^2 - 4*x - 1, -36*x^3 + 18*x^2 - 2*x], fmpz[-1, -1]), Vector{fmpq}[[744483363399261433351//1180591620717411303424, 372241681699630716673//1180591620717411303424, -154187553040555781639//1180591620717411303424], [1, 0, 0], [71793683196126133110381699745//316912650057057350374175801344, 71793683196126133110381699745//633825300114114700748351602688, 173325283664805084153412401855//633825300114114700748351602688], [196765270119568550571//590295810358705651712, 1//590295810358705651712, 196765270119568550571//590295810358705651712]])

msolve in SageMath

SageMath is a free open-source mathematics software system.

When you have msolve installed, it is used by SageMath when you call the Variety function for solving polynomial systems with real coefficients.

You can have a look here and here

See also here for a documentation on how to solve systems of polynomial equations in SageMath using msolve.

We are grateful to Marc Mezzarobba who initiated the usage of msolvein SageMath and the whole development team of SageMath, in particular those involed in this ticket

msolve in Macaulay2

Macaulay2 is a software system devoted to support research in algebraic geometry and commutative algebra.

It comes now with an msolve package providing to the users of Macaulay2 functionalities offered by msolve.

See here for a full documentation on this package and how to use msolve in Macaulay2.

Citing msolve

If you have used msolve in the preparation of some paper, we are grateful that you cite it as follows:

msolve: A Library for Solving Polynomial Systems, 
J. Berthomieu, C. Eder, M. Safey El Din, Proceedings of the  
46th International Symposium on Symbolic and Algebraic Computation (ISSAC), 
pp. 51-58, ACM, 2021.

or, if you use BibTeX entries:

@inproceedings{msolve,
  TITLE = {{msolve: A Library for Solving Polynomial Systems}},
  AUTHOR = {Berthomieu, J{\'e}r{\'e}my and Eder, Christian and {Safey El Din}, Mohab},
  BOOKTITLE = {{2021 International Symposium on Symbolic and Algebraic Computation}},
  ADDRESS = {Saint Petersburg, Russia},
  SERIES = {46th International Symposium on Symbolic and Algebraic Computation},
  PAGES     = {51--58},
  PUBLISHER = {{ACM}},  
  YEAR = {2021},
  MONTH = Jul,
  DOI = {10.1145/3452143.3465545},
  PDF = {https://hal.sorbonne-universite.fr/hal-03191666v2/file/main.pdf},
  HAL_ID = {hal-03191666},
  HAL_VERSION = {v2},
}

The paper can be downloaded here.

Funding

The development of msolve is supported by the Forschungsinitiative Rheinland-Pfalz and the Agence Nationale de la Recherche.

Explorar proyectos relacionados

Cargando…