Debian Codegraph @

kernel/constr.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 (** This file defines the most important datatype of Rocq, namely kernel terms,
12 as well as a handful of generic manipulation functions. *)
13
14 open Names
15
16 (** {6 Simply type aliases } *)
17 type pconstant = Constant.t UVars.puniverses
18 type pinductive = inductive UVars.puniverses
19 type pconstructor = constructor UVars.puniverses
20
21 (** {6 Existential variables } *)
22 type metavariable = int
23
24 (** {6 Case annotation } *)
25 type case_style = LetStyle | IfStyle | LetPatternStyle | MatchStyle
26 | RegularStyle (** infer printing form from number of constructor *)
27 type case_printing =
28 { style : case_style }
29
30 (* INVARIANT:
31 * - Array.length ci_cstr_ndecls = Array.length ci_cstr_nargs
32 * - forall (i : 0 .. pred (Array.length ci_cstr_ndecls)),
33 * ci_cstr_ndecls.(i) >= ci_cstr_nargs.(i)
34 *)
35 type case_info =
36 { ci_ind : inductive; (* inductive type to which belongs the value that is being matched *)
37 ci_npar : int; (* number of parameters of the above inductive type *)
38 ci_cstr_ndecls : int array; (* For each constructor, the corresponding integer determines
39 the number of values that can be bound in a match-construct.
40 NOTE: parameters of the inductive type are therefore excluded from the count *)
41 ci_cstr_nargs : int array; (* for each constructor, the corresponding integers determines
42 the number of values that can be applied to the constructor,
43 in addition to the parameters of the related inductive type
44 NOTE: "lets" are therefore excluded from the count
45 NOTE: parameters of the inductive type are also excluded from the count *)
46 ci_pp_info : case_printing (* not interpreted by the kernel *)
47 }
48
49 (** {6 The type of constructions } *)
50
51 type t
52 type constr = t
53 (** [types] is the same as [constr] but is intended to be used for
54 documentation to indicate that such or such function specifically works
55 with {e types} (i.e. terms of type a sort).
56 (Rem:plurial form since [type] is a reserved ML keyword) *)
57
58 type types = constr
59
60 (** {5 Functions for dealing with constr terms. }
61 The following functions are intended to simplify and to uniform the
62 manipulation of terms. Some of these functions may be overlapped with
63 previous ones. *)
64
65 (** {6 Term constructors. } *)
66
67 (** Constructs a de Bruijn index (DB indices begin at 1) *)
68 val mkRel : int -> constr
69
70 (** Constructs a Variable *)
71 val mkVar : Id.t -> constr
72
73 (** Constructs a machine integer *)
74 val mkInt : Uint63.t -> constr
75
76 (** Constructs an array *)
77 val mkArray : UVars.Instance.t * constr array * constr * types -> constr
78
79 (** Constructs a machine float number *)
80 val mkFloat : Float64.t -> constr
81
82 (** Constructs a machine string. *)
83 val mkString : Pstring.t -> constr
84
85 (** Constructs an patvar named "?n" *)
86 val mkMeta : metavariable -> constr
87
88 (** Constructs an existential variable *)
89 type existential = Evar.t * constr SList.t
90 val mkEvar : existential -> constr
91
92 (** Construct a sort *)
93 val mkSort : Sorts.t -> types
94 val mkSProp : types
95 val mkProp : types
96 val mkSet : types
97 val mkType : Univ.Universe.t -> types
98
99
100 (** This defines the strategy to use for verifiying a Cast *)
101 type cast_kind = VMcast | NATIVEcast | DEFAULTcast
102
103 (** Constructs the term [t1::t2], i.e. the term t{_ 1} casted with the
104 type t{_ 2} (that means t2 is declared as the type of t1). *)
105 val mkCast : constr * cast_kind * constr -> constr
106
107 type 'a binder_annot = ('a,Sorts.relevance) Context.pbinder_annot
108
109 (** Constructs the product [(x:t1)t2] *)
110 val mkProd : Name.t binder_annot * types * types -> types
111
112 (** Constructs the abstraction \[x:t{_ 1}\]t{_ 2} *)
113 val mkLambda : Name.t binder_annot * types * constr -> constr
114
115 (** Constructs the product [let x = t1 : t2 in t3] *)
116 val mkLetIn : Name.t binder_annot * constr * types * constr -> constr
117
118 (** [mkApp (f, [|t1; ...; tN|]] constructs the application
119 {%html:(f t<sub>1</sub> ... t<sub>n</sub>)%}
120 {%latex:$(f~t_1\dots f_n)$%}. *)
121 val mkApp : constr * constr array -> constr
122
123 val map_puniverses : ('a -> 'b) -> 'a UVars.puniverses -> 'b UVars.puniverses
124
125 (** Constructs a Constant.t *)
126 val mkConstU : pconstant -> constr
127
128 (** Constructs a projection application *)
129 val mkProj : (Projection.t * Sorts.relevance * constr) -> constr
130
131 (** Inductive types *)
132
133 (** Constructs the ith (co)inductive type of the block named kn *)
134 val mkIndU : pinductive -> constr
135
136 (** Constructs the jth constructor of the ith (co)inductive type of the
137 block named kn. *)
138 val mkConstructU : pconstructor -> constr
139 val mkConstructUi : pinductive * int -> constr
140
141 (** Make a constant, inductive, constructor or variable. *)
142 val mkRef : GlobRef.t UVars.puniverses -> constr
143
144 module UnsafeMonomorphic : sig
145 val mkConst : Constant.t -> constr
146 val mkInd : inductive -> constr
147 val mkConstruct : constructor -> constr
148 end
149
150 (** Constructs a destructor of inductive type.
151
152 [mkCase ci params p c ac] stand for match [c] as [x] in [I args] return [p] with [ac]
153 presented as describe in [ci].
154
155
156 [p] structure is [args x |- "return clause"]
157
158 [ac]{^ ith} element is ith constructor case presented as
159 {e construct_args |- case_term } *)
160
161 type ('constr,'r) pcase_branch = (Name.t,'r) Context.pbinder_annot array * 'constr
162 (** Names bound by matching the constructor for this branch. *)
163
164 type ('types,'r) pcase_return = ((Name.t,'r) Context.pbinder_annot array * 'types) * 'r
165 (** Names of the indices + name of self *)
166
167 type 'constr pcase_invert =
168 | NoInvert
169 (** Normal reduction: match when the scrutinee is a constructor. *)
170
171 | CaseInvert of { indices : 'constr array; }
172 (** SProp to non SProp only:
173 No constructors or reduce when the indices match those of the unique constructor. *)
174
175 type ('constr, 'types, 'univs, 'r) pcase =
176 case_info * 'univs * 'constr array * ('types,'r) pcase_return * 'constr pcase_invert * 'constr * ('constr,'r) pcase_branch array
177
178 type case_invert = constr pcase_invert
179 type case_return = (types, Sorts.relevance) pcase_return
180 type case_branch = (constr, Sorts.relevance) pcase_branch
181 type case = (constr, types, UVars.Instance.t, Sorts.relevance) pcase
182
183 val mkCase : case -> constr
184
185 (** If [recindxs = [|i1,...in|]]
186 [funnames = [|f1,.....fn|]]
187 [typarray = [|t1,...tn|]]
188 [bodies = [|b1,.....bn|]]
189 then [mkFix ((recindxs,i), funnames, typarray, bodies) ]
190 constructs the {% $ %}i{% $ %}th function of the block (counting from 0)
191
192 [Fixpoint f1 [ctx1] = b1
193 with f2 [ctx2] = b2
194 ...
195 with fn [ctxn] = bn.]
196
197 where the length of the {% $ %}j{% $ %}th context is {% $ %}ij{% $ %}.
198 *)
199 type ('constr, 'types, 'r) prec_declaration =
200 (Name.t, 'r) Context.pbinder_annot array * 'types array * 'constr array
201 type ('constr, 'types, 'r) pfixpoint =
202 (int array * int) * ('constr, 'types, 'r) prec_declaration
203 (** The array of [int]'s tells for each component of the array of
204 mutual fixpoints the number of lambdas to skip before finding the
205 recursive argument (e.g., value is 2 in "fix f (x:A) (y:=t) (z:B)
206 (v:=u) (w:I) {struct w}"), telling to skip x and z and that w is
207 the recursive argument); The second component [int] tells which
208 component of the block is returned *)
209
210 type ('constr, 'types, 'r) pcofixpoint =
211 int * ('constr, 'types, 'r) prec_declaration
212 (** The component [int] tells which component of the block of
213 cofixpoint is returned *)
214
215 type rec_declaration = (constr, types, Sorts.relevance) prec_declaration
216
217 type fixpoint = (constr, types, Sorts.relevance) pfixpoint
218 val mkFix : fixpoint -> constr
219
220 (** If [funnames = [|f1,.....fn|]]
221 [typarray = [|t1,...tn|]]
222 [bodies = [b1,.....bn]]
223 then [mkCoFix (i, (funnames, typarray, bodies))]
224 constructs the ith function of the block
225
226 [CoFixpoint f1 = b1
227 with f2 = b2
228 ...
229 with fn = bn.]
230 *)
231 type cofixpoint = (constr, types, Sorts.relevance) pcofixpoint
232 val mkCoFix : cofixpoint -> constr
233
234
235 (** {6 Concrete type for making pattern-matching. } *)
236
237 (** [constr list] is an instance matching definitional [named_context] in
238 the same order (i.e. last argument first) *)
239 type 'constr pexistential = Evar.t * 'constr SList.t
240
241 type ('constr, 'types, 'sort, 'univs, 'r) kind_of_term =
242 | Rel of int
243 (** Gallina-variable introduced by [forall], [fun], [let-in], [fix], or [cofix]. *)
244 | Var of Id.t
245 (** Gallina-variable that was introduced by Vernacular-command that
246 extends the local context of the currently open section (i.e.
247 [Variable] or [Let]). *)
248 | Meta of metavariable
249 | Evar of 'constr pexistential
250 | Sort of 'sort
251 | Cast of 'constr * cast_kind * 'types
252 | Prod of (Name.t,'r) Context.pbinder_annot * 'types * 'types
253 (** Concrete syntax ["forall A:B,C"] is represented as [Prod (A,B,C)]. *)
254 | Lambda of (Name.t,'r) Context.pbinder_annot * 'types * 'constr
255 (** Concrete syntax ["fun A:B => C"] is represented as [Lambda (A,B,C)]. *)
256 | LetIn of (Name.t,'r) Context.pbinder_annot * 'constr * 'types * 'constr
257 (** Concrete syntax ["let A:C := B in D"] is represented as [LetIn (A,B,C,D)]. *)
258 | App of 'constr * 'constr array
259 (** Concrete syntax ["(F P1 P2 ... Pn)"] is represented as [App (F, [|P1; P2; ...; Pn|])].
260 The {!mkApp} constructor also enforces the following invariant:
261 - [F] itself is not {!App}
262 - and [[|P1;..;Pn|]] is not empty. *)
263 | Const of (Constant.t * 'univs)
264 (** Gallina-variable that was introduced by Vernacular-command that
265 extends the global environment (i.e. [Parameter], or [Axiom], or
266 [Definition], or [Theorem], or [Symbol] etc.) *)
267 | Ind of (inductive * 'univs)
268 (** A name of an inductive type defined by [Variant], [Inductive] or
269 [Record] Vernacular-commands. *)
270 | Construct of (constructor * 'univs)
271 (** A constructor of an inductive type defined by [Variant],
272 [Inductive] or [Record] Vernacular-commands. *)
273 | Case of case_info * 'univs * 'constr array * ('types,'r) pcase_return * 'constr pcase_invert * 'constr * ('constr,'r) pcase_branch array
274 (** [Case (ci,u,params,p,iv,c,brs)] is a [match c return p with brs]
275 expression. [c] lives in inductive [ci.ci_ind] at universe
276 instance [u] and parameters [params]. If this match has case
277 inversion (ie match on a 1 constructor SProp inductive with
278 proof relevant return type) the indices are in [iv].
279
280 The names in [p] are the names of the bound indices and
281 inductive value (ie the [in] and [as] clauses).
282
283 The names in the [brs] are the names of the variables bound in the respective branch. *)
284 | Fix of ('constr, 'types, 'r) pfixpoint
285 | CoFix of ('constr, 'types, 'r) pcofixpoint
286 | Proj of Projection.t * 'r * 'constr
287 (** The relevance is the relevance of the whole term *)
288 | Int of Uint63.t
289 | Float of Float64.t
290 | String of Pstring.t
291 | Array of 'univs * 'constr array * 'constr * 'types
292 (** [Array (u,vals,def,t)] is an array of [vals] in type [t] with default value [def].
293 [u] is a universe containing [t]. *)
294
295 (** User view of [constr]. For [App], it is ensured there is at
296 least one argument and the function is not itself an applicative
297 term *)
298
299 val kind : constr -> (constr, types, Sorts.t, UVars.Instance.t, Sorts.relevance) kind_of_term
300 val of_kind : (constr, types, Sorts.t, UVars.Instance.t, Sorts.relevance) kind_of_term -> constr
301
302 val kind_nocast_gen : ('v -> ('v, 'v, 'sort, 'univs, 'r) kind_of_term) ->
303 ('v -> ('v, 'v, 'sort, 'univs, 'r) kind_of_term)
304
305 val kind_nocast : constr -> (constr, types, Sorts.t, UVars.Instance.t, Sorts.relevance) kind_of_term
306
307 (** {6 Simple case analysis} *)
308 val isRel : constr -> bool
309 val isRelN : int -> constr -> bool
310 val isVar : constr -> bool
311 val isVarId : Id.t -> constr -> bool
312 val isRef : constr -> bool
313 val isInd : constr -> bool
314 val isEvar : constr -> bool
315 val isMeta : constr -> bool
316 val isEvar_or_Meta : constr -> bool
317 val isSort : constr -> bool
318 val isCast : constr -> bool
319 val isApp : constr -> bool
320 val isLambda : constr -> bool
321 val isLetIn : constr -> bool
322 val isProd : constr -> bool
323 val isConst : constr -> bool
324 val isConstruct : constr -> bool
325 val isFix : constr -> bool
326 val isCoFix : constr -> bool
327 val isCase : constr -> bool
328 val isProj : constr -> bool
329
330 val is_Prop : constr -> bool
331 val is_Set : constr -> bool
332 val isprop : constr -> bool
333 val is_Type : constr -> bool
334 val iskind : constr -> bool
335 val is_small : Sorts.t -> bool
336
337 (** {6 Term destructors } *)
338 (** Destructor operations are partial functions and
339 @raise DestKO if the term has not the expected form. *)
340
341 exception DestKO
342
343 (** Destructs a de Bruijn index *)
344 val destRel : constr -> int
345
346 (** Destructs an existential variable *)
347 val destMeta : constr -> metavariable
348
349 (** Destructs a variable *)
350 val destVar : constr -> Id.t
351
352 (** Destructs a sort. [is_Prop] recognizes the sort [Prop], whether
353 [isprop] recognizes both [Prop] and [Set]. *)
354 val destSort : constr -> Sorts.t
355
356 (** Destructs a casted term *)
357 val destCast : constr -> constr * cast_kind * constr
358
359 (** Destructs the product {% $ %}(x:t_1)t_2{% $ %} *)
360 val destProd : types -> Name.t binder_annot * types * types
361
362 (** Destructs the abstraction {% $ %}[x:t_1]t_2{% $ %} *)
363 val destLambda : constr -> Name.t binder_annot * types * constr
364
365 (** Destructs the let {% $ %}[x:=b:t_1]t_2{% $ %} *)
366 val destLetIn : constr -> Name.t binder_annot * constr * types * constr
367
368 (** Destructs an application *)
369 val destApp : constr -> constr * constr array
370
371 (** Decompose any term as an applicative term; the list of args can be empty *)
372 val decompose_app_list : constr -> constr * constr list
373
374 (** Same as [decompose_app], but returns an array. *)
375 val decompose_app : constr -> constr * constr array
376
377 (** Destructs a constant *)
378 val destConst : constr -> Constant.t UVars.puniverses
379
380 (** Destructs an existential variable *)
381 val destEvar : constr -> existential
382
383 (** Destructs a (co)inductive type *)
384 val destInd : constr -> inductive UVars.puniverses
385
386 (** Destructs a constructor *)
387 val destConstruct : constr -> constructor UVars.puniverses
388
389 (** Destructs a [match c as x in I args return P with ... |
390 Ci(...yij...) => ti | ... end] (or [let (..y1i..) := c as x in I args
391 return P in t1], or [if c then t1 else t2])
392 @return [(info,c,fun args x => P,[|...|fun yij => ti| ...|])]
393 where [info] is pretty-printing information *)
394 val destCase : constr -> case
395
396 (** Destructs a projection *)
397 val destProj : constr -> Projection.t * Sorts.relevance * constr
398
399 (** Destructs the {% $ %}i{% $ %}th function of the block
400 [Fixpoint f{_ 1} ctx{_ 1} = b{_ 1}
401 with f{_ 2} ctx{_ 2} = b{_ 2}
402 ...
403 with f{_ n} ctx{_ n} = b{_ n}],
404 where the length of the {% $ %}j{% $ %}th context is {% $ %}ij{% $ %}.
405 *)
406 val destFix : constr -> fixpoint
407
408 val destCoFix : constr -> cofixpoint
409
410 val destRef : constr -> GlobRef.t UVars.puniverses
411
412 (** {6 Equality} *)
413
414 (** [equal a b] is true if [a] equals [b] modulo alpha, casts,
415 and application grouping *)
416 val equal : constr -> constr -> bool
417
418 (** [eq_constr_univs u a b] is [true] if [a] equals [b] modulo alpha, casts,
419 application grouping and the universe equalities in [u]. *)
420 val eq_constr_univs : UGraph.t -> constr -> constr -> bool
421
422 (** [leq_constr_univs u a b] is [true] if [a] is convertible to [b] modulo
423 alpha, casts, application grouping and the universe inequalities in [u]. *)
424 val leq_constr_univs : UGraph.t -> constr -> constr -> bool
425
426 (** [eq_constr_univs a b] [true, c] if [a] equals [b] modulo alpha, casts,
427 application grouping and ignoring universe instances. *)
428 val eq_constr_nounivs : constr -> constr -> bool
429
430 (** Total ordering compatible with [equal] *)
431 val compare : constr -> constr -> int
432
433 (** {6 Extension of Context with declarations on constr} *)
434
435 type rel_declaration = (constr, types, Sorts.relevance) Context.Rel.Declaration.pt
436 type named_declaration = (constr, types, Sorts.relevance) Context.Named.Declaration.pt
437 type compacted_declaration = (constr, types, Sorts.relevance) Context.Compacted.Declaration.pt
438 type rel_context = rel_declaration list
439 type named_context = named_declaration list
440 type compacted_context = compacted_declaration list
441
442 (** {6 Relocation and substitution } *)
443
444 (** [exliftn el c] lifts [c] with lifting [el] *)
445 val exliftn : Esubst.lift -> constr -> constr
446
447 (** [liftn n k c] lifts by [n] indexes above or equal to [k] in [c] *)
448 val liftn : int -> int -> constr -> constr
449
450 (** [lift n c] lifts by [n] the positive indexes in [c] *)
451 val lift : int -> constr -> constr
452
453 (** {6 Functionals working on expressions canonically abstracted over
454 a local context (possibly with let-ins)} *)
455
456 (** [map_branches f br] maps [f] on the immediate subterms of an array
457 of "match" branches [br] in canonical eta-let-expanded form; it is
458 not recursive and the order with which subterms are processed is
459 not specified; it preserves sharing; the immediate subterms are the
460 types and possibly terms occurring in the context of each branch as
461 well as the body of each branch *)
462
463 val map_branches : (constr -> constr) -> case_branch array -> case_branch array
464
465 (** [map_return_predicate f p] maps [f] on the immediate subterms of a
466 return predicate of a "match" in canonical eta-let-expanded form;
467 it is not recursive and the order with which subterms are processed
468 is not specified; it preserves sharing; the immediate subterms are
469 the types and possibly terms occurring in the context of each
470 branch as well as the body of the predicate *)
471
472 val map_return_predicate : (constr -> constr) -> case_return -> case_return
473
474 (** [map_branches_with_binders f br] maps [f] on the immediate
475 subterms of an array of "match" branches [br] in canonical
476 eta-let-expanded form; it carries an extra data [n] (typically a
477 lift index) which is processed by [g] (which typically adds 1 to
478 [n]) at each binder traversal; it is not recursive and the order
479 with which subterms are processed is not specified; it preserves
480 sharing; the immediate subterms are the types and possibly terms
481 occurring in the context of the branch as well as the body of the
482 branch *)
483
484 val map_branches_with_binders : ('a -> 'a) -> ('a -> constr -> constr) -> 'a -> case_branch array -> case_branch array
485
486 (** [map_return_predicate_with_binders f p] maps [f] on the immediate
487 subterms of a return predicate of a "match" in canonical
488 eta-let-expanded form; it carries an extra data [n] (typically a
489 lift index) which is processed by [g] (which typically adds 1 to
490 [n]) at each binder traversal; it is not recursive and the order
491 with which subterms are processed is not specified; it preserves
492 sharing; the immediate subterms are the types and possibly terms
493 occurring in the context of each branch as well as the body of the
494 predicate *)
495
496 val map_return_predicate_with_binders : ('a -> 'a) -> ('a -> constr -> constr) -> 'a -> case_return -> case_return
497
498 (** {6 Functionals working on the immediate subterm of a construction } *)
499
500 (** [fold f acc c] folds [f] on the immediate subterms of [c]
501 starting from [acc] and proceeding from left to right according to
502 the usual representation of the constructions; it is not recursive *)
503
504 val fold : ('a -> constr -> 'a) -> 'a -> constr -> 'a
505
506 val fold_invert : ('a -> 'b -> 'a) -> 'a -> 'b pcase_invert -> 'a
507
508 (** [map f c] maps [f] on the immediate subterms of [c]; it is
509 not recursive and the order with which subterms are processed is
510 not specified *)
511
512 val map : (constr -> constr) -> constr -> constr
513
514 val map_invert : ('a -> 'a) -> 'a pcase_invert -> 'a pcase_invert
515
516 (** Like {!map}, but also has an additional accumulator. *)
517
518 val fold_map : ('a -> constr -> 'a * constr) -> 'a -> constr -> 'a * constr
519
520 val fold_map_invert : ('a -> 'b -> 'a * 'b) ->
521 'a -> 'b pcase_invert -> 'a * 'b pcase_invert
522
523 (** [map_with_binders g f n c] maps [f n] on the immediate
524 subterms of [c]; it carries an extra data [n] (typically a lift
525 index) which is processed by [g] (which typically add 1 to [n]) at
526 each binder traversal; it is not recursive and the order with which
527 subterms are processed is not specified *)
528
529 val map_with_binders :
530 ('a -> 'a) -> ('a -> constr -> constr) -> 'a -> constr -> constr
531
532 (** [iter f c] iters [f] on the immediate subterms of [c]; it is
533 not recursive and the order with which subterms are processed is
534 not specified *)
535
536 val iter : (constr -> unit) -> constr -> unit
537
538 val iter_invert : ('a -> unit) -> 'a pcase_invert -> unit
539
540 (** [iter_with_binders g f n c] iters [f n] on the immediate
541 subterms of [c]; it carries an extra data [n] (typically a lift
542 index) which is processed by [g] (which typically add 1 to [n]) at
543 each binder traversal; it is not recursive and the order with which
544 subterms are processed is not specified *)
545
546 val iter_with_binders :
547 ('a -> 'a) -> ('a -> constr -> unit) -> 'a -> constr -> unit
548
549 (** [iter_with_binders g f n c] iters [f n] on the immediate
550 subterms of [c]; it carries an extra data [n] (typically a lift
551 index) which is processed by [g] (which typically add 1 to [n]) at
552 each binder traversal; it is not recursive and the order with which
553 subterms are processed is not specified *)
554
555 val fold_constr_with_binders :
556 ('a -> 'a) -> ('a -> 'b -> constr -> 'b) -> 'a -> 'b -> constr -> 'b
557
558 type 'constr constr_compare_fn = int -> 'constr -> 'constr -> bool
559
560 (** [compare_head f c1 c2] compare [c1] and [c2] using [f] to compare
561 the immediate subterms of [c1] of [c2] if needed; Cast's, binders
562 name and Cases annotations are not taken into account *)
563
564 val compare_head : (existential -> existential -> bool) -> constr constr_compare_fn -> constr constr_compare_fn
565
566 (** Convert a global reference applied to 2 instances. The int says
567 how many arguments are given (as we can only use cumulativity for
568 fully applied inductives/constructors) .*)
569 type 'univs instance_compare_fn = (GlobRef.t * int) option ->
570 'univs -> 'univs -> bool
571
572 (** [compare_head_gen u s f c1 c2] compare [c1] and [c2] using [f] to
573 compare the immediate subterms of [c1] of [c2] if needed, [u] to
574 compare universe instances, [s] to compare sorts; Cast's, binders
575 name and Cases annotations are not taken into account *)
576
577 val compare_head_gen : UVars.Instance.t instance_compare_fn ->
578 (Sorts.t -> Sorts.t -> bool) ->
579 (existential -> existential -> bool) ->
580 constr constr_compare_fn ->
581 constr constr_compare_fn
582
583 val compare_head_gen_leq_with :
584 ('v -> ('v, 'v, 'sort, 'univs, 'r) kind_of_term) ->
585 ('v -> ('v, 'v, 'sort, 'univs, 'r) kind_of_term) ->
586 'univs instance_compare_fn ->
587 ('sort -> 'sort -> bool) ->
588 ('v pexistential -> 'v pexistential -> bool) ->
589 'v constr_compare_fn ->
590 'v constr_compare_fn ->
591 'v constr_compare_fn
592
593 (** [compare_head_gen_with k1 k2 u s f c1 c2] compares [c1] and [c2]
594 like [compare_head_gen u s f c1 c2], except that [k1] (resp. [k2])
595 is used,rather than {!kind}, to expose the immediate subterms of
596 [c1] (resp. [c2]). *)
597 val compare_head_gen_with :
598 ('v -> ('v, 'v, 'sort, 'univs, 'r) kind_of_term) ->
599 ('v -> ('v, 'v, 'sort, 'univs, 'r) kind_of_term) ->
600 'univs instance_compare_fn ->
601 ('sort -> 'sort -> bool) ->
602 ('v pexistential -> 'v pexistential -> bool) ->
603 'v constr_compare_fn ->
604 'v constr_compare_fn
605
606 (** [compare_head_gen_leq u s f fle c1 c2] compare [c1] and [c2] using
607 [f] to compare the immediate subterms of [c1] of [c2] for
608 conversion, [fle] for cumulativity, [u] to compare universe
609 instances (the first boolean tells if they belong to a Constant.t),
610 [s] to compare sorts for for subtyping; Cast's, binders name and
611 Cases annotations are not taken into account *)
612
613 val compare_head_gen_leq : UVars.Instance.t instance_compare_fn ->
614 (Sorts.t -> Sorts.t -> bool) ->
615 (existential -> existential -> bool) ->
616 constr constr_compare_fn ->
617 constr constr_compare_fn ->
618 constr constr_compare_fn
619
620 val eq_invert : ('a -> 'a -> bool)
621 -> 'a pcase_invert -> 'a pcase_invert -> bool
622
623 (** {6 Hashconsing} *)
624
625 val hash : constr -> int
626
627 (*********************************************************************)
628
629 module GenHCons(C:sig
630 type t
631 val kind : t -> (t, t, Sorts.t, UVars.Instance.t, Sorts.relevance) kind_of_term
632 val self : t -> constr
633 val refcount : t -> int
634
635 val via_hconstr : bool
636
637 module Tbl : sig
638 val find_opt : t -> (int * constr) option
639 val add : t -> int * constr -> unit
640 end
641 end) : sig
642 val hcons : C.t -> int * constr
643 end
644
645
646 val hcons : constr Hashcons.f
647
648 val hasheq_kind : (_ kind_of_term as 'k) -> 'k -> bool
649 (** Checks physical equality of every immediate element (goes inside tuples and arrays) *)
650
651 val debug_print : constr -> Pp.t
652 val debug_print_fix : ('a -> Pp.t) -> ('a, 'a, 'r) pfixpoint -> Pp.t
653
654 val mkConst : Constant.t -> constr
655 [@@deprecated "(8.18) Use [mkConstU] or if truly needed [UnsafeMonomorphic.mkConst]"]
656
657 val mkInd : inductive -> constr
658 [@@deprecated "(8.18) Use [mkIndU] or if truly needed [UnsafeMonomorphic.mkInd]"]
659
660 val mkConstruct : constructor -> constr
661 [@@deprecated "(8.18) Use [mkConstructU] or if truly needed [UnsafeMonomorphic.mkConstruct]"]
662
663 val hcons_annot : Name.t binder_annot Hashcons.f
664
665 val hcons_caseinfo : case_info Hashcons.f
666
667 val hash_cast_kind : cast_kind -> int