# HG changeset patch # User wenzelm # Date 1521725252 -3600 # Node ID 7dc2046237708447c3bce706eed04487fc85e99a # Parent d13b2dd20f5ef7c658d5f75b0fb7870968ff0369 misc tuning and clarification; diff -r d13b2dd20f5e -r 7dc204623770 src/Doc/System/Server.thy --- a/src/Doc/System/Server.thy Wed Mar 21 21:50:28 2018 +0100 +++ b/src/Doc/System/Server.thy Thu Mar 22 14:27:32 2018 +0100 @@ -76,28 +76,29 @@ \<^medskip> Option \<^verbatim>\-c\ connects the console in/out channels after the initial check - for a suitable server process. Note that the @{tool client} tool - (\secref{sec:tool-client}) provides a more convenient way to do this - interactively, together with command-line editor support. - - \<^medskip> - Option \<^verbatim>\-l\ lists all active server processes with their connection - details. - - \<^medskip> - Option \<^verbatim>\-x\ exits the specified server process by sending it a \<^verbatim>\shutdown\ - command. + for a suitable server process. Also note that the @{tool client} tool + (\secref{sec:tool-client}) provides a command-line editor to interact with + the server. \<^medskip> Option \<^verbatim>\-L\ specifies a log file for exceptional output of internal server and session operations. + + \<^medskip> + Operation \<^verbatim>\-l\ lists all active server processes with their connection + details. + + \<^medskip> + Operation \<^verbatim>\-x\ exits the specified server process by sending it a + \<^verbatim>\shutdown\ command. \ subsection \Client \label{sec:tool-client}\ text \ - The @{tool_def client} provides console interaction for Isabelle servers: + The @{tool_def client} tool provides console interaction for Isabelle + servers: @{verbatim [display] \Usage: isabelle client [OPTIONS] @@ -107,8 +108,8 @@ Console interaction for Isabelle server (with line-editor).\} - This is a convenient wrapper to \<^verbatim>\isabelle server -s -c\ for interactive - experimentation, wrapped into @{setting ISABELLE_LINE_EDITOR} if available. + This is a wrapper to \<^verbatim>\isabelle server -s -c\ for interactive + experimentation, which uses @{setting ISABELLE_LINE_EDITOR} if available. The server name is sufficient for identification, as the client can determine the connection details from the local database of active servers. @@ -126,10 +127,9 @@ Ensure that a particular server instance is running in the background: @{verbatim [display] \isabelle server -n test &\} - Here the first line of output presents the connection details:\<^footnote>\This - information may be used in an independent TCP client, while the - Isabelle/Scala tool merely needs the server name to access the database of - servers.\ + The first line of output presents the connection details:\<^footnote>\This information + may be used in other TCP clients, without access to Isabelle/Scala and the + underlying database of running servers.\ @{verbatim [display] \server "test" = 127.0.0.1:4711 (password "XYZ")\} \<^medskip> @@ -152,7 +152,7 @@ possible to reconnect again, and have multiple connections at the same time. \<^medskip> - Finally, exit the named server on the command-line: + Exit the named server on the command-line: @{verbatim [display] \isabelle server -n test -x\} \ @@ -161,12 +161,12 @@ text \ The Isabelle server listens on a regular TCP socket, using a line-oriented - protocol of structured messages: input \<^emph>\commands\ and output \<^emph>\results\ + protocol of structured messages. Input \<^emph>\commands\ and output \<^emph>\results\ (via \<^verbatim>\OK\ or \<^verbatim>\ERROR\) are strictly alternating on the toplevel, but commands may also return a \<^emph>\task\ identifier to indicate an ongoing asynchronous process that is joined later (via \<^verbatim>\FINISHED\ or \<^verbatim>\FAILED\). Asynchronous \<^verbatim>\NOTE\ messages may occur at any time: they are independent of - the main command-reply protocol. + the main command-result protocol. For example, the synchronous \<^verbatim>\echo\ command immediately returns its argument as \<^verbatim>\OK\ result. In contrast, the asynchronous \<^verbatim>\session_build\ @@ -176,7 +176,7 @@ may emit asynchronous messages of the form \<^verbatim>\NOTE {"task":\\id\\<^verbatim>\,\\\\\<^verbatim>\}\ to inform about its progress. Due to the explicit task identifier, the client can show these messages in the proper context, e.g.\ a GUI window for - the session build job. + this particular session build job. \medskip Subsequently, the protocol message formats are described in further detail. @@ -191,22 +191,22 @@ particular length. Messages are written as a single chunk that is flushed immediately. - The message boundary is determined as follows: + Message boundaries are determined as follows: \<^item> A \<^emph>\short message\ consists of a single line: it is a sequence of arbitrary bytes excluding CR (13) and LF (10), and terminated by CR-LF or just LF. - \<^item> A \<^emph>\long message\ starts with a single line as above, which consists - only of decimal digits: that is interpreted as length of the subsequent - block of arbitrary bytes. A final line-terminator may be included here, + \<^item> A \<^emph>\long message\ starts with a single that consists only of decimal + digits: these are interpreted as length of the subsequent block of + arbitrary bytes. A final line-terminator (as above) may be included here, but is not required. Messages in JSON format (see below) always fit on a single line, due to escaping of newline characters within string literals. This is convenient for interactive experimentation, but it can impact performance for very long messages. If the message byte-length is given on the preceding line, the - server can read the message efficiently as a single block. + server can read the message more efficiently as a single block. \ @@ -232,13 +232,13 @@ \<^item> \name argument\ such that: \<^item> \name\ is the longest prefix consisting of ASCII letters, digits, - ``\<^verbatim>\_\'' (underscore), or ``\<^verbatim>\.\'' (dot), + ``\<^verbatim>\_\'', ``\<^verbatim>\.\'', \<^item> the separator between \name\ and \argument\ is the longest possible sequence of ASCII blanks (it could be empty, e.g.\ when the argument starts with a quote or bracket), - \<^item> \argument\ is the rest of the message without the line terminator. + \<^item> \argument\ is the rest of the message without line terminator. \<^medskip> Input messages are sent from the client to the server. Here the \name\ @@ -283,7 +283,8 @@ Whenever a new client opens the server socket, the initial message needs to be its unique password. The server replies either with \<^verbatim>\OK\ (and some information about the Isabelle version) or by silent disconnection of what - is considered an illegal connection attempt. + is considered an illegal connection attempt. Note that @{tool client} + already presents the correct password internally. Server passwords are created as Universally Unique Identifier (UUID) in Isabelle/Scala and stored in a per-user database, with restricted @@ -301,7 +302,7 @@ Isabelle/Scala, with single argument and result (regular or error). Both the argument and the result may consist of type \<^verbatim>\Unit\, \<^verbatim>\XML.Elem\, \<^verbatim>\JSON.T\. An error result typically consists of a JSON object with error message and - potentially further fields (this resembles exceptions in Scala). + potentially further result fields (this resembles exceptions in Scala). These are the protocol exchanges for both cases of command execution: \begin{center} @@ -318,11 +319,11 @@ text \ An \<^emph>\asynchronous command\ corresponds to an ongoing process that finishes - or fails eventually, while emitting arbitrary notifications intermediately. - Formally, it starts as synchronous command with immediate result \<^verbatim>\OK\ and - the \<^verbatim>\task\ identifier, or an immediate \<^verbatim>\ERROR\ that indicates bad command - syntax. For a running task, the termination is indicated later by - \<^verbatim>\FINISHED\ or \<^verbatim>\FAILED\, together with its ultimate result. + or fails eventually, while emitting arbitrary notifications in between. + Formally, it starts as synchronous command with immediate result \<^verbatim>\OK\ + giving the \<^verbatim>\task\ identifier, or an immediate \<^verbatim>\ERROR\ that indicates bad + command syntax. For a running task, the termination is indicated later by + \<^verbatim>\FINISHED\ or \<^verbatim>\FAILED\, together with its ultimate result value. These are the protocol exchanges for various cases of command task execution: @@ -332,7 +333,6 @@ \<^bold>\input:\ & \command argument\ \\ immediate \<^bold>\output:\ & \<^verbatim>\OK {"task":\\id\\<^verbatim>\}\ \\ intermediate \<^bold>\output:\ & \<^verbatim>\NOTE {"task":\\id\\<^verbatim>\,\\\\\<^verbatim>\}\ \\ - intermediate \<^bold>\output:\ & \<^verbatim>\NOTE {"task":\\id\\<^verbatim>\,\\\\\<^verbatim>\}\ \\ (a) regular \<^bold>\output:\ & \<^verbatim>\FINISHED {"task":\\id\\<^verbatim>\,\\\\\<^verbatim>\}\ \\ (b) error \<^bold>\output:\ & \<^verbatim>\FAILED {"task":\\id\\<^verbatim>\,\\\\\<^verbatim>\}\ \\[3ex] \<^bold>\input:\ & \command argument\ \\ @@ -341,34 +341,18 @@ \end{center} All asynchronous messages are decorated with the task identifier that was - revealed in the immediate (synchronous) result. Thus it is possible to emit - further asynchronous commands and dispatch the mingled stream of + revealed in the immediate (synchronous) result. Thus the client can + invoke further asynchronous commands and still dispatch the resulting stream of asynchronous messages properly. The synchronous command \<^verbatim>\cancel\~\id\ tells the specified task to terminate prematurely: usually causing a \<^verbatim>\FAILED\ result, but this is not guaranteed: - the cancel event may come too late or the task may just ignore it. + the cancel event may come too late or the running process may just ignore + it. \ -section \Server commands and results\ - -text \ - Here follows an overview of particular Isabelle server commands with their - results, which are usually represented as JSON values. The general format of - input and output messages is described in - \secref{sec:input-output-messages}. The relevant Isabelle/Scala source files - are: - - \<^medskip> - \begin{tabular}{l} - \<^file>\$ISABELLE_HOME/src/Pure/Tools/server_commands.scala\ \\ - \<^file>\$ISABELLE_HOME/src/Pure/Tools/server.scala\ - \end{tabular} -\ - - -subsection \Types for JSON values\ +section \Types for JSON values \label{sec:json-types}\ text \ In order to specify concrete JSON types for command arguments and result @@ -381,24 +365,25 @@ 'bool' | 'int' | 'long' | 'double' | 'string' | '[' @{syntax type} ']' | '{' (@{syntax field_type} ',' *) '}' | @{syntax type} '\' @{syntax type} | - @{syntax type} '|' @{syntax type} + @{syntax type} '|' @{syntax type} | + '(' @{syntax type} ')' ; @{syntax field_type}: @{syntax name} ('?'?) ':' @{syntax type} \ - This is a simplified version of interfaces in - TypeScript.\<^footnote>\\<^url>\https://www.typescriptlang.org/docs/handbook/interfaces.html\\ - The meaning of these types is specified wrt. the implementation in - Isabelle/Scala as follows. + This is a simplified variation of TypeScript + interfaces.\<^footnote>\\<^url>\https://www.typescriptlang.org/docs/handbook/interfaces.html\\ + The meaning of these types is specified wrt. the Isabelle/Scala + implementation as follows. \<^item> A \name\ refers to a type defined elsewhere. The environment of type definitions is given informally: put into proper foundational order, it - needs to specify a strongly normalizing system; type definitions may not be - recursive. + needs to specify a strongly normalizing system of syntactic abbreviations; + type definitions may not be recursive. \<^item> A \value\ in JSON notation represents the singleton type of the given - item. For example, the string \<^verbatim>\"error"\ can be used is the type for a slot - that is guaranteed to contain that constant. + item. For example, the string \<^verbatim>\"error"\ can be used as type for a slot that + is guaranteed to contain that constant. \<^item> Type \any\ is the super type of all other types: it is an untyped slot in the specification and corresponds to \<^verbatim>\Any\ or \<^verbatim>\JSON.T\ in Isabelle/Scala. @@ -408,7 +393,7 @@ ``Null References: The Billion Dollar Mistake'' by Tony Hoare \<^url>\https://www.infoq.com/presentations/Null-References-The-Billion-Dollar-Mistake-Tony-Hoare\.\ - \<^item> Type \bool\ is the type of the truth values \true\ and \false\; it + \<^item> Type \bool\ is the type of the truth values \<^verbatim>\true\ and \<^verbatim>\false\; it corresponds to \<^verbatim>\Boolean\ in Scala. \<^item> Types \int\, \long\, \double\ are specific versions of the generic @@ -422,18 +407,18 @@ \<^item> Type \[t]\ is the array (or list) type over \t\; it corresponds to \<^verbatim>\List[t]\ in Scala. The list type is co-variant as usual (i.e.\ monotonic - wrt. the subtype order). + wrt. the subtype relation). \<^item> Object types describe the possible content of JSON records, with field names and types. A question mark after a field name means that it is - optional: in Scala this could refer to an explicit type \<^verbatim>\Option[t]\. For - example, \{a: int, b?: string}\ corresponds to a Scala case class with - arguments \<^verbatim>\a: Int\, \<^verbatim>\b: Option[String]\. + optional. In Scala this could refer to an explicit type \<^verbatim>\Option[t]\, e.g.\ + \{a: int, b?: string}\ corresponding to a Scala case class with arguments + \<^verbatim>\a: Int\, \<^verbatim>\b: Option[String]\. Alternatively, optional fields can have a default value. If nothing else is - specified, the standard default value is the ``empty'' value of a type, - i.e.\ \<^verbatim>\0\ for the number types, \<^verbatim>\false\ for \bool\, or the empty string, - array, object etc. + specified, a standard ``empty value'' is used for each type, i.e.\ \<^verbatim>\0\ for + the number types, \<^verbatim>\false\ for \bool\, or the empty string, array, object + etc. Object types are \<^emph>\permissive\ in the sense that only the specified field names need to conform to the given types, but unspecified fields may be @@ -447,18 +432,20 @@ \<^item> The type expression \t\<^sub>1 | t\<^sub>2\ is the disjoint union of two types, either one of the two cases may occur. + \<^item> Parentheses \(t)\ merely group type expressions syntactically. + These types correspond to JSON values in an obvious manner, which is not further described here. For example, the JSON array \<^verbatim>\[1, 2, 3]\ conforms to types \[int]\, \[long]\, \[double]\, \[any]\, \any\. Note that JSON objects require field names to be quoted, but the type - language omits quotes for clarity. Thus \<^verbatim>\{"a": 42, "b": "xyz"}\ conforms to - the type \{a: int, b: string}\, for example. + language omits quotes for clarity. Thus the object \<^verbatim>\{"a": 42, "b": "xyz"}\ + conforms to the type \{a: int, b: string}\, for example. \<^medskip> - The absence of an argument or result is represented by type \<^verbatim>\Unit\ in - Isabelle/Scala: it is written as empty text in the message \argument\ + The absence of an argument or result is represented by the Scala type + \<^verbatim>\Unit\: it is written as empty text in the message \argument\ (\secref{sec:input-output-messages}). This is not part of the JSON language. Server replies have name tags like \<^verbatim>\OK\, \<^verbatim>\ERROR\: these are used literally @@ -467,16 +454,17 @@ list (JSON array) of strings. \<^bigskip> - Here are some common type definitions, for use in the subsequent - specifications of command arguments and results. + Here are some common type definitions, for use in particular specifications + of command arguments and results. \<^item> \<^bold>\type\~\position = {line?: int, offset?: int, end_offset?: int, file?: - string, id?: long}\ describes a source position within Isabelle source text. - Only the \line\ and \file\ fields make immediate sense to external programs. + string, id?: long}\ describes a source position within Isabelle text. Only + the \line\ and \file\ fields make immediate sense to external programs. Detailed \offset\ and \end_offset\ positions are counted according to Isabelle symbols, see @{ML_type Symbol.symbol} in Isabelle/ML @{cite - "isabelle-implementation"}. The position \id\ belongs to the internal - representation of command transactions in the Isabelle/PIDE protocol. + "isabelle-implementation"}. The position \id\ belongs to the representation + of command transactions in the Isabelle/PIDE protocol: it normally does not + occur in externalized positions. \<^item> \<^bold>\type\~\message = {kind?: string, message: string, pos?: position}\ where the \kind\ provides some hint about the role and importance of the message. @@ -492,9 +480,9 @@ \<^item> \<^bold>\type\~\theory_progress = {kind:\~\<^verbatim>\"writeln"\\, message: string, theory: string, session: string}\ reports formal progress in loading theories (e.g.\ when building a session image). Apart from a regular output message, it also - reveals the formal theory name (e.g.\ \<^verbatim>\HOL.Nat\) and session name (e.g.\ - \<^verbatim>\HOL\). Note that some rare theory names lack a proper session prefix, e.g. - theory \<^verbatim>\Main\ in session \<^verbatim>\HOL\. + reveals the formal theory name (e.g.\ \<^verbatim>\"HOL.Nat"\) and session name (e.g.\ + \<^verbatim>\"HOL"\). Note that some rare theory names lack a proper session prefix, + e.g. theory \<^verbatim>\"Main"\ in session \<^verbatim>\"HOL"\. \<^item> \<^bold>\type\~\timing = {elapsed: double, cpu: double, gc: double}\ refers to common Isabelle timing information in seconds, usually with a precision of @@ -506,7 +494,7 @@ identifiers are created as private random numbers of the server and only revealed to the client that creates a certain resource (e.g.\ task or session). A client may disclose this information for use in a different - client connection: e.g.\ this allows to share sessions between multiple + client connection: this allows to share sessions between multiple connections. Client commands need to provide syntactically wellformed UUIDs: this is @@ -515,8 +503,34 @@ \<^item> \<^bold>\type\~\task = {task: uuid}\ identifies a newly created asynchronous task and thus allows the client to control it by the \<^verbatim>\cancel\ command. The same - task identification is included in messages and the final result produced by - this task. + task identification is included in all messages produced by this task. + + \<^item> \<^bold>\type\ \node_status = {ok: bool, total: int, unprocessed: int, running: + int, warned: int, failed: int, finished: int, consolidated: bool}\ + represents a formal theory node status of the PIDE document model. Fields + \total\, \unprocessed\, \running\, \warned\, \failed\, \finished\ account + for individual commands within a theory node; \ok\ is an abstraction for + \failed = 0\. The \consolidated\ flag indicates whether the outermost theory + command structure has finished (or failed) and the final \<^theory_text>\end\ command has + been checked. +\ + + +section \Server commands and results\ + +text \ + Here follows an overview of particular Isabelle server commands with their + results, which are usually represented as JSON values with types according + to \secref{sec:json-types}. The general format of input and output messages + is described in \secref{sec:input-output-messages}. The relevant + Isabelle/Scala source files are: + + \<^medskip> + \begin{tabular}{l} + \<^file>\$ISABELLE_HOME/src/Pure/Tools/server_commands.scala\ \\ + \<^file>\$ISABELLE_HOME/src/Pure/Tools/server.scala\ \\ + \<^file>\$ISABELLE_HOME/src/Pure/General/json.scala\ \\ + \end{tabular} \ @@ -528,9 +542,9 @@ \end{tabular} \<^medskip> - The \<^verbatim>\help\ command has no argument and returns the list of command names - known to the server. This is occasionally useful for interactive - experimentation (see also @{tool client} in \secref{sec:tool-client}). + The \<^verbatim>\help\ command has no argument and returns the list of server command + names. This is occasionally useful for interactive experimentation (see also + @{tool client} in \secref{sec:tool-client}). \ @@ -547,8 +561,8 @@ regular result. This is occasionally useful for testing and interactive experimentation (see also @{tool client} in \secref{sec:tool-client}). - The type of \<^verbatim>\echo\ is actually more general than given above: \<^verbatim>\Unit\, - \<^verbatim>\XML.Elem\, \<^verbatim>\JSON.T\ are supported uniformly. Note that \<^verbatim>\XML.Elem\ might + The Scala type of \<^verbatim>\echo\ is actually more general than given above: + \<^verbatim>\Unit\, \<^verbatim>\XML.Elem\, \<^verbatim>\JSON.T\ work uniformly. Note that \<^verbatim>\XML.Elem\ might be difficult to type on the console in its YXML syntax (\secref{sec:yxml-vs-xml}). \ @@ -568,9 +582,8 @@ connections! \<^medskip> - Likewise, the command-line invocation \<^verbatim>\isabelle server -x\ opens a server - connection and issues a \<^verbatim>\shutdown\ command (see also - \secref{sec:tool-server}). + The command-line invocation \<^verbatim>\isabelle server -x\ opens a server connection + and issues a \<^verbatim>\shutdown\ command (see also \secref{sec:tool-server}). \ @@ -583,17 +596,17 @@ \end{tabular} \<^medskip> - The command invocation \<^verbatim>\cancel "\\id\\<^verbatim>\"\ attempts to cancel the specified - task. + The command invocation \<^verbatim>\cancel "\\uuid\\<^verbatim>\"\ attempts to cancel the + specified task. Cancellation is merely a hint that the client prefers an ongoing process to be stopped. The command always succeeds formally, but it may get ignored by - a task that is still running, or it might refer to a non-existing or - no-longer existing task without producing an error. + a task that is still running; it might also refer to a non-existing or + no-longer existing task (without producing an error). Successful cancellation typically leads to an asynchronous failure of type - \<^verbatim>\FAILED {\\task: string, message: \\<^verbatim>\"Interrupt"}\ --- or a slightly - different message, depending how the task handles the event. + \<^verbatim>\FAILED {\\task: uuid, message:\~\<^verbatim>\"Interrupt"}\. A different message is + also possible, depending how the task handles the event. \ @@ -621,43 +634,45 @@ \quad~~\system_mode?: bool,\ \\ \quad~~\verbose?: bool}\ \\[2ex] - \<^bold>\type\ \session_build_results =\ \\ - \quad\{ok: bool,\ \\ - \quad~~\return_code: int,\ \\ - \quad~~\sessions: [session_build_result]}\ \\[2ex] - \<^bold>\type\ \session_build_result =\ \\ \quad\{session: string,\ \\ \quad~~\ok: bool,\ \\ \quad~~\return_code: int,\ \\ \quad~~\timeout: bool,\ \\ - \quad~~\timing: timing}\ \\ + \quad~~\timing: timing}\ \\[2ex] + + \<^bold>\type\ \session_build_results =\ \\ + \quad\{ok: bool,\ \\ + \quad~~\return_code: int,\ \\ + \quad~~\sessions: [session_build_result]}\ \\ \end{tabular} \ text \ - The \<^verbatim>\session_build\ command prepares given a session image for interactive - use of theories. This is a limited version of command-line tool @{tool - build} (\secref{sec:tool-build}), with specific options to request a formal - context of an interactive session: it also resembles options of @{tool - jedit} @{cite "isabelle-jedit"}. + The \<^verbatim>\session_build\ command prepares a session image for interactive use of + theories. This is a limited version of command-line tool @{tool build} + (\secref{sec:tool-build}), with specific options to request a formal context + for an interactive PIDE session. The build process is asynchronous, with notifications that inform about the - progress of loaded theories. Some further human-readable messages may be - output as well. + progress of loaded theories. Some further informative messages are output as + well. Coordination of independent build processes is at the discretion of the - client: as for like @{tool build} there are no built-in measures against - conflicting builds with overlapping hierarchies of session images. + client (or end-user), just as for @{tool build} and @{tool jedit}. There is + no built-in coordination of conflicting builds with overlapping hierarchies + of session images. In the worst case, a session image produced by one task + may get overwritten by another task! \ subsubsection \Arguments\ text \ - The field \session\ is mandatory. It specifies the target session name: - either directly (default) or indirectly (if \required_session\ is - \<^verbatim>\true\). + The \session\ field is mandatory. It specifies the target session name: + either directly (default) or indirectly (if \required_session\ is \<^verbatim>\true\). + The build process will produce all required ancestor images for the + specified target. \<^medskip> The environment of Isabelle system options is determined from \preferences\ @@ -671,9 +686,9 @@ operating-system contexts. \<^medskip> - The \dirs\ field specifies additional directories for session ROOT files - (\secref{sec:session-root}). This augments the name space of available - sessions; see also option \<^verbatim>\-d\ in @{tool build} or @{tool jedit}. + The \dirs\ field specifies additional directories for session ROOT and ROOTS + files (\secref{sec:session-root}). This augments the name space of available + sessions; see also option \<^verbatim>\-d\ in @{tool build}. \<^medskip> The \ancestor_session\ field specifies an alternative image as starting @@ -683,18 +698,18 @@ session images of the hierarchy that are not used later on. \<^medskip> - The \all_known\ field set to \<^verbatim>\true\ includes all existing sessions from - reachable ROOT entries in the name space of theories with a proper - session-qualified name (instead of referring to the file-system location). - This could be relevant for the \<^verbatim>\use_theories\ command + The \all_known\ field set to \<^verbatim>\true\ includes all sessions from reachable + ROOT entries into the name space of theories. This is relevant for proper + session-qualified names, instead of referring to theory file names. The + option enables the \<^verbatim>\use_theories\ command (\secref{sec:command-use-theories}) to refer to arbitrary theories from - other sessions. Note that considerable time is required to explore all - accessible session directories and theory dependencies. + other sessions, but considerable time is required to explore all accessible + session directories and theory dependencies. \<^medskip> - The \focus_session\ field set to \<^verbatim>\true\ to focuses on the target session: + The \focus_session\ field set to \<^verbatim>\true\ focuses on the target session: the accessible name space of theories is restricted to sessions that are - connected to it. + connected to it in the imports graph. \<^medskip> The \required_session\ field set to \<^verbatim>\true\ indicates that the target image @@ -703,14 +718,13 @@ the \session\ itself can be loaded. \<^medskip> - The \system_mode\ field may be set to \<^verbatim>\true\ to store session images and + The \system_mode\ field set to \<^verbatim>\true\ stores resulting session images and log files in @{path "$ISABELLE_HOME/heaps"} instead of the default location @{setting ISABELLE_OUTPUT} (which is normally in @{setting - ISABELLE_HOME_USER}, i.e.\ the user's home directory). See also option \<^verbatim>\-s\ - in @{tool build} and @{tool jedit}. + ISABELLE_HOME_USER}). See also option \<^verbatim>\-s\ in @{tool build}. \<^medskip> - The \verbose\ field may be set to \<^verbatim>\true\ for extra verbosity. The effect is + The \verbose\ field set to \<^verbatim>\true\ yields extra verbosity. The effect is similar to option \<^verbatim>\-v\ in @{tool build}. \ @@ -723,28 +737,29 @@ Isabelle/jEdit after startup @{cite "isabelle-jedit"}. For the client it is usually sufficient to print the messages in plain text, - but note that \theory_progress\ also reveals the internal \theory\ and - \session\ names. + but note that \theory_progress\ also reveals formal \theory\ and + \session\ names directly. \ subsubsection \Results\ text \ - The overall \session_build_results\ contain both a summary and and entry - \session_build_result\ for each session in the build hierarchy, leading up - to the specified target session. The result is always provided, - independently of overall success (\<^verbatim>\FINISHED\ task) or failure (\<^verbatim>\FAILED\ - task). + The overall \session_build_results\ contain both a summary and an entry + \session_build_result\ for each session in the build hierarchy. The result + is always provided, independently of overall success (\<^verbatim>\FINISHED\ task) or + failure (\<^verbatim>\FAILED\ task). The \ok\ field tells abstractly, whether all required session builds came - out as \ok\, i.e.\ \return_code\. A non-zero \return_code\ indicates an - error according to usual POSIX conventions for process exit. + out as \ok\, i.e.\ with zero \return_code\. A non-zero \return_code\ + indicates an error according to usual POSIX conventions for process exit. + + The individual \session_build_result\ entries provide extra fields: - For individual \session_build_result\ entries, there are additional fields: - \timeout\ to tell if the build process was aborted after running too long, - and \timing\ for the overall process timing in the usual Isabelle format - with elapsed, CPU, gc time. + \<^item> \timeout\ tells if the build process was aborted after running too long, + + \<^item> \timing\ gives the overall process timing in the usual Isabelle format + with elapsed, CPU, GC time. \ @@ -780,25 +795,25 @@ \<^medskip> The \<^verbatim>\session_start\ command starts a new Isabelle/PIDE session with underlying Isabelle/ML process, based on a session image that it produces on - demand in the same manner as \<^verbatim>\session_build\. Thus it accepts all - \session_build_args\ and produces similar notifications, but the detailed - \session_build_results\ are omitted. + demand using \<^verbatim>\session_build\. Thus it accepts all \session_build_args\ and + produces similar notifications, but the detailed \session_build_results\ are + omitted. The session build and startup process is asynchronous: when the task is - finished, the session remains active for commands such as \<^verbatim>\use_theories\ - (\secref{sec:command-use-theories}), until a \<^verbatim>\session_stop\ or \<^verbatim>\shutdown\ - command is sent to the server. + finished, the session remains active for commands, until a \<^verbatim>\session_stop\ + or \<^verbatim>\shutdown\ command is sent to the server. Sessions are independent of client connections: it is possible to start a session and later apply \<^verbatim>\use_theories\ on different connections, as long as - the internal session identifier is known. + the internal session identifier is known: shared theory imports will be used + only once (and persist until purged explicitly). \ subsubsection \Arguments\ text \ - Most of the arguments are the same as for \<^verbatim>\session_build\ + Most arguments are shared with \<^verbatim>\session_build\ (\secref{sec:command-session-build}). \<^medskip> @@ -826,6 +841,9 @@ text \ Start a default Isabelle/HOL session: @{verbatim [display] \session_start {"session": "HOL"}\} + + Start a session from the Archive of Formal Proofs: + @{verbatim [display] \session_start {"session": "Coinductive", "dirs": ["$AFP_BASE/thys"]}\} \ @@ -844,9 +862,9 @@ \end{tabular} \<^medskip> - The \<^verbatim>\session_stop\ command forces a shutdown of the identified - Isabelle/PIDE session. This asynchronous tasks usually finishes quickly. - Failure only happens unusual situations, according to the return code of the + The \<^verbatim>\session_stop\ command forces a shutdown of the identified PIDE + session. This asynchronous tasks usually finishes quickly. Failure only + happens in unusual situations, according to the return code of the underlying Isabelle/ML process. \ @@ -854,17 +872,19 @@ subsubsection \Arguments\ text \ - The \session_id\ field is the UUID originally created by the server for the - intended session. + The \session_id\ field provides the UUID originally created by the server + for this session. \ subsubsection \Results\ text \ - The \ok\ field tells abstractly, whether the Isabelle/ML process terminated - properly. The \return_code\ expresses this information according to usual - POSIX conventions for process exit. + The \ok\ field tells abstractly, whether the Isabelle/ML process has + terminated properly. + + The \return_code\ field expresses this information according to usual POSIX + conventions for process exit. \ @@ -888,17 +908,9 @@ \quad~~\master_dir?: string,\ \\ \quad~~\pretty_margin?: double\ & \<^bold>\default:\ \<^verbatim>\76\ \\ \quad~~\unicode_symbols?: bool}\ \\[2ex] + \end{tabular} - \<^bold>\type\ \node_status =\ \\ - \quad\{ok: bool,\ \\ - \quad~~\total: int,\ \\ - \quad~~\unprocessed: int,\ \\ - \quad~~\running: int,\ \\ - \quad~~\warned: int,\ \\ - \quad~~\failed: int,\ \\ - \quad~~\finished: int,\ \\ - \quad~~\consolidated: bool}\ \\[2ex] - + \begin{tabular}{ll} \<^bold>\type\ \node_result =\ \\ \quad\{node_name: string,\ \\ \quad~~\theory: string,\ \\ @@ -912,13 +924,17 @@ \end{tabular} \<^medskip> + The \<^verbatim>\use_theories\ command updates the identified session by adding the + current version of theory files to it, while dependencies are resolved + implicitly. The command succeeds eventually, when all theories have been + \<^emph>\consolidated\ in the sense the formal \node_status\ + (\secref{sec:json-types}): the outermost command structure has finished (or + failed) and the final \<^theory_text>\end\ command of each theory has been checked. - The \<^verbatim>\use_theories\ command updates the identified session by adding the - current version of given theory files to it: theory dependencies are - resolved implicitly. The command succeeds eventually, when all theories have - been \<^emph>\consolidated\ in the sense that the outermost command structure has - finished (or failed) and the final \<^theory_text>\end\ command of each theory has been - checked. + Already used theories persist in the session until purged explicitly. This + also means that repeated invocations of \<^verbatim>\use_theories\ are idempotent: it + could make sense to do that with different values for \pretty_margin\ or + \unicode_symbols\ to get different formatting for \errors\ or \messages\. \ @@ -929,63 +945,62 @@ was created (possibly on a different client connection). \<^medskip> - The \theories\ field specifies theory names as in \<^theory_text>\theory imports\ or in - session ROOT \<^verbatim>\theories\: an explicit source position for these theory name - specifications may be given as well, which is occasionally useful for - precise error locations. + The \theories\ field specifies theory names as in theory \<^theory_text>\imports\ or in + ROOT \<^bold>\theories\. An explicit source position for these theory name + specifications may be given, which is occasionally useful for precise error + locations. \<^medskip> The \qualifier\ field provides an alternative session qualifier for theories that are not formally recognized as a member of a particular session. The default is \<^verbatim>\Draft\ as in Isabelle/jEdit. There is rarely a need to change that, as theory nodes are already uniquely identified by their physical - file-system location. + file-system location. This already allows reuse of theory base names with + the same session qualifier --- as long as these theories are not used + together (e.g.\ in \<^theory_text>\imports\). - \<^medskip> - The \master_dir\ field explicit specifies the formal master directory of the - imported theory. Normally this is determined implicitly from the parent - directory of the physical theory file location. + \<^medskip> The \master_dir\ field explicit specifies the formal master directory of + the imported theory. Normally this is determined implicitly from the parent + directory of the theory file. \<^medskip> The \pretty_margin\ field specifies the line width for pretty-printing. The - default is for classic console output. Formatting happens at the end of - \<^verbatim>\use_theories\, when all prover messages produced are exported to the - client. + default is suitable for classic console output. Formatting happens at the + end of \<^verbatim>\use_theories\, when all prover messages are exported to the client. \<^medskip> - The \unicode_symbols\ field set to \<^verbatim>\true\ means that message output is - rendered for direct output on a Unicode capable channel, ideally with the - Isabelle fonts as in Isabelle/jEdit (or Isabelle HTML output). The default - is to keep the symbolic representation of Isabelle text, e.g.\ \<^verbatim>\\\ instead - of its rendering as \\\. This means the client needs to perform its own - rendering to present it to the end-user. + The \unicode_symbols\ field set to \<^verbatim>\true\ renders message output for direct + output on a Unicode capable channel, ideally with the Isabelle fonts as in + Isabelle/jEdit. The default is to keep the symbolic representation of + Isabelle text, e.g.\ \<^verbatim>\\\ instead of its rendering as \\\. This means the + client needs to perform its own rendering before presenting it to the + end-user. \ + subsubsection \Results\ text \ The \ok\ field indicates overall success of processing the specified theories with all their dependencies. - When \ok\ is \<^verbatim>\false\, the \errors\ field lists all errors cumulatively, - including position information for the theory nodes where the error happened - (this includes imported theories). + When \ok\ is \<^verbatim>\false\, the \errors\ field lists all errors cumulatively + (including imported theories). The messages contain position information for + the original theory nodes. \<^medskip> - The \nodes\ field provides more detailed information about each imported - theory node. Here the individual fields are as follows: + The \nodes\ field provides detailed information about each imported theory + node. The individual fields are as follows: \<^item> \node_name\: the physical name for the theory node, based on its - file-system location;\<^footnote>\Clients may recognize the originally provided - file-names after careful normalization in the file-system of the server.\ + file-system location; - \<^item> \theory\: the logical theory name, e.g.\ \<^verbatim>\HOL-Library.AList\ or - \<^verbatim>\Draft.Test\; + \<^item> \theory\: the logical theory name, e.g.\ \<^verbatim>\HOL-Library.AList\; \<^item> \status\: the overall node status, e.g.\ see the visualization in the \Theories\ panel of Isabelle/jEdit @{cite "isabelle-jedit"}; - \<^item> \messages\: the main bulk of prover messages produced in this theory note + \<^item> \messages\: the main bulk of prover messages produced in this theory (\<^verbatim>\writeln\, \<^verbatim>\warning\, \<^verbatim>\error\, etc.). \