Fix instance_reducible not being preserved for WF-recursive definitions

Co-authored-by: nomeata <148037+nomeata@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-03-03 15:48:38 +00:00
parent 134e10955a
commit c15c7f2d49
2 changed files with 27 additions and 1 deletions

View File

@@ -63,7 +63,9 @@ def addPreDefAttributes (preDefs : Array PreDefinition) : TermElabM Unit := do
a wrong setting and creates bad `defEq` equations.
-/
for preDef in preDefs do
unless preDef.modifiers.attrs.any fun a => a.name = `reducible || a.name = `semireducible do
unless preDef.modifiers.attrs.any fun a =>
a.name = `reducible || a.name = `semireducible ||
a.name = `instance_reducible || a.name = `implicit_reducible do
setIrreducibleAttribute preDef.declName
/-

View File

@@ -107,3 +107,27 @@ example : foo = bar := rfl
unseal foo bar in
example : foo = bar := rfl
/-!
Tests that reducibility attributes set by the user are preserved for WF-recursive functions.
In particular, `@[instance_reducible]` (alias for `@[implicit_reducible]`) should not be
overridden by the default `@[irreducible]` that WF recursion sets. See issue #7082.
-/
@[instance_reducible] def baz : Nat Nat Nat
| 0, m => m
| n+1, m => baz n (m + n)
termination_by n m => (n, m)
/-- info: @[implicit_reducible] def baz : Nat → Nat → Nat -/
#guard_msgs in
#print sig baz
@[implicit_reducible] def qux : Nat Nat Nat
| 0, m => m
| n+1, m => qux n (m + n)
termination_by n m => (n, m)
/-- info: @[implicit_reducible] def qux : Nat → Nat → Nat -/
#guard_msgs in
#print sig qux