Debian Codegraph @

kernel/mod_subst.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 (** {6 [Mod_subst] } *)
12
13 open Names
14 open Constr
15
16 (** {6 Delta resolver} *)
17
18 (** A delta resolver is a renaming of kernames and modpaths.
19 Objects on which the resolver acts non-trivially must share a common modpath
20 prefix called the root of the resolver. *)
21 type delta_resolver
22
23 (** Given a root, build a resolver. *)
24 val empty_delta_resolver : ModPath.t -> delta_resolver
25
26 val has_root_delta_resolver : ModPath.t -> delta_resolver -> bool
27
28 (** [add_mp_delta_resolver mp v reso] assumes that root(reso) ⊆ mp. *)
29 val add_mp_delta_resolver :
30 ModPath.t -> ModPath.t -> delta_resolver -> delta_resolver
31
32 (** [add_kn_delta_resolver kn v reso] assumes that root(reso) ⊆ modpath(kn). *)
33 val add_kn_delta_resolver :
34 KerName.t -> KerName.t -> delta_resolver -> delta_resolver
35
36 (** [add_inline_delta_resolver kn v reso] assumes that root(reso) ⊆ modpath(kn). *)
37 val add_inline_delta_resolver :
38 KerName.t -> (int * constr UVars.univ_abstracted option) -> delta_resolver -> delta_resolver
39
40 (** [add_delta_resolver reso1 reso2] merges two renamings, assuming that
41 root(reso2) ⊆ root(reso1). Note that this is asymmetrical. The root of the
42 result is root(reso2). *)
43 val add_delta_resolver : delta_resolver -> delta_resolver -> delta_resolver
44
45 (** Assuming mp ⊆ root(delta), [upcast_delta_resolver mp delta] allows seeing
46 [delta] as a resolver with root = mp. *)
47 val upcast_delta_resolver : ModPath.t -> delta_resolver -> delta_resolver
48
49 (** Effect of a [delta_resolver] on a module path, on a kernel name *)
50
51 val mp_of_delta : delta_resolver -> ModPath.t -> ModPath.t
52 val kn_of_delta : delta_resolver -> KerName.t -> KerName.t
53
54 (** Build a constant whose canonical part is obtained via a resolver *)
55
56 val constant_of_delta_kn : delta_resolver -> KerName.t -> Constant.t
57
58 (** Same for inductive names *)
59
60 val mind_of_delta_kn : delta_resolver -> KerName.t -> MutInd.t
61
62 (** Extract the set of inlined constant in the resolver *)
63 val inline_of_delta : int option -> delta_resolver -> (int * KerName.t) list
64
65 (** Does a [delta_resolver] contains a [mp]? *)
66
67 val mp_in_delta : ModPath.t -> delta_resolver -> bool
68
69 (** {6 Substitution} *)
70
71 type substitution
72
73 val empty_subst : substitution
74
75 val is_empty_subst : substitution -> bool
76
77 (** add_* add [arg2/arg1]\{arg3\} to the substitution with no sequential
78 composition. Most often this is not what you want. For sequential
79 composition, try [join (map_mbid mp delta) subs] **)
80 val add_mbid :
81 MBId.t -> ModPath.t -> delta_resolver -> substitution -> substitution
82 val add_mp :
83 ModPath.t -> ModPath.t -> delta_resolver -> substitution -> substitution
84
85 (** map_* create a new substitution [arg2/arg1]\{arg3\} *)
86 val map_mbid :
87 MBId.t -> ModPath.t -> delta_resolver -> substitution
88 val map_mp :
89 ModPath.t -> ModPath.t -> delta_resolver -> substitution
90
91 (** sequential composition:
92 [substitute (join sub1 sub2) t = substitute sub2 (substitute sub1 t)]
93 *)
94 val join : substitution -> substitution -> substitution
95
96
97 (** Apply the substitution on the domain of the resolver *)
98 val subst_dom_delta_resolver : substitution -> delta_resolver -> delta_resolver
99
100 (** Apply the substitution on the codomain of the resolver *)
101 val subst_codom_delta_resolver :
102 substitution -> delta_resolver -> delta_resolver
103
104 val subst_dom_codom_delta_resolver :
105 substitution -> delta_resolver -> delta_resolver
106
107
108 (**/**)
109 (* debugging *)
110 val debug_string_of_subst : substitution -> string
111 val debug_pr_subst : substitution -> Pp.t
112 val debug_string_of_delta : delta_resolver -> string
113 val debug_pr_delta : delta_resolver -> Pp.t
114 (**/**)
115
116 (** [subst_mp sub mp] guarantees that whenever the result of the
117 substitution is structutally equal [mp], it is equal by pointers
118 as well [==] *)
119
120 val subst_mp :
121 substitution -> ModPath.t -> ModPath.t
122
123 val subst_mind :
124 substitution -> MutInd.t -> MutInd.t
125
126 val subst_ind :
127 substitution -> inductive -> inductive
128
129 val subst_constructor :
130 substitution -> constructor -> constructor
131
132 val subst_pind : substitution -> pinductive -> pinductive
133
134 val subst_kn :
135 substitution -> KerName.t -> KerName.t
136
137 val subst_con :
138 substitution -> Constant.t -> Constant.t * constr UVars.univ_abstracted option
139
140 val subst_pcon :
141 substitution -> pconstant -> pconstant
142
143 val subst_constant :
144 substitution -> Constant.t -> Constant.t
145
146 val subst_proj_repr : substitution -> Projection.Repr.t -> Projection.Repr.t
147 val subst_proj : substitution -> Projection.t -> Projection.t
148
149 val subst_retro_action : substitution -> Retroknowledge.action -> Retroknowledge.action
150
151 (** [replace_mp_in_con mp mp' con] replaces [mp] with [mp'] in [con] *)
152 val replace_mp_in_kn : ModPath.t -> ModPath.t -> KerName.t -> KerName.t
153
154 (** [subst_mps sub c] performs the substitution [sub] on all kernel
155 names appearing in [c] *)
156 val subst_mps : substitution -> constr -> constr
157 val subst_mps_list : substitution list -> constr -> constr