-
Notifications
You must be signed in to change notification settings - Fork 22
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
saturate instances on structure declaration #334
Conversation
don't forget to undup the list of types. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo
I'm reviving this since we really need it in the contest of coreact. |
I'll rebase on top of master and then force push. |
edaff8d
to
198ce25
Compare
@ThomasPortet do you mind if I squash the history? There are so many changes on the same lines that rebasing other work on this PR is quite tedious. As I was saying this PR is really needed for the Coreact project, and we need to rebase our work there on this one. Then I think I can merge and maybe open a few issues for some of the TODOs so that we don't forget about them. |
@CohenCyril I need you help, I'd like to run CI on math-comp and co, but here it succeeds super fast. I've the impression it is not using this branch of HB. |
When a new structure `S` is created it may be the case that some type which is already equipped with some mixins is an instance of `S`, but was not declared as such since `S` was not declared yet. Similarly, mixin instances which have parameters may not be available on a single type until there is a structure for the parameter which is rich enough. We store in the predicate `has-mixin-instance` the list of types which have mixin instances, so that we can reconsider them later. Out of these we craft `mixin-src` clauses (used by `HB/common/inference.elpi`) which have premises using Coq's unifyer (which in turn can compute the smallest structure having all requirements thanks to the hints we declare on joins). Example: When such an instance is declared: ```coq HB.instance Definition I1 (X:t1) : mixin1 (list X) := ... . ``` a clause of this form is generated: ```coq has-mixin-instance (cs-gref (indt «list»)) (indt «mixin1.axioms_») (const «I1») ``` When `HB.saturate` is called, we generate conditional `mixin-src` clauses with conditions on parameters (via the function `has-mixin-instance->mixin-src`). Then for each type constructor mentioned in a `has-mixin-src` clause we try to declare new instances with the new clauses via `declare-all-on-type-constructor`. Unresolved parameters are abstracted out. Their type is the smallest structure which can satisfy all the constraints coming from single mixins.
df1f03d
to
81cdb25
Compare
Fix #197