src/Doc/Implementation/ML.thy
changeset 58555 7975676c08c0
parent 57834 0d295e339f52
child 58618 782f0b662cae
equal deleted inserted replaced
58554:423202f05a43 58555:7975676c08c0
   679   @{rail \<open>
   679   @{rail \<open>
   680   @{syntax_def antiquote}: '@{' nameref args '}'
   680   @{syntax_def antiquote}: '@{' nameref args '}'
   681   \<close>}
   681   \<close>}
   682 
   682 
   683   Here @{syntax nameref} and @{syntax args} are outer syntax categories, as
   683   Here @{syntax nameref} and @{syntax args} are outer syntax categories, as
   684   defined in \cite{isabelle-isar-ref}.
   684   defined in @{cite "isabelle-isar-ref"}.
   685 
   685 
   686   \medskip A regular antiquotation @{text "@{name args}"} processes
   686   \medskip A regular antiquotation @{text "@{name args}"} processes
   687   its arguments by the usual means of the Isar source language, and
   687   its arguments by the usual means of the Isar source language, and
   688   produces corresponding ML source text, either as literal
   688   produces corresponding ML source text, either as literal
   689   \emph{inline} text (e.g.\ @{text "@{term t}"}) or abstract
   689   \emph{inline} text (e.g.\ @{text "@{term t}"}) or abstract
  1006   Depending on the user interface involved, these messages may appear
  1006   Depending on the user interface involved, these messages may appear
  1007   in different text styles or colours.  The standard output for
  1007   in different text styles or colours.  The standard output for
  1008   batch sessions prefixes each line of warnings by @{verbatim
  1008   batch sessions prefixes each line of warnings by @{verbatim
  1009   "###"} and errors by @{verbatim "***"}, but leaves anything else
  1009   "###"} and errors by @{verbatim "***"}, but leaves anything else
  1010   unchanged.  The message body may contain further markup and formatting,
  1010   unchanged.  The message body may contain further markup and formatting,
  1011   which is routinely used in the Prover IDE \cite{isabelle-jedit}.
  1011   which is routinely used in the Prover IDE @{cite "isabelle-jedit"}.
  1012 
  1012 
  1013   Messages are associated with the transaction context of the running
  1013   Messages are associated with the transaction context of the running
  1014   Isar command.  This enables the front-end to manage commands and
  1014   Isar command.  This enables the front-end to manage commands and
  1015   resulting messages together.  For example, after deleting a command
  1015   resulting messages together.  For example, after deleting a command
  1016   from a given theory document version, the corresponding message
  1016   from a given theory document version, the corresponding message
  1323   be a singleton string do not require extra memory in Poly/ML.}
  1323   be a singleton string do not require extra memory in Poly/ML.}
  1324 
  1324 
  1325   \item @{ML "Symbol.is_letter"}, @{ML "Symbol.is_digit"}, @{ML
  1325   \item @{ML "Symbol.is_letter"}, @{ML "Symbol.is_digit"}, @{ML
  1326   "Symbol.is_quasi"}, @{ML "Symbol.is_blank"} classify standard
  1326   "Symbol.is_quasi"}, @{ML "Symbol.is_blank"} classify standard
  1327   symbols according to fixed syntactic conventions of Isabelle, cf.\
  1327   symbols according to fixed syntactic conventions of Isabelle, cf.\
  1328   \cite{isabelle-isar-ref}.
  1328   @{cite "isabelle-isar-ref"}.
  1329 
  1329 
  1330   \item Type @{ML_type "Symbol.sym"} is a concrete datatype that
  1330   \item Type @{ML_type "Symbol.sym"} is a concrete datatype that
  1331   represents the different kinds of symbols explicitly, with
  1331   represents the different kinds of symbols explicitly, with
  1332   constructors @{ML "Symbol.Char"}, @{ML "Symbol.UTF8"},
  1332   constructors @{ML "Symbol.Char"}, @{ML "Symbol.UTF8"},
  1333   @{ML "Symbol.Sym"}, @{ML "Symbol.Ctrl"}, @{ML "Symbol.Raw"},
  1333   @{ML "Symbol.Sym"}, @{ML "Symbol.Ctrl"}, @{ML "Symbol.Raw"},
  1402   \begin{enumerate}
  1402   \begin{enumerate}
  1403 
  1403 
  1404   \item sequence of Isabelle symbols (see also \secref{sec:symbols}),
  1404   \item sequence of Isabelle symbols (see also \secref{sec:symbols}),
  1405   with @{ML Symbol.explode} as key operation;
  1405   with @{ML Symbol.explode} as key operation;
  1406 
  1406 
  1407   \item XML tree structure via YXML (see also \cite{isabelle-sys}),
  1407   \item XML tree structure via YXML (see also @{cite "isabelle-sys"}),
  1408   with @{ML YXML.parse_body} as key operation.
  1408   with @{ML YXML.parse_body} as key operation.
  1409 
  1409 
  1410   \end{enumerate}
  1410   \end{enumerate}
  1411 
  1411 
  1412   Note that Isabelle/ML string literals may refer Isabelle symbols
  1412   Note that Isabelle/ML string literals may refer Isabelle symbols
  1684   there are ``spare cycles'' to be wasted.  It means that the
  1684   there are ``spare cycles'' to be wasted.  It means that the
  1685   continued exponential speedup of CPU performance due to ``Moore's
  1685   continued exponential speedup of CPU performance due to ``Moore's
  1686   Law'' follows different rules: clock frequency has reached its peak
  1686   Law'' follows different rules: clock frequency has reached its peak
  1687   around 2005, and applications need to be parallelized in order to
  1687   around 2005, and applications need to be parallelized in order to
  1688   avoid a perceived loss of performance.  See also
  1688   avoid a perceived loss of performance.  See also
  1689   \cite{Sutter:2005}.}
  1689   @{cite "Sutter:2005"}.}
  1690 
  1690 
  1691   Isabelle/Isar exploits the inherent structure of theories and proofs to
  1691   Isabelle/Isar exploits the inherent structure of theories and proofs to
  1692   support \emph{implicit parallelism} to a large extent. LCF-style theorem
  1692   support \emph{implicit parallelism} to a large extent. LCF-style theorem
  1693   proving provides almost ideal conditions for that, see also
  1693   proving provides almost ideal conditions for that, see also
  1694   \cite{Wenzel:2009}. This means, significant parts of theory and proof
  1694   @{cite "Wenzel:2009"}. This means, significant parts of theory and proof
  1695   checking is parallelized by default. In Isabelle2013, a maximum
  1695   checking is parallelized by default. In Isabelle2013, a maximum
  1696   speedup-factor of 3.5 on 4 cores and 6.5 on 8 cores can be expected
  1696   speedup-factor of 3.5 on 4 cores and 6.5 on 8 cores can be expected
  1697   \cite{Wenzel:2013:ITP}.
  1697   @{cite "Wenzel:2013:ITP"}.
  1698 
  1698 
  1699   \medskip ML threads lack the memory protection of separate
  1699   \medskip ML threads lack the memory protection of separate
  1700   processes, and operate concurrently on shared heap memory.  This has
  1700   processes, and operate concurrently on shared heap memory.  This has
  1701   the advantage that results of independent computations are directly
  1701   the advantage that results of independent computations are directly
  1702   available to other threads: abstract values can be passed without
  1702   available to other threads: abstract values can be passed without
  2154 subsection {* Futures \label{sec:futures} *}
  2154 subsection {* Futures \label{sec:futures} *}
  2155 
  2155 
  2156 text {*
  2156 text {*
  2157   Futures help to organize parallel execution in a value-oriented manner, with
  2157   Futures help to organize parallel execution in a value-oriented manner, with
  2158   @{text fork}~/ @{text join} as the main pair of operations, and some further
  2158   @{text fork}~/ @{text join} as the main pair of operations, and some further
  2159   variants; see also \cite{Wenzel:2009,Wenzel:2013:ITP}. Unlike lazy values,
  2159   variants; see also @{cite "Wenzel:2009" and "Wenzel:2013:ITP"}. Unlike lazy
  2160   futures are evaluated strictly and spontaneously on separate worker threads.
  2160   values, futures are evaluated strictly and spontaneously on separate worker
  2161   Futures may be canceled, which leads to interrupts on running evaluation
  2161   threads. Futures may be canceled, which leads to interrupts on running
  2162   attempts, and forces structurally related futures to fail for all time;
  2162   evaluation attempts, and forces structurally related futures to fail for all
  2163   already finished futures remain unchanged. Exceptions between related
  2163   time; already finished futures remain unchanged. Exceptions between related
  2164   futures are propagated as well, and turned into parallel exceptions (see
  2164   futures are propagated as well, and turned into parallel exceptions (see
  2165   above).
  2165   above).
  2166 
  2166 
  2167   Technically, a future is a single-assignment variable together with a
  2167   Technically, a future is a single-assignment variable together with a
  2168   \emph{task} that serves administrative purposes, notably within the
  2168   \emph{task} that serves administrative purposes, notably within the