lean4-htt/tests/elab/match_expose_implicit_reducible.lean
Leonardo de Moura adc45d7c7b
feat: mark exposed match auxiliary declarations as implicit_reducible (#13281)
This PR marks any exposed (non-private) auxiliary match declaration as
`[implicit_reducible]`. This is essential when the outer declaration is
marked as `instance_reducible` — without it, reduction is blocked at the
match auxiliary. We do not inherit the attribute from the parent
declaration because match auxiliary declarations are reused across
definitions, and the reducibility setting of the parent can change
independently. This change prepares for implementing the TODO at
`ExprDefEq.lean:465`, which would otherwise cause too many failures
requiring manual `[implicit_reducible]` annotations on match
declarations whose names are not necessarily derived from the outer
function.

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-04 23:55:47 +00:00

49 lines
1.5 KiB
Text

module
public def foo : Nat → Nat
| 0 => 1
| 1 => 3
| 2 => 5
| x+3 => foo x
@[expose, implicit_reducible] public def bla : Nat → Nat
| 0 => 1
| 1 => 3
| 2 => 5
| x+3 => bla x
public abbrev boo : Nat → Nat
| 0 => 1
| 1 => 3
| 2 => 5
| _ => 7
/--
info: private def foo.match_1.{u_1} : (motive : Nat → Sort u_1) →
(x : Nat) →
(Unit → motive 0) → (Unit → motive 1) → (Unit → motive 2) → ((x : Nat) → motive x.succ.succ.succ) → motive x :=
fun motive x h_1 h_2 h_3 h_4 =>
Nat.casesOn x (h_1 ()) fun n => Nat.casesOn n (h_2 ()) fun n => Nat.casesOn n (h_3 ()) fun n => h_4 n
-/
#guard_msgs in
#print foo.match_1
/--
info: @[implicit_reducible, expose] def bla.match_1.{u_1} : (motive : Nat → Sort u_1) →
(x : Nat) →
(Unit → motive 0) → (Unit → motive 1) → (Unit → motive 2) → ((x : Nat) → motive x.succ.succ.succ) → motive x :=
fun motive x h_1 h_2 h_3 h_4 =>
Nat.casesOn x (h_1 ()) fun n => Nat.casesOn n (h_2 ()) fun n => Nat.casesOn n (h_3 ()) fun n => h_4 n
-/
#guard_msgs in
#print bla.match_1
/--
info: @[implicit_reducible, expose] def boo.match_1.{u_1} : (motive : Nat → Sort u_1) →
(x : Nat) → (Unit → motive 0) → (Unit → motive 1) → (Unit → motive 2) → ((x : Nat) → motive x) → motive x :=
fun motive x h_1 h_2 h_3 h_4 =>
dite (x = 0) (Eq.ndrec_symm (h_1 ())) fun h_1 =>
dite (x = 1) (Eq.ndrec_symm (h_2 ())) fun h_2 => dite (x = 2) (Eq.ndrec_symm (h_3 ())) fun h_3 => h_4 x
-/
#guard_msgs in
#print boo.match_1