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

dsimp simplifies too much #5755

Closed
3 tasks done
hargoniX opened this issue Oct 17, 2024 · 0 comments · Fixed by #6397
Closed
3 tasks done

dsimp simplifies too much #5755

hargoniX opened this issue Oct 17, 2024 · 0 comments · Fixed by #6397
Labels
bug Something isn't working P-medium We may work on this issue if we find the time

Comments

@hargoniX
Copy link
Contributor

Prerequisites

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

Description

Consider:

inductive C : Type where
| C1 (b     : Bool) : C
| C2 (c1 c2 : C)    : C
deriving Inhabited

open C

def id1 (b : Bool) : C := C1 b

def id2 (c : C) : C :=
  match c with
  | C1 b     => id1 b
  | C2 c1 c2 => C2 (id2 c1) (id2 c2)

theorem id2_is_idempotent : id2 (id2 c) ≠ id2 c :=
  match c with
  | C1 b  =>  by
    dsimp only [id2]
    -- HERE , which implies that id2 (id1 b) --> id1 b happened at some point
    sorry
  | C2 _ _ => by
    sorry

At "HERE" the goal is id1 b ≠ id1 b so dsimp did a id2 (id1 b) --> id1 b rewrite at some
point (as confirmed by trace.Meta.Tactic.simp.rewrite), this happens despite dsimp only
being instructed to unfold id2, not id1.

Expected behavior: id2 (id1 b) should not be rewritten to id1, this breaks abstraction without the user intending so.
Actual behavior: id2 (id1 b) get's rewritten to id1 b

Versions

"4.12.0-nightly-2024-10-17"

Impact

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

@hargoniX hargoniX added the bug Something isn't working label Oct 17, 2024
@leanprover-bot leanprover-bot added the P-medium We may work on this issue if we find the time label Oct 18, 2024
leodemoura added a commit that referenced this issue Dec 16, 2024
This PR ensures that `simp` and `dsimp` do not unfold definitions that are
not intended to be unfolded by the user. See issue #5755 for an
example affected by this issue.

Closes #5755
github-merge-queue bot pushed a commit that referenced this issue Dec 21, 2024
This PR ensures that `simp` and `dsimp` do not unfold definitions that
are not intended to be unfolded by the user. See issue #5755 for an
example affected by this issue.

Closes #5755

---------

Co-authored-by: Kim Morrison <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P-medium We may work on this issue if we find the time
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants