Debian Codegraph @

dev/doc/xml-protocol.md

raw symbols SCIP
1 # Coq XML Protocol
2
3 This document is based on documentation originally written by CJ Bell
4 for his [vscoq](https://github.com/coq-community/vscoq/) project.
5
6 Here, the aim is to provide a "hands on" description of the XML
7 protocol that coqtop and IDEs use to communicate. The protocol first appeared
8 with Coq 8.5, and is used by RocqDE, [vscoq legacy](https://github.com/coq-community/vscoq-legacy/), and other user interfaces.
9
10 A somewhat out-of-date description of the async state machine is
11 [documented here](https://github.com/ejgallego/jscoq/blob/v8.16/etc/notes/coq-notes.md).
12 OCaml types for the protocol can be found in the [`ide/protocol/interface.ml` file](/ide/protocol/interface.ml).
13
14 Changes to the XML protocol are documented as part of [`dev/doc/changes.md`](/dev/doc/changes.md).
15
16 * [Commands](#commands)
17 - [About](#command-about)
18 - [Add](#command-add)
19 - [EditAt](#command-editAt)
20 - [Init](#command-init)
21 - [Goal](#command-goal)
22 - [Subgoals](#command-subgoals)
23 - [Status](#command-status)
24 - [Query](#command-query)
25 - [Evars](#command-evars)
26 - [Hints](#command-hints)
27 - [Search](#command-search)
28 - [GetOptions](#command-getoptions)
29 - [SetOptions](#command-setoptions)
30 - [MkCases](#command-mkcases)
31 - [StopWorker](#command-stopworker)
32 - [PrintAst](#command-printast)
33 - [Annotate](#command-annotate)
34 - [Db_cmd](#command-db_cmd)
35 - [Db_upd_bpts](#command-db_upd_bpts)
36 - [Db_continue](#command-db_continue)
37 - [Db_stack](#command-db_stack)
38 - [Db_vars](#command-db_vars)
39 * [Feedback messages](#feedback)
40 - [Added Axiom](#feedback-addedaxiom)
41 - [Processing](#feedback-processing)
42 - [Processed](#feedback-processed)
43 - [Incomplete](#feedback-incomplete)
44 - [Complete](#feedback-complete)
45 - [GlobRef](#feedback-globref)
46 - [Error](#feedback-error)
47 - [InProgress](#feedback-inprogress)
48 - [WorkerStatus](#feedback-workerstatus)
49 - [File Dependencies](#feedback-filedependencies)
50 - [File Loaded](#feedback-fileloaded)
51 - [Message](#feedback-message)
52 - [Custom](#feedback-custom)
53 * [Ltac-debug messages](ltac_debug)
54 * [Highlighting Text](#highlighting)
55
56 Sentences: each command sent to Coqtop is a "sentence"; they are typically terminated by ".\s" (followed by whitespace or EOF).
57 Examples: "Lemma a: True.", "(* asdf *) Qed.", "auto; reflexivity."
58 In practice, the command sentences sent to Coqtop are terminated at the "." and start with any previous whitespace.
59 Each sentence is assigned a unique stateId after being sent to Coq (via Add).
60 States:
61 * Processing: has been received by Coq and has no obvious syntax error (that would prevent future parsing)
62 * Processed:
63 * InProgress:
64 * Incomplete: the validity of the sentence cannot be checked due to a prior error
65 * Complete:
66 * Error: the sentence has an error
67
68 State ID 0 is reserved as a 'dummy' state.
69
70 --------------------------
71
72 ## <a name="commands">Commands</a>
73
74 ### <a name="command-about">**About(unit)**</a>
75 Returns information about the protocol and build dates for Coqtop.
76 ```
77 <call val="About">
78 <unit/>
79 </call>
80 ```
81 #### *Returns*
82 ```html
83 <value val="good">
84 <coq_info><string>8.6</string>
85 <string>20150913</string>
86 <string>December 2016</string>
87 <string>Dec 23 2016 16:16:30</string>
88 </coq_info>
89 </value>
90 ```
91 The string fields are the Coq version, the protocol version, the release date, and the compile time of Coqtop.
92 The protocol version is a date in YYYYMMDD format, where "20150913" corresponds to Coq 8.6. An IDE that wishes
93 to support multiple Coq versions can use the protocol version information to know how to handle output from Coqtop.
94
95 ### <a name="command-add">**Add(command: string, editId: integer, stateId: integer, verbose: boolean, bp: integer, line_nb: integer, bol_pos: integer)**</a>
96 Adds a toplevel command (e.g. vernacular, definition, tactic) to the given state.
97 `verbose` controls whether out-of-band messages will be generated for the added command
98 (e.g. "foo is assumed" in response to adding "Axiom foo: nat."). `bp`, `line_nb` and
99 `bol_pos` are the `Loc.t` values relative to the IDE buffer.
100
101 ```html
102 <call val="Add">
103 <pair>
104 <pair>
105 <pair>
106 <pair>
107 <string>${command}</string>
108 <int>${editId}</int>
109 </pair>
110 <pair>
111 <state_id val="${stateId}"/>
112 <bool val="${verbose}"/>
113 </pair>
114 </pair>
115 <int>${bp}</int>
116 </pair>
117 <pair>
118 <int>${line_nb}</int>
119 <int>${bol_pos}</int>
120 </pair>
121 </pair>
122 </call>
123 ```
124
125 #### *Returns*
126 * The added command is given a fresh `stateId` and becomes the next "tip".
127 ```html
128 <value val="good">
129 <pair>
130 <state_id val="${newStateId}"/>
131 <union val="in_l">
132 <unit/>
133 </union>
134 </pair>
135 </value>
136 ```
137 * When closing a focused proof (in the middle of a bunch of interpreted commands),
138 the `Qed` will be assigned a prior `stateId` and `nextStateId` will be the id of an already-interpreted
139 state that should become the next tip.
140 ```html
141 <value val="good">
142 <pair>
143 <state_id val="${stateId}"/>
144 <pair>
145 <union val="in_r"><state_id val="${nextStateId}"/></union>
146 <string>${message}</string>
147 </pair>
148 </pair>
149 </value>
150 ```
151 * Failure:
152 - Syntax error. Error offsets are byte offsets (not character offsets) with respect to the start of the sentence, starting at 0.
153 ```html
154 <value val="fail">
155 <state_id val="${stateId}"/>
156 <option val="none|some">${loc}</option>
157 <richpp>${errorMessage}</richpp>
158 </value>
159 ```
160 - Another kind of error, for example, Qed with a pending goal.
161 ```html
162 <value val="fail"><state_id val="${stateId}"/><option val="some">${loc}</option><richpp>${errorMessage}</richpp></value>
163 ```
164
165 Note that IDEs may need to convert byte offsets passed in the four position fields of the
166 location to character offsets to correctly handle multi-byte characters. Also, due to
167 asynchronous evaluation, line number fields of locations may need to be adjusted
168 if the sentence has moved since it was sent to Coqtop.
169
170 -------------------------------
171
172 ### <a name="command-editAt">**EditAt(stateId: integer)**</a>
173 Moves current tip to `${stateId}`, such that commands may be added to the new state ID.
174 ```html
175 <call val="Edit_at"><state_id val="${stateId}"/></call>
176 ```
177 #### *Returns*
178 * Simple backtrack; focused stateId becomes the parent state
179 ```html
180 <value val="good">
181 <union val="in_l"><unit/></union>
182 </value>
183 ```
184
185 * New focus; focusedQedStateId is the closing Qed of the new focus; sentences between the two should be cleared
186 ```html
187 <value val="good">
188 <union val="in_r">
189 <pair>
190 <state_id val="${focusedStateId}"/>
191 <pair>
192 <state_id val="${focusedQedStateId}"/>
193 <state_id val="${oldFocusedStateId}"/>
194 </pair>
195 </pair>
196 </union>
197 </value>
198 ```
199 * Failure: If `stateId` is in an error-state and cannot be jumped to, `errorFreeStateId` is the parent state of `stateId` that should be edited instead.
200 ```html
201 <value val="fail">
202 <state_id val="${errorFreeStateId}"/>
203 <option val="none|some">${loc}</option>
204 ${errorMessage}
205 </value>
206 ```
207
208 -------------------------------
209
210 ### <a name="command-init">**Init()**</a>
211 * No options.
212 ```html
213 <call val="Init"><option val="none"/></call>
214 ```
215 * With options:
216 ```html
217 <call val="Init">
218 <option val="some">
219 <string>${v_file}.v</string>
220 </option>
221 </call>
222 ```
223 Providing the script file `$v_file.v` enables Coq to use the `.$v_file.aux`
224 file created during compilation. Those file contain timing information
225 that allow Coq to choose smartly between asynchronous and synchronous
226 processing of proofs.
227
228 #### *Returns*
229 * The initial stateId (not associated with a sentence)
230 ```html
231 <value val="good">
232 <state_id val="${initialStateId}"/>
233 </value>
234 ```
235
236 -------------------------------
237
238
239 ### <a name="command-goal">**Goal()**</a>
240 ```html
241 <call val="Goal"><unit/></call>
242 ```
243 #### *Returns*
244 * If there is a goal. `shelvedGoals` and `abandonedGoals` have the same structure as the first set of (current/foreground) goals. `backgroundGoals` contains a list of pairs of lists of goals (list ((list Goal)*(list Goal))); it represents a "focus stack" ([see code for reference](https://github.com/rocq-prover/rocq/blob/trunk/engine/proofview.ml#L113)). Each time a proof is focused, it will add a new pair of lists-of-goals. The first pair is the most nested set of background goals, the last pair is the top level set of background goals. The first list in the pair is in reverse order. Each time you focus the goal (e.g. using `Focus` or a bullet), a new pair will be prefixed to the list.
245 ```html
246 <value val="good">
247 <option val="some">
248 <goals>
249 <!-- current goals -->
250 <list>
251 <goal>
252 <string>3</string>
253 <list>
254 <richpp>${hyp1}</richpp>
255 ...
256 <richpp>${hypN}</richpp>
257 </list>
258 <richpp>${goal}</richpp>
259 </goal>
260 ...
261 ${goalN}
262 </list>
263 <!-- `backgroundGoals` -->
264 <list>
265 <pair>
266 <list><goal />...</list>
267 <list><goal />...</list>
268 </pair>
269 ...
270 </list>
271 ${shelvedGoals}
272 ${abandonedGoals}
273 </goals>
274 </option>
275 </value>
276 ```
277
278 For example, this script:
279 ```coq
280 Goal P -> (1=1/\2=2) /\ (3=3 /\ (4=4 /\ 5=5) /\ 6=6) /\ 7=7.
281 intros.
282 split; split. (* current visible goals are [1=1, 2=2, 3=3/\(4=4/\5=5)/\6=6, 7=7] *)
283 Focus 3. (* focus on 3=3/\(4=4/\5=5)/\6=6; bg-before: [1=1, 2=2], bg-after: [7=7] *)
284 split; [ | split ]. (* current visible goals are [3=3, 4=4/\5=5, 6=6] *)
285 Focus 2. (* focus on 4=4/\5=5; bg-before: [3=3], bg-after: [6=6] *)
286 * (* focus again on 4=4/\5=5; bg-before: [], bg-after: [] *)
287 split. (* current visible goals are [4=4,5=5] *)
288 ```
289 should generate the following goals structure:
290 ```
291 goals: [ P|-4=4, P|-5=5 ]
292 background:
293 [
294 ( [], [] ), (* bullet with one goal has no before or after background goals *)
295 ( [ P|-3=3 ], [ P|-6=6 ] ), (* Focus 2 *)
296 ( [ P|-2=2, P|-1=1 ], [ P|-7=7 ] ) (* Focus 3; notice that 1=1 and 2=2 are reversed *)
297 ]
298 ```
299 Pseudocode for listing all of the goals in order: `rev (flat_map fst background) ++ goals ++ flat_map snd background`.
300
301 * No goal:
302 ```html
303 <value val="good"><option val="none"/></value>
304 ```
305
306 -------------------------------
307
308 ### <a name="command-subgoals">**Subgoals(flags: goal_flags)**</a>
309 Similar to [Goal](#command-goal), but with `flags` to control whether to include
310 information about `fg`, `bg`, `shelved`, or `given_up` goals. The flags also
311 include `mode`, which is either "full" (return hypotheses and conclusion for
312 each goal) or "short" (return only the conclusion). The "short" mode is useful
313 for speeding up goal display when there are many shelved or admitted goals with
314 large proof contexts, but the IDE only needs to know their conclusions or how
315 many there are.
316 ```html
317 <call val="Subgoals">
318 <goal_flags>
319 <string>${mode}</string>
320 <bool val="${fg}"/>
321 <bool val="${bg}"/>
322 <bool val="${shelved}"/>
323 <bool val="${given_up}"/>
324 </goal_flags>
325 </call>
326 ```
327
328 #### Returns
329 * The same as [Goal](#command-goal).
330
331 -------------------------------
332
333 ### <a name="command-status">**Status(force: bool)**</a>
334 Returns information about the current proofs. RocqIDE typically sends this
335 message with `force = false` after each sentence, and with `force = true` if
336 the user wants to force the checking of all proofs (wheels button). In terms of
337 the STM API, `force` triggers a `Join`.
338 ```html
339 <call val="Status"><bool val="${force}"/></call>
340 ```
341 #### *Returns*
342 *
343 ```html
344 <status>
345 <string>${path}</string>
346 <string>${proofName}</string>
347 <string>${allProofs}</string>
348 <string>${proofNumber}</string>
349 </status>
350 ```
351
352 -------------------------------
353
354 ### <a name="command-query">**Query(route_id: integer, query: string, stateId: integer)**</a>
355
356 `routeId` can be used to distinguish the result of a particular query,
357 `stateId` should be set to the state the query should be run.
358
359 ```html
360 <call val="Query">
361 <pair>
362 <route_id val="${routeId}"/>
363 <pair>
364 <string>${query}</string>
365 <state_id val="${stateId}"/>
366 </pair>
367 </pair>
368 </call>
369 ```
370 #### *Returns*
371 *
372 ```html
373 <value val="good">
374 <string>${message}</string>
375 </value>
376 ```
377
378 Before 8.8, `Query` only executed the first command present in the
379 `query` string; starting with 8.8, the caller may include several
380 statements. This is useful for instance for temporarily setting an
381 option and then executing a command.
382
383 -------------------------------
384
385
386
387 ### <a name="command-evars">**Evars()**</a>
388 ```html
389 <call val="Evars"><unit/></call>
390 ```
391 #### *Returns*
392 *
393 ```html
394 <value val="good">
395 <option val="some">
396 <list>
397 <evar>${evar1}</evar>
398 ...
399 <evar>${evarN}</evar>
400 </list>
401 </option>
402 </value>
403 ```
404
405 -------------------------------
406
407
408 ### <a name="command-hints">**Hints()**</a>
409 ```html
410 <call val="Hints"><unit/></call>
411 ```
412 #### *Returns*
413 *
414 ```html
415 <value val="good">
416 <option val="some">
417 <pair>
418 <list/>
419 <list>
420 <pair>
421 <string>${hint1}</string>
422 <string>${hint2}</string>
423 </pair>
424 ...
425 <pair>
426 <string>${hintN-1}</string>
427 <string>${hintN}</string>
428 </pair>
429 </list>
430 </pair>
431 </option>
432 </value>
433 ```
434
435 -------------------------------
436
437
438 ### <a name="command-search">**Search([(constraintTypeN: string, constraintValueN: string, positiveConstraintN: boolean)])**</a>
439 Searches for objects that satisfy a list of constraints. If `${positiveConstraint}` is `false`, then the constraint is inverted.
440 ```html
441 <call val="Search">
442 <list>
443 <pair>
444 <search_cst val="${constraintType1}">
445 ${constraintValue1}
446 </search_cst>
447 <bool val="${positiveConstraint1}"/>
448 </pair>
449 ...
450 <!-- Example: -->
451 <pair>
452 <search_cst val="name_pattern">
453 <string>bool_rect</string>
454 </search_cst>
455 <bool val="true"/>
456 </pair>
457 </list>
458 </call>
459 ```
460 #### *Returns*
461 *
462 ```html
463 <value val="good">
464 <list>
465 <coq_object>
466 <list>
467 <string>${metaInfo}</string>
468 ...
469 </list>
470 <list>
471 <string>${name}</string>
472 </list>
473 <string>${definition}</string>
474 </coq_object>
475 ...
476 </list>
477 </value>
478 ```
479 ##### Types of constraints:
480 * Name pattern: `${constraintType} = "name_pattern"`; `${constraintValue}` is a regular expression string.
481 * Type pattern: `${constraintType} = "type_pattern"`; `${constraintValue}` is a pattern (???: an open gallina term) string.
482 * SubType pattern: `${constraintType} = "subtype_pattern"`; `${constraintValue}` is a pattern (???: an open gallina term) string.
483 * In module: `${constraintType} = "in_module"`; `${constraintValue}` is a list of strings specifying the module/directory structure.
484 * Include blacklist: `${constraintType} = "include_blacklist"`; `${constraintValue}` *is omitted*.
485
486 -------------------------------
487
488
489 ### <a name="command-getoptions">**GetOptions()**</a>
490 ```html
491 <call val="GetOptions"><unit/></call>
492 ```
493 #### *Returns*
494 *
495 ```html
496 <value val="good">
497 <list>
498 <pair>
499 <list><string>${string1}</string>...</list>
500 <option_state>
501 <bool>${sync}</bool>
502 <bool>${deprecated}</bool>
503 <string>${name}</string>
504 ${option_value}
505 </option_state>
506 </pair>
507 ...
508 </list>
509 </value>
510 ```
511
512 -------------------------------
513
514
515 ### <a name="command-setoptions">**SetOptions(options)**</a>
516 Sends a list of option settings, where each setting roughly looks like:
517 `([optionNamePart1, ..., optionNamePartN], value)`.
518 ```html
519 <call val="SetOptions">
520 <list>
521 <pair>
522 <list>
523 <string>optionNamePart1</string>
524 ...
525 <string>optionNamePartN</string>
526 </list>
527 <option_value val="${typeOfOption}">
528 <option val="some">
529 ${value}
530 </option>
531 </option_value>
532 </pair>
533 ...
534 <!-- Example: -->
535 <pair>
536 <list>
537 <string>Printing</string>
538 <string>Width</string>
539 </list>
540 <option_value val="intvalue">
541 <option val="some"><int>60</int></option>
542 </option_value>
543 </pair>
544 </list>
545 </call>
546 ```
547 RocqIDE sends the following settings (defaults in parentheses):
548 ```
549 Printing Width : (<option_value val="intvalue"><int>60</int></option_value>),
550 Printing Coercions : (<option_value val="boolvalue"><bool val="false"/></option_value>),
551 Printing Matching : (...true...)
552 Printing Notations : (...true...)
553 Printing Existential Instances : (...false...)
554 Printing Implicit : (...false...)
555 Printing All : (...false...)
556 Printing Universes : (...false...)
557 ```
558 #### *Returns*
559 *
560 ```html
561 <value val="good"><unit/></value>
562 ```
563
564 -------------------------------
565
566
567 ### <a name="command-mkcases">**MkCases(...)**</a>
568 ```html
569 <call val="MkCases"><string>...</string></call>
570 ```
571 #### *Returns*
572 *
573 ```html
574 <value val="good">
575 <list>
576 <list><string>${string1}</string>...</list>
577 ...
578 </list>
579 </value>
580 ```
581
582 -------------------------------
583
584
585 ### <a name="command-stopworker">**StopWorker(worker: string)**</a>
586 ```html
587 <call val="StopWorker"><string>${worker}</string></call>
588 ```
589 #### *Returns*
590 *
591 ```html
592 <value val="good"><unit/></value>
593 ```
594
595 -------------------------------
596
597
598 ### <a name="command-printast">**PrintAst(stateId: integer)**</a>
599 ```html
600 <call val="PrintAst"><state_id val="${stateId}"/></call>
601 ```
602 #### *Returns*
603 *
604 ```html
605 <value val="good">
606 <gallina begin="${gallina_begin}" end="${gallina_end}">
607 <theorem begin="${theorem_begin}" end="${theorem_end}" type="Theorem" name="${theorem_name}">
608 <apply begin="${apply_begin}" end="${apply_end}">
609 <operator begin="${operator_begin}" end="${operator_end}" name="${operator_name}"/>
610 <typed begin="${typed_begin}" end="${typed_end}">
611 <constant begin="${constant_begin}" end="${constant_end}" name="${constant_name}"/>
612 ...
613 <token begin="${token_begin}" end="token_end">${token}</token>
614 ...
615 </typed>
616 ...
617 </apply>
618 </theorem>
619 ...
620 </gallina>
621 </value>
622 ```
623
624 -------------------------------
625
626
627
628 ### <a name="command-annotate">**Annotate(annotation: string)**</a>
629 ```html
630 <call val="Annotate"><string>${annotation}</string></call>
631 ```
632 #### *Returns*
633 *
634
635 take `<call val="Annotate"><string>Theorem plus_0_r : forall n : nat, n + 0 = n.</string></call>` as an example.
636
637 ```html
638 <value val="good">
639 <pp startpos="0" endpos="45">
640 <vernac_expr startpos="0" endpos="44">
641 <keyword startpos="0" endpos="7">Theorem</keyword>
642 &nbsp;plus_0_r&nbsp;:&nbsp;
643 <constr_expr startpos="19" endpos="44">
644 <keyword startpos="19" endpos="25">forall</keyword>
645 &nbsp;n&nbsp;:&nbsp;
646 <constr_expr startpos="30" endpos="33">nat</constr_expr>
647 ,&nbsp;
648 <unparsing startpos="35" endpos="44">
649 <unparsing startpos="35" endpos="40">
650 <unparsing startpos="35" endpos="40">
651 <unparsing startpos="35" endpos="36">
652 <constr_expr startpos="35" endpos="36">n</constr_expr>
653 </unparsing>
654 <unparsing startpos="36" endpos="38">&nbsp;+</unparsing>
655 <unparsing startpos="38" endpos="39">&nbsp;</unparsing>
656 <unparsing startpos="39" endpos="40">
657 <constr_expr startpos="39" endpos="40">0</constr_expr>
658 </unparsing>
659 </unparsing>
660 </unparsing>
661 <unparsing startpos="40" endpos="42">&nbsp;=</unparsing>
662 <unparsing startpos="42" endpos="43">&nbsp;</unparsing>
663 <unparsing startpos="43" endpos="44">
664 <constr_expr startpos="43" endpos="44">n</constr_expr>
665 </unparsing>
666 </unparsing>
667 </constr_expr>
668 </vernac_expr>
669 .
670 </pp>
671 </value>
672 ```
673
674 -------------------------------
675
676
677
678 ### <a name="command-db_cmd">**Db_cmd(user_input: string)**</a>
679 ```html
680 <call val="Db_cmd"><string>${user_input}</string></call>
681 ```
682 #### *Returns*
683 *
684
685 `<call val="Db_cmd"><string>h</string></call>` directs Coq to process the debugger command "h".
686 It returns unit. This call is processed only when the debugger is stopped and has just
687 sent a `prompt` message.
688
689
690
691 -------------------------------
692
693
694
695 ### <a name="command-db_upd_bpts">**Db_upd_bpts(...)**</a>
696 The call passes a list of breakpoints to set or clear. The string is the
697 absolute pathname of the .v file (or "ToplevelInput"), the int is the byte offset
698 within the file and the boolean is true to set a breakpoint and false to clear it.
699 Breakpoints can be updated when Coq is not busy or when Coq is stopped in the
700 debugger. If this message is sent in other states, it will be received and
701 processed when Coq is no longer busy or execution stops in the debugger.
702
703 ```html
704 <call val="Db_upd_bpts">
705 <list>
706 <pair>
707 <pair>
708 <string>/home/proj/coq/ide/rocqide/debug.v</string>
709 <int>22</int>
710 </pair>
711 <bool val="true"/>
712 </pair>
713 </list>
714 </call>
715 ```
716 #### *Returns*
717 * Unit.
718
719
720
721 -------------------------------
722
723
724
725
726 ### <a name="command-db_continue">**Db_continue(option: integer)**</a>
727
728 Tells Coq to continue processing the proof when it is stopped in the debugger.
729 The integer indicates when the debugger should stop again:
730
731 ```
732 0: StepIn - step one tactic. If it is an Ltac tactic, stop at the first tactic within it
733 1: StepOver - step over one tactic. if it is an Ltac tactic, don't stop within it
734 2: StepOut - stop on the first tactic after exiting the current Ltac tactic
735 3: Continue - continue running until the next breakpoint or the debugger exits
736 4: Interrupt - generate a User interrupt (for use when stopped in the debugger; otherwise
737 interrupt is sent as a signal)
738 ```
739
740 If the debugger encounters a breakpoint during a StepOver or a StepOut, it will
741 stop at the breakpoint.
742
743 ```html
744 <call val="Db_continue">
745 <int>1</int>
746 </call>
747 ```
748
749 #### *Returns*
750 * Unit.
751
752
753
754 ### <a name="command-db_stack">**Db_stack()**</a>
755
756 Returns the Ltac call stack. Each entry has a description of what was called
757 (e.g. the tactic name) plus the absolute pathname of the file and the offset of
758 the call therein. The top of stack is the first entry in the list. Offsets
759 are in bytes, not counts of unicode characters.
760
761 ```html
762 <call val="Db_stack">
763 </unit>
764 </call>
765 ```
766
767 #### *Returns*
768 ```html
769 <value val="good">
770 <list>
771 <pair>
772 <string>vars2.z</string>
773 <option val="some">
774 <pair>
775 <string>ToplevelInput</string>
776 <list>
777 <int>51</int>
778 <int>58</int>
779 </list>
780 </pair>
781 </option>
782 </pair>
783 :
784 </list>
785 </value>
786 ```
787
788
789 ### <a name="command-db_vars">**Db_vars(frame: integer)**</a>
790
791 Returns a list of the names and values of the local variables defined in the
792 specified frame of the Ltac call stack. (0 = top of stack, 1, 2, ...).
793
794 ```html
795 <call val="Db_vars">
796 <int>0</int>
797 </call>
798 ```
799
800 #### *Returns*
801 ```html
802 <value val="good">
803 <list>
804 <pair>
805 <string>w</string>
806 <ppdoc val="string">
807 <string>0</string>
808 </ppdoc>
809 </pair>
810 :
811 </list>
812 </value>
813 ```
814
815
816 -------------------------------
817
818 ## <a name="feedback">Feedback messages</a>
819
820 Feedback messages are issued out-of-band,
821 giving updates on the current state of sentences/stateIds,
822 worker-thread status, etc.
823
824 In the descriptions of feedback syntax below, wherever a `state_id`
825 tag may occur, there may instead be an `edit_id` tag.
826
827 * <a name="feedback-addedaxiom">Added Axiom</a>: in response to `Axiom`, `admit`, `Admitted`, etc.
828 ```html
829 <feedback object="state" route="0">
830 <state_id val="${stateId}"/>
831 <feedback_content val="addedaxiom" />
832 </feedback>
833 ```
834 * <a name="feedback-processing">Processing</a>
835 ```html
836 <feedback object="state" route="0">
837 <state_id val="${stateId}"/>
838 <feedback_content val="processingin">
839 <string>${workerName}</string>
840 </feedback_content>
841 </feedback>
842 ```
843 * <a name="feedback-processed">Processed</a>
844 ```html
845 <feedback object="state" route="0">
846 <feedback object="state" route="0">
847 <state_id val="${stateId}"/>
848 <feedback_content val="processed"/>
849 </feedback>
850 ```
851 * <a name="feedback-incomplete">Incomplete</a>
852 ```html
853 <feedback object="state" route="0">
854 <state_id val="${stateId}"/>
855 <feedback_content val="incomplete" />
856 </feedback>
857 ```
858 * <a name="feedback-complete">Complete</a>
859 * <a name="feedback-globref">GlobRef</a>
860 * <a name="feedback-error">Error</a>. Issued, for example, when a processed tactic has failed or is unknown.
861 The error offsets may both be 0 if there is no particular syntax involved.
862 * <a name="feedback-inprogress">InProgress</a>
863 ```html
864 <feedback object="state" route="0">
865 <state_id val="${stateId}"/>
866 <feedback_content val="inprogress">
867 <int>1</int>
868 </feedback_content>
869 </feedback>
870 ```
871 * <a name="feedback-workerstatus">WorkerStatus</a>
872 Ex: `workername = "proofworker:0"`
873 Ex: `status = "Idle"` or `status = "proof: myLemmaName"` or `status = "Dead"`
874 ```html
875 <feedback object="state" route="0">
876 <state_id val="${stateId}"/>
877 <feedback_content val="workerstatus">
878 <pair>
879 <string>${workerName}</string>
880 <string>${status}</string>
881 </pair>
882 </feedback_content>
883 </feedback>
884 ```
885 * <a name="feedback-filedependencies">File Dependencies</a>. Typically in response to a `Require`. Dependencies are *.vo files.
886 - State `stateId` directly depends on `dependency`:
887 ```html
888 <feedback object="state" route="0">
889 <state_id val="${stateId}"/>
890 <feedback_content val="filedependency">
891 <option val="none"/>
892 <string>${dependency}</string>
893 </feedback_content>
894 </feedback>
895 ```
896 - State `stateId` depends on `dependency` via dependency `sourceDependency`
897 ```xml
898 <feedback object="state" route="0">
899 <state_id val="${stateId}"/>
900 <feedback_content val="filedependency">
901 <option val="some"><string>${sourceDependency}</string></option>
902 <string>${dependency}</string>
903 </feedback_content>
904 </feedback>
905 ```
906 * <a name="feedback-fileloaded">File Loaded</a>. For state `stateId`, module `module` is being loaded from `voFileName`
907 ```xml
908 <feedback object="state" route="0">
909 <state_id val="${stateId}"/>
910 <feedback_content val="fileloaded">
911 <string>${module}</string>
912 <string>${voFileName`}</string>
913 </feedback_content>
914 </feedback>
915 ```
916
917 * <a name="feedback-message">Message</a>. `level` is one of `{info,warning,notice,error,debug}`. For example, in response to an <a href="#command-add">add</a> `"Axiom foo: nat."` with `verbose=true`, message `foo is assumed` will be emitted in response.
918 ```xml
919 <feedback object="state" route="0">
920 <state_id val="${stateId}"/>
921 <feedback_content val="message">
922 <message>
923 <message_level val="${level}"/>
924 <string>${message}</string>
925 </message>
926 </feedback_content>
927 </feedback>
928 ```
929 * <a name="location">Location</a>, a Coq location (`Loc.t`)
930 ```xml
931 <loc start="${start_offset}" stop="${stop_offset}
932 line_nb="${start_line}" bol_pos="${begin_of_start_line_offset}"
933 line_nb_last="${end_line}" bol_pos_last="${begin_of_end_line_offset}"
934 ```
935
936 * <a name="feedback-custom">Custom</a>. A feedback message that Coq plugins can use to return structured results, including results from Ltac profiling. `customTag` is intended as a unique string that identifies what kind of payload is contained in `customXML`. An optional location may be attached if present in the message.
937 ```xml
938 <feedback object="state" route="0">
939 <state_id val="${stateId}"/>
940 <feedback_content val="custom">
941 <option val="none|some">${loc}</option>
942 <string>${customTag}</string>
943 ${customXML}
944 </feedback_content>
945 </feedback>
946 ```
947
948 -------------------------------
949
950 ## <a name="ltac-debug">Ltac-debug messages</a>
951
952 Ltac-debug messages are issued out-of-band, similar to Feedback messages.
953 The response contains an identifying tag and a `<ppdoc>`.
954 Currently these tags are used:
955
956 * **output** - ordinary output for display in the Messages panel
957 * **goal** - the current goal for the debugger, for display in the Messages panel
958 or elsewhere
959 * **prompt** - output for display in the Messages panel prompting the user to
960 enter a debug command, allowing RocqIDE to display it without
961 appending a newline. It also signals that coqidetop is waiting to receive
962 a debugger-specific message such as [Db_cmd](#command-db_cmd).
963
964 ```xml
965 <ltac_debug>
966 prompt
967 <ppdoc val="tag">
968 :
969 </ppdoc>
970 </ltac_debug>
971 ```
972
973 -------------------------------
974
975 ## <a name="highlighting">Highlighting Text</a>
976
977 [Proof diffs](https://coq.inria.fr/distrib/current/refman/proof-engine/proof-handling.html#showing-differences-between-proof-steps)
978 highlight differences between the current and previous proof states in the displayed output.
979 These are represented by tags embedded in output fields of the XML document.
980
981 There are 4 tags that indicate how the enclosed text should be highlighted:
982 - diff.added - added text
983 - diff.removed - removed text
984 - diff.added.bg - unchanged text in a line that has additions ("bg" for "background")
985 - diff.removed.bg - unchanged text in a line that has removals
986
987 RocqIDE, Proof General and coqtop currently use 2 shades of green and 2 shades of red
988 as the background color for highlights. Coqtop and RocqIDE also apply underlining and/or
989 strikeout highlighting for the sake of the color blind.
990
991 For example, `<diff.added>ABC</diff.added>` indicates that "ABC" should be highlighted
992 as added text. Tags can be nested, such as:
993 `<diff.added.bg>A <diff.added> + 1</diff.added> + B</diff.added.bg>`. IDE code
994 displaying highlighted strings should maintain a stack for nested tags and the associated
995 highlight. Currently the diff code only nests at most 2 tags deep.
996 If an IDE uses other highlights such as text foreground color or italic text, it may
997 need to merge the background color with those other highlights to give the desired
998 (IDE dependent) behavior.
999
1000 The current implementations avoid highlighting white space at the beginning or the
1001 end of a line. This gives a better appearance.
1002
1003 There may be additional text that is marked with other tags in the output text. IDEs probably
1004 should ignore and not display tags they don't recognize.
1005
1006 Some internal details about generating tags within Coq (e.g. if you want to add
1007 additional tags):
1008
1009 Tagged output strings are generated from Pp.t's. Use Pp.tag to highlight a Pp.t using
1010 one of the tags listed above. A span of tokens can be marked by using "start.<tag>" on
1011 the first token and "end.<tag>" on the last token. (Span markers are needed because a span of
1012 tokens in the output may not match nesting of layout boxes in the Pp.t.)
1013 The conversion from the Pp.t to the XML-tagged string replaces the "start.\*" and "end.\*"
1014 tags with the basic tags.