Debian Codegraph @

ide/rocqide/protocol/interface.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 (** * Declarative part of the interface of RocqIDE calls to Rocq *)
12
13 (** * Generic structures *)
14
15 type raw = bool
16 type verbose = bool
17
18 (** The type of rocqtop goals *)
19 type goal = {
20 goal_id : string;
21 (** Unique goal identifier *)
22 goal_hyp : Pp.t list;
23 (** List of hypotheses *)
24 goal_ccl : Pp.t;
25 (** Goal conclusion *)
26 goal_name : string option;
27 (** User-level goal name *)
28 }
29
30 type evar = {
31 evar_info : string;
32 (** A string describing an evar: type, number, environment *)
33 }
34
35 type status = {
36 status_path : string list;
37 (** Module path of the current proof *)
38 status_proofname : string option;
39 (** Current proof name. [None] if no focused proof is in progress *)
40 status_allproofs : string list;
41 (** List of all pending proofs. Order is not significant *)
42 status_proofnum : int;
43 (** An id describing the state of the current proof. *)
44 }
45
46 type 'a pre_goals = {
47 fg_goals : 'a list;
48 (** List of the focused goals *)
49 bg_goals : ('a list * 'a list) list;
50 (** Zipper representing the unfocused background goals *)
51 shelved_goals : 'a list;
52 (** List of the goals on the shelf. *)
53 given_up_goals : 'a list;
54 (** List of the goals that have been given up *)
55 }
56
57 type goals = goal pre_goals
58
59 type hint = (string * string) list
60 (** A list of tactics applicable and their appearance *)
61
62 type option_name = string list
63
64 type option_value =
65 | BoolValue of bool
66 | IntValue of int option
67 | StringValue of string
68 | StringOptValue of string option
69
70 (** Summary of an option status *)
71 type option_state = {
72 opt_sync : bool;
73 (** Whether an option is synchronous *)
74 opt_depr : bool;
75 (** Whether an option is deprecated *)
76 opt_value : option_value;
77 (** The current value of the option *)
78 }
79
80 type search_constraint =
81 | Name_Pattern of string
82 (** Whether the name satisfies a regexp (uses Ocaml Str syntax) *)
83
84 | Type_Pattern of string
85 (** Whether the object type satisfies a pattern *)
86
87 | SubType_Pattern of string
88 (** Whether some subtype of object type satisfies a pattern *)
89
90 | In_Module of string list
91 (** Whether the object pertains to a module *)
92
93 | Include_Blacklist
94 (** Bypass the Search blacklist *)
95
96 (** A list of search constraints; the boolean flag is set to [false] whenever
97 the flag should be negated. *)
98 type search_flags = (search_constraint * bool) list
99
100 (** Subset of goals to print. *)
101 type goal_flags = {
102 gf_mode : string;
103 gf_fg : bool;
104 gf_bg : bool;
105 gf_shelved : bool;
106 gf_given_up : bool;
107 }
108
109 (** A named object in Rocq. [coq_object_qualid] is the shortest path defined for
110 the user. [coq_object_prefix] is the missing part to recover the fully
111 qualified name, i.e [fully_qualified = coq_object_prefix + coq_object_qualid].
112 [coq_object_object] is the actual content of the object. *)
113 type 'a coq_object = {
114 coq_object_prefix : string list;
115 coq_object_qualid : string list;
116 coq_object_object : 'a;
117 }
118
119 type coq_info = {
120 coqtop_version : string;
121 protocol_version : string;
122 release_date : string;
123 compile_date : string;
124 }
125
126 (* a subset of DebugHook.Action.t *)
127 type db_continue_opt =
128 | StepIn
129 | StepOver
130 | StepOut
131 | Continue
132 | Interrupt
133
134 (** Calls result *)
135
136 type location = Loc.t option
137 type state_id = Stateid.t
138 type route_id = Feedback.route_id
139
140 (* Obsolete *)
141 type edit_id = int
142
143 (* The fail case carries the current state_id of the prover, the GUI
144 should probably retract to that point *)
145 type 'a value =
146 | Good of 'a
147 | Fail of (state_id * location * Pp.t)
148
149 type ('a, 'b) union = ('a, 'b) Util.union
150
151 (* Request/Reply message protocol between Rocq and RocqIDE *)
152
153 (** [add ((((s,eid),(sid,v)), bp), (line_nb, bol_pos) ] adds the phrase [s] with edit id [eid]
154 on top of the current edit position (that is asserted to be [sid]).
155 [v] set to true indicates "verbose". The response [(id,rc)] is the new state
156 [id] assigned to the phrase. [rc] is [Inl] if the new
157 state id is the tip of the edit point, or [Inr tip] if the new phrase
158 closes a focus and [tip] is the new edit tip. [bp], [line_nb] and [bol_pos]
159 are the Loc.t values for the phrase in the buffer, needed to return the correct
160 location for [s] to the debugger *)
161 type add_sty = (((string * edit_id) * (state_id * verbose)) * int) * (int * int)
162 type add_rty = state_id * (unit, state_id) union
163
164 (** [edit_at id] declares the user wants to edit just after [id].
165 The response is [Inl] if the document has been rewound to that point,
166 [Inr (start,(stop,tip))] if [id] is in a zone that can be focused.
167 In that case the zone is delimited by [start] and [stop] while [tip]
168 is the new document [tip]. Edits made by subsequent [add] are always
169 performed on top of [id]. *)
170 type edit_at_sty = state_id
171 type edit_at_rty = (unit, state_id * (state_id * state_id)) union
172
173 (** [query s id] executes [s] at state [id].
174
175 query used to reply with the contents of Rocq's console output, and
176 has been deprecated in favor of sending the query answers as
177 feedback. It will be removed in a future version of the protocol.
178 *)
179 type query_sty = route_id * (string * state_id)
180 type query_rty = unit
181
182 (** Fetching the list of current goals. Return [None] if no proof is in
183 progress, [Some gl] otherwise. *)
184 type goals_sty = unit
185 type goals_rty = goals option
186
187 (** Same as above, but specific kind of goals can be retrieved by setting the
188 flags. *)
189 type subgoals_sty = goal_flags
190 type subgoals_rty = goals option
191
192 (** Retrieve the list of uninstantiated evars in the current proof. [None] if no
193 proof is in progress. *)
194 type evars_sty = unit
195 type evars_rty = evar list option
196
197 (** Retrieving the tactics applicable to the current goal. [None] if there is
198 no proof in progress. *)
199 type hints_sty = unit
200 type hints_rty = (hint list * hint) option
201
202 (** The status, for instance "Ready in SomeSection, proving Foo", the
203 input boolean (if true) forces the evaluation of all unevaluated
204 statements *)
205 type status_sty = bool
206 type status_rty = status
207
208 (** Search for objects satisfying the given search flags. *)
209 type search_sty = search_flags
210 type search_rty = string coq_object list
211
212 (** Diffs between the proof term at a given stateid and the previous one *)
213 type proof_diff_sty = string * Stateid.t
214 type proof_diff_rty = Pp.t
215
216 (** A debugger command *)
217 type db_cmd_sty = string
218 type db_cmd_rty = unit
219
220 (** update one or more breakpoints in the specified file *)
221 type db_upd_bpts_sty = ((string * int) * bool) list
222 type db_upd_bpts_rty = unit
223
224 (** continue execution (in various ways) *)
225 type db_continue_sty = db_continue_opt
226 type db_continue_rty = unit
227
228 (** fetch the stack *)
229 type db_stack_sty = unit
230 type db_stack_rty = (string * (string * int list) option) list
231
232 (** fetch variable names and values for a stack frame *)
233 type db_vars_sty = int
234 type db_vars_rty = (string * Pp.t) list
235
236 (** indicate debugger config is complete *)
237 type db_configd_sty = unit
238 type db_configd_rty = unit
239
240 (** Retrieve the list of options of the current toplevel *)
241 type get_options_sty = unit
242 type get_options_rty = (option_name * option_state) list
243
244 (** Set the options to the given values. Warning: this is not atomic, so whenever
245 the call fails, the option state can be messed up... This is the caller duty
246 to check that everything is correct. *)
247 type set_options_sty = (option_name * option_value) list
248 type set_options_rty = unit
249
250 (** Create a "match" template for a given inductive type.
251 For each branch of the match, we list the constructor name
252 followed by enough pattern variables. *)
253 type mkcases_sty = string
254 type mkcases_rty = string list list
255
256 (** Quit gracefully the interpreter. *)
257 type quit_sty = unit
258 type quit_rty = unit
259
260 (* Initialize, and return the initial state id. The argument is the filename.
261 * If its directory is not in dirpath, it adds it. It also loads
262 * compilation hints for the filename. *)
263 type init_sty = string option
264 type init_rty = state_id
265
266 type about_sty = unit
267 type about_rty = coq_info
268
269 type handle_exn_sty = Exninfo.iexn
270 type handle_exn_rty = state_id * location * Pp.t
271
272 (* Retrocompatibility stuff *)
273 type interp_sty = (raw * verbose) * string
274 (* spiwack: [Inl] for safe and [Inr] for unsafe. *)
275 type interp_rty = state_id * (string,string) Util.union
276
277 type stop_worker_sty = string
278 type stop_worker_rty = unit
279
280 type print_ast_sty = state_id
281 type print_ast_rty = Xml_datatype.xml
282
283 type annotate_sty = string
284 type annotate_rty = Xml_datatype.xml
285
286 type wait_sty = unit
287 type wait_rty = unit
288
289 type handler = {
290 add : add_sty -> add_rty;
291 edit_at : edit_at_sty -> edit_at_rty;
292 query : query_sty -> query_rty;
293 goals : goals_sty -> goals_rty;
294 evars : evars_sty -> evars_rty;
295 hints : hints_sty -> hints_rty;
296 status : status_sty -> status_rty;
297 search : search_sty -> search_rty;
298 get_options : get_options_sty -> get_options_rty;
299 set_options : set_options_sty -> set_options_rty;
300 mkcases : mkcases_sty -> mkcases_rty;
301 about : about_sty -> about_rty;
302 stop_worker : stop_worker_sty -> stop_worker_rty;
303 print_ast : print_ast_sty -> print_ast_rty;
304 annotate : annotate_sty -> annotate_rty;
305 proof_diff : proof_diff_sty -> proof_diff_rty;
306 db_cmd : db_cmd_sty -> db_cmd_rty;
307 db_upd_bpts : db_upd_bpts_sty -> db_upd_bpts_rty;
308 db_continue : db_continue_sty -> db_continue_rty;
309 db_stack : db_stack_sty -> db_stack_rty;
310 db_vars : db_vars_sty -> db_vars_rty;
311 db_configd : db_configd_sty -> db_configd_rty;
312 handle_exn : handle_exn_sty -> handle_exn_rty;
313 init : init_sty -> init_rty;
314 quit : quit_sty -> quit_rty;
315 (* for internal use (fake_id) only, do not use *)
316 wait : wait_sty -> wait_rty;
317 (* Retrocompatibility stuff *)
318 interp : interp_sty -> interp_rty;
319 subgoals : subgoals_sty -> subgoals_rty;
320 }