Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
3 tasks done
sgouezel opened this issue Jan 15, 2025 · 3 comments
Open
3 tasks done

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

sgouezel opened this issue Jan 15, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@sgouezel
Copy link

sgouezel commented Jan 15, 2025

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.

@sgouezel sgouezel added the bug Something isn't working label Jan 15, 2025
@nomeata
Copy link
Collaborator

nomeata commented Jan 15, 2025

Thanks for the report. So the issue is just™ that the simp argument set suggested by simp? is too large, but otherwise this works as expected? So the impact of this bug is on the low side, or am I missing something?

@sgouezel
Copy link
Author

Yes, it's "just" that simp? is suggesting a simpset which is too large. It breaks proofs, though, by unfolding too much if you don't realize what is going on and fix the simpset. Not a deal breaker, but a minor inconvenience for expert users, and can be confusing for newcomers.

@nomeata
Copy link
Collaborator

nomeata commented Jan 15, 2025

Ah, I see: for a non-terminal simp this is more than just a small nuisance. Got it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants