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

wrapper mixin step0 #370

Draft
wants to merge 64 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
6f1dee6
test for step 0 of CoREACT
gares Jun 2, 2023
1ceb6ea
update
gares Jun 2, 2023
f6c1970
more
gares Jun 2, 2023
17d6561
more
gares Jun 2, 2023
d2bc00f
Update tests/monoid_enriched_cat.v
CohenCyril Jun 19, 2023
6726472
Update tests/monoid_enriched_cat.v
CohenCyril Jun 19, 2023
0821793
Update tests/monoid_enriched_cat.v
CohenCyril Jun 19, 2023
234e3f5
Update tests/monoid_enriched_cat.v
CohenCyril Jun 19, 2023
92e1f68
Update tests/monoid_enriched_cat.v
CohenCyril Jun 19, 2023
b7f3789
Update tests/monoid_enriched_cat.v
CohenCyril Jun 19, 2023
80e17f2
added enriched_cat.v
ptorrx Jun 19, 2023
314c6b9
copied Cyril's monoid_enriched_cat.v to enriched_cat.v
ptorrx Jun 19, 2023
67526eb
added monoid_enriched_cat.v as the original pull request by Cyril, in…
ptorrx Jun 20, 2023
a3bcee5
add enriched_cat to _CoqProject
ptorrx Jun 21, 2023
f472ce6
changes to enriched_cat.v
ptorrx Jun 21, 2023
b3ba8c1
changes related to monoid_enriched_cat.v and wrappers in various file…
ptorrx Jun 21, 2023
9f0bde5
change to enriched_cat.v
ptorrx Jun 22, 2023
056f6e0
minor changes
ptorrx Jun 22, 2023
b78c77c
added Elpi code in monoid_enriched_cat.v
ptorrx Jun 23, 2023
0d0e9b7
changes in monoid_enriched_cat.v
ptorrx Jun 26, 2023
b6b8278
added improved version of extraction predicates in monoid_enriched_cat.v
ptorrx Jun 27, 2023
145aa0d
minor changes in monoid_enriched_cat.v
ptorrx Jun 27, 2023
8d0310e
moved Elpi code from monoid_enriched_cat.v to factory.v. monoid-enric…
ptorrx Jun 27, 2023
0b2b79f
minor changes in monoid_enriched_cat.v
ptorrx Jun 28, 2023
7fbd129
added instance in monoid_enriched_cat.v
ptorrx Jun 28, 2023
5ded009
added some tests to monoid_enriched_cat.v
ptorrx Jun 28, 2023
2ea2be6
pseudo-code to add new instances for each wrapper mixin
CohenCyril Jun 28, 2023
2fccea4
added some comment
ptorrx Jun 29, 2023
1ffc93d
tentative changes in structure.elpi (reexport-wrapper-as-instance is …
ptorrx Jun 29, 2023
d9c7980
changes in structure.elpi and monoid_enriched_cat.v - compiles
ptorrx Jun 30, 2023
7158c54
added comments in structure.elpi
ptorrx Jun 30, 2023
7ec530a
changes in structure.elpi, to prepare the derivation of the wrapper i…
ptorrx Jul 3, 2023
7e83bd9
added comments in structure.elpi
ptorrx Jul 3, 2023
40eef02
tentative changes to structure.elpi
ptorrx Jul 3, 2023
a26cf4b
changes in structure.elpi - mainly comments
ptorrx Jul 4, 2023
09b0222
changes in structure.elpi - mainly comments
ptorrx Jul 4, 2023
e5f56a1
main changes in instance.elpi
ptorrx Jul 4, 2023
36dc631
added commments in instance.elpi
ptorrx Jul 4, 2023
b46a369
minor changes in monoid_enriched_cat.v (wrapper instance definition n…
ptorrx Jul 4, 2023
d93a11d
Update tests/monoid_enriched_cat.v
ptorrx Jul 5, 2023
e4c3732
added summary of today's discussion at the bottom of instance.elpi
ptorrx Jul 5, 2023
8c30d1a
Merge remote-tracking branch 'origin/wrapper' into wrapper
ptorrx Jul 5, 2023
911ede1
setup nix
CohenCyril Jul 3, 2023
4e47908
blind attempt
CohenCyril Jul 6, 2023
3d0961c
minor changes to comments in instance.elpi
ptorrx Jul 6, 2023
314dadc
added debug printouts
ptorrx Jul 13, 2023
5f18ee4
revised comments and printouts, minor change in structure.elpi to nam…
ptorrx Jul 17, 2023
ce51cc4
Switched to tentive version of add-all-mixins with extra parameter. B…
ptorrx Jul 18, 2023
641d35d
gone back to old add-all-mixins (without std.forall), revised comment…
ptorrx Jul 19, 2023
6bdfd59
gone back to old add-all-mixins (without std.forall), revised comment…
ptorrx Jul 19, 2023
790ca44
added predicates to handle cumulative output over forall, avoiding du…
ptorrx Jul 20, 2023
f0975bb
added redirect-instances (instances.elpi), in progress
ptorrx Jul 20, 2023
73e614b
instance.elpi, redirect-instances - in progress (section problem)
ptorrx Jul 21, 2023
ab87dd8
instance.elpi, redirect-instances - in progress (section problem)
ptorrx Jul 21, 2023
11baf58
instance.elpi: redirect-instances in progress, still need to add call…
ptorrx Jul 21, 2023
8e22bb3
instance.elpi: redirect-instances in progress, added call to declare-…
ptorrx Jul 24, 2023
3dbe65e
instance.elpi: redirect-instances in progress, added call to declare-…
ptorrx Jul 24, 2023
e7361bf
more comments in instance.elpi, added lemma in enriched_cat.v and fac…
ptorrx Jul 24, 2023
9d80cdf
enriched_cat.v: minor changes
ptorrx Jul 26, 2023
7835883
enriched_cat.v: minor changes
ptorrx Jul 26, 2023
f8da435
test commit, minor changes
ptorrx Aug 3, 2023
2338a1f
adding examples in cmon_enriched_cat.v
ptorrx Aug 4, 2023
7907b7f
updated cmonoid_enriched_cat.v with new examples; some problems
ptorrx Aug 9, 2023
ce88b3d
updated cmon_enriched_cat.v - now the file contains three examples; c…
ptorrx Aug 10, 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
5 changes: 4 additions & 1 deletion .nix/config.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
format = "1.0.0";
attribute = "hierarchy-builder";
default-bundle = "coq-8.15";
default-bundle = "coq-8.16";
bundles = let
mcHBcommon = {
mathcomp.override.version = "hierarchy-builder";
Expand All @@ -26,6 +26,9 @@
coq.override.version = "8.15";
} // mcHBcommon;

"coq-8.17".coqPackages = {
coq.override.version = "8.17";
};
"coq-8.16".coqPackages = {
coq.override.version = "8.16";
mathcomp.override.version = "mathcomp-1.15.0";
Expand Down
1 change: 1 addition & 0 deletions HB/common/utils.elpi
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ with-attributes P :-
att "primitive" bool,
att "non_forgetful_inheritance" bool,
att "hnf" bool,
att "wrapper" bool,
] Opts, !,
Opts => (save-docstring, P).

Expand Down
86 changes: 84 additions & 2 deletions HB/factory.elpi
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ type by-phantabbrev abbreviation -> factory-abbrev.

pred declare-abbrev i:id, i:factory-abbrev.
declare-abbrev Name (by-classname GR) :-

coq.say "DA!!!!!!&&& NOW RUNNING declare-abbrev",

% looks fishy (the parameters are not taken into account)
@global! => log.coq.notation.add-abbreviation Name 1 (fun _ _ t\ app[global GR,t]) tt _.
declare-abbrev Name (by-phantabbrev Abbr) :- std.do! [
coq.say "DA!!!!!!&&& NOW RUNNING declare-abbrev",
coq.notation.abbreviation-body Abbr Nargs AbbrTrm,
@global! => log.coq.notation.add-abbreviation Name Nargs AbbrTrm tt _,
].
Expand Down Expand Up @@ -192,6 +196,7 @@ mk-factory-abbrev Str GR Aliases FactAbbrev :- !, std.do! [
pred declare-asset i:argument, i:asset.
declare-asset Arg AssetKind :- std.do! [
argument-name Arg Module,

if-verbose (coq.say {header} "start module and section" Module),
log.coq.env.begin-module Module none,
log.coq.env.begin-section Module,
Expand All @@ -218,19 +223,75 @@ declare-asset Arg AssetKind :- std.do! [
)
].

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% auxiliary code for wrapper-mixin

pred extract_from_record_decl i: (term -> gref -> prop), i:indt-decl, o:gref.
extract_from_record_decl P (parameter ID _ _ R) Out :-
pi p\
extract_from_record_decl P (R p) Out.
extract_from_record_decl P (record ID _ KID (field _ _ Ty (x\end-record))) GR0 :-
P Ty GR0.

pred extract_from_rtty i: (term -> gref -> prop), i: term, o:gref.
extract_from_rtty P (prod _ _ TF) Out1 :-
pi p\
extract_from_rtty P (TF p) Out1.
extract_from_rtty P Ty Gr :- P Ty Gr.

pred xtr_fst_op i:term, o:gref.
xtr_fst_op Ty Gr1 :-
Ty = (app [global Gr0| _]),
factory-alias->gref Gr0 Gr1.

pred xtr_snd_op i:term, o:gref.
xtr_snd_op Ty Gr :-
Ty = (app [global _, app [global Gr| _]]).

pred extract_wrapped i:indt-decl, o:gref.
extract_wrapped In Out :-
extract_from_record_decl (extract_from_rtty xtr_fst_op) In Out.

pred extract_subject i:indt-decl, o:gref.
extract_subject In Out :-
extract_from_record_decl (extract_from_rtty xtr_snd_op) In Out.

pred wrapper_mixin_aux i:gref, o:gref, o:gref.
wrapper_mixin_aux XX Gr1 Gr2 :-
XX = (indt I),
coq.env.indt-decl I D,
extract_subject D Gr1,
extract_wrapped D Gr2.

%%% end auxiliary code for wrapper-mixin
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

pred declare-mixin-or-factory i:list prop, i:list constant, i:list term, i:term,
i:term, i:record-decl, i:list-w-params factoryname, i:id, i:asset.
declare-mixin-or-factory MixinSrcClauses SectionCanonicalInstance
TheParams TheType Sort1 Fields GRFSwP Module D :- std.do! [

coq.say "DMOF!!!!!!!!!!!!!!!!!!!! NOW RUNNING declare-mixin-or-factory",
coq.say "DMOF!!!!!!!! MixinSrcClauses" MixinSrcCaluses,
coq.say "DMOF!!!!!!!! SectionCanonicalInstance" SectionCanonicalInstance,
coq.say "DMOF!!!!!!!! TheParams" TheParams,
coq.say "DMOF!!!!!!!! TheType" TheType,
coq.say "DMOF!!!!!!!! Sort1" Sort1,
coq.say "DMOF!!!!!!!! Fields" Fields,
coq.say "DMOF!!!!!!!! GRFSwP" GRFSwP,
coq.say "DMOF!!!!!!!! Module" Module,
coq.say "DMOF!!!!!!!! D" D,

if-verbose (coq.say {header} "declare record axioms_"),
Kname = "Axioms_",
RDeclSkel = record "axioms_" Sort1 Kname Fields,
std.assert-ok! (coq.elaborate-indt-decl-skeleton RDeclSkel RDecl) "record declaration illtyped",

abstract-over-section TheParams TheType MixinSrcClauses SectionCanonicalInstance coq.abstract-indt-decl RDecl RDeclClosed _,

% coq.say RDecl RDeclClosed,
% coq.say "TEST" RDecl RDeclClosed,
% coq.say "TEST" RDecl,
% coq.say "TEST" (indt R),

if (get-option "primitive" tt)
(@primitive! => log.coq.env.add-indt RDeclClosed R)
Expand All @@ -250,6 +311,27 @@ declare-mixin-or-factory MixinSrcClauses SectionCanonicalInstance
build-deps-for-projections R MLwP GRDepsClausesProjs,
GRDepsClauses = [gref-deps (indt R) MLwP, gref-deps (indc K) MLwP|GRDepsClausesProjs],

% coq.say "TODO: extract useful info:" RDecl,
% coq.say "TODO: extract useful info:" RDecl "AND THEN:" RDeclClosed,
% record-decl in https://github.com/LPCIC/coq-elpi/blob/master/coq-builtin.elpi#L429
% per trovare il vero nome del mixin database.elpi:factory-alias->gref
% per sapere quanti argomenti skippare prima del soggetto del mixin
% factory-nparams
%
% in generale hai:
% forall ....., app[mixin_alias, p1 ... pn | [ app[subject, ...] , extra]]
% mixin_alias -> mixin via factory-alias->gref
% factory-nparams mixin -> n
%
% coq.say "TEST 2" (indt R),

if (get-option "wrapper" tt)
((wrapper_mixin_aux (indt R) NSbj WMxn),
(WrapperClauses = [wrapper-mixin (indt R) NSbj WMxn]))
(WrapperClauses = []),

coq.say "DMOF!!!!!!!! adding WrapperClauses " WrapperClauses,

% GRDepsClauses => mk-factory-sort MLwP (indt R) _ FactorySortCoe,
% FactorySortCoe = coercion GRFSort _ _ _,

Expand All @@ -271,7 +353,7 @@ declare-mixin-or-factory MixinSrcClauses SectionCanonicalInstance
if-verbose (coq.say {header} "start module Exports"),

log.coq.env.begin-module "Exports" none,
std.flatten [Clauses, GRDepsClauses, [
std.flatten [Clauses, GRDepsClauses, WrapperClauses, [
factory-constructor (indt R) GRK,
factory-nparams (indt R) NParams,
factory-builder-nparams BuildConst NParams,
Expand Down
Loading