Debian Codegraph @

printing/printer.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 Constr
13 open Environ
14 open Pattern
15 open Evd
16 open Glob_term
17 open Ltac_pretype
18 open Notation_term
19
20 (** These are the entry points for printing terms, context, tac, ... *)
21
22 val print_goal_tag_opt_name : string list
23
24 (** Terms *)
25
26 (** Printers for terms.
27
28 The "lconstr" variant does not require parentheses to isolate the
29 expression from the surrounding context (for instance [3 + 4]
30 will be written [3 + 4]). The "constr" variant (w/o "l")
31 enforces parentheses whenever the term is not an atom (for
32 instance, [3] will be written [3] but [3 + 4] will be
33 written [(3 + 4)].
34
35 [~inctx:true] indicates that the term is intended to be printed in
36 a context where its type is known so that a head coercion would be
37 skipped, or implicit arguments inferable from the context will not
38 be made explicit. For instance, if [foo] is declared as a
39 coercion, [foo bar] will be printed as [bar] if [inctx] is [true]
40 and as [foo bar] otherwise.
41
42 [~scope:some_scope_name] indicates that the head of the term is
43 intended to be printed in scope [some_scope_name]. It defaults to
44 [None].
45
46 [~impargs:some_list_of_binding_kind] indicates the implicit arguments
47 of the external quatification. Only used for printing types (not
48 terms), and at toplevel (only "l" versions). It defaults to [None].
49 *)
50
51
52 val pr_constr_env : ?inctx:bool -> ?scope:scope_name -> ?flags:PrintingFlags.t ->
53 env -> evar_map -> constr -> Pp.t
54 val pr_lconstr_env : ?inctx:bool -> ?scope:scope_name -> ?flags:PrintingFlags.t ->
55 env -> evar_map -> constr -> Pp.t
56
57 val pr_constr_n_env : ?inctx:bool -> ?scope:scope_name -> ?flags:PrintingFlags.t ->
58 env -> evar_map -> Constrexpr.entry_relative_level -> constr -> Pp.t
59
60 (** Same, but resilient to [Nametab] errors. Prints fully-qualified
61 names when [shortest_qualid_of_global] has failed. Prints "??"
62 in case of remaining issues (such as reference not in env). *)
63
64 val safe_pr_constr_env : ?flags:PrintingFlags.t -> env -> evar_map -> constr -> Pp.t
65 val safe_pr_lconstr_env : ?flags:PrintingFlags.t -> env -> evar_map -> constr -> Pp.t
66 val safe_extern_wrapper : (env -> evar_map -> 'a -> 'b) -> env -> evar_map -> 'a -> 'b option
67
68 val pr_econstr_env : ?inctx:bool -> ?scope:scope_name -> ?flags:PrintingFlags.t ->
69 env -> evar_map -> EConstr.t -> Pp.t
70 val pr_leconstr_env : ?inctx:bool -> ?scope:scope_name -> ?flags:PrintingFlags.t ->
71 env -> evar_map -> EConstr.t -> Pp.t
72
73 val pr_econstr_n_env : ?inctx:bool -> ?scope:scope_name -> ?flags:PrintingFlags.t ->
74 env -> evar_map -> Constrexpr.entry_relative_level -> EConstr.t -> Pp.t
75
76 val pr_etype_env : ?goal_concl_style:bool -> ?flags:PrintingFlags.t ->
77 env -> evar_map -> EConstr.types -> Pp.t
78 val pr_letype_env : ?goal_concl_style:bool -> ?flags:PrintingFlags.t ->
79 env -> evar_map -> ?impargs:Glob_term.binding_kind list -> EConstr.types -> Pp.t
80
81 val pr_constr_under_binders_env : ?flags:PrintingFlags.t -> env -> evar_map -> constr_under_binders -> Pp.t
82
83 val pr_lconstr_under_binders_env : ?flags:PrintingFlags.t -> env -> evar_map -> constr_under_binders -> Pp.t
84
85 (** Printers for types. Types are printed in scope "type_scope" and
86 under the constraint of being of type a sort.
87
88 The "ltype" variant does not require parentheses to isolate the
89 expression from the surrounding context (for instance [nat * bool]
90 will be written [nat * bool]). The "type" variant (w/o "l")
91 enforces parentheses whenever the term is not an atom (for
92 instance, [nat] will be written [nat] but [nat * bool] will be
93 written [(nat * bool)].
94
95 [~goal_concl_style:true] tells to print the type the same way as
96 command [Show] would print a goal. Concretely, it means that all
97 names of goal/section variables and all names of variables
98 referred by de Bruijn indices (if any) in the given environment
99 and all short names of global definitions of the current module
100 must be avoided while printing bound variables. Otherwise, short
101 names of global definitions are printed qualified and only names
102 of goal/section variables and rel names that do _not_ occur in the
103 scope of the binder to be printed are avoided.
104 *)
105
106 val pr_ltype_env : ?goal_concl_style:bool -> ?flags:PrintingFlags.t ->
107 env -> evar_map -> ?impargs:Glob_term.binding_kind list -> types -> Pp.t
108 val pr_type_env : ?goal_concl_style:bool -> ?flags:PrintingFlags.t ->
109 env -> evar_map -> types -> Pp.t
110
111 val pr_closed_glob_n_env : ?goal_concl_style:bool -> ?inctx:bool -> ?scope:scope_name -> ?flags:PrintingFlags.t ->
112 env -> evar_map -> Constrexpr.entry_relative_level -> closed_glob_constr -> Pp.t
113 val pr_closed_glob_env : ?goal_concl_style:bool -> ?inctx:bool -> ?scope:scope_name -> ?flags:PrintingFlags.t ->
114 env -> evar_map -> closed_glob_constr -> Pp.t
115 val pr_closed_lglob_env : ?goal_concl_style:bool -> ?inctx:bool -> ?scope:scope_name -> ?flags:PrintingFlags.t ->
116 env -> evar_map -> closed_glob_constr -> Pp.t
117
118 val pr_ljudge_env : ?flags:PrintingFlags.t ->
119 env -> evar_map -> EConstr.unsafe_judgment -> Pp.t * Pp.t
120
121 val pr_lglob_constr_env : ?flags:PrintingFlags.Extern.t ->
122 env -> evar_map -> 'a glob_constr_g -> Pp.t
123
124 val pr_glob_constr_env : ?flags:PrintingFlags.Extern.t ->
125 env -> evar_map -> 'a glob_constr_g -> Pp.t
126
127 val pr_lconstr_pattern_env : ?flags:PrintingFlags.Extern.t ->
128 env -> evar_map -> constr_pattern -> Pp.t
129
130 val pr_constr_pattern_env : ?flags:PrintingFlags.Extern.t ->
131 env -> evar_map -> constr_pattern -> Pp.t
132
133 val pr_uninstantiated_lconstr_pattern_env : ?flags:PrintingFlags.Extern.t ->
134 env -> evar_map -> uninstantiated_pattern -> Pp.t
135
136 val pr_uninstantiated_constr_pattern_env : ?flags:PrintingFlags.Extern.t ->
137 env -> evar_map -> uninstantiated_pattern -> Pp.t
138
139 val pr_cases_pattern : ?flags:PrintingFlags.Extern.t -> cases_pattern -> Pp.t
140
141 val pr_sort : ?universes:bool -> ?qualities:bool -> evar_map -> Sorts.t -> Pp.t
142
143 (** Universe constraints *)
144
145 val pr_universe_instance : evar_map -> UVars.Instance.t -> Pp.t
146 val pr_universe_instance_binder : evar_map -> UVars.Instance.t -> Univ.UnivConstraints.t -> Pp.t
147 val pr_universe_ctx : evar_map -> ?variance:UVars.Variance.t array ->
148 UVars.UContext.t -> Pp.t
149 val pr_abstract_universe_ctx : evar_map -> ?variance:UVars.Variance.t array ->
150 ?priv:Univ.ContextSet.t -> UVars.AbstractContext.t -> Pp.t
151 val pr_sort_context_set : evar_map -> UnivGen.sort_context_set -> Pp.t
152 val pr_universes : evar_map ->
153 ?variance:UVars.Variance.t array -> ?priv:Univ.ContextSet.t ->
154 Declarations.universes -> Pp.t
155
156 (** [universe_binders_with_opt_names ref l]
157
158 If [l] is [Some univs] return the universe binders naming the
159 bound levels of [ref] by [univs] (generating names for Anonymous).
160 May error if the lengths mismatch.
161
162 Otherwise return the bound universe names registered for [ref].
163
164 Inefficient on large contexts due to name generation. *)
165 val universe_binders_with_opt_names : UVars.AbstractContext.t ->
166 (GlobRef.t * UnivNames.full_name_list) option -> UnivNames.universe_binders * UnivNames.rev_binders
167
168 (** Printing global references using names as short as possible *)
169
170 val pr_global_env : Id.Set.t -> GlobRef.t -> Pp.t
171 val pr_global : GlobRef.t -> Pp.t
172
173 val pr_constant : env -> Constant.t -> Pp.t
174 val pr_existential_key : env -> evar_map -> Evar.t -> Pp.t
175 val pr_existential : ?flags:PrintingFlags.t -> env -> evar_map -> existential -> Pp.t
176 val pr_constructor : env -> constructor -> Pp.t
177 val pr_inductive : env -> inductive -> Pp.t
178 val pr_evaluable_reference : Evaluable.t -> Pp.t
179
180 val pr_pconstant : env -> evar_map -> pconstant -> Pp.t
181 val pr_pinductive : env -> evar_map -> pinductive -> Pp.t
182 val pr_pconstructor : env -> evar_map -> pconstructor -> Pp.t
183
184 val pr_notation_interpretation_env : env -> evar_map -> glob_constr -> Pp.t
185
186 (** Contexts *)
187
188 (** Display compact contexts of goals (simple hyps on the same line) *)
189 val set_compact_context : bool -> unit
190 val get_compact_context : unit -> bool
191
192 val pr_context_unlimited : ?flags:PrintingFlags.t -> env -> evar_map -> Pp.t
193 val pr_ne_context_of : Pp.t -> ?flags:PrintingFlags.t -> env -> evar_map -> Pp.t
194
195 val pr_named_decl : ?flags:PrintingFlags.t ->
196 env -> evar_map -> Constr.named_declaration -> Pp.t
197 val pr_compacted_decl : ?flags:PrintingFlags.t ->
198 env -> evar_map -> Constr.compacted_declaration -> Pp.t
199 val pr_rel_decl : ?flags:PrintingFlags.t ->
200 env -> evar_map -> Constr.rel_declaration -> Pp.t
201
202 val pr_enamed_decl : ?flags:PrintingFlags.t ->
203 env -> evar_map -> EConstr.named_declaration -> Pp.t
204 val pr_ecompacted_decl : ?flags:PrintingFlags.t ->
205 env -> evar_map -> EConstr.compacted_declaration -> Pp.t
206 val pr_erel_decl : ?flags:PrintingFlags.t ->
207 env -> evar_map -> EConstr.rel_declaration -> Pp.t
208
209 val pr_named_context : ?flags:PrintingFlags.t ->
210 env -> evar_map -> Constr.named_context -> Pp.t
211 val pr_named_context_of : ?flags:PrintingFlags.t ->
212 env -> evar_map -> Pp.t
213 val pr_rel_context : ?flags:PrintingFlags.t ->
214 env -> evar_map -> Constr.rel_context -> Pp.t
215 val pr_rel_context_of : ?flags:PrintingFlags.t ->
216 env -> evar_map -> Pp.t
217 val pr_context_of : ?flags:PrintingFlags.t ->
218 env -> evar_map -> Pp.t
219
220 (** Predicates *)
221
222 val pr_predicate : ('a -> Pp.t) -> (bool * 'a list) -> Pp.t
223 val pr_cpred : Cpred.t -> Pp.t
224 val pr_idpred : Id.Pred.t -> Pp.t
225 val pr_prpred : PRpred.t -> Pp.t
226 val pr_transparent_state : TransparentState.t -> Pp.t
227
228 (** Proofs, these functions obey [Hyps Limit] and [Compact contexts]. *)
229
230 (** [pr_open_subgoals ~quiet ?oldp proof] shows the context for [proof] as used by, for example, coqtop.
231 The first active goal is printed with all its antecedents and the conclusion. The other active goals only show their
232 conclusions. If [oldp] is [Some oproof], highlight the differences between the old proof [oproof], and [proof]. [quiet]
233 disables printing messages as Feedback.
234 *)
235 val pr_open_subgoals : ?quiet:bool -> ?oldp:Proof.t option option -> ?flags:PrintingFlags.t ->
236 Proof.t -> Pp.t
237 val pr_nth_open_subgoal : ?flags:PrintingFlags.t ->
238 ?oldp:Proof.t option option -> proof:Proof.t -> int -> Pp.t
239 val pr_evar : ?flags:PrintingFlags.t ->
240 evar_map -> (Evar.t * undefined evar_info) -> Pp.t
241 val pr_evars_int : ?flags:PrintingFlags.t ->
242 evar_map -> shelf:Evar.t list -> given_up:Evar.t list -> int -> undefined evar_info Evar.Map.t -> Pp.t
243 val pr_ne_evar_set : ?flags:PrintingFlags.t ->
244 Pp.t -> Pp.t -> evar_map ->
245 Evar.Set.t -> Pp.t
246
247 (** Declarations for the "Print Assumption" command *)
248 type axiom =
249 | Constant of Constant.t (* An axiom or a constant. *)
250 | Positive of MutInd.t (* A mutually inductive definition which has been assumed positive. *)
251 | Guarded of GlobRef.t (* a constant whose (co)fixpoints have been assumed to be guarded *)
252 | TypeInType of GlobRef.t (* a constant which relies on type in type *)
253 | UIP of MutInd.t (* An inductive using the special reduction rule. *)
254
255 type context_object =
256 | Variable of Id.t (* A section variable or a Let definition *)
257 | Axiom of axiom * (GlobRef.t * Constr.rel_context * types) list
258 | Opaque of Constant.t (* An opaque constant. *)
259 | Transparent of Constant.t
260
261 module ContextObjectSet : CSet.ExtS with type elt = context_object
262 module ContextObjectMap : CMap.ExtS
263 with type key = context_object and module Set := ContextObjectSet
264
265 val pr_assumptionset : ?flags:PrintingFlags.t ->
266 env -> evar_map -> types ContextObjectMap.t -> Pp.t
267
268 val pr_goal_by_id : ?flags:PrintingFlags.t ->
269 ?oldp:Proof.t option option -> proof:Proof.t -> Libnames.qualid -> Pp.t
270 val pr_goal_emacs : ?flags:PrintingFlags.t ->
271 proof:Proof.t option -> int -> int -> Pp.t
272
273 val pr_typing_flags : Declarations.typing_flags -> Pp.t
274
275 (** Tells if goal name should be printed, i.e., either "Printing Goal Names" flag is activated,
276 or the evar was given a name. *)
277 val print_goal_name : evar_map -> Evar.t -> bool
278
279 module Debug :
280 sig
281
282 val pr_goal : ?flags:PrintingFlags.t -> Proofview.Goal.t -> Pp.t
283
284 end
285 (** Debug printers *)