leanprover / leanprover/lean4

failed to generate equality theorem for `match` expression with array patterns

Open
#9,846 2 comments 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

A sub-issue of https://github.com/leanprover/lean4/issues/9713 is that match statements with array patterns fail to produce equations:

def testMatch : Array α → Unit
  | #[a] => ()
  | _ => ()

/--
error: Failed to realize constant testMatch.match_1.eq_1:
  failed to generate equality theorems for `match` expression `testMatch.match_1`
  case isTrue
  α✝ : Type u_1
  motive✝ : Array α✝ → Sort u_2
  x✝¹ : Array α✝
  h_1✝ : (a : α✝) → motive✝ #[a]
  h_2✝ : (x : Array α✝) → motive✝ x
  x✝ : ∀ (a : α✝), x✝¹ = #[a] → False
  h✝ : x✝¹.size = 1
  ⊢ (⋯ ▸ fun h => ⋯ ▸ h_1✝ (x✝¹.getLit 0 ⋯ ⋯)) ⋯ = h_2✝ x✝¹
---
error: Unknown constant `testMatch.match_1.eq_1`
-/
#guard_msgs in
#print testMatch.match_1.eq_1
Version

Lean 4.23.0-nightly-2025-08-11

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 testMatch definition and its #guard_msgs/#print testMatch.match_1.eq_1 checks from the issue. Investigate the compiler path that generates equality theorems for match expressions with array patterns. Done means the equality theorem is generated and the guarded output no longer reports the failed realization or unknown constant.

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
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.