Debian Codegraph @

pretyping/inductiveops.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 EConstr
13 open Declarations
14 open Environ
15 open Evd
16
17 (** The following three functions are similar to the ones defined in
18 Inductive, but they expect an env *)
19
20 val type_of_inductive : env -> inductive puniverses -> types
21
22 val e_type_of_inductive : env -> evar_map -> inductive EConstr.puniverses -> EConstr.types
23
24 (** Return type as quoted by the user *)
25 val type_of_constructor : env -> constructor puniverses -> types
26
27 val e_type_of_constructor : env -> evar_map -> constructor EConstr.puniverses -> EConstr.types
28
29 val type_of_constructors : env -> inductive puniverses -> types array
30
31 (** Return constructor types in normal form *)
32 val arities_of_constructors : env -> inductive puniverses -> types array
33
34 (** An inductive type with its parameters (transparently supports
35 reasoning either with only recursively uniform parameters or with all
36 parameters including the recursively non-uniform ones *)
37 type inductive_family
38 val make_ind_family : inductive puniverses * constr list -> inductive_family
39 val dest_ind_family : inductive_family -> inductive puniverses * constr list
40 val map_ind_family : (constr -> constr) -> inductive_family -> inductive_family
41 val liftn_inductive_family : int -> int -> inductive_family -> inductive_family
42 val lift_inductive_family : int -> inductive_family -> inductive_family
43 val substnl_ind_family :
44 constr list -> int -> inductive_family -> inductive_family
45
46 val relevance_of_inductive : env -> inductive puniverses -> ERelevance.t
47 val relevance_of_inductive_family : env -> inductive_family -> ERelevance.t
48
49 (** An inductive type with its parameters and real arguments *)
50 type inductive_type = IndType of inductive_family * EConstr.constr list
51 val make_ind_type : inductive_family * EConstr.constr list -> inductive_type
52 val dest_ind_type : inductive_type -> inductive_family * EConstr.constr list
53 val map_inductive_type : (EConstr.constr -> EConstr.constr) -> inductive_type -> inductive_type
54 val liftn_inductive_type : int -> int -> inductive_type -> inductive_type
55 val lift_inductive_type : int -> inductive_type -> inductive_type
56 val substnl_ind_type : EConstr.constr list -> int -> inductive_type -> inductive_type
57 val ind_of_ind_type : inductive_type -> inductive
58
59 val relevance_of_inductive_type : env -> inductive_type -> ERelevance.t
60
61 val mkAppliedInd : inductive_type -> EConstr.constr
62
63 val dest_recarg : recarg Rtree.Kind.t -> recarg
64 val dest_subterms : recarg Rtree.Kind.t -> recarg Rtree.Kind.t array array
65
66 (** Check if a [one_inductive_body] is recursive, possibly nestedly *)
67 val mis_is_recursive : one_inductive_body -> bool
68 val mis_is_nested : MutInd.t -> mutual_inductive_body -> bool
69 val mis_nf_constructor_type :
70 constructor puniverses -> mutual_inductive_body * one_inductive_body -> constr
71
72 (** {6 Extract information from an inductive name} *)
73
74 (** @return number of constructors *)
75 val nconstructors : env -> inductive -> int
76
77 (** @return arity of constructors excluding parameters, excluding local defs *)
78 val constructors_nrealargs : env -> inductive -> int array
79
80 (** @return arity of constructors excluding parameters, including local defs *)
81 val constructors_nrealdecls : env -> inductive -> int array
82
83 (** @return the arity, excluding params, excluding local defs *)
84 val inductive_nrealargs : env -> inductive -> int
85
86 (** @return the arity, excluding params, including local defs *)
87 val inductive_nrealdecls : env -> inductive -> int
88
89 (** @return the arity, including params, excluding local defs *)
90 val inductive_nallargs : env -> inductive -> int
91
92 (** @return the arity, including params, including local defs *)
93 val inductive_nalldecls : env -> inductive -> int
94
95 (** @return nb of params without local defs *)
96 val inductive_nparams : env -> inductive -> int
97
98 (** @return nb of params with local defs *)
99 val inductive_nparamdecls : env -> inductive -> int
100
101 (** @return params context *)
102 val inductive_paramdecls : env -> inductive puniverses -> rel_context
103
104 (** @return full arity context, hence with letin *)
105 val inductive_alldecls : env -> inductive puniverses -> rel_context
106
107 (** {7 Extract information from a constructor name} *)
108
109 (** @return param + args without letin *)
110 val constructor_nallargs : env -> constructor -> int
111
112 (** @return param + args with letin *)
113 val constructor_nalldecls : env -> constructor -> int
114
115 (** @return args without letin *)
116 val constructor_nrealargs : env -> constructor -> int
117
118 (** @return args with letin *)
119 val constructor_nrealdecls : env -> constructor -> int
120
121 (** @return tags of all decls: true = letin, false = assumption *)
122 val inductive_alltags : env -> inductive -> bool list
123 val constructor_alltags : env -> constructor -> bool list
124
125 (** Is there local defs in params or args ? *)
126 val constructor_has_local_defs : env -> constructor -> bool
127 val inductive_has_local_defs : env -> inductive -> bool
128
129 val constant_sorts_below : Sorts.Quality.t -> UnivGen.QualityOrSet.t list
130
131 val sorts_for_schemes : mind_specif -> UnivGen.QualityOrSet.t list
132
133 val is_squashed : evar_map -> (mind_specif * EInstance.t) -> Inductive.squash option
134
135 val squash_elim_sort : evar_map -> Inductive.squash -> ESorts.t -> evar_map
136 (** Take into account elimination constraints. When there is an
137 elimination constraint and the predicate is underspecified, i.e. a
138 QSort, we make a non-canonical choice for the return type.
139 Incompatible constraints produce a universe inconsistency. *)
140
141 val is_allowed_elimination : evar_map -> (mind_specif * EInstance.t) -> EConstr.ESorts.t -> bool
142
143 val make_allowed_elimination : evar_map -> (mind_specif * EInstance.t) -> EConstr.ESorts.t -> evar_map option
144 (** Returns [Some sigma'] if the elimination can be allowed, possibly adding constraints in [sigma'] *)
145
146 val elim_sort : mind_specif -> Sorts.Quality.t
147
148 val top_allowed_sort : env -> inductive -> Sorts.Quality.t
149
150 (** (Co)Inductive records with primitive projections do not have eta-conversion,
151 hence no dependent elimination. *)
152 val has_dependent_elim : mind_specif -> bool
153
154 (** Primitive projections *)
155 val type_of_projection_knowing_arg : env -> evar_map -> Projection.t ->
156 EConstr.t -> EConstr.types -> EConstr.types
157
158 (** Extract information from an inductive family *)
159
160 type constructor_summary = {
161 cs_name : Id.t; (* name of the constructor *)
162 cs_cstr : constructor puniverses; (* internal name of the constructor plus universes *)
163 cs_params : constr list; (* parameters of the constructor in current ctx *)
164 cs_nargs : int; (* length of arguments signature (letin included) *)
165 cs_args : rel_context; (* signature of the arguments (letin included) *)
166 cs_concl_realargs : constr array; (* actual realargs in the concl of cstr *)
167 }
168 val lift_constructor : int -> constructor_summary -> constructor_summary
169 val get_constructor :
170 inductive puniverses * mutual_inductive_body * one_inductive_body * constr list ->
171 int -> constructor_summary
172 val get_constructors : env -> inductive_family -> constructor_summary array
173
174 (** [get_arity] returns the arity of the inductive family instantiated
175 with the parameters; if recursively non-uniform parameters are not
176 part of the inductive family, they appears in the arity *)
177 val get_arity : env -> inductive_family -> rel_context
178
179 val build_dependent_constructor : constructor_summary -> constr
180 val build_dependent_inductive : env -> inductive_family -> constr
181 val make_arity_signature : env -> evar_map -> bool -> inductive_family -> EConstr.rel_context
182 val make_arity : env -> evar_map -> bool -> inductive_family -> EConstr.ESorts.t -> EConstr.types
183
184 (** Raise [Not_found] if not given a valid inductive type *)
185 val extract_mrectype : evar_map -> EConstr.t -> (inductive * EConstr.EInstance.t) * EConstr.constr list
186 val find_mrectype : env -> evar_map -> EConstr.types -> (inductive * EConstr.EInstance.t) * EConstr.constr list
187 val find_mrectype_vect : env -> evar_map -> EConstr.types -> (inductive * EConstr.EInstance.t) * EConstr.constr array
188 val find_rectype : env -> evar_map -> EConstr.types -> inductive_type
189 val find_inductive : env -> evar_map -> EConstr.types -> (inductive * EConstr.EInstance.t) * constr list
190 val find_coinductive : env -> evar_map -> EConstr.types -> (inductive * EConstr.EInstance.t) * constr list
191
192 (** [instantiate_constructor_params cstr mind params] instantiates the
193 type of the given constructor with parameters [params] *)
194 val instantiate_constructor_params : constructor puniverses -> mind_specif -> constr list -> constr
195
196 (********************)
197
198 (** Builds the case predicate arity (dependent or not) *)
199 val arity_of_case_predicate :
200 env -> inductive_family -> bool -> ESorts.t -> types
201
202 (** Annotation for cases *)
203 val make_case_info : env -> inductive -> Constr.case_style -> Constr.case_info
204
205 (** Make a case or substitute projections if the inductive type is a record
206 with primitive projections.
207 Fail with an error if the elimination is dependent while the
208 inductive type does not allow dependent elimination. *)
209 val make_case_or_project :
210 env -> evar_map -> inductive_type -> Constr.case_info ->
211 (* pred *) EConstr.constr * ERelevance.t -> (* term *) EConstr.constr -> (* branches *) EConstr.constr array -> EConstr.constr
212
213 (** Sometimes [make_case_or_project] is nicer to call with a pre-built
214 [case_invert] than [inductive_type]. *)
215 val simple_make_case_or_project :
216 env -> evar_map -> Constr.case_info ->
217 (* pred *) EConstr.constr * ERelevance.t -> EConstr.case_invert -> (* term *) EConstr.constr -> (* branches *) EConstr.constr array -> EConstr.constr
218
219 val make_case_invert : env -> evar_map -> inductive_type -> case_relevance:ERelevance.t
220 -> Constr.case_info -> EConstr.case_invert
221
222 (*i Compatibility
223 val make_default_case_info : env -> case_style -> inductive -> case_info
224 i*)
225
226 val compute_projections : Environ.env -> inductive -> (constr * types) array
227 (** Given a primitive record type, for every field computes the eta-expanded
228 projection and its type. *)
229
230 (********************)
231 val control_only_guard : env -> Evd.evar_map -> EConstr.types -> unit
232
233 (** Generalize template polymorphic universe variables, subtitute the instance,
234 and returns the context of parameters, the new evar_map, and the
235 substitution for the template variable if there is one. *)
236 val paramdecls_fresh_template : evar_map -> mutual_inductive_body * einstance ->
237 evar_map * rel_context * Inductive.template_subst option
238
239 module Internal : sig
240 (* FIXME hack for the [QVar]s, see the implementation for more information. *)
241 val nf_relevance : Evd.evar_map -> Sorts.relevance -> Sorts.relevance
242 val should_invert_case : env -> Evd.evar_map -> Sorts.relevance -> Constr.case_info -> bool
243 end