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

Remove section paths from kernel names #8555

Merged
merged 1 commit into from
Oct 6, 2018

Conversation

maximedenes
Copy link
Member

Let's see what CI says.

API documentation needs to be updated, and dev/doc/changes.md to mention a few renamings.

@maximedenes maximedenes added the needs: documentation Documentation was not added or updated. label Sep 25, 2018
@ppedrot
Copy link
Member

ppedrot commented Sep 25, 2018

Looks broken...

@gares
Copy link
Member

gares commented Sep 25, 2018

you need to fix dev/*ml stuff to :-/

@maximedenes maximedenes force-pushed the rm-section-path branch 4 times, most recently from 329d7d1 to b7b61f3 Compare September 26, 2018 07:36
@herbelin
Copy link
Member

Can you explain your goals? Is it intended to be a purely internal cleaning or with a change of semantics in mind? For instance, does this have an impact in what About reports for constants in sections?

@maximedenes
Copy link
Member Author

Can you explain your goals? Is it intended to be a purely internal cleaning or with a change of semantics in mind? For instance, does this have an impact in what About reports for constants in sections?

It is not fully internal, because it prevents for example:

Ltac f := idtac.
Section foo. Ltac f := idtac. End foo.

which was previously allowed. I didn't find an occurrence, except one in the test suite. But overall, it does not change much the semantics of names at the user level.

After this patch, About still reports the same thing, and you can still qualify constants using a section path, since this relies on the full_path / Nametab thing, not the kernel names that this patch cleans.

However, I was very surprised to discover one can qualify using section paths (and not just module paths), I'm not sure how aware users are of this feature. We may want to discuss it separately.

@maximedenes
Copy link
Member Author

Can you explain your goals?

So the answer is I'm trying to clean (parts of) the section-related code, and save some memory.

@maximedenes maximedenes added the kind: cleanup Code removal, deprecation, refactorings, etc. label Sep 26, 2018
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.

I am supporting this change. It makes the kernel cleaner and reduces many places where we can break invariants while not removing any user-facing feature.

(** Projections *)

val user : t -> KerName.t
val canonical : t -> KerName.t

val repr3 : t -> ModPath.t * DirPath.t * Label.t
val repr2 : t -> ModPath.t * Label.t
Copy link
Member

Choose a reason for hiding this comment

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

Should probably be called repr.

Copy link
Member Author

Choose a reason for hiding this comment

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

I doubt it, because repr should return the two names...

let (_, dir, _) = Constant.repr3 kn in
let hcons = DirPath.is_empty dir in
(* let (_, dir, _) = Constant.repr3 kn in *)
let hcons = false (* XXX DirPath.is_empty dir *) in
Copy link
Member

Choose a reason for hiding this comment

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

Isn't that preventing section definitions from being hashconsed when they exit it?

Copy link
Contributor

Choose a reason for hiding this comment

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

In fact now that we don't have to change the names I think we could just hashcons when the cooking_info is empty.

Copy link
Member

Choose a reason for hiding this comment

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

Indeed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Isn't that preventing section definitions from being hashconsed when they exit it?

Yeah, I completely forgot to come back to this part of the code, sorry.

Copy link
Member Author

Choose a reason for hiding this comment

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

Isn't that preventing section definitions from being hashconsed when they exit it?

In fact, I don't think so because the only call to translate_recipe already hash conses everything (body, type, universes)...

Can you confirm?

@@ -92,8 +92,7 @@ let subst_keys (subst,(k,k')) =
(subst_key subst k, subst_key subst k')

let discharge_key = function
| KGlob g when Lib.is_in_section g ->
if isVarRef g then None else Some (KGlob (pop_global_reference g))
| KGlob (VarRef _ as g) when Lib.is_in_section g -> None
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there still a need for the when?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know, the logic is pretty mysterious to me, so I kept the behavior of the original code.

@herbelin
Copy link
Member

After this patch, About still reports the same thing, and you can still qualify constants using a section path, since this relies on the full_path / Nametab thing, not the kernel names that this patch cleans.

OK, I think I now understand.

One reason I'm worrying is that I feel that there is a general confusion about where to go with discharge and with overwriting the name of section variables in goal, a sea snake which blocks us to make progresses (e.g. with Proof using, with treating the copy of section variables in goal as goal variables, etc.). I'd like to hear a vision on this latter point, knowing that in the absence of a vision, I shall propose to have the discharge in the kernel and the section variables locally-global objects.

@maximedenes
Copy link
Member Author

One reason I'm worrying is that I feel that there is a general confusion about where to go with discharge and with overwriting the name of section variables in goal, a sea snake which blocks us to make progresses (e.g. with Proof using, with treating the copy of section variables in goal as goal variables, etc.). I'd like to hear a vision on this latter point, knowing that in the absence of a vision, I shall propose to have the discharge in the kernel and the section variables locally-global objects.

I'm pretty sure discussion on these points is needed indeed, and you can open an issue about it. But as far as I can tell, this patch is completely orthogonal to these questions.

@maximedenes maximedenes force-pushed the rm-section-path branch 5 times, most recently from 756d69a to 05ebff8 Compare October 1, 2018 08:47
@maximedenes maximedenes removed the needs: documentation Documentation was not added or updated. label Oct 1, 2018
@maximedenes
Copy link
Member Author

This is blocking on a fiat-crypto-legacy failure, but building it on my machine takes ~2h before I see the first coqc invocations...

@maximedenes
Copy link
Member Author

Good, state what "essentially" means, like "they were used only in this case"

Ok, you're asking me to describe the previous design but I failed to understand it, so I'll let you amend the commit message in the way you like. I anyway exhausted the time I was planning to spend on this patch, and as mentioned above, I don't need it at all.

@ejgallego
Copy link
Member

Ok, you're asking me to describe the previous design but I failed to understand it

Does that mean that you don't understand what this patch does?

I'll let you amend the commit message in the way you like.

I am very puzzled with this statement, which does seem wrong at several levels.

If you, the author of the patch, and maintainer of the subsystem in question, has deep trouble writing a short paragraph that documents the change for those doing git diving in the future, how am I supposed to come up with a description, precisely that I have no idea of what the patch does, nor what it does imply nor how does the kernel work.

@maximedenes
Copy link
Member Author

Does that mean that you don't understand what this patch does?

Exactly.

@ppedrot
Copy link
Member

ppedrot commented Oct 3, 2018

Well, it's pretty clear: there is legacy code in the kernel that is essentially dead in a non-trivial way. So it doesn't hurt removing it, it makes the kernel more robust and reduces its attack surface.

@gares
Copy link
Member

gares commented Oct 3, 2018

I dunno what others things

I'm fine with this patch.

@ppedrot ppedrot added this to the 8.10+beta1 milestone Oct 3, 2018
@ppedrot
Copy link
Member

ppedrot commented Oct 4, 2018

@ejgallego are you reassured and OK for the PR?

@ejgallego
Copy link
Member

ejgallego commented Oct 4, 2018

Sure, I have nothing against the PR, which seems very welcome, I just said that the commit message could be a bit better than empty IMO. Give me a few minutes and I'll prepare a commit message then, given that I am supposed to do it, it seems.

@gares

This comment has been minimized.

@ejgallego
Copy link
Member

Sorry for the delay, here it goes:

[kernel] Remove section paths from `KerName.t`

We remove sections paths from kernel names. This is a cleanup as most of the times this information was unused. This implies a change in the Kernel API and small user visible changes with regards to tactic qualification. In particular, the removal of "global discharge" implies a large cleanup of code.

Additionally, the change implies that some machinery in `library` and `safe_typing` must now take an `~in_section` parameter, as to provide the information whether a section is open or not.

We remove sections paths from kernel names. This is a cleanup as most of the times this information was unused. This implies a change in the Kernel API and small user visible changes with regards to tactic qualification. In particular, the removal of "global discharge" implies a large cleanup of code.

Additionally, the change implies that some machinery in `library` and `safe_typing` must now take an `~in_section` parameter, as to provide the information whether a section is open or not.
@maximedenes
Copy link
Member Author

Sorry for the delay, here it goes:

Thanks, commit updated.

@ppedrot
Copy link
Member

ppedrot commented Oct 5, 2018

CI failures are spurious, right? Iris is broken in master already...

@ejgallego
Copy link
Member

ejgallego commented Oct 5, 2018

CI failures are spurious, right? Iris is broken in master already...

Yup, CI here is good. However, this got bitten by the CHANGES disease so a new rebase seems to be needed :(

@ejgallego ejgallego added the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Oct 5, 2018
@maximedenes
Copy link
Member Author

lol

@gares
Copy link
Member

gares commented Oct 5, 2018

No rebase, the guy that merges should take care of the conflict.

@ppedrot ppedrot merged commit 650c65a into coq:master Oct 6, 2018
@ppedrot ppedrot removed the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label Oct 6, 2018
@ejgallego
Copy link
Member

I am confused or was this PR merged without the overlays having been properly submitted as PR @ppedrot ?

Anyways, CI in master is broken so please @maximedenes submit the corresponding PRs and @mattam82 @ppedrot merge, thanks.

@ejgallego
Copy link
Member

Also not sure about the deprecation policy followed here.

@ppedrot
Copy link
Member

ppedrot commented Oct 6, 2018

I am confused or was this PR merged without the overlays having been properly submitted

Strange, the merge script didn't warn me that there were overlays, and I forgot to check that there were there indeed. I can merge the Ltac2 one quickly, and submit one in equations.

Also not sure about the deprecation policy followed here.

API changed in a non-backward compatible way, I don't think we can easily provide a deprecated interface.

@ppedrot
Copy link
Member

ppedrot commented Oct 6, 2018

PR submitted on equations and already merged in Ltac2.

@maximedenes
Copy link
Member Author

Also not sure about the deprecation policy followed here.

API changed in a non-backward compatible way, I don't think we can easily provide a deprecated interface.

Yep, I did provide one deprecation warning for the construct for which I could see a transition path.

@ejgallego
Copy link
Member

Cool, thanks @ppedrot

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.

6 participants