Show HN: Sostactic — polynomial inequalities using sums-of-squares in Lean

What it is
Sostactic is a new Lean4 tactic suite that leans on a Python backend to produce sum‑of‑squares (SOS) certificates for polynomial inequalities. It plugs into Lean or can be driven from Python, and it has been reported that these tactics can solve inequalities that built‑in tactics like nlinarith and positivity cannot. Examples in the repo range from the familiar AM‑GM inequality to the Motzkin polynomial and more pathological cases — even proving infeasibility of semialgebraic systems such as two disjoint unit disks. Impressive? Yes. Magic? Not quite.
How it works
The Lean tactics ask a Python CLI to run an SDP solver (cvxpy under the hood) and return a numerical SOS decomposition. That solution is then rationalized and projected to an exact certificate which Lean checks. This two‑step dance — numerical search followed by exactification — is well known in the SOS world, and Sostactic packages it into a developer‑friendly workflow with examples, a blog post, and full README documentation. Want your coding agent to read it? The README even suggests pointing it at the docs.
Caveats, setup and limitations
Allegedly, in theory Sostactic can handle global nonnegativity, nonnegativity over semialgebraic sets, or show a semialgebraic set is empty. In practice numerical issues can bite: exactification may fail for a variety of reasons, and the tool will surface suggestions (tweak degrees, change options) to recover. Setup is straightforward but exact: you need Lean 4, a matching Mathlib version, Python 3.10+, and a virtualenv with the repo’s Python requirements; Sostactic auto‑discovers .venv/bin/python3 or you can set SOSTACTIC_PYTHON.
This is part of a wider trend — modern proof assistants increasingly outsource heavy numeric searches but insist on checked, exact certificates. Sostactic slots neatly into that pattern: it hands Lean a calculator, then makes Lean show its work. Curious? Check the Sostactic repo for examples and the accompanying blog post for the deeper theory.
Sources: github.com/mmaaz-git, Hacker News
Comments