Debian Codegraph @

engine/evarutil.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 Names
12 open Constr
13 open Evd
14 open Environ
15 open Namegen
16 open EConstr
17
18 (** This module provides useful higher-level functions for evar manipulation. *)
19
20 (** {6 Metas} *)
21
22 (** [new_meta] is a generator of unique meta variables *)
23 val new_meta : unit -> metavariable
24
25 (** {6 Creating a fresh evar given their type and context} *)
26
27 val next_evar_name : intro_pattern_naming_expr -> (Id.t * bool) option
28
29 module VarSet :
30 sig
31 type t
32 val empty : t
33 val full : t
34 val variables : Environ.env -> t
35 end
36
37 type naming_mode = VarSet.t
38
39 val new_evar :
40 ?src:Evar_kinds.t Loc.located -> ?filter:Filter.t ->
41 ?relevance:ERelevance.t ->
42 ?abstract_arguments:Abstraction.t -> ?candidates:constr list ->
43 ?naming:intro_pattern_naming_expr ->
44 ?parent:Evar.t ->
45 ?typeclass_candidate:bool ->
46 ?rrpat:bool ->
47 ?hypnaming:naming_mode ->
48 env -> evar_map -> types -> evar_map * EConstr.t
49
50 (** Alias of {!Evd.new_pure_evar} *)
51 val new_pure_evar :
52 ?src:Evar_kinds.t Loc.located -> ?filter:Filter.t ->
53 relevance:ERelevance.t ->
54 ?abstract_arguments:Abstraction.t -> ?candidates:constr list ->
55 ?name:(Id.t * bool) ->
56 ?parent:Evar.t ->
57 ?typeclass_candidate:bool ->
58 ?rrpat:bool ->
59 named_context_val -> evar_map -> types -> evar_map * Evar.t
60
61 (** Create a new Type existential variable, as we keep track of
62 them during type-checking and unification. *)
63 val new_type_evar :
64 ?src:Evar_kinds.t Loc.located -> ?filter:Filter.t ->
65 ?naming:intro_pattern_naming_expr ->
66 ?hypnaming:naming_mode ->
67 env -> evar_map -> rigid ->
68 evar_map * (constr * ESorts.t)
69
70 val new_Type : ?rigid:rigid -> evar_map -> evar_map * constr
71
72 (** {6 Unification utils} *)
73
74 (* Expand head evar if any *)
75 val whd_head_evar : evar_map -> constr -> constr
76
77 (* An over-approximation of [has_undefined (nf_evars evd c)] *)
78 val has_undefined_evars : evar_map -> constr -> bool
79 val has_undefined_evars_or_metas : evar_map -> constr -> bool
80
81 val is_ground_term : evar_map -> constr -> bool
82 val is_ground_env : evar_map -> env -> bool
83
84 (** [advance sigma g] returns [Some g'] if [g'] is undefined and is
85 the current avatar of [g] (for instance [g] was changed by [clear]
86 into [g']). It returns [None] if [g] has been (partially)
87 solved. *)
88 val advance : evar_map -> Evar.t -> Evar.t option
89
90 (** [reachable_from_evars sigma seeds] computes the descendents of
91 evars in [seeds] by restriction or evar-evar unifications in [sigma]. *)
92 val reachable_from_evars : evar_map -> Evar.Set.t -> Evar.Set.t
93
94 (** The following functions return the set of undefined evars
95 contained in the object, the defined evars being traversed.
96 This is roughly a combination of the previous functions and
97 [nf_evar]. *)
98
99 val undefined_evars_of_term : evar_map -> constr -> Evar.Set.t
100 val undefined_evars_of_named_context : evar_map -> Constr.named_context -> Evar.Set.t
101
102 type undefined_evars_cache
103
104 val create_undefined_evars_cache : unit -> undefined_evars_cache
105
106 val filtered_undefined_evars_of_evar_info : ?cache:undefined_evars_cache -> evar_map -> 'a evar_info -> Evar.Set.t
107
108 (** [occur_evar_upto sigma k c] returns [true] if [k] appears in
109 [c]. It looks up recursively in [sigma] for the value of existential
110 variables. *)
111 val occur_evar_upto : evar_map -> Evar.t -> constr -> bool
112
113 (** {6 Value/Type constraints} *)
114
115 val judge_of_new_Type : evar_map -> evar_map * unsafe_judgment
116
117 (***********************************************************)
118
119 val create_clos_infos : env -> evar_map -> RedFlags.reds -> CClosure.clos_infos
120
121 val whd_evar : evar_map -> constr -> constr
122 val nf_evar : evar_map -> constr -> constr
123 val j_nf_evar : evar_map -> unsafe_judgment -> unsafe_judgment
124 val jl_nf_evar :
125 evar_map -> unsafe_judgment list -> unsafe_judgment list
126 val jv_nf_evar :
127 evar_map -> unsafe_judgment array -> unsafe_judgment array
128 val tj_nf_evar :
129 evar_map -> unsafe_type_judgment -> unsafe_type_judgment
130
131 val nf_named_context_evar : evar_map -> Constr.named_context -> Constr.named_context
132 val nf_rel_context_evar : evar_map -> rel_context -> rel_context
133 val nf_env_evar : evar_map -> env -> env
134
135 val nf_evar_info : evar_map -> 'a evar_info -> 'a evar_info
136 val nf_evar_map : evar_map -> evar_map
137 val nf_evar_map_undefined : evar_map -> evar_map
138 val nf_relevance : evar_map -> Sorts.relevance -> Sorts.relevance
139
140 (** Presenting terms without solved evars *)
141
142 val nf_evars_universes : evar_map -> Constr.constr -> Constr.constr
143
144 (** [finalize env sigma f] combines universe minimisation,
145 evar-and-universe normalisation and universe restriction.
146
147 It minimizes universes in [sigma], calls [f] a normalisation
148 function with respect to the updated [sigma] and restricts the
149 local universes of [sigma] to those encountered while running [f].
150
151 Note that the normalizer passed to [f] holds some imperative state
152 in its closure. *)
153 val finalize : ?abort_on_undefined_evars:bool -> evar_map ->
154 ((EConstr.t -> Constr.t) -> 'a) ->
155 evar_map * 'a
156
157 (** {6 Term manipulation up to instantiation} *)
158
159 (** Like {!Constr.kind} except that [kind_of_term sigma t] exposes [t]
160 as an evar [e] only if [e] is uninstantiated in [sigma]. Otherwise the
161 value of [e] in [sigma] is (recursively) used. *)
162 val kind_of_term_upto : evar_map -> Constr.constr ->
163 (Constr.constr, Constr.types, Sorts.t, UVars.Instance.t, Sorts.relevance) kind_of_term
164
165 (** [eq_constr_univs_test ~evd ~extended_evd t u] tests equality of
166 [t] and [u] up to existential variable instantiation and
167 equalisable universes. The term [t] is interpreted in [evd] while
168 [u] is interpreted in [extended_evd]. The universe constraints in
169 [extended_evd] are assumed to be an extension of those in [evd]. *)
170 val eq_constr_univs_test :
171 evd:Evd.evar_map ->
172 extended_evd:Evd.evar_map ->
173 constr ->
174 constr ->
175 bool
176
177 (** [compare_cumulative_instances cv_pb variance u1 u2 sigma] Returns
178 [Inl sigma'] where [sigma'] is [sigma] augmented with universe
179 constraints such that [u1 cv_pb? u2] according to [variance].
180 Additionally flexible universes in irrelevant positions are unified
181 if possible. Returns [Inr p] when the former is impossible. *)
182 val compare_cumulative_instances : Conversion.conv_pb -> UVars.Variance.t array ->
183 UVars.Instance.t -> UVars.Instance.t -> evar_map ->
184 (evar_map, UGraph.univ_inconsistency) Util.union
185
186 (** We should only compare constructors at convertible types, so this
187 is only an opportunity to unify universes.
188
189 But what about qualities?
190 *)
191 val compare_constructor_instances : evar_map ->
192 UVars.Instance.t -> UVars.Instance.t -> (evar_map, UGraph.univ_inconsistency) Util.union
193
194 (** {6 Unification problems} *)
195 type unification_pb = conv_pb * env * constr * constr
196
197 (** [add_unification_pb ?tail pb sigma]
198 Add a unification problem [pb] to [sigma], if not already present.
199 Put it at the end of the list if [tail] is true, by default it is false. *)
200 val add_unification_pb : ?tail:bool -> unification_pb -> evar_map -> evar_map
201
202 (** {6 Removing hyps in evars'context}
203 raise OccurHypInSimpleClause if the removal breaks dependencies *)
204
205 type clear_dependency_error =
206 | OccurHypInSimpleClause of Id.t option
207 | EvarTypingBreak of EConstr.existential
208 | NoCandidatesLeft of Evar.t
209
210 exception ClearDependencyError of Id.t * clear_dependency_error * GlobRef.t option
211
212 (** Restrict an undefined evar according to a (sub)filter and candidates.
213 The evar will be defined if there is only one candidate left,
214 @raise ClearDependencyError NoCandidatesLeft if the filter turns the candidates
215 into an empty list. *)
216
217 val restrict_evar : evar_map -> Evar.t -> Filter.t ->
218 constr list option -> evar_map * Evar.t
219
220 val clear_hyps_in_evi : env -> evar_map -> named_context_val -> types ->
221 Id.Set.t -> evar_map * named_context_val * types
222
223 val clear_hyps2_in_evi : env -> evar_map -> named_context_val -> types -> types ->
224 Id.Set.t -> evar_map * named_context_val * types * types
225
226 val check_and_clear_in_constr
227 : Environ.env
228 -> Evd.evar_map
229 -> clear_dependency_error
230 -> Names.Id.Set.t
231 -> EConstr.constr
232 -> Evd.evar_map
233
234 type csubst
235
236 val empty_csubst : csubst
237 val csubst_subst : Evd.evar_map -> csubst -> constr -> constr
238
239 type ext_named_context
240
241 val ext_named_context_of_env : hypnaming:naming_mode -> env -> evar_map -> ext_named_context
242
243 val ext_named_context_val : ext_named_context -> named_context_val
244 val ext_csubst : ext_named_context -> csubst
245
246 val default_ext_instance : ext_named_context -> constr SList.t
247
248 val ext_rev_subst : ext_named_context -> Id.t -> constr
249
250 val push_rel_decl_to_named_context : hypnaming:naming_mode ->
251 evar_map -> rel_declaration -> ext_named_context -> ext_named_context
252
253 val push_rel_context_to_named_context : hypnaming:naming_mode ->
254 Environ.env -> evar_map -> types ->
255 named_context_val * types * constr SList.t * csubst
256
257 val generalize_evar_over_rels : evar_map -> existential -> types * constr list
258
259 val subterm_source : Evar.t -> ?where:Evar_kinds.subevar_kind -> Evar_kinds.t Loc.located ->
260 Evar_kinds.t Loc.located
261
262 val meta_counter_summary_tag : int Summary.Dyn.tag