Debian Codegraph @

test-suite/output/unidecls.v

raw
1 (* -*- coq-prog-args: ("-noinit" "-top" "unidecls"); -*- *)
2 Require Import Notations Ltac.
3 Notation "a -> b" := (forall _:a, b).
4
5 Set Printing Universes.
6
7 Inductive nat := O | S : nat -> nat.
8
9 Module decls.
10 Universes a b.
11 End decls.
12
13 Universe a.
14
15 Constraint a < decls.a.
16
17 Print Universes.
18
19 (** These are different universes *)
20 Check Type@{a}.
21 Check Type@{decls.a}.
22
23 Check Type@{decls.b}.
24
25 Fail Check Type@{decls.c}.
26
27 Fail Check Type@{i}.
28 Universe foo.
29 Module Foo.
30 (** Already declared globaly: but universe names are scoped at the module level *)
31 Universe foo.
32 Universe bar.
33
34 Check Type@{Foo.foo}.
35 Definition bar := O.
36 End Foo.
37
38 (** Already declared in the module *)
39 Universe bar.
40
41 (** Accessible outside the module: universe declarations are global *)
42 Check Type@{bar}.
43 Check Type@{Foo.bar}.
44
45 Check Type@{Foo.foo}.
46 (** The same *)
47 Check Type@{foo}.
48 Check Type@{unidecls.foo}.
49
50 Universe secfoo.
51 Section Foo'.
52 Fail Universe secfoo.
53 Universe secfoo2.
54 Fail Check Type@{Foo'.secfoo2}.
55 Check Type@{secfoo2}.
56 Constraint secfoo2 < a.
57 End Foo'.
58
59 Check Type@{secfoo2}.
60 Fail Check eq_refl : Type@{secfoo2} = Type@{a}.
61
62 (** Below, u and v are global, fixed universes *)
63 Module Type Arg.
64 Universe u.
65 Parameter T: Type@{u}.
66 End Arg.
67
68 Module Fn(A : Arg).
69 Universes v.
70
71 (* univ names are not substitutive *)
72 Fail Check Type@{A.u}.
73 Check Type@{Arg.u}.
74 Constraint Arg.u < v.
75
76 Definition foo : Type@{v} := nat.
77 Definition bar : Type@{Arg.u} := nat.
78
79 Definition foo'(A : Type@{v}) : Type@{Arg.u}. Fail exact A. Abort.
80 End Fn.
81
82 Module ArgImpl : Arg.
83 Definition T := nat.
84 End ArgImpl.
85
86 Module ArgImpl2 : Arg.
87 Definition T := nat.
88 End ArgImpl2.
89
90 (** Two applications of the functor result in the exact same universes *)
91 Module FnApp := Fn(ArgImpl).
92
93 Fail Check Type@{FnApp.v}.
94 Check Type@{Fn.v}.
95 Check FnApp.foo.
96 Check FnApp.bar.
97
98 (* "module M : T" does not produce a universe M.u from T.u *)
99 Fail Check Type@{ArgImpl.u}.
100
101 Module FnApp2 := Fn(ArgImpl).
102 Check FnApp2.foo.
103 Check FnApp2.bar.
104
105 Set Universe Polymorphism.
106
107 Section PS.
108 Universe poly.
109
110 Definition id (A : Type@{poly}) (a : A) : A := a.
111 End PS.
112 (** The universe is polymorphic and discharged, does not persist *)
113 Fail Check Type@{poly}.
114
115 Print Universes.
116 Check id nat.
117 Check id@{Set}.