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

saturate instances on structure declaration #334

Merged
merged 2 commits into from
Oct 8, 2023
Merged

Conversation

gares
Copy link
Member

@gares gares commented Feb 7, 2023

Fix #197

HB/common/database.elpi Outdated Show resolved Hide resolved
HB/common/database.elpi Outdated Show resolved Hide resolved
@gares
Copy link
Member Author

gares commented Feb 22, 2023

don't forget to undup the list of types.
write something naïve, we will refine it later.

HB/instance.elpi Outdated Show resolved Hide resolved
HB/instance.elpi Outdated Show resolved Hide resolved
Copy link
Collaborator

@ThomasPortet ThomasPortet left a comment

Choose a reason for hiding this comment

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

todo

HB/common/database.elpi Outdated Show resolved Hide resolved
HB/common/database.elpi Outdated Show resolved Hide resolved
HB/common/database.elpi Outdated Show resolved Hide resolved
HB/common/utils.elpi Outdated Show resolved Hide resolved
HB/instance.elpi Show resolved Hide resolved
HB/instance.elpi Outdated Show resolved Hide resolved
HB/instance.elpi Show resolved Hide resolved
HB/structure.elpi Outdated Show resolved Hide resolved
HB/structure.elpi Outdated Show resolved Hide resolved
HB/structure.elpi Outdated Show resolved Hide resolved
@gares
Copy link
Member Author

gares commented Oct 5, 2023

I'm reviving this since we really need it in the contest of coreact.

@gares gares marked this pull request as ready for review October 5, 2023 06:16
@gares
Copy link
Member Author

gares commented Oct 5, 2023

I'll rebase on top of master and then force push.

@gares
Copy link
Member Author

gares commented Oct 6, 2023

@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.

@gares
Copy link
Member Author

gares commented Oct 6, 2023

@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.

structures.v Outdated Show resolved Hide resolved
HB/instance.elpi Outdated Show resolved Hide resolved
structures.v Outdated Show resolved Hide resolved
HB/structure.elpi Outdated Show resolved Hide resolved
ThomasPortet and others added 2 commits October 8, 2023 15:36
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.
@gares gares merged commit 2a10928 into master Oct 8, 2023
66 checks passed
@gares gares deleted the instance-before-structure branch October 8, 2023 13:41
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.

Saturate instances on new Structure declaration
2 participants