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

Match equations not allowed in simp only theorem list #4251

Closed
3 tasks done
JLimperg opened this issue May 22, 2024 · 2 comments · Fixed by #4274
Closed
3 tasks done

Match equations not allowed in simp only theorem list #4251

JLimperg opened this issue May 22, 2024 · 2 comments · Fixed by #4274
Labels
bug Something isn't working

Comments

@JLimperg
Copy link
Contributor

Prerequisites

Description

In the following example, a simp only list suggested by simp? fails:

-- works
theorem foo₁ (a : Nat) (ha : a = 37) :
    (match h : a with | 42 => by simp_all | n => n) = 37 := by
  simp? [ha]
  -- Try this: simp only [ha, Nat.reduceEqDiff, imp_self, foo₁.match_1.eq_2]

-- fails
theorem foo₂ (a : Nat) (ha : a = 37) :
    (match h : a with | 42 => by simp_all | n => n) = 37 := by
  simp only [ha, Nat.reduceEqDiff, imp_self, foo₂.match_1.eq_2]
  -- invalid field notation, type is not of the form (C ...) where C is a constant
  --   foo₂

The issue might be that on-demand generation of match equations is not triggered by simp only.

Versions

nightly-2024-05-22

Impact

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

@JLimperg JLimperg added the bug Something isn't working label May 22, 2024
@nomeata
Copy link
Collaborator

nomeata commented May 22, 2024

I think your analysis is correct. So either match equations become public API, and should take part in the lazy definition generation, or there needs to be a way to say “equations for this match” like with functions. Or both. The former is probably easier.

@leodemoura
Copy link
Member

match equational theorems are supposed to be internal and are applied even if simp only does not list them. For example, the following works as expected

theorem foo₂ (a : Nat) (ha : a = 37) :
    (match h : a with | 42 => by simp_all | n => n) = 37 := by
  simp only [ha, Nat.reduceEqDiff, imp_self]

So, we can't simply omit match equational theorems when generating the simp only command at simp?.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants