"failed to generate equational theorem" when a `match` discriminant such as `1 - a` becomes a closed term after unfolding

Aperta
#16,300 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Ambito
compilers

Direzione di ricerca

Start with the minimal reproducer in the issue and inspect src/Lean/Elab/PreDefinition/Eqns.lean, which the report identifies as the equation theorem generation code. Compare the generated proof for a closed arithmetic match discriminant with the working id 3 case, then check whether the stated hypothesis is used. Done when the equation theorem is generated and simp [f] proves f 0 = 0.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Prerequisites
  • Check that your issue is not already filed: searched for failed to generate equational theorem, equational theorem match discriminant and closed discriminant. Related: #16259 (same kind of match, but there the hypothesis is dropped from the statement), #7841, #15735, #10431.
  • Reduce the issue to a minimal, self-contained, reproducible test case. Avoid dependencies to Mathlib or Batteries.
  • Test your test case against the latest nightly release.
Description

Lean accepts this definition and states a true equation lemma for it, but cannot prove that lemma:

def f (a : Nat) : Nat :=
  match 1 - a, a with
  | n+1, 0 => n
  | _, _ => 0

#check @f.eq_1
example : f 0 = 0 := by simp [f]
Eqn.lean:6:8: error: Failed to realize constant f.eq_1:
  failed to generate equational theorem for `f`
  n : Nat
  h : 1 - 0 = n.succ
  ⊢ 0 = n
Eqn.lean:6:8: error(lean.unknownIdentifier): Unknown identifier `f.eq_1`
Eqn.lean:7:30: error: failed to generate equational theorem for `f`
...
Eqn.lean:7:24: error: `simp` made no progress

The hypothesis h : 1 - 0 = n.succ is in the goal and gives n = 0, but the proof doesn't use it. example : f 0 = 0 := rfl and by unfold f; rfl are both accepted. Unlike #16259, the generated statement here is correct; only its proof fails. 5 - a fails the same way, while match id 3, a with ... works (h.eq_1 : ∀ n, id 3 = n.succ → h 0 = n).

Expected behavior: f.eq_1 : ∀ (n : Nat), 1 - 0 = n.succ → f 0 = n is generated and simp [f] proves f 0 = 0.

Actual behavior: the errors above.

Versions
4.37.0-nightly-2026-11-05   failed to generate equational theorem
4.35.0                       failed to generate equational theorem (hypothesis named heq)
4.22.0                       (deterministic) timeout at `whnf`

These are on macOS arm64 (official toolchains via elan), and Linux x86_64 gives the same results. Since the nightly, the only change on master to src/Lean/Elab/PreDefinition/Eqns.lean is #16275, which is about over-applied matchers.

Impact

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

Found by an automated differential tester (ephyra); this report was drafted with AI assistance.

Lingua principale
Lean
Stelle
10.3k
Fork
1.1k
Merge medio
19h 8m
PR unite (30g)
421

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di leanprover/lean4

Tutte le issue di leanprover/lean4

Issue simili

Altre issue su Compilers

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.