Debian Codegraph @

pretyping/globEnv.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 Environ
13 open Evd
14 open EConstr
15 open Ltac_pretype
16 open Evarutil
17
18 (** Type of environment extended with naming and ltac interpretation data *)
19
20 type t
21
22 (** To embed constr in glob_constr *)
23
24 type 'a obj_interp_fun =
25 ?loc:Loc.t -> poly:PolyFlags.t -> t -> Evd.evar_map -> Evardefine.type_constraint ->
26 'a -> unsafe_judgment * Evd.evar_map
27
28 val register_constr_interp0 :
29 ('r, 'g, 't) Genarg.genarg_type -> 'g obj_interp_fun -> unit
30
31 (** {6 Pretyping name management} *)
32
33 (** The following provides a level of abstraction for the kind of
34 environment used for type inference (so-called pretyping); in
35 particular:
36 - it supports that term variables can be interpreted as Ltac
37 variables pointing to the effective expected name
38 - it incrementally and lazily computes the renaming of rel
39 variables used to build purely-named evar contexts
40 *)
41
42 (** Build a pretyping environment from an ltac environment *)
43
44 val make : hypnaming:naming_mode -> env -> evar_map -> ltac_var_map -> t
45
46 (** Export the underlying environment *)
47
48 val env : t -> env
49 val renamed_env : t -> env
50 val lfun : t -> unbound_ltac_var_map
51
52 val vars_of_env : t -> Id.Set.t
53
54 (** Push to the environment, returning the declaration(s) with interpreted names *)
55
56 val push_rel : hypnaming:naming_mode -> evar_map -> rel_declaration -> t -> rel_declaration * t
57 val push_rel_context : hypnaming:naming_mode -> ?force_names:bool -> evar_map -> rel_context -> t -> rel_context * t
58 val push_rec_types : hypnaming:naming_mode -> evar_map -> Name.t EConstr.binder_annot array * constr array -> t -> Name.t EConstr.binder_annot array * t
59
60 (** Declare an evar using renaming information *)
61
62 val new_evar : t -> evar_map -> ?src:Evar_kinds.t Loc.located -> ?rrpat:bool ->
63 ?naming:Namegen.intro_pattern_naming_expr -> ?relevance:ERelevance.t ->
64 constr -> evar_map * constr
65
66 val new_type_evar : t -> evar_map -> src:Evar_kinds.t Loc.located -> evar_map * constr
67
68 (** Lookup the ident in the context that would be used for an evar in
69 this environment, producing a term (Var or Rel) valid in [renamed_env]. *)
70 val lookup_renamed : t -> Id.t -> constr
71
72 (** [hide_variable env id] tells to hide the binding of [id] in
73 the ltac environment part of [env]. It is useful e.g.
74 for the dual status of [y] as term and binder. This is the case
75 of [match y return p with ... end] which implicitly denotes
76 [match z as z return p with ... end] when [y] is bound to a
77 variable [z] and [match t as y return p with ... end] when [y]
78 is bound to a non-variable term [t]. In the latter case, the
79 binding of [y] to [t] should be hidden in [p]. *)
80
81 val hide_variable : t -> Id.t -> t
82
83 (** In case a variable is not bound by a term binder, look if it has
84 an interpretation as a term in the ltac_var_map *)
85
86 val interp_ltac_variable : ?loc:Loc.t -> (t -> Glob_term.glob_constr -> evar_map * unsafe_judgment) ->
87 t -> evar_map -> Id.t -> evar_map * unsafe_judgment
88
89 (** Interp an identifier as an ltac variable bound to an identifier,
90 or as the identifier itself if not bound to an ltac variable *)
91
92 val interp_ltac_id : t -> Id.t -> Id.t
93
94 (** Interpreting a generic argument, typically a "ltac:(...)", taking
95 into account the possible renaming *)
96
97 val interp_glob_genarg : ?loc:Loc.t -> poly:PolyFlags.t -> t -> evar_map -> Evardefine.type_constraint ->
98 Genarg.glob_generic_argument -> unsafe_judgment * evar_map