From 865fa8fc7aacbca3ab167e65f56e280d334eb192 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Thu, 13 Apr 2017 16:38:26 -0400 Subject: add XML protocol doc for 8.5 --- dev/doc/xml-protocol.md | 738 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 738 insertions(+) create mode 100644 dev/doc/xml-protocol.md (limited to 'dev/doc') diff --git a/dev/doc/xml-protocol.md b/dev/doc/xml-protocol.md new file mode 100644 index 0000000000..22aa120d5d --- /dev/null +++ b/dev/doc/xml-protocol.md @@ -0,0 +1,738 @@ +#Coq XML Protocol for Coq 8.5# + +This document is based on documentation originally written by CJ Bell +for his [vscoq](https://github.com/siegebell/vscoq/) project. + +Here, the aim is to provide a "hands on" description of the XML +protocol that coqtop and IDEs use to communicate. The protocol first appeared +with Coq 8.5, and is used by CoqIDE. It will also be used in upcoming +versions of Proof General. + +A somewhat out-of-date description of the async state machine is +[documented here](https://github.com/ejgallego/jscoq/blob/master/etc/notes/coq-notes.md). +OCaml types for the protocol can be found in the [`ide/interface.mli` file](/ide/interface.mli). + +* [Commands](#commands) + - [About](#command-about) + - [Add](#command-add) + - [EditAt](#command-editAt) + - [Init](#command-init) + - [Goal](#command-goal) + - [Status](#command-status) + - [Query](#command-query) + - [Evars](#command-evars) + - [Hints](#command-hints) + - [Search](#command-search) + - [GetOptions](#command-getoptions) + - [SetOptions](#command-setoptions) + - [MkCases](#command-mkcases) + - [StopWorker](#command-stopworker) + - [PrintAst](#command-printast) + - [Annotate](#command-annotate) +* [Feedback messages](#feedback) + - [Added Axiom](#feedback-addedaxiom) + - [Processing](#feedback-processing) + - [Processed](#feedback-processed) + - [Incomplete](#feedback-incomplete) + - [Complete](#feedback-complete) + - [GlobRef](#feedback-globref) + - [Error](#feedback-error) + - [InProgress](#feedback-inprogress) + - [WorkerStatus](#feedback-workerstatus) + - [File Dependencies](#feedback-filedependencies) + - [File Loaded](#feedback-fileloaded) + - [ErrorMessage](#feedback-errormessage) + - [Message](#feedback-message) + - [Custom](#feedback-custom) + +Sentences: each command sent to Coqtop is a "sentence"; they are typically terminated by ".\s" (followed by whitespace or EOF). +Examples: "Lemma a: True.", "(* asdf *) Qed.", "auto; reflexivity." +In practice, the command sentences sent to Coqtop are terminated at the "." and start with any previous whitespace. +Each sentence is assigned a unique stateId after being sent to Coq (via Add). +States: + * Processing: has been received by Coq and has no obvious syntax error (that would prevent future parsing) + * Processed: + * InProgress: + * Incomplete: the validity of the sentence cannot be checked due to a prior error + * Complete: + * Error: the sentence has an error + +State ID 0 is reserved as a 'dummy' state. + +-------------------------- + +## Commands + +### **About(unit)** +Returns information about the protocol and build dates for Coqtop. +``` + + + +``` +#### *Returns* +```html + + 8.5 + 20140312 + April 2014 + April 15 2014 16:16:30 + + +``` +The string fields are the Coq version, the protocol version, the release date, and the compile time of Coqtop. +The protocol version is a date in YYYYMMDD format, where "20140312" corresponds to Coq 8.5. An IDE that wishes +to support multiple Coq versions can use the protocol version information to know how to handle output from Coqtop. + +### **Add(stateId: integer, command: string, verbose: boolean)** +Adds a toplevel command (e.g. vernacular, definition, tactic) to the given state. +`verbose` controls whether out-of-band messages will be generated for the added command (e.g. "foo is assumed" in response to adding "Axiom foo: nat."). +```html + + + + ${command} + ${editId} + + + + + + + +``` + +#### *Returns* +* The added command is given a fresh `stateId` and becomes the next "tip". +```html + + + + + + ${message} + + + +``` +* When closing a focused proof (in the middle of a bunch of interpreted commands), +the `Qed` will be assigned a prior `stateId` and `nextStateId` will be the id of an already-interpreted +state that should become the next tip. +```html + + + + + + ${message} + + + +``` +* Failure: + - Syntax error. Error offsets are byte offsets (not character offsets) with respect to the start of the sentence, starting at 0. + ```html + + + ${errorMessage} + + ``` + - Another kind of error, for example, Qed with a pending goal. + ```html + ${errorMessage} + ``` + +------------------------------- + +### **EditAt(stateId: integer)** +Moves current tip to `${stateId}`, such that commands may be added to the new state ID. +```html + +``` +#### *Returns* +* Simple backtrack; focused stateId becomes the parent state +```html + + + +``` + +* New focus; focusedQedStateId is the closing Qed of the new focus; senteneces between the two should be cleared +```html + + + + + + + + + + + +``` +* Failure: If `stateId` is in an error-state and cannot be jumped to, `errorFreeStateId` is the parent state of ``stateId` that shopuld be edited instead. +```html + + + ${errorMessage} + +``` + +------------------------------- + +### **Init()** +* No options. +```html + +``` +* With options. Looking at + [ide_slave.ml](https://github.com/coq/coq/blob/c5d0aa889fa80404f6c291000938e443d6200e5b/ide/ide_slave.ml#L355), + it seems that `options` is just the name of a script file, whose path + is added via `Add LoadPath` to the initial state. +```html + + + +``` +Providing the script file enables Coq to use .aux files created during +compilation. Those file contain timing information that allow Coq to +choose smartly between asynchronous and synchronous processing of +proofs. + +#### *Returns* +* The initial stateId (not associated with a sentence) +```html + + + +``` + +------------------------------- + + +### **Goal()** +```html + +``` +#### *Returns* +* 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/coq/coq/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. +```html + + + +``` + +For example, this script: +```coq +Goal P -> (1=1/\2=2) /\ (3=3 /\ (4=4 /\ 5=5) /\ 6=6) /\ 7=7. +intros. +split; split. (* current visible goals are [1=1, 2=2, 3=3/\(4=4/\5=5)/\6=6, 7=7] *) +Focus 3. (* focus on 3=3/\(4=4/\5=5)/\6=6; bg-before: [1=1, 2=2], bg-after: [7=7] *) +split; [ | split ]. (* current visible goals are [3=3, 4=4/\5=5, 6=6] *) +Focus 2. (* focus on 4=4/\5=5; bg-before: [3=3], bg-after: [6=6] *) +* (* focus again on 4=4/\5=5; bg-before: [], bg-after: [] *) +split. (* current visible goals are [4=4,5=5] *) +``` +should generate the following goals structure: +``` +goals: [ P|-4=4, P|-5=5 ] +background: +[ + ( [], [] ), (* bullet with one goal has no before or after background goals *) + ( [ P|-3=3 ], [ P|-6=6 ] ), (* Focus 2 *) + ( [ P|-2=2, P|-1=1 ], [ P|-7=7 ] ) (* Focus 3; notice that 1=1 and 2=2 are reversed *) +] +``` +Pseudocode for listing all of the goals in order: `rev (flat_map fst background) ++ goals ++ flat_map snd background`. + +* No goal: +```html + +``` + +------------------------------- + + +### **Status(force: bool)** +CoqIDE typically sets `force` to `false`. +```html + +``` +#### *Returns* +* +```html + + ${path} + ${proofName} + ${allProofs} + ${proofNumber} + +``` + +------------------------------- + + +### **Query(query: string, stateId: integer)** +In practice, `stateId` is 0, but the effect is to perform the query on the currently-focused state. +```html + + + ${query} + + + +``` +#### *Returns* +* +```html + + ${message} + +``` +------------------------------- + + + +### **Evars()** +```html + +``` +#### *Returns* +* +```html + + + +``` + +------------------------------- + + +### **Hints()** +```html + +``` +#### *Returns* +* +```html + + + +``` + +------------------------------- + + +### **Search([(constraintTypeN: string, constraintValueN: string, positiveConstraintN: boolean)])** +Searches for objects that satisfy a list of constraints. If `${positiveConstraint}` is `false`, then the constraint is inverted. +```html + + + + + ${constraintValue1} + + + + ... + + + + bool_rect + + + + + +``` +#### *Returns* +* +```html + + + + + ${metaInfo} + ... + + + ${name} + + ${definition} + + ... + + +``` +##### Types of constraints: +* Name pattern: `${constraintType} = "name_pattern"`; `${constraintValue}` is a regular expression string. +* Type pattern: `${constraintType} = "type_pattern"`; `${constraintValue}` is a pattern (???: an open gallina term) string. +* SubType pattern: `${constraintType} = "subtype_pattern"`; `${constraintValue}` is a pattern (???: an open gallina term) string. +* In module: `${constraintType} = "in_module"`; `${constraintValue}` is a list of strings specifying the module/directory structure. +* Include blacklist: `${constraintType} = "include_blacklist"`; `${constraintValue}` *is ommitted*. + +------------------------------- + + +### **GetOptions()** +```html + +``` +#### *Returns* +* +```html + + + + ${string1}... + + ${sync} + ${deprecated} + ${name} + ${option_value} + + + ... + + +``` + +------------------------------- + + +### **SetOptions(options)** +Sends a list of option settings, where each setting roughly looks like: +`([optionNamePart1, ..., optionNamePartN], value)`. +```html + + + + + optionNamePart1 + ... + optionNamePartN + + + + + + ... + + + + Printing + Width + + + + + + + +``` +CoqIDE sends the following settings (defaults in parentheses): +``` +Printing Width : (60), +Printing Coercions : (), +Printing Matching : (...true...) +Printing Notations : (...true...) +Printing Existential Instances : (...false...) +Printing Implicit : (...false...) +Printing All : (...false...) +Printing Universes : (...false...) +``` +#### *Returns* +* +```html + +``` + +------------------------------- + + +### **MkCases(...)** +```html +... +``` +#### *Returns* +* +```html + + + ${string1}... + ... + + +``` + +------------------------------- + + +### **StopWorker(worker: string)** +```html +${worker} +``` +#### *Returns* +* +```html + +``` + +------------------------------- + + +### **PrintAst(stateId: integer)** +```html + +``` +#### *Returns* +* +```html + + + + + + + + ... + ${token} + ... + + ... + + + ... + + +``` + +------------------------------- + + + +### **Annotate(annotation: string)** +```html +${annotation} +``` +#### *Returns* +* + +take `Theorem plus_0_r : forall n : nat, n + 0 = n.` as an example. + +```html + + + + Theorem +  plus_0_r :  + + forall +  n :  + nat + ,  + + + + + n + +  + +   + + 0 + + + +  = +   + + n + + + + + . + + +``` + +------------------------------- + +## Feedback messages + +Feedback messages are issued out-of-band, + giving updates on the current state of sentences/stateIds, + worker-thread status, etc. + +In the descriptions of feedback syntax below, wherever a `state_id` +tag may occur, there may instead be an `edit_id` tag. + +* Added Axiom: in response to `Axiom`, `admit`, `Admitted`, etc. +```html + + + + +``` +* Processing +```html + + + + ${workerName} + + +``` +* Processed +```html + + + + + +``` +* Incomplete +```html + + + + +``` +* Complete +* GlobRef +* Error. Issued, for example, when a processed tactic has failed or is unknown. +The error offsets may both be 0 if there is no particular syntax involved. +* InProgress +```html + + + + 1 + + +``` +* WorkerStatus +Ex: `workername = "proofworker:0"` +Ex: `status = "Idle"` or `status = "proof: myLemmaName"` or `status = "Dead"` +```html + + + + + ${workerName} + ${status} + + + +``` +* File Dependencies. Typically in response to a `Require`. Dependencies are *.vo files. + - State `stateId` directly depends on `dependency`: + ```html + + + + + + ``` + - State `stateId` depends on `dependency` via dependency `sourceDependency` + ```xml + + + + + ${dependency} + + + ``` +* File Loaded. For state `stateId`, module `module` is being loaded from `voFileName` +```xml + + + + ${module} + ${voFileName`} + + +``` + +* Error Message. +```xml + + + + + ${errorMessage" + + +``` + +* Custom. A feedback message that Coq plugins can use to return structured results, including results from Ltac profiling. Optionally, `startPos` and `stopPos` define a range of offsets in the document that the message refers to; otherwise, they will be 0. `customTag` is intended as a unique string that identifies what kind of payload is contained in `customXML`. +```xml + + + + + ${customTag} + ${customXML} + + +``` + -- cgit v1.2.3 From 6ef2dc11653e0572db6f7660470242ed23a0bdc2 Mon Sep 17 00:00:00 2001 From: Paul Steckler Date: Thu, 13 Apr 2017 16:38:48 -0400 Subject: update XML protocol doc to 8.6 --- dev/doc/xml-protocol.md | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'dev/doc') diff --git a/dev/doc/xml-protocol.md b/dev/doc/xml-protocol.md index 22aa120d5d..4e51176059 100644 --- a/dev/doc/xml-protocol.md +++ b/dev/doc/xml-protocol.md @@ -1,4 +1,4 @@ -#Coq XML Protocol for Coq 8.5# +#Coq XML Protocol for Coq 8.6# This document is based on documentation originally written by CJ Bell for his [vscoq](https://github.com/siegebell/vscoq/) project. @@ -12,6 +12,12 @@ A somewhat out-of-date description of the async state machine is [documented here](https://github.com/ejgallego/jscoq/blob/master/etc/notes/coq-notes.md). OCaml types for the protocol can be found in the [`ide/interface.mli` file](/ide/interface.mli). +# CHANGES +## Changes from 8.5: + * In several places, flat text wrapped in tags now appears as structured text inside tags + * The "errormsg" feedback has been replaced by a "message" feedback which contains + tag, with a message_level attribute of "error" + * [Commands](#commands) - [About](#command-about) - [Add](#command-add) @@ -41,7 +47,6 @@ OCaml types for the protocol can be found in the [`ide/interface.mli` file](/ide - [WorkerStatus](#feedback-workerstatus) - [File Dependencies](#feedback-filedependencies) - [File Loaded](#feedback-fileloaded) - - [ErrorMessage](#feedback-errormessage) - [Message](#feedback-message) - [Custom](#feedback-custom) @@ -73,15 +78,15 @@ Returns information about the protocol and build dates for Coqtop. #### *Returns* ```html - 8.5 - 20140312 - April 2014 - April 15 2014 16:16:30 + 8.6 + 20150913 + December 2016 + Dec 23 2016 16:16:30 ``` The string fields are the Coq version, the protocol version, the release date, and the compile time of Coqtop. -The protocol version is a date in YYYYMMDD format, where "20140312" corresponds to Coq 8.5. An IDE that wishes +The protocol version is a date in YYYYMMDD format, where "20150913" corresponds to Coq 8.6. An IDE that wishes to support multiple Coq versions can use the protocol version information to know how to handle output from Coqtop. ### **Add(stateId: integer, command: string, verbose: boolean)** @@ -136,12 +141,12 @@ state that should become the next tip. loc_s="${startOffsetOfError}" loc_e="${endOffsetOfError}"> - ${errorMessage} + ${errorMessage} ``` - Another kind of error, for example, Qed with a pending goal. ```html - ${errorMessage} + ${errorMessage} ``` ------------------------------- @@ -230,11 +235,11 @@ proofs. 3 - ${hyp1} + ${hyp1} ... - ${hypN} + ${hypN} - ${goal} + ${goal} ... ${goalN} @@ -713,13 +718,15 @@ Ex: `status = "Idle"` or `status = "proof: myLemmaName"` or `status = "Dead"` ``` -* Error Message. +* Message. `level` is one of `{info,warning,notice,error,debug}`. For example, in response to an add `"Axiom foo: nat."` with `verbose=true`, message `foo is assumed` will be emitted in response. ```xml - - ${errorMessage" + + + ${message} + ``` -- cgit v1.2.3 From 74f9548a083409d400f2723ee8c1e07705da4812 Mon Sep 17 00:00:00 2001 From: Maxime Dénès Date: Fri, 14 Apr 2017 20:49:16 +0200 Subject: Fix EOL characters in xml protocol documentation. --- dev/doc/xml-protocol.md | 1490 +++++++++++++++++++++++------------------------ 1 file changed, 745 insertions(+), 745 deletions(-) (limited to 'dev/doc') diff --git a/dev/doc/xml-protocol.md b/dev/doc/xml-protocol.md index 4e51176059..2ff82c6888 100644 --- a/dev/doc/xml-protocol.md +++ b/dev/doc/xml-protocol.md @@ -1,745 +1,745 @@ -#Coq XML Protocol for Coq 8.6# - -This document is based on documentation originally written by CJ Bell -for his [vscoq](https://github.com/siegebell/vscoq/) project. - -Here, the aim is to provide a "hands on" description of the XML -protocol that coqtop and IDEs use to communicate. The protocol first appeared -with Coq 8.5, and is used by CoqIDE. It will also be used in upcoming -versions of Proof General. - -A somewhat out-of-date description of the async state machine is -[documented here](https://github.com/ejgallego/jscoq/blob/master/etc/notes/coq-notes.md). -OCaml types for the protocol can be found in the [`ide/interface.mli` file](/ide/interface.mli). - -# CHANGES -## Changes from 8.5: - * In several places, flat text wrapped in tags now appears as structured text inside tags - * The "errormsg" feedback has been replaced by a "message" feedback which contains - tag, with a message_level attribute of "error" - -* [Commands](#commands) - - [About](#command-about) - - [Add](#command-add) - - [EditAt](#command-editAt) - - [Init](#command-init) - - [Goal](#command-goal) - - [Status](#command-status) - - [Query](#command-query) - - [Evars](#command-evars) - - [Hints](#command-hints) - - [Search](#command-search) - - [GetOptions](#command-getoptions) - - [SetOptions](#command-setoptions) - - [MkCases](#command-mkcases) - - [StopWorker](#command-stopworker) - - [PrintAst](#command-printast) - - [Annotate](#command-annotate) -* [Feedback messages](#feedback) - - [Added Axiom](#feedback-addedaxiom) - - [Processing](#feedback-processing) - - [Processed](#feedback-processed) - - [Incomplete](#feedback-incomplete) - - [Complete](#feedback-complete) - - [GlobRef](#feedback-globref) - - [Error](#feedback-error) - - [InProgress](#feedback-inprogress) - - [WorkerStatus](#feedback-workerstatus) - - [File Dependencies](#feedback-filedependencies) - - [File Loaded](#feedback-fileloaded) - - [Message](#feedback-message) - - [Custom](#feedback-custom) - -Sentences: each command sent to Coqtop is a "sentence"; they are typically terminated by ".\s" (followed by whitespace or EOF). -Examples: "Lemma a: True.", "(* asdf *) Qed.", "auto; reflexivity." -In practice, the command sentences sent to Coqtop are terminated at the "." and start with any previous whitespace. -Each sentence is assigned a unique stateId after being sent to Coq (via Add). -States: - * Processing: has been received by Coq and has no obvious syntax error (that would prevent future parsing) - * Processed: - * InProgress: - * Incomplete: the validity of the sentence cannot be checked due to a prior error - * Complete: - * Error: the sentence has an error - -State ID 0 is reserved as a 'dummy' state. - --------------------------- - -## Commands - -### **About(unit)** -Returns information about the protocol and build dates for Coqtop. -``` - - - -``` -#### *Returns* -```html - - 8.6 - 20150913 - December 2016 - Dec 23 2016 16:16:30 - - -``` -The string fields are the Coq version, the protocol version, the release date, and the compile time of Coqtop. -The protocol version is a date in YYYYMMDD format, where "20150913" corresponds to Coq 8.6. An IDE that wishes -to support multiple Coq versions can use the protocol version information to know how to handle output from Coqtop. - -### **Add(stateId: integer, command: string, verbose: boolean)** -Adds a toplevel command (e.g. vernacular, definition, tactic) to the given state. -`verbose` controls whether out-of-band messages will be generated for the added command (e.g. "foo is assumed" in response to adding "Axiom foo: nat."). -```html - - - - ${command} - ${editId} - - - - - - - -``` - -#### *Returns* -* The added command is given a fresh `stateId` and becomes the next "tip". -```html - - - - - - ${message} - - - -``` -* When closing a focused proof (in the middle of a bunch of interpreted commands), -the `Qed` will be assigned a prior `stateId` and `nextStateId` will be the id of an already-interpreted -state that should become the next tip. -```html - - - - - - ${message} - - - -``` -* Failure: - - Syntax error. Error offsets are byte offsets (not character offsets) with respect to the start of the sentence, starting at 0. - ```html - - - ${errorMessage} - - ``` - - Another kind of error, for example, Qed with a pending goal. - ```html - ${errorMessage} - ``` - -------------------------------- - -### **EditAt(stateId: integer)** -Moves current tip to `${stateId}`, such that commands may be added to the new state ID. -```html - -``` -#### *Returns* -* Simple backtrack; focused stateId becomes the parent state -```html - - - -``` - -* New focus; focusedQedStateId is the closing Qed of the new focus; senteneces between the two should be cleared -```html - - - - - - - - - - - -``` -* Failure: If `stateId` is in an error-state and cannot be jumped to, `errorFreeStateId` is the parent state of ``stateId` that shopuld be edited instead. -```html - - - ${errorMessage} - -``` - -------------------------------- - -### **Init()** -* No options. -```html - -``` -* With options. Looking at - [ide_slave.ml](https://github.com/coq/coq/blob/c5d0aa889fa80404f6c291000938e443d6200e5b/ide/ide_slave.ml#L355), - it seems that `options` is just the name of a script file, whose path - is added via `Add LoadPath` to the initial state. -```html - - - -``` -Providing the script file enables Coq to use .aux files created during -compilation. Those file contain timing information that allow Coq to -choose smartly between asynchronous and synchronous processing of -proofs. - -#### *Returns* -* The initial stateId (not associated with a sentence) -```html - - - -``` - -------------------------------- - - -### **Goal()** -```html - -``` -#### *Returns* -* 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/coq/coq/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. -```html - - - -``` - -For example, this script: -```coq -Goal P -> (1=1/\2=2) /\ (3=3 /\ (4=4 /\ 5=5) /\ 6=6) /\ 7=7. -intros. -split; split. (* current visible goals are [1=1, 2=2, 3=3/\(4=4/\5=5)/\6=6, 7=7] *) -Focus 3. (* focus on 3=3/\(4=4/\5=5)/\6=6; bg-before: [1=1, 2=2], bg-after: [7=7] *) -split; [ | split ]. (* current visible goals are [3=3, 4=4/\5=5, 6=6] *) -Focus 2. (* focus on 4=4/\5=5; bg-before: [3=3], bg-after: [6=6] *) -* (* focus again on 4=4/\5=5; bg-before: [], bg-after: [] *) -split. (* current visible goals are [4=4,5=5] *) -``` -should generate the following goals structure: -``` -goals: [ P|-4=4, P|-5=5 ] -background: -[ - ( [], [] ), (* bullet with one goal has no before or after background goals *) - ( [ P|-3=3 ], [ P|-6=6 ] ), (* Focus 2 *) - ( [ P|-2=2, P|-1=1 ], [ P|-7=7 ] ) (* Focus 3; notice that 1=1 and 2=2 are reversed *) -] -``` -Pseudocode for listing all of the goals in order: `rev (flat_map fst background) ++ goals ++ flat_map snd background`. - -* No goal: -```html - -``` - -------------------------------- - - -### **Status(force: bool)** -CoqIDE typically sets `force` to `false`. -```html - -``` -#### *Returns* -* -```html - - ${path} - ${proofName} - ${allProofs} - ${proofNumber} - -``` - -------------------------------- - - -### **Query(query: string, stateId: integer)** -In practice, `stateId` is 0, but the effect is to perform the query on the currently-focused state. -```html - - - ${query} - - - -``` -#### *Returns* -* -```html - - ${message} - -``` -------------------------------- - - - -### **Evars()** -```html - -``` -#### *Returns* -* -```html - - - -``` - -------------------------------- - - -### **Hints()** -```html - -``` -#### *Returns* -* -```html - - - -``` - -------------------------------- - - -### **Search([(constraintTypeN: string, constraintValueN: string, positiveConstraintN: boolean)])** -Searches for objects that satisfy a list of constraints. If `${positiveConstraint}` is `false`, then the constraint is inverted. -```html - - - - - ${constraintValue1} - - - - ... - - - - bool_rect - - - - - -``` -#### *Returns* -* -```html - - - - - ${metaInfo} - ... - - - ${name} - - ${definition} - - ... - - -``` -##### Types of constraints: -* Name pattern: `${constraintType} = "name_pattern"`; `${constraintValue}` is a regular expression string. -* Type pattern: `${constraintType} = "type_pattern"`; `${constraintValue}` is a pattern (???: an open gallina term) string. -* SubType pattern: `${constraintType} = "subtype_pattern"`; `${constraintValue}` is a pattern (???: an open gallina term) string. -* In module: `${constraintType} = "in_module"`; `${constraintValue}` is a list of strings specifying the module/directory structure. -* Include blacklist: `${constraintType} = "include_blacklist"`; `${constraintValue}` *is ommitted*. - -------------------------------- - - -### **GetOptions()** -```html - -``` -#### *Returns* -* -```html - - - - ${string1}... - - ${sync} - ${deprecated} - ${name} - ${option_value} - - - ... - - -``` - -------------------------------- - - -### **SetOptions(options)** -Sends a list of option settings, where each setting roughly looks like: -`([optionNamePart1, ..., optionNamePartN], value)`. -```html - - - - - optionNamePart1 - ... - optionNamePartN - - - - - - ... - - - - Printing - Width - - - - - - - -``` -CoqIDE sends the following settings (defaults in parentheses): -``` -Printing Width : (60), -Printing Coercions : (), -Printing Matching : (...true...) -Printing Notations : (...true...) -Printing Existential Instances : (...false...) -Printing Implicit : (...false...) -Printing All : (...false...) -Printing Universes : (...false...) -``` -#### *Returns* -* -```html - -``` - -------------------------------- - - -### **MkCases(...)** -```html -... -``` -#### *Returns* -* -```html - - - ${string1}... - ... - - -``` - -------------------------------- - - -### **StopWorker(worker: string)** -```html -${worker} -``` -#### *Returns* -* -```html - -``` - -------------------------------- - - -### **PrintAst(stateId: integer)** -```html - -``` -#### *Returns* -* -```html - - - - - - - - ... - ${token} - ... - - ... - - - ... - - -``` - -------------------------------- - - - -### **Annotate(annotation: string)** -```html -${annotation} -``` -#### *Returns* -* - -take `Theorem plus_0_r : forall n : nat, n + 0 = n.` as an example. - -```html - - - - Theorem -  plus_0_r :  - - forall -  n :  - nat - ,  - - - - - n - -  + -   - - 0 - - - -  = -   - - n - - - - - . - - -``` - -------------------------------- - -## Feedback messages - -Feedback messages are issued out-of-band, - giving updates on the current state of sentences/stateIds, - worker-thread status, etc. - -In the descriptions of feedback syntax below, wherever a `state_id` -tag may occur, there may instead be an `edit_id` tag. - -* Added Axiom: in response to `Axiom`, `admit`, `Admitted`, etc. -```html - - - - -``` -* Processing -```html - - - - ${workerName} - - -``` -* Processed -```html - - - - - -``` -* Incomplete -```html - - - - -``` -* Complete -* GlobRef -* Error. Issued, for example, when a processed tactic has failed or is unknown. -The error offsets may both be 0 if there is no particular syntax involved. -* InProgress -```html - - - - 1 - - -``` -* WorkerStatus -Ex: `workername = "proofworker:0"` -Ex: `status = "Idle"` or `status = "proof: myLemmaName"` or `status = "Dead"` -```html - - - - - ${workerName} - ${status} - - - -``` -* File Dependencies. Typically in response to a `Require`. Dependencies are *.vo files. - - State `stateId` directly depends on `dependency`: - ```html - - - - - - ``` - - State `stateId` depends on `dependency` via dependency `sourceDependency` - ```xml - - - - - ${dependency} - - - ``` -* File Loaded. For state `stateId`, module `module` is being loaded from `voFileName` -```xml - - - - ${module} - ${voFileName`} - - -``` - -* Message. `level` is one of `{info,warning,notice,error,debug}`. For example, in response to an add `"Axiom foo: nat."` with `verbose=true`, message `foo is assumed` will be emitted in response. -```xml - - - - - - ${message} - - - -``` - -* Custom. A feedback message that Coq plugins can use to return structured results, including results from Ltac profiling. Optionally, `startPos` and `stopPos` define a range of offsets in the document that the message refers to; otherwise, they will be 0. `customTag` is intended as a unique string that identifies what kind of payload is contained in `customXML`. -```xml - - - - - ${customTag} - ${customXML} - - -``` - +#Coq XML Protocol for Coq 8.6# + +This document is based on documentation originally written by CJ Bell +for his [vscoq](https://github.com/siegebell/vscoq/) project. + +Here, the aim is to provide a "hands on" description of the XML +protocol that coqtop and IDEs use to communicate. The protocol first appeared +with Coq 8.5, and is used by CoqIDE. It will also be used in upcoming +versions of Proof General. + +A somewhat out-of-date description of the async state machine is +[documented here](https://github.com/ejgallego/jscoq/blob/master/etc/notes/coq-notes.md). +OCaml types for the protocol can be found in the [`ide/interface.mli` file](/ide/interface.mli). + +# CHANGES +## Changes from 8.5: + * In several places, flat text wrapped in tags now appears as structured text inside tags + * The "errormsg" feedback has been replaced by a "message" feedback which contains + tag, with a message_level attribute of "error" + +* [Commands](#commands) + - [About](#command-about) + - [Add](#command-add) + - [EditAt](#command-editAt) + - [Init](#command-init) + - [Goal](#command-goal) + - [Status](#command-status) + - [Query](#command-query) + - [Evars](#command-evars) + - [Hints](#command-hints) + - [Search](#command-search) + - [GetOptions](#command-getoptions) + - [SetOptions](#command-setoptions) + - [MkCases](#command-mkcases) + - [StopWorker](#command-stopworker) + - [PrintAst](#command-printast) + - [Annotate](#command-annotate) +* [Feedback messages](#feedback) + - [Added Axiom](#feedback-addedaxiom) + - [Processing](#feedback-processing) + - [Processed](#feedback-processed) + - [Incomplete](#feedback-incomplete) + - [Complete](#feedback-complete) + - [GlobRef](#feedback-globref) + - [Error](#feedback-error) + - [InProgress](#feedback-inprogress) + - [WorkerStatus](#feedback-workerstatus) + - [File Dependencies](#feedback-filedependencies) + - [File Loaded](#feedback-fileloaded) + - [Message](#feedback-message) + - [Custom](#feedback-custom) + +Sentences: each command sent to Coqtop is a "sentence"; they are typically terminated by ".\s" (followed by whitespace or EOF). +Examples: "Lemma a: True.", "(* asdf *) Qed.", "auto; reflexivity." +In practice, the command sentences sent to Coqtop are terminated at the "." and start with any previous whitespace. +Each sentence is assigned a unique stateId after being sent to Coq (via Add). +States: + * Processing: has been received by Coq and has no obvious syntax error (that would prevent future parsing) + * Processed: + * InProgress: + * Incomplete: the validity of the sentence cannot be checked due to a prior error + * Complete: + * Error: the sentence has an error + +State ID 0 is reserved as a 'dummy' state. + +-------------------------- + +## Commands + +### **About(unit)** +Returns information about the protocol and build dates for Coqtop. +``` + + + +``` +#### *Returns* +```html + + 8.6 + 20150913 + December 2016 + Dec 23 2016 16:16:30 + + +``` +The string fields are the Coq version, the protocol version, the release date, and the compile time of Coqtop. +The protocol version is a date in YYYYMMDD format, where "20150913" corresponds to Coq 8.6. An IDE that wishes +to support multiple Coq versions can use the protocol version information to know how to handle output from Coqtop. + +### **Add(stateId: integer, command: string, verbose: boolean)** +Adds a toplevel command (e.g. vernacular, definition, tactic) to the given state. +`verbose` controls whether out-of-band messages will be generated for the added command (e.g. "foo is assumed" in response to adding "Axiom foo: nat."). +```html + + + + ${command} + ${editId} + + + + + + + +``` + +#### *Returns* +* The added command is given a fresh `stateId` and becomes the next "tip". +```html + + + + + + ${message} + + + +``` +* When closing a focused proof (in the middle of a bunch of interpreted commands), +the `Qed` will be assigned a prior `stateId` and `nextStateId` will be the id of an already-interpreted +state that should become the next tip. +```html + + + + + + ${message} + + + +``` +* Failure: + - Syntax error. Error offsets are byte offsets (not character offsets) with respect to the start of the sentence, starting at 0. + ```html + + + ${errorMessage} + + ``` + - Another kind of error, for example, Qed with a pending goal. + ```html + ${errorMessage} + ``` + +------------------------------- + +### **EditAt(stateId: integer)** +Moves current tip to `${stateId}`, such that commands may be added to the new state ID. +```html + +``` +#### *Returns* +* Simple backtrack; focused stateId becomes the parent state +```html + + + +``` + +* New focus; focusedQedStateId is the closing Qed of the new focus; senteneces between the two should be cleared +```html + + + + + + + + + + + +``` +* Failure: If `stateId` is in an error-state and cannot be jumped to, `errorFreeStateId` is the parent state of ``stateId` that shopuld be edited instead. +```html + + + ${errorMessage} + +``` + +------------------------------- + +### **Init()** +* No options. +```html + +``` +* With options. Looking at + [ide_slave.ml](https://github.com/coq/coq/blob/c5d0aa889fa80404f6c291000938e443d6200e5b/ide/ide_slave.ml#L355), + it seems that `options` is just the name of a script file, whose path + is added via `Add LoadPath` to the initial state. +```html + + + +``` +Providing the script file enables Coq to use .aux files created during +compilation. Those file contain timing information that allow Coq to +choose smartly between asynchronous and synchronous processing of +proofs. + +#### *Returns* +* The initial stateId (not associated with a sentence) +```html + + + +``` + +------------------------------- + + +### **Goal()** +```html + +``` +#### *Returns* +* 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/coq/coq/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. +```html + + + +``` + +For example, this script: +```coq +Goal P -> (1=1/\2=2) /\ (3=3 /\ (4=4 /\ 5=5) /\ 6=6) /\ 7=7. +intros. +split; split. (* current visible goals are [1=1, 2=2, 3=3/\(4=4/\5=5)/\6=6, 7=7] *) +Focus 3. (* focus on 3=3/\(4=4/\5=5)/\6=6; bg-before: [1=1, 2=2], bg-after: [7=7] *) +split; [ | split ]. (* current visible goals are [3=3, 4=4/\5=5, 6=6] *) +Focus 2. (* focus on 4=4/\5=5; bg-before: [3=3], bg-after: [6=6] *) +* (* focus again on 4=4/\5=5; bg-before: [], bg-after: [] *) +split. (* current visible goals are [4=4,5=5] *) +``` +should generate the following goals structure: +``` +goals: [ P|-4=4, P|-5=5 ] +background: +[ + ( [], [] ), (* bullet with one goal has no before or after background goals *) + ( [ P|-3=3 ], [ P|-6=6 ] ), (* Focus 2 *) + ( [ P|-2=2, P|-1=1 ], [ P|-7=7 ] ) (* Focus 3; notice that 1=1 and 2=2 are reversed *) +] +``` +Pseudocode for listing all of the goals in order: `rev (flat_map fst background) ++ goals ++ flat_map snd background`. + +* No goal: +```html + +``` + +------------------------------- + + +### **Status(force: bool)** +CoqIDE typically sets `force` to `false`. +```html + +``` +#### *Returns* +* +```html + + ${path} + ${proofName} + ${allProofs} + ${proofNumber} + +``` + +------------------------------- + + +### **Query(query: string, stateId: integer)** +In practice, `stateId` is 0, but the effect is to perform the query on the currently-focused state. +```html + + + ${query} + + + +``` +#### *Returns* +* +```html + + ${message} + +``` +------------------------------- + + + +### **Evars()** +```html + +``` +#### *Returns* +* +```html + + + +``` + +------------------------------- + + +### **Hints()** +```html + +``` +#### *Returns* +* +```html + + + +``` + +------------------------------- + + +### **Search([(constraintTypeN: string, constraintValueN: string, positiveConstraintN: boolean)])** +Searches for objects that satisfy a list of constraints. If `${positiveConstraint}` is `false`, then the constraint is inverted. +```html + + + + + ${constraintValue1} + + + + ... + + + + bool_rect + + + + + +``` +#### *Returns* +* +```html + + + + + ${metaInfo} + ... + + + ${name} + + ${definition} + + ... + + +``` +##### Types of constraints: +* Name pattern: `${constraintType} = "name_pattern"`; `${constraintValue}` is a regular expression string. +* Type pattern: `${constraintType} = "type_pattern"`; `${constraintValue}` is a pattern (???: an open gallina term) string. +* SubType pattern: `${constraintType} = "subtype_pattern"`; `${constraintValue}` is a pattern (???: an open gallina term) string. +* In module: `${constraintType} = "in_module"`; `${constraintValue}` is a list of strings specifying the module/directory structure. +* Include blacklist: `${constraintType} = "include_blacklist"`; `${constraintValue}` *is ommitted*. + +------------------------------- + + +### **GetOptions()** +```html + +``` +#### *Returns* +* +```html + + + + ${string1}... + + ${sync} + ${deprecated} + ${name} + ${option_value} + + + ... + + +``` + +------------------------------- + + +### **SetOptions(options)** +Sends a list of option settings, where each setting roughly looks like: +`([optionNamePart1, ..., optionNamePartN], value)`. +```html + + + + + optionNamePart1 + ... + optionNamePartN + + + + + + ... + + + + Printing + Width + + + + + + + +``` +CoqIDE sends the following settings (defaults in parentheses): +``` +Printing Width : (60), +Printing Coercions : (), +Printing Matching : (...true...) +Printing Notations : (...true...) +Printing Existential Instances : (...false...) +Printing Implicit : (...false...) +Printing All : (...false...) +Printing Universes : (...false...) +``` +#### *Returns* +* +```html + +``` + +------------------------------- + + +### **MkCases(...)** +```html +... +``` +#### *Returns* +* +```html + + + ${string1}... + ... + + +``` + +------------------------------- + + +### **StopWorker(worker: string)** +```html +${worker} +``` +#### *Returns* +* +```html + +``` + +------------------------------- + + +### **PrintAst(stateId: integer)** +```html + +``` +#### *Returns* +* +```html + + + + + + + + ... + ${token} + ... + + ... + + + ... + + +``` + +------------------------------- + + + +### **Annotate(annotation: string)** +```html +${annotation} +``` +#### *Returns* +* + +take `Theorem plus_0_r : forall n : nat, n + 0 = n.` as an example. + +```html + + + + Theorem +  plus_0_r :  + + forall +  n :  + nat + ,  + + + + + n + +  + +   + + 0 + + + +  = +   + + n + + + + + . + + +``` + +------------------------------- + +## Feedback messages + +Feedback messages are issued out-of-band, + giving updates on the current state of sentences/stateIds, + worker-thread status, etc. + +In the descriptions of feedback syntax below, wherever a `state_id` +tag may occur, there may instead be an `edit_id` tag. + +* Added Axiom: in response to `Axiom`, `admit`, `Admitted`, etc. +```html + + + + +``` +* Processing +```html + + + + ${workerName} + + +``` +* Processed +```html + + + + + +``` +* Incomplete +```html + + + + +``` +* Complete +* GlobRef +* Error. Issued, for example, when a processed tactic has failed or is unknown. +The error offsets may both be 0 if there is no particular syntax involved. +* InProgress +```html + + + + 1 + + +``` +* WorkerStatus +Ex: `workername = "proofworker:0"` +Ex: `status = "Idle"` or `status = "proof: myLemmaName"` or `status = "Dead"` +```html + + + + + ${workerName} + ${status} + + + +``` +* File Dependencies. Typically in response to a `Require`. Dependencies are *.vo files. + - State `stateId` directly depends on `dependency`: + ```html + + + + + + ``` + - State `stateId` depends on `dependency` via dependency `sourceDependency` + ```xml + + + + + ${dependency} + + + ``` +* File Loaded. For state `stateId`, module `module` is being loaded from `voFileName` +```xml + + + + ${module} + ${voFileName`} + + +``` + +* Message. `level` is one of `{info,warning,notice,error,debug}`. For example, in response to an add `"Axiom foo: nat."` with `verbose=true`, message `foo is assumed` will be emitted in response. +```xml + + + + + + ${message} + + + +``` + +* Custom. A feedback message that Coq plugins can use to return structured results, including results from Ltac profiling. Optionally, `startPos` and `stopPos` define a range of offsets in the document that the message refers to; otherwise, they will be 0. `customTag` is intended as a unique string that identifies what kind of payload is contained in `customXML`. +```xml + + + + + ${customTag} + ${customXML} + + +``` + -- cgit v1.2.3