Helmer

Whitney stratifications of complex and real algebraic varieties, and of polynomial maps, from their equations. A C++ library with Python bindings and a command-line program, needing no Macaulay2.

What it computes

Helmer is named in memory of Martin Helmer. It reimplements his Macaulay2 package WhitneyStratifications so that it runs wherever C++ or Python runs.

A Whitney stratification of an algebraic variety X partitions it into smooth pieces, the strata, that fit together so regularly (Whitney's condition (b)) that the topology of X is locally constant along each stratum. It is the natural input for computing the topology of singular spaces: intersection homology, Morse theory, and the singularities of maps and mechanisms.

Given polynomial equations with rational coefficients, Helmer returns, for each dimension d, the prime ideals whose zero sets are the closures of the d-dimensional strata. The open strata are differences: the points of V(P) not in any stratum of lower dimension.

import helmer

R  = helmer.Ring("x, y, z")
WS = helmer.whitney_stratify(helmer.Ideal(R, ["y^2*z - x^2"]))    # the Whitney umbrella
# {0: [ideal(z, y, x)], 1: [ideal(y, x)], 2: [ideal(y^2*z - x^2)]}

The umbrella is singular along the whole z-axis, but the origin is a stratum of its own: Whitney's condition fails there. Over the real numbers the same polynomials give a valid stratification of the real points; some strata may then be empty or of lower dimension.

For a polynomial map f: X → Y, Helmer stratifies X and Y so that f maps each stratum of X submersively onto a stratum of Y. By Thom's isotopy lemma the fibres of f are then topologically the same over each stratum of Y: the target strata are where the topology of the fibres can change. For the roots of a x2 + b x + c, these are the discriminant b2 − 4ac and the hyperplane a = 0, where a root escapes to infinity.

Install

The current version is 1.0.0.

Binary packages for Linux (x86-64) and macOS (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 examples/ directory has six short Python scripts and a C++ program:

exampleshows
01 first stratificationrings and ideals; reading a stratification; curves, surfaces, several equations, projective varieties
02 mapsthe roots of a quadratic as its coefficients vary; where a map is not proper
03 algebraGröbner bases, dimension, minimal primes, elimination, saturation, conormal varieties
04 certifiedpolynomial identities that prove where the critical values of a function lie
05 linkagesthe singular configurations of four-bar linkages
06 conormal or polarthe two algorithms side by side
cpp/stratify.cppthe 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

HelmerMacaulay2 (WhitneyStratifications)
whitney_stratify(I)whitneyStratify(I, AssocPrimes=>false)the conormal algorithm (default)
whitney_stratify(I, method="polar")whitneyStratifyPol(I)polar varieties: randomised, non-minimal
map_stratify(F, X, Y)mapStratify(F, X, Y)maps, for Thom's isotopy lemma
non_proper_set(F, X, Y)nonProperSetwhere a map is not proper (Jelonek)
conormal(I), polar_varieties(I)conormal, polarVars
minimal_primes, eliminate, saturate, intersect, Gröbner bases, dimensiondecompose, … (Macaulay2 itself)implemented in Helmer
certify_membership, eliminate_certified, verify_membershipnew: certified membership and elimination

Projective varieties are handled with projective=True. Not yet ported: minimisation of stratifications (minCoarsenWS), the polar route for maps, and the Euler-obstruction and characteristic-cycle functions, which rest on Segre classes. The full reference is docs/API.md.

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.

What is exact, and what is certified

The only randomised step is the modular lifting of Gröbner bases over Q, 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.

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 Q. For the critical values of a function, this proves that every critical value is a root of P, even when the critical points are not isolated.

Performance and validation

exampleMacaulay2Helmer
Whitney cusp0.09 s< 0.01 s
projective quartic0.39 s0.01 s
Helmer–Mohr, Example 1.1 (a hypersurface in C4)14.1 s0.18 s
Helmer–Mohr, X1 (a complete intersection in C4)210 s0.04 s
Helmer–Mohr, X27.2 s0.19 s
a Feynman-integral map (package documentation)1.38 s0.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.

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.

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 and the papers behind it:

Vidit Nanda. Helmer: Whitney stratifications of algebraic varieties and maps, version 1.0.0, 2026. doi:10.5281/zenodo.24531435.

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.