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 offset checking fails with non-canonical instances. #3836

Closed
joehendrix opened this issue Apr 5, 2024 · 0 comments · Fixed by #3838
Closed

Simp offset checking fails with non-canonical instances. #3836

joehendrix opened this issue Apr 5, 2024 · 0 comments · Fixed by #3838
Labels
bug Something isn't working

Comments

@joehendrix
Copy link
Contributor

joehendrix commented Apr 5, 2024

The logic for checking if a term is an offset seems to do a syntactic check that prevents simp rules from firing.

This appears to be a regression introduced by #3614. Prior to that, the example below succeeds, but after #3614 lean returns error: simp made no progress.

class AddCommMagma (G : Type u) extends Add G where
  /-- Addition is commutative in an commutative additive magma. -/
  protected add_comm : ∀ a b : G, a + b = b + a

instance : AddCommMagma Nat where
  add_comm := Nat.add_comm

example (n : Nat) (p : n = 3) : 1 + n = 1 + 3 := by
  rw [AddCommMagma.add_comm 1, AddCommMagma.add_comm 1]
  simp only [Nat.succ.injEq]
  exact p
@joehendrix joehendrix added the bug Something isn't working label Apr 5, 2024
github-merge-queue bot pushed a commit that referenced this issue Apr 7, 2024
This changes how Nat typeclass checks in offset terms from syntactic
equality to definitional equality with "instances" transparency.

This may have a negative performance penalty in `isOffset?`, but it
should be small in common cases since the relevant instances are small
terms.

This closes #3836
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.

1 participant