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

RFC: simp attribute to accept ← modifier #5828

Closed
nomeata opened this issue Oct 24, 2024 · 0 comments · Fixed by #5870
Closed

RFC: simp attribute to accept ← modifier #5828

nomeata opened this issue Oct 24, 2024 · 0 comments · Fixed by #5870
Labels
P-medium We may work on this issue if we find the time RFC accepted RFC is waiting for a corresponding PR (external or internal) RFC Request for comments

Comments

@nomeata
Copy link
Contributor

nomeata commented Oct 24, 2024

Proposal

When invoking the simp tactic, it is possible to write simp [foo, ↓bar, ←baz], but the attribute version of extending the simpset only supports

attribute [simp] foo
attribute [simp ↓] bar

but not

attribute [simp ←] bar

to add the inverse of a rewrite rule to the simp set.

Adding support for this presumably amounts to extending the syntax in Lean.Parser.Attr.simp and then setting the inv parameter to Lean.Meta.addSimpTheorem in Lean.Meta.mkSimpAttr.

I assume there is no reason this isn’t already the case beyond “nobody asked for it yet”?

Context

The alternative rsimp simpset that’s part of the plan in #5806 benefits from being able to write

attribute [simp ←] Nat.add_eq

instead of

@[rsimp] def Nat.add_eq_symm := fun a b => (@Nat.add_eq a b).symm

Impact

Add 👍 to issues you consider important. If others benefit from the changes in this proposal being added, please ask them to add 👍 to it.

@nomeata nomeata added the RFC Request for comments label Oct 24, 2024
@Kha Kha added RFC accepted RFC is waiting for a corresponding PR (external or internal) P-medium We may work on this issue if we find the time labels Oct 25, 2024
github-merge-queue bot pushed a commit that referenced this issue Oct 29, 2024
This adds the ability to add the converse direction of a rewrite rule
not just in simp arguments `simp [← thm]`, but also as a global
attribute

```lean
attribute [simp ←] thm
```

This fixes #5828.

This can be undone with `attribute [-simp]`, although note that
`[-simp]` wins and cannot be undone at the moment (#5868).

Like `simp [← thm]` (see #4290), this will do an implicit `attribute
[-simp] thm` if the other direction is already defined.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P-medium We may work on this issue if we find the time RFC accepted RFC is waiting for a corresponding PR (external or internal) RFC Request for comments
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants