Skip to content

Conversation

@mattam82
Copy link
Member

@mattam82 mattam82 commented Dec 11, 2025

Adapt the whole code base to use this instead of the multiple poly/"sort_poly"/cumulative flags. Actually the sort_poly flag is renamed collapse_sort_variables as it is the only thing it will govern. We use PolyFlags.univ_poly to check for universe polymorphism (= sort and level polymorphism).

Consistently name the argument ~poly:PolyFlags.t. Also adds an attribute poly : PolyFlags.construction_kind -> PolyFlags.t attribute that decides depending on the construction (assumption, definition or inductive) which flags are supported and how they should be set. Subsequent PRs will add new options for cumulativity of assumptions and definitions (in this PR they are still unsupported as before), and will use collapse_sort_variables to govern implicit sort polymorphism (do metavariable sorts default to Type (the current default) or not).

These flags are not used in all places they are passed yet, but will be in the upcoming PRs around sort-elim/univ-poly/variances and cumulativity. The goal is just to do a functionality-preserving API change here, that should reduce conflicts down the road for these feature PRs, with this one requiring simple overlays.

In particular this is a prerequisite for @TDiazT 's subsequent PRs on adding sort elaboration.

  • Added changelog.

@mattam82 mattam82 requested review from a team as code owners December 11, 2025 17:01
@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 Dec 11, 2025
Copy link
Contributor

@yannl35133 yannl35133 left a comment

Choose a reason for hiding this comment

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

General comments:

  • Is the future umbrella term not going to be Universe Polymorphism? I believe the structure should be called UnivPolyFlags rather than SortPolyFlags
  • There are a few SortPolyFlags.of_poly and a fewSortPolyFlags.make ~level_polymorphic:poly ~sort_polymorphic:false ~cumulative:false, why such a difference ?

@mattam82
Copy link
Member Author

General comments:

  • Is the future umbrella term not going to be Universe Polymorphism? I believe the structure should be called UnivPolyFlags rather than SortPolyFlags

I would also like to explain it like this: A universe is a sort and an optional universe level Prop|SProp|Set|Type@u|Global@{s;u}|Local@{s;u}) The we consistently use sort polymorphism, universe level polymorphism and universe polymorphism is their union. Does everyone agree?

  • There are a few SortPolyFlags.of_poly and a fewSortPolyFlags.make ~level_polymorphic:poly ~sort_polymorphic:false ~cumulative:false, why such a difference ?

They should all be UnivPolyFlags.of_level_poly indeed, I just introduced the abbreviation too late ;)

@ppedrot
Copy link
Member

ppedrot commented Dec 12, 2025

universe level polymorphism

Just say "level polymorphism".

@mattam82
Copy link
Member Author

mattam82 commented Dec 12, 2025

Thanks for the feedback. So I will correct the little mistakes here and there and:

  • have the type defined in engine/polyFlags.ml{,i}
  • make it private to not redefine the projections
  • is_polymorphic -> is_level_polymorphic
  • of_poly -> of_level_poly (most should have a FIXME comment here, it means something probably does not yet support sort_poly/cumulativity when it should)

Please +1 this message or state your disagreement :)

@ppedrot
Copy link
Member

ppedrot commented Dec 12, 2025

have the type defined in engine/polyFlags.ml{,i}

Why not as an abstract type in UState? I'm still not a fan of having to write PolyFlag.t.

@yannl35133
Copy link
Contributor

is_polymorphic -> is_level_polymorphic

Either you remove the alias or you consider it as more than an alias and you properly document the fact.
I tend to prefer the latter, considering the use cases.

@SkySkimmer
Copy link
Contributor

What are the flags when doing Polymorphic Definition id@{s;u} (A:Type@{s;u}) (a:A) := a. ?
If it's level_poly = true, sort_poly = false then that seems wrong since we are sort polymorphic
If they're both true then what's the difference between level_poly and sort_poly?

@mattam82
Copy link
Member Author

mattam82 commented Dec 12, 2025

have the type defined in engine/polyFlags.ml{,i}

