Debian Codegraph @

engine/namegen.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 (** This file features facilities to generate fresh names. *)
12
13 open Names
14 open Environ
15 open Evd
16 open EConstr
17
18 (** General evar naming using intro patterns *)
19 type intro_pattern_naming_expr =
20 | IntroIdentifier of Id.t
21 | IntroFresh of Id.t
22 | IntroAnonymous
23
24 (** Equalities on [intro_pattern_naming] *)
25 val intro_pattern_naming_eq :
26 intro_pattern_naming_expr -> intro_pattern_naming_expr -> bool
27
28 (*********************************************************************
29 Conventional default names *)
30
31 val default_prop_ident : Id.t (* "H" *)
32 val default_small_ident : Id.t (* "H" *)
33 val default_type_ident : Id.t (* "X" *)
34 val default_non_dependent_ident : Id.t (* "H" *)
35 val default_dependent_ident : Id.t (* "x" *)
36
37 (*********************************************************************
38 Generating "intuitive" names from their type *)
39
40 val lowercase_first_char : Id.t -> string
41 val sort_hdchar : Sorts.t -> string
42 val hdchar : env -> evar_map -> types -> string
43 val id_of_name_using_hdchar : env -> evar_map -> types -> Name.t -> Id.t
44 val named_hd : env -> evar_map -> types -> Name.t -> Name.t
45 val head_name : evar_map -> types -> Id.t option
46
47 val mkProd_name : env -> evar_map -> Name.t EConstr.binder_annot * types * types -> types
48 val mkLambda_name : env -> evar_map -> Name.t EConstr.binder_annot * types * constr -> constr
49
50 (** Deprecated synonyms of [mkProd_name] and [mkLambda_name] *)
51 val prod_name : env -> evar_map -> Name.t EConstr.binder_annot * types * types -> types
52 val lambda_name : env -> evar_map -> Name.t EConstr.binder_annot * types * constr -> constr
53
54 val prod_create : env -> evar_map -> ERelevance.t * types * types -> constr
55 val lambda_create : env -> evar_map -> ERelevance.t * types * constr -> constr
56 val name_assumption : env -> evar_map -> rel_declaration -> rel_declaration
57 val name_context : env -> evar_map -> rel_context -> rel_context
58
59 val mkProd_or_LetIn_name : env -> evar_map -> types -> rel_declaration -> types
60 val mkLambda_or_LetIn_name : env -> evar_map -> constr -> rel_declaration -> constr
61 val it_mkProd_or_LetIn_name : env -> evar_map -> types -> rel_context -> types
62 val it_mkLambda_or_LetIn_name : env -> evar_map -> constr -> rel_context -> constr
63
64 (*********************************************************************
65 Fresh names *)
66
67 val mangle_id : Id.t -> Id.t
68
69 (** Avoid clashing with a name satisfying some predicate *)
70 val next_ident_away_from : Id.t -> (Id.t -> bool) -> Id.t
71
72 (** [next_ident_away original_id unwanted_ids] returns a new identifier as close as possible
73 to the [original_id] while avoiding all [unwanted_ids].
74
75 In particular:
76 {ul {- if [original_id] does not appear in the list of [unwanted_ids], then [original_id] is returned.}
77 {- if [original_id] appears in the list of [unwanted_ids],
78 then this function returns a new id that:
79 {ul {- has the same {i root} as the [original_id],}
80 {- does not occur in the list of [unwanted_ids],}
81 {- has the smallest possible {i subscript}.}}}}
82
83 where by {i subscript} of some identifier we mean last part of it that is composed
84 only from (decimal) digits and by {i root} of some identifier we mean
85 the whole identifier except for the {i subscript}.
86
87 E.g. if we take [foo42], then [42] is the {i subscript}, and [foo] is the root. *)
88 val next_ident_away : Id.t -> Id.Set.t -> Id.t
89
90 (** Avoid clashing with a name already used in current module *)
91 val next_ident_away_in_goal : Environ.env -> Id.t -> Id.Set.t -> Id.t
92
93 (** Avoid clashing with a name already used in current module
94 but tolerate overwriting section variables, as in goals *)
95 val next_global_ident_away : Safe_typing.safe_environment -> Id.t -> Id.Set.t -> Id.t
96
97 (** Default is [default_non_dependent_ident] *)
98 val next_name_away : Name.t -> Id.Set.t -> Id.t
99
100 val next_name_away_with_default : string -> Name.t -> Id.Set.t -> Id.t
101
102 val next_name_away_with_default_using_types : Environ.env -> evar_map ->
103 string -> Name.t -> Id.Set.t -> types -> Id.t
104
105 val set_reserved_typed_name : (Environ.env -> evar_map -> types -> Name.t) -> unit
106
107 (*********************************************************************
108 Making name distinct for displaying *)
109
110 val make_all_rel_context_name_different : env -> evar_map -> rel_context -> env * rel_context
111 val make_all_name_different : env -> evar_map -> env
112
113 module Generator :
114 sig
115 type 'a t
116 type 'a input = 'a t * 'a
117 val fresh : Nameops.Fresh.t t
118 val idset : Id.Set.t t
119
120 val next_name_away : 'a t -> Name.t -> 'a -> Id.t * 'a
121
122 val max_map : 'a t -> 'a -> Nameops.Subscript.t Id.Map.t
123 end
124
125 type renaming_flags =
126 | RenamingForCasesPattern of (Name.t list * constr) (** avoid only global constructors *)
127 | RenamingForGoal (** avoid all globals (as in intro) *)
128 | RenamingElsewhereFor of (Name.t list * constr)
129
130 val compute_displayed_name_in :
131 'a Generator.t -> Environ.env -> evar_map -> renaming_flags -> 'a -> Name.t -> constr -> Name.t * 'a
132 val compute_displayed_let_name_in :
133 'a Generator.t -> Environ.env -> evar_map -> renaming_flags -> 'a -> Name.t -> Name.t * 'a
134
135 (* Generic function expecting a "not occurn" function *)
136 val compute_displayed_name_in_gen :
137 'a Generator.t -> (evar_map -> int -> 'constr -> bool) ->
138 Environ.env -> evar_map -> 'a -> Name.t -> 'constr -> Name.t * 'a