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

unexpected "dependent match elimination failed" #6416

Open
3 tasks done
b-mehta opened this issue Dec 19, 2024 · 2 comments
Open
3 tasks done

unexpected "dependent match elimination failed" #6416

b-mehta opened this issue Dec 19, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@b-mehta
Copy link
Contributor

b-mehta commented Dec 19, 2024

Prerequisites

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

Description

The equation compiler gives error "dependent match elimination failed" when I expect the match to succeed

Context

inductive MyOrder : Nat × Nat × Nat → Nat × Nat × Nat → Prop
  | twice {x y n u v m : Nat} : m + 2 ≤ n → MyOrder (x, y, n) (u, v, m)
  | within {x y u v m : Nat} : x ≤ u → y ≤ v → MyOrder (x, y, m) (u, v, m)
  | next_min {x y u v m : Nat} : min x y + 1 ≤ min u v → MyOrder (x, y, m + 1) (u, v, m)

theorem antisymmetric : ∀ {x y : Nat × Nat × Nat}, MyOrder x y → MyOrder y x → x = y
  | _, _, .twice _, .twice _ => _
  | _, _, .twice _, .within _ _ => _
  | _, _, .twice _, .next_min _ => _
  | _, _, .within _ _, .twice _ => _
  | _, _, .within _ _, .within _ _ => _
  | _, _, .next_min _, .twice _ => _

Steps to Reproduce

  1. Code as above

Expected behavior: Code gives errors on the six right-hand-sides to fill in the six proofs.

Actual behavior: The line | _, _, .twice _, .within _ _ => _ gives confusing error

dependent match elimination failed, inaccessible pattern found
  .(n✝)
constructor expected

Versions

Lean 4.15.0-rc1
Target: x86_64-unknown-linux-gnu

Using live.lean-lang.org on Lean nightly.

Additional Information

Discussion here: https://leanprover.zulipchat.com/#narrow/channel/270676-lean4/topic/dependent.20match.20elimination.20failed

Impact

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

@b-mehta b-mehta added the bug Something isn't working label Dec 19, 2024
@kmill
Copy link
Collaborator

kmill commented Dec 19, 2024

A bit more context: we found the following two fixes:

theorem antisymmetric : ∀ {x y : Nat × Nat × Nat}, MyOrder x y → MyOrder y x → x = y
  | _, _, .twice _, .twice _ => _
  | _, p, .twice _, .within _ _ => _
  | _, _, .twice _, .next_min _ => _
  | _, _, .within _ _, .twice _ => _
  | _, _, .within _ _, .within _ _ => _
  | _, _, .next_min _, .twice _ => _

and

theorem antisymmetric : ∀ {x y : Nat × Nat × Nat}, MyOrder x y → MyOrder y x → x = y
  | _, _, .twice _, .twice _ => _
  | _, (_,_,_), .twice _, .within _ _ => _
  | _, _, .twice _, .next_min _ => _
  | _, _, .within _ _, .twice _ => _
  | _, _, .within _ _, .within _ _ => _
  | _, _, .next_min _, .twice _ => _

This was by trial-and-error. (I also tried to write the complete patterns with all the necessary inaccessible patterns manually, but I didn't succeed.)

@cppio
Copy link
Contributor

cppio commented Dec 20, 2024

Another example that gives the same error:

inductive Pred : Nat → Nat → Type
  | here : Pred n.succ n
  | there : Pred n m → Pred n.succ m.succ

inductive HasPred n
  | mk (p : Pred n m)

def fails : HasPred (.succ n) → Unit
  | .mk .here => ()
  | .mk (.there _) => ()

def works : HasPred (.succ n) → Unit
  | .mk .here => ()
  | .mk (m := _) (.there _) => ()

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

3 participants