leanprover / leanprover/lean4

`simp` unable to rewrite seemingly identical terms

Open
#10,559 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

P-low
Dominant language
Lean
Stars
9.2k
Forks
990
Avg merge
1d 17h
Merged PRs (30d)
175

Description

Prerequisites

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

Description

Hello, I'm new to Lean so I'm not sure whether this is an expected behavior:

def f.{u, v} {T : Type u} {U : Type v} (x : T) (y : U) : T := z
  where z := x

theorem test (h₁ : f x y = 0) : true := by
  generalize h₂ : f.z x = w
  simp only [f] at h₁
  simp only [h₁] at h₂ -- This fails
  -- This works: rw [h₁] at h₂
  sorry

At simp only [h₁] at h₂, the proof state is

x : ℕ
U : Type u_1
y : U
h₁ : f.z x = 0
w : ℕ
h₂ : f.z x = w
⊢ true = true

So the simp should work there right?
I suspect it's because of the definition of f.z somehow captures the unused universe v.
This could also be related to #4613

With set_option trace.Meta.Tactic.simp true enabled, I also got this confusing trace

[Meta.Tactic.simp.unify] h₁:1000, failed to unify
      f.z x
    with
      f.z x
Related Issues

Potentially related to #4613 but not sure.

Versions

I'm using Lean version 4.23.0-rc2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the minimal reproducer from the issue against the latest nightly release, then inspect the simp trace produced by set_option trace.Meta.Tactic.simp true. Investigate why simp only [h₁] at h₂ fails despite the displayed terms matching, and consider the connection to issue #4613. Done means the reproducer has an explained and tested outcome.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.