doc-src/IsarRef/pure.tex
changeset 26479 3a2efce3e992
parent 26434 d004b791218e
child 26660 f978a6f48949
equal deleted inserted replaced
26478:9d1029ce0e13 26479:3a2efce3e992
    79   later in the text (typically via explicit $\isarcmd{use}$ in the body text,
    79   later in the text (typically via explicit $\isarcmd{use}$ in the body text,
    80   see \S\ref{sec:ML}).  In reminiscence of the old-style theory system of
    80   see \S\ref{sec:ML}).  In reminiscence of the old-style theory system of
    81   Isabelle, \texttt{$A$.thy} may be also accompanied by an additional file
    81   Isabelle, \texttt{$A$.thy} may be also accompanied by an additional file
    82   \texttt{$A$.ML} consisting of ML code that is executed in the context of the
    82   \texttt{$A$.ML} consisting of ML code that is executed in the context of the
    83   \emph{finished} theory $A$.  That file should not be included in the
    83   \emph{finished} theory $A$.  That file should not be included in the
    84   $\isarkeyword{files}$ dependency declaration, though.
    84   $\isarkeyword{uses}$ dependency declaration, though.
    85   
    85   
    86 \item [$\END$] concludes the current theory definition or context switch.
    86 \item [$\END$] concludes the current theory definition or context switch.
    87   Note that this command cannot be undone, but the whole theory definition has
    87   Note that this command cannot be undone, but the whole theory definition has
    88   to be retracted.
    88   to be retracted.
    89 
    89 
   464 \end{descr}
   464 \end{descr}
   465 
   465 
   466 
   466 
   467 \subsection{Incorporating ML code}\label{sec:ML}
   467 \subsection{Incorporating ML code}\label{sec:ML}
   468 
   468 
   469 \indexisarcmd{use}\indexisarcmd{ML}
   469 \indexisarcmd{use}\indexisarcmd{ML}\indexisarcmd{ML-val}\indexisarcmd{ML-command}
   470 \indexisarcmd{ML-val}\indexisarcmd{ML-command}
   470 \indexisarcmd{setup}\indexisarcmd{method-setup}
   471 \indexisarcmd{ML-setup}\indexisarcmd{setup}
   471 \begin{matharray}{rcl}
   472 \indexisarcmd{method-setup}
   472   \isarcmd{use} & : & \isarkeep{theory~|~local{\dsh}theory} \\
   473 \begin{matharray}{rcl}
   473   \isarcmd{ML} & : & \isarkeep{theory~|~local{\dsh}theory} \\
   474   \isarcmd{use} & : & \isartrans{\cdot}{\cdot} \\
       
   475   \isarcmd{ML} & : & \isartrans{\cdot}{\cdot} \\
       
   476   \isarcmd{ML_val} & : & \isartrans{\cdot}{\cdot} \\
   474   \isarcmd{ML_val} & : & \isartrans{\cdot}{\cdot} \\
   477   \isarcmd{ML_command} & : & \isartrans{\cdot}{\cdot} \\
   475   \isarcmd{ML_command} & : & \isartrans{\cdot}{\cdot} \\
   478   \isarcmd{ML_setup} & : & \isartrans{theory}{theory} \\
       
   479   \isarcmd{setup} & : & \isartrans{theory}{theory} \\
   476   \isarcmd{setup} & : & \isartrans{theory}{theory} \\
   480   \isarcmd{method_setup} & : & \isartrans{theory}{theory} \\
   477   \isarcmd{method_setup} & : & \isartrans{theory}{theory} \\
   481 \end{matharray}
   478 \end{matharray}
   482 
   479 
   483 \begin{rail}
   480 \begin{rail}
   484   'use' name
   481   'use' name
   485   ;
   482   ;
   486   ('ML' | 'ML\_val' | 'ML\_command' | 'ML\_setup' | 'setup') text
   483   ('ML' | 'ML\_val' | 'ML\_command' | 'setup') text
   487   ;
   484   ;
   488   'method\_setup' name '=' text text
   485   'method\_setup' name '=' text text
   489   ;
   486   ;
   490 \end{rail}
   487 \end{rail}
   491 
   488 
   492 \begin{descr}
   489 \begin{descr}
   493 \item [$\isarkeyword{use}~file$] reads and executes ML commands from $file$.
   490 \item [$\isarkeyword{use}~file$] reads and executes ML commands from
   494   The current theory context (if present) is passed down to the ML session,
   491   $file$.  The current theory context is passed down to the ML
   495   but may not be modified.  Furthermore, the file name is checked with the
   492   toplevel and may be modified, using \verb,Context.>>, or any other
   496   $\isarkeyword{files}$ dependency declaration given in the theory header (see
   493   ML commands derived from it.  The file name is checked with the
   497   also \S\ref{sec:begin-thy}).
   494   $\isarkeyword{uses}$ dependency declaration given in the theory
   498   
   495   header (see also \S\ref{sec:begin-thy}).
   499 \item [$\isarkeyword{ML}~text$ and $\isarkeyword{ML_val}~text$ and
   496   
   500   $\isarkeyword{ML_command}~text$] execute ML commands from $text$.
   497 \item [$\isarkeyword{ML}~text$] is similar to $\isarkeyword{use}$, but
   501   The theory context is passed in the same way as for
   498   executes ML commands from the given $text$.
   502   $\isarkeyword{use}$, but may not be changed.  Note that the output
   499 
   503   of $\isarkeyword{ML_command}$ is less verbose than plain
   500 \item [$\isarkeyword{ML_val}$ and $\isarkeyword{ML_command}$] are
   504   $\isarkeyword{ML}$.
   501   diagnostic versions of $\isarkeyword{ML}$, which means that the
   505   
   502   context may not be updated.  $\isarkeyword{ML_val}$ echos the
   506 \item [$\isarkeyword{ML_setup}~text$] executes ML commands from $text$.  The
   503   bindings produced at the ML toplevel, but $\isarkeyword{ML_command}$
   507   theory context is passed down to the ML session, and fetched back
   504   is silent.
   508   afterwards.  Thus $text$ may actually change the theory as a side effect.
       
   509   
   505   
   510 \item [$\isarkeyword{setup}~text$] changes the current theory context
   506 \item [$\isarkeyword{setup}~text$] changes the current theory context
   511   by applying $text$, which refers to an ML expression of type
   507   by applying $text$, which refers to an ML expression of type
   512   \texttt{theory~->~theory)}.  The $\isarkeyword{setup}$ command is
   508   \texttt{theory~->~theory)}.  The $\isarkeyword{setup}$ command is
   513   the canonical way to initialize any object-logic specific tools and
   509   the canonical way to initialize any object-logic specific tools and