-
Notifications
You must be signed in to change notification settings - Fork 632
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
Discharge on the fly #17888
Discharge on the fly #17888
Conversation
7eed083
to
b21e6d6
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This is nice!
I think we want all versions (unless it's declared I worry that doing this for instances is going to blow up typeclass resolution, though? In general, it seems like we only want the more global version of a canonical structure/coercion/instance to trigger if the section-local one cannot apply. |
b21e6d6
to
6fc1ad4
Compare
This comment was marked as outdated.
This comment was marked as outdated.
6fc1ad4
to
3c89247
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This PR is in anticipation of name collisions that would appear with the introduction of discharge on the fly in Coq (coq/coq#17888). In the present case, the collisions would come from the introduction of new discharged names of the form `pullbacks.PullbackArrow` in `graphs` which would collide with the same names in `limits`. Apparently, the convention was anyway that names from `limits` had an explicit `limits` prefix up to the four exceptions of this PR. So, I believe that this PR can be merged anyway, as soon as now, independently of coq/coq#17888.
I like the feature, I've always thought that this is how sections should work. Section S.
Variable A : Type.
Definition f : T :=. .. A ...
Module Aux. Let f := f A. End Aux. Import Aux. (* pseudo code for nametab *)
Check f : T.
Check Top.f : Type -> T. or said otherwise Section S.
Variable A : Type.
Definition f : T :=. .. A ...
Let f_aux := f A.
(* nametab making f -> f_aux *)
Check f : T.
Check f_aux. (* error, no nametab entry *)
Check Top.f : Type -> T.
End S.
(* nametab entry for f -> f_aux gone *) Modifying the kernel is a regression to me, it has been a while since we managed to get rid of section components in kernel names. But maybe your change amounts to implementing the module-in-section thing just for constants, in that case I stand corrected, but you mark it as the main change which seems a bit odd it is amounts to generate a |
In any case, I think this is a huge change deserving a CEP (like the one about levels in grammar entries, which studies all details and possible angles to tackle it) |
I think that generating the metadata twice would be an error, e.g. the discharged copy should stay naked. |
The test suite error is a new warning in an output test, seems quite unlike the other CI errors. Therefore |
also @coqbot bench |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
About declaring scopes, databases for hints, and overriden notations.
That means canonically relying on discharge functions for global references.
There is basically one change of structure: - kernel names include a section path in their name (encoded using MPdot) There are basically three kinds of algorithmic change: - in the kernel (safe_typing.ml): add all generalisations of a declaration at declaration time - in library (lib.ml): add all discharges of a declaration at declaration time - adapt all discharge functions to take into account that names now include a section segment There are three kinds of behaviors for objects: - registered only in the innermost section (e.g. coercions, canonical projections, instances, ...) - registered only in the outermost section (e.g. Require) - registered only in all section (e.g. implicit arguments, arguments scopes, ...) (Note that the Univ object is implemented in an ad hoc way so that bound universes are innermost and monomorphic universes are outermost) TODO: - double-check what really needs to be in Safe_typing.section_data
3d1eed9
to
219bc2f
Compare
I see. The minimization strategy for removing sections indeed becomes more fragile with this change, since there are more cases where removing |
Actually, sorry, I think I misdiagnosed the failure, and in fact the issue is that minimization got stronger / easier, now that absolute names are available inside sections. I guess the test case check should be adapted |
For the record, a comment of Théo reporting about the experience in Lean of simulating sections with implicit arguments. |
Is this currently blocked on me writing an overlay for coq-tools, or something else? |
Nothing strictly blocking yet. We had a discussion at the Coq call today and decided to merge already the internal (kernel) part (#18065). For the rest, we decided to collect examples of needs so that we understand better what to exactly implement user-side (e.g. whether the discharge is made on demand or systematically, or how to deal with different versions of a hint, or whether we recover the specific versions from the most general ones, etc.) |
The "needs: rebase" label was set more than 30 days ago. If the PR is not rebased in 30 days, it will be automatically closed. |
This PR was not rebased after 30 days despite the warning, it is now closed. |
This is a proof of concept for discharge on the fly, that is for being able to access all generalizations of a declaration in a section at the time of declaration.
Example:
The new model is basically the following:
There is basically one main change of structure:
The changes are otherwise dispatched into three parts:
This raises questions about the levels at which a declaration has to be done:
S
, bothoption
andTop.option
have to be definedRequire
, or (mono)Universe
only the copy living at the toplevel has to be registeredIncidentally, since the discharge functions have to be adapted anyway, that might be a right time to change the type of Libobject functions (e.g. so that they take an environment and a summary as arguments?).
I open the PR as draft to get some first comments.
Current status: PRs #18062 (preliminatory work on discharge) and #18065 (discharge on the fly in the kernel) have been made out of this PR, which now depends on them.
Related discussion: Future of sections #6254 and coq/ceps#72.