Debian Codegraph @

interp/notation_term.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 Glob_term
13
14 (** [notation_constr] *)
15
16 (** [notation_constr] is the subtype of [glob_constr] allowed in syntactic
17 extensions (i.e. notations).
18 No location since intended to be substituted at any place of a text.
19 Complex expressions such as fixpoints and cofixpoints are excluded,
20 as well as non global expressions such as existential variables. *)
21
22 type notation_constr =
23 (* Part common to [glob_constr] and [cases_pattern] *)
24 | NRef of GlobRef.t * glob_instance option
25 | NVar of Id.t
26 | NApp of notation_constr * notation_constr list
27 | NProj of (Constant.t * glob_instance option) * notation_constr list * notation_constr
28 | NHole of glob_evar_kind
29 | NGenarg of Genarg.glob_generic_argument
30 | NList of Id.t * Id.t * notation_constr * notation_constr * (* associativity: *) bool
31 (* Part only in [glob_constr] *)
32 | NLambda of Name.t * notation_constr option * notation_constr
33 | NProd of Name.t * notation_constr option * notation_constr
34 | NBinderList of Id.t * Id.t * notation_constr * notation_constr * (* associativity: *) bool
35 | NLetIn of Name.t * notation_constr * notation_constr option * notation_constr
36 | NCases of Constr.case_style * notation_constr option *
37 (notation_constr * (Name.t * (inductive * Name.t list) option)) list *
38 (cases_pattern list * notation_constr) list
39 | NLetTuple of Name.t list * (Name.t * notation_constr option) *
40 notation_constr * notation_constr
41 | NIf of notation_constr * (Name.t * notation_constr option) *
42 notation_constr * notation_constr
43 | NRec of glob_fix_kind * Id.t array *
44 (Name.t * notation_constr option * notation_constr) list array *
45 notation_constr array * notation_constr array
46 | NSort of glob_sort
47 | NCast of notation_constr * Constr.cast_kind option * notation_constr
48 | NInt of Uint63.t
49 | NFloat of Float64.t
50 | NString of Pstring.t
51 | NArray of notation_constr array * notation_constr * notation_constr
52
53 (** Note concerning NList: first constr is iterator, second is terminator;
54 first id is where each argument of the list has to be substituted
55 in iterator and snd id is alternative name just for printing;
56 boolean is associativity *)
57
58 (** Types concerning notations *)
59
60 type scope_name = string
61
62 type tmp_scope_name = scope_name
63
64 type subscopes = tmp_scope_name list * scope_name list
65
66 type extended_subscopes = Constrexpr.notation_entry_relative_level * subscopes
67
68 (** Type of the meta-variables of an notation_constr: in a recursive pattern x..y,
69 x carries the sequence of objects bound to the list x..y *)
70
71 type notation_binder_kind =
72 (* This accepts only ident *)
73 | AsIdent
74 (* This accepts only name *)
75 | AsName
76 (* This accepts pattern *)
77 | AsAnyPattern
78 (* This accepts only strict pattern (i.e. no single variable) at printing *)
79 | AsStrictPattern
80
81 type notation_binder_source =
82 (* Parsed as constr and constrained to be ident, name or pattern, depending on kind *)
83 | NtnBinderParsedAsConstr of notation_binder_kind
84 (* Parsed and interpreted as ident, name or pattern, depending on kind *)
85 | NtnBinderParsedAsSomeBinderKind of notation_binder_kind
86 (* Parsed as open or closed binder: This accepts ident, _, quoted pattern, etc. *)
87 | NtnBinderParsedAsBinder
88
89 type notation_var_instance_type =
90 | NtnTypeConstr
91 | NtnTypeConstrList
92 | NtnTypeBinder of notation_binder_source
93 | NtnTypeBinderList of notation_binder_source
94
95 (** Type of variables when interpreting a constr_expr as a notation_constr:
96 in a recursive pattern x..y, both x and y carry the individual type
97 of each element of the list x..y *)
98 type notation_var_internalization_type =
99 | NtnInternTypeAny of scope_name option
100 | NtnInternTypeOnlyBinder
101
102 (** The set of other notation variables that are bound to a binder or
103 binder list and that bind the given notation variable, for
104 instance, in ["{ x | P }" := (sigT (fun x => P)], "x" is under an
105 empty set of binders and "P" is under the binders bound to "x",
106 that is, its notation_var_binders set is "x" *)
107 type notation_var_binders = Id.Set.t
108
109 (** This characterizes to what a notation is interpreted to *)
110 type 'a interpretation_gen = (Id.t * 'a) list * notation_constr
111 type interpretation = (extended_subscopes * notation_var_binders * notation_var_instance_type) interpretation_gen
112
113 type forgetfulness = { forget_ltac : bool; forget_volatile_cast : bool }
114
115 type reversibility_status =
116 | APrioriReversible
117 | Forgetful of forgetfulness
118 | NonInjective of Id.t list
119
120 type notation_interp_env = {
121 ninterp_var_type : notation_var_internalization_type Id.Map.t;
122 ninterp_rec_vars : Id.t Id.Map.t;
123 }