Skip to content

Commit 9ae1653

Browse files
garesFissoreD
andauthored
Fix for new compiler (#692)
Mainly declare types before clauses --------- Co-authored-by: Davide Fissore <[email protected]>
1 parent c9eb00e commit 9ae1653

24 files changed

+140
-56
lines changed

apps/derive/elpi/param1.elpi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
/* ------------------------------------------------------------------------- */
44

55
% Author: Cyril Cohen
6+
pred reali-done i:gref.
7+
8+
:index(3)
9+
pred reali i:term, o:term.
10+
type realiR term -> term -> prop.
611

712
shorten std.{forall, forall2, do!, rev, map2, map}.
813

apps/derive/elpi/param1_functor.elpi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/* map over a container */
22
/* license: GNU Lesser General Public License Version 2.1 or later */
33
/* ------------------------------------------------------------------------- */
4+
pred param1-functor-db i:term, i:term, o:term.
5+
pred param1-functor-for i:inductive, o:gref, o:list bool.
46

57
shorten std.{assert!, do!, length, split-at, drop-last, rev, append}.
68

apps/derive/elpi/param2.elpi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
/* ------------------------------------------------------------------------- */
44

55
% Author: Cyril Cohen
6+
pred param-done i:gref.
7+
:index(3)
8+
pred param i:term, o:term, o:term.
9+
type paramR term -> term -> term -> prop.
610

711
shorten std.{forall, forall2, do!, rev, map2, map}.
812

apps/derive/tests/test_derive.v

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ Inductive rtree A : Type :=
121121
Leaf (n : A) | Node (l : list rtree).
122122

123123
Module XXX.
124-
Elpi derive rtree.
124+
derive list.
125+
derive rtree.
125126
End XXX.
126127

127128
Fail Check XXX.rtree_is_rtree_map.
@@ -161,8 +162,10 @@ Redirect "tmp" Check Pred.Pred_to_Predinv : forall T, Pred T -> Pred.Predinv T.
161162
(* #286 *)
162163
Module Import derive_container.
163164
Unset Implicit Arguments.
165+
Import XXX.
164166
derive
165167
Inductive wimpls {A} `{rtree A} := Kwi (x:A) (y : x = x) : wimpls | Kwa.
168+
166169
End derive_container.
167170
About wimpls.wimpls.
168171
About wimpls.Kwi.

apps/derive/theories/derive/param1.v

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ Elpi Accumulate lp:{{
9292
usage :- coq.error "Usage: derive.param1 <object name>".
9393
}}.
9494
Elpi Typecheck.
95-
9695
Module Export exports.
9796
Elpi derive.param1 eq.
9897
End exports.

apps/tc/elpi/compiler1.elpi

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace tc {
2828
tc.get-full-path Inst ClauseName,
2929
Locality => (
3030
tc.add-tc-db ClauseName Grafting Clause,
31-
tc.add-tc-db _ Grafting (tc.instance SectionPath Inst TC)).
31+
tc.add-tc-db _ Grafting (tc.instance SectionPath Inst TC Locality)).
3232
add-inst.aux Inst _ _ _ :-
3333
@global! => tc.add-tc-db _ _ (tc.banned Inst),
3434
coq.error "Not-added" "TC_solver" "[TC] Not yet able to compile" Inst "...".
@@ -51,7 +51,7 @@ namespace tc {
5151
% TC.AddAllInstances or TC.AddInstances InstName
5252
if (is-local; has-context-deps Inst)
5353
(LocalityStr = "Local")
54-
(LocalityStr = "Global"),
54+
(LocalityStr = "Export"),
5555
add-inst Inst TC LocalityStr Prio.
5656

5757
% [add-inst->db IgnoreClassDepL ForceAdd Inst] compiles and add the Inst to
@@ -61,7 +61,7 @@ namespace tc {
6161
add-inst->db _ tt Inst :- !, add-inst>db.aux Inst.
6262
add-inst->db _ _ Inst :-
6363
tc.banned Inst, !, (coq.warning "tc.banned-inst" "TC-warning" Inst "is tc.banned").
64-
add-inst->db _ _ Inst :- tc.instance _ Inst _, !. % the instance has already been added
64+
add-inst->db _ _ Inst :- tc.instance _ Inst _ _, !. % the instance has already been added
6565
add-inst->db IgnoreClassDepL _ Inst :-
6666
get-class-dependencies Inst Dep,
6767
std.exists Dep (std.mem IgnoreClassDepL), !,
@@ -85,11 +85,19 @@ namespace tc {
8585
(coq.warning "not-inst-nor-tc" "TC-warning" GR "is neither a TC nor a instance")
8686
).
8787

88+
pred build-args i:term, o:list term.
89+
build-args (prod _ _ Bo) [{{0}} | TL] :- !, build-args (Bo _) TL.
90+
build-args _ [{{0}}].
91+
8892
% [remove-inst GR] remove an instance from the DB by replacing it with `dummy`
8993
pred remove-inst i:gref.
9094
remove-inst InstGR :-
9195
tc.get-full-path InstGR ClauseName,
92-
tc.remove-clause ClauseName.
96+
tc.instance _ InstGR ClassGR Locality,
97+
tc.gref->pred-name ClassGR PredName,
98+
coq.env.typeof ClassGR ClassTy,
99+
coq.elpi.predicate PredName {build-args ClassTy} Clause,
100+
tc.remove-clause ClauseName Clause Locality.
93101

94102
pred is-in-path i:string, i:gref.
95103
is-in-path Path GR :-

apps/tc/elpi/modes.elpi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ namespace tc {
6666

6767
pred remove-pending-mode.
6868
remove-pending-mode :-
69-
tc.remove-clause @pending-mode!.
69+
tc.remove-clause @pending-mode! (pending-mode []) [].
7070

7171
pred check-pending-mode-arity i:gref, i:list A.
7272
check-pending-mode-arity GR L :-

apps/tc/elpi/tc_aux.elpi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ namespace tc {
4242
:name "MySectionEndHook"
4343
instances-of-current-section InstsFiltered :-
4444
coq.env.current-section-path SectionPath,
45-
std.findall (tc.instance SectionPath _ _) Insts,
45+
std.findall (tc.instance SectionPath _ _ _) Insts,
4646
coq.env.section SectionVars,
47-
std.map-filter Insts (x\r\ sigma X\ tc.instance _ r _ = x, const X = r, not(std.mem SectionVars X)) InstsFiltered.
47+
std.map-filter Insts (x\r\ sigma X\ tc.instance _ r _ _ = x, const X = r, not(std.mem SectionVars X)) InstsFiltered.
4848

4949
pred is-instance-gr i:gref.
5050
is-instance-gr GR :-
@@ -156,9 +156,9 @@ namespace tc {
156156

157157
pred dummy.
158158

159-
pred remove-clause i:string.
160-
remove-clause ClauseName :-
161-
add-tc-db _ (replace ClauseName) dummy.
159+
pred remove-clause i:string, i:prop, i:list prop.
160+
remove-clause ClauseName P Locality :-
161+
Locality => add-tc-db _ (remove ClauseName) P.
162162

163163
% [section-var->decl.aux L R] auxiliary function for `section-var->decl`
164164
pred section-var->decl.aux i:list constant, o:list prop.

apps/tc/elpi/tc_same_order.elpi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ pred correct_instance_order i:(list gref), i:(list prop).
1212
correct_instance_order [] _.
1313
correct_instance_order [TC | TL] ElpiInst :-
1414
coq.TC.db-for TC CoqInst,
15-
std.map-filter ElpiInst (x\r\ sigma I\ x = tc.instance _ I TC, r = I) ElpiInstTC,
15+
std.map-filter ElpiInst (x\r\ sigma I\ x = tc.instance _ I TC _, r = I) ElpiInstTC,
1616
if (correct_instance_order_aux TC CoqInst ElpiInstTC)
1717
(correct_instance_order TL ElpiInst)
1818
(coq.error "Error in import order\n"
1919
"Expected :" CoqInst "\nFound :" ElpiInstTC).
2020

2121
:name "tc-same-order-main"
2222
main _ :-
23-
std.findall (tc.instance _ _ _) ElpiInst,
23+
std.findall (tc.instance _ _ _ _) ElpiInst,
2424
correct_instance_order {coq.TC.db-tc} ElpiInst.

apps/tc/tests/auto_compile.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ Goal M.B 10. apply _. Qed.
4848
Elpi Query TC.Solver lp:{{
4949
% Small test for instance order
5050
sigma I L\
51-
std.findall (tc.instance _ _ _) I,
52-
std.map-filter I (x\y\ x = tc.instance _ y {{:gref M.B}})
51+
std.findall (tc.instance _ _ _ _) I,
52+
std.map-filter I (x\y\ x = tc.instance _ y {{:gref M.B}} _)
5353
[{{:gref M.W}}, {{:gref M.Y}}, {{:gref M.Z}}].
5454
}}.
5555

0 commit comments

Comments
 (0)