Debian Codegraph @

engine/nameops.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
13 (** Identifiers and names *)
14
15 val make_ident : string -> int option -> Id.t
16 val repr_ident : Id.t -> string * int option
17
18 val atompart_of_id : Id.t -> string (** remove trailing digits *)
19
20 val root_of_id : Id.t -> Id.t (** remove trailing digits, ' and _ *)
21
22 val add_suffix : Id.t -> string -> Id.t
23 val add_prefix : string -> Id.t -> Id.t
24
25 (** Below, by {i subscript} we mean a suffix composed solely from (decimal) digits. *)
26
27 module Subscript :
28 sig
29 type t
30 (** Abstract datatype of subscripts. Isomorphic to a string of digits. *)
31
32 val zero : t
33 (** Empty subscript *)
34
35 val succ : t -> t
36 (** Guarantees that [x < succ x], but [succ x] might not be the smallest
37 element strictly above [x], generally it does not exist. Example mappings:
38 "" ↦ "0"
39 "0" ↦ "1"
40 "00" ↦ "01"
41 "1" ↦ "2"
42 "01" ↦ "02"
43 "9" ↦ "10"
44 "09" ↦ "10"
45 "99" ↦ "100"
46 *)
47
48 val compare : t -> t -> int
49 (** Well-founded order. *)
50
51 val equal : t -> t -> bool
52
53 end
54
55 module Fresh :
56 sig
57 type t
58 val empty : t
59 val add : Id.t -> t -> t
60 val union : t -> t -> t
61 val remove : Id.t -> t -> t
62 val mem : Id.t -> t -> bool
63 val next : Id.t -> t -> Id.t
64 val fresh : Id.t -> t -> Id.t * t
65
66 val of_list : Id.t list -> t
67 val of_set : Id.Set.t -> t
68 val of_named_context_val : Environ.named_context_val -> t
69
70 val max_map : t -> Subscript.t Id.Map.t
71 end
72
73
74 val has_subscript : Id.t -> bool
75
76 val get_subscript : Id.t -> Id.t * Subscript.t
77 (** Split an identifier into a base name and a subscript. *)
78
79 val add_subscript : Id.t -> Subscript.t -> Id.t
80 (** Append the subscript to the identifier. *)
81
82 val increment_subscript : Id.t -> Id.t
83 (** Return the same identifier as the original one but whose {i subscript} is incremented.
84 If the original identifier does not have a suffix, [0] is appended to it.
85
86 Example mappings:
87
88 [bar] ↦ [bar0]
89
90 [bar0] ↦ [bar1]
91
92 [bar00] ↦ [bar01]
93
94 [bar1] ↦ [bar2]
95
96 [bar01] ↦ [bar01]
97
98 [bar9] ↦ [bar10]
99
100 [bar09] ↦ [bar10]
101
102 [bar99] ↦ [bar100]
103 *)
104
105 val forget_subscript : Id.t -> Id.t
106
107 module Name : sig
108
109 include module type of struct include Names.Name end
110
111 exception IsAnonymous
112
113 val fold_left : ('a -> Id.t -> 'a) -> 'a -> Name.t -> 'a
114 (** [fold_left f na a] is [f id a] if [na] is [Name id], and [a] otherwise. *)
115
116 val fold_right : (Id.t -> 'a -> 'a) -> Name.t -> 'a -> 'a
117 (** [fold_right f a na] is [f a id] if [na] is [Name id], and [a] otherwise. *)
118
119 val iter : (Id.t -> unit) -> Name.t -> unit
120 (** [iter f na] does [f id] if [na] equals [Name id], nothing otherwise. *)
121
122 val map : (Id.t -> Id.t) -> Name.t -> t
123 (** [map f na] is [Anonymous] if [na] is [Anonymous] and [Name (f id)] if [na] is [Name id]. *)
124
125 val fold_left_map : ('a -> Id.t -> 'a * Id.t) -> 'a -> Name.t -> 'a * Name.t
126 (** [fold_left_map f a na] is [a',Name id'] when [na] is [Name id] and [f a id] is [(a',id')].
127 It is [a,Anonymous] otherwise. *)
128
129 val fold_right_map : (Id.t -> 'a -> Id.t * 'a) -> Name.t -> 'a -> Name.t * 'a
130 (** [fold_right_map f na a] is [Name id',a'] when [na] is [Name id] and [f id a] is [(id',a')].
131 It is [Anonymous,a] otherwise. *)
132
133 val get_id : Name.t -> Id.t
134 (** [get_id] associates [id] to [Name id].
135 @raise IsAnonymous otherwise. *)
136
137 val pick : Name.t -> Name.t -> Name.t
138 (** [pick na na'] returns [Anonymous] if both names are [Anonymous].
139 Pick one of [na] or [na'] otherwise. *)
140
141 val pick_annot : (Name.t,'r) Context.pbinder_annot -> (Name.t,'r) Context.pbinder_annot ->
142 (Name.t,'r) Context.pbinder_annot
143
144 val cons : Name.t -> Id.t list -> Id.t list
145 (** [cons na l] returns [id::l] if [na] is [Name id] and [l] otherwise. *)
146
147 val to_option : Name.t -> Id.t option
148 (** [to_option Anonymous] is [None] and [to_option (Name id)] is [Some id] *)
149
150 end
151
152 (** Metavariables *)
153 val pr_meta : Constr.metavariable -> Pp.t
154 val string_of_meta : Constr.metavariable -> string