subtype: generalize over section-declared free types at section close#1002
Merged
subtype: generalize over section-declared free types at section close#1002
Conversation
oskgo
approved these changes
May 8, 2026
Contributor
oskgo
left a comment
There was a problem hiding this comment.
Looks like this handles all the edge cases I had found. Awesome!
I think there were some theories where I was using an inlined Subtype or Quotient construction because of this. I need to get around to migrating those now.
Member
|
Be careful that the "update" button creates a merge commit by default. You need to open the drop-down and select "Update by rebase" |
Member
Author
|
Yes. I only have my phone. So not hesitate to revert the merge and rebase. (The CI will forbid merging it anyway) |
[subtype X = { x : T | P x }] declared inside [section. declare type
c. ...] previously stayed monomorphic at section close. The cloned
auto-axioms ([insubN], [insubT], [valP], [valK]) and the [val] / [insub]
operators correctly gained a [c] tparam, but [X] itself didn't — the
result was an inconsistent state where the operations were polymorphic
over [c] but returned a single shared [X] type for every instantiation,
a soundness gap flagged by [FIXME:SUBTYPE] at [add_subtype].
This patch threads the carrier and predicate through the subtype's
[tydecl] so [tydecl_fv] picks up their dependency on section-declared
free types and the existing [generalize_tydecl] machinery adds the
right tparams at close.
Tests in [tests/subtype-section-generalize.ec] cover three cases:
1. carrier mentions a section-declared free type — subtype is unary.
2. predicate mentions a section-declared free type (carrier doesn't) —
same outcome via fv collected from the predicate.
3. nested sections, subtype declared in the inner one, depending on
free types from both levels — subtype is binary after both closes.
Each test instantiates [val] and [valP] at two distinct carriers in a
single lemma; would fail to type-check if the cloned type or axiom
had stayed monomorphic.
a5296d9 to
4bb149e
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.
[subtype X = { x : T | P x }] declared inside [section. declare type
c. ...] previously stayed monomorphic at section close. The cloned
auto-axioms ([insubN], [insubT], [valP], [valK]) and the [val] / [insub]
operators correctly gained a [c] tparam, but [X] itself didn't — the
result was an inconsistent state where the operations were polymorphic
over [c] but returned a single shared [X] type for every instantiation,
a soundness gap flagged by [FIXME:SUBTYPE] at [add_subtype].
This patch threads the carrier and predicate through the subtype's
[tydecl] so [tydecl_fv] picks up their dependency on section-declared
free types and the existing [generalize_tydecl] machinery adds the
right tparams at close.
Tests in [tests/subtype-section-generalize.ec] cover three cases:
same outcome via fv collected from the predicate.
free types from both levels — subtype is binary after both closes.
Each test instantiates [val] and [valP] at two distinct carriers in a
single lemma; would fail to type-check if the cloned type or axiom
had stayed monomorphic.
Closes #1001