-
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
Instance saturation with parameters #343
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
From HB Require Import structures. | ||
|
||
HB.mixin Record m1 T := { default1 : T }. | ||
|
||
HB.mixin Record m2 T := { default2 : T }. | ||
|
||
HB.structure Definition s1 := { T of m1 T }. | ||
HB.structure Definition s2 := { T of m2 T }. | ||
|
||
HB.instance Definition _ (X : s1.type) : m1 (list X) := | ||
m1.Build (list X) (cons default1 nil). | ||
HB.instance Definition list_m2 (X : s2.type) : m2 (list X) := | ||
m2.Build (list X) (cons default2 nil). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
HB.structure Definition s3 := { T of m1 T & m2 T }. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We run the code to infer instances about all known types, since maybe we already have all the mixin instances we need. E.g. list is already both an m1 and m2, but when we did run instance inference before, s3 did not exist yet. We know "list" is an interesting type since we have some We run some code corresponding to the question "does (list ?T) have s3". This is a query run
I guess we need one extra rule
which in turn checks the premises on the parameter of
the implementation of find structure calls Coq's unification (structure-proj may be named differently, it is in HB/database.elpi)
Since Coe 8.16 can compute the "pullback" asking
Coq will figure out something like To simulate in Coq
The answer should be
|
||
|
||
HB.about list. (* should have s3 *) | ||
|
||
(* The s3 instance on list should be synthetized automatically, *) | ||
(* this is nontrivial because the parameters are not the same *) | ||
(* but there is a join in the hierarchy, so it can be defined. *) | ||
(* Actually just recalling the list_s2 instance above suffices. *) | ||
HB.instance Definition _ (X : s3.type) := list_m2 X. | ||
HB.about list. | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
From HB Require Import structures. | ||
|
||
HB.mixin Record m1 T := { default1 : T }. | ||
|
||
HB.mixin Record m2 T := { default2 : T }. | ||
|
||
HB.structure Definition s1 := { T of m1 T }. | ||
HB.structure Definition s2 := { T of m2 T }. | ||
|
||
HB.instance Definition _ (X : s1.type) : m1 (list X) := | ||
m1.Build (list X) (cons default1 nil). | ||
HB.instance Definition list_m2 (X : s1.type) : m2 (list X) := | ||
m2.Build (list X) nil. | ||
|
||
HB.structure Definition s3 := { T of m1 T & m2 T }. | ||
|
||
HB.about list. (* should have s3 *) | ||
|
||
(* The s3 instance on list should be synthetized automatically, *) | ||
(* But since it's defined afterwards, it's not taken into account. *) | ||
(* The subtelty now is that there is a parameter, but it's always the same *) | ||
(* A simple recall suffices: *) | ||
HB.instance Definition _ (X : s1.type) := list_m2 X. | ||
HB.about list. | ||
|
||
|
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.
The code does
Then, from
c
we generate a clause like this:and adds it to the db.
Note that the new clause does not mention the term
X
hence it makes sense even outside the sectionTMP
. The presence offind-structure
part depends on the type of the section parameters, in this caseX
has thes1
structure, so we record it in the premise of the clause.