What it computes
Give Helmer polynomial equations with rational coefficients for a variety, or for a polynomial map. It computes:
| area | what you get |
|---|---|
| stratifications | Whitney stratifications of varieties (affine or projective, over ℂ or ℝ) and of maps; minimal stratifications; where a map is not proper |
| local invariants | multiplicities eX(Y) along any subvariety, containment in the singular locus, polar multiplicities, local Euler obstructions |
| characteristic classes | Chern–Schwartz–MacPherson, Chern–Mather, Chern–Fulton and Milnor classes; Segre classes and projective degrees; Euler characteristics; characteristic cycles |
| Euler calculus | constructible functions: sums, products, Euler integrals, pushforwards and pullbacks along maps, Euler-obstruction functions, nearby and vanishing cycles |
| singularities | Milnor and Tjurina numbers at a point; Lê numbers and Milnor-fibre Euler characteristics of non-isolated singularities; Teissier's μ* |
| optimisation and statistics | polar degrees, dual varieties, Euclidean distance degrees, maximum likelihood degrees |
A Whitney stratification partitions a variety into smooth pieces that fit together so regularly that the topology is locally constant along each one. It is where everything else starts:
import helmer
R = helmer.Ring("x, y, z")
X = helmer.Ideal(R, ["y^2*z - x^2"]) # the Whitney umbrella
helmer.whitney_stratify(X)
# {0: [ideal(z, y, x)], 1: [ideal(y, x)], 2: [ideal(y^2*z - x^2)]}
helmer.multiplicity(helmer.Ideal(R, ["x", "y"]), X) # 2: two sheets meet along the z-axis
helmer.csm_class(X) # [1, 2, 3, 0]: its CSM class; χ = 1
helmer.ed_degree(X) # 7: critical points of the distance to a general point
The umbrella is singular along the whole z-axis, but the origin is a stratum of its own: Whitney's condition fails there. For a polynomial map f: X → Y, Helmer stratifies X and Y so that, by Thom's isotopy lemma, the fibres of f are topologically the same over each stratum of Y. For the roots of a x2 + b x + c, the target strata are the discriminant b2 − 4ac and the hyperplane a = 0, where a root escapes to infinity.
Install
The current version is 2.0.0.
Binary packages for Linux (x86-64) and macOS 15 or later (Apple silicon and Intel), for Python 3.9–3.13, include everything Helmer needs:
pip install helmer-strat
The package is imported as helmer and installs the helmer command. On other systems pip builds it from source, which needs FLINT ≥ 3.0, msolve ≥ 0.6, a C++20 compiler and CMake; on Ubuntu, sudo apt install libflint-dev libmsolve-dev cmake g++. The C++ library alone builds with CMake from a clone of the repository.
Bug reports and questions are welcome on the issue tracker, or by email with “Helmer” in the subject line.
Getting started
From the command line:
$ helmer "y^2*z - x^2" Whitney stratification in C^3 with coordinates x, y, z (0.00 s) dim 2: y^2*z - x^2 dim 1: y, x dim 0: z, y, x $ helmer --projective --vars x,y,z,w "x*y*z + x*y*w + x*z*w + y*z*w" # the Cayley cubic: four nodes $ helmer --json "x^2 + y^2 + z^2 - 1" "x*y" # several equations
The best way in is the examples/ directory: eleven short Python scripts, each runnable as it is and commented as a tutorial, and a C++ program. Start with 01; after that each script stands on its own.
| example | shows |
|---|---|
| 01 first stratification | rings and ideals; reading a stratification; curves, surfaces, several equations, projective varieties |
| 02 maps | the roots of a quadratic as its coefficients vary; where a map is not proper |
| 03 algebra | Gröbner bases, dimension, minimal primes, elimination, saturation, conormal varieties |
| 04 certified | polynomial identities that prove where the critical values of a function lie |
| 05 linkages | the singular configurations of four-bar linkages |
| 06 conormal or polar | the two algorithms side by side |
| 07 local invariants | multiplicities, containment in the singular locus, polar sequences, Euler obstructions; minimal stratifications |
| 08 characteristic classes | CSM and Euler characteristics by two routes; per-stratum Chern–Mather classes; Segre, Chern–Fulton and Milnor classes |
| 09 constructible functions | indicators, Euler integrals, Euler-obstruction functions, pushforward along a map, nearby cycles |
| 10 singularities | Milnor and Tjurina numbers at a point, Lê numbers, Milnor fibres, μ* |
| 11 optimisation and statistics | ED degrees (circle, ellipse, Eckart–Young), polar degrees, dual varieties, ML degrees |
| cpp/stratify.cpp | the C++ interface |
For example, a planar four-bar linkage whose lengths satisfy a + b = c + d has a configuration space with one singular point, where the bars line up and the mechanism can change mode:
R = helmer.Ring("x1, y1, x2, y2")
I = helmer.Ideal(R, ["x1^2 + y1^2 - 1", "(x2 - 2)^2 + y2^2 - 4", "(x1 - x2)^2 + (y1 - y2)^2 - 9"])
helmer.whitney_stratify(I)[0] # [ideal(y2, x2 - 4, y1, x1 - 1)]
What is available
The Python functions, with their nearest counterparts elsewhere. The full reference, with every option, is docs/API.md.
| Helmer | counterpart | |
|---|---|---|
| Stratifications | ||
whitney_stratify(I) | M2 whitneyStratify | conormal algorithm (default); method="polar" for whitneyStratifyPol; minimal=True |
min_coarsen(S) | M2 minCoarsenWS | minimal Whitney stratification (Teissier's criterion) |
whitney_filtration(I) | the closed filtration, avoiding prime decomposition where it can | |
map_stratify(F, X, Y), non_proper_set | M2 mapStratify, nonProperSet | maps, for Thom's isotopy lemma |
| Local invariants (at a general point of V(X) ⊆ V(Y)) | ||
multiplicity, contained, in_singular_locus | M2 SegreClasses | eX(Y) for any X, not only strata |
polar_sequence, euler_obstruction | M2 eulerObsMatrix | Lê–Teissier formula |
| Characteristic classes and intersection theory (degrees by dimension in A*(ℙN)) | ||
csm_class, euler_characteristic | M2 CSM, Euler | Aluffi's formula for hypersurfaces, otherwise via a stratification; affine or projective |
chern_classes(S), cc_multiplicities | M2 multCC | per stratum: χ, CSM, Chern–Mather, characteristic cycle |
segre_class, projective_degrees | M2 segre, projectiveDegrees | s(X, Y) for X ⊆ Y ⊆ ℙN |
chern_fulton_class, milnor_class | M2 Chern | the Milnor class is Σ μp[p] for isolated singularities |
| Euler calculus | ||
indicator, euler_obstruction_function, ConstructibleFunction | +, *, .integral(), .push(F, …), .pull, .characteristic_cycle() | |
nearby_cycles, vanishing_cycles | ψf(1) and φf(1): Euler characteristics of Milnor fibres | |
| Singularities | ||
milnor_number, tjurina_number | Singular milnor, tjurina | at a rational point |
le_numbers, milnor_fibre_euler_characteristic, sectional_milnor_numbers | non-isolated singularities (Massey); Teissier's μ* | |
| Optimisation and statistics | ||
projective_polar_degrees, dual_variety_degree | M2 dualVariety (degree) | dimension, degree and defect of the dual |
ed_degree, generic_ed_degree, ml_degree | two routes each: Lagrange multipliers, or Euler obstructions | |
| Algebra | ||
minimal_primes, eliminate, saturate, intersect, Gröbner bases, dimension | Macaulay2 itself | implemented in Helmer |
certify_membership, eliminate_certified, verify_membership | certified membership and elimination | |
Projective input is homogeneous, with projective=True where a function takes both. Not yet available: products of projective spaces and toric ambient spaces, and the polar route for maps.
How it works
The algorithm is the conormal method of Helmer and Nanda, in the associated-prime-free form of Helmer and Mohr: the strata come from the singular loci of the pieces and from the fibres of their conormal varieties over the lower-dimensional pieces. What Macaulay2 supplied is implemented from scratch:
- Gröbner bases over Q from msolve's F4 modulo 31-bit primes, with Chinese remaindering and rational reconstruction, checked against a fresh prime and against the input.
- Minimal primes by factorisation and a Gianni–Trager–Zacharias-style reduction, with each prime certified by a degree count.
- Conormal varieties, where the time goes in Macaulay2, which saturates by the whole ideal of minors of the Jacobian. Helmer saturates by a single affine linear form vanishing on the singular locus when there is one (a "hyperplane chart", in one Gröbner basis by Bayer's trick), and otherwise by a single sparse minor. Both are exact for prime input.
- Free directions. When the equations are invariant under translation in some directions, as equations in the differences of the joint coordinates of a mechanism are, Helmer stratifies a slice and pulls the strata back.
The invariants beyond stratification are computed over finite fields. A local invariant along V(X) is read at a general point found as a root of an eliminant on a random slice, by cutting down to a curve germ there and taking lengths; the length at an isolated point is found by doubling N in the colength of I + (z1N, …, zsN), which Nakayama's lemma certifies once it stops growing. Global invariants (Segre classes, polar degrees, ED and ML degrees) are numbers of points of zero-dimensional schemes, written to keep degrees low: linear sections are parametrised, rank conditions use kernel coordinates or Lagrange multipliers rather than minors, and singular loci are removed by saturating with one general element rather than computed. CSM classes of hypersurfaces use Aluffi's formula, which needs one Segre class and no stratification.
What is exact, and what is certified
Stratifications. The only randomised step is the modular lifting of Gröbner bases over ℚ, as in msolve and in Macaulay2's modular methods: a wrong answer would need a reconstruction that a fresh prime confirms and that contains the input ideal. Minimal primes are certified prime, and the conormal saturations are exact. The polar route also uses random projections, by design.
Invariants. Local and global invariants are Monte Carlo: each is computed modulo random 31-bit primes with random choices, and returned when two runs agree (trials=2; raise it for more confidence). Every function documents what it needs of its input (prime, radical, pure-dimensional, homogeneous). Many invariants have two independent routes, and the test suite checks that they agree: CSM classes by Aluffi's formula and by stratification, ED and ML degrees by Lagrange multipliers and by Euler obstructions, Milnor numbers by local lengths and by Lê numbers.
Certificates. Ideal membership and elimination can be certified: eliminate_certified returns, for each generator P of an elimination ideal, cofactors with P = Σ cj gj, checked exactly over ℚ. For the critical values of a function, this proves that every critical value is a root of P.
Performance and validation
| example | Macaulay2 | Helmer |
|---|---|---|
| Whitney cusp | 0.09 s | < 0.01 s |
| projective quartic | 0.39 s | 0.01 s |
| Helmer–Mohr, Example 1.1 (a hypersurface in C4) | 14.1 s | 0.18 s |
| Helmer–Mohr, X1 (a complete intersection in C4) | 210 s | 0.04 s |
| Helmer–Mohr, X2 | 7.2 s | 0.19 s |
| a Feynman-integral map (package documentation) | 1.38 s | 0.07 s |
Wall clock on the same 2-core machine; Macaulay2 1.22 with WhitneyStratifications 2.23 on its conormal route, Helmer from Python. The Briançon–Speder family x5 + y7z + z15 + t·xy6, μ-constant but not Whitney-equisingular, takes 35 s.
Characteristic classes, by Aluffi's formula and by a stratification (same machine, same answers):
| example | stratification | Segre classes |
|---|---|---|
| CSM class of the 3×3 determinantal cubic in ℙ8 | 27 s | 0.01 s |
| CSM class of the Briançon–Speder hypersurface in ℂ4 | 125 s | 0.7 s |
| Chern–Fulton = CSM class of ℙ2 × ℙ2 ⊂ ℙ8 | 21 s | 0.02 s |
Against other systems, on the same machine:
| example | other | Helmer |
|---|---|---|
| ML degree of 4×4 matrices of rank ≤ 3 (191) | Macaulay2, one run: 46 s | 15 s for two agreeing runs |
| μ and τ of x8 + y9 + z10 + w11 + x2y2z2w2 (3884, 2912) | Singular: 16 ms | 7 ms |
| μ of a 3-variable germ with many higher-order terms (207) | Singular: no answer in 300 s | 8.7 s |
Macaulay2 1.22 on the same Lagrange system with one saturation; Singular 4.3 milnor and tjurina over ℚ in local orderings, times including about 8 ms of start-up. A systematic comparison with Macaulay2, Singular and HomotopyContinuation.jl is in preparation.
The test suite compares Helmer with Macaulay2 on the package's documentation examples, the Helmer–Mohr benchmarks and a range of singular curves, surfaces and projective hypersurfaces: the same strata in every case. It also checks the polar route against the minimal stratifications, the hyperplane charts against the exact saturation, the free directions against the direct computation, and the certificates; and every invariant against closed forms (classical Milnor numbers, Segre classes of curves and complete intersections, ML degrees of statistical models, ED degrees of determinantal varieties) and against its second route.
Licence and citing
Helmer is released under the GNU General Public License, version 3 or later (msolve is GPL, FLINT LGPL). The software comes with no warranty.
If Helmer helps your research, please cite the software with the version you used, and the papers behind it. The DOI below covers all versions; each release also has its own DOI on Zenodo, linked from its release page.
Vidit Nanda. Helmer: the Computational Intersection Theory Software. doi:10.5281/zenodo.24531434.
Martin Helmer and Vidit Nanda. Conormal Spaces and Whitney Stratifications. Foundations of Computational Mathematics, 2022; correction 2023. arXiv:2106.14555.
Martin Helmer, Anton Leykin and Vidit Nanda. Effective Whitney Stratification of Real Algebraic Varieties. Mathematics of Computation, 2025. arXiv:2307.05427.
Martin Helmer and Rafael Mohr. Faster Computation of Whitney Stratifications and their Minimization. arXiv:2406.17122.
The README lists the references for each invariant (Aluffi, Harris–Helmer, Lê–Teissier, Massey, Seade–Tibăr–Verjovsky, Draisma–Horobeţ–Ottaviani–Sturmfels–Thomas, Huh, and others).