leanprover / leanprover/lean4

failed to generate equality theorems for `match` expression `ctor_C'.match_1`

Open
#7,513 0 comments 0 reactions 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

Hey 👋

Prerequisites

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

Similar issue:

Description

Here is the MRE.

This code

structure CellularAutomata where
  Q: Type u
  [inv_decidable_q: DecidableEq Q] -- comment this out

structure FCellularAutomata extends CellularAutomata where
  --[inv_decidable_q: DecidableEq Q] -- ...and uncomment this, then it works
  state_accepts: Q -> Nat

def ctor_C': FCellularAutomata :=
  {
    Q := Bool,
    state_accepts
      | true  => 1+1
      | false => 2+2
  }

def FCellularAutomata.d1 (C: FCellularAutomata): Bool := true

theorem t: ctor_C'.d1 = true := by
  unfold ctor_C'
  simp -- this fails with "failed to generate equality theorems for `match` expression `ctor_C'.match_1`"
  sorry

fails with

lean-nightly.lean:19:34
Tactic state
1 goal
⊢ ctor_C'.d1 = true
Messages (1)
lean-nightly.lean:19:32
failed to generate equality theorems for `match` expression `ctor_C'.match_1`
_x_1 : DecidableEq Bool
_x_2 : (motive : (CellularAutomata.mk Bool).Q → Sort u_1) →
  (Unit → motive true) → (Unit → motive false) → (x : (CellularAutomata.mk Bool).Q) → motive x
motive : (CellularAutomata.mk Bool).Q → Sort u_1
h_1 : Unit → motive true
h_2 : Unit → motive false
⊢ _x_2 motive h_1 h_2 true = h_1 ()

Because this example works, I assume this is a bug in how the type class is referenced.

Versions

lean-nightly.lean:6:34

Impact

So far I didn't find a workaround that unblocks me. But I'm only doing this for fun, so no urgency.

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 linked minimal reproducible example against the Lean nightly release and inspect the simp step after unfold ctor_C'. Trace equality-theorem generation for the ctor_C'.match_1 expression, using the working comparison example to isolate the type-class difference. Done when the original theorem closes without the reported failure.

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
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.