Skip to content

restateOne: bind the declaration's universe parameters - #17

Merged
chris-dare-dev merged 1 commit into
mainfrom
agent/restate-universe-polymorphic
Aug 19, 2026
Merged

chris-dare-dev merged 1 commit into
mainfrom
agent/restate-universe-polymorphic

Conversation

@chris-dare-dev

Copy link
Copy Markdown
Owner

The first real declaration ever put through restate came back:

not_checkable | elaboration threw: unknown universe level `u_2`

A universe-polymorphic statement mentions its level parameters by name, and elabTerm resolves those against Term.Context.levelNames — empty for a string parsed out of a review. So every polymorphic statement was unverifiable, and the failure presented as a tooling error on a statement that had not changed: the review silently could not be carried forward, which is the precise outcome restate exists to prevent.

The fix

Bind ci.levelParams around the elaboration — from the declaration, never from the statement. A statement inventing a level name the declaration does not have is a different statement, and isDefEq is not the place to discover that. The Type v case pins that direction.

Why nothing caught it

restateSubject is ∀ (n : Nat), n + 0 = n. No universes at all. The fixture exercising this path since #188 never asked whether a level parameter resolves, so every assertion passed on a question that was never put. restateSubjectPoly now asks it.

And why my own verification missed it

The rendering backfilled into derived-alg-geo-lean's review was checked by elaborating

universe u_1 u_2 u_3
example : <the statement> := @...stabilityDistanceTopologyCompatible

which declares the universes. restateOne does not. I described that round-trip as "the same question restate asks". It wasn't — it was the same question with the hard part already answered.

Verified through the producer, not just the checker

a  restated                                          (monomorphic)
u  restated                                          (polymorphic, correct level)
v  not_checkable  unknown universe level `v`         (level the decl lacks)

613 passed, 1 skipped; lake build clean at 26 jobs.

The first real declaration ever put through restate came back

  not_checkable | elaboration threw: unknown universe level `u_2`

A universe-polymorphic statement mentions its level parameters by name, and
`elabTerm` resolves those against `Term.Context.levelNames` -- which is EMPTY
for a string parsed out of a review. So every polymorphic statement was
unverifiable, and the failure presented as a tooling error on a statement that
had not changed: the review silently could not be carried forward.

Bind `ci.levelParams` around the elaboration. From the DECLARATION, never from
the statement: a statement inventing a level name the declaration does not have
is a different statement, and `isDefEq` is not the place to find that out. The
`Type v` case in the tests pins that direction.

WHY NOTHING CAUGHT IT

`restateSubject` is `∀ (n : Nat), n + 0 = n`. It has no universes at all, so
the fixture exercising this path since #188 never asked whether a level
parameter resolves. Every assertion passed, on a question that was never put.
`restateSubjectPoly` is now the subject that asks it.

AND WHY MY OWN VERIFICATION MISSED IT

The rendering backfilled into derived-alg-geo-lean's review was checked by
elaborating

  universe u_1 u_2 u_3
  example : <the statement> := @...stabilityDistanceTopologyCompatible

which declares the universes. `restateOne` does not. That round-trip was
described as "the same question restate asks" and it was not the same question
-- it was the same question with the hard part already answered.

Verified through the producer, not just the checker: a polymorphic statement
returns `restated`, and one naming a level the declaration lacks still returns
`not_checkable`.

613 passed, 1 skipped; lake build clean at 26 jobs.

Refs chris-dare-dev/derived-alg-geo-lean#646
@chris-dare-dev
chris-dare-dev force-pushed the agent/restate-universe-polymorphic branch from 839c409 to f6f5694 Compare August 19, 2026 18:41
@chris-dare-dev
chris-dare-dev merged commit 271bf44 into main Aug 19, 2026
5 checks passed
@chris-dare-dev
chris-dare-dev deleted the agent/restate-universe-polymorphic branch August 22, 2026 15:05
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