Skip to content

Only allow universe level comparisons to fail with type-in-type#21531

Merged
coqbot-app[bot] merged 6 commits intorocq-prover:masterfrom
Yann-Leray:stricter-type-in-type
Feb 11, 2026
Merged

Only allow universe level comparisons to fail with type-in-type#21531
coqbot-app[bot] merged 6 commits intorocq-prover:masterfrom
Yann-Leray:stricter-type-in-type

Conversation

@yannl35133
Copy link
Contributor

@yannl35133 yannl35133 commented Jan 21, 2026

@coqbot-app coqbot-app bot added the needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI. label Jan 21, 2026
@yannl35133 yannl35133 added part: kernel part: universes The universe system. part: sort polymorphism The sorts subsystem of the universe system. labels Jan 21, 2026
@ppedrot
Copy link
Member

ppedrot commented Jan 21, 2026

what to do with Prop ≤ Type

I'd say this always holds.

@yannl35133
Copy link
Contributor Author

The better question would be what to do with Type ≤ Prop ?

@ppedrot
Copy link
Member

ppedrot commented Jan 21, 2026

This one should probably fail, even though that's not what we've been doing so far. Allowing this we can probably get into trouble with the rules for impredicativity, leading to SR breakage. It's not because we're inconsistent that we don't care about other good metatheoretical properties!

@mattam82
Copy link
Member

I think we should disallow Type <= Prop still in -type-in-type mode

@yannl35133
Copy link
Contributor Author

That should be what happens in this PR, and most errors in the test suite are due to this (some are due to Type ≤ SProp not holding)

@ppedrot
Copy link
Member

ppedrot commented Jan 21, 2026

I don't really care about the tests but I'm mostly concerned about the legendary type-in-type development known as UniMath. Let's @coqbot run full ci

@coqbot-app coqbot-app bot added needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI. and removed needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI. labels Jan 21, 2026
@yannl35133
Copy link
Contributor Author

Tested locally, Unimath compiles after the minor overlay (fixes a test)

@yannl35133 yannl35133 force-pushed the stricter-type-in-type branch from 11123db to 3a5105b Compare January 21, 2026 20:52
@yannl35133 yannl35133 marked this pull request as ready for review January 21, 2026 21:17
@yannl35133 yannl35133 requested review from a team as code owners January 21, 2026 21:17
@yannl35133
Copy link
Contributor Author

This was in draft because it needs discussion, but it can actually still get reviewed at the same time.

@ppedrot
Copy link
Member

ppedrot commented Jan 22, 2026

The changes seem desirable to me. There are probably a few places that are still behaving weirdly in the upper layers with type-in-type, but the kernel changes are a net improvement.

@yannl35133
Copy link
Contributor Author

I went over all calls to type_in_type in the codebase and hopefully made them all align with the new semantics. In practice, the only remaining calls are in UGraph and UState, the rest is all about printing whether the flag is set.

@yannl35133
Copy link
Contributor Author

yannl35133 commented Jan 22, 2026

  • lean-importer needs to unsafely eliminate from SProp to Type, so either a flag to reenable this or a way to allow an SProp ~> Type elimination constraint globally will be needed at some point.
  • hb_test needs fixing as well, but I don't understand the test well enough to fix it
  • 3 tests in the test-suite need fixing, not clear how to though
    • bug_20242 can be changed to stop relying on type in type
    • I don't think bug_16204 can be adapted, a universe level issue wouldn't have caused the anomaly
    • bug_4403 the issue and the test look unrelated, the test can obviously not work anymore

yannl35133 added a commit to Yann-Leray/hierarchy-builder that referenced this pull request Jan 23, 2026
@yannl35133 yannl35133 added the request: full CI Use this label when you want your next push to trigger a full CI. label Jan 23, 2026
@yannl35133 yannl35133 force-pushed the stricter-type-in-type branch from 3a5105b to 4a135b0 Compare January 23, 2026 16:09
@yannl35133 yannl35133 requested a review from a team as a code owner January 23, 2026 16:09
@coqbot-app coqbot-app bot removed request: full CI Use this label when you want your next push to trigger a full CI. needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI. labels Jan 23, 2026
@SkySkimmer
Copy link
Contributor

