[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

# 4. Proof Shell Settings

The variables in this chapter concern the proof shell mode, and are the largest group. They are split into several subgroups. The first subgroup are commands invoked at various points. The second subgroup of variables are concerned with matching the output from the proof assistant. The final subgroup contains various hooks which you can set to add lisp customization to Proof General in various points (some of them are also used internally for behaviour you may wish to adjust).

Variables for configuring the proof shell are put into the customize group `proof-shell`.

These should be set in the shell mode configuration, before `proof-shell-config-done` is called.

To understand the way the proof assistant runs inside Emacs, you may want to refer to the `comint.el` (Command interpreter) package distributed with Emacs. This package controls several shell-like modes available in Emacs, including the `proof-shell-mode` and all specific shell modes derived from it.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 4.1 Commands

Settings in this section configure Proof General with commands to send to the prover to activate certain actions.

Variable: proof-prog-name

  System command to run the proof assistant in the proof shell.
  May contain arguments separated by spaces, but see also ‘`proof-prog-args`’.

  Remark: if ‘`proof-prog-args`’ is non-nil, then `proof-prog-name` is considered strictly: it must contain only the program name with no option, spaces are interpreted literally as part of the program name.

Variable: proof-shell-auto-terminate-commands

  Non-nil if Proof General should try to add terminator to every command.
  If non-nil, whenever a command is sent to the prover using ‘``proof-shell-invisible-command``’, Proof General will check to see if it ends with `proof-terminal-char`, and add it if not. If `proof-terminal-char` is nil, this has no effect.

Variable: proof-shell-pre-sync-init-cmd

  The command for configuring the proof process to gain synchronization.
  This command is sent before Proof General's synchronization mechanism is engaged, to allow customization inside the process to help gain syncrhonization (e.g. engaging special markup).

  It is better to configure the proof assistant for this purpose via command line options if possible, in which case this variable does not need to be set.

  See also ‘``proof-shell-init-cmd``’.

Variable: proof-shell-init-cmd

  The command for initially configuring the proof process.
  This command is sent to the process as soon as synchronization is gained (when an annotated prompt is first recognized). It can be used to configure the proof assistant in some way, or print a welcome message (since output before the first prompt is discarded).

  See also ‘``proof-shell-pre-sync-init-cmd``’.

Variable: proof-shell-restart-cmd

  A command for re-initialising the proof process.

Variable: proof-shell-quit-cmd

  A command to quit the proof process. If nil, send EOF instead.

Variable: proof-shell-quit-timeout

  The number of seconds to wait after sending `proof-shell-quit-cmd`.
  After this timeout, the proof shell will be killed off more rudely. If your proof assistant takes a long time to clean up (for example writing persistent databases out or the like), you may need to bump up this value.

Variable: proof-shell-cd-cmd

  Command to the proof assistant to change the working directory.
  The format character ‘`%s`’ is replaced with the directory, and the escape sequences in ‘``proof-shell-filename-escapes``’ are applied to the filename.

  This setting is used to define the function `proof-cd` which changes to the value of (`default-directory`) for script buffers. For files, the value of (`default-directory`) is simply the directory the file resides in.

  NB: By default, `proof-cd` is called from `proof-activate-scripting-hook`, so that the prover switches to the directory of a proof script every time scripting begins.

Variable: proof-shell-start-silent-cmd

  Command to turn prover goals output off when sending many script commands.
  If non-nil, Proof General will automatically issue this command to help speed up processing of long proof scripts. See also `proof-shell-stop-silent-cmd`. NB: terminator not added to command.

Variable: proof-shell-stop-silent-cmd

  Command to turn prover output on.
  If non-nil, Proof General will automatically issue this command to help speed up processing of long proof scripts. See also `proof-shell-start-silent-cmd`. NB: Terminator not added to command.

Variable: proof-shell-silent-threshold

  Number of waiting commands in the proof queue needed to trigger silent mode.
  Default is 2, but you can raise this in case switching silent mode on or off is particularly expensive (or make it ridiculously large to disable silent mode altogether).

See section Handling Multiple Files, for more details about the final two settings in this group,

Variable: proof-shell-inform-file-processed-cmd

  Command to the proof assistant to tell it that a file has been processed.
  The format character ‘`%s`’ is replaced by a complete filename for a script file which has been fully processed interactively with Proof General. See ‘``proof-format-filename``’ for other possibilities to process the filename.

  This setting used to interface with the proof assistant's internal management of multiple files, so the proof assistant is kept aware of which files have been processed. Specifically, when scripting is deactivated in a completed buffer, it is added to Proof General's list of processed files, and the prover is told about it by issuing this command.

  If this is set to nil, no command is issued.

  See also: `proof-shell-inform-file-retracted-cmd`, `proof-shell-process-file`, `proof-shell-compute-new-files-list`.

Variable: proof-shell-inform-file-retracted-cmd

  Command to the proof assistant to tell it that a file has been retracted.
  The format character ‘`%s`’ is replaced by a complete filename for a script file which Proof General wants the prover to consider as not completely processed. See ‘``proof-format-filename``’ for other possibilities to process the filename.

  This is used to interface with the proof assistant's internal management of multiple files, so the proof assistant is kept aware of which files have been processed. Specifically, when scripting is activated, the file is removed from Proof General's list of processed files, and the prover is told about it by issuing this command. The action may cause the prover in turn to suggest to Proof General that files depending on this one are also unlocked.

  If this is set to nil, no command is issued.

  It is also possible to set this value to a function which will be invoked on the name of the retracted file, and should remove the ancestor files from ‘``proof-included-files-list``’ by some other calculation.

  See also: `proof-shell-inform-file-processed-cmd`, `proof-shell-process-file`, `proof-shell-compute-new-files-list`.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 4.2 Script input to the shell

Generally, commands from the proof script are sent verbatim to the proof process running in the proof shell. For historical reasons, carriage returns are stripped by default. You can set `proof-shell-strip-crs-from-input` to adjust that. For more sophisticated pre-processing of the sent string, you may like to set `proof-shell-insert-hook`.

Variable: proof-shell-strip-crs-from-input

  If non-nil, replace carriage returns in every input with spaces.
  This is enabled by default: it is appropriate for many systems based on human input, because several CR's can result in several prompts, which may mess up the display (or even worse, the synchronization).

  If the prover can be set to output only one prompt for every chunk of input, then newlines can be retained in the input.

Variable: proof-shell-insert-hook

  Hooks run by ‘``proof-shell-insert``’ before inserting a command.
  Can be used to configure the proof assistant to the interface in various ways – for example, to observe or alter the commands sent to the prover, or to sneak in extra commands to configure the prover.

  This hook is called inside a ‘``save-excursion``’ with the `proof-shell-buffer` current, just before inserting and sending the text in the variable ‘`string`’. The hook can massage ‘`string`’ or insert additional text directly into the `proof-shell-buffer`. Before sending ‘`string`’, it will be stripped of carriage returns.

  Additionally, the hook can examine the variable ‘`action`’. It will be a symbol, set to the callback command which is executed in the proof shell filter once ‘`string`’ has been processed. The ‘`action`’ variable suggests what class of command is about to be inserted:

       'proof-done-invisible       A non-scripting command
       'proof-done-advancing       A "forward" scripting command
       'proof-done-retracting      A "backward" scripting command
       'init-cmd                   Initialization command sent to prover
       'interactive-input          Special interactive input direct to prover

  Caveats: You should be very careful about setting this hook. Proof General relies on a careful synchronization with the process between inputs and outputs. It expects to see a prompt for each input it sends from the queue. If you add extra input here and it causes more prompts than expected, things will break! Extending the variable ‘`string`’ may be safer than inserting text directly, since it is stripped of carriage returns before being sent.

  Example uses: lego uses this hook for setting the pretty printer width if the window width has changed; Plastic uses it to remove literate-style markup from ‘`string`’. The x-symbol support uses this hook to convert special characters into tokens for the proof assistant.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 4.3 Settings for matching various output from proof process

These settings control the way Proof General reacts to process output. The single most important setting is `proof-shell-annotated-prompt-regexp`, which must be set as part of the prover configuraton. This is used to configure the communication with the prover process.

Variable: proof-shell-wakeup-char

  A special character which terminates an annotated prompt.
  Set to nil if proof assistant does not support annotated prompts.

Variable: pg-subterm-first-special-char

  First special character.
  Codes above this character can have special meaning to Proof General, and are stripped from the prover's output strings. Leave unset if no special characters are being used.

Variable: proof-shell-prompt-pattern

  Proof shell's value for comint-prompt-pattern, which see.
  NB!! This pattern is just for interaction in comint (shell buffer). You don't really need to set it. The important one to set is ‘``proof-shell-annotated-prompt-regexp``’, which see.

Variable: proof-shell-annotated-prompt-regexp

  Regexp matching a (possibly annotated) prompt pattern.

  this IS THE most important setting TO configure!!

  Output is grabbed between pairs of lines matching this regexp, and the appearance of this regexp is used by Proof General to recognize when the prover has finished processing a command.

  To help speed up matching you may be able to annotate the proof assistant prompt with a special character not appearing in ordinary output. The special character should appear in this regexp, and should be the value of `proof-shell-wakeup-char`.

Variable: proof-shell-abort-goal-regexp

  Regexp matching output from an aborted proof.

Variable: proof-shell-error-regexp

  Regexp matching an error report from the proof assistant.

  We assume that an error message corresponds to a failure in the last proof command executed. So don't match mere warning messages with this regexp. Moreover, an error message should not be matched as an eager annotation (see `proof-shell-eager-annotation-start`) otherwise it will be lost.

  Error messages are considered to begin from `proof-shell-error-regexp` and continue until the next prompt. The variable ‘``proof-shell-truncate-before-error``’ controls whether text before the error message is displayed.

  The engine matches interrupts before errors, see `proof-shell-interrupt-regexp`.

  It is safe to leave this variable unset (as nil).

Variable: proof-shell-interrupt-regexp

  Regexp matching output indicating the assistant was interrupted.
  We assume that an interrupt message corresponds to a failure in the last proof command executed. So don't match mere warning messages with this regexp. Moreover, an interrupt message should not be matched as an eager annotation (see `proof-shell-eager-annotation-start`) otherwise it will be lost.

  The engine matches interrupts before errors, see `proof-shell-error-regexp`.

  It is safe to leave this variable unset (as nil).

Variable: proof-shell-truncate-before-error

  Non-nil means truncate output that appears before error messages.
  If nil, the whole output that the prover generated before the last error message will be shown.

  NB: the default setting for this is ‘`t`’ to be compatible with behaviour in Proof General before version 3.4. The more obvious setting for new instances is probably ‘`nil`’.

  Interrupt messages are treated in the same way. See ‘``proof-shell-error-regexp``’ and ‘``proof-shell-interrupt-regexp``’.

Variable: proof-shell-proof-completed-regexp

  Regexp matching output indicating a finished proof.

  When output which matches this regexp is seen, we clear the goals buffer in case this is not also marked up as a ‘`goals`’ type of message.

  We also enable the QED function (save a proof) and we may automatically close off the proof region if another goal appears before a save command, depending on whether the prover supports nested proofs or not.

Variable: proof-shell-start-goals-regexp

  Regexp matching the start of the proof state output.
  This is an important setting. Output between ‘``proof-shell-start-goals-regexp``’ and ‘``proof-shell-end-goals-regexp``’ will be pasted into the goals buffer and possibly analysed further for proof-by-pointing markup.

Variable: proof-shell-end-goals-regexp

  Regexp matching the end of the proof state output, or nil.
  If nil, just use the rest of the output following `proof-shell-start-goals-regexp`.

Variable: proof-shell-assumption-regexp

  A regular expression matching the name of assumptions.

  At the moment, this setting is not used in the generic Proof General.

  Future use may providea generic implementation for ‘``pg-topterm-goalhyplit-fn``’, used to help parse the goals buffer to annotate it for proof by pointing.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 4.4 Settings for matching urgent messages from proof process

Among the various dialogue messages that the proof assistant outputs during proof, Proof General can consider certain messages to be "urgent". When processing many lines of a proof, Proof General will normally supress the output, waiting until the final message appears before displaying anything to the user. Urgent messages escape this: typically they include messages that the prover wants the user to notice, for example, perhaps, file loading messages, or timing statistics.

So that Proof General notices, these urgent messages should be marked-up with "eager" annotations.

Variable: proof-shell-eager-annotation-start

  Eager annotation field start. A regular expression or nil.
  An "eager annotation indicates" to Proof General that some following output should be displayed (or processed) immediately and not accumulated for parsing later. Note that this affects processing of output which is ordinarily accumulated: output which appears before the eager annotation start will be discarded.

  The start/end annotations can be used to hilight the output, but are stripped from display of the message in the minibuffer.

  It is useful to recognize (starts of) warnings or file-reading messages with this regexp. You must also recognize any special messages from the prover to PG with this regexp (e.g. ‘``proof-shell-clear-goals-regexp``’, ‘``proof-shell-retract-files-regexp``’, etc.)

  See also ‘``proof-shell-eager-annotation-start-length``’, ‘``proof-shell-eager-annotation-end``’.

  Set to nil to disable this feature.

Variable: proof-shell-eager-annotation-start-length

  Maximum length of an eager annotation start.
  Must be set to the maximum length of the text that may match ‘``proof-shell-eager-annotation-start``’ (at least 1). If this value is too low, eager annotations may be lost!

  This value is used internally by Proof General to optimize the process filter to avoid unnecessary searching.

Variable: proof-shell-eager-annotation-end

  Eager annotation field end. A regular expression or nil.
  An eager annotation indicates to Emacs that some following output should be displayed or processed immediately.

  See also ‘``proof-shell-eager-annotation-start``’.

  It is nice to recognize (ends of) warnings or file-reading messages with this regexp. You must also recognize (ends of) any special messages from the prover to PG with this regexp (e.g. ‘``proof-shell-clear-goals-regexp``’, ‘``proof-shell-retract-files-regexp``’, etc.)

  The default value is "\n" to match up to the end of the line.

The default action for urgent messages is to display them in the response buffer, highlighted. But we also allow for some control messages, issued from the proof assistant to Proof General and not intended for the user to see. These are recognized in the same way as urgent messages (marked with eager annotations), so they will be acted on as soon as they are issued by the prover.

Variable: proof-shell-clear-response-regexp

  Regexp matching output telling Proof General to clear the response buffer.
  This feature is useful to give the prover more control over what output is shown to the user. Set to nil to disable.

Variable: proof-shell-clear-goals-regexp

  Regexp matching output telling Proof General to clear the goals buffer.
  This feature is useful to give the prover more control over what output is shown to the user. Set to nil to disable.

Variable: proof-shell-set-elisp-variable-regexp

  Matches output telling Proof General to set some variable.
  This allows the proof assistant to configure Proof General directly and dynamically. (It's also a fantastic backdoor security risk).

  If the regexp matches output from the proof assistant, there should be two match strings: (`match-string` 1) should be the name of the elisp variable to be set, and (`match-string` 2) should be the value of the variable (which will be evaluated as a Lisp expression).

  A good markup for the second string is to delimit with #'s, since these are not valid syntax for elisp evaluation.

  Elisp errors will be trapped when evaluating; set `proof-general-debug` to be informed when this happens.

  Example uses are to adjust PG's internal copies of proof assistant's settings, or to make automatic dynamic syntax adjustments in Emacs to match changes in theory, etc.

  If you pick a dummy variable name (e.g. ‘`proof-dummy-setting`’) you can just evaluation arbitrary elisp expressions for their side effects, to adjust menu entries, or even launch auxiliary programs. But use with care – there is no protection against catastrophic elisp!

  This setting could also be used to move some configuration settings from PG to the prover, but this is not really supported (most settings must be made before this mechanism will work). In future, the PG standard protocol, pgip, will use this mechanism for making all settings.

Variable: proof-shell-theorem-dependency-list-regexp

  Matches output telling Proof General about dependencies.
  This is to allow navigation and display of dependency information. The output from the prover should be a message with the form

         dependencies OF  X Y Z   ARE  A B C

  with X Y Z, A B C separated by whitespace or somehow else (see ‘``proof-shell-theorem-dependency-list-split``’. This variable should be set to a regexp to match the overall message (which should be an urgent message), with two sub-matches for X Y Z and A B C.

  This is an experimental feature, currently work-in-progress.

Two important control messages are recognized by `proof-shell-process-file` and `proof-shell-retract-files-regexp`, used for synchronizing Proof General with a file loading mechanism built into the proof assistant. See section Handling Multiple Files, for more details about how to use the final four settings described here.

Variable: proof-shell-process-file

  A pair (regexp . function) to match a processed file name.

  If regexp matches output, then the function function is invoked on the output string chunk. It must return the name of a script file (with complete path) that the system has successfully processed. In practice, function is likely to inspect the match data. If it returns the empty string, the file name of the scripting buffer is used instead. If it returns nil, no action is taken.

  Care has to be taken in case the prover only reports on compiled versions of files it is processing. In this case, function needs to reconstruct the corresponding script file name. The new (true) file name is added to the front of ‘``proof-included-files-list``’.

Variable: proof-shell-retract-files-regexp

  Matches a message that the prover has retracted a file.

  At this stage, Proof General's view of the processed files is out of date and needs to be updated with the help of the function ‘``proof-shell-compute-new-files-list``’.

Variable: proof-shell-compute-new-files-list

  Function to update ‘`proof-included-files list`’.

  It needs to return an up to date list of all processed files. Its output is stored in ‘``proof-included-files-list``’. Its input is the string of which ‘``proof-shell-retract-files-regexp``’ matched a substring. In practice, this function is likely to inspect the previous (global) variable ‘``proof-included-files-list``’ and the match data triggered by ‘``proof-shell-retract-files-regexp``’.

Variable: proof-cannot-reopen-processed-files

  Non-nil if the prover allows re-opening of already processed files.

  If the user has used Proof General to process a file incrementally, then PG will retain the spans recording undo history in the buffer corresponding to that file (provided it remains visited in Emacs).

  If the prover allows, it will be possible to undo to a position within this file. If the prover does not allow this, this variable should be set non-nil, so that when a completed file is activated for scripting (to do undo operations), the whole history is discarded.

Variable: proof-shell-require-command-regexp

  A regular expression to match a Require-type of command, or nil.
  If set to a regexp, then ‘``proof-done-advancing-require-function``’ should also be set, and will be called immediately after the match.

  This can be used to adjust ‘``proof-included-files-list``’ based on the lines of script that have been processed/parsed, rather than relying on information from the prover.

Variable: proof-done-advancing-require-function

  Used in ‘``proof-done-advancing``’, see ‘``proof-shell-require-command-regexp``’.
  The function is passed the span and the command as arguments.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## 4.5 Hooks and other settings

Variable: proof-shell-filename-escapes

  A list of escapes that are applied to %s for filenames.
  A list of cons cells, car of which is string to be replaced by the cdr. For example, when directories are sent to Isabelle, HOL, and Coq, they appear inside ML strings and the backslash character and quote characters must be escaped. The setting

        '(("\\\\" . "\\\\")
          ("\"" . "\\\""))

  achieves this. This does not apply to lego, which does not need backslash escapes and does not allow filenames with quote characters.

  This setting is used inside the function ‘``proof-format-filename``’.

Variable: proof-shell-process-connection-type

  The value of ‘``process-connection-type``’ for the proof shell.
  Set non-nil for ptys, nil for pipes. The default (and preferred) option is to use pty communication. However there is a long-standing backslash/long line problem with Solaris which gives a mess of ^G characters when some input is sent which has a \ in the 256th position. So we select pipes by default if it seems like we're on Solaris. We do not force pipes everywhere because this risks loss of data.

Variable: proof-shell-handle-error-or-interrupt-hook

  Run after an error or interrupt has been reported in the response buffer.
  Hook functions may inspect ‘``proof-shell-error-or-interrupt-seen``’ to determine whether the cause was an error or interrupt. Possible values for this hook include:

       proof-goto-end-of-locked-on-error-if-pos-not-visible-in-window
       proof-goto-end-of-locked-if-pos-not-visible-in-window

  which move the cursor in the scripting buffer on an error or error/interrupt.

  Remark: This hook is called from shell buffer. If you want to do something in scripting buffer, ‘``save-excursion``’ and/or ‘``set-buffer``’.

Variable: proof-shell-pre-interrupt-hook

  Run immediately after ‘``comint-interrupt-subjob``’ is called. This
  hook is added to allow customization for systems that query the user before returning to the top level.

Variable: proof-shell-process-output-system-specific

  Set this variable to handle system specific output.
  Errors, start of proofs, abortions of proofs and completions of proofs are recognised in the function ‘``proof-shell-process-output``’. All other output from the proof engine is simply reported to the user in the response buffer.

  To catch further special cases, set this variable to a pair of functions '(condf . actf). Both are given (cmd string) as arguments. ‘`cmd`’ is a string containing the currently processed command. ‘`string`’ is the response from the proof system. To change the behaviour of ‘``proof-shell-process-output``’, (condf cmd string) must return a non-nil value. Then (actf cmd string) is invoked.

  See the documentation of ‘``proof-shell-process-output``’ for the required output format.

[ << ] | [ >> ] |  |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

This document was generated by David Aspinall on July, 24 2008 using texi2html 1.78.