11/* license: GNU Lesser General Public License Version 2.1 or later */
22/* ------------------------------------------------------------------------- */
33
4+ accumulate base.
5+
6+ pred time-solve i:prop.
7+ time-solve P :-
8+ std.time P Time,
9+ if (is-option-active oTC-time) (coq.say "[TC] Total resolution time is:" Time) true.
10+
411msolve L N :- !,
5- coq.ltac.all (coq.ltac.open solve) {std.rev L} N.
12+ time-solve (coq.ltac.all (coq.ltac.open solve-aux) {std.rev L} N).
13+
14+ solve A L :- time-solve (solve-aux A L).
15+
616
717pred build-context-clauses i:list prop, o:list prop.
818% Add the section's definition to the given context
@@ -20,48 +30,49 @@ tc-recursive-search Ty Sol :-
2030 std.time (coq.safe-dest-app Ty (global TC) TL',
2131 std.append TL' [Sol] TL,
2232 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.
33+ if (is-option-active oTC-time-instance-search ) (coq.say "[TC] Instance search time is: " Time) true.
2434
2535:if "solve-print-goal"
2636solve (goal Ctx _ Ty _ _) _ :-
2737 coq.say "Ctx" Ctx "Ty" Ty, fail.
2838
29- % solve (goal C _ (prod N Ty F) S _ as _G) _L GL :- !,
39+ pred solve-aux i:goal, o:list sealed-goal.
40+ % solve-aux (goal C _ (prod N Ty F) S _ as _G) _L GL :- !,
3041% @pi-decl N Ty x\
3142% 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,
43+ % solve-aux (goal [decl x N Ty|C] (Raw x) (F x) (Sol x) []) _L GL,
3344% 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 :- !,
45+ % solve-aux (goal C _ (prod N Ty F) XX _ as G) _L GL :- !,
3546% % intros_if_needed Prod C []
3647% (@pi-decl N Ty x\
3748% 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 _,
49+ % solve-aux (goal [decl x N Ty|C] (Raw x) (F x) (Sol x) []) _L _,
3950% coq.safe-dest-app (Sol x) Hd (Args x)),
4051% if (pi x\ last-no-error (Args x) x, std.drop-last 1 (Args x) NewArgs)
4152% (coq.mk-app Hd NewArgs Out, refine Out G GL) (
4253% % coq.say "Not eta" (Sol x) x (fun N Ty Sol),
4354% XX = (fun N Ty Sol)).
44- % solve (goal C _ (prod N _ _ as P) _ A as G) _L GL :- !,
55+ % solve-aux (goal C _ (prod N _ _ as P) _ A as G) _L GL :- !,
4556% declare-evar C T P S',
4657% G' = (goal C T P S' A),
4758% refine (fun N _ _) G' GL1,
48- % coq.ltac.all (coq.ltac.open solve) GL1 _,
59+ % coq.ltac.all (coq.ltac.open solve-aux ) GL1 _,
4960% refine S' G GL.
50- solve (goal C _ (prod N Ty F) _ _ as G) GL :- !,
61+ solve-aux (goal C _ (prod N Ty F) _ _ as G) GL :- !,
5162 (@pi-decl N Ty x\
5263 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) []) _),
64+ solve-aux (goal [decl x N Ty|C] (Raw x) (F x) (Sol x) []) _),
5465 if (pi x\
5566 % also check the head does not contain x
5667 coq.safe-dest-app (Sol x) Hd (Args x),
5768 last-no-error (Args x) x,
5869 std.drop-last 1 (Args x) NewArgs)
5970 (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 :- !,
71+ coq.ltac.all (coq.ltac.open solve-aux ) GL1 GL.
72+ % solve-aux (goal _ _ (prod N _ _) _ _ as G) GL :- !,
6273% refine (fun N _ _) G GL1,
63- % coq.ltac.all (coq.ltac.open solve) GL1 GL.
64- solve (goal Ctx _ Ty Sol _ as G) GL :-
74+ % coq.ltac.all (coq.ltac.open solve-aux ) GL1 GL.
75+ solve-aux (goal Ctx _ Ty Sol _ as G) GL :-
6576 var Sol,
6677 build-context-clauses Ctx Clauses,
6778 % @redflags! coq.redflags.beta => coq.reduction.lazy.norm Ty Ty1,
@@ -71,10 +82,10 @@ solve (goal Ctx _ Ty Sol _ as G) GL :-
7182 % coq.say "Solution " X "end" X' "caio",
7283 % std.assert! (ground_term X') "solution not complete",
7384 % (pi F\ (copy (fun _ _ x\ (app [F, x])) F :- !)) => copy X X',
74- if (is-option-active { oTC-ignore-eta-reduction} )
85+ if (is-option-active oTC-ignore-eta-reduction)
7586 (Proof' = Proof) (coq.reduction.eta-contract Proof Proof'),
7687 std.time (refine Proof' G GL) Refine-Time,
77- if (is-option-active { oTC-time-refine} ) (coq.say "Refine Time " Refine-Time) true;
88+ if (is-option-active oTC-time-refine) (coq.say "[TC] Refine time is: " Refine-Time) true;
7889 coq.error "illtyped solution:" {coq.term->string Proof}
7990 )
8091 (GL = [seal G]).
0 commit comments