Debian Codegraph @

interp/constrexpr.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 Libnames
13
14 (** {6 Concrete syntax for terms } *)
15
16 (** Universes *)
17 type sort_name_expr =
18 | CSProp | CProp | CSet
19 | CType of qualid
20 | CRawType of Univ.Level.t (** Universes like "foo.1" have no qualid form *)
21
22 type univ_level_expr = sort_name_expr Glob_term.glob_sort_gen
23
24 type qvar_expr =
25 | CQVar of qualid
26 | CQAnon of Loc.t option
27 | CRawQVar of Sorts.QVar.t
28
29 type quality_expr =
30 | CQConstant of Sorts.Quality.constant
31 | CQualVar of qvar_expr
32
33 type relevance_expr =
34 | CRelevant | CIrrelevant
35 | CRelevanceVar of qvar_expr
36
37 type relevance_info_expr = relevance_expr option
38
39 type sort_expr = (qvar_expr option * (sort_name_expr * int) list Glob_term.glob_sort_gen)
40
41 type instance_expr = quality_expr list * univ_level_expr list
42
43 (** UnivConstraints don't have anonymous universes *)
44 type univ_constraint_expr = sort_name_expr * Univ.UnivConstraint.kind * sort_name_expr
45 type elim_constraint_expr = quality_expr * Sorts.ElimConstraint.kind * quality_expr
46
47 type sort_constraint_expr =
48 | UnivCst of univ_constraint_expr
49 | ElimCst of elim_constraint_expr
50
51 type universe_decl_expr = (lident list, elim_constraint_expr list, lident list, univ_constraint_expr list) UState.gen_universe_decl
52 type cumul_univ_decl_expr =
53 (lident list, elim_constraint_expr list, (lident * UVars.Variance.t option) list, univ_constraint_expr list) UState.gen_universe_decl
54
55 type ident_decl = lident * universe_decl_expr option
56 type cumul_ident_decl = lident * cumul_univ_decl_expr option
57 type name_decl = lname * universe_decl_expr option
58
59 type notation_with_optional_scope = LastLonelyNotation | NotationInScope of string
60
61 type side = Left | Right
62 type entry_level = int
63 type entry_relative_level = LevelLt of entry_level | LevelLe of entry_level | LevelSome
64
65 (* The entry in which a notation is declared *)
66 type 'name notation_entry_gen = InConstrEntry | InCustomEntry of 'name
67 type notation_entry = Globnames.CustomName.t notation_entry_gen
68
69 (* A notation entry with the level where the notation lives *)
70 type notation_entry_level = {
71 notation_entry : notation_entry;
72 notation_level : entry_level;
73 }
74
75 (* Notation subentries, to be associated to the variables of the notation *)
76 type notation_entry_relative_level = {
77 notation_subentry : notation_entry;
78 notation_relative_level : entry_relative_level;
79 notation_position : side option;
80 }
81
82 type notation_key = string
83
84 (* A notation associated to a given parsing rule *)
85 type notation = notation_entry * notation_key
86
87 (* A notation associated to a given interpretation *)
88 type specific_notation = notation_with_optional_scope * notation
89
90 type 'a or_by_notation_r =
91 | AN of 'a
92 | ByNotation of (string * string option)
93
94 type 'a or_by_notation = 'a or_by_notation_r CAst.t
95
96 (* NB: the last string in [ByNotation] is actually a [Notation.delimiters],
97 but this formulation avoids a useless dependency. *)
98
99 type explicitation =
100 | ExplByName of Id.t
101 | ExplByPos of int (* a reference to the n-th non-dependent implicit starting from left *)
102
103 type binder_kind =
104 | Default of Glob_term.binding_kind
105 | Generalized of Glob_term.binding_kind * bool
106 (** (Inner binding always Implicit) Outer bindings, typeclass-specific flag
107 for implicit generalization of superclasses *)
108
109 type explicit_flag = bool (** true = with "@" *)
110
111 type delimiter_depth = DelimOnlyTmpScope | DelimUnboundedScope
112 (** shallow (%_) vs. deep (%) scope opening *)
113
114 type prim_token =
115 | Number of NumTok.Signed.t
116 | String of string
117
118 (** [constr_expr] is the abstract syntax tree produced by the parser *)
119 type cases_pattern_expr_r =
120 | CPatAlias of cases_pattern_expr * lname
121 | CPatCstr of qualid
122 * cases_pattern_expr list option * cases_pattern_expr list
123 (** [CPatCstr (_, c, Some l1, l2)] represents [(@ c l1) l2] *)
124 | CPatAtom of qualid option
125 | CPatOr of cases_pattern_expr list
126 | CPatNotation of notation_with_optional_scope option * notation * cases_pattern_notation_substitution
127 * cases_pattern_expr list (** CPatNotation (_, n, l1 ,l2) represents
128 (notation n applied with substitution l1)
129 applied to arguments l2 *)
130 | CPatPrim of prim_token
131 | CPatRecord of (qualid * cases_pattern_expr) list
132 | CPatDelimiters of delimiter_depth * string * cases_pattern_expr
133 | CPatCast of cases_pattern_expr * constr_expr
134 and cases_pattern_expr = cases_pattern_expr_r CAst.t
135
136 and kinded_cases_pattern_expr = cases_pattern_expr * Glob_term.binding_kind
137
138 and cases_pattern_notation_substitution =
139 cases_pattern_expr list * (* for cases_pattern subterms parsed as terms *)
140 cases_pattern_expr list list * (* for recursive notations parsed as terms*)
141 kinded_cases_pattern_expr list (* for cases_pattern subterms parsed as binders *)
142
143 and constr_expr_r =
144 | CRef of qualid * instance_expr option
145 | CFix of lident * fix_expr list
146 | CCoFix of lident * cofix_expr list
147 | CProdN of local_binder_expr list * constr_expr
148 | CLambdaN of local_binder_expr list * constr_expr
149 | CLetIn of lname * constr_expr * constr_expr option * constr_expr
150 | CAppExpl of (qualid * instance_expr option) * constr_expr list
151 | CApp of constr_expr * (constr_expr * explicitation CAst.t option) list
152 | CProj of explicit_flag * (qualid * instance_expr option)
153 * (constr_expr * explicitation CAst.t option) list * constr_expr
154 | CRecord of (qualid * constr_expr) list
155
156 (* representation of the "let" and "match" constructs *)
157 | CCases of Constr.case_style (* determines whether this value represents "let" or "match" construct *)
158 * constr_expr option (* return-clause *)
159 * case_expr list
160 * branch_expr list (* branches *)
161
162 | CLetTuple of lname list * (lname option * constr_expr option) *
163 constr_expr * constr_expr
164 | CIf of constr_expr * (lname option * constr_expr option)
165 * constr_expr * constr_expr
166 | CHole of Evar_kinds.glob_evar_kind option
167 | CGenarg of Genarg.raw_generic_argument
168
169 (* because print for genargs wants to print directly the glob without an extern phase (??) *)
170 | CGenargGlob of Genarg.glob_generic_argument
171
172 | CPatVar of Pattern.patvar
173 | CEvar of Glob_term.existential_name CAst.t * (lident * constr_expr) list
174 | CSort of sort_expr
175 | CCast of constr_expr * Constr.cast_kind option * constr_expr
176 | CNotation of notation_with_optional_scope option * notation * constr_notation_substitution
177 | CGeneralization of Glob_term.binding_kind * constr_expr
178 | CPrim of prim_token
179 | CDelimiters of delimiter_depth * string * constr_expr
180 | CArray of instance_expr option * constr_expr array * constr_expr * constr_expr
181 and constr_expr = constr_expr_r CAst.t
182
183 and case_expr = constr_expr (* expression that is being matched *)
184 * lname option (* as-clause *)
185 * cases_pattern_expr option (* in-clause *)
186
187 and branch_expr =
188 (cases_pattern_expr list list * constr_expr) CAst.t
189
190 and fix_expr =
191 lident * relevance_info_expr
192 * fixpoint_order_expr option *
193 local_binder_expr list * constr_expr * constr_expr
194
195 and cofix_expr =
196 lident * relevance_info_expr * local_binder_expr list * constr_expr * constr_expr
197
198 and fixpoint_order_expr_r =
199 | CStructRec of lident
200 | CWfRec of lident * constr_expr
201 | CMeasureRec of lident option * constr_expr * constr_expr option (** argument, measure, relation *)
202 and fixpoint_order_expr = fixpoint_order_expr_r CAst.t
203
204 (* Anonymous defs allowed ?? *)
205 and local_binder_expr =
206 | CLocalAssum of lname list * relevance_info_expr * binder_kind * constr_expr
207 | CLocalDef of lname * relevance_info_expr * constr_expr * constr_expr option
208 | CLocalPattern of cases_pattern_expr
209
210 and constr_notation_substitution =
211 constr_expr list * (* for constr subterms *)
212 constr_expr list list * (* for recursive notations *)
213 kinded_cases_pattern_expr list * (* for binders *)
214 local_binder_expr list list (* for binder lists (recursive notations) *)
215
216 type constr_pattern_expr = constr_expr
217
218 (** Concrete syntax for modules and module types *)
219
220 type with_declaration_ast =
221 | CWith_Module of Id.t list CAst.t * qualid
222 | CWith_Definition of Id.t list CAst.t * universe_decl_expr option * constr_expr
223
224 type module_ast_r =
225 | CMident of qualid
226 | CMapply of module_ast * qualid
227 | CMwith of module_ast * with_declaration_ast
228 and module_ast = module_ast_r CAst.t