leanprover / leanprover/lean4

`nomatch` causes "... was not added to the environment" error in `genMatchCongrEqns`

Open
#11,689 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Prerequisites
Description

When you try to generate congruence equation lemmas for a nomatch through genMatchCongrEqns or something that uses it (e.g. grind), you get the following error:

Failed to realize constant xyz.match_n.congr_eq_1:
  Lean.Meta.realizeConst: _private.module.0.xyz.match_1.congr_eq_1 was not added to the environment
Steps to Reproduce
axiom Fin.succAbove {n : Nat} (i : Fin (n + 1)) (j : Fin n) : Fin (n + 1)

@[elab_as_elim]
axiom Fin.succAboveCases.{u} {n : Nat} {α : Fin (n + 1) → Sort u} (i : Fin (n + 1)) (x : α i)
  (p : (j : Fin n) → α (i.succAbove j)) (j : Fin (n + 1)) : α j

noncomputable def newPredAbove (p i : Fin (n + 1)) (hip : i ≠ p) : Fin n :=
  p.succAboveCases nofun (fun x _ => x) i hip

/--
error: Failed to realize constant newPredAbove.match_1.congr_eq_1:
  Lean.Meta.realizeConst: _private.«external:file:///lean-nightly/lean-nightly.lean».0.newPredAbove.match_1.congr_eq_1 was not added to the environment
---
error: Unknown constant `newPredAbove.match_1.congr_eq_1`
-/
#guard_msgs in
#print newPredAbove.match_1.congr_eq_1

Expected behavior: You just get an "Unknown identifier" error and an empty array returned in the corresponding genMatchCongrEqns call.

Actual behavior: genMatchCongrEqns fails with the error message mentioned above.

Versions

Lean 4.28.0-nightly-2025-12-15

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 reproducer and inspect the genMatchCongrEqns entry point, including the path used by grind. Compare the handling of a missing nomatch congruence equation with the expected unknown-identifier result; done means no realization failure and an empty result from genMatchCongrEqns.

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
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.