Debian Codegraph @

kernel/univ.mli

raw symbols SCIP
1 (************************************************************************)
2 (* * The Rocq Prover / The Rocq Development Team *)
3 (* v * Copyright INRIA, CNRS and contributors *)
4 (* <O___,, * (see version control and CREDITS file for authors & dates) *)
5 (* \VV/ **************************************************************)
6 (* // * This file is distributed under the terms of the *)
7 (* * GNU Lesser General Public License Version 2.1 *)
8 (* * (see LICENSE file for the text of the license) *)
9 (************************************************************************)
10
11 (** Qualified global universe level *)
12 module UGlobal :
13 sig
14
15 type t
16
17 val make : Names.DirPath.t -> string -> int -> t
18 val repr : t -> Names.DirPath.t * string * int
19 val equal : t -> t -> bool
20 val hash : t -> int
21 val compare : t -> t -> int
22 val to_string : t -> string
23
24 end
25
26 (** Universes. *)
27 module Level :
28 sig
29
30 type t
31 (** Type of universe levels. A universe level is essentially a unique name
32 that will be associated to constraints later on. A level can be local to a
33 definition or global. *)
34
35 val set : t
36 (** The Set universe level. *)
37
38 val is_set : t -> bool
39 (** Is the universe Set? *)
40
41 val compare : t -> t -> int
42 (** Comparison function *)
43
44 val equal : t -> t -> bool
45 (** Equality function *)
46
47 val hash : t -> int
48
49 val hcons : t Hashcons.f
50
51 val make : UGlobal.t -> t
52
53 val raw_pr : t -> Pp.t
54 (** Pretty-printing.
55 When possible you should use name-aware printing. *)
56
57 val pr : t -> Pp.t
58 [@@deprecated "(8.18) Use [UnivNames.pr_with_global_universes] instead if possible, otherwise [raw_pr]."]
59
60 val to_string : t -> string
61 (** Debug printing *)
62
63 val var : int -> t
64
65 val var_index : t -> int option
66
67 val name : t -> UGlobal.t option
68
69 module Set :
70 sig
71 include CSig.USetS with type elt = t
72
73 val pr : (elt -> Pp.t) -> t -> Pp.t
74 (** Pretty-printing *)
75
76 val hcons : t Hashcons.f
77 end
78
79 module Map :
80 sig
81 include CMap.UExtS with type key = t and module Set := Set
82
83 val lunion : 'a t -> 'a t -> 'a t
84 (** [lunion x y] favors the bindings in the first map. *)
85
86 val diff : 'a t -> 'a t -> 'a t
87 (** [diff x y] removes bindings from x that appear in y (whatever the value). *)
88
89 val pr : (key -> Pp.t) -> ('a -> Pp.t) -> 'a t -> Pp.t
90 (** Pretty-printing *)
91 end
92
93 end
94
95 module Universe :
96 sig
97 type t
98 (** Type of universes. A universe is defined as a set of level expressions.
99 A level expression is built from levels and successors of level expressions, i.e.:
100 le ::= l + n, n \in N.
101
102 A universe is said atomic if it consists of a single level expression with
103 no increment, and algebraic otherwise (think the least upper bound of a set of
104 level expressions).
105 *)
106
107 val compare : t -> t -> int
108 (** Comparison function *)
109
110 val equal : t -> t -> bool
111 (** Equality function on formal universes *)
112
113 val hash : t -> int
114 (** Hash function *)
115
116 val hcons : t Hashcons.f
117
118 val make : Level.t -> t
119 (** Create a universe representing the given level. *)
120
121 val maken : Level.t -> int -> t
122 (** Composition of [make] and iterated [super]. *)
123
124 val pr : (Level.t -> Pp.t) -> t -> Pp.t
125 (** Pretty-printing *)
126
127 val raw_pr : t -> Pp.t
128
129 val is_level : t -> bool
130 (** Test if the universe is a level or an algebraic universe. *)
131
132 val is_levels : t -> bool
133 (** Test if the universe is a lub of levels or contains +n's. *)
134
135 val level : t -> Level.t option
136 (** Try to get a level out of a universe, returns [None] if it
137 is an algebraic universe. *)
138
139 val levels : ?init:Level.Set.t -> t -> Level.Set.t
140 (** Get the levels inside the universe, forgetting about increments,
141 and add them to [init] (default empty) *)
142
143 val super : t -> t
144 (** The universe strictly above *)
145
146 val sup : t -> t -> t
147 (** The l.u.b. of 2 universes *)
148
149 val type0 : t
150 (** image of Set in the universes hierarchy *)
151
152 val type1 : t
153 (** the universe of the type of Prop/Set *)
154
155 val is_type0 : t -> bool
156
157 val exists : (Level.t * int -> bool) -> t -> bool
158 val for_all : (Level.t * int -> bool) -> t -> bool
159
160 val repr : t -> (Level.t * int) list
161 val unrepr : (Level.t * int) list -> t
162
163 val map : (Level.t -> Level.t) -> t -> t
164
165 module Set : CSet.ExtS with type elt = t
166 module Map : CMap.ExtS with type key = t and module Set := Set
167
168 end
169
170 (** [univ_level_mem l u] Is l is mentioned in u ? *)
171
172 val univ_level_mem : Level.t -> Universe.t -> bool
173
174 (** [univ_level_rem u v min] removes [u] from [v], resulting in [min]
175 if [v] was exactly [u]. *)
176
177 val univ_level_rem : Level.t -> Universe.t -> Universe.t -> Universe.t
178
179 (** {6 UnivConstraints. } *)
180
181 module UnivConstraint : sig
182 type kind = AcyclicGraph.constraint_type = Lt | Le | Eq
183 val compare_kind : kind -> kind -> int
184 val pr_kind : kind -> Pp.t
185 type t = Level.t * kind * Level.t
186 end
187
188 module UnivConstraints : sig
189 include CSet.ExtS with type elt = UnivConstraint.t
190
191 val pr : (Level.t -> Pp.t) -> t -> Pp.t
192
193 val hcons : t Hashcons.f
194 end
195
196 (** Enforcing UnivConstraints.t. *)
197 type 'a constraint_function = 'a -> 'a -> UnivConstraints.t -> UnivConstraints.t
198
199 val enforce_eq_level : Level.t constraint_function
200 val enforce_leq_level : Level.t constraint_function
201
202 (** Universe contexts (as sets) *)
203
204 (** A set of universes with universe UnivConstraints.t.
205 We linearize the set to a list after typechecking.
206 Beware, representation could change.
207 *)
208
209 module ContextSet :
210 sig
211 type t = Level.Set.t * UnivConstraints.t
212
213 val empty : t
214 val is_empty : t -> bool
215
216 val singleton : Level.t -> t
217 val of_set : Level.Set.t -> t
218
219 val equal : t -> t -> bool
220 val union : t -> t -> t
221
222 val append : t -> t -> t
223 (** Variant of {!union} which is more efficient when the left argument is
224 much smaller than the right one. *)
225
226 val diff : t -> t -> t
227 val add_universe : Level.t -> t -> t
228 val add_constraints : UnivConstraints.t -> t -> t
229
230 val constraints : t -> UnivConstraints.t
231 val levels : t -> Level.Set.t
232
233 val size : t -> int
234 (** The number of universes in the context *)
235
236 val hcons : t Hashcons.f
237
238 val pr : (Level.t -> Pp.t) -> t -> Pp.t
239
240
241 end