Why not as an abstract type in UState? I'm still not a fan of having to write PolyFlag.t.

You prefer to write UState.poly_flags then? And then the projections as UState.level_polymorphic poly? I'm fine with that too, even if I would prefer to qualify as PolyFlags.level_polymorphic

@mattam82
Copy link
Member Author

@SkySkimmer just a PolyFlags.pr : t -> Pp.t would satisfy you ?

@mattam82
Copy link
Member Author

@SkySkimmer Also, any idea about the artifact errors on the CI?

@SkySkimmer
Copy link
Contributor

@SkySkimmer just a PolyFlags.pr : t -> Pp.t would satisfy you ?

and the stuff in top_printers.ml / top_printers.dbg to get it automatically in ocamldebug

@SkySkimmer
Copy link
Contributor

@SkySkimmer Also, any idea about the artifact errors on the CI?

no

Adapt the whole code base to using this instead of the multiple
poly/sort_poly/cumulative flags.

poly_flags -> poly

PolyFlags.of_poly -> of_level_poly
sort_polymorphic -> implicit_sort_polymorphic

Implement suggested fixes from PR

level_polymorphic -> univ_polymorphic

implicit_sort_polymorphic -> collapse_sorts_to_type

univ_polymorphic -> univ_poly

cleaner parsing of attributes (cumulative and collapse_sort_variables are just
not settable without universe polymorphism).

Fixed comments

Apply suggestions from code review

Spacing/indentation

Co-authored-by: yannl35133 <40719961+yannl35133@users.noreply.github.com>

Fix wrong poly kind used for inductive and record decls

Remove options that are not supported yet

Add Changelog entry

PolyFlags.assumption_or_definition -> PolyFlags.construction_kind

Support the polymorphism attributes in Hint Rewrite

Change plugin_tutorial to use the forward-compatible poly_def attribute

Add overlays

Fix rewrite rule integration of polyflags as per Y. Leray's comments

Add debug printer
@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 Dec 17, 2025
@mattam82
Copy link
Member Author

I added the debug printer stuff now

@mattam82
Copy link
Member Author

I don't think this needs another full ci

@ppedrot
Copy link
Member

ppedrot commented Dec 17, 2025

@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 Dec 17, 2025
@ppedrot ppedrot self-assigned this Dec 17, 2025
@ppedrot ppedrot added the kind: cleanup Code removal, deprecation, refactorings, etc. label Dec 17, 2025
@ppedrot ppedrot modified the milestones: 9.1.1, 9.2+rc1 Dec 17, 2025
@ppedrot
Copy link
Member

ppedrot commented Dec 17, 2025

@coqbot merge now

@coqbot-app coqbot-app bot merged commit bb0e90f into rocq-prover:master Dec 17, 2025
9 of 14 checks passed
@coqbot-app
Copy link
Contributor

coqbot-app bot commented Dec 17, 2025

@ppedrot: Please take care of the following overlays:

  • 21419-mattam82-sort-poly-flags.sh

ppedrot added a commit to rocq-community/paramcoq that referenced this pull request Dec 17, 2025
Janno added a commit to Mtac2/Mtac2 that referenced this pull request Dec 17, 2025
ppedrot added a commit to LPCIC/coq-elpi that referenced this pull request Dec 17, 2025
ppedrot added a commit to MetaRocq/metarocq that referenced this pull request Dec 17, 2025
SkySkimmer added a commit to impermeable/coq-waterproof that referenced this pull request Dec 17, 2025
Lysxia added a commit to Lysxia/coq-simple-io that referenced this pull request Dec 17, 2025
Lysxia pushed a commit to QuickChick/QuickChick that referenced this pull request Dec 17, 2025
ckeller pushed a commit to smtcoq/smtcoq that referenced this pull request Dec 18, 2025
JasonGross pushed a commit to mit-plv/rewriter that referenced this pull request Dec 18, 2025
@SkySkimmer SkySkimmer mentioned this pull request Jan 20, 2026
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind: cleanup Code removal, deprecation, refactorings, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants