lean4-htt/tests/lean/run/cbv_proj_arg_bug.lean
Wojciech Różowski 2ce55ba460
fix: catch exceptions in cbv rewrite simprocs to handle projections (#12562)
This PR fixes #12554 where the `cbv` tactic throws "unexpected kernel
projection term during structural definitional equality" when a rewrite
theorem's pattern contains a lambda and the expression being matched has
a `.proj` (kernel projection) at the corresponding position.

The `Sym` pattern matching infrastructure (`isDefEqMain` in
`Pattern.lean`) does not handle `.proj` expressions and can throw an
exception. Rather than presenting it as an error in `cbv`, we fail
quietly and let the `cbv` tactic try other fallback paths.

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 11:10:30 +00:00

23 lines
667 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- Regression test for https://github.com/leanprover/lean4/issues/12554
def applyFn (f : Nat → Nat) (x : Nat) : Nat := f x
@[cbv_eval] theorem applyFn_id : applyFn (fun x => x) = fun x => x := by
funext x; rfl
opaque fnPair : (Nat → Nat) × Nat
-- The `.proj` in `fnPair.1` caused pattern matching against the lambda in
-- `applyFn_id` to throw.
example : applyFn fnPair.1 42 = fnPair.1 42 := by cbv
opaque pair : Nat × Nat
def myId (x : Nat) : Nat := x
example : myId pair.1 = pair.1 := by cbv
def isZero : Nat → Bool
| 0 => true
| _ + 1 => false
example : isZero pair.1 = isZero pair.1 := by cbv
example : applyFn (fun x => x) 42 = 42 := by cbv