Skip to content

Commit b587ac3

Browse files
committed
add index to primitive-projection?
1 parent e638b58 commit b587ac3

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

elpi/coq-lib.elpi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ coq.term->gref (global GR) GR :- !.
510510
coq.term->gref (pglobal GR _) GR :- !.
511511
coq.term->gref (app [Hd|_]) GR :- !, coq.term->gref Hd GR.
512512
coq.term->gref (let _ _ T x\x) GR :- !, coq.term->gref T GR.
513-
coq.term->gref (primitive (proj Proj _)) (const C) :- coq.env.primitive-projection? Proj C, !.
513+
coq.term->gref (primitive (proj Proj _)) (const C) :- coq.env.primitive-projection? Proj C _, !.
514514
:name "term->gref:fail"
515515
coq.term->gref Term _ :-
516516
fatal-error-w-data "term->gref: input has no global reference" Term.

src/rocq_elpi_builtins.ml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2363,14 +2363,15 @@ denote the same x as before.|};
23632363
MLCode(Pred("coq.env.primitive-projection?",
23642364
InOut(B.ioarg projection, "Projection",
23652365
InOut(B.ioarg constant, "Compatibility constant",
2366-
Read(global, "Relates a primitive projection to its compatibility constant."))),
2367-
(fun p c ~depth coq_context _ _ ->
2366+
Out(int, "Index",
2367+
Read(global, "Relates a primitive projection to its compatibility constant and its index in the record.")))),
2368+
(fun p c _ ~depth coq_context _ _ ->
23682369
match p, c with
23692370
| _, Data (Variable c) -> raise No_clause
23702371
| Data p, Data (Constant c) ->
2371-
if Constant.equal (Projection.constant p) c then ?: None +? None else raise No_clause
2372+
if Constant.equal (Projection.constant p) c then ?: None +? None +! Names.Projection.(arg p + npars p) else raise No_clause
23722373
| NoData, NoData -> U.type_error "coq.env.primitive-projection?: got no input data"
2373-
| Data p, NoData -> ?: None +! (Constant (Projection.constant p))
2374+
| Data p, NoData -> ?: None +! (Constant (Projection.constant p)) +! Names.Projection.(arg p + npars p)
23742375
| NoData, Data (Constant c) ->
23752376
(match Environ.constant_opt_value_in coq_context.env (UVars.in_punivs c) with
23762377
| None -> raise No_clause
@@ -2381,7 +2382,9 @@ denote the same x as before.|};
23812382
| App (hd, _) -> get_proj hd
23822383
| Proj (p, _, _) -> p
23832384
| _ -> raise No_clause
2384-
in !: (get_proj p) +? None))),
2385+
in
2386+
let p = get_proj p in
2387+
!: p +? None +! Names.Projection.(arg p + npars p)))),
23852388
DocAbove);
23862389

23872390
LPDoc "-- Sorts (and their universe level, if applicable) ----------------";

tests/test_HOAS.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ Module P''.
221221

222222
Elpi Query lp:{{
223223
app[primitive (proj P _) | _] = {{X.(proj1 _)}},
224-
coq.env.primitive-projection? P C,
224+
coq.env.primitive-projection? P C _,
225225
global (const C) = {{proj1}}.
226226
}}.
227227

0 commit comments

Comments
 (0)