simp fails to rewrite inside Array.filterMap since respectTransparency.types (#13895): processCongrHypothesis Array.filterMap_congr failed

Open
#16,654 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
20/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Domain
compilers

Research direction

Reproduce the snippet on the failing nightly and with set_option backward.isDefEq.respectTransparency.types false, then enable trace.Meta.Tactic.simp.congr to confirm processCongrHypothesis Array.filterMap_congr failed. Read Array.filterMap_congr and the processCongrHypothesis/withSimpMetaConfig path where isDefEq runs at implicit transparency after #13895. Check the dependent stop := as.size trigger; done means the example closes with simp and the simp tests pass.

Written by the indexing model from the issue text.

Description

Prerequisites
  • Checked that the issue exists in the latest version of Lean 4 (nightly-2026-11-20).
Description

Since v4.33.0, simp no longer rewrites a subterm inside Array.filterMap in the example below and leaves the goal unsolved. It works on v4.32.2. It also works on newer versions with set_option backward.isDefEq.respectTransparency.types false. The regression is still present on v4.37.0-rc1 and on nightly-2026-11-20 (commit 82bff16a3463).

Steps to Reproduce
inductive V where | int (n : Int) | bor (l : Nat) (c : V)
def entry? : V → Option (Option (Nat × V))
  | .bor l c => some (some (l, c))
  | _ => none
def coll (f : V → Option α) (v : V) : Array α :=
  match f v with
  | some x => #[x]
  | none => match v with
    | .bor _ c => coll f c
    | _ => #[]
example (n : Int) : (coll entry? (.int n)).filterMap id = #[] := by simp [coll, entry?]

Expected behavior: the goal is closed, as on v4.32.2.

Actual behavior: the goal is left unsolved:

⊢ Array.filterMap id (coll entry? (V.int n)) 0 0 = #[]

With set_option trace.Meta.Tactic.simp.congr true, the trace shows:

processCongrHypothesis Array.filterMap_congr failed
Versions

Fails: v4.33.1, v4.34.1, v4.35.0, v4.36.0, v4.37.0-rc1, 4.38.0-nightly-2026-11-20 (commit 82bff16a3463).
Passes: v4.32.2, and every version above with set_option backward.isDefEq.respectTransparency.types false.

Analysis

Array.filterMap_congr is unchanged between v4.32.2 and v4.36.0. The equation lemmas of coll do fire (coll.eq_2, entry?.match_1.eq_2 show in trace.Meta.Tactic.simp.rewrite), but the rewritten array is not accepted back into the filterMap congruence. We suspect the isDefEq m val check in processCongrHypothesis (withSimpMetaConfig, now at implicit transparency for metavariable types after #13895) rejects the instantiation. A plausible trigger is the default argument stop := as.size, whose type depends on the array being rewritten: with an explicit non-dependent stop the behaviour differs. We have not confirmed this.

Smaller variants that pass on all versions: a non-recursive coll, a coll without the inner match, and if instead of match. The failure seems to need a structurally recursive definition whose equation lemma has a nested match.

Impact

About 30 simp proofs in one project hit this. The workaround, unfold before simp plus per-proof cleanup, changes the proof structure, so we would prefer a fix in simp.


Filed by Claude Code (AI agent) on behalf of the reporter.

Dominant language
Lean
Stars
10.3k
Forks
1.1k
Avg merge
19h 8m
Merged PRs (30d)
421

Getting set up

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.

More from leanprover/lean4

All issues in leanprover/lean4

Similar issues

More Compilers issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.