Debian Codegraph @

test-suite/modules/polymorphism.v

raw
1 Set Universe Polymorphism.
2
3 (** Tests for module subtyping of polymorphic terms *)
4
5 Module Type S.
6
7 Section Foo.
8
9 Universes i j.
10 Constraint i <= j.
11
12 Parameter foo : Type@{i} -> Type@{j}.
13
14 End Foo.
15
16 End S.
17
18 (** Same constraints *)
19
20 Module OK_1.
21
22 Definition foo@{i j} (A : Type@{i}) : Type@{j} := A.
23
24 End OK_1.
25
26 Module OK_1_Test : S := OK_1.
27
28 (** More general constraints *)
29
30 Module OK_2.
31
32 Inductive X@{i} : Type@{i} :=.
33 Definition foo@{i j} (A : Type@{i}) : Type@{j} := X@{j}.
34
35 End OK_2.
36
37 Module OK_2_Test : S := OK_2.
38
39 (** Wrong instance length *)
40
41 Module KO_1.
42
43 Definition foo@{i} (A : Type@{i}) : Type@{i} := A.
44
45 End KO_1.
46
47 Fail Module KO_Test_1 : S := KO_1.
48
49 (** Less general constraints *)
50
51 Module KO_2.
52
53 Section Foo.
54
55 Universe i j.
56 Constraint i < j.
57
58 Definition foo (A : Type@{i}) : Type@{j} := A.
59
60 End Foo.
61
62 End KO_2.
63
64 Fail Module KO_Test_2 : S := KO_2.
65
66 (** Less general constraints *)
67
68 Module KO_3.
69
70 Section Foo.
71
72 Universe i j.
73 Constraint i = j.
74
75 Definition foo (A : Type@{i}) : Type@{j} := A.
76
77 End Foo.
78
79 End KO_3.
80
81 Fail Module KO_Test_3 : S := KO_3.