perf: share monomials and coefficients in `grind` ring proof terms This PR makes `grind` ring proofs smaller in memory by building the expression of each distinct monomial and coefficient once. The polynomials of a proof have few distinct monomials and coefficients, but they are separate objects, so `toExpr` produced a copy for every occurrence: on a Gröbner basis benchmark, 1.2 million `Mon.mult` nodes for 1,500 distinct monomials. Every traversal of the proof paid for the copies, including `instantiateMVars`, `Environment.hasUnsafe` and the hash-consing in the kernel. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This is the repository for Lean 4.
See Install Lean.
Please read our Contribution Guidelines first.
See Building Lean.