Skip to content

Conversation

@leodemoura
Copy link
Member

This PR adds a done flag to the result returned by Simprocs in Sym.simp.

The done flag controls whether simplification should continue after the result:

  • done = false (default): Continue with subsequent simplification steps
  • done = true: Stop processing, return this result as final

Use cases for done = true

In pre simprocs

Skip simplification of certain subterms entirely:

def skipLambdas : Simproc := fun e =>
  if e.isLambda then return .rfl (done := true)
  else return .rfl

In post simprocs

Perform single-pass normalization without recursive simplification:

def singlePassNormalize : Simproc := fun e =>
  if let some (e', h) ← tryNormalize e then
    return .step e' h (done := true)
  else return .rfl

With done = true, the result e' won't be recursively simplified.

This PR adds a `done` flag to the result returned by `Simproc`s in `Sym.simp`.

The `done` flag controls whether simplification should continue after the result:
- `done = false` (default): Continue with subsequent simplification steps
- `done = true`: Stop processing, return this result as final

 ## Use cases for `done = true`

 ### In `pre` simprocs
Skip simplification of certain subterms entirely:
```
def skipLambdas : Simproc := fun e =>
  if e.isLambda then return .rfl (done := true)
  else return .rfl
```

 ### In `post` simprocs
Perform single-pass normalization without recursive simplification:
```
def singlePassNormalize : Simproc := fun e =>
  if let some (e', h) ← tryNormalize e then
    return .step e' h (done := true)
  else return .rfl
```
With `done = true`, the result `e'` won't be recursively simplified.

 ## Behavior

The `done` flag affects:
1. **`andThen` composition**: If the first simproc returns `done = true`,
   the second simproc is skipped.
2. **Recursive simplification**: After `pre` or `post` returns `.step e' h`,
   `simp` normally recurses on `e'`. With `done = true`, recursion is skipped.

The flag is orthogonal to caching: both `.rfl` and `.step` results are cached
regardless of the `done` flag, and cached results are always treated as final.
@leodemoura leodemoura added the changelog-tactics User facing tactics label Jan 5, 2026
@leodemoura leodemoura enabled auto-merge January 5, 2026 02:03
@leodemoura leodemoura added this pull request to the merge queue Jan 5, 2026
Merged via the queue into master with commit 82f60a7 Jan 5, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-tactics User facing tactics

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants