feat: flesh out def_wanted / ❰…❱ references (universes, transitive deps, transparency)#1861
Open
kim-em wants to merge 1 commit into
Open
feat: flesh out def_wanted / ❰…❱ references (universes, transitive deps, transparency)#1861kim-em wants to merge 1 commit into
kim-em wants to merge 1 commit into
Conversation
This was referenced Jun 18, 2026
Collaborator
Author
|
In draft mode while I sort out some performance issues. |
f19157c to
d807f9e
Compare
Collaborator
Author
|
Performance issues sorted — ready for review. The slowdown was super-exponential binder growth down a chain of |
This consolidates several related improvements to the `theorem_wanted` / `def_wanted` / `instance_wanted` machinery (superseding the separate PRs #1858 and #1859, which touch the same file and build on one another). * **Concrete universes.** A `❰foo❱` reference to a universe-polymorphic wanted now resolves at whatever universe the use site picks, including a concrete one (`❰foo❱ ℚ`). The generated binder spelled `foo`'s universe parameters as named levels, which auto-bound to rigid parameters of the referrer; they are now rewritten to level holes. (Filippo Nuccio's first report.) * **Transitive dependencies.** Referencing a wanted that carries its own `❰…❱` dependencies surfaces those as binders on the referring declaration and threads them through, instead of re-quantifying them as unsolvable implicits. (Filippo Nuccio's second report.) * **Transparent (derived) `def_wanted`.** A `def_wanted` *with a body* is now emitted as a genuine `@[reducible]` definition wrapped in `DerivedWanted` (which carries the value), rather than an opaque `DefWanted` placeholder. `❰foo❱` then inlines it, so it is definitionally equal to its body — letting honest accessors and derived data be built on top of opaque holes (e.g. projecting a field of a bundled wanted, with the projection reducing downstream). The wrapper keeps the declaration from being used directly as a value of its type; only `❰…❱` accesses it. The leaves it abstracts over remain opaque `DefWanted`/`ProofWanted` placeholders, so no `axiom`/`sorry` is introduced. * **`instance_wanted` is included on use.** An ambient `instance_wanted` is now bound on a later wanted declaration only when that declaration actually uses it (determined by elaborating the statement/body and keeping the binders the result mentions, transitively — like `variable [inst]`), rather than unconditionally on every subsequent wanted. This removes irrelevant binders and, with the transitive-dependency surfacing now also flattening class-valued deps, avoids the super-exponential binder growth a chain of `instance_wanted`s previously caused — which had made `def_wanted` unusable for a specification carrying several wanted instances (e.g. a group scheme that is at once proper, smooth, and geometrically irreducible). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
d807f9e to
1b9db29
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fleshes out the
theorem_wanted/def_wanted/instance_wantedmachinery, superseding #1858 and #1859 (which touch the same file and build on each other).❰foo❱references to a universe-polymorphic wanted now resolve at concrete universes, not just a shared universe variable (Filippo Nuccio's first report).❰…❱dependencies surfaces them on the referrer, instead of leaving them as unsolvable implicits (Filippo Nuccio's second report).def_wantedwith a body becomes a transparent@[reducible]definition (wrapped inDerivedWanted), so❰foo❱is definitionally its body — letting you build honest accessors over opaque holes. The wrapper keeps it from being used directly as a value of its type, and noaxiom/sorryis introduced.instance_wantedis now included on use (likevariable [inst]): a later declaration carries an instance binder only when it actually needs it, rather than carrying every prior instance unconditionally. The latter grew super-exponentially down a file, makingdef_wantedunusable for a specification with several wanted instances.🤖 Prepared with Claude Code