Skip to content

fix: preserve @[implicit_reducible] for WF-recursive definitions#12776

Merged
nomeata merged 2 commits intomasterfrom
copilot/fix-wfrec-instance-reproducible
Mar 3, 2026
Merged

fix: preserve @[implicit_reducible] for WF-recursive definitions#12776
nomeata merged 2 commits intomasterfrom
copilot/fix-wfrec-instance-reproducible

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 3, 2026

This PR fixes @[implicit_reducible] on well-founded recursive definitions.

addPreDefAttributes sets WF-recursive definitions as @[irreducible] by default, skipping this only when the user explicitly wrote @[reducible] or @[semireducible]. It was missing @[instance_reducible] and @[implicit_reducible], causing those attributes to be silently overridden.

Add instance_reducible and implicit_reducible to the check in src/Lean/Elab/PreDefinition/Mutual.lean that guards against overriding user-specified reducibility attributes, and add regression tests in tests/elab/wfirred.lean.

Example

-- Before fix: printed @[irreducible] def f : List Nat → Nat
-- After fix:  printed @[implicit_reducible] def f : List Nat → Nat
@[instance_reducible] def f : ∀ _l : List Nat, Nat
  | [] => 0
  | [_x] => 1
  | x :: y :: l => if h : x = y then f (x :: l) else f l + 2
termination_by l => sizeOf l

#print sig f

Fixes #12775

Co-authored-by: nomeata <148037+nomeata@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix reducibility special handling in wfrec for instance_reproducible Fix @[instance_reducible] not being preserved for WF-recursive definitions Mar 3, 2026
@nomeata
Copy link
Copy Markdown
Collaborator

nomeata commented Mar 3, 2026

@copilot looks good. Please reformat PR title and description according to the commit convention.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 3, 2026

@copilot looks good. Please reformat PR title and description according to the commit convention.

Updated the PR description to follow the commit convention. The PR title should be updated to: fix: preserve \@[instance_reducible]` for WF-recursive definitions`

Copilot AI changed the title Fix @[instance_reducible] not being preserved for WF-recursive definitions fix: preserve @[instance_reducible] for WF-recursive definitions Mar 3, 2026
@nomeata nomeata marked this pull request as ready for review March 3, 2026 16:00
@nomeata nomeata enabled auto-merge March 3, 2026 16:00
@Rob23oba
Copy link
Copy Markdown
Contributor

Rob23oba commented Mar 3, 2026

The new preferred name is @[implicit_reducible] so maybe use that instead in the title (also link #12775)

@nomeata nomeata changed the title fix: preserve @[instance_reducible] for WF-recursive definitions fix: preserve @[implicit_reducible] for WF-recursive definitions Mar 3, 2026
@nomeata nomeata added the changelog-language Language features and metaprograms label Mar 3, 2026
@nomeata nomeata added this pull request to the merge queue Mar 3, 2026
Merged via the queue into master with commit 73640d3 Mar 3, 2026
31 of 39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-language Language features and metaprograms

Projects

None yet

Development

Successfully merging this pull request may close these issues.

reducibility special handling in wfrec does not know about instance_reproducible

3 participants