@JasonGross the lean importer will need some adaptation to this PR, not entirely sure how.
Essentially inductives in lean Prop with unrestricted elimination will not have it in rocq SProp with default flags if they have a constructor.
Typically I think this means either prod, which gets turned into a primitive record so it's fine, and Acc.
For Acc we currently unset universe checking which gives it unrestricted elimination, with this PR it doesn't work.

One possibility is to have a new flag in rocq to unset the problematic checking elimination, separate from universe checking.

@ppedrot suggested generating the recursor with guard checking off and a dummy unit argument, ie
Acc_rect A R P f := (fix Acc_rect (x:A) (a:Acc R x) (dummy:unit) {struct dummy} := match a with Acc_intro a' => f x a' (fun y r => Acc_rect y (a' y r) dummy) end) tt
not sure how well that would work

yannl35133 added a commit to Yann-Leray/hierarchy-builder that referenced this pull request Jan 27, 2026
yannl35133 added a commit to Yann-Leray/rocq-lean-import that referenced this pull request Feb 5, 2026
@yannl35133 yannl35133 added the request: full CI Use this label when you want your next push to trigger a full CI. label Feb 5, 2026
@yannl35133 yannl35133 force-pushed the stricter-type-in-type branch from 4a135b0 to aed195a Compare February 5, 2026 13:49
@coqbot-app coqbot-app bot removed the request: full CI Use this label when you want your next push to trigger a full CI. label Feb 5, 2026
@yannl35133
Copy link
Contributor Author

I added a typing flag for backwards compatibility of plugins (it's not accessible from the outside).
It's not entirely polished, it's especially missing indications of its inherent danger (by putting it in Internal), this is to get some feedback for now.

@yannl35133 yannl35133 added the needs: test-suite update Test case should be added to / updated in the test-suite. label Feb 5, 2026
@yannl35133 yannl35133 requested a review from ppedrot February 6, 2026 13:11

type t

val set_ignore_constraints : bool -> t -> t
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know we already don't do that with UGraph, but I think this is an API defect: this function should be one-off, i.e. of type t -> t so that there is no way to go back to a state where we check constraints again. After setting it all hell breaks loose and invariants are obliterated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, should have turned my tongue seven times in my mouth: we do want to be able to set the flag locally, so no, the API is fine. That said I have no idea what it means in the semantics.

Copy link
Contributor Author

@yannl35133 yannl35133 Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't see it be worse than how type-in-type currently behaves, which is the best we can hope for.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤷

@yannl35133 yannl35133 assigned yannl35133 and unassigned yannl35133 Feb 10, 2026
@coqbot-app coqbot-app bot added the needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI. label Feb 10, 2026
@yannl35133 yannl35133 removed the needs: test-suite update Test case should be added to / updated in the test-suite. label Feb 10, 2026
@ppedrot
Copy link
Member

ppedrot commented Feb 10, 2026

@coqbot run full ci

@coqbot-app coqbot-app bot removed the needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI. label Feb 10, 2026
@ppedrot
Copy link
Member

ppedrot commented Feb 11, 2026

@coqbot merge now

@coqbot-app coqbot-app bot merged commit fb76e37 into rocq-prover:master Feb 11, 2026
9 of 10 checks passed
@coqbot-app
Copy link
Contributor

coqbot-app bot commented Feb 11, 2026

@ppedrot: Please take care of the following overlays:

  • 21531-Yann-Leray-stricter-type-in-type.sh

SkySkimmer added a commit to rocq-community/rocq-lean-import that referenced this pull request Feb 11, 2026
@yannl35133 yannl35133 deleted the stricter-type-in-type branch February 11, 2026 13:09
proux01 added a commit to math-comp/hierarchy-builder that referenced this pull request Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind: fix This fixes a bug or incorrect documentation. part: kernel part: sort polymorphism The sorts subsystem of the universe system. part: universes The universe system.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The kernel should permit differing sorts/qualities on sort-polymorphic inductives when Universe Checking is unset

4 participants