Debian Codegraph @

tests/test_module_type_subst.v

raw
1 From elpi Require Import elpi.
2
3 (* Test that Elpi database clauses are correctly substituted when a
4 module type is sealed into a concrete module, per issue #989. *)
5
6 Elpi Db known.db lp:{{
7 pred known o:gref.
8 }}.
9
10 Elpi Command register.
11 Elpi Accumulate Db known.db.
12 Elpi Accumulate lp:{{
13 main [str S] :- coq.locate S GR,
14 coq.elpi.accumulate _ "known.db" (clause _ _ (known GR)).
15 }}.
16
17 Elpi Command check.
18 Elpi Accumulate Db known.db.
19 Elpi Accumulate lp:{{
20 main [str S] :-
21 coq.locate S GR,
22 std.assert! (known GR) "gref not registered after substitution".
23 }}.
24
25 (* Also check that sealing via a functor-parameter signature works:
26 inside the functor body, the parameter's gref is known. *)
27 Module Type DEP_SIG.
28 Parameter dep : nat.
29 Elpi register "dep".
30 End DEP_SIG.
31
32 Module F (D : DEP_SIG).
33 Import D.
34 Elpi check "dep".
35 End F.
36
37 (* Register an axiom inside a module type, then seal and verify the
38 clause refers to the sealed module's definition rather than the
39 stale module-type axiom. *)
40 Module Type MT.
41 Parameter bar : nat.
42 Elpi register "bar".
43 End MT.
44
45 Module M : MT.
46 Definition bar := 42.
47 Fail Elpi check "bar".
48 End M.
49
50 Import M.
51 Elpi check "bar".
52