Debian Codegraph @

kernel/inductive.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 Univ
14 open PConstraints
15 open UVars
16 open Declarations
17 open Environ
18 open CClosure
19
20 (** {6 Extracting an inductive type from a construction } *)
21
22 (** [find_m*type env sigma c] coerce [c] to an recursive type (I args).
23 [find_rectype], [find_inductive] and [find_coinductive]
24 respectively accepts any recursive type, only an inductive type and
25 only a coinductive type.
26 They raise [Not_found] if not convertible to a recursive type. *)
27
28 val find_rectype : ?evars:evar_handler -> env -> types -> pinductive * constr list
29 val find_inductive : ?evars:evar_handler -> env -> types -> pinductive * constr list
30 val find_coinductive : ?evars:evar_handler -> env -> types -> pinductive * constr list
31
32 (** {6 ... } *)
33 (** Fetching information in the environment about an inductive type.
34 Raises an anomaly if the inductive type is not found. *)
35 val lookup_mind_specif : env -> inductive -> mind_specif
36
37 (** {6 Functions to build standard types related to inductive } *)
38
39 (** Returns the parameters of an inductive type with universes instantiated *)
40 val inductive_paramdecls : mutual_inductive_body puniverses -> Constr.rel_context
41
42 (** Returns the parameters of an inductive type with universes
43 instantiated, splitting it into the contexts of recursively
44 uniform and recursively non-uniform parameters *)
45 val inductive_nonrec_rec_paramdecls : mutual_inductive_body puniverses -> Constr.rel_context * Constr.rel_context
46
47 val inductive_nnonrecparams : mutual_inductive_body -> int
48
49 val instantiate_inductive_constraints :
50 mutual_inductive_body -> Instance.t -> PConstraints.t
51
52 type template_univ =
53 | TemplateProp
54 | TemplateAboveProp of Sorts.QVar.t * Universe.t
55 | TemplateUniv of Universe.t
56
57 type param_univs = (default:Sorts.t -> template_univ) list
58
59 type template_subst = Sorts.Quality.t Int.Map.t * Universe.t Int.Map.t
60
61 val instantiate_template_constraints
62 : template_subst
63 -> Declarations.template_universes
64 -> PConstraints.t
65
66 val instantiate_template_universes : mutual_inductive_body -> param_univs ->
67 PConstraints.t * rel_context * template_subst
68
69 val constrained_type_of_inductive : mind_specif puniverses -> types constrained
70
71 val relevance_of_ind_body : one_inductive_body -> UVars.Instance.t -> Sorts.relevance
72
73 val relevance_of_inductive : env -> pinductive -> Sorts.relevance
74
75 val type_of_inductive : mind_specif puniverses -> types
76
77 val type_of_inductive_knowing_parameters :
78 mind_specif puniverses -> param_univs -> types constrained
79
80 (** Elimination operations.
81 These functions handle the internals of elimination.
82 Call them instead of the lower-level ones like [QGraph.eliminates_to]. *)
83
84 val raw_eliminates_to : Sorts.Quality.t -> Sorts.Quality.t -> bool
85 (* Warning: this function does not handle [QVar]s properly: it only allows
86 elimination on the same [QVar]. Use [eliminates_to] for a proper handling of
87 variables. *)
88
89 val eliminates_to : QGraph.t -> Sorts.Quality.t -> Sorts.Quality.t -> bool
90
91 val sort_eliminates_to : QGraph.t -> Sorts.t -> Sorts.t -> bool
92
93 type squash = SquashToSet | SquashToQuality of Sorts.Quality.t
94
95 type 'a allow_elimination_actions =
96 { not_squashed : 'a
97 ; squashed_to_set_below : 'a
98 ; squashed_to_set_above : 'a
99 ; squashed_to_quality : Sorts.Quality.t -> 'a }
100
101 val is_squashed_gen : QGraph.t -> (Sorts.Quality.t -> Sorts.Quality.t)
102 -> mind_specif puniverses
103 -> squash option
104
105 val allowed_elimination_gen : QGraph.t -> (Sorts.Quality.t -> Sorts.Quality.t)
106 -> 'b allow_elimination_actions -> mind_specif puniverses -> Sorts.t -> 'b
107
108 val is_squashed : env -> mind_specif puniverses -> squash option
109
110 val is_allowed_elimination_actions : QGraph.t -> Sorts.t -> bool allow_elimination_actions
111
112 val is_allowed_elimination : env -> mind_specif puniverses -> Sorts.t -> bool
113 val is_allowed_fixpoint : (Sorts.Quality.t -> Sorts.Quality.t -> bool)
114 -> Sorts.t -> Sorts.t -> bool
115
116 (** End of elimination functions *)
117
118 val is_private : mind_specif -> bool
119 val is_primitive_record : mind_specif -> bool
120
121 (** Return type as quoted by the user *)
122
123 val constrained_type_of_constructor : pconstructor -> mind_specif -> types constrained
124 val type_of_constructor : pconstructor -> mind_specif -> types
125 val type_of_constructor_knowing_parameters : pconstructor -> mind_specif -> param_univs -> types constrained
126
127 (** Return constructor types in normal form *)
128 val arities_of_constructors : pinductive -> mind_specif -> types array
129
130 (** Return constructor types in user form *)
131 val type_of_constructors : pinductive -> mind_specif -> types array
132
133 (** Turns a constructor type recursively referring to inductive types
134 into the same constructor type referring instead to a context made
135 from the abstract declaration of the inductive types (e.g. turns
136 [nat->nat] into [mkArrowR (Rel 1) (Rel 2)]); takes as arguments the number
137 of inductive types in the block and the name of the block *)
138 val abstract_constructor_type_relatively_to_inductive_types_context :
139 int -> MutInd.t -> types -> types
140
141 val inductive_params : mind_specif -> int
142
143 (** Given an inductive type and its parameters, builds the context of the return
144 clause, including the inductive being eliminated. The additional binder
145 array is only used to set the names of the context variables, we use the
146 less general type to make it easy to use this function on Case nodes. *)
147 val expand_arity : mind_specif -> pinductive -> constr array ->
148 Name.t binder_annot array -> rel_context
149
150 (** Given an inductive type and its parameters, builds the context of the return
151 clause, including the inductive being eliminated. The additional binder
152 array is only used to set the names of the context variables, we use the
153 less general type to make it easy to use this function on Case nodes. *)
154 val expand_branch_contexts : mind_specif -> UVars.Instance.t -> constr array ->
155 (Name.t binder_annot array * 'a) array -> rel_context array
156
157 type ('constr,'types,'r) pexpanded_case =
158 (case_info * ('constr * 'r) * 'constr pcase_invert * 'constr * 'constr array)
159
160 type expanded_case = (constr,types,Sorts.relevance) pexpanded_case
161
162 (** Given a pattern-matching represented compactly, expands it so as to produce
163 lambda and let abstractions in front of the return clause and the pattern
164 branches. *)
165 val expand_case : env -> case -> expanded_case
166
167 val expand_case_specif : mutual_inductive_body -> case -> expanded_case
168
169 (** Dual operation of the above. Fails if the return clause or branch has not
170 the expected form. *)
171 val contract_case : env -> expanded_case -> case
172
173 (** [instantiate_context u subst nas ctx] applies both [u] and [subst]
174 to [ctx] while replacing names using [nas] (order reversed). In particular,
175 assumes that [ctx] and [nas] have the same length. *)
176 val instantiate_context : Instance.t -> Vars.substl -> Name.t binder_annot array ->
177 rel_context -> rel_context
178
179 val build_branches_type :
180 pinductive -> mutual_inductive_body * one_inductive_body ->
181 constr list -> constr -> types array
182
183 (** Check a [case_info] actually correspond to a Case expression on the
184 given inductive type. *)
185 val check_case_info : env -> pinductive -> case_info -> unit
186
187 (** {6 Guard conditions for fix and cofix-points. } *)
188
189 (** [is_primitive_positive_container env c] tells if the constant [c] is
190 registered as a primitive type that can be seen as a container where the
191 occurrences of its parameters are positive, in which case the positivity and
192 guard conditions are extended to allow inductive types to nest their subterms
193 in these containers. *)
194 val is_primitive_positive_container : env -> Constant.t -> bool
195
196 (** When [chk] is false, the guard condition is not actually
197 checked. *)
198 val check_fix : ?evars:evar_handler -> ?elim_to:(Sorts.Quality.t -> Sorts.Quality.t -> bool) -> env -> fixpoint -> unit
199 val check_cofix : ?evars:evar_handler -> env -> cofixpoint -> unit
200
201 val abstract_mind_lc : int -> int -> MutInd.t -> (rel_context * constr) array -> constr array
202
203 module Template : sig
204 val bind_kind : Sorts.t -> int option * int option
205 val template_subst_sort : template_subst -> Sorts.t -> Sorts.t
206
207 (** Qualities must be above_prop *)
208 val max_template_quality : Sorts.Quality.t -> Sorts.Quality.t -> Sorts.Quality.t
209 end