src/Doc/JEdit/JEdit.thy
author wenzelm
Sun, 03 Nov 2013 16:22:57 +0100
changeset 55247 e649dff217ae
parent 55246 0f50303e899f
child 55248 9d19298d3650
permissions -rw-r--r--
more on Timing;
wenzelm@55118
     1
(*:wrap=hard:maxLineLen=78:*)
wenzelm@55118
     2
wenzelm@54906
     3
theory JEdit
wenzelm@54906
     4
imports Base
wenzelm@54906
     5
begin
wenzelm@54906
     6
wenzelm@54906
     7
chapter {* Introduction *}
wenzelm@54906
     8
wenzelm@54907
     9
section {* Concepts and terminology *}
wenzelm@54907
    10
wenzelm@55209
    11
text {* Isabelle/jEdit is a Prover IDE that integrates \emph{parallel
wenzelm@55209
    12
  proof checking} \cite{Wenzel:2009,Wenzel:2013:ITP} with
wenzelm@55209
    13
  \emph{asynchronous user interaction}
wenzelm@55209
    14
  \cite{Wenzel:2010,Wenzel:2012:UITP-EPTCS}, based on a
wenzelm@55209
    15
  document-oriented approach to \emph{continuous proof processing}
wenzelm@55209
    16
  \cite{Wenzel:2011:CICM,Wenzel:2012}. Many concepts and system
wenzelm@55209
    17
  components are fit together in order to make this work. The main
wenzelm@55217
    18
  building blocks are as follows.
wenzelm@54906
    19
wenzelm@55209
    20
  \begin{description}
wenzelm@54906
    21
wenzelm@55217
    22
  \item [PIDE] is a general framework for Prover IDEs based on
wenzelm@55217
    23
  Isabelle/Scala. It is built around a concept of parallel and
wenzelm@55217
    24
  asynchronous document processing, which is supported natively by the
wenzelm@55217
    25
  parallel proof engine that is implemented in Isabelle/ML. The prover
wenzelm@55217
    26
  discontinues the traditional TTY-based command loop, and supports
wenzelm@55217
    27
  direct editing of formal source text with rich formal markup for GUI
wenzelm@55217
    28
  rendering.
wenzelm@54906
    29
wenzelm@55209
    30
  \item [Isabelle/ML] is the implementation and extension language of
wenzelm@55209
    31
  Isabelle, see also \cite{isabelle-implementation}. It is integrated
wenzelm@55217
    32
  into the logical context of Isabelle/Isar and allows to manipulate
wenzelm@55217
    33
  logical entities directly. Arbitrary add-on tools may be implemented
wenzelm@55217
    34
  for object-logics such as Isabelle/HOL.
wenzelm@54906
    35
wenzelm@55209
    36
  \item [Isabelle/Scala] is the system programming language of
wenzelm@55209
    37
  Isabelle. It extends the pure logical environment of Isabelle/ML
wenzelm@55209
    38
  towards the ``real world'' of graphical user interfaces, text
wenzelm@55209
    39
  editors, IDE frameworks, web services etc.  Special infrastructure
wenzelm@55236
    40
  allows to transfer algebraic datatype values and formatted text
wenzelm@55217
    41
  easily between ML and Scala, using asynchronous protocol commands.
wenzelm@54907
    42
wenzelm@55217
    43
  \item [jEdit] is a sophisticated text editor implemented in
wenzelm@55217
    44
  Java.\footnote{\url{http://www.jedit.org}} It is easily extensible
wenzelm@55217
    45
  by plugins written in languages that work on the JVM, e.g.\
wenzelm@55217
    46
  Scala\footnote{\url{http://www.scala-lang.org/}}.
wenzelm@54907
    47
wenzelm@55209
    48
  \item [Isabelle/jEdit] is the main example application of the PIDE
wenzelm@55217
    49
  framework and the default user-interface for Isabelle. It targets
wenzelm@55217
    50
  both beginners and experts. Technically, Isabelle/jEdit combines a
wenzelm@55217
    51
  slightly modified version of the official jEdit code base with a
wenzelm@55217
    52
  special plugin for Isabelle, integrated as standalone application
wenzelm@55217
    53
  for the main operating system platforms: Linux, Windows, Mac OS X.
wenzelm@54907
    54
wenzelm@55209
    55
  \end{description}
wenzelm@54907
    56
wenzelm@55209
    57
  The subtle differences of Isabelle/ML versus Standard ML,
wenzelm@55218
    58
  Isabelle/Scala versus Scala, Isabelle/jEdit versus jEdit need to be
wenzelm@55218
    59
  taken into account when discussing any of these PIDE building blocks
wenzelm@55218
    60
  in public forums, mailing lists, or even scientific publications.
wenzelm@55218
    61
  *}
wenzelm@54906
    62
wenzelm@54907
    63
wenzelm@54907
    64
section {* The Isabelle/jEdit Prover IDE *}
wenzelm@54907
    65
wenzelm@54907
    66
text {*
wenzelm@55245
    67
  \begin{figure}[htb]
wenzelm@55219
    68
  \begin{center}
wenzelm@54910
    69
  \includegraphics[width=\textwidth]{isabelle-jedit}
wenzelm@55219
    70
  \end{center}
wenzelm@55219
    71
  \caption{The Isabelle/jEdit Prover IDE}
wenzelm@55245
    72
  \label{fig:isabelle-jedit}
wenzelm@55219
    73
  \end{figure}
wenzelm@54910
    74
wenzelm@55245
    75
  Isabelle/jEdit (\figref{fig:isabelle-jedit}) consists of some
wenzelm@55245
    76
  plugins for the well-known jEdit text editor
wenzelm@55245
    77
  \url{http://www.jedit.org}, according to the following principles.
wenzelm@54907
    78
wenzelm@54907
    79
  \begin{itemize}
wenzelm@54907
    80
wenzelm@55209
    81
  \item The original jEdit look-and-feel is generally preserved,
wenzelm@55236
    82
  although some default properties are changed to accommodate Isabelle
wenzelm@55236
    83
  (e.g.\ the text area font).
wenzelm@54907
    84
wenzelm@55209
    85
  \item Formal Isabelle/Isar text is checked asynchronously while
wenzelm@55209
    86
  editing.  The user is in full command of the editor, and the prover
wenzelm@55209
    87
  refrains from locking portions of the buffer.
wenzelm@54907
    88
wenzelm@54907
    89
  \item Prover feedback works via colors, boxes, squiggly underline,
wenzelm@55236
    90
  hyperlinks, popup windows, icons, clickable output --- all based on
wenzelm@55209
    91
  semantic markup produced by Isabelle in the background.
wenzelm@54907
    92
wenzelm@55209
    93
  \item Using the mouse together with the modifier key @{verbatim
wenzelm@55209
    94
  CONTROL} (Linux, Windows) or @{verbatim COMMAND} (Mac OS X) exposes
wenzelm@55209
    95
  additional formal content via tooltips and/or hyperlinks.
wenzelm@54907
    96
wenzelm@55209
    97
  \item Formal output (in popups etc.) may be explored recursively,
wenzelm@55209
    98
  using the same techniques as in the editor source buffer.
wenzelm@54907
    99
wenzelm@55217
   100
  \item Additional panels (e.g.\ \emph{Output}, \emph{Symbols}) are
wenzelm@55217
   101
  organized by the Dockable Window Manager of jEdit, which also allows
wenzelm@55217
   102
  multiple floating instances of each window class.
wenzelm@55217
   103
wenzelm@55209
   104
  \item The prover process and source files are managed on the editor
wenzelm@55209
   105
  side.  The prover operates on timeless and stateless document
wenzelm@55236
   106
  content as provided via Isabelle/Scala.
wenzelm@54907
   107
wenzelm@55209
   108
  \item Plugin options of jEdit (for the \emph{Isabelle} plugin) give
wenzelm@55236
   109
  access to a selection of Isabelle/Scala options and its persistent
wenzelm@55209
   110
  preferences, usually with immediate effect on the prover back-end or
wenzelm@55209
   111
  editor front-end.
wenzelm@54907
   112
wenzelm@54907
   113
  \item The logic image of the prover session may be specified within
wenzelm@55236
   114
  Isabelle/jEdit.  The new image is provided automatically by the
wenzelm@55236
   115
  Isabelle build tool after restart of the application.
wenzelm@54907
   116
wenzelm@54907
   117
  \end{itemize}
wenzelm@54907
   118
*}
wenzelm@54907
   119
wenzelm@54907
   120
wenzelm@55209
   121
subsection {* Documentation *}
wenzelm@55209
   122
wenzelm@55209
   123
text {* Regular jEdit documentation is accessible via its @{verbatim
wenzelm@55209
   124
  Help} menu or @{verbatim F1} keyboard shortcut. This includes a full
wenzelm@55209
   125
  \emph{User's Guide} and \emph{Frequently Asked Questions} for this
wenzelm@55209
   126
  sophisticated text editor.
wenzelm@55209
   127
wenzelm@55217
   128
  Most of this information about jEdit is relevant for Isabelle/jEdit
wenzelm@55217
   129
  as well, but one needs to keep in mind that defaults sometimes
wenzelm@55217
   130
  differ, and the official jEdit documentation does not know about the
wenzelm@55217
   131
  Isabelle plugin with its special support for theory editing.
wenzelm@55209
   132
*}
wenzelm@55209
   133
wenzelm@55209
   134
wenzelm@55209
   135
subsection {* Plugins *}
wenzelm@55209
   136
wenzelm@55209
   137
text {* The \emph{Plugin Manager} of jEdit allows to augment editor
wenzelm@55209
   138
  functionality by JVM modules (jars) that are provided by the central
wenzelm@55236
   139
  plugin repository, which is accessible by various mirror sites.
wenzelm@55209
   140
wenzelm@55209
   141
  Connecting to the plugin server infrastructure of the jEdit project
wenzelm@55236
   142
  allows to update bundled plugins or to add further functionality.
wenzelm@55236
   143
  This needs to be done with the usual care for such an open bazaar of
wenzelm@55236
   144
  contributions. Arbitrary combinations of add-on features are apt to
wenzelm@55236
   145
  cause problems.  It is advisable to start with the default
wenzelm@55236
   146
  configuration of Isabelle/jEdit and develop some understanding how
wenzelm@55236
   147
  it is supposed to work, before loading additional plugins at a grand
wenzelm@55236
   148
  scale.
wenzelm@55209
   149
wenzelm@55236
   150
  \medskip The main \emph{Isabelle} plugin is an integral part of
wenzelm@55236
   151
  Isabelle/jEdit and needs to remain active at all times! A few
wenzelm@55236
   152
  additional plugins are bundled with Isabelle/jEdit for convenience
wenzelm@55236
   153
  or out of necessity, notably \emph{Console} with its Isabelle/Scala
wenzelm@55236
   154
  sub-plugin and \emph{SideKick} with some Isabelle-specific parsers
wenzelm@55236
   155
  for document tree structure.  The \emph{ErrorList} plugin is
wenzelm@55236
   156
  required by \emph{SideKick}, but not used specifically in
wenzelm@55236
   157
  Isabelle/jEdit. *}
wenzelm@55209
   158
wenzelm@55209
   159
wenzelm@55209
   160
subsection {* Options *}
wenzelm@55209
   161
wenzelm@55217
   162
text {* Both jEdit and Isabelle have distinctive management of
wenzelm@55236
   163
  persistent options.
wenzelm@55209
   164
wenzelm@55236
   165
  Regular jEdit options are accessible via the dialogs for
wenzelm@55236
   166
  \emph{Global Options} and \emph{Plugin Options}.  Changed properties
wenzelm@55236
   167
  are stored eventually in @{verbatim
wenzelm@55236
   168
  "$ISABELLE_HOME_USER/jedit/properties"}.  In contrast, Isabelle
wenzelm@55236
   169
  system options are managed by Isabelle/Scala and changes stored in
wenzelm@55236
   170
  @{verbatim "$ISABELLE_HOME_USER/etc/preferences"}, independently of
wenzelm@55236
   171
  the jEdit properties.  See also \cite{isabelle-sys}, especially the
wenzelm@55236
   172
  coverage of sessions and command-line tools like @{tool build} or
wenzelm@55236
   173
  @{tool options}.
wenzelm@55209
   174
wenzelm@55236
   175
  Those Isabelle options that are declared as \textbf{public} are
wenzelm@55236
   176
  configurable in jEdit via \emph{Plugin Options / Isabelle /
wenzelm@55236
   177
  General}.  Moreover, there are various options for rendering of
wenzelm@55236
   178
  document content, which are configurable via \emph{Plugin Options /
wenzelm@55236
   179
  Isabelle / Rendering}.  Thus \emph{Plugin Options / Isabelle} in
wenzelm@55236
   180
  jEdit provides a view on certain Isabelle options.  Note that some
wenzelm@55236
   181
  of these options affect general parameters that are relevant outside
wenzelm@55236
   182
  Isabelle/jEdit as well, e.g.\ @{system_option threads} or
wenzelm@55209
   183
  @{system_option parallel_proofs} for the Isabelle build tool
wenzelm@55209
   184
  \cite{isabelle-sys}.
wenzelm@55217
   185
wenzelm@55236
   186
  \medskip All options are loaded on startup and saved on shutdown of
wenzelm@55217
   187
  Isabelle/jEdit.  Editing the machine-generated files @{verbatim
wenzelm@55217
   188
  "$ISABELLE_HOME_USER/jedit/properties"} or @{verbatim
wenzelm@55217
   189
  "$ISABELLE_HOME_USER/etc/preferences"} manually while the
wenzelm@55236
   190
  application is running is likely to cause surprise due to lost
wenzelm@55236
   191
  update!  *}
wenzelm@55209
   192
wenzelm@55209
   193
wenzelm@55209
   194
subsection {* Keymaps *}
wenzelm@55209
   195
wenzelm@55209
   196
text {* Keyboard shortcuts used to be managed as jEdit properties in
wenzelm@55209
   197
  the past, but recent versions (2013) have a separate concept of
wenzelm@55236
   198
  \emph{keymap} that is configurable via \emph{Global Options /
wenzelm@55236
   199
  Shortcuts}.  The @{verbatim imported} keymap is derived from the
wenzelm@55218
   200
  initial environment of properties that is available at the first
wenzelm@55236
   201
  start of the editor; afterwards the keymap file takes precedence.
wenzelm@55209
   202
wenzelm@55209
   203
  This is relevant for Isabelle/jEdit due to various fine-tuning of
wenzelm@55209
   204
  default properties, and additional keyboard shortcuts for Isabelle
wenzelm@55236
   205
  specific functionality. Users may change their keymap, but need to
wenzelm@55236
   206
  copy Isabelle-specific key bindings manually.  *}
wenzelm@55209
   207
wenzelm@55209
   208
wenzelm@55210
   209
subsection {* Look-and-feel *}
wenzelm@55209
   210
wenzelm@55218
   211
text {* jEdit is a Java/AWT/Swing application with some ambition to
wenzelm@55217
   212
  support ``native'' look-and-feel on all platforms, within the limits
wenzelm@55218
   213
  of what Oracle as Java provider and major operating system
wenzelm@55218
   214
  distributors allow (see also \secref{sec:problems}).
wenzelm@55209
   215
wenzelm@55217
   216
  Isabelle/jEdit enables platform-specific look-and-feel by default as
wenzelm@55218
   217
  follows:
wenzelm@55209
   218
wenzelm@55209
   219
  \begin{description}
wenzelm@55209
   220
wenzelm@55209
   221
  \item[Linux] The platform-independent \emph{Nimbus} is used by
wenzelm@55210
   222
  default, but the classic \emph{Metal} also works.  \emph{GTK+} works
wenzelm@55210
   223
  under the side-condition that the overall GTK theme is selected in a
wenzelm@55236
   224
  Swing-friendly way.\footnote{GTK support in Java/Swing was once
wenzelm@55236
   225
  marketed aggressively by Sun, but never quite finished, and is today
wenzelm@55236
   226
  (2013) lagging a bit behind further development of Swing and GTK.}
wenzelm@55209
   227
wenzelm@55209
   228
  \item[Windows] Regular \emph{Windows} is used by default, but
wenzelm@55209
   229
  platform-independent \emph{Nimbus} and \emph{Metal} also work.
wenzelm@55209
   230
wenzelm@55236
   231
  \item[Mac OS X] Regular \emph{Mac OS X} is used by default, but
wenzelm@55236
   232
  platform-independent \emph{Nimbus} and \emph{Metal} also work.
wenzelm@55209
   233
  Moreover the bundled \emph{MacOSX} plugin provides various functions
wenzelm@55209
   234
  that are expected from applications on that particular platform:
wenzelm@55209
   235
  quit from menu or dock, preferences menu, drag-and-drop of text
wenzelm@55209
   236
  files on the application, full-screen mode for main editor windows
wenzelm@55209
   237
  etc.
wenzelm@55209
   238
wenzelm@55209
   239
  \end{description}
wenzelm@55209
   240
wenzelm@55209
   241
  Users may experiment with different look-and-feels, but need to keep
wenzelm@55217
   242
  in mind that this extra variance of GUI functionality is unlikely to
wenzelm@55236
   243
  work in arbitrary combinations.  The historic \emph{CDE/Motif} is
wenzelm@55236
   244
  better avoided.  After changing the look-and-feel in \emph{Global
wenzelm@55236
   245
  Options / Appearance}, it is advisable to restart Isabelle/jEdit in
wenzelm@55236
   246
  order to take full effect.  *}
wenzelm@55209
   247
wenzelm@55209
   248
wenzelm@55239
   249
subsection {* File-system access *}
wenzelm@55239
   250
wenzelm@55239
   251
text {* File specifications in jEdit follow various formats and
wenzelm@55239
   252
  conventions according to \emph{Virtual File Systems}, which may be
wenzelm@55239
   253
  also provided by additional plugins.  This allows to access remote
wenzelm@55239
   254
  files via the @{verbatim "http:"} protocol prefix, for example.
wenzelm@55239
   255
  Isabelle/jEdit attempts to work with the file-system access model of
wenzelm@55239
   256
  jEdit as far as possible.  In particular, theory sources are passed
wenzelm@55239
   257
  directly from the editor to the prover, without indirection via
wenzelm@55239
   258
  files.
wenzelm@55239
   259
wenzelm@55239
   260
  Despite the flexibility of URLs in jEdit, local files are
wenzelm@55239
   261
  particularly important and are accessible without protocol prefix.
wenzelm@55239
   262
  Here the path notation is that of the Java Virtual Machine on the
wenzelm@55239
   263
  underlying platform.  On Windows the preferred form uses
wenzelm@55239
   264
  backslashes, but happens to accept Unix/POSIX forward slashes, too.
wenzelm@55239
   265
  Further differences arise due to drive letters and network shares.
wenzelm@55239
   266
wenzelm@55239
   267
  The Java notation for files needs to be distinguished from the one
wenzelm@55239
   268
  of Isabelle, which uses POSIX notation with forward slashes on
wenzelm@55239
   269
  \emph{all} platforms.\footnote{Isabelle on Windows uses Cygwin
wenzelm@55239
   270
  file-system access.}  Moreover, environment variables from the
wenzelm@55239
   271
  Isabelle process may be used freely, e.g.\ @{file
wenzelm@55239
   272
  "$ISABELLE_HOME/etc/symbols"} or @{file
wenzelm@55239
   273
  "$ISABELLE_JDK_HOME/README.html"}.  There are special shortcuts:
wenzelm@55239
   274
  @{verbatim "~"} for @{file "$USER_HOME"}, and @{verbatim "~~"} for
wenzelm@55239
   275
  @{file "$ISABELLE_HOME"}.
wenzelm@55239
   276
wenzelm@55239
   277
  \medskip Since jEdit happens to support environment variables within
wenzelm@55239
   278
  file specifications as well, it is natural to use similar notation
wenzelm@55239
   279
  within the editor, e.g.\ in the file-browser.  This does not work in
wenzelm@55239
   280
  full generality, though, due to the bias of jEdit towards
wenzelm@55239
   281
  platform-specific notation and of Isabelle towards POSIX.  Moreover,
wenzelm@55239
   282
  the Isabelle settings environment is not yet active when starting
wenzelm@55239
   283
  Isabelle/jEdit via its standard application wrapper (in contrast to
wenzelm@55239
   284
  @{verbatim "isabelle jedit"} run from the command line).
wenzelm@55239
   285
wenzelm@55239
   286
  For convenience, Isabelle/jEdit imitates at least @{verbatim
wenzelm@55239
   287
  "$ISABELLE_HOME"} and @{verbatim "$ISABELLE_HOME_USER"} within the
wenzelm@55239
   288
  Java process environment, in order to allow easy access to these
wenzelm@55239
   289
  important places from the editor.
wenzelm@55239
   290
wenzelm@55239
   291
  Moreover note that path specifications in prover input or output
wenzelm@55239
   292
  usually include formal markup that turns it into a hyperlink (see
wenzelm@55240
   293
  also \secref{sec:tooltips-hyperlinks}).  This allows to open the
wenzelm@55239
   294
  corresponding file in the text editor, independently of the path
wenzelm@55239
   295
  notation.  *}
wenzelm@55239
   296
wenzelm@55239
   297
wenzelm@54907
   298
chapter {* Prover IDE functionality *}
wenzelm@54907
   299
wenzelm@55241
   300
section {* Text buffers and theories \label{sec:buffers-theories} *}
wenzelm@55209
   301
wenzelm@55238
   302
text {* As regular text editor, jEdit maintains a collection of open
wenzelm@55238
   303
  \emph{text buffers} to store source files; each buffer may be
wenzelm@55238
   304
  associated with any number of visible \emph{text areas}.  Buffers
wenzelm@55238
   305
  are subject to an \emph{edit mode} that is determined from the file
wenzelm@55238
   306
  type.  Files with extension \texttt{.thy} are assigned to the mode
wenzelm@55238
   307
  \emph{isabelle} and treated specifically.
wenzelm@55209
   308
wenzelm@55217
   309
  \medskip Isabelle theory files are automatically added to the formal
wenzelm@55217
   310
  document model of Isabelle/Scala, which maintains a family of
wenzelm@55217
   311
  versions of all sources for the prover.  The \emph{Theories} panel
wenzelm@55217
   312
  provides an overview of the status of continuous checking of theory
wenzelm@55217
   313
  sources.  Unlike batch sessions \cite{isabelle-sys}, theory nodes
wenzelm@55217
   314
  are identified by full path names; this allows to work with multiple
wenzelm@55217
   315
  (disjoint) Isabelle sessions simultaneously within the same editor
wenzelm@55217
   316
  session.
wenzelm@55209
   317
wenzelm@55217
   318
  Certain events to open or update buffers with theory files cause
wenzelm@55217
   319
  Isabelle/jEdit to resolve dependencies of \emph{theory imports}.
wenzelm@55238
   320
  The system requests to load additional files into editor buffers, in
wenzelm@55238
   321
  order to be included in the theory document model for further
wenzelm@55238
   322
  checking.  It is also possible to resolve dependencies
wenzelm@55238
   323
  automatically, depending on \emph{Plugin Options / Isabelle /
wenzelm@55238
   324
  General / Auto load} (Isabelle system option @{system_option
wenzelm@55238
   325
  jedit_auto_load}).
wenzelm@55209
   326
wenzelm@55217
   327
  \medskip The open text area views on theory buffers define the
wenzelm@55217
   328
  visible \emph{perspective} of Isabelle/jEdit.  This is taken as a
wenzelm@55217
   329
  hint for document processing: the prover ensures that those parts of
wenzelm@55217
   330
  a theory where the user is looking are checked, while other parts
wenzelm@55238
   331
  that are presently not required are ignored.  The perspective is
wenzelm@55218
   332
  changed by opening or closing text area windows, or scrolling within
wenzelm@55218
   333
  some window.
wenzelm@55210
   334
wenzelm@55218
   335
  The \emph{Theories} panel provides some further options to influence
wenzelm@55218
   336
  the process of continuous checking: it may be switched off globally
wenzelm@55238
   337
  to restrict the prover to superficial processing of command syntax.
wenzelm@55238
   338
  It is also possible to indicate theory nodes as \emph{required} for
wenzelm@55218
   339
  continuous checking: this means such nodes and all their imports are
wenzelm@55218
   340
  always processed independently of the visibility status (if
wenzelm@55218
   341
  continuous checking is enabled).  Big theory libraries that are
wenzelm@55218
   342
  marked as required can have significant impact on performance,
wenzelm@55218
   343
  though.
wenzelm@55210
   344
wenzelm@55210
   345
  \medskip Formal markup of checked theory content is turned into GUI
wenzelm@55210
   346
  rendering, based on a standard repertoire known from IDEs for
wenzelm@55210
   347
  programming languages: colors, icons, highlighting, squiggly
wenzelm@55217
   348
  underline, tooltips, hyperlinks etc.  For outer syntax of
wenzelm@55238
   349
  Isabelle/Isar there is some traditional syntax-highlighting via
wenzelm@55238
   350
  static keyword tables and tokenization within the editor.  In
wenzelm@55238
   351
  contrast, the painting of inner syntax (term language etc.)\ uses
wenzelm@55238
   352
  semantic information that is reported dynamically from the logical
wenzelm@55238
   353
  context.  Thus the prover can provide additional markup to help the
wenzelm@55238
   354
  user to understand the meaning of formal text, and to produce more
wenzelm@55238
   355
  text with some add-on tools (e.g.\ information messages by automated
wenzelm@55238
   356
  provers or disprovers running in the background).
wenzelm@55240
   357
*}
wenzelm@55210
   358
wenzelm@55240
   359
wenzelm@55242
   360
section {* Prover output \label{sec:prover-output} *}
wenzelm@55241
   361
wenzelm@55241
   362
text {* Prover output consists of \emph{markup} and \emph{messages}.
wenzelm@55241
   363
  Both are directly attached to the corresponding positions in the
wenzelm@55241
   364
  original source text, and visualized in the text area, e.g.\ as text
wenzelm@55241
   365
  colours for free and bound variables, or as squiggly underline for
wenzelm@55245
   366
  warnings, errors etc.\ (see also \figref{fig:output}).  In the
wenzelm@55245
   367
  latter case, the corresponding messages are shown by hovering with
wenzelm@55245
   368
  the mouse over the highlighted text --- although in many situations
wenzelm@55245
   369
  the user should already get some clue by looking at the text
wenzelm@55245
   370
  highlighting alone.
wenzelm@55245
   371
wenzelm@55245
   372
  \begin{figure}[htb]
wenzelm@55245
   373
  \begin{center}
wenzelm@55245
   374
  \includegraphics[scale=0.3]{output}
wenzelm@55245
   375
  \end{center}
wenzelm@55245
   376
  \caption{Multiple views on prover output: gutter area, text area
wenzelm@55245
   377
    with popup, overview area, Theories panel, Output panel}
wenzelm@55245
   378
  \label{fig:output}
wenzelm@55245
   379
  \end{figure}
wenzelm@55241
   380
wenzelm@55241
   381
  The ``gutter area'' on the left-hand-side of the text area uses
wenzelm@55241
   382
  icons to provide a summary of the messages within the corresponding
wenzelm@55241
   383
  line of text.  Message priorities are used to prefer errors over
wenzelm@55241
   384
  warnings, warnings over information messages etc.  Plain output is
wenzelm@55241
   385
  ignored here.
wenzelm@55241
   386
wenzelm@55241
   387
  The ``overview area'' on the right-hand-side of the text area uses
wenzelm@55241
   388
  similar information to paint small rectangles for the overall status
wenzelm@55241
   389
  of the whole text buffer.  The graphics is scaled to fit the logical
wenzelm@55241
   390
  buffer length into the given window height.  Mouse clicks on the
wenzelm@55241
   391
  overview area position the cursor approximately to the corresponding
wenzelm@55241
   392
  line of text in the buffer.
wenzelm@55241
   393
wenzelm@55241
   394
  Another course-grained overview is provided by the \emph{Theories}
wenzelm@55241
   395
  panel (\secref{sec:buffers-theories}), but without direct
wenzelm@55241
   396
  correspondence to text positions.  A double-click on one of the
wenzelm@55241
   397
  theory entries with their status overview opens the corresponding
wenzelm@55241
   398
  text buffer, without changing the cursor position.
wenzelm@55241
   399
wenzelm@55241
   400
  \medskip In addition, the \emph{Output} panel displays prover
wenzelm@55241
   401
  messages that correspond to a given command, within a separate
wenzelm@55241
   402
  window.
wenzelm@55241
   403
wenzelm@55241
   404
  The cursor position in the presently active text area determines the
wenzelm@55241
   405
  prover commands whose cumulative message output is appended an shown
wenzelm@55241
   406
  in that window (in canonical order according to the processing of
wenzelm@55241
   407
  the command).  There are also control elements to modify the update
wenzelm@55241
   408
  policy of the output wrt.\ continued editor movements.  This is
wenzelm@55241
   409
  particularly useful with several independent instances of the
wenzelm@55241
   410
  \emph{Output} panel, which the Dockable Window Manager of jEdit can
wenzelm@55241
   411
  handle conveniently.
wenzelm@55241
   412
wenzelm@55241
   413
  Former users of the old TTY interaction model (e.g.\ Proof~General)
wenzelm@55241
   414
  might find a separate window for prover messages familiar, but it is
wenzelm@55241
   415
  important to understand that the main Prover IDE feedback happens
wenzelm@55241
   416
  elsewhere.  It is possible to do meaningful proof editing
wenzelm@55241
   417
  efficiently while using the secondary window only rarely.
wenzelm@55241
   418
wenzelm@55241
   419
  The main purpose of the output window is to ``debug'' unclear
wenzelm@55241
   420
  situations by inspecting internal state of the prover.\footnote{In
wenzelm@55243
   421
  that sense, unstructured tactic scripts depend on continuous
wenzelm@55241
   422
  debugging with internal state inspection.} Consequently, some
wenzelm@55241
   423
  special messages for \emph{tracing} or \emph{proof state} only
wenzelm@55241
   424
  appear here, and are not attached to the original source.
wenzelm@55241
   425
wenzelm@55241
   426
  \medskip In any case, prover messages also contain markup that may
wenzelm@55241
   427
  be explored recursively via tooltips or hyperlinks (see
wenzelm@55241
   428
  \secref{sec:tooltips-hyperlinks}), or clicked directly to initiate
wenzelm@55243
   429
  certain actions (see \secref{sec:auto-tools} and
wenzelm@55243
   430
  \secref{sec:sledgehammer}).  *}
wenzelm@55241
   431
wenzelm@55241
   432
wenzelm@55240
   433
section {* Tooltips and hyperlinks \label{sec:tooltips-hyperlinks} *}
wenzelm@55240
   434
wenzelm@55240
   435
text {* Formally processed text (prover input or output) contains rich
wenzelm@55240
   436
  markup information that can be explored further by using the
wenzelm@55240
   437
  @{verbatim CONTROL} modifier key on Linux and Windows, or @{verbatim
wenzelm@55240
   438
  COMMAND} on Mac OS X.  Hovering with the mouse while the modifier is
wenzelm@55240
   439
  pressed reveals a \emph{tooltip} (grey box over the text with a
wenzelm@55240
   440
  yellow popup) and/or a \emph{hyperlink} (black rectangle over the
wenzelm@55240
   441
  text); see also \figref{fig:tooltip}.
wenzelm@55219
   442
wenzelm@55245
   443
  \begin{figure}[htb]
wenzelm@55219
   444
  \begin{center}
wenzelm@55245
   445
  \includegraphics[scale=0.5]{popup1}
wenzelm@55219
   446
  \end{center}
wenzelm@55244
   447
  \caption{Tooltip and hyperlink for some formal entity}
wenzelm@55238
   448
  \label{fig:tooltip}
wenzelm@55219
   449
  \end{figure}
wenzelm@55219
   450
wenzelm@55238
   451
  Tooltip popups use the same rendering principles as the main text
wenzelm@55238
   452
  area, and further tooltips and/or hyperlinks may be exposed
wenzelm@55245
   453
  recursively by the same mechanism; see \figref{fig:nested-tooltips}.
wenzelm@55211
   454
wenzelm@55245
   455
  \begin{figure}[htb]
wenzelm@55219
   456
  \begin{center}
wenzelm@55245
   457
  \includegraphics[scale=0.5]{popup2}
wenzelm@55219
   458
  \end{center}
wenzelm@55244
   459
  \caption{Nested tooltips over formal entities}
wenzelm@55238
   460
  \label{fig:nested-tooltips}
wenzelm@55219
   461
  \end{figure}
wenzelm@55238
   462
wenzelm@55238
   463
  The tooltip popup window provides some controls to \emph{close} or
wenzelm@55238
   464
  \emph{detach} the window, turning it into a separate \emph{Info}
wenzelm@55238
   465
  dockable window managed by jEdit.  The @{verbatim ESCAPE} key closes
wenzelm@55240
   466
  \emph{all} popups, which is particularly relevant when nested
wenzelm@55240
   467
  tooltips are stacking up.
wenzelm@55209
   468
wenzelm@55240
   469
  \medskip A black rectangle in the text indicates a hyperlink that
wenzelm@55240
   470
  may be followed by a mouse click (while the @{verbatim CONTROL} or
wenzelm@55240
   471
  @{verbatim COMMAND} modifier key is still pressed). Presently (2013)
wenzelm@55240
   472
  there is no systematic way to return to the original location within
wenzelm@55240
   473
  the editor.
wenzelm@55209
   474
wenzelm@55240
   475
  Also note that the link target may be a file that is itself not
wenzelm@55240
   476
  subject to formal document processing of the editor session and thus
wenzelm@55240
   477
  prevents further exploration: the chain of hyperlinks may end in
wenzelm@55240
   478
  some source file of the underlying logic image, even within the
wenzelm@55240
   479
  Isabelle/ML bootstrap sources of Isabelle/Pure, where the formal
wenzelm@55240
   480
  markup is less detailed. *}
wenzelm@55240
   481
wenzelm@55240
   482
wenzelm@55240
   483
section {* Isabelle symbols *}
wenzelm@54907
   484
wenzelm@55211
   485
text {* Isabelle sources consist of \emph{symbols} that extend plain
wenzelm@55218
   486
  ASCII to allow infinitely many mathematical symbols within the
wenzelm@55218
   487
  formal sources.  This works without depending on particular
wenzelm@55240
   488
  encodings or varying Unicode standards
wenzelm@55240
   489
  \cite{Wenzel:2011:CICM}.\footnote{Raw Unicode characters within
wenzelm@55240
   490
  formal sources would compromise portability and reliability in the
wenzelm@55240
   491
  face of changing interpretation of various unexpected features of
wenzelm@55240
   492
  Unicode.}
wenzelm@55211
   493
wenzelm@55211
   494
  For the prover back-end, formal text consists of ASCII characters
wenzelm@55211
   495
  that are grouped according to some simple rules, e.g.\ as plain
wenzelm@55211
   496
  ``@{verbatim a}'' or symbolic ``@{verbatim "\<alpha>"}''.
wenzelm@55211
   497
wenzelm@55240
   498
  For the editor front-end, a certain subset of symbols is rendered
wenzelm@55240
   499
  physically via Unicode glyphs, in order to show ``@{verbatim "\<alpha>"}''
wenzelm@55240
   500
  as ``@{text "\<alpha>"}'', for example.  This symbol interpretation is
wenzelm@55240
   501
  specified by the Isabelle system distribution in @{file
wenzelm@55240
   502
  "$ISABELLE_HOME/etc/symbols"} and may be augmented by the user in
wenzelm@55240
   503
  @{verbatim "$ISABELLE_HOME_USER/etc/symbols"}.
wenzelm@55211
   504
wenzelm@55217
   505
  The appendix of \cite{isabelle-isar-ref} gives an overview of the
wenzelm@55217
   506
  standard interpretation of finitely many symbols from the infinite
wenzelm@55240
   507
  collection.  Uninterpreted symbols are displayed literally, e.g.\
wenzelm@55240
   508
  ``@{verbatim "\<foobar>"}''.  Overlap of Unicode characters used in
wenzelm@55240
   509
  symbol interpretation with informal ones that might appear e.g.\ in
wenzelm@55240
   510
  comments needs to be avoided!
wenzelm@54907
   511
wenzelm@55240
   512
  \medskip \paragraph{Encoding.} Technically, the Unicode view on
wenzelm@55240
   513
  Isabelle symbols is an \emph{encoding} in jEdit (not in the
wenzelm@55240
   514
  underlying JVM) that is called @{verbatim "UTF-8-Isabelle"}.  It is
wenzelm@55240
   515
  provided by the Isabelle/jEdit plugin and enabled by default for all
wenzelm@55240
   516
  source files.  Sometimes such defaults are reset accidentally, or
wenzelm@55240
   517
  malformed UTF-8 sequences in the text force jEdit to fall back on a
wenzelm@55240
   518
  different encoding like @{verbatim "ISO-8859-15"}.  In that case,
wenzelm@55240
   519
  verbatim ``@{verbatim "\<alpha>"}'' will be shown in the text buffer
wenzelm@55240
   520
  instead of its Unicode rendering ``@{text "\<alpha>"}''.  The jEdit menu
wenzelm@55240
   521
  operation \emph{File / Reload with Encoding / UTF-8-Isabelle} helps
wenzelm@55240
   522
  to resolve such problems, potentially after repairing malformed
wenzelm@55240
   523
  parts of the text.
wenzelm@55211
   524
wenzelm@55240
   525
  \medskip \paragraph{Font.} Correct rendering via Unicode requires a
wenzelm@55240
   526
  font that contains glyphs for the corresponding codepoints.  Most
wenzelm@55240
   527
  system fonts lack that, so Isabelle/jEdit prefers its own
wenzelm@55240
   528
  application font @{verbatim IsabelleText}, which ensures that
wenzelm@55240
   529
  standard collection of Isabelle symbols are actually seen on the
wenzelm@55240
   530
  screen (or printer).
wenzelm@55217
   531
wenzelm@55218
   532
  Note that a Java/AWT/Swing application can load additional fonts
wenzelm@55218
   533
  only if they are not installed as system font already!  This means
wenzelm@55218
   534
  some old version of @{verbatim IsabelleText} that happens to be
wenzelm@55218
   535
  already present prevents Isabelle/jEdit from using its current
wenzelm@55240
   536
  bundled version.  This results in missing glyphs (black rectangles),
wenzelm@55240
   537
  when some obsolete version of @{verbatim IsabelleText} is used by
wenzelm@55240
   538
  accident.  This problem can be avoided by refraining to ``install''
wenzelm@55240
   539
  any version of @{verbatim IsabelleText} in the first place.
wenzelm@55217
   540
wenzelm@55211
   541
  \medskip \paragraph{Input methods.} In principle, Isabelle/jEdit
wenzelm@55211
   542
  could delegate the problem to produce Isabelle symbols in their
wenzelm@55211
   543
  Unicode rendering to the underlying operating system and its
wenzelm@55217
   544
  \emph{input methods}.  Regular jEdit also provides various ways to
wenzelm@55217
   545
  work with \emph{abbreviations} to produce certain non-ASCII
wenzelm@55217
   546
  characters.  Since none of these standard input methods work
wenzelm@55217
   547
  satisfactorily for the mathematical characters required for
wenzelm@55217
   548
  Isabelle, various specific Isabelle/jEdit mechanisms are provided.
wenzelm@55211
   549
wenzelm@55217
   550
  Here is a summary for practically relevant input methods for
wenzelm@55218
   551
  Isabelle symbols:
wenzelm@55211
   552
wenzelm@54907
   553
  \begin{enumerate}
wenzelm@55211
   554
wenzelm@55218
   555
  \item The \emph{Symbols} panel with some GUI buttons to insert
wenzelm@55211
   556
  certain symbols in the text buffer.  There are also tooltips to
wenzelm@55211
   557
  reveal to official Isabelle representation with some additional
wenzelm@55211
   558
  information about \emph{symbol abbreviations} (see below).
wenzelm@55211
   559
wenzelm@55211
   560
  \item Copy / paste from decoded source files: text that is rendered
wenzelm@55240
   561
  as Unicode already can be re-used to produce further text.  This
wenzelm@55240
   562
  also works between different applications, e.g.\ Isabelle/jEdit and
wenzelm@55240
   563
  some web browser or mail client, as long as the same Unicode view on
wenzelm@55240
   564
  Isabelle symbols is used uniformly.
wenzelm@55211
   565
wenzelm@55217
   566
  \item Copy / paste from prover output within Isabelle/jEdit.  The
wenzelm@55217
   567
  same principles as for text buffers apply, but note that \emph{copy}
wenzelm@55240
   568
  in secondary Isabelle/jEdit windows works via the keyboard shortcut
wenzelm@55240
   569
  @{verbatim "C+c"}.  The jEdit menu actions always refer to the
wenzelm@55240
   570
  primary text area!
wenzelm@55211
   571
wenzelm@55211
   572
  \item Completion provided by Isabelle plugin (see
wenzelm@55211
   573
  \secref{sec:completion}).  Isabelle symbols have a canonical name
wenzelm@55211
   574
  and optional abbreviations.  This can be used with the text
wenzelm@55211
   575
  completion mechanism of Isabelle/jEdit, to replace a prefix of the
wenzelm@55217
   576
  actual symbol like @{verbatim "\<lambda>"}, or its backslashed name
wenzelm@55217
   577
  @{verbatim "\\"}@{verbatim "lambda"}, or its ASCII abbreviation
wenzelm@55218
   578
  @{verbatim "%"} by the Unicode rendering.
wenzelm@55211
   579
wenzelm@55211
   580
  The following table is an extract of the information provided by the
wenzelm@55217
   581
  standard @{file "$ISABELLE_HOME/etc/symbols"} file:
wenzelm@54907
   582
wenzelm@54907
   583
  \medskip
wenzelm@54907
   584
  \begin{tabular}{lll}
wenzelm@55217
   585
    \textbf{symbol} & \textbf{abbreviation} & \textbf{backslashed name} \\\hline
wenzelm@54908
   586
    @{text "\<lambda>"}   & @{verbatim "%"}     &  @{verbatim "\\lambda"}         \\
wenzelm@54908
   587
    @{text "\<Rightarrow>"}  & @{verbatim "=>"}    &  @{verbatim "\\Rightarrow"}     \\
wenzelm@54908
   588
    @{text "\<Longrightarrow>"} & @{verbatim "==>"}   &  @{verbatim "\\Longrightarrow"} \\
wenzelm@54907
   589
wenzelm@54908
   590
    @{text "\<And>"}  & @{verbatim "!!"}    &  @{verbatim "\\And"}            \\
wenzelm@54908
   591
    @{text "\<equiv>"}  & @{verbatim "=="}    &  @{verbatim "\\equiv"}          \\
wenzelm@54907
   592
wenzelm@54908
   593
    @{text "\<forall>"}   & @{verbatim "!"}     &  @{verbatim "\\forall"}         \\
wenzelm@54908
   594
    @{text "\<exists>"}   & @{verbatim "?"}     &  @{verbatim "\\exists"}         \\
wenzelm@54908
   595
    @{text "\<longrightarrow>"} & @{verbatim "-->"}   &  @{verbatim "\\longrightarrow"} \\
wenzelm@54908
   596
    @{text "\<and>"}   & @{verbatim "&"}     &  @{verbatim "\\and"}            \\
wenzelm@54908
   597
    @{text "\<or>"}   & @{verbatim "|"}     &  @{verbatim "\\or"}             \\
wenzelm@54908
   598
    @{text "\<not>"}   & @{verbatim "~"}     &  @{verbatim "\\not"}            \\
wenzelm@54908
   599
    @{text "\<noteq>"}   & @{verbatim "~="}    &  @{verbatim "\\noteq"}          \\
wenzelm@54908
   600
    @{text "\<in>"}   & @{verbatim ":"}     &  @{verbatim "\\in"}             \\
wenzelm@54908
   601
    @{text "\<notin>"}   & @{verbatim "~:"}    &  @{verbatim "\\notin"}          \\
wenzelm@54907
   602
  \end{tabular}
wenzelm@55217
   603
  \medskip
wenzelm@55217
   604
wenzelm@55217
   605
  Note that the above abbreviations refer to the input method. The
wenzelm@55217
   606
  logical notation provides ASCII alternatives that often coincide,
wenzelm@55240
   607
  but deviate occasionally.  This occasionally causes user confusion
wenzelm@55240
   608
  with very old-fashioned Isabelle source that use ASCII replacement
wenzelm@55240
   609
  notation like @{verbatim "!"} or @{verbatim "ALL"} directly.
wenzelm@54907
   610
wenzelm@54907
   611
  \end{enumerate}
wenzelm@54907
   612
wenzelm@55217
   613
  Raw Unicode characters within prover source files should be
wenzelm@55211
   614
  restricted to informal parts, e.g.\ to write text in non-latin
wenzelm@55211
   615
  alphabets.  Mathematical symbols should be defined via the official
wenzelm@55219
   616
  rendering tables, to avoid problems with portability and long-term
wenzelm@55211
   617
  storage of formal text.
wenzelm@54907
   618
wenzelm@55211
   619
  \paragraph{Control symbols.} There are some special control symbols
wenzelm@55217
   620
  to modify the style of a single symbol (without nesting). Control
wenzelm@55217
   621
  symbols may be applied to a region of selected text, either using
wenzelm@55240
   622
  the \emph{Symbols} panel or keyboard shortcuts or jEdit actions.
wenzelm@55240
   623
  These editor operations produce a separate control symbol for each
wenzelm@55240
   624
  symbol in the text, in order to make the whole text appear in a
wenzelm@55240
   625
  certain style.
wenzelm@54907
   626
wenzelm@54907
   627
  \medskip
wenzelm@55240
   628
  \begin{tabular}{llll}
wenzelm@55240
   629
    style & \textbf{symbol} & shortcut & action \\\hline
wenzelm@55240
   630
    superscript & @{verbatim "\<^sup>"} & @{verbatim "C+e UP"} & @{verbatim "isabelle.control-sup"} \\
wenzelm@55240
   631
    subscript & @{verbatim "\<^sub>"} & @{verbatim "C+e DOWN"} & @{verbatim "isabelle.control-sub"} \\
wenzelm@55240
   632
    bold face & @{verbatim "\<^bold>"} & @{verbatim "C+e RIGHT"} & @{verbatim "isabelle.control-bold"} \\
wenzelm@55240
   633
    reset & & @{verbatim "C+e LEFT"} & @{verbatim "isabelle.control-reset"} \\
wenzelm@54907
   634
  \end{tabular}
wenzelm@55240
   635
  \medskip
wenzelm@55211
   636
wenzelm@55240
   637
  To produce a single control symbol, it is also possible to complete
wenzelm@55240
   638
  on @{verbatim "\\"}@{verbatim sup}, @{verbatim "\\"}@{verbatim sub},
wenzelm@55240
   639
  @{verbatim "\\"}@{verbatim bold} as for regular symbols.  *}
wenzelm@54907
   640
wenzelm@54907
   641
wenzelm@55211
   642
section {* Text completion \label{sec:completion} *}
wenzelm@54906
   643
wenzelm@55118
   644
text {*
wenzelm@55118
   645
  Text completion works via some light-weight GUI popup, which is triggered by
wenzelm@55118
   646
  keyboard events during the normal editing process in the main jEdit text
wenzelm@55118
   647
  area and a few additional text fields. The popup interprets special keys:
wenzelm@55118
   648
  @{verbatim TAB}, @{verbatim ESCAPE}, @{verbatim UP}, @{verbatim DOWN},
wenzelm@55118
   649
  @{verbatim PAGE_UP}, @{verbatim PAGE_DOWN}. All other key events are passed
wenzelm@55118
   650
  to the jEdit text area --- this allows to ignore unwanted completions most
wenzelm@55118
   651
  of the time and continue typing quickly.
wenzelm@55118
   652
wenzelm@55118
   653
  Various Isabelle plugin options control the popup behavior and immediate
wenzelm@55118
   654
  insertion into buffer.
wenzelm@55118
   655
wenzelm@55208
   656
  Isabelle Symbols are completed in backslashed forms, e.g.\ @{verbatim
wenzelm@55118
   657
  "\\"}@{verbatim "forall"} or @{verbatim "\<forall>"} that both produce the Isabelle
wenzelm@55119
   658
  symbol @{text "\<forall>"} in its Unicode rendering. Alternatively, symbol
wenzelm@55119
   659
  abbreviations may be used as specified in @{file
wenzelm@55119
   660
  "$ISABELLE_HOME/etc/symbols"}.
wenzelm@55118
   661
wenzelm@55118
   662
  \emph{Explicit completion} works via standard jEdit shortcut @{verbatim
wenzelm@55118
   663
  "C+b"}, which is remapped to action @{verbatim "isabelle.complete"}, with a
wenzelm@55118
   664
  fall-back on regular @{verbatim "complete-word"} for non-Isabelle buffers.
wenzelm@55118
   665
wenzelm@55118
   666
  \emph{Implicit completion} works via keyboard input on text area, with popup
wenzelm@55118
   667
  or immediate insertion into buffer. Plain words require at least 3
wenzelm@55118
   668
  characters to be completed.
wenzelm@55118
   669
wenzelm@55118
   670
  \emph{Immediate completion} means the (unique) replacement text is inserted
wenzelm@55118
   671
  into the buffer without popup. This mode ignores plain words and requires
wenzelm@55118
   672
  more than one characters for symbol abbreviations. Otherwise it falls back
wenzelm@55118
   673
  on completion popup.
wenzelm@55118
   674
*}
wenzelm@54906
   675
wenzelm@54907
   676
wenzelm@55243
   677
section {* Automatically tried tools \label{sec:auto-tools} *}
wenzelm@55241
   678
wenzelm@55242
   679
text {* Continuous document processing works asynchronously in the
wenzelm@55242
   680
  background.  Visible document source that has been evaluated already
wenzelm@55242
   681
  may get augmented by additional results of \emph{asynchronous print
wenzelm@55242
   682
  functions}.  The canonical example is proof state output, which is
wenzelm@55242
   683
  always enabled.  More heavy-weight print functions may be applied,
wenzelm@55242
   684
  in order to prove or disprove parts of the formal text by other
wenzelm@55242
   685
  means.
wenzelm@55242
   686
wenzelm@55242
   687
  Isabelle/HOL provides various automatically tried tools that operate
wenzelm@55242
   688
  on outermost goal statements (e.g.\ @{command lemma}, @{command
wenzelm@55242
   689
  theorem}), independently of the state of the current proof attempt.
wenzelm@55242
   690
  They work implicitly without any arguments.  Results are output as
wenzelm@55242
   691
  \emph{information messages}, which are indicated in the text area by
wenzelm@55244
   692
  blue squiggles and a blue information sign in the gutter (see
wenzelm@55244
   693
  \figref{fig:auto-tools}).  The message content may be shown as for
wenzelm@55244
   694
  any other message, see also \secref{sec:prover-output}.  Some tools
wenzelm@55244
   695
  produce output with \emph{sendback} markup, which means that
wenzelm@55244
   696
  clicking on certain parts of the output inserts that text into the
wenzelm@55244
   697
  source in the proper place.
wenzelm@55244
   698
wenzelm@55245
   699
  \begin{figure}[htb]
wenzelm@55244
   700
  \begin{center}
wenzelm@55244
   701
  \includegraphics[scale=0.5]{auto-tools}
wenzelm@55244
   702
  \end{center}
wenzelm@55244
   703
  \caption{Results of automatically tried tools}
wenzelm@55244
   704
  \label{fig:auto-tools}
wenzelm@55244
   705
  \end{figure}
wenzelm@55242
   706
wenzelm@55242
   707
  \medskip The following Isabelle system options control the behaviour
wenzelm@55242
   708
  of automatically tried tools (see also the jEdit dialog window
wenzelm@55242
   709
  \emph{Plugin Options / Isabelle / General / Automatically tried
wenzelm@55242
   710
  tools}):
wenzelm@55242
   711
wenzelm@55242
   712
  \begin{itemize}
wenzelm@55242
   713
wenzelm@55242
   714
  \item @{system_option auto_methods} controls automatic use of a
wenzelm@55242
   715
  combination of standard proof methods (@{method auto}, @{method
wenzelm@55242
   716
  simp}, @{method blast}, etc.).  This corresponds to the command
wenzelm@55242
   717
  @{command "try0"}.
wenzelm@55242
   718
wenzelm@55242
   719
  The tool is disabled by default, since unparameterized invocation of
wenzelm@55242
   720
  standard proof methods often consumes substantial CPU resources
wenzelm@55242
   721
  without leading to success.
wenzelm@55242
   722
wenzelm@55242
   723
  \item @{system_option auto_nitpick} controls a slightly reduced
wenzelm@55242
   724
  version of @{command nitpick}, which tests for counterexamples using
wenzelm@55242
   725
  first-order relational logic. See also the Nitpick manual
wenzelm@55242
   726
  \cite{isabelle-nitpick}.
wenzelm@55242
   727
wenzelm@55242
   728
  This tool is disabled by default, due to the extra overhead of
wenzelm@55242
   729
  invoking an external Java process for each attempt to disprove a
wenzelm@55242
   730
  subgoal.
wenzelm@55242
   731
wenzelm@55242
   732
  \item @{system_option auto_quickcheck} controls automatic use of
wenzelm@55242
   733
  @{command quickcheck}, which tests for counterexamples using a
wenzelm@55242
   734
  series of assignments for free variables of a subgoal.
wenzelm@55242
   735
wenzelm@55242
   736
  This tool is \emph{enabled} by default.  It requires little
wenzelm@55242
   737
  overhead, but is a bit weaker than @{command nitpick}.
wenzelm@55242
   738
wenzelm@55242
   739
  \item @{system_option auto_sledgehammer} controls a significantly
wenzelm@55242
   740
  reduced version of @{command sledgehammer}, which attempts to prove
wenzelm@55242
   741
  a subgoal using external automatic provers. See also the
wenzelm@55242
   742
  Sledgehammer manual \cite{isabelle-sledgehammer}.
wenzelm@55242
   743
wenzelm@55242
   744
  This tool is disabled by default, due to the relatively heavy nature
wenzelm@55242
   745
  of Sledgehammer.
wenzelm@55242
   746
wenzelm@55242
   747
  \item @{system_option auto_solve_direct} controls automatic use of
wenzelm@55242
   748
  @{command solve_direct}, which checks whether the current subgoals
wenzelm@55242
   749
  can be solved directly by an existing theorem.  This also helps to
wenzelm@55242
   750
  detect duplicate lemmas.
wenzelm@55242
   751
wenzelm@55242
   752
  This tool is \emph{enabled} by default.
wenzelm@55242
   753
wenzelm@55242
   754
  \end{itemize}
wenzelm@55242
   755
wenzelm@55242
   756
  Invocation of automatically tried tools is subject to some global
wenzelm@55242
   757
  policies of parallel execution, which may be configured as follows:
wenzelm@55242
   758
wenzelm@55242
   759
  \begin{itemize}
wenzelm@55242
   760
wenzelm@55242
   761
  \item @{system_option auto_time_limit} (default 2.0) determines the
wenzelm@55242
   762
  timeout (in seconds) for each tool execution individually.
wenzelm@55242
   763
wenzelm@55242
   764
  \item @{system_option auto_time_start} (default 1.0) determines the
wenzelm@55242
   765
  start delay (in seconds) for automatically tried tools, after the
wenzelm@55242
   766
  main command evaluation is finished.
wenzelm@55242
   767
wenzelm@55242
   768
  \end{itemize}
wenzelm@55242
   769
wenzelm@55242
   770
  Each tool is submitted independently to the pool of parallel
wenzelm@55242
   771
  execution tasks in Isabelle/ML, using hardwired priorities according
wenzelm@55242
   772
  to its relative ``heaviness''.  The main stages of evaluation and
wenzelm@55242
   773
  printing of proof states take precedence, but an already running
wenzelm@55242
   774
  tool is not canceled and may thus reduce reactivity of proof
wenzelm@55242
   775
  document processing.
wenzelm@55242
   776
wenzelm@55242
   777
  Users should experiment how the available CPU resources (number of
wenzelm@55242
   778
  cores) are best invested to get additional feedback from prover in
wenzelm@55242
   779
  the background, by using weaker or stronger tools.  *}
wenzelm@55241
   780
wenzelm@55241
   781
wenzelm@55241
   782
section {* Sledgehammer \label{sec:sledgehammer} *}
wenzelm@55241
   783
wenzelm@55244
   784
text {* The \emph{Sledgehammer} panel (\figref{fig:sledgehammer})
wenzelm@55244
   785
  provides a view on some independent execution of @{command
wenzelm@55244
   786
  sledgehammer}, with process indicator (spinning wheel) and GUI
wenzelm@55244
   787
  elements for important Sledgehammer arguments and options.  Any
wenzelm@55244
   788
  number of Sledgehammer panels may be active, according to the
wenzelm@55244
   789
  standard policies of Dockable Window Management in jEdit.  Closing a
wenzelm@55244
   790
  window also cancels the corresponding prover tasks.
wenzelm@55244
   791
wenzelm@55245
   792
  \begin{figure}[htb]
wenzelm@55244
   793
  \begin{center}
wenzelm@55244
   794
  \includegraphics[scale=0.3]{sledgehammer}
wenzelm@55244
   795
  \end{center}
wenzelm@55244
   796
  \caption{An instance of the Sledgehammer panel}
wenzelm@55244
   797
  \label{fig:sledgehammer}
wenzelm@55244
   798
  \end{figure}
wenzelm@55243
   799
wenzelm@55243
   800
  The \emph{Apply} button attaches a fresh invocation of @{command
wenzelm@55243
   801
  sledgehammer} to the command where the cursor is pointing in the
wenzelm@55243
   802
  text --- this should be some pending proof problem.  Further buttons
wenzelm@55243
   803
  like \emph{Cancel} and \emph{Locate} help to manage the running
wenzelm@55243
   804
  process.
wenzelm@55243
   805
wenzelm@55243
   806
  Results appear incrementally in the output window of the panel.
wenzelm@55243
   807
  Proposed proof snippets are marked up as \emph{sendback}, which
wenzelm@55243
   808
  means a single mouse click inserts the text into a suitable place of
wenzelm@55243
   809
  the original source.  Some manual editing may be required
wenzelm@55243
   810
  nonetheless, say to remove earlier proof attempts. *}
wenzelm@55241
   811
wenzelm@55241
   812
wenzelm@55241
   813
section {* Find theorems *}
wenzelm@55241
   814
wenzelm@55244
   815
text {* The \emph{Find} panel (\figref{fig:find}) provides an
wenzelm@55244
   816
  independent view for @{command find_theorems}.  The main text field
wenzelm@55244
   817
  accepts search criteria according to the syntax @{syntax
wenzelm@55244
   818
  thmcriterium} given in \cite{isabelle-isar-ref}.  Further options of
wenzelm@55244
   819
  @{command find_theorems} are available via GUI elements.
wenzelm@55244
   820
wenzelm@55245
   821
  \begin{figure}[htb]
wenzelm@55244
   822
  \begin{center}
wenzelm@55244
   823
  \includegraphics[scale=0.3]{find}
wenzelm@55244
   824
  \end{center}
wenzelm@55244
   825
  \caption{An instance of the Find panel}
wenzelm@55244
   826
  \label{fig:find}
wenzelm@55244
   827
  \end{figure}
wenzelm@55243
   828
wenzelm@55243
   829
  The \emph{Apply} button attaches a fresh invocation of @{command
wenzelm@55243
   830
  find_theorems} to the current context of the command where the
wenzelm@55243
   831
  cursor is pointing in the text, unless an alternative theory context
wenzelm@55243
   832
  (from the underlying logic image) is specified explicitly. *}
wenzelm@55241
   833
wenzelm@55241
   834
wenzelm@55246
   835
chapter {* Miscellaneous tools *}
wenzelm@55246
   836
wenzelm@55246
   837
section {* SideKick *}
wenzelm@55246
   838
wenzelm@55246
   839
text {* The \emph{SideKick} plugin of jEdit provides some general
wenzelm@55246
   840
  services to display buffer structure in a tree view.
wenzelm@55246
   841
wenzelm@55246
   842
  Isabelle/jEdit provides SideKick parsers for its main mode for
wenzelm@55246
   843
  theory files, as well as some minor modes for the @{verbatim NEWS}
wenzelm@55246
   844
  file, session @{verbatim ROOT} files, and @{verbatim options}.
wenzelm@55246
   845
wenzelm@55246
   846
  Moreover, the special SideKick parser @{verbatim "isabelle-markup"}
wenzelm@55246
   847
  provides access to the full (uninterpreted) markup tree of the PIDE
wenzelm@55246
   848
  document model of the current buffer.  This is occasionally useful
wenzelm@55246
   849
  for informative purposes, but the amount of displayed information
wenzelm@55246
   850
  might cause problems for large buffers, both for the human and the
wenzelm@55246
   851
  machine.
wenzelm@55246
   852
*}
wenzelm@55246
   853
wenzelm@55246
   854
wenzelm@55247
   855
section {* Timing *}
wenzelm@55247
   856
wenzelm@55247
   857
text {* Managed evaluation of commands within PIDE documents includes
wenzelm@55247
   858
  timing information, which consists of elapsed (wall-clock) time, CPU
wenzelm@55247
   859
  time, and GC (garbage collection) time.  Note that in a
wenzelm@55247
   860
  multithreaded system it is difficult to measure execution time
wenzelm@55247
   861
  precisely: elapsed time is closer to the real requirements of
wenzelm@55247
   862
  runtime resources than CPU or GC time, which are both subject to
wenzelm@55247
   863
  influences from the parallel environment that are outside the scope
wenzelm@55247
   864
  of the current command transaction.
wenzelm@55247
   865
wenzelm@55247
   866
  The \emph{Timing} panel provides an overview of cumulative command
wenzelm@55247
   867
  timings for each document node.  Commands with elapsed time below
wenzelm@55247
   868
  the given threshold are ignored in the grand total.  Nodes are
wenzelm@55247
   869
  sorted according to their overall timing.  For the document node
wenzelm@55247
   870
  that corresponds to the current buffer, individual command timings
wenzelm@55247
   871
  are shown as well.  A double-click on a theory node or command moves
wenzelm@55247
   872
  the editor focus to that particular source position.
wenzelm@55247
   873
wenzelm@55247
   874
  It is also possible to reveal individual timing information via some
wenzelm@55247
   875
  tooltip for the corresponding command keyword, using the technique
wenzelm@55247
   876
  of mouse hovering with @{verbatim CONTROL}/@{verbatim COMMAND}
wenzelm@55247
   877
  modifier key as explained in \secref{sec:tooltips-hyperlinks}.
wenzelm@55247
   878
  Actual display of timing depends on the global option
wenzelm@55247
   879
  @{system_option jedit_timing_threshold}, which can be configured in
wenzelm@55247
   880
  "Plugin Options / Isabelle / General".  *}
wenzelm@55247
   881
wenzelm@55247
   882
wenzelm@55246
   883
section {* Isabelle/Scala console *}
wenzelm@55246
   884
wenzelm@55246
   885
text {* The \emph{Console} plugin of jEdit manages various shells
wenzelm@55246
   886
  (command interpreters), e.g.\ \emph{BeanShell}, which is the
wenzelm@55246
   887
  official jEdit scripting language, and the somewhat
wenzelm@55246
   888
  platform-independent \emph{System} shell.  Thus the console provides
wenzelm@55246
   889
  similar functionality than the special buffers @{verbatim
wenzelm@55246
   890
  "*scratch*"} and @{verbatim "*shell*"} in Emacs.
wenzelm@55246
   891
wenzelm@55246
   892
  Isabelle/jEdit extends the repertoire of the console by
wenzelm@55246
   893
  \emph{Scala}, which is the regular Scala toplevel loop running
wenzelm@55246
   894
  inside the \emph{same} JVM process as Isabelle/jEdit itself.  This
wenzelm@55246
   895
  means the Scala command interpreter has access to the JVM name space
wenzelm@55246
   896
  and state of the running Prover IDE application: the main entry
wenzelm@55246
   897
  points are @{verbatim view} (the current editor view of jEdit) and
wenzelm@55246
   898
  @{verbatim PIDE} (the Isabelle/jEdit plugin object).
wenzelm@55246
   899
wenzelm@55246
   900
  For example, the subsequent Scala snippet gets the PIDE document
wenzelm@55246
   901
  model of the current buffer within the current editor view:
wenzelm@55246
   902
wenzelm@55246
   903
  \begin{center}
wenzelm@55246
   904
  @{verbatim "PIDE.document_model(view.getBuffer).get"}
wenzelm@55246
   905
  \end{center}
wenzelm@55246
   906
wenzelm@55246
   907
  This helps to explore Isabelle/Scala functionality interactively.
wenzelm@55246
   908
  Some care is required to avoid interference with the internals of
wenzelm@55246
   909
  the running application, especially in production use.  *}
wenzelm@55246
   910
wenzelm@55246
   911
wenzelm@55246
   912
section {* Low-level output *}
wenzelm@55246
   913
wenzelm@55246
   914
text {* Prover output is normally shown directly in the main text area
wenzelm@55246
   915
  or adjacent \emph{Output} panels, as explained in
wenzelm@55246
   916
  \secref{sec:prover-output}.
wenzelm@55246
   917
wenzelm@55246
   918
  Beyond this, it is occasionally useful to inspect low-level output
wenzelm@55246
   919
  channels via some of the following additional panels:
wenzelm@55246
   920
wenzelm@55246
   921
  \begin{itemize}
wenzelm@55246
   922
wenzelm@55246
   923
  \item \emph{Protocol} shows internal messages between the
wenzelm@55246
   924
  Isabelle/Scala and Isabelle/ML side of the PIDE editing protocol.
wenzelm@55246
   925
  Recording of messages starts with the first activation of the
wenzelm@55246
   926
  corresponding dockable window; earlier messages are lost.
wenzelm@55246
   927
wenzelm@55246
   928
  Actual display of protocol messages causes considerable slowdown, so
wenzelm@55246
   929
  it is important to ``undock'' the \emph{Protocol} panel for
wenzelm@55246
   930
  production work.
wenzelm@55246
   931
wenzelm@55246
   932
  \item \emph{Raw Output} shows chunks of text from the @{verbatim
wenzelm@55246
   933
  stdout} and @{verbatim stderr} channels of the prover process.
wenzelm@55246
   934
  Recording of output starts with the first activation of the
wenzelm@55246
   935
  corresponding dockable window; earlier output is lost.
wenzelm@55246
   936
wenzelm@55246
   937
  The implicit stateful nature of physical I/O channels makes it
wenzelm@55246
   938
  difficult to relate raw output to the actual command from where it
wenzelm@55246
   939
  was originating.  Parallel execution may add to the confusion.
wenzelm@55246
   940
  Peeking at physical process I/O is only the last resort to diagnose
wenzelm@55246
   941
  problems with tools that are not fully PIDE compliant.
wenzelm@55246
   942
wenzelm@55246
   943
  Under normal circumstances, prover output always works via managed
wenzelm@55246
   944
  message channels (corresponding to @{ML writeln}, @{ML warning},
wenzelm@55246
   945
  @{ML error} etc.\ in Isabelle/ML), which are displayed by regular
wenzelm@55246
   946
  means within the document model (\secref{sec:prover-output}).
wenzelm@55246
   947
wenzelm@55246
   948
  \item \emph{Syslog} shows system messages that might be relevant to
wenzelm@55246
   949
  diagnose problems with the startup or shutdown phase of the prover
wenzelm@55246
   950
  process; this also includes raw output on @{verbatim stderr}.
wenzelm@55246
   951
wenzelm@55246
   952
  A limited amount of syslog messages are buffered, independently of
wenzelm@55246
   953
  the docking state of the \emph{Syslog} panel.  This allows to
wenzelm@55246
   954
  diagnose serious problems with Isabelle/PIDE process management,
wenzelm@55246
   955
  outside of the actual protocol layer.
wenzelm@55246
   956
wenzelm@55246
   957
  Under normal situations, such low-level system output can be
wenzelm@55246
   958
  ignored.
wenzelm@55246
   959
wenzelm@55246
   960
  \end{itemize}
wenzelm@55246
   961
*}
wenzelm@55246
   962
wenzelm@55246
   963
wenzelm@55217
   964
chapter {* Known problems and workarounds \label{sec:problems} *}
wenzelm@54907
   965
wenzelm@54907
   966
text {*
wenzelm@54907
   967
  \begin{itemize}
wenzelm@54907
   968
wenzelm@54907
   969
  \item \textbf{Problem:} Lack of dependency management for auxiliary files
wenzelm@54908
   970
  that contribute to a theory (e.g.\ @{command ML_file}).
wenzelm@54907
   971
wenzelm@55218
   972
  \textbf{Workaround:} Re-load files manually within the prover, by
wenzelm@55218
   973
  editing corresponding command in the text.
wenzelm@54907
   974
wenzelm@54907
   975
  \item \textbf{Problem:} Odd behavior of some diagnostic commands with
wenzelm@54907
   976
  global side-effects, like writing a physical file.
wenzelm@54907
   977
wenzelm@54907
   978
  \textbf{Workaround:} Avoid such commands.
wenzelm@54907
   979
wenzelm@54907
   980
  \item \textbf{Problem:} No way to delete document nodes from the overall
wenzelm@54907
   981
  collection of theories.
wenzelm@54907
   982
wenzelm@55217
   983
  \textbf{Workaround:} Ignore unused files.  Restart whole
wenzelm@55217
   984
  Isabelle/jEdit session in worst-case situation.
wenzelm@54907
   985
wenzelm@55218
   986
  \item \textbf{Problem:} Keyboard shortcuts @{verbatim "C+PLUS"} and
wenzelm@55218
   987
  @{verbatim "C+MINUS"} for adjusting the editor font size depend on
wenzelm@55218
   988
  platform details and national keyboards.
wenzelm@55218
   989
wenzelm@55218
   990
  \textbf{Workaround:} Use numeric keypad or rebind keys in the
wenzelm@55218
   991
  jEdit Shortcuts options dialog.
wenzelm@55218
   992
wenzelm@55023
   993
  \item \textbf{Problem:} The Mac OS X keyboard shortcut @{verbatim
wenzelm@55237
   994
  "COMMAND+COMMA"} for application \emph{Preferences} is in conflict
wenzelm@55237
   995
  with the jEdit default shortcut for \emph{Incremental Search Bar}
wenzelm@55237
   996
  (action @{verbatim "quick-search"}).
wenzelm@54907
   997
wenzelm@55023
   998
  \textbf{Workaround:} Remap in jEdit manually according to national
wenzelm@55023
   999
  keyboard, e.g.\ @{verbatim "COMMAND+SLASH"} on English ones.
wenzelm@54907
  1000
wenzelm@55237
  1001
  \item \textbf{Problem:} Mac OS X system fonts sometimes lead to
wenzelm@55237
  1002
  character drop-outs in the main text area.
wenzelm@55237
  1003
wenzelm@55237
  1004
  \textbf{Workaround:} Use the default @{verbatim IsabelleText} font.
wenzelm@55237
  1005
  (Do not install that font on the system.)
wenzelm@55237
  1006
wenzelm@55217
  1007
  \item \textbf{Problem:} Some Linux / X11 input methods such as IBus
wenzelm@55218
  1008
  tend to disrupt key event handling of Java/AWT/Swing.
wenzelm@55217
  1009
wenzelm@55217
  1010
  \textbf{Workaround:} Do not use input methods, reset the environment
wenzelm@55217
  1011
  variable @{verbatim XMODIFIERS} within Isabelle settings (default in
wenzelm@55217
  1012
  Isabelle2013-1).
wenzelm@55217
  1013
wenzelm@55217
  1014
  \item \textbf{Problem:} Some Linux / X11 window managers that are
wenzelm@55217
  1015
  not ``re-parenting'' cause problems with additional windows opened
wenzelm@55219
  1016
  by Java. This affects either historic or neo-minimalistic window
wenzelm@55219
  1017
  managers like @{verbatim awesome} or @{verbatim xmonad}.
wenzelm@55217
  1018
wenzelm@55217
  1019
  \textbf{Workaround:} Use regular re-parenting window manager.
wenzelm@55217
  1020
wenzelm@55217
  1021
  \item \textbf{Problem:} Recent forks of Linux / X11 window managers
wenzelm@55217
  1022
  and desktop environments (variants of Gnome) disrupt the handling of
wenzelm@55217
  1023
  menu popups and mouse positions of Java/AWT/Swing.
wenzelm@55217
  1024
wenzelm@55217
  1025
  \textbf{Workaround:} Use mainstream versions of Linux desktops.
wenzelm@54907
  1026
wenzelm@55237
  1027
  \item \textbf{Problem:} Full-screen mode via jEdit action @{verbatim
wenzelm@55237
  1028
  "toggle-full-screen"} (default shortcut @{verbatim F11}) works on
wenzelm@55237
  1029
  Windows, but not on Mac OS X or various Linux / X11 window managers.
wenzelm@55237
  1030
wenzelm@55237
  1031
  \textbf{Workaround:} Use native full-screen control of the window
wenzelm@55237
  1032
  manager, if available (notably on Mac OS X).
wenzelm@55237
  1033
wenzelm@55237
  1034
  \item \textbf{Problem:} Full-screen mode and dockable windows in
wenzelm@55237
  1035
  \emph{floating} state may lead to confusion about window placement
wenzelm@55237
  1036
  (depending on platform characteristics).
wenzelm@55237
  1037
wenzelm@55237
  1038
  \textbf{Workaround:} Avoid this combination.
wenzelm@55237
  1039
wenzelm@54907
  1040
  \end{itemize}
wenzelm@54907
  1041
*}
wenzelm@54907
  1042
wenzelm@54906
  1043
end