package coq
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=36577b55f4a4b1c64682c387de7abea932d0fd42fc0cd5406927dca344f53587
doc/coq-core.interp/Notation/index.html
Module Notation
Source
Notations
Printing
Equality on notation_entry
.
val notation_entry_level_eq :
Constrexpr.notation_entry_level ->
Constrexpr.notation_entry_level ->
bool
Equality on notation_entry_level
.
val notation_with_optional_scope_eq :
Constrexpr.notation_with_optional_scope ->
Constrexpr.notation_with_optional_scope ->
bool
Equality on notation
.
module NotationMap :
CMap.ExtS with type key = Constrexpr.notation and module Set := NotationSet
module SpecificNotationMap :
CMap.ExtS
with type key = Constrexpr.specific_notation
and module Set := SpecificNotationSet
Scopes
A scope is a set of interpreters for symbols + optional interpreter and printers for integers + optional delimiters
= scope_name list
Check where a scope is opened or not in a scope list, or in * the current opened scopes
Open scope
Declare delimiters for printing
Declare and uses back and forth an interpretation of primitive token
A number interpreter is the pair of an interpreter for **(hexa)decimal** numbers in terms and an optional interpreter in pattern, if non integer or negative numbers are not supported, the interpreter must fail with an appropriate error message
The unique id string below will be used to refer to a particular registered interpreter/uninterpreter of number or string notation. Using the same uid for different (un)interpreters will fail. If at most one interpretation of prim token is used per scope, then the scope name could be used as unique id.
val register_rawnumeral_interpretation :
?allow_overwrite:bool ->
prim_token_uid ->
rawnum prim_token_interpretation ->
unit
val register_bignumeral_interpretation :
?allow_overwrite:bool ->
prim_token_uid ->
Z.t prim_token_interpretation ->
unit
val register_string_interpretation :
?allow_overwrite:bool ->
prim_token_uid ->
string prim_token_interpretation ->
unit
* Number notation
exception PrimTokenNotationError of string
* Environ.env
* Evd.evar_map
* prim_token_notation_error
type int_ty = {
dec_uint : Names.inductive;
dec_int : Names.inductive;
hex_uint : Names.inductive;
hex_int : Names.inductive;
uint : Names.inductive;
int : Names.inductive;
}
type number_ty = {
int : int_ty;
decimal : Names.inductive;
hexadecimal : Names.inductive;
number : Names.inductive;
}
A postprocessing translation to_post
can be done after execution of the to_ty
interpreter. The reverse translation is performed before the of_ty
uninterpreter.
to_post
is an array of n
lists l_i
of tuples (f, t, args)
. When the head symbol of the translated term matches one of the f
in the list l_0
it is replaced by t
and its arguments are translated acording to args
where ToPostCopy
means that the argument is kept unchanged and ToPostAs k
means that the argument is recursively translated according to l_k
. ToPostHole
introduces an additional implicit argument hole (in the reverse translation, the corresponding argument is removed). ToPostCheck r
behaves as ToPostCopy
except in the reverse translation which fails if the copied term is not r
. When n
is null, no translation is performed.
type ('target, 'warning) prim_token_notation_obj = {
to_kind : 'target conversion_kind;
to_ty : Names.GlobRef.t;
to_post : (Names.GlobRef.t * Names.GlobRef.t * to_post_arg list) list array;
of_kind : 'target conversion_kind;
of_ty : Names.GlobRef.t;
ty_name : Libnames.qualid;
warning : 'warning;
}
type prim_token_interp_info =
| Uid of prim_token_uid
| NumberNotation of number_notation_obj
| StringNotation of string_notation_obj
type prim_token_infos = {
pt_local : bool;
(*Is this interpretation local?
*)pt_scope : Notation_term.scope_name;
(*Concerned scope
*)pt_interp_info : prim_token_interp_info;
(*Unique id "pointing" to (un)interp functions, OR a number notation object describing (un)interp functions
*)pt_required : required_module;
(*Module that should be loaded first
*)pt_refs : Names.GlobRef.t list;
(*Entry points during uninterpretation
*)pt_in_match : bool;
(*Is this prim token legal in match patterns ?
*)
}
Note: most of the time, the pt_refs
field above will contain inductive constructors (e.g. O and S for nat). But it could also be injection functions such as IZR for reals.
Activate a prim token interpretation whose unique id and functions have already been registered.
Compatibility. Avoid the next two functions, they will now store unnecessary objects in the library segment. Instead, combine register_*_interpretation
and enable_prim_token_interpretation
(the latter inside a Mltop.declare_cache_obj
).
val declare_numeral_interpreter :
?local:bool ->
Notation_term.scope_name ->
required_module ->
Z.t prim_token_interpreter ->
(Glob_term.glob_constr list * Z.t prim_token_uninterpreter * bool) ->
unit
val declare_string_interpreter :
?local:bool ->
Notation_term.scope_name ->
required_module ->
string prim_token_interpreter ->
(Glob_term.glob_constr list * string prim_token_uninterpreter * bool) ->
unit
Return the term
/cases_pattern
bound to a primitive token in a given scope context
val interp_prim_token :
?loc:Loc.t ->
Constrexpr.prim_token ->
Notation_term.subscopes ->
Glob_term.glob_constr * (notation_location * Notation_term.scope_name option)
val interp_prim_token_cases_pattern_expr :
?loc:Loc.t ->
(Names.GlobRef.t -> unit) ->
Constrexpr.prim_token ->
Notation_term.subscopes ->
Glob_term.glob_constr * (notation_location * Notation_term.scope_name option)
Return the primitive token associated to a term
/cases_pattern
; raise No_match
if no such token
val uninterp_prim_token :
'a Glob_term.glob_constr_g ->
Notation_term.subscopes ->
Constrexpr.prim_token * delimiters option
val uninterp_prim_token_cases_pattern :
'a Glob_term.cases_pattern_g ->
Notation_term.subscopes ->
Names.Name.t * Constrexpr.prim_token * delimiters option
val availability_of_prim_token :
Constrexpr.prim_token ->
Notation_term.scope_name ->
Notation_term.subscopes ->
delimiters option option
Declare and interpret back and forth a notation
Binds a notation in a given scope to an interpretation
val declare_uninterpretation :
?also_in_cases_pattern:bool ->
Notation_term.interp_rule ->
Notation_term.interpretation ->
unit
type entry_coercion_kind =
| IsEntryCoercion of Constrexpr.notation_entry_level
| IsEntryGlobal of string * int
| IsEntryIdent of string * int
val declare_notation :
(Constrexpr.notation_with_optional_scope * Constrexpr.notation) ->
Notation_term.interpretation ->
notation_location ->
use:notation_use ->
also_in_cases_pattern:bool ->
entry_coercion_kind option ->
Deprecation.t option ->
unit
val interp_notation :
?loc:Loc.t ->
Constrexpr.notation ->
Notation_term.subscopes ->
Notation_term.interpretation
* (notation_location * Notation_term.scope_name option)
Return the interpretation bound to a notation
type notation_rule =
Notation_term.interp_rule
* Notation_term.interpretation
* notation_applicative_status
Return the possible notations for a given term
val availability_of_notation :
Constrexpr.specific_notation ->
Notation_term.subscopes ->
(Notation_term.scope_name option * delimiters option) option
Test if a notation is available in the scopes context scopes
; if available, the result is not None; the first argument is itself not None if a delimiters is needed
val is_printing_inactive_rule :
Notation_term.interp_rule ->
Notation_term.interpretation ->
bool
Miscellaneous
Take a notation string and turn it into a notation key. eg. "x + y"
becomes "_ + _"
.
val interp_notation_as_global_reference :
?loc:Loc.t ->
head:bool ->
(Names.GlobRef.t -> bool) ->
Constrexpr.notation_key ->
delimiters option ->
Names.GlobRef.t
If head is true, also allows applied global references.
val declare_arguments_scope :
bool ->
Names.GlobRef.t ->
Notation_term.scope_name option list ->
unit
Declares and looks for scopes associated to arguments of a global ref
Comparison of scope_class
val subst_scope_class :
Environ.env ->
Mod_subst.substitution ->
scope_class ->
scope_class option
val compute_arguments_scope :
Environ.env ->
Evd.evar_map ->
EConstr.types ->
Notation_term.scope_name option list
val compute_type_scope :
Environ.env ->
Evd.evar_map ->
EConstr.types ->
Notation_term.scope_name option
Get the current scope bound to Sortclass, if it exists
Building notation key
type symbol =
| Terminal of string
| NonTerminal of Names.Id.t
| SProdList of Names.Id.t * symbol list
| Break of int
Make/decompose a notation of the form "_ U _"
type notation_symbols = {
recvars : (Names.Id.t * Names.Id.t) list;
mainvars : Names.Id.t list;
symbols : symbol list;
}
Decompose a notation of the form "a 'U' b" together with the lists of pairs of recursive variables and the list of all variables binding in the notation
Prints scopes (expects a pure aconstr printer)
val locate_notation :
(Glob_term.glob_constr -> Pp.t) ->
Constrexpr.notation_key ->
Notation_term.scope_name option ->
Pp.t
val pr_visibility :
(Glob_term.glob_constr -> Pp.t) ->
Notation_term.scope_name option ->
Pp.t
val make_notation_entry_level :
Constrexpr.notation_entry ->
Constrexpr.entry_level ->
Constrexpr.notation_entry_level
val declare_entry_coercion :
Constrexpr.specific_notation ->
Constrexpr.entry_level option ->
Constrexpr.notation_entry_level ->
unit
val availability_of_entry_coercion :
Constrexpr.notation_entry_level ->
Constrexpr.notation_entry_level ->
entry_coercion option
Dealing with precedences
type level =
Constrexpr.notation_entry
* Constrexpr.entry_level
* Constrexpr.entry_relative_level list
val entry_relative_level_eq :
Constrexpr.entry_relative_level ->
Constrexpr.entry_relative_level ->
bool
Declare and test the level of a (possibly uninterpreted) notation
raise Not_found
if not declared
Rem: printing rules for primitive token are canonical