Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return canonical instance from basic declare.ml APIs + use to fix Program bug #18931

Closed
wants to merge 4 commits into from

Conversation

SkySkimmer
Copy link
Contributor

Fix #13979 (based on #18918)

@SkySkimmer SkySkimmer added kind: fix This fixes a bug or incorrect documentation. kind: cleanup Code removal, deprecation, refactorings, etc. labels Apr 15, 2024
@SkySkimmer SkySkimmer requested review from a team as code owners April 15, 2024 13:56
@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 Apr 15, 2024
Copy link
Member

@herbelin herbelin left a comment

Choose a reason for hiding this comment

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

OK to me, thanks.

let univs = match univs with
| Monomorphic_entry _ -> UVars.Instance.empty
| Polymorphic_entry uctx -> UVars.UContext.instance uctx
Copy link
Member

Choose a reason for hiding this comment

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

These lines of code are used at least 2 other times in the code. Would it make sense to add them to the universe API (in particular, they seem obvious to expert, but documenting why they are canonical in some sense - if so - would help non-expert like me).

let kn = declare_primitive_core ?typing_flags ~name cd in
let () = register_constant kn IsPrimitive local ?user_warns in
kn

Copy link
Member

Choose a reason for hiding this comment

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

By curiosity, why to extract a specific declare_primitive? It is because primitive cannot be polymorphic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See the message on the commit which does this change

Copy link
Member

Choose a reason for hiding this comment

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

OK.

One reason I'm asking is that I started to be afraid at some time by the diversity of code doing this or that manipulation on universes which is sometimes the same sometimes different of what is done in similar functions, and, at the end I felt unable to evaluate whether it is normal that there are difference or if there were oversights.

For instance, so that it is easier to be convinced that the treatment done in declare_primitive_core is consistent with what is done in declare_constant_core would it make sense to encapsulate the following lines beyond a level of abstraction shared with declare_constant_core:

let typ, ubinders, ctx = ... in
let () = Global.push_context_set ~strict:true ctx in
let ubinders = (UState.Monomorphic_entry ctx, ubinders) in
let () = DeclareUniv.declare_univ_binders (GlobRef.ConstRef kn) ubinders in

so that it is clear that it is intended to work as in declare_constant_core?

For instance, are Global.push_context_set and DeclareUniv.declare_univ_binders always supposed to go in pair?

Or, would it make sense to change the level of abstraction of extract_monomorphic to take a pair (univs, ubinders) and return a triple (univ_entry, ctx, (UState.Monomorphic_entry ctx, ubinders))?

PS: My question is more general than the PR and it is not blocking for the PR.

@github-actions github-actions bot added the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Apr 21, 2024
@coqbot-app coqbot-app bot removed the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Apr 23, 2024
@github-actions github-actions bot added the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Apr 29, 2024
@coqbot-app coqbot-app bot removed the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label May 2, 2024
@github-actions github-actions bot added the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label May 8, 2024
@coqbot-app coqbot-app bot removed the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label May 13, 2024
@github-actions github-actions bot added the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label May 17, 2024
@coqbot-app coqbot-app bot removed the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label May 21, 2024
@SkySkimmer
Copy link
Contributor Author

Seems not that useful in the end

@SkySkimmer SkySkimmer closed this May 24, 2024
@SkySkimmer SkySkimmer deleted the declare-hook-instance branch May 24, 2024 12:47
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. kind: fix This fixes a bug or incorrect documentation. needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Universe polymorphism breaks well-foundedness proofs of program definitions
2 participants