leanprover / leanprover/lean4

Missing optimization: trivial cases

Open
#599 0 comments 0 reactions 1 assignee View on GitHub

@zwarich is already working on this.

Since Apr 29, 2025.

enhancement low priority P-low
Dominant language
Lean
Stars
9.2k
Forks
990
Avg merge
1d 17h
Merged PRs (30d)
175

Description

In

  @EStateM.Result.casesOn _x_3
    (fun (a_7 a_8 : _obj) =>
      @Lean.Elab.Term.elabTerm stx t _x_1 _x_1 a a_1 a_2 a_3 a_4 a_5 a_8)
    fun (a a_7 : _obj) => EStateM.Result.error _neutral _neutral _neutral a a_7

the second case could be replaced by fun _ _ => _x_3 (but only after erasure), saving us from generating reset-reuse code. Funnily enough, in the fast path of reset-reuse this is already the produced code since it's clever enough not to re-set any fields when reusing _x_3. Also, cesimp contains an optimization in the other direction, so the new optimization should happen somewhere in between these two phases.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.