Skip to content

feat: flesh out def_wanted / ❰…❱ references (universes, transitive deps, transparency)#1861

Open
kim-em wants to merge 1 commit into
mainfrom
def-wanted-transparent
Open

feat: flesh out def_wanted / ❰…❱ references (universes, transitive deps, transparency)#1861
kim-em wants to merge 1 commit into
mainfrom
def-wanted-transparent

Conversation

@kim-em

@kim-em kim-em commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

This PR fleshes out the theorem_wanted / def_wanted / instance_wanted machinery, 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).
  • Referencing a wanted that has its own ❰…❱ dependencies surfaces them on the referrer, instead of leaving them as unsolvable implicits (Filippo Nuccio's second report).
  • A def_wanted with a body becomes a transparent @[reducible] definition (wrapped in DerivedWanted), 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 no axiom/sorry is introduced.
  • instance_wanted is now included on use (like variable [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, making def_wanted unusable for a specification with several wanted instances.

🤖 Prepared with Claude Code

@github-actions github-actions Bot added the awaiting-review This PR is ready for review; the author thinks it is ready to be merged. label Jun 18, 2026
@kim-em kim-em marked this pull request as draft June 18, 2026 07:24
@kim-em

kim-em commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator Author

In draft mode while I sort out some performance issues.

@kim-em kim-em force-pushed the def-wanted-transparent branch 4 times, most recently from f19157c to d807f9e Compare June 18, 2026 13:33
@kim-em kim-em marked this pull request as ready for review June 18, 2026 13:43
@kim-em

kim-em commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator Author

Performance issues sorted — ready for review.

The slowdown was super-exponential binder growth down a chain of instance_wanteds: every later wanted unconditionally carried every prior instance, and class deps nested rather than flattening. Fixed by surfacing deps flat and making ambient inclusion on use (like variable [inst]). A Jacobian-scale def_wanted file now elaborates in ~3s, down from not terminating.

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>
@kim-em kim-em force-pushed the def-wanted-transparent branch from d807f9e to 1b9db29 Compare June 18, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-review This PR is ready for review; the author thinks it is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant