leanprover / leanprover/lean4

deriving `DecidableEq` fails with failure of dependent elimination

Open
#7,580 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug P-low
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

Consider:

inductive BVExpr : Nat → Type where
  | append (lhs : BVExpr l) (rhs : BVExpr r) : BVExpr (l + r)
  deriving DecidableEq

This errors out with:

tactic 'cases' failed, nested error:
dependent elimination failed, failed to solve equation
  l✝¹.add r✝¹ = l✝.add r✝
at case BVExpr.append after processing
  _, (BVExpr.append _ _ _ _), _
the dependent pattern matcher can solve the following kinds of equations
- <var> = <term> and <term> = <var>
- <term> = <term> where the terms are definitionally equal
- <constructor> = <constructor>, examples: List.cons x xs = List.cons y ys, and List.cons x xs = List.nil

I would love this to work but also to at least throw a nice error message.

Context

Work on bv_decide.

Steps to Reproduce
  1. Copy code
  2. Boom

Expected behavior: The instance should be synthesized or at least a good error be thrown if it isn't possible.

Actual behavior: Incomprehensible error message to users that aren't aware of the internals.

Versions

Lean 4.19.0-nightly-2025-03-19
Target: x86_64-unknown-linux-gnu

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 reproducing the minimal BVExpr example with deriving DecidableEq on the specified Lean nightly release, then inspect the dependent pattern-matching and deriving paths involved in the reported failure. Done means either the DecidableEq instance is synthesized for this case or the failure is replaced with an understandable diagnostic explaining the limitation.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.