leanprover / leanprover/lean4

unexpected "dependent match elimination failed"

Open
#6,416 4 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P-medium
Dominant language
Lean
Stars
9.2k
Forks
990
Avg merge
1d 17h
Merged PRs (30d)
175

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the minimal MyOrder and antisymmetric reproducer against the latest Lean nightly, focusing on the equation compiler's dependent match elimination. Read the linked Zulip discussion for context; done means the reported pattern no longer produces the confusing inaccessible-pattern error and behaves as expected for the six proof holes.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.