Skip to content

[Backport releases/v4.30.0] fix: make delta-derived Prop-valued instances theorems#13314

Open
github-actions[bot] wants to merge 1 commit intoreleases/v4.30.0from
backport-13304-to-releases/v4.30.0
Open

[Backport releases/v4.30.0] fix: make delta-derived Prop-valued instances theorems#13314
github-actions[bot] wants to merge 1 commit intoreleases/v4.30.0from
backport-13304-to-releases/v4.30.0

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot commented Apr 8, 2026

Backport 30dca7b from #13304.

This PR makes the delta-deriving handler create `theorem` declarations
instead of `def` declarations when the instance type is a `Prop`.
Previously, `deriving instance Nonempty for Foo` would always create a
`def`, which is inconsistent with the behavior of a handwritten
`instance` declaration.

For example, given:
```lean
def Foo (α : Type u) := List α
deriving instance Nonempty for Foo
```

Before: `@[implicit_reducible] def instNonemptyFoo ...`
After: `@[implicit_reducible] theorem instNonemptyFoo ...`

The implementation checks `isProp result.type` after constructing the
instance closure, and uses `mkThmOrUnsafeDef` for the Prop case (which
also handles the unsafe fallback correctly). The noncomputable check is
skipped for Prop-typed instances since theorems can freely reference
noncomputable constants.

Closes #13295

🤖 Prepared with Claude Code

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
(cherry picked from commit 30dca7b)
@github-actions github-actions bot requested a review from kim-em as a code owner April 8, 2026 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant