Guide
Why SymLean
What can go wrong in the output of a computer algebra system, mistakes on record from Mathematica to SymPy, Sage, Maxima, FLINT and PARI/GP, and how proving the answer catches them.
A computer algebra system answers with an expression, and whether that expression is right depends on conditions the output rarely states: a domain, a branch, an interval without poles, a precision. When I use one for a quick calculation, I can usually fill them in myself. In a proof those conditions are the point, so SymLean answers with a theorem that carries them, and Lean’s kernel checks it.
What has to be proved#
For each kind of operation, here is what a system prints, what a proof needs on top of it, and what SymLean proves:
| Operation | A system prints | What has to be proved as well | In SymLean |
|---|---|---|---|
| Simplification | an equal expression | that the two agree on the stated domain: for real , , and needs | simplify proves that they agree under the conditions it prints |
| Differentiation | a formula for the derivative | that the function has this derivative wherever the theorem claims it, with the conditions of the denominators and branches | derive proves HasDerivAt under its conditions |
| Definite integration | a value | that the antiderivative satisfies on the whole interval, poles and endpoints included, so that the fundamental theorem of calculus applies | integrate proves there first |
| Root finding | a list of roots | that each listed value is a root, and for all roots, that there are no others | roots proves the list complete |
| Numerical computation | digits | that the exact value lies within a proved bound, rounding and truncation included | N proves every printed digit |
In an analytic proof, the last row decides whether a number can be part of the argument at all. A decimal value of a constant is evidence. A proved inequality between the constant and a threshold is a step of the proof, and that’s the one I need.
Mistakes on record#
The list below comes from the projects’ own trackers and from published papers. Each entry names the version and the date of its report, and none is a claim about a later version. I don’t mean it as a scorecard. These are good systems kept up by careful people, and several of the bugs have been fixed since they were reported. What it shows is that even mature tools sometimes print a wrong answer that looks like any other.
- Simplification. SymPy 1.14.0 rewrites
acot(-x)to-acot(x), which is false at , where SymPy’s is (sympy#30588, September 2026, fixed on the development branch). On the development branch of November 2026,Abs(1/(2*n - 1) - 1/2).subs(n, 1)gave with declared a nonnegative integer, because a sign rule took the expression to be monotonic across its pole at (sympy#30976, introduced on 2026-10-29 and fixed on 2026-11-09, before any release). - Differentiation. From 2015 to 1.14.0, SymPy gave as the derivative of . For that is the negative of the derivative of , SymPy’s own definition of (sympy#30335, August 2026, fixed on the development branch after 1.14.0).
- Definite integration. Fateman’s review of Mathematica, written in 1990 and 1991, reports that
Integrate[1/x^2, {x, -1, 1}]gave , which is what gives at the endpoints, across the pole at . With the DefiniteIntegr package of version 1.2 loaded, the answer was (J. Symbolic Comput. 13 (1992), section 10). SymPy 1.14.0 gives , although the integrand is on the whole interval (sympy#29792, May 2026, open on 2026-11-11). - Root finding. Sage 10.9 gave and as the roots of over , but neither is a root, and the roots are and (sagemath/sage#42796, September 2026, fixed in 10.10). In FLINT 3.6.0,
fmpz_poly_num_real_roots_vcacounts one real root of , which has two, because a bound on the positive roots comes out too small (flintlib/flint#2893, October 2026, open on 2026-11-11). SymPy 1.14.0 solves for real and , and the solution at , gives , while the equation is (sympy#30837, October 2026, open on 2026-11-11). Maxima’snroots(x^2 - 2, 0, a)counted one root for a bigfloat just below , because the endpoint was rounded to a rational on the other side of the root (Maxima bug #4958, August 2026, reported on a development build after 5.49 and fixed after 5.50.0, and the rounding was already in Maxima’s source of 2000). - Numerical computation. SymPy 1.14.0 evaluates , a number near , to two digits as
3.7e+2, and its assumptions call the number positive (sympy#29850, June 2026, open on 2026-11-11). In FLINT 3.2.0, whose ball arithmetic is meant to be rigorous,arb_nintof the ball returned a ball that encloses and misses , the nearest integer to (flintlib/flint#2293, April 2025, fixed in 3.3.0). - Exact algebra. Durán, Pérez and Varona found that Mathematica 8 to 9.0.1 computed wrong determinants of some integer matrices with large entries, and different values for the same matrix on repeated runs. Wolfram acknowledged the report they filed in October 2013, and their matrices still showed it in version 10 (Notices AMS 61 (2014)). In Sage 9.7 to 10.6, with parallel linear algebra switched on, the Hecke operator on the one-dimensional space came out as instead of . A change of default algorithm in 10.7 hid it, and the maintainers trace the fix to 10.8 (sagemath/sage#41267, December 2025). In Sage 10.2 to 10.9 the reduced echelon form of some sparse rational matrices was wrong, a matrix among them, because the multimodular algorithm verified its result against a bound computed from the wrong matrix (sagemath/sage#42411, June 2026, fixed in 10.10).
primecertisvalidin PARI/GP 2.17.2 and 2.19.0 accepted elliptic-curve primality certificates for composite numbers, among them (PARI bug #2723, October 2026, patched on the development branch).
The two I find most telling are failed checks. Sage’s echelon form tested its own result, and primecertisvalid exists to validate certificates. So a check is only as good as the program that runs it. In SymLean the check is a proof, and the program that accepts it is Lean’s kernel, the same one that checks every proof in Mathlib.
The same inputs in SymLean#
Here is SymLean on four of the same inputs. On Fateman’s integral, SymLean’s own search makes the old mistake and proposes . I like this example because the search really is wrong and nothing bad comes of it: the proof needs on all of , so the value is refused, and the message names the condition that failed:
#cas [integrate x in [-1, 1]] (1 / x ^ 2)
Error
`cas` did not prove the value -2 of the integral: it could not prove that the conditions of the primitive -(1/x) hold on the interval (x ≠ 0). The endpoint calculation needs a primitive valid throughout the interval.
Next, Sage’s matrix. Sage’s algorithm checked its result against a bound computed from the wrong matrix. The theorem here needs no such bound: it gives the row operations with , invertible and in reduced echelon form, and those three facts determine :
#cas [rowReduce] !![1000001000, -1/501000500, 3; 1, -1, 1]
reduced row echelon form, pivot columns [0, 1]
!![1, 0, 1503001499/501001001000499999; 0, 1, -501000999497498500/501001001000499999]- Domain
ℚ^(2×3)- Input (matrix)
!![1000001000, -1/501000500, 3; 1, -1, 1]
Checked by Lean’s kernel: Row operations E with E * A = R
!![501000500 / 501001001000499999, -(1 / 501001001000499999); 501000500 / 501001001000499999, -(501001001000500000 / 501001001000499999)] * !![1000001000, -(1 / 501000500), 3; 1, -1, 1] = !![1, 0, 1503001499 / 501001001000499999; 0, 1, -(501000999497498500 / 501001001000499999)] ∧ !![501000500 / 501001001000499999, -(1 / 501001001000499999); 501000500 / 501001001000499999, -(501001001000500000 / 501001001000499999)].det ≠ 0 ∧ !![1, 0, 1503001499 / 501001001000499999; 0, 1, -(501000999497498500 / 501001001000499999)].IsReducedRowEchelon
The certificate: 1 checked step
Row operations E with E * A = R
!![501000500 / 501001001000499999, -(1 / 501001001000499999); 501000500 / 501001001000499999, -(501001001000500000 / 501001001000499999)] * !![1000001000, -(1 / 501000500), 3; 1, -1, 1] = !![1, 0, 1503001499 / 501001001000499999; 0, 1, -(501000999497498500 / 501001001000499999)] ∧ !![501000500 / 501001001000499999, -(1 / 501001001000499999); 501000500 / 501001001000499999, -(501001001000500000 / 501001001000499999)].det ≠ 0 ∧ !![1, 0, 1503001499 / 501001001000499999; 0, 1, -(501000999497498500 / 501001001000499999)].IsReducedRowEchelon
FLINT’s quartic has two real roots. Each interval in the answer holds exactly one, and the theorem says there are no others:
#cas [roots x] (2*x^4 - 2*x^3 - 2*x^2 - 3*x - 4 = 0)
all 2 real solutions; enclosed ones by 20 decimals, truncated
-0.91456483178822888407, 2.06403079373484306477- Input (polynomial equation)
(2*x^4 - 2*x^3 - 2*x^2 - 3*x - 4 = 0)
Checked by Lean’s kernel: Complete list of real solutions
((∃! x,
x ∈ Set.Ioo (-91456483178822888408 / 10 ^ 20) (-91456483178822888407 / 10 ^ 20) ∧
2 * x ^ 4 - 2 * x ^ 3 - 2 * x ^ 2 - 3 * x - 4 = 0) ∧
∃! x,
x ∈ Set.Ioo (206403079373484306477 / 10 ^ 20) (206403079373484306478 / 10 ^ 20) ∧
2 * x ^ 4 - 2 * x ^ 3 - 2 * x ^ 2 - 3 * x - 4 = 0) ∧
∀ (x : ℝ),
2 * x ^ 4 - 2 * x ^ 3 - 2 * x ^ 2 - 3 * x - 4 = 0 →
x ∈ Set.Ioo (-91456483178822888408 / 10 ^ 20) (-91456483178822888407 / 10 ^ 20) ∨
x ∈ Set.Ioo (206403079373484306477 / 10 ^ 20) (206403079373484306478 / 10 ^ 20)from CAS.Polynomial.RealRoot.of_exprRootCheck
The certificate: 1 checked step
Complete list of real solutions
((∃! x, x ∈ Set.Ioo (-91456483178822888408 / 10 ^ 20) (-91456483178822888407 / 10 ^ 20) ∧ 2 * x ^ 4 - 2 * x ^ 3 - 2 * x ^ 2 - 3 * x - 4 = 0) ∧ ∃! x, x ∈ Set.Ioo (206403079373484306477 / 10 ^ 20) (206403079373484306478 / 10 ^ 20) ∧ 2 * x ^ 4 - 2 * x ^ 3 - 2 * x ^ 2 - 3 * x - 4 = 0) ∧ ∀ (x : ℝ), 2 * x ^ 4 - 2 * x ^ 3 - 2 * x ^ 2 - 3 * x - 4 = 0 → x ∈ Set.Ioo (-91456483178822888408 / 10 ^ 20) (-91456483178822888407 / 10 ^ 20) ∨ x ∈ Set.Ioo (206403079373484306477 / 10 ^ 20) (206403079373484306478 / 10 ^ 20)
The computation
Certified isolation
Square-free polynomial of degree 4, Cauchy bound 13/2, 10 cells Guarantee: the listed solutions are distinct, each rational is a solution, each decimal interval contains exactly one solution, and there are no other real solutions
And SymPy’s number, with written as . Where SymPy printed 3.7e+2, each of these fifteen digits is proved:
#cas [N 15] (1 / sin (231 * π / 500 + 26944))
first 15 significant digits, truncated
-89.0810623457336- Domain
closed real expression
Checked by Lean’s kernel: Certified decimal digits
-(890810623457336 + 1) / 10 ^ 13 < 1 / Real.sin (231 * Real.pi / 500 + 26944) ∧ 1 / Real.sin (231 * Real.pi / 500 + 26944) ≤ -890810623457336 / 10 ^ 13
from CAS.Continuum.DigitsEval.eval_sound
The certificate: 1 checked step
Certified decimal digits
-(890810623457336 + 1) / 10 ^ 13 < 1 / Real.sin (231 * Real.pi / 500 + 26944) ∧ 1 / Real.sin (231 * Real.pi / 500 + 26944) ≤ -890810623457336 / 10 ^ 13
The computation
Certified numerical evaluation
Working precision: 89 bits, 39 series terms, 73 logarithm terms Guarantee: every printed digit is a digit of the real value, truncated toward zero
Where the idea comes from#
None of this is a new idea, and I’m glad it isn’t. The design, in which an untrusted search proposes an answer and the prover checks it, is Harrison and Théry’s, and it has since been used in HOL Light, Rocq, Isabelle and Lean. A computer algebra system built on top of a proof assistant is Kaliszyk and Wiedijk’s. SymLean follows this design. What we added is reach: many kinds of calculation behind one Lean front end, checked in the kernel by default.
- Harrison and Théry combined HOL with Maple by separating the search for a solution from checking it: Maple searched, and HOL proved the result (“A Skeptic’s Approach to Combining HOL and Maple”, J. Automated Reasoning 21 (1998)).
- Kaliszyk and Wiedijk built a prototype computer algebra system on top of HOL Light, with an interface close to those of Maple and Mathematica, in which every expression has a precise meaning and the prover proves each simplification (“Certified Computer Algebra on Top of an Interactive Theorem Prover”, Calculemus 2007, LNCS 4573).
- Harrison verified nonlinear real formulas in HOL Light with sums of squares found by semidefinite programming, a numerical search whose certificate is easy to check in the prover (TPHOLs 2007). Rocq’s
psatzuses his driver to the external solver CSDP, and the expression the solver returns is normalized byringand checked to be (Rocq reference manual, Micromega). - Li, Passmore and Paulson decide univariate real polynomial problems in Isabelle/HOL with certificates from Mathematica. Isabelle checks the sample points, and it also checks that the roots Mathematica returned are all the real roots (J. Automated Reasoning 62 (2019)).
- Ballarin, Homann and Calmet connected Isabelle and Maple (“Theorems and Algorithms: An Interface between Isabelle and Maple”, ISSAC 1995).
- Delahaye and Mayero simplified field expressions in Coq with Maple and checked the results in Coq (J. Symbolic Computation 39 (2005)).
- Lewis connected Lean and Mathematica (PxTP 2017). Lewis and Wu then connected Lean 3 with Mathematica, used Mathematica as an untrusted oracle in proof search, and verified some of its computations in Lean (J. Automated Reasoning 66 (2022)).
- Mathlib’s
linarithlets an untrusted oracle search for a certificate of unsatisfiability, a list of coefficients of the hypotheses, and proves the contradiction from it, withringchecking the linear combination (Mathlib.Tactic.Linarith.Frontend). - Mathlib’s
polyrithasked SageMath for the coefficients of alinear_combinationcall, which Lean then checked. It was withdrawn in September 2025, after the public Sage server it used shut down (mathlib4#29547). The calls it had suggested never depended on Sage.
Inside provers, computer algebra and certified numerics have a history of their own:
- Grégoire and Mahboubi’s
ringin Coq normalizes by reflection (TPHOLs 2005), the approach behind SymLean’s normalizer and Mathlib’sring. - In Isabelle/HOL, Thiemann and Yamada formalized algebraic numbers (ITP 2016), Divasón, Joosten, Thiemann and Yamada verified Berlekamp-Zassenhaus factorization (J. Automated Reasoning 64 (2020)), and Eberl verified real asymptotics and limits (ISSAC 2019).
- Hex, the Lean FRO’s verified computer algebra, proves factorization, determinants and primality in Lean. SciLean brings scientific computing to Lean 4, with symbolic manipulation and automatic differentiation.
- Melquiond’s interval methods in Coq prove bounds on real functions (IJCAR 2008), and Mahboubi, Melquiond and Sibut-Pinote extended them to definite integrals (J. Automated Reasoning 62 (2019)).
- MetiTarski proves inequalities between real special functions automatically (J. Automated Reasoning 44 (2010)).
- In Lean, Irving and coauthors built conservative interval arithmetic (girving/interval), and LeanCert proves bounds and roots by verified interval arithmetic.
What this does not mean#
- SymLean doesn’t compute everything Mathematica can. A search can fail, and a refusal proves nothing: SymLean finds no antiderivative for SymPy’s integrand above and says so.
- A list is complete only when the theorem says so.
rootsproves that no root is missing, whilefindRootproves one root and its uniqueness near the printed value. - The oracles are not verified. They propose, and their answers enter only through a proof (Oracles).
- The default profile trusts Lean’s kernel and its standard axioms. Native evaluation is opt-in and adds Lean’s compiler (What you trust).
- Lean checks theorems about the data it is given. A build that embedded a stale copy of a data file would get a correct theorem about the stale data, so the build has to track its input files.
- The theorem is about what you wrote, with Lean’s definitions, where (What a refusal means).
To try it, start with Getting started, or browse the documentation.
