11/* license: GNU Lesser General Public License Version 2.1 or later */
22/* ------------------------------------------------------------------------- */
33
4+ pred time-solve i:prop.
5+ time-solve P :-
6+ std.time P Time,
7+ if (is-option-active {oTC-time}) (coq.say "[TC] Total resolution time is:" Time) true.
8+
49msolve L N :- !,
5- coq.ltac.all (coq.ltac.open solve) {std.rev L} N.
10+ time-solve (coq.ltac.all (coq.ltac.open solve-aux) {std.rev L} N).
11+
12+ solve A L :- time-solve (solve-aux A L).
13+
614
715pred build-context-clauses i:list prop, o:list prop.
816% Add the section's definition to the given context
@@ -20,48 +28,49 @@ tc-recursive-search Ty Sol :-
2028 std.time (coq.safe-dest-app Ty (global TC) TL',
2129 std.append TL' [Sol] TL,
2230 coq.elpi.predicate {gref->pred-name TC} TL Q, Q) Time,
23- if (is-option-active {oTC-resolution- time}) (coq.say "Instance search" Time) true.
31+ if (is-option-active {oTC-time-instance-search }) (coq.say "[TC] Instance search time is: " Time) true.
2432
2533:if "solve-print-goal"
2634solve (goal Ctx _ Ty _ _) _ :-
2735 coq.say "Ctx" Ctx "Ty" Ty, fail.
2836
29- % solve (goal C _ (prod N Ty F) S _ as _G) _L GL :- !,
37+ pred solve-aux i:goal, o:list sealed-goal.
38+ % solve-aux (goal C _ (prod N Ty F) S _ as _G) _L GL :- !,
3039% @pi-decl N Ty x\
3140% declare-evar [decl x N Ty|C] (Raw x) (F x) (Sol x),
32- % solve (goal [decl x N Ty|C] (Raw x) (F x) (Sol x) []) _L GL,
41+ % solve-aux (goal [decl x N Ty|C] (Raw x) (F x) (Sol x) []) _L GL,
3342% if (Sol x = app [HD, x]) (S = HD) (S = fun N Ty Sol).
34- % solve (goal C _ (prod N Ty F) XX _ as G) _L GL :- !,
43+ % solve-aux (goal C _ (prod N Ty F) XX _ as G) _L GL :- !,
3544% % intros_if_needed Prod C []
3645% (@pi-decl N Ty x\
3746% declare-evar [decl x N Ty|C] (Raw x) (F x) (Sol x),
38- % solve (goal [decl x N Ty|C] (Raw x) (F x) (Sol x) []) _L _,
47+ % solve-aux (goal [decl x N Ty|C] (Raw x) (F x) (Sol x) []) _L _,
3948% coq.safe-dest-app (Sol x) Hd (Args x)),
4049% if (pi x\ last-no-error (Args x) x, std.drop-last 1 (Args x) NewArgs)
4150% (coq.mk-app Hd NewArgs Out, refine Out G GL) (
4251% % coq.say "Not eta" (Sol x) x (fun N Ty Sol),
4352% XX = (fun N Ty Sol)).
44- % solve (goal C _ (prod N _ _ as P) _ A as G) _L GL :- !,
53+ % solve-aux (goal C _ (prod N _ _ as P) _ A as G) _L GL :- !,
4554% declare-evar C T P S',
4655% G' = (goal C T P S' A),
4756% refine (fun N _ _) G' GL1,
48- % coq.ltac.all (coq.ltac.open solve) GL1 _,
57+ % coq.ltac.all (coq.ltac.open solve-aux ) GL1 _,
4958% refine S' G GL.
50- solve (goal C _ (prod N Ty F) _ _ as G) GL :- !,
59+ solve-aux (goal C _ (prod N Ty F) _ _ as G) GL :- !,
5160 (@pi-decl N Ty x\
5261 declare-evar [decl x N Ty|C] (Raw x) (F x) (Sol x),
53- solve (goal [decl x N Ty|C] (Raw x) (F x) (Sol x) []) _),
62+ solve-aux (goal [decl x N Ty|C] (Raw x) (F x) (Sol x) []) _),
5463 if (pi x\
5564 % also check the head does not contain x
5665 coq.safe-dest-app (Sol x) Hd (Args x),
5766 last-no-error (Args x) x,
5867 std.drop-last 1 (Args x) NewArgs)
5968 (coq.mk-app Hd NewArgs Out, refine Out G GL1) (refine (fun N _ _) G GL1),
60- coq.ltac.all (coq.ltac.open solve) GL1 GL.
61- % solve (goal _ _ (prod N _ _) _ _ as G) GL :- !,
69+ coq.ltac.all (coq.ltac.open solve-aux ) GL1 GL.
70+ % solve-aux (goal _ _ (prod N _ _) _ _ as G) GL :- !,
6271% refine (fun N _ _) G GL1,
63- % coq.ltac.all (coq.ltac.open solve) GL1 GL.
64- solve (goal Ctx _ Ty Sol _ as G) GL :-
72+ % coq.ltac.all (coq.ltac.open solve-aux ) GL1 GL.
73+ solve-aux (goal Ctx _ Ty Sol _ as G) GL :-
6574 var Sol,
6675 build-context-clauses Ctx Clauses,
6776 % @redflags! coq.redflags.beta => coq.reduction.lazy.norm Ty Ty1,
@@ -74,7 +83,7 @@ solve (goal Ctx _ Ty Sol _ as G) GL :-
7483 if (is-option-active {oTC-ignore-eta-reduction})
7584 (Proof' = Proof) (coq.reduction.eta-contract Proof Proof'),
7685 std.time (refine Proof' G GL) Refine-Time,
77- if (is-option-active {oTC-time-refine}) (coq.say "Refine Time " Refine-Time) true;
86+ if (is-option-active {oTC-time-refine}) (coq.say "[TC] Refine time is: " Refine-Time) true;
7887 coq.error "illtyped solution:" {coq.term->string Proof}
7988 )
8089 (GL = [seal G]).
0 commit comments