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

Clean-up around substitution of globals #8971

Closed
wants to merge 5 commits into from

Conversation

maximedenes
Copy link
Member

We clean up the kernel API to not expose unsafe combinators (that silently insert dummy universe instances).

This is related to #8951 but does not solve it per se. It just makes the problem more visible on the user side (in that case, library/heads.ml).

@coqbot coqbot added the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Nov 12, 2018
@coqbot coqbot removed the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Nov 12, 2018
Copy link
Member

@mattam82 mattam82 left a comment

Choose a reason for hiding this comment

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

Cleanup looks good to me. IIUC, there are places where we do the wrong thing in case inlining produces a term rather than a global?

@maximedenes
Copy link
Member Author

Cleanup looks good to me. IIUC, there are places where we do the wrong thing in case inlining produces a term rather than a global?

Unfortunately, the most dangerous cases are when we don't inline, and subst_con0 puts back the dummy universe instance...

@maximedenes
Copy link
Member Author

maximedenes commented Nov 12, 2018

In order to resolve cleanly the universe poly vs inlining tension, I experimented removing functor inlining, and improving support for aliases in tactics instead. I went pretty far, but I'd need an answer to #5301, to make hints not rely on inlining.

if c'==c then ref else ConstructRef c'

let subst_global subst ref = match ref with
| VarRef var -> ref, mkVar var
| ConstRef kn ->
let kn',t = subst_con_kn subst kn in
let kn',t = subst_con subst (Univ.in_punivs kn) in
Copy link
Contributor

Choose a reason for hiding this comment

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

This should have some XXX TODO universes comment.

This comment was marked as resolved.

Copy link
Member

Choose a reason for hiding this comment

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

I talked too quickly. Reading the discussions, #8974 seems a very good direction.

@@ -192,7 +192,7 @@ let subst_cl_typ subst ct = match ct with
let c' = subst_proj_repr subst c in
if c' == c then ct else CL_PROJ c'
| CL_CONST c ->
let c',t = subst_con_kn subst c in
let c',t = subst_con subst (Univ.in_punivs c) in
Copy link
Contributor

Choose a reason for hiding this comment

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

Should have a comment XXX TODO FIXME univs

@@ -156,7 +156,7 @@ let cache_head o =

let subst_head_approximation subst = function
| RigidHead (RigidParameter cst) as k ->
let cst,c = subst_con_kn subst cst in
let cst,c = subst_con subst (Univ.in_punivs cst) in
Copy link
Contributor

Choose a reason for hiding this comment

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

FIXME XXX TODO univs

@SkySkimmer
Copy link
Contributor

In order to resolve cleanly the universe poly vs inlining tension

I don't think there's a tension, we just need to update the code.

Copy link
Member

@ppedrot ppedrot left a comment

Choose a reason for hiding this comment

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

LGTM modulo the changes mentioned by @SkySkimmer. There is a call to subst_global in tacsubst.ml that can be removed as well, it triggers a warning that is not removable and not using the warning system, so it's better to just get rid of this check.

@maximedenes
Copy link
Member Author

I think I prefer #8974 , but even better if we can really fix the problems.

@maximedenes
Copy link
Member Author

Closing in favor of #8974.

@maximedenes maximedenes deleted the clean-subst-global branch August 27, 2023 15:04
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.

None yet

6 participants