Debian Codegraph @

engine/evd.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 open Util
12 open Loc
13 open Names
14 open Constr
15 open Environ
16
17 (** This file defines the pervasive unification state used everywhere
18 in Rocq tactic engine. It is very low-level and most of the
19 functions exported here are irrelevant to the standard API user.
20 Consider using {!Evarutil} or {!Proofview} instead.
21
22 A unification state (of type [evar_map]) is primarily a finite mapping
23 from existential variables to records containing the type of the evar
24 ([evar_concl]), the context under which it was introduced ([evar_hyps])
25 and its definition ([evar_body]). [evar_extra] is used to add any other
26 kind of information.
27
28 It also contains conversion constraints, debugging information and
29 information about meta variables. *)
30
31 type econstr
32 type etypes = econstr
33 type esorts
34 type erelevance
35 type einstance
36 type 'a puniverses = 'a * einstance
37
38 (** {5 Existential variables and unification states} *)
39
40 (** If true, enables generation of goal names. *)
41 val generate_goal_names : unit -> bool
42
43 (** {6 Evar filters} *)
44
45 module Filter :
46 sig
47 type t
48 (** Evar filters, seen as bitmasks. *)
49
50 val equal : t -> t -> bool
51 (** Equality over filters *)
52
53 val identity : t
54 (** The identity filter. *)
55
56 val filter_list : t -> 'a list -> 'a list
57 (** Filter a list. Sizes must coincide. *)
58
59 val filter_array : t -> 'a array -> 'a array
60 (** Filter an array. Sizes must coincide. *)
61
62 val filter_slist : t -> 'a SList.t -> 'a SList.t
63 (** Filter a sparse list. Sizes must coincide. *)
64
65 val extend : int -> t -> t
66 (** [extend n f] extends [f] on the left with [n]-th times [true]. *)
67
68 val compose : t -> t -> t
69 (** Horizontal composition : [compose f1 f2] only keeps parts of [f2] where
70 [f1] is set. In particular, [f1] and [f2] must have the same length. *)
71
72 val apply_subfilter : t -> bool list -> t
73 (** [apply_subfilter f1 f2] applies filter [f2] where [f1] is [true]. In
74 particular, the length of [f2] is the number of times [f1] is [true] *)
75
76 val restrict_upon : t -> int -> (int -> bool) -> t option
77 (** Ad-hoc primitive. *)
78
79 val map_along : (bool -> 'a -> bool) -> t -> 'a list -> t
80 (** Apply the function on the filter and the list. Sizes must coincide. *)
81
82 val make : bool list -> t
83 (** Create out of a list *)
84
85 val repr : t -> bool list option
86 (** Observe as a bool list. *)
87
88 end
89
90 module Abstraction : sig
91 type abstraction =
92 | Abstract
93 | Imitate
94
95 type t = abstraction list
96
97 val identity : t
98
99 val abstract_last : t -> t
100 end
101
102 (** {6 Evar infos} *)
103
104 type defined = [ `defined ]
105 type undefined = [ `undefined ]
106
107 type _ evar_body =
108 | Evar_empty : undefined evar_body
109 | Evar_defined : econstr -> defined evar_body
110
111 type 'a evar_info
112
113 type any_evar_info = EvarInfo : 'a evar_info -> any_evar_info
114
115 (** {6 Projections from evar infos} *)
116
117 val evar_concl : undefined evar_info -> econstr
118 (** Type of the evar. *)
119
120 val evar_context : 'a evar_info -> (econstr, etypes, erelevance) Context.Named.pt
121 (** Context of the evar. *)
122
123 val evar_hyps : 'a evar_info -> named_context_val
124 (** Context of the evar. *)
125
126 val evar_body : 'a evar_info -> 'a evar_body
127 (** Optional content of the evar. *)
128
129 val evar_candidates : undefined evar_info -> econstr list option
130 (** List of possible solutions when known that it is a finite list *)
131
132 val evar_source : 'a evar_info -> Evar_kinds.t located
133
134 val evar_filter : 'a evar_info -> Filter.t
135 (** Boolean mask over {!evar_hyps}. Should have the same length.
136 When filtered out, the corresponding variable is not allowed to occur
137 in the solution *)
138
139 val evar_abstract_arguments : undefined evar_info -> Abstraction.t
140 (** Boolean information over {!evar_hyps}, telling if an hypothesis instance
141 can be imitated or should stay abstract in HO unification problems
142 and inversion (see [second_order_matching_with_args] for its use). *)
143
144 val evar_relevance : 'a evar_info -> erelevance
145 (** Relevance of the conclusion of the evar. *)
146
147 (** {6 Derived projections} *)
148
149 val evar_filtered_context : 'a evar_info -> (econstr, etypes, erelevance) Context.Named.pt
150 val evar_filtered_hyps : 'a evar_info -> named_context_val
151 val evar_env : env -> 'a evar_info -> env
152 val evar_filtered_env : env -> 'a evar_info -> env
153 val evar_identity_subst : 'a evar_info -> econstr SList.t
154
155 val map_evar_body : (econstr -> econstr) -> 'a evar_body -> 'a evar_body
156 val map_evar_info : (econstr -> econstr) -> 'a evar_info -> 'a evar_info
157
158 (** {6 Unification state} **)
159
160 type evar_map
161 (** Type of unification state. Essentially a bunch of state-passing data needed
162 to handle incremental term construction. *)
163
164 val empty : evar_map
165 (** The empty evar map. *)
166
167 val from_env : ?binders:lident list -> env -> evar_map
168 (** The empty evar map with given universe context, taking its initial
169 universes from env, possibly with initial universe binders. This
170 is the main entry point at the beginning of the process of
171 interpreting a declaration (e.g. before entering the
172 interpretation of a Theorem statement). *)
173
174 val from_ctx : UState.t -> evar_map
175 (** The empty evar map with given universe context. This is the main
176 entry point when resuming from a already interpreted declaration
177 (e.g. after having interpreted a Theorem statement and preparing
178 to open a goal). *)
179
180 val is_empty : evar_map -> bool
181 (** Whether an evarmap is empty. *)
182
183 val has_undefined : evar_map -> bool
184 (** [has_undefined sigma] is [true] if and only if
185 there are uninstantiated evars in [sigma]. *)
186
187 val has_given_up : evar_map -> bool
188 (** [has_given_up sigma] is [true] if and only if
189 there are given up evars in [sigma]. *)
190
191 val has_shelved : evar_map -> bool
192 (** [has_shelved sigma] is [true] if and only if
193 there are shelved evars in [sigma]. *)
194
195 val new_pure_evar :
196 ?src:Evar_kinds.t Loc.located -> ?filter:Filter.t ->
197 relevance:erelevance ->
198 ?abstract_arguments:Abstraction.t -> ?candidates:econstr list ->
199 ?name:(Id.t * bool) ->
200 ?parent:Evar.t ->
201 ?typeclass_candidate:bool ->
202 ?rrpat:bool ->
203 named_context_val -> evar_map -> etypes -> evar_map * Evar.t
204 (** Low-level interface to create an evar.
205 @param src User-facing source for the evar
206 @param filter See {!Evd.Filter}, must be the same length as [named_context_val]
207 @param name A name for the evar
208 @param named_context_val The context of the evar
209 @param types The type of conclusion of the evar
210 *)
211
212 val add : evar_map -> Evar.t -> 'a evar_info -> evar_map
213 (** [add sigma ev info] adds [ev] with evar info [info] in sigma.
214 Precondition: ev must not preexist in [sigma]. *)
215
216 val find_defined : evar_map -> Evar.t -> defined evar_info option
217
218 val find : evar_map -> Evar.t -> any_evar_info
219 (** Recover the data associated to an evar. *)
220
221 val find_undefined : evar_map -> Evar.t -> undefined evar_info
222 (** Same as {!find} but restricted to undefined evars. For efficiency
223 reasons. *)
224
225 val remove : evar_map -> Evar.t -> evar_map
226 (** Remove an evar from an evar map. Use with caution. *)
227
228 val mem : evar_map -> Evar.t -> bool
229 (** Whether an evar is present in an evarmap. *)
230
231 val fold : (Evar.t -> any_evar_info -> 'a -> 'a) -> evar_map -> 'a -> 'a
232 (** Apply a function to all evars and their associated info in an evarmap. *)
233
234 val fold_undefined : (Evar.t -> undefined evar_info -> 'a -> 'a) -> evar_map -> 'a -> 'a
235 (** Same as {!fold}, but restricted to undefined evars. For efficiency
236 reasons. *)
237
238 type map = { map : 'r. Evar.t -> 'r evar_info -> 'r evar_info }
239
240 val raw_map : map -> evar_map -> evar_map
241 (** Apply the given function to all evars in the map. Beware: this function
242 expects the argument function to preserve the kind of [evar_body], i.e. it
243 must send [Evar_empty] to [Evar_empty] and [Evar_defined c] to some
244 [Evar_defined c']. *)
245
246 val raw_map_undefined : (Evar.t -> undefined evar_info -> undefined evar_info) -> evar_map -> evar_map
247 (** Same as {!raw_map}, but restricted to undefined evars. For efficiency
248 reasons. *)
249
250 val define : Evar.t -> econstr -> evar_map -> evar_map
251 (** Set the body of an evar to the given constr. It is expected that:
252 {ul
253 {- The evar is already present in the evarmap.}
254 {- The evar is not defined in the evarmap yet.}
255 {- All the evars present in the constr should be present in the evar map.}
256 } *)
257
258 val define_with_evar : Evar.t -> econstr -> evar_map -> evar_map
259 (** Same as [define ev body evd], except the body must be an existential variable [ev'].
260 This additionally makes [ev'] inherit the [obligation] and [typeclass] flags of [ev]. *)
261
262 val cmap : (econstr -> econstr) -> evar_map -> evar_map
263 (** Map the function on all terms in the evar map. *)
264
265 val is_evar : evar_map -> Evar.t-> bool
266 (** Alias for {!mem}. *)
267
268 val is_defined : evar_map -> Evar.t-> bool
269 (** Whether an evar is defined in an evarmap. *)
270
271 val is_undefined : evar_map -> Evar.t-> bool
272 (** Whether an evar is not defined in an evarmap. *)
273
274 val add_univ_constraints : evar_map -> Univ.UnivConstraints.t -> evar_map
275 (** Add universe constraints in an evar map. *)
276
277 val add_poly_constraints : ?src:UState.constraint_source -> evar_map -> PConstraints.t -> evar_map
278
279 val undefined_map : evar_map -> undefined evar_info Evar.Map.t
280 (** Access the undefined evar mapping directly. *)
281
282 val defined_map : evar_map -> defined evar_info Evar.Map.t
283 (** Access the defined evar mapping directly. *)
284
285 val drop_all_defined : evar_map -> evar_map
286
287 val drop_new_defined : original:evar_map -> evar_map -> evar_map
288 (** Drop the defined evars in the second evar map which did not exist in the first. *)
289
290 (** {6 Instantiating partial terms} *)
291
292 exception NotInstantiatedEvar
293
294 val existential_value : evar_map -> econstr pexistential -> econstr
295 (** [existential_value sigma ev] raises [NotInstantiatedEvar] if [ev] has
296 no body and [Not_found] if it does not exist in [sigma] *)
297
298 val existential_type_opt : evar_map -> econstr pexistential -> etypes option
299
300 val existential_type : evar_map -> econstr pexistential -> etypes
301
302 val existential_opt_value : evar_map -> econstr pexistential -> econstr option
303 (** Same as {!existential_value} but returns an option instead of raising an
304 exception. *)
305
306 val existential_opt_value0 : evar_map -> existential -> constr option
307
308 val evar_handler : evar_map -> CClosure.evar_handler
309
310 val existential_expand_value0 : evar_map -> existential -> constr CClosure.evar_expansion
311
312 val expand_existential : evar_map -> econstr pexistential -> econstr list
313 (** Returns the full evar instance with implicit default variables turned into
314 explicit [Var] nodes. *)
315
316 val expand_existential0 : evar_map -> constr pexistential -> constr list
317
318 val instantiate_evar_array : evar_map -> 'a evar_info -> econstr -> econstr SList.t -> econstr
319
320 (** {6 Misc} *)
321
322 val restrict : Evar.t-> Filter.t -> ?candidates:econstr list ->
323 ?src:Evar_kinds.t located -> evar_map -> evar_map * Evar.t
324 (** Restrict an undefined evar into a new evar by filtering context and
325 possibly limiting the instances to a set of candidates (candidates
326 are filtered according to the filter) *)
327
328 val update_source : evar_map -> Evar.t -> Evar_kinds.t located -> evar_map
329 (** To update the source a posteriori, e.g. when an evar type of
330 another evar has to refer to this other evar, with a mutual dependency *)
331
332 val get_aliased_evars : evar_map -> Evar.t Evar.Map.t
333 (** The map of aliased evars *)
334
335 val is_aliased_evar : evar_map -> Evar.t -> Evar.t option
336 (** Tell if an evar has been aliased to another evar, and if yes, which *)
337
338 val max_undefined_with_candidates : evar_map -> Evar.t option
339 (** If any, the evar with highest id with a non-empty list of candidates. *)
340
341 val set_typeclass_evars : evar_map -> Evar.Set.t -> evar_map
342 (** Mark the given set of evars as available for resolution.
343 (The previous marked set is replaced, not added to.)
344
345 Precondition: they should indeed refer to undefined typeclass evars.
346 *)
347
348 val get_typeclass_evars : evar_map -> Evar.Set.t
349 (** The set of undefined typeclass evars *)
350
351 val is_typeclass_evar : evar_map -> Evar.t -> bool
352 (** Is the evar declared resolvable for typeclass resolution *)
353
354 val get_obligation_evars : evar_map -> Evar.Set.t
355 (** The set of obligation evars *)
356
357 val set_obligation_evar : evar_map -> Evar.t -> evar_map
358 (** Declare an evar as an obligation *)
359
360 val is_obligation_evar : evar_map -> Evar.t -> bool
361 (** Is the evar declared as an obligation *)
362
363 val get_impossible_case_evars : evar_map -> Evar.Set.t
364 (** Set of undefined evars with ImpossibleCase evar source. *)
365
366 val get_rewrite_rule_evars : evar_map -> Evar.Set.t
367 (** Set of evars declared as an ununifiable rewrite rule evar *)
368
369 val is_rewrite_rule_evar : evar_map -> Evar.t -> bool
370 (** Is the evar declared as an ununifiable rewrite rule evar *)
371
372 val downcast : Evar.t-> etypes -> evar_map -> evar_map
373 (** Change the type of an undefined evar to a new type assumed to be a
374 subtype of its current type; subtyping must be ensured by caller *)
375
376 (** {6 Evar names} *)
377
378 val evar_ident : Evar.t -> evar_map -> Libnames.full_path option
379
380 val evar_has_name : Evar.t -> evar_map -> bool
381
382 val evar_has_unambiguous_name : Evar.t -> evar_map -> bool
383
384 val add_name : Evar.t -> Id.t -> ?parent:Evar.t -> evar_map -> evar_map
385
386 val transfer_name : Evar.t -> Evar.t -> evar_map -> evar_map
387
388 val evar_key : Libnames.qualid -> evar_map -> Evar.t
389
390 val dependent_evar_ident : Evar.t -> evar_map -> Id.t
391
392 (** {5 Side-effects} *)
393
394 type side_effect_role =
395 | Schema of inductive * string
396
397 type side_effects
398
399 val empty_side_effects : side_effects
400
401 val get_senv_side_effects : side_effects -> Safe_typing.safe_environment
402
403 val set_side_effects : side_effects -> evar_map -> evar_map
404 (** Replaces the side-effects of the evarmap. *)
405
406 val emit_side_effects : side_effects -> evar_map -> evar_map
407 (** Push a side-effect into the evar map. *)
408
409 val eval_side_effects : evar_map -> side_effects
410 (** Return the effects contained in the evar map. *)
411
412 val push_side_effects :
413 ?role:side_effect_role -> ?ts:Conv_oracle.oracle ->
414 Id.t -> Safe_typing.side_effect_declaration -> Univ.ContextSet.t ->
415 side_effects -> Constant.t * side_effects
416
417 (** {6 Accessors} *)
418
419 val seff_mem_label : Id.t -> side_effects -> bool
420 val seff_private : side_effects -> Safe_typing.private_constants
421 val seff_roles : side_effects -> side_effect_role Cmap_env.t
422 val seff_univs : side_effects -> UState.named_universes_entry Names.Cmap_env.t
423
424 (** {5 Future goals} *)
425
426 val declare_future_goal : Evar.t -> evar_map -> evar_map
427 (** Adds an existential variable to the list of future goals. For
428 internal uses only. *)
429
430 module FutureGoals : sig
431
432 type t
433
434 val comb : t -> Evar.t list
435
436 val map_filter : (Evar.t -> Evar.t option) -> t -> t
437 (** Applies a function on the future goals *)
438
439 val filter : (Evar.t -> bool) -> t -> t
440 (** Applies a filter on the future goals *)
441
442 end
443
444 val push_future_goals : evar_map -> evar_map
445
446 val pop_future_goals : evar_map -> FutureGoals.t * evar_map
447
448 val fold_future_goals : (evar_map -> Evar.t -> evar_map) -> evar_map -> evar_map
449
450 val remove_future_goal : evar_map -> Evar.t -> evar_map
451
452 val pr_future_goals_stack : evar_map -> Pp.t
453
454 val push_shelf : evar_map -> evar_map
455
456 val pop_shelf : evar_map -> Evar.t list * evar_map
457
458 val filter_shelf : (Evar.t -> bool) -> evar_map -> evar_map
459
460 val give_up : Evar.t -> evar_map -> evar_map
461
462 val shelve : evar_map -> Evar.t list -> evar_map
463
464 val unshelve : evar_map -> Evar.t list -> evar_map
465
466 val given_up : evar_map -> Evar.Set.t
467
468 val shelf : evar_map -> Evar.t list
469 (** All evars in the shelf (not just the shallowest shelf) *)
470
471 val mem_shelf : Evar.t -> evar_map -> bool
472 (** [true] if the evar is in the shelf (not necessarily in the shallowest shelf) *)
473
474 val pr_shelf : evar_map -> Pp.t
475
476 (** {5 Sort variables}
477
478 Evar maps also keep track of the universe constraints defined at a given
479 point. This section defines the relevant manipulation functions. *)
480
481 exception UniversesDiffer
482
483 val add_constraints : evar_map -> UnivProblem.Set.t -> evar_map
484 (** Add the given universe unification constraints to the evar map.
485 @raise UniversesDiffer in case a first-order unification fails.
486 @raise UniverseInconsistency .
487 *)
488
489 (** {5 Extra data}
490
491 Evar maps can contain arbitrary data, allowing to use an extensible state.
492 As evar maps are theoretically used in a strict state-passing style, such
493 additional data should be passed along transparently. Some old and bug-prone
494 code tends to drop them nonetheless, so you should keep cautious.
495
496 *)
497
498 module Store : Store.S
499 (** Datatype used to store additional information in evar maps. *)
500
501 val get_extra_data : evar_map -> Store.t
502 val set_extra_data : Store.t -> evar_map -> evar_map
503
504 (** {5 The state monad with state an evar map} *)
505
506 module MonadR : Monad.S with type +'a t = evar_map -> evar_map * 'a
507 module Monad : Monad.S with type +'a t = evar_map -> 'a * evar_map
508
509 (** Unification constraints *)
510 type conv_pb = Conversion.conv_pb
511 type evar_constraint = conv_pb * env * econstr * econstr
512
513 (** The following two functions are for internal use only,
514 see [Evarutil.add_unification_pb] for a safe interface. *)
515 val add_conv_pb : ?tail:bool -> evar_constraint -> evar_map -> evar_map
516 val conv_pbs : evar_map -> evar_constraint list
517
518 val extract_conv_pbs : evar_map ->
519 (evar_constraint -> bool) ->
520 evar_map * evar_constraint list
521 val extract_changed_conv_pbs : evar_map ->
522 evar_map * evar_constraint list
523 val extract_changed_conv_pbs_from : evar_map -> Evar.Set.t option ->
524 evar_map * evar_constraint list
525 val extract_all_conv_pbs : evar_map -> evar_map * evar_constraint list
526 val loc_of_conv_pb : evar_map -> evar_constraint -> Loc.t option
527
528 (** The following functions return the set of undefined evars
529 contained in the object. *)
530
531 val evars_of_term : evar_map -> econstr -> Evar.Set.t
532 (** including evars in instances of evars *)
533
534 val evars_of_named_context : evar_map -> (econstr, etypes, erelevance) Context.Named.pt -> Evar.Set.t
535
536 val evars_of_filtered_evar_info : evar_map -> 'a evar_info -> Evar.Set.t
537
538 (** {5 FIXME: Nothing to do here} *)
539
540 (*********************************************************
541 Sort/universe variables *)
542
543 (** Rigid or flexible universe variables.
544
545 [UnivRigid] variables are user-provided or come from an explicit
546 [Type] in the source, we do not minimize them or unify them eagerly.
547
548 [UnivFlexible alg] variables are fresh universe variables of
549 polymorphic constants or generated during refinement, sometimes in
550 algebraic position (i.e. not appearing in the term at the moment of
551 creation). They are the candidates for minimization (if alg, to an
552 algebraic universe) and unified eagerly in the first-order
553 unification heurstic. *)
554
555 type rigid = UState.rigid =
556 | UnivRigid
557 | UnivFlexible of bool (** Is substitution by an algebraic ok? *)
558
559 val univ_rigid : rigid
560 val univ_flexible : rigid
561 val univ_flexible_alg : rigid
562
563 type 'a in_ustate = 'a * UState.t
564
565 val restrict_universe_context : evar_map -> Univ.Level.Set.t -> evar_map
566
567 (** Raises Not_found if not a name for a universe in this map. *)
568 val universe_of_name : evar_map -> Id.t -> Univ.Level.t
569 val quality_of_name : evar_map -> Id.t -> Sorts.QVar.t
570
571 val is_rigid_qvar : evar_map -> Sorts.QVar.t -> bool
572
573 val is_relevance_irrelevant : evar_map -> erelevance -> bool
574 (** Whether the relevance is irrelevant modulo qstate *)
575 (* XXX move to ERelevance *)
576
577 val universe_binders : evar_map -> UnivNames.universe_binders
578
579 val new_univ_level_variable : ?loc:Loc.t -> ?name:Id.t -> rigid -> evar_map -> evar_map * Univ.Level.t
580 val new_quality_variable : ?loc:Loc.t -> ?name:Id.t -> evar_map -> evar_map * Sorts.QVar.t
581 val new_sort_info : ?loc:Loc.t -> ?sort_rigid:bool -> ?name:Names.Id.t -> rigid -> evar_map -> evar_map * Sorts.QVar.t * Univ.Universe.t
582 val new_sort_variable : ?loc:Loc.t -> ?sort_rigid:bool -> ?name:Names.Id.t -> rigid -> evar_map -> evar_map * esorts
583
584 val add_forgotten_univ : evar_map -> Univ.Level.t -> evar_map
585
586 val make_nonalgebraic_variable : evar_map -> Univ.Level.t -> evar_map
587 (** See [UState.make_nonalgebraic_variable]. *)
588
589 val is_flexible_level : evar_map -> Univ.Level.t -> bool
590
591 val normalize_universe_instance : evar_map -> einstance -> einstance
592
593 val set_leq_sort : evar_map -> esorts -> esorts -> evar_map
594 val set_eq_sort : evar_map -> esorts -> esorts -> evar_map
595 val set_eq_level : evar_map -> Univ.Level.t -> Univ.Level.t -> evar_map
596 val set_leq_level : evar_map -> Univ.Level.t -> Univ.Level.t -> evar_map
597 val set_eq_instances : ?flex:bool ->
598 evar_map -> einstance -> einstance -> evar_map
599
600 val set_eq_qualities : evar_map -> Sorts.Quality.t -> Sorts.Quality.t -> evar_map
601 val set_elim_to : evar_map -> Sorts.Quality.t -> Sorts.Quality.t -> evar_map
602 val set_above_prop : evar_map -> Sorts.Quality.t -> evar_map
603
604 val check_eq : evar_map -> esorts -> esorts -> bool
605 val check_leq : evar_map -> esorts -> esorts -> bool
606
607 val check_univ_constraints : evar_map -> Univ.UnivConstraints.t -> bool
608 val check_elim_constraints : evar_map -> Sorts.ElimConstraints.t -> bool
609 val check_poly_constraints : evar_map -> PConstraints.t -> bool
610 val check_quality_constraints : evar_map -> UVars.QPairSet.t -> bool
611
612 val ustate : evar_map -> UState.t
613 val elim_graph : evar_map -> QGraph.t
614 val evar_universe_context : evar_map -> UState.t [@@deprecated "(9.0) Use [Evd.ustate]"]
615
616 val universe_context_set : evar_map -> Univ.ContextSet.t
617 val sort_context_set : evar_map -> UnivGen.sort_context_set
618 val universe_subst : evar_map -> UnivFlex.t
619 val universes : evar_map -> UGraph.t
620
621 (** [to_universe_context evm] extracts the local universes and
622 constraints of [evm] and orders the universes *)
623 val to_universe_context : evar_map -> UVars.UContext.t
624
625 val univ_entry : poly:PolyFlags.t -> evar_map -> UState.named_universes_entry
626
627 val check_univ_decl : poly:PolyFlags.t -> evar_map -> UState.universe_decl -> UState.named_universes_entry
628
629 (** An early check of compatibility of the universe declaration before
630 starting to build a declaration interactively *)
631 val check_univ_decl_early : poly:PolyFlags.t -> with_obls:bool -> evar_map -> UState.universe_decl -> Constr.t list -> unit
632
633 val merge_universe_context : evar_map -> UState.t -> evar_map
634 val set_universe_context : evar_map -> UState.t -> evar_map
635
636 val merge_universe_context_set : ?loc:Loc.t -> ?sideff:bool -> rigid -> evar_map -> Univ.ContextSet.t -> evar_map
637
638 val merge_sort_context_set : ?loc:Loc.t -> ?sort_rigid:bool -> ?sideff:bool ->
639 ?src:UState.constraint_source -> rigid -> evar_map -> UnivGen.sort_context_set -> evar_map
640
641 val with_sort_context_set : ?loc:Loc.t -> ?sort_rigid:bool -> ?src:UState.constraint_source ->
642 rigid -> evar_map -> 'a UnivGen.in_sort_context_set -> evar_map * 'a
643
644 val nf_univ_variables : evar_map -> evar_map
645
646 val collapse_sort_variables : ?except:Sorts.QVar.Set.t -> evar_map -> evar_map
647
648 val fix_undefined_variables : evar_map -> evar_map
649
650 (** Universe minimization (collapse_sort_variables is true by default) *)
651 val minimize_universes : ?collapse_sort_variables:bool -> evar_map -> evar_map
652
653 (** Lift [UState.update_sigma_univs] *)
654 val update_sigma_univs : UGraph.t -> evar_map -> evar_map
655
656 (** Polymorphic universes *)
657
658 val fresh_sort_in_quality : ?loc:Loc.t -> ?rigid:rigid
659 -> evar_map -> UnivGen.QualityOrSet.t -> evar_map * esorts
660 val fresh_constant_instance : ?loc:Loc.t -> ?rigid:rigid
661 -> env -> evar_map -> Constant.t -> evar_map * Constant.t puniverses
662 val fresh_inductive_instance : ?loc:Loc.t -> ?sort_rigid:bool -> ?rigid:rigid
663 -> env -> evar_map -> inductive -> evar_map * inductive puniverses
664 val fresh_constructor_instance : ?loc:Loc.t -> ?rigid:rigid
665 -> env -> evar_map -> constructor -> evar_map * constructor puniverses
666 val fresh_array_instance : ?loc:Loc.t -> ?rigid:rigid
667 -> env -> evar_map -> evar_map * einstance
668
669 val fresh_global : ?loc:Loc.t -> ?rigid:rigid -> ?names:einstance -> env ->
670 evar_map -> GlobRef.t -> evar_map * econstr
671
672 (** Partially constructed constrs. *)
673
674 type unsolvability_explanation = SeveralInstancesFound of int
675 (** Failure explanation. *)
676
677 (** {5 Summary names} *)
678
679 (* This stuff is internal and should not be used. Currently a hack in
680 the STM relies on it. *)
681 val evar_counter_summary_tag : int Summary.Dyn.tag
682
683 (** {5 Deprecated functions} *)
684 val create_evar_defs : evar_map -> evar_map
685 (* XXX: This is supposed to be deprecated by used by ssrmatching, what
686 should the replacement be? *)
687
688 (** Create an [evar_map] with empty meta map: *)
689
690 (** Use this module only to bootstrap EConstr *)
691 module MiniEConstr : sig
692 module ERelevance : sig
693 type t = erelevance
694 val make : Sorts.relevance -> t
695 val kind : evar_map -> t -> Sorts.relevance
696 val unsafe_to_relevance : t -> Sorts.relevance
697 end
698
699 module ESorts : sig
700 type t = esorts
701 val make : Sorts.t -> t
702 val kind : evar_map -> t -> Sorts.t
703 val unsafe_to_sorts : t -> Sorts.t
704 end
705
706 module EInstance : sig
707 type t = einstance
708 val make : UVars.Instance.t -> t
709 val kind : evar_map -> t -> UVars.Instance.t
710 val empty : t
711 val is_empty : t -> bool
712 val unsafe_to_instance : t -> UVars.Instance.t
713 end
714
715 type t = econstr
716
717 val kind : evar_map -> t -> (t, t, ESorts.t, EInstance.t, ERelevance.t) Constr.kind_of_term
718 val kind_upto : evar_map -> constr -> (constr, types, Sorts.t, UVars.Instance.t, Sorts.relevance) Constr.kind_of_term
719
720 val whd_evar : evar_map -> t -> t
721
722 val mkLEvar : evar_map -> Evar.t * t list -> t
723
724 val replace_vars : evar_map -> (Id.t * t) list -> t -> t
725
726 val of_kind : (t, t, ESorts.t, EInstance.t, ERelevance.t) Constr.kind_of_term -> t
727
728 val of_constr : Constr.t -> t
729 val of_constr_array : Constr.t array -> t array
730
731 val to_constr : ?abort_on_undefined_evars:bool -> evar_map -> t -> Constr.t
732 val to_constr_opt : evar_map -> t -> Constr.t option
733 val nf_evar : evar_map -> t -> t
734
735 val unsafe_to_constr : t -> Constr.t
736 val unsafe_to_constr_array : t array -> Constr.t array
737
738 val unsafe_eq : (t, Constr.t) eq
739 val unsafe_relevance_eq : (ERelevance.t, Sorts.relevance) eq
740
741 val of_named_decl : (Constr.t, Constr.types, Sorts.relevance) Context.Named.Declaration.pt ->
742 (t, t, ERelevance.t) Context.Named.Declaration.pt
743 val unsafe_to_named_decl : (t, t, ERelevance.t) Context.Named.Declaration.pt ->
744 (Constr.t, Constr.types, Sorts.relevance) Context.Named.Declaration.pt
745 val unsafe_to_rel_decl : (t, t, ERelevance.t) Context.Rel.Declaration.pt ->
746 (Constr.t, Constr.types, Sorts.relevance) Context.Rel.Declaration.pt
747 val of_case_invert : constr pcase_invert -> econstr pcase_invert
748 val unsafe_to_case_invert : econstr pcase_invert -> constr pcase_invert
749 val of_rel_decl : (Constr.t, Constr.types, Sorts.relevance) Context.Rel.Declaration.pt ->
750 (t, t, ERelevance.t) Context.Rel.Declaration.pt
751
752 val of_named_context : (Constr.t, Constr.types, Sorts.relevance) Context.Named.pt ->
753 (t, t, ERelevance.t) Context.Named.pt
754 val of_rel_context : (Constr.t, Constr.types, Sorts.relevance) Context.Rel.pt ->
755 (t, t, ERelevance.t) Context.Rel.pt
756
757 val lookup_constant : env -> evar_map -> Constant.t -> Declarations.constant_body
758 end
759
760 (** Only used as EConstr internals *)
761 module Expand : sig
762 open MiniEConstr
763 type handle
764 val empty_handle : handle
765 val liftn_handle : int -> handle -> handle
766 val kind : evar_map -> handle -> econstr -> handle * (econstr, econstr, ESorts.t, EInstance.t, ERelevance.t) Constr.kind_of_term
767 val expand : evar_map -> handle -> econstr -> econstr
768 val expand_instance : skip:bool -> undefined evar_info -> handle -> econstr SList.t -> econstr SList.t
769 end