Skip to content

[Merged by Bors] - feat(Tactic/FieldSimp): rewrite for performance and robustness - #28658

Closed
hrmacbeth wants to merge 16 commits into
leanprover-community:masterfrom
hrmacbeth:fieldsimp-rewrite
Closed

hrmacbeth wants to merge 16 commits into
leanprover-community:masterfrom
hrmacbeth:fieldsimp-rewrite

Conversation

@hrmacbeth

@hrmacbeth hrmacbeth commented Aug 19, 2025 •

Copy link
Copy Markdown
Member

This is a rewrite from scratch of the field_simp tactic. The former implementation was a lightweight wrapper around simp (with a custom simp-set and discharger).

Broadly speaking, the new implementation reduces expressions to an internal normal form x1 ^ k1 * ... * xn ^ kn, where x1, ... xn are atoms tracked by the AtomM monad and k1, ... kn are integers.

This is more robust: the tactic now solves goals which were not in scope for the simp-set version, often to the confusion of users. For example, x ^ 2 / x is now reduced to x, and x / (x * y) is now reduced, given (hx : x ≠ 0), to 1 / y.

It's also faster: on a typical large example taken from Mathlib, the heartbeat count reduces from 19983 heartbeats to 2979 heartbeats.

There is a big diff: the old field_simp subsumed simp, and this was often exploited. We offer a simproc version of the new field_simp, and switching to a simp call with this simproc fixes about 80% of the cases that break; the rest are handled individually (typically by alternating simp and field_simp calls).

Developed at Big Proof at the Isaac Newton Institute.

Co-authored-by: Arend Mellendijk @fldutchmann
Co-authored-by: Michael Rothgang @grunweg


Open in Gitpod

For ease of review, the PR is built from two commits: the tactic implementation itself (+1318, -265), and the fixes across the library (+511, -533).

A good way to get a sense of the changed implementation is to look at the diff in MathlibTest.FieldSimp.

Zulip announcement

Zulip PR reviews discussion

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). large-import Automatically added label for PRs with a significant increase in transitive imports ready-to-merge This PR has been sent to bors. t-meta Tactics, attributes or user commands

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants