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 can't rewrite definitions backwards #2431

Closed
1 task done
alreadydone opened this issue Aug 17, 2023 · 3 comments
Closed
1 task done

simp can't rewrite definitions backwards #2431

alreadydone opened this issue Aug 17, 2023 · 3 comments
Labels
closing soon This issue will be closed soon (<1 month) as it is missing essential features. invalid This doesn't seem right

Comments

@alreadydone
Copy link
Contributor

alreadydone commented Aug 17, 2023

Prerequisites

  • Put an X between the brackets on this line if you have done all of the following:
    • Checked that your issue isn't already filed.
    • Reduced the issue to a self-contained, reproducible test case.

Description

rw can rewrite backwards using the equational lemma associated to a definition, but simp, simp_rw, simp only cannot.

Steps to Reproduce

def double (n : ℕ) : ℕ := n + n

example (n : ℕ) : double n = n + n := by
  simp_rw [← double]

Expected behavior: No goals

rw [← double], simp_rw [double], rw [double] exhibit this correct behavior.

Actual behavior:

invalid '←' modifier, 'double' is a declaration name to be unfolded

simp only [← double] and simp [← double] exhibit the same bad behavior.

Reproduces how often: every time

Versions

Lean (version 4.0.0-nightly-2023-08-15, commit b5a7367, Release)
MacOS Ventura 13.5

@semorrison semorrison added invalid This doesn't seem right closing soon This issue will be closed soon (<1 month) as it is missing essential features. labels Aug 27, 2023
@semorrison
Copy link
Collaborator

This is the intended behaviour. simp and rw simply handle "unfolding definitions" differently, and it is not intended that you can "refold" a definition using simp.

@alreadydone
Copy link
Contributor Author

alreadydone commented Aug 27, 2023

The irreplaceable use case of simp_rw is to rewrite under a binder, which rw can't do. (It's convenient that it can rewrite multiple times, but that's just more cumbersome with rw.) What should I do to refold a definition under a binder? It's infeasible to manually write a equational lemma for every definition, right?

@semorrison
Copy link
Collaborator

My guess is this happens infrequently enough (I don't think I've ever wanted to do this!) that writing an equational lemma on the spot, to use in simp_rw is the right solution. But this discussion should happen on zulip, I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closing soon This issue will be closed soon (<1 month) as it is missing essential features. invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants