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

rcases can't use rfl on 0 = a in some circumstances. #62

Open
kim-em opened this issue Dec 8, 2022 · 5 comments
Open

rcases can't use rfl on 0 = a in some circumstances. #62

kim-em opened this issue Dec 8, 2022 · 5 comments

Comments

@kim-em
Copy link
Collaborator

kim-em commented Dec 8, 2022

import Std.Tactic.RCases

variable {α : Type _} [LT α] (a : α)

theorem lt_trichotomy (a b : α) : a < b ∨ a = b ∨ b < a := sorry

example : True := by
  rcases lt_trichotomy 0 a with (ha | rfl | ha)

Fails with
tactic 'subst' failed, 'a' occurs at 0

This breaks a proof from Algebra.Order.Ring.Defs, leanprover-community/mathlib4#905.

@digama0
Copy link
Member

digama0 commented Dec 8, 2022

This should be fixed in subst; both versions of rcases are just calling the subst tactic so probably you can make a repro that uses only that.

@kim-em
Copy link
Collaborator Author

kim-em commented Apr 3, 2023

I guess this is a repro:

theorem foo [OfNat α 0] (a : α) : a = 0 := sorry

example (a : α) [OfNat α 0] : True := by
  let t := @foo _ ?_ a
  subst t -- fails with `'a' occurs at 0`
  
example (a : α) [OfNat α 0] : True := by
  let t := foo a
  subst t  

@kim-em
Copy link
Collaborator Author

kim-em commented Apr 3, 2023

The problem here is that substCore calls exprDependsOn, which is conservative, and looks for any metavariables which could possibly result in a dependency.

@kim-em
Copy link
Collaborator Author

kim-em commented Apr 3, 2023

@kim-em
Copy link
Collaborator Author

kim-em commented Apr 3, 2023

Per mathlib porting meeting discussion, it seems rcases should be synthesizing instances here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants