lean4 icon indicating copy to clipboard operation
lean4 copied to clipboard

`dsimp` simplifies too much

Open hargoniX opened this issue 1 year ago • 0 comments

Prerequisites

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

  • [X] Check that your issue is not already filed: https://github.com/leanprover/lean4/issues
  • [X] Reduce the issue to a minimal, self-contained, reproducible test case. Avoid dependencies to Mathlib or Batteries.
  • [X] Test your test case against the latest nightly release, for example on https://live.lean-lang.org/#project=lean-nightly (You can also use the settings there to switch to “Lean nightly”)

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 :+1: to issues you consider important. If others are impacted by this issue, please ask them to add :+1: to it.

hargoniX avatar Oct 17 '24 18:10 hargoniX