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

Instance before structure #475

Draft
wants to merge 37 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
2d7d478
test showing the problem
gares Feb 7, 2023
1e51163
first try on modifying HB
ThomasPortet Feb 14, 2023
bd2a356
fixing bug on issue #335 should work but no tests yet
ThomasPortet Feb 15, 2023
90559fc
changing conflicting predicate name and completing the test for that …
ThomasPortet Feb 15, 2023
1dfc12c
completing the test
ThomasPortet Feb 15, 2023
c7f0e3e
starting to write the function for #336
ThomasPortet Feb 15, 2023
a832dbf
taking out duplicates for the function in #336 and including a test f…
ThomasPortet Feb 16, 2023
62378c1
starting to write function in #337
ThomasPortet Feb 16, 2023
45153aa
#335
ThomasPortet Feb 17, 2023
77cc438
#335
ThomasPortet Feb 20, 2023
3a6341b
implements the new approach mentioned in #335 and adds the steps in #…
ThomasPortet Feb 22, 2023
fd7d32b
starting to work on the undup function for list of terms with sets
ThomasPortet Feb 22, 2023
050163a
working on undup function and starting to rewrite the test for it
ThomasPortet Feb 23, 2023
051df0c
rewriting the function to remove duplicates and the test for it
ThomasPortet Feb 24, 2023
6815e50
typo
ThomasPortet Feb 27, 2023
0f428cb
first draft at modifying the mixin src clauses for type parameters
ThomasPortet Mar 13, 2023
071619a
continuing the transformation of clauses
ThomasPortet Mar 14, 2023
d2a8a5f
working on saturating instances with types
ThomasPortet Mar 14, 2023
d79445b
starting to work on #347
ThomasPortet Mar 15, 2023
c499513
changing how the boolean list works : with section parameters
ThomasPortet Mar 17, 2023
4025a2c
writing the boolean computing functions
ThomasPortet Mar 22, 2023
3c7b01a
fixing mixin-src->has-mixin-instance
ThomasPortet Mar 22, 2023
c167f78
writing the find instance function
ThomasPortet Mar 23, 2023
7a83809
reorganising declare all and working on mk-src
ThomasPortet Mar 27, 2023
5675a26
modifying how we get the first argument of mixin-src : it's pre-proce…
ThomasPortet Mar 28, 2023
3c04b9f
using the right types to declare classes
ThomasPortet Mar 28, 2023
9621cad
fixing the list of type upon which we call declare-all
ThomasPortet Mar 29, 2023
fdb2f58
starting to rewrite mk-src
ThomasPortet Mar 29, 2023
3532146
fixing mk-src, still need to check find-instance
ThomasPortet Mar 30, 2023
06268e3
fixing clause generation
ThomasPortet Mar 31, 2023
cc36c74
saturating instance works !
ThomasPortet Mar 31, 2023
3febe7f
cleaning up code and adding comments and a unit test
ThomasPortet Apr 5, 2023
c51263d
creating unit tests and cleaning up code
ThomasPortet Apr 7, 2023
6450bf4
more tests
ThomasPortet Apr 11, 2023
971749f
more tests and fixing the instance parameters case
ThomasPortet Apr 12, 2023
64b5ee9
fixing coqproject and fixing a bug on mk-src
ThomasPortet Apr 13, 2023
7fd35ef
changing prints into warnings to allow test suite to work
ThomasPortet Apr 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rewriting the function to remove duplicates and the test for it
  • Loading branch information
ThomasPortet committed Feb 24, 2023
commit 051df0c9d82518af0f4a3164ce1d006ca56ea2be
33 changes: 14 additions & 19 deletions HB/common/database.elpi
Original file line number Diff line number Diff line change
Expand Up @@ -139,30 +139,25 @@ factories-provide FLwP MLwP :- std.do! [
w-params.map UnsortedMLwP (p\t\ toposort-mixins) MLwP,
].

% pred gref-set-undup i:list gref, i:coq.gref.set, o:coq.gref.set.
% gref-set-undup (Gr::LN) S US :-
% if (coq.gref.set.mem Gr S)
% (gref-set-undup LN S US)
% (std.do! [gref-set-undup LN S US1, coq.gref.set.add Gr (gref-set-undup LN S US1) US]).
% gref-set-undup [] E E1 :- E = E1.
% pred undup-terms i:list term, o:list term.
% undup-terms [T|TL] UTL :-
% filter TL (x\ coq.gref.list->set) UTL

pred undup-gref i:list gref, o:list gref.
undup-gref [] [].
undup-gref [Te | Tl] Utl :-
(coq.gref.list->set Tl TS), (coq.gref.set.mem Te TS), !, std.append [Te] Utl Utl.
undup-gref [_ | TL] UTL :- (undup-gref TL UTL).
% % finds all unique types for which an instance was created
pred undup-grefs i:list gref, o:list gref.
undup-grefs L UL :- std.do! [
coq.gref.list->set L S,
coq.gref.set.elements S UL,
].

pred undup-terms i:list term, o:list term.
undup-terms L UL :- std.do! [
std.map L coq.term->gref LG,
undup-grefs LG ULG,
std.map ULG (coq.env.global ) UL,
].

% % finds all unique types for which an instance was created
pred findall-cs-types o:list term.
findall-cs-types TypeList :- std.do![
std.findall (has-db-instance _) Clauses,
std.map Clauses has-db-instance_type TypeListDup,
std.map TypeListDup coq.term->gref TGref,
undup-gref TGref UTgref,
std.map UTgref (coq.env.global ) TypeList,
undup-terms TypeListDup TypeList,
].


Expand Down
25 changes: 12 additions & 13 deletions tests/findall_cs_type.v
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,28 @@ From elpi Require Import elpi.

HB.mixin Record m1 T := { default1 : T }.
HB.mixin Record m2 T := { default1 : T }.

HB.mixin Record m3 T := { default2 : T }.
HB.mixin Record m4 T := { default3 : T }.
HB.mixin Record m5 T := { default4 : T }.
(* no types yet*)
Elpi Query HB.instance lp:{{std.assert! (findall-cs-types []) "a type was found"}}.

HB.instance Definition _ : m1 nat := m1.Build nat 1.
HB.instance Definition _ : m2 nat := m2.Build nat 2.

HB.instance Definition _ : m1 bool := m1.Build bool true.

HB.instance Definition _ : m1 bool := m1.Build bool true.
HB.instance Definition _ : m1 nat := m1.Build nat 1.
HB.instance Definition _ : m2 nat := m2.Build nat 2.

(*no duplicates *)
Elpi Query HB.instance lp:{{
undup-gref [m1,m2] L,
std.assert! (std.last L m2) "no type",

std.assert! (findall-cs-types [X]) "no type",
std.assert! (X = {{nat}}) "wrong type".
}}.

HB.instance Definition _ : m1 bool := m1.Build bool true.

HB.instance Definition _ : m4 bool := m4.Build bool true.
HB.instance Definition _ : m5 nat := m5.Build nat 5.
HB.instance Definition _ : m3 bool := m3.Build bool false.
Elpi Query HB.instance lp:{{
std.assert! (findall-cs-types [X,Y]) "no type",
std.assert! (Y = {{bool}}) "wrong type".
findall-cs-types Clauses,
std.assert! (std.length Clauses 2) "wrong number of clauses",
std.assert! (X = {{bool}}) "wrong type",
std.assert! (Y = {{nat}}) "wrong type".
}}.