src/Doc/JEdit/JEdit.thy
author wenzelm
Sat, 12 Oct 2013 14:37:45 +0200
changeset 55217 e0fa4bd16c80
parent 55211 d521407f8d0f
child 55218 2189d05622c4
permissions -rw-r--r--
misc tuning;
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@55217
    40
  allows to transfer algebraic datatypes 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@55209
    58
  Isabelle/Scala versus Scala, Isabelle/jEdit versus regular jEdit
wenzelm@55209
    59
  need to be taken into account when discussing any of these PIDE
wenzelm@55209
    60
  building blocks on public forums, mailing lists, or even scientific
wenzelm@55209
    61
  publications.
wenzelm@54906
    62
*}
wenzelm@54906
    63
wenzelm@54907
    64
wenzelm@54907
    65
section {* The Isabelle/jEdit Prover IDE *}
wenzelm@54907
    66
wenzelm@54907
    67
text {*
wenzelm@54910
    68
  \includegraphics[width=\textwidth]{isabelle-jedit}
wenzelm@54910
    69
wenzelm@55209
    70
  Isabelle/jEdit consists of some plugins for the well-known jEdit
wenzelm@55209
    71
  text editor \url{http://www.jedit.org}, according to the following
wenzelm@54907
    72
  principles.
wenzelm@54907
    73
wenzelm@54907
    74
  \begin{itemize}
wenzelm@54907
    75
wenzelm@55209
    76
  \item The original jEdit look-and-feel is generally preserved,
wenzelm@55209
    77
  although some default properties have been changed to accommodate
wenzelm@55209
    78
  Isabelle (e.g.\ the text area font).
wenzelm@54907
    79
wenzelm@55209
    80
  \item Formal Isabelle/Isar text is checked asynchronously while
wenzelm@55209
    81
  editing.  The user is in full command of the editor, and the prover
wenzelm@55209
    82
  refrains from locking portions of the buffer.
wenzelm@54907
    83
wenzelm@54907
    84
  \item Prover feedback works via colors, boxes, squiggly underline,
wenzelm@55209
    85
  hyperlinks, popup windows, icons, clickable output, all based on
wenzelm@55209
    86
  semantic markup produced by Isabelle in the background.
wenzelm@54907
    87
wenzelm@55209
    88
  \item Using the mouse together with the modifier key @{verbatim
wenzelm@55209
    89
  CONTROL} (Linux, Windows) or @{verbatim COMMAND} (Mac OS X) exposes
wenzelm@55209
    90
  additional formal content via tooltips and/or hyperlinks.
wenzelm@54907
    91
wenzelm@55209
    92
  \item Formal output (in popups etc.) may be explored recursively,
wenzelm@55209
    93
  using the same techniques as in the editor source buffer.
wenzelm@54907
    94
wenzelm@55217
    95
  \item Additional panels (e.g.\ \emph{Output}, \emph{Symbols}) are
wenzelm@55217
    96
  organized by the Dockable Window Manager of jEdit, which also allows
wenzelm@55217
    97
  multiple floating instances of each window class.
wenzelm@55217
    98
wenzelm@55209
    99
  \item The prover process and source files are managed on the editor
wenzelm@55209
   100
  side.  The prover operates on timeless and stateless document
wenzelm@55209
   101
  content via Isabelle/Scala.
wenzelm@54907
   102
wenzelm@55209
   103
  \item Plugin options of jEdit (for the \emph{Isabelle} plugin) give
wenzelm@55209
   104
  access to a selection of Isabelle/Scala options and its persistence
wenzelm@55209
   105
  preferences, usually with immediate effect on the prover back-end or
wenzelm@55209
   106
  editor front-end.
wenzelm@54907
   107
wenzelm@54907
   108
  \item The logic image of the prover session may be specified within
wenzelm@54907
   109
  Isabelle/jEdit, but this requires restart. The new image is provided
wenzelm@55208
   110
  automatically by the Isabelle build tool.
wenzelm@54907
   111
wenzelm@54907
   112
  \end{itemize}
wenzelm@54907
   113
*}
wenzelm@54907
   114
wenzelm@54907
   115
wenzelm@55209
   116
subsection {* Documentation *}
wenzelm@55209
   117
wenzelm@55209
   118
text {* Regular jEdit documentation is accessible via its @{verbatim
wenzelm@55209
   119
  Help} menu or @{verbatim F1} keyboard shortcut. This includes a full
wenzelm@55209
   120
  \emph{User's Guide} and \emph{Frequently Asked Questions} for this
wenzelm@55209
   121
  sophisticated text editor.
wenzelm@55209
   122
wenzelm@55217
   123
  Most of this information about jEdit is relevant for Isabelle/jEdit
wenzelm@55217
   124
  as well, but one needs to keep in mind that defaults sometimes
wenzelm@55217
   125
  differ, and the official jEdit documentation does not know about the
wenzelm@55217
   126
  Isabelle plugin with its special support for theory editing.
wenzelm@55209
   127
*}
wenzelm@55209
   128
wenzelm@55209
   129
wenzelm@55209
   130
subsection {* Plugins *}
wenzelm@55209
   131
wenzelm@55209
   132
text {* The \emph{Plugin Manager} of jEdit allows to augment editor
wenzelm@55209
   133
  functionality by JVM modules (jars) that are provided by the central
wenzelm@55209
   134
  plugin repository, or one of various mirror sites. The main
wenzelm@55217
   135
  \emph{Isabelle} plugin is an integral part of Isabelle/jEdit needs
wenzelm@55217
   136
  to remain active at all times! A few additional plugins are bundled
wenzelm@55209
   137
  with Isabelle/jEdit for convenience or out of necessity, notably
wenzelm@55209
   138
  \emph{Console} with its Isabelle/Scala sub-plugin and
wenzelm@55217
   139
  \emph{SideKick} with some Isabelle-specific parsers for document
wenzelm@55217
   140
  tree structure.
wenzelm@55209
   141
wenzelm@55209
   142
  Connecting to the plugin server infrastructure of the jEdit project
wenzelm@55209
   143
  allows to update bundled plugins or to add further
wenzelm@55209
   144
  functionality. This needs to be done with the usual care for such an
wenzelm@55209
   145
  open bazaar, with contributions of very mixed quality. Arbitrary
wenzelm@55209
   146
  combinations of add-on features are apt to cause problems.
wenzelm@55209
   147
wenzelm@55209
   148
  It is advisable to start with the default configuration of
wenzelm@55209
   149
  Isabelle/jEdit and develop some understanding how it is supposed to
wenzelm@55209
   150
  work, before loading additional plugins at a grand scale.
wenzelm@55209
   151
*}
wenzelm@55209
   152
wenzelm@55209
   153
wenzelm@55209
   154
subsection {* Options *}
wenzelm@55209
   155
wenzelm@55217
   156
text {* Both jEdit and Isabelle have distinctive management of
wenzelm@55217
   157
  persistent options.  Regular jEdit options are accessible via the
wenzelm@55217
   158
  dialogs for \emph{Global Options} and \emph{Plugin Options}.  This
wenzelm@55217
   159
  results in an environment of properties that is stored within the
wenzelm@55209
   160
  \emph{settings directory} of jEdit; see also the menu
wenzelm@55209
   161
  \emph{Utilities / Settings Directory}.
wenzelm@55209
   162
wenzelm@55217
   163
  Isabelle system options are managed by Isabelle/Scala; see also
wenzelm@55217
   164
  \cite{isabelle-sys}, especially the coverage of sessions and
wenzelm@55217
   165
  command-line tools like @{tool build} or @{tool options}.  Isabelle
wenzelm@55217
   166
  options that are declared as \textbf{public} are exposed to the
wenzelm@55217
   167
  jEdit \emph{Plugin Options} dialog, in its section \emph{Isabelle /
wenzelm@55217
   168
  General}.  This provides a view on Isabelle options and persistent
wenzelm@55217
   169
  preferences in @{verbatim "$ISABELLE_HOME_USER/etc/preferences"},
wenzelm@55217
   170
  independently of the jEdit properties in its settings directory.
wenzelm@55209
   171
wenzelm@55209
   172
  Some Isabelle options that are accessible in the Isabelle/jEdit
wenzelm@55209
   173
  Plugin Options dialog affect general parameters that are relevant
wenzelm@55209
   174
  outside Isabelle/jEdit as well, e.g.\ @{system_option threads} or
wenzelm@55209
   175
  @{system_option parallel_proofs} for the Isabelle build tool
wenzelm@55209
   176
  \cite{isabelle-sys}.
wenzelm@55217
   177
wenzelm@55217
   178
  \medskip Options are loaded once on startup and saved on shutdown of
wenzelm@55217
   179
  Isabelle/jEdit.  Editing the machine-generated files @{verbatim
wenzelm@55217
   180
  "$ISABELLE_HOME_USER/jedit/properties"} or @{verbatim
wenzelm@55217
   181
  "$ISABELLE_HOME_USER/etc/preferences"} manually while the
wenzelm@55217
   182
  application is running is likely to cause a lost-update!  *}
wenzelm@55209
   183
wenzelm@55209
   184
wenzelm@55209
   185
subsection {* Keymaps *}
wenzelm@55209
   186
wenzelm@55209
   187
text {* Keyboard shortcuts used to be managed as jEdit properties in
wenzelm@55209
   188
  the past, but recent versions (2013) have a separate concept of
wenzelm@55209
   189
  \emph{keymap}.  The ``imported'' keymap is produced initially from
wenzelm@55209
   190
  the environment of properties that is available at the first start
wenzelm@55209
   191
  of the editor.
wenzelm@55209
   192
wenzelm@55209
   193
  This is relevant for Isabelle/jEdit due to various fine-tuning of
wenzelm@55209
   194
  default properties, and additional keyboard shortcuts for Isabelle
wenzelm@55209
   195
  specific functionality. Users may change their keymap later on, but
wenzelm@55217
   196
  may need to copy Isabelle-specific key bindings manually.
wenzelm@55209
   197
*}
wenzelm@55209
   198
wenzelm@55209
   199
wenzelm@55210
   200
subsection {* Look-and-feel *}
wenzelm@55209
   201
wenzelm@55209
   202
text {* jEdit is a Java/Swing application with some ambition to
wenzelm@55217
   203
  support ``native'' look-and-feel on all platforms, within the limits
wenzelm@55217
   204
  of what Oracle as Java provider and major operating system vendors
wenzelm@55217
   205
  and distributors allow (see also \secref{sec:problems}).
wenzelm@55209
   206
wenzelm@55217
   207
  Isabelle/jEdit enables platform-specific look-and-feel by default as
wenzelm@55217
   208
  follows.
wenzelm@55209
   209
wenzelm@55209
   210
  \begin{description}
wenzelm@55209
   211
wenzelm@55209
   212
  \item[Linux] The platform-independent \emph{Nimbus} is used by
wenzelm@55210
   213
  default, but the classic \emph{Metal} also works.  \emph{GTK+} works
wenzelm@55210
   214
  under the side-condition that the overall GTK theme is selected in a
wenzelm@55217
   215
  Java/Swing friendly way.
wenzelm@55209
   216
wenzelm@55209
   217
  \item[Windows] Regular \emph{Windows} is used by default, but
wenzelm@55209
   218
  platform-independent \emph{Nimbus} and \emph{Metal} also work.
wenzelm@55209
   219
wenzelm@55217
   220
  \item[Mac OS X] Standard \emph{Apple Aqua} is used by default.
wenzelm@55209
   221
  Moreover the bundled \emph{MacOSX} plugin provides various functions
wenzelm@55209
   222
  that are expected from applications on that particular platform:
wenzelm@55209
   223
  quit from menu or dock, preferences menu, drag-and-drop of text
wenzelm@55209
   224
  files on the application, full-screen mode for main editor windows
wenzelm@55209
   225
  etc.
wenzelm@55209
   226
wenzelm@55209
   227
  \end{description}
wenzelm@55209
   228
wenzelm@55209
   229
  Users may experiment with different look-and-feels, but need to keep
wenzelm@55217
   230
  in mind that this extra variance of GUI functionality is unlikely to
wenzelm@55217
   231
  work in arbitrary combinations.  The \emph{GTK+} look-and-feel is
wenzelm@55209
   232
  particularly critical due to its additional dimension of ``themes''.
wenzelm@55209
   233
wenzelm@55209
   234
  After changing the look-and-feel in \emph{Global Options /
wenzelm@55209
   235
  Appearance}, it is advisable to restart Isabelle/jEdit in order to
wenzelm@55209
   236
  take full effect.
wenzelm@55209
   237
*}
wenzelm@55209
   238
wenzelm@55209
   239
wenzelm@54907
   240
chapter {* Prover IDE functionality *}
wenzelm@54907
   241
wenzelm@55210
   242
section {* Buffers and theories *}
wenzelm@55209
   243
wenzelm@55210
   244
text {* jEdit maintains a collection of open \emph{text buffers} to
wenzelm@55210
   245
  store source files.  Each buffer may be associated with any number
wenzelm@55217
   246
  of visible \emph{text areas}.  Buffers are subject to an
wenzelm@55217
   247
  \emph{editor mode} that is determined from the file type.  Files
wenzelm@55217
   248
  with extension \texttt{.thy} are assigned to the mode
wenzelm@55217
   249
  \emph{isabelle} and treated specifically.
wenzelm@55209
   250
wenzelm@55217
   251
  \medskip Isabelle theory files are automatically added to the formal
wenzelm@55217
   252
  document model of Isabelle/Scala, which maintains a family of
wenzelm@55217
   253
  versions of all sources for the prover.  The \emph{Theories} panel
wenzelm@55217
   254
  provides an overview of the status of continuous checking of theory
wenzelm@55217
   255
  sources.  Unlike batch sessions \cite{isabelle-sys}, theory nodes
wenzelm@55217
   256
  are identified by full path names; this allows to work with multiple
wenzelm@55217
   257
  (disjoint) Isabelle sessions simultaneously within the same editor
wenzelm@55217
   258
  session.
wenzelm@55209
   259
wenzelm@55217
   260
  Certain events to open or update buffers with theory files cause
wenzelm@55217
   261
  Isabelle/jEdit to resolve dependencies of \emph{theory imports}.
wenzelm@55217
   262
  The system requests to load further files into jEdit editor buffers,
wenzelm@55217
   263
  to be added to the theory document model for further checking.  It
wenzelm@55217
   264
  is also possible to resolve dependencies automatically, depending on
wenzelm@55217
   265
  the option @{system_option jedit_auto_load}.
wenzelm@55209
   266
wenzelm@55217
   267
  \medskip The open text area views on theory buffers define the
wenzelm@55217
   268
  visible \emph{perspective} of Isabelle/jEdit.  This is taken as a
wenzelm@55217
   269
  hint for document processing: the prover ensures that those parts of
wenzelm@55217
   270
  a theory where the user is looking are checked, while other parts
wenzelm@55217
   271
  that are presently not required are ignored.
wenzelm@55210
   272
wenzelm@55217
   273
  The perspective can be changed by opening or closing text areas
wenzelm@55217
   274
  windows, or scrolling within some window.  It is also possible to
wenzelm@55210
   275
  indicate theory nodes as \emph{required} for continuous checking in
wenzelm@55210
   276
  the \emph{Theories} panel.  This means such nodes and all their
wenzelm@55210
   277
  imports are always processed, independently of the visibility
wenzelm@55210
   278
  status.  This can have significant impact on performance, though.
wenzelm@55210
   279
wenzelm@55210
   280
  \medskip Formal markup of checked theory content is turned into GUI
wenzelm@55210
   281
  rendering, based on a standard repertoire known from IDEs for
wenzelm@55210
   282
  programming languages: colors, icons, highlighting, squiggly
wenzelm@55217
   283
  underline, tooltips, hyperlinks etc.  For outer syntax of
wenzelm@55217
   284
  Isabelle/Isar there is some traditional syntax-highlighting, based
wenzelm@55217
   285
  on static keyword tables and tokenization within the editor.  In
wenzelm@55217
   286
  contrast, the painting of inner syntax (term language etc.)  is
wenzelm@55217
   287
  based on semantic information that is reported dynamically from the
wenzelm@55217
   288
  logical context.  Thus the prover can provide additional markup to
wenzelm@55217
   289
  help the user understanding the meaning of the text, and to produce
wenzelm@55217
   290
  more text with some add-on tools (e.g.\ information messages by
wenzelm@55217
   291
  automated provers or disprovers running in the background).
wenzelm@55210
   292
wenzelm@55210
   293
  Such formally annotated text can be explored further by using the
wenzelm@55217
   294
  @{verbatim CONTROL} modifier key on Linux and Windows, or @{verbatim
wenzelm@55210
   295
  COMMAND} on Mac OS X.  Hovering with the mouse while the modifier is
wenzelm@55210
   296
  pressed reveals \emph{tooltips} (grey box within the text with a
wenzelm@55210
   297
  yellow popup) and/or \emph{hyperlinks} (dark grey rectangle within
wenzelm@55210
   298
  the text).  Tooltip popups use the same rendering principles as the
wenzelm@55210
   299
  main text area, and further tooltips and/or hyperlinks may be
wenzelm@55210
   300
  exposed recursively by the same mechanism.
wenzelm@55211
   301
wenzelm@55211
   302
  %FIXME screenshot of term "x = x" with typing/sorting
wenzelm@55210
   303
*}
wenzelm@55209
   304
wenzelm@55209
   305
wenzelm@54907
   306
section {* Isabelle symbols and fonts *}
wenzelm@54907
   307
wenzelm@55211
   308
text {* Isabelle sources consist of \emph{symbols} that extend plain
wenzelm@55211
   309
  ASCII and UTF-8 (for informal text) to allow infinitely many
wenzelm@55217
   310
  mathematical symbols within the formal sources.  This works without
wenzelm@55217
   311
  depending on particular encodings or varying Unicode standards
wenzelm@55217
   312
  \cite{Wenzel:2011:CICM}.
wenzelm@55211
   313
wenzelm@55211
   314
  For the prover back-end, formal text consists of ASCII characters
wenzelm@55211
   315
  that are grouped according to some simple rules, e.g.\ as plain
wenzelm@55211
   316
  ``@{verbatim a}'' or symbolic ``@{verbatim "\<alpha>"}''.
wenzelm@55211
   317
wenzelm@55217
   318
  For the editor front-end, a certain subset of symbols is rendered as
wenzelm@55211
   319
  Unicode glyphs, in order to show ``@{verbatim "\<alpha>"}'' as actual
wenzelm@55211
   320
  ``@{text "\<alpha>"}''.  This symbol interpretation is specified by the
wenzelm@55211
   321
  Isabelle system distribution (in @{file
wenzelm@55217
   322
  "$ISABELLE_HOME/etc/symbols"}) or by the user (in @{verbatim
wenzelm@55211
   323
  "$ISABELLE_HOME_USER/etc/symbols"}).
wenzelm@55211
   324
wenzelm@55217
   325
  The appendix of \cite{isabelle-isar-ref} gives an overview of the
wenzelm@55217
   326
  standard interpretation of finitely many symbols from the infinite
wenzelm@55217
   327
  collection.  Uninterpreted symbols are shown literally.
wenzelm@54907
   328
wenzelm@55211
   329
  \medskip Technically, the Unicode view on Isabelle symbols is an
wenzelm@55211
   330
  \emph{encoding} in Isabelle/jEdit, which is called @{verbatim
wenzelm@55211
   331
  "UTF-8-Isabelle"} and enabled by default.  Sometimes such defaults
wenzelm@55211
   332
  are reset accidentally, or malformed UTF-8 sequences in the text
wenzelm@55211
   333
  force jEdit to fall back on a different encoding like @{verbatim
wenzelm@55211
   334
  "ISO-8859-15"}.  In the latter case, raw @{verbatim "\<alpha>"} will be
wenzelm@55211
   335
  shown in the text buffer instead of its Unicode rendering @{text
wenzelm@55211
   336
  "\<alpha>"}.  The jEdit menu operation \emph{File / Reload with Encoding /
wenzelm@55211
   337
  UTF-8-Isabelle} helps to resolve such problems, potentially after
wenzelm@55211
   338
  repairing malformed parts of the text.
wenzelm@55211
   339
wenzelm@55217
   340
  \medskip Correct rendering via Unicode requires a font that contains
wenzelm@55217
   341
  glyphs for the corresponding codepoints.  Most system fonts lack
wenzelm@55217
   342
  that, so Isabelle/jEdit prefers its own application font @{verbatim
wenzelm@55217
   343
  IsabelleText} by default, which ensures that standard collection of
wenzelm@55217
   344
  Isabelle symbols are actually seen on the screen (or printer).
wenzelm@55217
   345
wenzelm@55217
   346
  Note that a Java/Swing application can load additional fonts only if
wenzelm@55217
   347
  they are not installed as system font already!  This means some old
wenzelm@55217
   348
  version of @{verbatim IsabelleText} that happens to be already
wenzelm@55217
   349
  present prevents Isabelle/jEdit from using its current bundled
wenzelm@55217
   350
  version.  This might result in missing glyphs (black rectangles),
wenzelm@55217
   351
  since obsolete versions of @{verbatim IsabelleText} lack recent
wenzelm@55217
   352
  improvements of Unicode glyph coverage.  This problem can be avoided
wenzelm@55217
   353
  by refraining to ``install'' any version of @{verbatim IsabelleText}
wenzelm@55217
   354
  in the first place.
wenzelm@55217
   355
wenzelm@55211
   356
  \medskip \paragraph{Input methods.} In principle, Isabelle/jEdit
wenzelm@55211
   357
  could delegate the problem to produce Isabelle symbols in their
wenzelm@55211
   358
  Unicode rendering to the underlying operating system and its
wenzelm@55217
   359
  \emph{input methods}.  Regular jEdit also provides various ways to
wenzelm@55217
   360
  work with \emph{abbreviations} to produce certain non-ASCII
wenzelm@55217
   361
  characters.  Since none of these standard input methods work
wenzelm@55217
   362
  satisfactorily for the mathematical characters required for
wenzelm@55217
   363
  Isabelle, various specific Isabelle/jEdit mechanisms are provided.
wenzelm@55211
   364
wenzelm@55217
   365
  Here is a summary for practically relevant input methods for
wenzelm@55217
   366
  Isabelle symbols.
wenzelm@55211
   367
wenzelm@54907
   368
  \begin{enumerate}
wenzelm@55211
   369
wenzelm@55211
   370
  \item The \emph{Symbols} panel with some GUI buttoms to insert
wenzelm@55211
   371
  certain symbols in the text buffer.  There are also tooltips to
wenzelm@55211
   372
  reveal to official Isabelle representation with some additional
wenzelm@55211
   373
  information about \emph{symbol abbreviations} (see below).
wenzelm@55211
   374
wenzelm@55211
   375
  \item Copy / paste from decoded source files: text that is rendered
wenzelm@55211
   376
  as Unicode already may get re-used to produce further such text.
wenzelm@55211
   377
  This also works between different applications, e.g.\ Isabelle/jEdit
wenzelm@55217
   378
  and some web browser or mail client, as long as the same Unicode
wenzelm@55217
   379
  view on Isabelle symbols is used uniformly.
wenzelm@55211
   380
wenzelm@55217
   381
  \item Copy / paste from prover output within Isabelle/jEdit.  The
wenzelm@55217
   382
  same principles as for text buffers apply, but note that \emph{copy}
wenzelm@55217
   383
  in Isabelle \emph{Output} works via the keyboard shortcut @{verbatim
wenzelm@55217
   384
  "C+c"}, not the jEdit menu.
wenzelm@55211
   385
wenzelm@55211
   386
  \item Completion provided by Isabelle plugin (see
wenzelm@55211
   387
  \secref{sec:completion}).  Isabelle symbols have a canonical name
wenzelm@55211
   388
  and optional abbreviations.  This can be used with the text
wenzelm@55211
   389
  completion mechanism of Isabelle/jEdit, to replace a prefix of the
wenzelm@55217
   390
  actual symbol like @{verbatim "\<lambda>"}, or its backslashed name
wenzelm@55217
   391
  @{verbatim "\\"}@{verbatim "lambda"}, or its ASCII abbreviation
wenzelm@55217
   392
  @{verbatim "%"}.
wenzelm@55211
   393
wenzelm@55211
   394
  The following table is an extract of the information provided by the
wenzelm@55217
   395
  standard @{file "$ISABELLE_HOME/etc/symbols"} file:
wenzelm@54907
   396
wenzelm@54907
   397
  \medskip
wenzelm@54907
   398
  \begin{tabular}{lll}
wenzelm@55217
   399
    \textbf{symbol} & \textbf{abbreviation} & \textbf{backslashed name} \\\hline
wenzelm@54908
   400
    @{text "\<lambda>"}   & @{verbatim "%"}     &  @{verbatim "\\lambda"}         \\
wenzelm@54908
   401
    @{text "\<Rightarrow>"}  & @{verbatim "=>"}    &  @{verbatim "\\Rightarrow"}     \\
wenzelm@54908
   402
    @{text "\<Longrightarrow>"} & @{verbatim "==>"}   &  @{verbatim "\\Longrightarrow"} \\
wenzelm@54907
   403
wenzelm@54908
   404
    @{text "\<And>"}  & @{verbatim "!!"}    &  @{verbatim "\\And"}            \\
wenzelm@54908
   405
    @{text "\<equiv>"}  & @{verbatim "=="}    &  @{verbatim "\\equiv"}          \\
wenzelm@54907
   406
wenzelm@54908
   407
    @{text "\<forall>"}   & @{verbatim "!"}     &  @{verbatim "\\forall"}         \\
wenzelm@54908
   408
    @{text "\<exists>"}   & @{verbatim "?"}     &  @{verbatim "\\exists"}         \\
wenzelm@54908
   409
    @{text "\<longrightarrow>"} & @{verbatim "-->"}   &  @{verbatim "\\longrightarrow"} \\
wenzelm@54908
   410
    @{text "\<and>"}   & @{verbatim "&"}     &  @{verbatim "\\and"}            \\
wenzelm@54908
   411
    @{text "\<or>"}   & @{verbatim "|"}     &  @{verbatim "\\or"}             \\
wenzelm@54908
   412
    @{text "\<not>"}   & @{verbatim "~"}     &  @{verbatim "\\not"}            \\
wenzelm@54908
   413
    @{text "\<noteq>"}   & @{verbatim "~="}    &  @{verbatim "\\noteq"}          \\
wenzelm@54908
   414
    @{text "\<in>"}   & @{verbatim ":"}     &  @{verbatim "\\in"}             \\
wenzelm@54908
   415
    @{text "\<notin>"}   & @{verbatim "~:"}    &  @{verbatim "\\notin"}          \\
wenzelm@54907
   416
  \end{tabular}
wenzelm@55217
   417
  \medskip
wenzelm@55217
   418
wenzelm@55217
   419
  Note that the above abbreviations refer to the input method. The
wenzelm@55217
   420
  logical notation provides ASCII alternatives that often coincide,
wenzelm@55217
   421
  but deviate occasionally.  Writing formal sources directly with
wenzelm@55217
   422
  ASCII replacement notation like @{verbatim "!"} or @{verbatim "ALL"}
wenzelm@55217
   423
  or @{verbatim "-->"} is considered very old fashioned in 2013!
wenzelm@54907
   424
wenzelm@54907
   425
  \end{enumerate}
wenzelm@54907
   426
wenzelm@55217
   427
  Raw Unicode characters within prover source files should be
wenzelm@55211
   428
  restricted to informal parts, e.g.\ to write text in non-latin
wenzelm@55211
   429
  alphabets.  Mathematical symbols should be defined via the official
wenzelm@55211
   430
  rendering tables, to avoid problems with portability and longterm
wenzelm@55211
   431
  storage of formal text.
wenzelm@54907
   432
wenzelm@55211
   433
  \paragraph{Control symbols.} There are some special control symbols
wenzelm@55217
   434
  to modify the style of a single symbol (without nesting). Control
wenzelm@55217
   435
  symbols may be applied to a region of selected text, either using
wenzelm@55217
   436
  the \emph{Symbols} panel or keyboard shortcuts; these editor
wenzelm@55217
   437
  operations produce a separate control symbol for each symbol in the
wenzelm@55217
   438
  text.
wenzelm@54907
   439
wenzelm@54907
   440
  \medskip
wenzelm@54907
   441
  \begin{tabular}{lll}
wenzelm@55209
   442
    \textbf{symbol}      & style       & keyboard shortcut \\\hline
wenzelm@55211
   443
    @{verbatim "\<^sup>"} & superscript & @{verbatim "C+e UP"} \\
wenzelm@55211
   444
    @{verbatim "\<^sub>"} & subscript   & @{verbatim "C+e DOWN"} \\
wenzelm@55211
   445
    @{verbatim "\<^bold>"} & bold face  & @{verbatim "C+e RIGHT"} \\
wenzelm@54907
   446
                          & reset      & @{verbatim "C+e LEFT"} \\
wenzelm@54907
   447
  \end{tabular}
wenzelm@55211
   448
wenzelm@55211
   449
  It is also possible to complete on @{verbatim "\\"}@{verbatim sup},
wenzelm@55211
   450
  @{verbatim "\\"}@{verbatim sub}, @{verbatim "\\"}@{verbatim bold} as
wenzelm@55211
   451
  for regular symbols.
wenzelm@54907
   452
*}
wenzelm@54907
   453
wenzelm@54907
   454
wenzelm@55211
   455
section {* Text completion \label{sec:completion} *}
wenzelm@54906
   456
wenzelm@55118
   457
text {*
wenzelm@55118
   458
  Text completion works via some light-weight GUI popup, which is triggered by
wenzelm@55118
   459
  keyboard events during the normal editing process in the main jEdit text
wenzelm@55118
   460
  area and a few additional text fields. The popup interprets special keys:
wenzelm@55118
   461
  @{verbatim TAB}, @{verbatim ESCAPE}, @{verbatim UP}, @{verbatim DOWN},
wenzelm@55118
   462
  @{verbatim PAGE_UP}, @{verbatim PAGE_DOWN}. All other key events are passed
wenzelm@55118
   463
  to the jEdit text area --- this allows to ignore unwanted completions most
wenzelm@55118
   464
  of the time and continue typing quickly.
wenzelm@55118
   465
wenzelm@55118
   466
  Various Isabelle plugin options control the popup behavior and immediate
wenzelm@55118
   467
  insertion into buffer.
wenzelm@55118
   468
wenzelm@55208
   469
  Isabelle Symbols are completed in backslashed forms, e.g.\ @{verbatim
wenzelm@55118
   470
  "\\"}@{verbatim "forall"} or @{verbatim "\<forall>"} that both produce the Isabelle
wenzelm@55119
   471
  symbol @{text "\<forall>"} in its Unicode rendering. Alternatively, symbol
wenzelm@55119
   472
  abbreviations may be used as specified in @{file
wenzelm@55119
   473
  "$ISABELLE_HOME/etc/symbols"}.
wenzelm@55118
   474
wenzelm@55118
   475
  \emph{Explicit completion} works via standard jEdit shortcut @{verbatim
wenzelm@55118
   476
  "C+b"}, which is remapped to action @{verbatim "isabelle.complete"}, with a
wenzelm@55118
   477
  fall-back on regular @{verbatim "complete-word"} for non-Isabelle buffers.
wenzelm@55118
   478
wenzelm@55118
   479
  \emph{Implicit completion} works via keyboard input on text area, with popup
wenzelm@55118
   480
  or immediate insertion into buffer. Plain words require at least 3
wenzelm@55118
   481
  characters to be completed.
wenzelm@55118
   482
wenzelm@55118
   483
  \emph{Immediate completion} means the (unique) replacement text is inserted
wenzelm@55118
   484
  into the buffer without popup. This mode ignores plain words and requires
wenzelm@55118
   485
  more than one characters for symbol abbreviations. Otherwise it falls back
wenzelm@55118
   486
  on completion popup.
wenzelm@55118
   487
*}
wenzelm@54906
   488
wenzelm@54907
   489
wenzelm@55217
   490
chapter {* Known problems and workarounds \label{sec:problems} *}
wenzelm@54907
   491
wenzelm@54907
   492
text {*
wenzelm@54907
   493
  \begin{itemize}
wenzelm@54907
   494
wenzelm@54907
   495
  \item \textbf{Problem:} Lack of dependency management for auxiliary files
wenzelm@54908
   496
  that contribute to a theory (e.g.\ @{command ML_file}).
wenzelm@54907
   497
wenzelm@54907
   498
  \textbf{Workaround:} Re-load files manually within the prover.
wenzelm@54907
   499
wenzelm@54907
   500
  \item \textbf{Problem:} Odd behavior of some diagnostic commands with
wenzelm@54907
   501
  global side-effects, like writing a physical file.
wenzelm@54907
   502
wenzelm@54907
   503
  \textbf{Workaround:} Avoid such commands.
wenzelm@54907
   504
wenzelm@54907
   505
  \item \textbf{Problem:} No way to delete document nodes from the overall
wenzelm@54907
   506
  collection of theories.
wenzelm@54907
   507
wenzelm@55217
   508
  \textbf{Workaround:} Ignore unused files.  Restart whole
wenzelm@55217
   509
  Isabelle/jEdit session in worst-case situation.
wenzelm@54907
   510
wenzelm@55023
   511
  \item \textbf{Problem:} The Mac OS X keyboard shortcut @{verbatim
wenzelm@55023
   512
  "COMMAND+COMMA"} for Preferences is in conflict with the jEdit default
wenzelm@55023
   513
  binding for @{verbatim "quick-search"}.
wenzelm@54907
   514
wenzelm@55023
   515
  \textbf{Workaround:} Remap in jEdit manually according to national
wenzelm@55023
   516
  keyboard, e.g.\ @{verbatim "COMMAND+SLASH"} on English ones.
wenzelm@54907
   517
wenzelm@55217
   518
  \item \textbf{Problem:} Keyboard shortcuts @{verbatim "C+PLUS"} and
wenzelm@55217
   519
  @{verbatim "C+MINUS"} for adjusting the editor font size depend on
wenzelm@55217
   520
  platform details and national keyboards.
wenzelm@54907
   521
wenzelm@55217
   522
  \textbf{Workaround:} Use numeric keypad or rebind keys in the
wenzelm@55217
   523
  jEdit Shortcuts options dialog.
wenzelm@55217
   524
wenzelm@55217
   525
  \item \textbf{Problem:} Some Linux / X11 input methods such as IBus
wenzelm@55217
   526
  tend to disrupt key event handling of Java/Swing.
wenzelm@55217
   527
wenzelm@55217
   528
  \textbf{Workaround:} Do not use input methods, reset the environment
wenzelm@55217
   529
  variable @{verbatim XMODIFIERS} within Isabelle settings (default in
wenzelm@55217
   530
  Isabelle2013-1).
wenzelm@55217
   531
wenzelm@55217
   532
  \item \textbf{Problem:} Some Linux / X11 window managers that are
wenzelm@55217
   533
  not ``re-parenting'' cause problems with additional windows opened
wenzelm@55217
   534
  by the Java VM. This affects either historic or neo-minimalistic
wenzelm@55217
   535
  window managers like @{verbatim awesome} or @{verbatim xmonad}.
wenzelm@55217
   536
wenzelm@55217
   537
  \textbf{Workaround:} Use regular re-parenting window manager.
wenzelm@55217
   538
wenzelm@55217
   539
  \item \textbf{Problem:} Recent forks of Linux / X11 window managers
wenzelm@55217
   540
  and desktop environments (variants of Gnome) disrupt the handling of
wenzelm@55217
   541
  menu popups and mouse positions of Java/AWT/Swing.
wenzelm@55217
   542
wenzelm@55217
   543
  \textbf{Workaround:} Use mainstream versions of Linux desktops.
wenzelm@54907
   544
wenzelm@54907
   545
  \end{itemize}
wenzelm@54907
   546
*}
wenzelm@54907
   547
wenzelm@54906
   548
end