@@ -10,7 +10,7 @@ exists-indc I P :-
1010 std.exists KL P.
1111
1212pred if-verbose i:prop.
13- if-verbose P :- get-option "verbose" tt, !, P.
13+ if-verbose P :- ( get-option "verbose" tt ; get-option "recursive" tt) , !, P.
1414if-verbose _.
1515
1616pred dep o:string, o:string.
@@ -22,38 +22,38 @@ selected Name :- get-option "only" Map, !,
2222 Map => (get-option Name _; (get-option X _, dep X Name)).
2323selected _.
2424
25- pred validate-only i:list derive.
26- validate-only LD :- get-option "only" Map, !, std.forall Map (known-option LD).
27- validate-only _.
25+ pred validate-only i:gref, i: list derive.
26+ validate-only T LD :- get-option "only" Map, !, std.forall Map (known-option T LD).
27+ validate-only _ _ .
2828
29- pred known-option i:list derive, i:prop.
30- known-option L (get-option X _) :-
29+ pred known-option i:gref, i: list derive, i:prop.
30+ known-option T L (get-option X _) :-
3131 if (std.mem! L (derive X _ _)) true
32- (coq.error "Derivation" X "unknown or not applicable to the input").
33-
34- pred chain i:list derive, o:list prop.
35- chain [] [].
36- chain [derive Name _ _|FS] CL :- not(selected Name), !,
37- if-verbose (coq.say "Skipping derivation" Name "since the user did not select it"),
38- chain FS CL.
39- chain [derive Name _ AlreadyDone|FS] CL :- (pi x\ stop x :- !, fail) => AlreadyDone, !,
40- if-verbose (coq.say "Skipping derivation" Name "since it has been already run"),
41- chain FS CL.
42- chain [derive Name F _|FS] CL :- get-option "only" _, !, % request this one
43- if-verbose (coq.say "Derivation" Name),
32+ (coq.error "Derivation" X "unknown or not applicable to input" T ).
33+
34+ pred chain i:gref, i: list derive, o:list prop.
35+ chain _ [] [].
36+ chain T [derive Name _ _|FS] CL :- not(selected Name), !,
37+ if-verbose (coq.say "Skipping derivation" Name "on" T " since the user did not select it"),
38+ chain T FS CL.
39+ chain T [derive Name _ AlreadyDone|FS] CL :- (pi x\ stop x :- !, fail) => AlreadyDone, !,
40+ if-verbose (coq.say "Skipping derivation" Name "on" T " since it has been already run"),
41+ chain T FS CL.
42+ chain T [derive Name F _|FS] CL :- get-option "only" _, !, % request this one
43+ if-verbose (coq.say "Derivation" Name "on" T ),
4444 @dropunivs! => std.time (F C) Time,
45- if-verbose (coq.say "Derivation" Name "took" Time),
46- C => chain FS CS,
45+ if-verbose (coq.say "Derivation" Name "on" T " took" Time),
46+ C => chain T FS CS,
4747 std.append C CS CL.
48- chain [derive Name F _|FS] CL :- % all are selected, we can fail
49- if-verbose (coq.say "Derivation" Name),
48+ chain T [derive Name F _|FS] CL :- % all are selected, we can fail
49+ if-verbose (coq.say "Derivation" Name "on" T ),
5050 (pi x\ stop x :- !, fail) => @dropunivs! => std.time (F C) Time, !,
51- if-verbose (coq.say "Derivation" Name "took" Time),
52- C => chain FS CS,
51+ if-verbose (coq.say "Derivation" Name "on" T " took" Time),
52+ C => chain T FS CS,
5353 std.append C CS CL.
54- chain [derive F _ _|FS] CL :-
55- if-verbose (coq.say "Derivation" F "failed, continuing"),
56- chain FS CL.
54+ chain T [derive F _ _|FS] CL :-
55+ if-verbose (coq.say "Derivation" F "on" T " failed, continuing"),
56+ chain T FS CL.
5757
5858pred toposort i:list derive, o:list derive.
5959toposort L SL :-
@@ -85,20 +85,36 @@ topo L Deps SL :-
8585pred export? i:prop, o:prop.
8686export? (export M) (coq.env.export-module M).
8787
88+ pred indt-or-const i:gref.
89+ indt-or-const (indt _).
90+ indt-or-const (const _).
91+
8892pred main i:gref, i:string, o:list prop.
89- main T Prefix CL :-
93+ main T Prefix CL :- get-option "recursive" tt, !,
94+ coq.env.dependencies T _ AllDeps,
95+ coq.gref.set.elements AllDeps AllDepsL,
96+ std.filter AllDepsL indt-or-const Deps,
97+ main.aux Deps Prefix [] CL1,
98+ CL1 => main1 T Prefix CL2,
99+ std.append CL1 CL2 CL.
100+ pred main.aux i:list gref, i:string, i:list prop, o:list prop.
101+ main.aux [] _ X X.
102+ main.aux [T|TS] Prefix Acc CL :-
103+ (pi X\get-option "only" X :- !, fail) => Acc => main T Prefix CL1,
104+ main.aux TS Prefix {std.append CL1 Acc} CL.
105+
106+ main T Prefix CL :- main1 T Prefix CL.
107+
108+ pred main1 i:gref, i:string, o:list prop.
109+ main1 T Prefix CL :-
90110 std.findall (derivation T Prefix _) L,
91111 if (L = [])
92112 (coq.error "no derivation found, did you Import derive.std?")
93113 true,
94114 std.map L (x\r\ x = derivation _ _ r) DL,
95- validate-only DL,
115+ validate-only T DL,
96116 toposort DL SortedDL,
97- ModName is "Derive_Anonymous_" ^ {std.any->string {new_int}},
98- coq.env.begin-module ModName none,
99- chain SortedDL CL,
100- coq.env.end-module ModPath,
101- coq.env.import-module ModPath.
117+ chain T SortedDL CL.
102118
103119pred decl+main i:indt-decl.
104120decl+main DS :- std.do! [
0 commit comments