perf: skip type checking in `Closure.mkValueTypeClosure` when the local context has no let-declarations (#15230) This PR speeds up the elaboration of definitions using `match`, and of other auxiliary definitions created with `mkAuxDefinition` and `mkAuxTheorem` with `zetaDelta := false`. On a file with 12,800 small pattern-matching definitions, cumulative elaboration time drops from about 19s to about 17s. `Closure.mkValueTypeClosure` with `zetaDelta := false` runs `check` on the value, its type, and the type of every abstracted local. The only purpose of this check is to discover which let-declarations of the local context are zeta-delta expanded during type checking, so that they can be kept as `let`s in the auxiliary definition instead of being lambda-abstracted. When the local context has no let-declarations, the check cannot find anything and its result is discarded. `mkMatcherAuxDefinition` always uses `zetaDelta := false`, so every `match` paid for this check, including matchers that hit the matcher cache. The new `Context.hasLetDecls` flag is computed once per closure, and `preprocess` skips the check when it is `false`. Behavior is unchanged whenever the local context contains a let-declaration. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01H836x4J1WCWxgJqoL3MLk6 Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This is the repository for Lean 4.
See Install Lean.
Please read our Contribution Guidelines first.
See Building Lean.