Skip to content

simp? unfolds more let definitions than a bare simp call #6655

@sgouezel

Description

@sgouezel

Prerequisites

Please put an X between the brackets as you perform the following steps:

Description

In some situations, simp? creates a simp only call wrongly unfolding let variables.

Context

Zulip discussion at https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/simp.3F.20adding.20let.20reduction/near/493985664

Steps to Reproduce

Run the following snippet:

theorem foo {α : Type} (c : α → α) (x : α) : c x = x := by
  let d := c
  let e := d
  change e x = x
  simp? [e]
  sorry

Expected behavior:
simp? [e] should suggest simp only [e]

Actual behavior:
simp? [e] suggests simp only [e, d], pulling in d while this is not used in the simp call

Another example of misbehavior (probably due to the same bug) is

theorem foo {α : Type} (c : α → α) (x : α) : c x = x := by
  let d := c
  change d x = x
  -- simp [d]
  have : x = x := by
    simp?
  sorry

where the simp? call unfolds to simp only, unless you uncomment simp [d] two lines above: then simp? unfolds to simp only [d].

Versions

Lean 4.16.0-nightly-2025-01-15

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P-mediumWe may work on this issue if we find the timebugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions