Debian Codegraph @

vernac/vernacexpr.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 Constrexpr
13 open Libnames
14
15 (** Vernac expressions, produced by the parser *)
16 type coercion_class = FunClass | SortClass | RefClass of qualid or_by_notation
17
18 type goal_identifier = string
19 type scope_name = string
20
21 type scope_delimiter = delimiter_depth * scope_name
22
23 type goal_reference =
24 | OpenSubgoals
25 | NthGoal of int
26 | GoalId of qualid
27
28 type debug_univ_name =
29 | NamedUniv of qualid
30 | RawUniv of lstring
31
32 type print_universes = {
33 sort : bool;
34 subgraph : debug_univ_name list option;
35 with_sources : bool option;
36 file : string option;
37 }
38
39 type printable =
40 | PrintTypingFlags
41 | PrintTables
42 | PrintFullContext
43 | PrintSectionContext of qualid
44 | PrintInspect of int
45 | PrintGrammar of string list
46 | PrintCustomGrammar of qualid
47 | PrintKeywords
48 | PrintLoadPath of DirPath.t option
49 | PrintLibraries
50 | PrintModule of qualid
51 | PrintModuleType of qualid
52 | PrintNamespace of DirPath.t
53 | PrintMLLoadPath
54 | PrintMLModules
55 | PrintDebugGC
56 | PrintName of qualid or_by_notation * UnivNames.full_name_list option
57 | PrintGraph
58 | PrintClasses
59 | PrintTypeclasses
60 | PrintInstances of qualid or_by_notation
61 | PrintCoercions
62 | PrintCoercionPaths of coercion_class * coercion_class
63 | PrintCanonicalConversions of qualid or_by_notation list
64 | PrintUniverses of print_universes
65 | PrintSorts
66 | PrintHint of qualid or_by_notation
67 | PrintHintGoal
68 | PrintHintDbName of string
69 | PrintHintDb
70 | PrintScopes
71 | PrintScope of string
72 | PrintVisibility of string option
73 | PrintAbout of qualid or_by_notation * UnivNames.full_name_list option * Goal_select.t option
74 | PrintImplicit of qualid or_by_notation
75 | PrintAssumptions of bool * bool * qualid or_by_notation list
76 | PrintStrategy of qualid or_by_notation option
77 | PrintRegistered
78 | PrintRegisteredSchemes
79 | PrintNotation of qualid Constrexpr.notation_entry_gen * string
80
81 type glob_search_where = InHyp | InConcl | Anywhere
82
83 type search_item =
84 | SearchSubPattern of (glob_search_where * bool) * constr_pattern_expr
85 | SearchString of (glob_search_where * bool) * string * scope_delimiter option
86 | SearchKind of Decls.logical_kind
87
88 type search_request =
89 | SearchLiteral of search_item
90 | SearchDisjConj of (bool * search_request) list list
91
92 type searchable =
93 | SearchPattern of constr_pattern_expr
94 | SearchRewrite of constr_pattern_expr
95 | Search of (bool * search_request) list
96
97 type locatable =
98 | LocateAny of qualid or_by_notation
99 | LocateTerm of qualid or_by_notation
100 | LocateLibrary of qualid
101 | LocateModule of qualid
102 | LocateOther of string * qualid
103 | LocateFile of string
104
105 type showable =
106 | ShowGoal of goal_reference
107 | ShowProof
108 | ShowExistentials
109 | ShowUniverses
110 | ShowProofNames
111 | ShowIntros of bool
112 | ShowMatch of qualid
113
114 type comment =
115 | CommentConstr of constr_expr
116 | CommentString of string
117 | CommentInt of int
118
119 type 'a search_restriction =
120 | SearchInside of 'a
121 | SearchOutside of 'a
122
123 type verbose_flag = bool (* true = Verbose; false = Silent *)
124 type coercion_flag = AddCoercion | NoCoercion
125 type instance_flag = BackInstance | NoInstance
126
127 type export_flag = Lib.export_flag = Export | Import
128
129 type import_categories = {
130 negative : bool;
131 import_cats : string CAst.t list;
132 }
133
134 type export_with_cats = export_flag * import_categories option
135
136 type infix_flag = bool (* true = Infix; false = Notation *)
137
138 type one_import_filter_name = qualid * bool (* import inductive components *)
139 type import_filter_expr =
140 | ImportAll
141 | ImportNames of one_import_filter_name list
142
143 type locality_flag = bool (* true = Local *)
144
145 type option_setting =
146 | OptionUnset
147 | OptionSetTrue
148 | OptionSetInt of int
149 | OptionSetString of string
150
151 (** Identifier and optional list of bound universes and constraints. *)
152
153 type definition_expr =
154 | ProveBody of local_binder_expr list * constr_expr
155 | DefineBody of local_binder_expr list * Redexpr.raw_red_expr option * constr_expr
156 * constr_expr option
157
158 type notation_format =
159 | TextFormat of lstring
160
161 type syntax_modifier =
162 | SetItemLevel of string list * Notation_term.notation_binder_kind option * Extend.production_level
163 | SetItemScope of string list * scope_name
164 | SetLevel of int
165 | SetCustomEntry of qualid * int option
166 | SetAssoc of Gramlib.Gramext.g_assoc
167 | SetEntryType of string * qualid Extend.simple_constr_prod_entry_key
168 | SetOnlyParsing
169 | SetOnlyPrinting
170 | SetFormat of notation_format
171
172 type notation_enable_modifier =
173 | EnableNotationEntry of qualid notation_entry_gen
174 | EnableNotationOnly of Notationextern.notation_use
175 | EnableNotationAll
176
177 type notation_declaration =
178 { ntn_decl_string : lstring
179 ; ntn_decl_interp : constr_expr
180 ; ntn_decl_scope : scope_name option
181 ; ntn_decl_modifiers : syntax_modifier CAst.t list
182 }
183
184 type recursion_order_expr =
185 | CFixRecOrder of fixpoint_order_expr option list
186 | CCoFixRecOrder
187 | CUnknownRecOrder
188
189 type recursive_expr_gen =
190 { fname : lident
191 ; univs : universe_decl_expr option
192 ; binders : local_binder_expr list
193 ; rtype : constr_expr
194 ; body_def : constr_expr option
195 ; notations : notation_declaration list
196 }
197
198 type fixpoint_expr = fixpoint_order_expr option * recursive_expr_gen
199 type fixpoints_expr = fixpoint_order_expr option list * recursive_expr_gen list
200 type cofixpoints_expr = recursive_expr_gen list
201 type recursives_expr = recursion_order_expr * recursive_expr_gen list
202
203 type local_decl_expr =
204 | AssumExpr of lname * local_binder_expr list * constr_expr
205 | DefExpr of lname * local_binder_expr list * constr_expr * constr_expr option
206
207 type inductive_kind = Inductive_kw | CoInductive | Variant | Record | Structure | Class of bool (* true = definitional, false = inductive *)
208 type simple_binder = lident list * constr_expr
209 type class_binder = lident * constr_expr list
210 type 'a with_coercion = coercion_flag * 'a
211 type 'a with_coercion_instance = (Attributes.vernac_flags * coercion_flag * instance_flag) * 'a
212 (* Same before parsing the attributes *)
213 type record_field_attr_unparsed = {
214 rfu_attrs: Attributes.vernac_flags;
215 rfu_coercion: coercion_flag;
216 rfu_instance: instance_flag;
217 rfu_priority: int option;
218 rfu_notation: notation_declaration list;
219 }
220 type constructor_expr = (lident * constr_expr) with_coercion_instance
221 type constructor_list_or_record_decl_expr =
222 | Constructors of constructor_expr list
223 | RecordDecl of lident option * (local_decl_expr * record_field_attr_unparsed) list * lident option
224 type inductive_params_expr = local_binder_expr list * local_binder_expr list option
225 (** If the option is nonempty the "|" marker was used *)
226
227 type inductive_expr =
228 cumul_ident_decl with_coercion
229 * inductive_params_expr * constr_expr option
230 * constructor_list_or_record_decl_expr
231
232 type one_inductive_expr =
233 lident * inductive_params_expr * constr_expr option * constructor_expr list
234
235 type typeclass_constraint = name_decl * Glob_term.binding_kind * constr_expr
236 and typeclass_context = typeclass_constraint list
237
238 type proof_expr =
239 ident_decl * (local_binder_expr list * constr_expr)
240
241 type opacity_flag = Opaque | Transparent
242
243 type proof_end =
244 | Admitted
245 (* name in `Save ident` when closing goal *)
246 | Proved of opacity_flag * lident option
247
248 type scheme_type =
249 | SchemeInduction
250 | SchemeMinimality
251 | SchemeElimination
252 | SchemeCase
253
254 type equality_scheme_type =
255 | SchemeBooleanEquality
256 | SchemeEquality
257 | SchemeRewriting
258
259 (* The data of a Scheme decleration *)
260 type scheme = {
261 sch_type : scheme_type ;
262 sch_qualid : Libnames.qualid Constrexpr.or_by_notation ;
263 sch_sort : UnivGen.QualityOrSet.t ;
264 }
265
266 type section_subset_expr =
267 | SsEmpty
268 | SsType
269 | SsSingl of lident
270 | SsCompl of section_subset_expr
271 | SsUnion of section_subset_expr * section_subset_expr
272 | SsSubstr of section_subset_expr * section_subset_expr
273 | SsFwdClose of section_subset_expr
274
275 (** Extension identifiers for the VERNAC EXTEND mechanism.
276
277 {b ("Extraction", 0} indicates {b Extraction {i qualid}} command.
278
279 {b ("Extraction", 1} indicates {b Recursive Extraction {i qualid}} command.
280
281 {b ("Extraction", 2)} indicates {b Extraction "{i filename}" {i qualid{_ 1}} ... {i qualid{_ n}}} command.
282
283 {b ("ExtractionLibrary", 0)} indicates {b Extraction Library {i ident}} command.
284
285 {b ("RecursiveExtractionLibrary", 0)} indicates {b Recursive Extraction Library {i ident}} command.
286
287 {b ("SeparateExtraction", 0)} indicates {b Separate Extraction {i qualid{_ 1}} ... {i qualid{_ n}}} command.
288
289 {b ("ExtractionLanguage", 0)} indicates {b Extraction Language Ocaml} or {b Extraction Language Haskell} or {b Extraction Language Scheme} or {b Extraction Language JSON} commands.
290
291 {b ("ExtractionImplicit", 0)} indicates {b Extraction Implicit {i qualid} \[ {i ident{_1}} ... {i ident{_n} } \] } command.
292
293 {b ("ExtractionConstant", 0)} indicates {b Extract Constant {i qualid} => {i string}} command.
294
295 {b ("ExtractionInlinedConstant", 0)} indicates {b Extract Inlined Constant {i qualid} => {i string}} command.
296
297 {b ("ExtractionInductive", 0)} indicates {b Extract Inductive {i qualid} => {i string} [ {i string} ... {string} ] {i optstring}} command.
298
299 {b ("ExtractionBlacklist", 0)} indicates {b Extraction Blacklist {i ident{_1}} ... {i ident{_n}}} command.
300 *)
301
302 (* This type allows registering the inlining of constants in native compiler.
303 It will be extended with primitive inductive types and operators *)
304 type register_kind =
305 | RegisterInline
306 | RegisterCoqlib of qualid
307 | RegisterScheme of { inductive : qualid; scheme_kind : qualid }
308
309 (** {6 Types concerning the module layer} *)
310
311 type module_ast_inl = module_ast * Declaremods.inline
312 type module_binder = export_with_cats option * lident list * module_ast_inl
313
314 (** {6 The type of vernacular expressions} *)
315
316 type vernac_one_argument_status = {
317 name : Name.t;
318 recarg_like : bool;
319 notation_scope : scope_delimiter CAst.t list;
320 implicit_status : Glob_term.binding_kind;
321 }
322
323 type vernac_argument_status =
324 | VolatileArg | BidiArg
325 | RealArg of vernac_one_argument_status
326
327 type arguments_modifier =
328 [ `Assert
329 | `ClearBidiHint
330 | `ClearImplicits
331 | `ClearReduction
332 | `ClearScopes
333 | `DefaultImplicits
334 | `ExtraScopes
335 | `SimplDontExposeCase (* simpl nomatch *)
336 | `SimplNeverUnfold (* simpl never *)
337 | `Rename ]
338
339 type extend_name = {
340 ext_plugin : string;
341 (** Name of the plugin where the extension is defined as per DECLARE PLUGIN *)
342 ext_entry : string;
343 (** Name of the vernac entry where the tactic is defined, typically found
344 after the VERNAC EXTEND statement in the source. *)
345 ext_index : int;
346 (* Index of the extension in the VERNAC EXTEND statement. Each parsing branch
347 is given an offset, starting from zero. *)
348 }
349
350 type discharge = DoDischarge | NoDischarge
351
352 type hint_info_expr = Constrexpr.constr_pattern_expr Typeclasses.hint_info_gen
353
354 type reference_or_constr =
355 | HintsReference of Libnames.qualid
356 | HintsConstr of Constrexpr.constr_expr
357
358 type hints_expr =
359 | HintsResolve of (hint_info_expr * bool * reference_or_constr) list
360 | HintsResolveIFF of bool * Libnames.qualid list * int option
361 | HintsImmediate of reference_or_constr list
362 | HintsUnfold of Libnames.qualid list
363 | HintsTransparency of Libnames.qualid Hints.hints_transparency_target * bool
364 | HintsMode of Libnames.qualid * Hints.hint_mode list
365 | HintsConstructors of Libnames.qualid list
366 | HintsExtern of int * Constrexpr.constr_expr option * Gentactic.raw_generic_tactic
367
368 (** [synterp_vernac_expr] describes the AST of commands which have effects on
369 parsing or parsing extensions *)
370 type synterp_vernac_expr =
371 | VernacLoad of verbose_flag * string
372 | VernacReservedNotation of infix_flag * (lstring * syntax_modifier CAst.t list)
373 | VernacNotation of
374 infix_flag * notation_declaration
375 | VernacDeclareCustomEntry of Id.t
376 | VernacBeginSection of lident
377 | VernacEndSegment of lident
378 | VernacRequire of
379 qualid option * export_with_cats option * (qualid * import_filter_expr) list
380 | VernacImport of export_with_cats * (qualid * import_filter_expr) list
381 (* Modules and Module Types *)
382 | VernacDeclareModule of export_with_cats option * lident *
383 module_binder list * module_ast_inl
384 | VernacDefineModule of export_with_cats option * lident * module_binder list *
385 module_ast_inl Declaremods.module_signature * module_ast_inl list
386 | VernacDeclareModuleType of lident *
387 module_binder list * module_ast_inl list * module_ast_inl list
388 | VernacInclude of module_ast_inl list
389
390 (* Auxiliary file and library management *)
391 | VernacDeclareMLModule of string list
392 | VernacChdir of string option
393 | VernacExtraDependency of qualid * string * Id.t option
394
395 | VernacSetOption of bool (* Export modifier? *) * Goptions.option_name * option_setting
396 | VernacProofMode of string
397
398 (* For extension *)
399 | VernacExtend of extend_name * Genarg.raw_generic_argument list
400
401 (** [synpure_vernac_expr] describes the AST of commands which have no effect on
402 parsing or parsing extensions. On these ASTs, the syntactic interpretation
403 phase is the identity. *)
404 type nonrec synpure_vernac_expr =
405
406 (* Syntax *)
407 | VernacOpenCloseScope of bool * scope_name
408 | VernacDeclareScope of scope_name
409 | VernacDelimiters of scope_name * string option
410 | VernacBindScope of scope_name * coercion_class list
411 | VernacEnableNotation of bool * (string, Id.t list * qualid) Util.union option * constr_expr option * notation_enable_modifier list * notation_with_optional_scope option
412
413 (* Gallina *)
414 | VernacDefinition of (discharge * Decls.definition_object_kind) * name_decl * definition_expr
415 | VernacStartTheoremProof of Decls.theorem_kind * proof_expr list
416 | VernacEndProof of proof_end
417 | VernacExactProof of constr_expr
418 | VernacAssumption of (discharge * Decls.assumption_object_kind) *
419 Declaremods.inline * (ident_decl list * constr_expr) with_coercion list
420 | VernacSymbol of (ident_decl list * constr_expr) with_coercion list
421 | VernacInductive of inductive_kind * (inductive_expr * notation_declaration list) list
422 | VernacFixpoint of discharge * fixpoints_expr
423 | VernacCoFixpoint of discharge * cofixpoints_expr
424 | VernacSchemeAll of Libnames.qualid Constrexpr.or_by_notation * (Id.t list) option
425 | VernacScheme of (lident option * scheme) list
426 | VernacSchemeEquality of equality_scheme_type * Libnames.qualid Constrexpr.or_by_notation
427 | VernacCombinedScheme of lident * lident list
428 | VernacUniverse of lident list
429 | VernacSort of lident list
430 | VernacConstraint of sort_constraint_expr list
431 | VernacAddRewRule of lident * (universe_decl_expr option * constr_expr * constr_expr) list
432
433 (* Gallina extensions *)
434 | VernacCanonical of qualid or_by_notation
435 | VernacCoercion of qualid or_by_notation *
436 (coercion_class * coercion_class) option
437 | VernacIdentityCoercion of lident * coercion_class * coercion_class
438 | VernacNameSectionHypSet of lident * section_subset_expr
439
440 (* Type classes *)
441 | VernacInstance of
442 name_decl * (* name *)
443 local_binder_expr list * (* binders *)
444 constr_expr * (* type *)
445 (bool * constr_expr) option * (* body (bool=true when using {}) *)
446 hint_info_expr
447
448 | VernacDeclareInstance of
449 ident_decl * (* name *)
450 local_binder_expr list * (* binders *)
451 constr_expr * (* type *)
452 hint_info_expr
453
454 | VernacContext of local_binder_expr list
455
456 | VernacExistingInstance of
457 (qualid * hint_info_expr) list (* instances names, priorities and patterns *)
458
459 | VernacExistingClass of qualid (* inductive or definition name *)
460
461 (* Resetting *)
462 | VernacResetName of lident
463 | VernacResetInitial
464 | VernacBack of int
465
466 (* Commands *)
467 | VernacCreateHintDb of string * bool
468 | VernacRemoveHints of string list * qualid list
469 | VernacHints of string list * hints_expr
470 | VernacAbbreviation of
471 lident * (Id.t list * constr_expr) * syntax_modifier CAst.t list
472 * Loc.t option (* warn about old deprecated "Notation" keyword, to remove when removing it *)
473 | VernacArguments of
474 qualid or_by_notation *
475 vernac_argument_status list (* Main arguments status list *) *
476 (Name.t * Glob_term.binding_kind) list list (* Extra implicit status lists *) *
477 arguments_modifier list
478 | VernacReserve of simple_binder list
479 | VernacGeneralizable of (lident list) option
480 | VernacSetOpacity of (Conv_oracle.level * qualid or_by_notation list) * bool
481 | VernacSetStrategy of
482 (Conv_oracle.level * qualid or_by_notation list) list
483 | VernacMemOption of Goptions.option_name * Goptions.table_value list
484 | VernacPrintOption of Goptions.option_name
485 | VernacCheckMayEval of Redexpr.raw_red_expr option * Goal_select.t option * constr_expr
486 | VernacGlobalCheck of constr_expr
487 | VernacDeclareReduction of string * Redexpr.raw_red_expr
488 | VernacPrint of printable
489 | VernacSearch of searchable * Goal_select.t option * qualid list search_restriction
490 | VernacLocate of locatable
491 | VernacRegister of qualid * register_kind
492 | VernacPrimitive of ident_decl * CPrimitives.op_or_type * constr_expr option
493 | VernacComments of comment list
494 | VernacAttributes of Attributes.vernac_flags
495
496 (* Proof management *)
497 | VernacAbort
498 | VernacAbortAll
499 | VernacRestart
500 | VernacUndo of int
501 | VernacUndoTo of int
502 | VernacFocus of int option
503 | VernacUnfocus
504 | VernacUnfocused
505 | VernacBullet of Proof_bullet.t
506 | VernacSubproof of Goal_select.t option
507 | VernacEndSubproof
508 | VernacShow of showable
509 | VernacCheckGuard
510 | VernacValidateProof
511 | VernacProof of Gentactic.raw_generic_tactic option * section_subset_expr option
512
513 | VernacAddOption of Goptions.option_name * Goptions.table_value list
514 | VernacRemoveOption of Goptions.option_name * Goptions.table_value list
515
516 (** We classify vernacular expressions in two categories. [VernacSynterp]
517 represents commands which have an effect on parsing or on parsing extensions.
518 [VernacSynPure] represents commands which have no such effects. *)
519 type 'a vernac_expr_gen =
520 | VernacSynterp of 'a
521 | VernacSynPure of synpure_vernac_expr
522
523 type vernac_expr = synterp_vernac_expr vernac_expr_gen
524
525 type control_flag_r =
526 | ControlTime
527 | ControlInstructions
528 | ControlProfile of string option
529 | ControlRedirect of string
530 | ControlTimeout of int
531 | ControlFail
532 | ControlSucceed
533
534 type control_flag = control_flag_r CAst.t
535
536 type ('a, 'b) vernac_control_gen_r =
537 { control : 'a list
538 ; attrs : Attributes.vernac_flags
539 ; expr : 'b vernac_expr_gen
540 }
541 and 'a vernac_control_gen = (control_flag, 'a) vernac_control_gen_r CAst.t
542
543 type vernac_control = synterp_vernac_expr vernac_control_gen