Skip to content

Commit e5ece2b

Browse files
committed
Support cumulative definitions
1 parent bdea556 commit e5ece2b

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/rocq_elpi_builtins.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2145,6 +2145,7 @@ Supported attributes:
21452145
- @using! (default: section variables actually used)
21462146
- @univpoly! (default unset)
21472147
- @udecl! (default unset)
2148+
- @udecl-cumul! (default unset)
21482149
- @dropunivs! (default: false, drops all universe constraints from the store after the definition)
21492150
|})))))),
21502151
(fun id body types opaque _ ~depth {options} _ -> grab_global_env__drop_sigma_univs_if_option_is_set options "coq.env.add-const" (fun state ->
@@ -2191,7 +2192,7 @@ Supported attributes:
21912192
let hook = Declare.Hook.make (fun { Declare.Hook.S.uctx = x } -> uctx := Some (UState.context_set x)) in
21922193
(* End hack *)
21932194

2194-
let info = Declare.Info.make ~scope ~kind ~poly ~udecl ~hook () in
2195+
let info = Declare.Info.make ~scope ~kind ~poly ~cumulative:cumul ~udecl ~hook () in
21952196

21962197
let used =
21972198
Univ.Level.Set.union

tests/test_polymorphism.v

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,26 @@ Print test.
2929
(* It's indeed polymorphic and we do get the minimized version *)
3030
End test_explicit.
3131

32+
Module test_explicit2.
33+
Elpi Command test_explicit2.
34+
Elpi Query lp:"
35+
coq.univ.new U,
36+
@keep-alg-univs! => @univpoly-cumul! =>
37+
coq.env.add-indt (record ""test"" (sort (typ U+1)) ""mktest""
38+
(field _ ""foo"" (sort (typ U)) _ \ end-record)) _C.
39+
".
40+
Print test.
41+
(* Record test@{u} : Type@{u+1} := mktest { foo : Type@{u} }. *)
42+
(* u(+ (= for typing) in term, + in type) |= *)
43+
(* It's indeed polymorphic and we do get the minimized version *)
44+
End test_explicit2.
45+
3246
Module test_minimization.
3347
Elpi Command test_minimization.
3448
Elpi Query lp:"
3549
coq.univ.new U,
3650
coq.univ.variable U V,
37-
@keep-alg-univs! => @udecl! [V] ff [] tt => coq.env.add-indt (record ""test"" (sort (typ _)) ""mktest""
51+
@keep-alg-univs! => @udecl-cumul! [(auto V)] ff [] tt => coq.env.add-indt (record ""test"" (sort (typ _)) ""mktest""
3852
(field _ ""foo"" (sort (typ U)) _ \ end-record)) _C.
3953
".
4054
Print test.

0 commit comments

Comments
 (0)