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

simp lemma discrimination tree keys are computed with iota := false, while simp uses iota := true #6331

Open
2 of 3 tasks
JovanGerb opened this issue Dec 6, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@JovanGerb
Copy link
Contributor

Prerequisites

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

Description

When computing the discrimination tree keys for a (global) simp lemma, the configuration is set to iota := false. However, the default configuration for simp uses iota := true. Since #6053, the setting iota := false propagates to the function Lean.Meta.unfoldDefinition?, which now causes bad discrimination tree keys to be computed when the LHS of a simp lemma contains a match expression.

Context

This was reported on Zulip.

Steps to Reproduce

Consider this minimal example:

abbrev Multiseries : List Nat → Type
  | [] => Nat
  | _ :: _ => Int

opaque maxExp (n : Nat) (ns : List Nat) (li : List (Multiseries (n :: ns))) : Nat

@[simp]
axiom bad_simp_lemma (n : Nat) (ns : List Nat) : maxExp n ns [] = 8

theorem same_lemma (n : Nat) (ns : List Nat) : maxExp n ns [] = 8 := by
  simp -- simp made no progress

theorem same_lemma' (n : Nat) (ns : List Nat) : maxExp n ns [] = 8 := by
  simp -iota -- succeeds

Expected behavior:
simp should succeed, while simp -iota should not succeed.

Actual behavior:
simp fails, and simp -iota succeeds.

Versions

4.16.0-nightly-2024-12-06

Additional Information

We can manually force the lemma to have the match expression already unfolded. This gives the correct discrimination tree keys for simp:

abbrev Multiseries : List Nat → Type
  | [] => Nat
  | _ :: _ => Int

opaque maxExp (n : Nat) (ns : List Nat) (li : List (Multiseries (n :: ns))) : Nat

@[simp]
axiom good_simp_lemma (n : Nat) (ns : List Nat) : maxExp n ns ([] : List Int) = 8

theorem same_lemma (n : Nat) (ns : List Nat) : maxExp n ns [] = 8 := by
  simp -- succeeds

theorem same_lemma' (n : Nat) (ns : List Nat) : maxExp n ns [] = 8 := by
  simp -iota -- simp made no progress

Impact

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

@JovanGerb JovanGerb added the bug Something isn't working label Dec 6, 2024
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

No branches or pull requests

1 participant