doc-src/IsarRef/syntax.tex
changeset 14895 b9cc12a91fd3
parent 14707 2d6350d7b9b7
child 14919 0f5fde03e2b5
equal deleted inserted replaced
14894:d23f6b505e9a 14895:b9cc12a91fd3
    79   typefree & = & \verb,',ident \\
    79   typefree & = & \verb,',ident \\
    80   typevar & = & typefree ~|~ \verb,?,typefree ~|~ \verb,?,typefree\verb,.,nat \\
    80   typevar & = & typefree ~|~ \verb,?,typefree ~|~ \verb,?,typefree\verb,.,nat \\
    81   string & = & \verb,", ~\dots~ \verb,", \\
    81   string & = & \verb,", ~\dots~ \verb,", \\
    82   verbatim & = & \verb,{*, ~\dots~ \verb,*}, \\[1ex]
    82   verbatim & = & \verb,{*, ~\dots~ \verb,*}, \\[1ex]
    83 
    83 
    84   letter & = & sletter ~|~ xletter \\
    84   letter & = & latin ~|~ symletter \\
       
    85   latin & = & \verb,a, ~|~ \dots ~|~ \verb,z, ~|~ \verb,A, ~|~ \dots ~|~ \verb,Z, \\
    85   digit & = & \verb,0, ~|~ \dots ~|~ \verb,9, \\
    86   digit & = & \verb,0, ~|~ \dots ~|~ \verb,9, \\
    86   quasiletter & = & letter ~|~ digit ~|~ \verb,_, ~|~ \verb,', \\
    87   quasiletter & = & letter ~|~ digit ~|~ \verb,_, ~|~ \verb,', ~|~ \verb,\<^isub>, ~|~ \verb,\<^isup>, \\
    87   sym & = & \verb,!, ~|~ \verb,#, ~|~ \verb,$, ~|~ \verb,%, ~|~ \verb,&, ~|~  %$
    88   sym & = & \verb,!, ~|~ \verb,#, ~|~ \verb,$, ~|~ \verb,%, ~|~ \verb,&, ~|~  %$
    88    \verb,*, ~|~ \verb,+, ~|~ \verb,-, ~|~ \verb,/, ~|~ \verb,:, ~|~ \\
    89    \verb,*, ~|~ \verb,+, ~|~ \verb,-, ~|~ \verb,/, ~|~ \verb,:, ~|~ \\
    89   & & \verb,<, ~|~ \verb,=, ~|~ \verb,>, ~|~ \verb,?, ~|~ \texttt{\at} ~|~
    90   & & \verb,<, ~|~ \verb,=, ~|~ \verb,>, ~|~ \verb,?, ~|~ \texttt{\at} ~|~
    90   \verb,^, ~|~ \verb,_, ~|~ \verb,`, ~|~ \verb,|, ~|~ \verb,~, \\
    91   \verb,^, ~|~ \verb,_, ~|~ \verb,`, ~|~ \verb,|, ~|~ \verb,~, \\
    91   symbol & = & {\forall} ~|~ {\exists} ~|~ {\land} ~|~ {\lor} ~|~ \dots\\
    92   symbol & = & {\forall} ~|~ {\exists} ~|~ {\land} ~|~ {\lor} ~|~ \dots\\
    92 sletter & = & \verb,a, ~|~ \dots ~|~ \verb,z, ~|~ \verb,A, ~|~ \dots ~|~ \verb,Z, \\
    93 symletter & = & \verb,\<, (latin ~|~ latin~latin ~|~ greek) \verb,>, \\
    93 xletter & = & {\tt \backslash<} ~ (sletter ~|~ dletter ~|~ gletter ~|~ cletter) ~ {\tt >}\\
    94 greek & = & \verb,alpha, ~|~ \verb,beta, ~|~ \verb,gamma, ~|~ \verb,delta, ~|~ \verb,epsilon, ~|~ \verb,zeta, ~|~ \verb,eta, ~| \\
    94 dletter & = & \verb,aa, ~|~ \dots ~|~ \verb,zz, ~|~ \verb,AA, ~|~ \dots ~|~ \verb,ZZ, \\
    95         &   & \verb,theta, ~|~ \verb,iota, ~|~ \verb,kappa, ~|~ \verb,mu, ~|~ \verb,nu, ~|~ \verb,xi, ~|~ \verb,pi, ~|~ \verb,rho, ~| \\
    95 bletter & = & {\tt bool} ~|~ {\tt complex} ~|~ {\tt nat} ~|~ {\tt rat} ~|~ {\tt real} ~|~ {\tt int}\\
    96         &   & \verb,sigma, ~|~ \verb,tau, ~|~ \verb,upsilon, ~|~ \verb,phi, ~|~ \verb,psi, ~|~ \verb,omega, ~|~ \verb,Gamma, ~| \\
    96 cletter & = & {\tt \hat{}\, isup} ~~|~~ {\tt \hat{}\, isub}
    97         &   & \verb,Delta, ~|~ \verb,Theta, ~|~ \verb,Lambda, ~|~ \verb,Xi, ~|~ \verb,Pi, ~|~ \verb,Sigma, ~|~ \verb,Upsilon, ~| \\
    97 \end{matharray}
    98         &   & \verb,Phi, ~|~ \verb,Psi, ~|~ \verb,Omega,
    98 \begin{matharray}{rcl}
       
    99 gletter & = & {\tt alpha} ~|~ {\tt beta} ~|~ {\tt gamma} ~|~ {\tt delta} ~|~ {\tt epsilon} ~|~ {\tt zeta} ~|~ {\tt eta} ~|\\ 
       
   100         &   & {\tt theta} ~|~ {\tt iota} ~|~ {\tt kappa} ~|~ {\tt mu} ~|~ {\tt nu} ~|~ {\tt xi} ~|~ {\tt pi} ~|~ {\tt rho} ~|\\
       
   101         &   & {\tt sigma} ~|~ {\tt tau} ~|~ {\tt upsilon} ~|~ {\tt phi} ~|~ {\tt psi} ~|~ {\tt omega} ~|~ {\tt Gamma} ~|\\
       
   102         &   & {\tt Delta} ~|~ {\tt Theta} ~|~ {\tt Lambda} ~|~ {\tt Xi} ~|~ {\tt Pi} ~|~ {\tt Sigma} ~|~ {\tt Upsilon} ~|\\
       
   103         &   & {\tt Phi} ~|~ {\tt Psi} ~|~ {\tt Omega}
       
   104 \end{matharray}
    99 \end{matharray}
   105 
   100 
   106 The syntax of $string$ admits any characters, including newlines; ``\verb|"|''
   101 The syntax of $string$ admits any characters, including newlines; ``\verb|"|''
   107 (double-quote) and ``\verb|\|'' (backslash) need to be escaped by a backslash.
   102 (double-quote) and ``\verb|\|'' (backslash) need to be escaped by a backslash.
   108 Note that ML-style control characters are \emph{not} supported.  The body of
   103 Note that ML-style control characters are \emph{not} supported.  The body of
   126 \medskip
   121 \medskip
   127 
   122 
   128 Mathematical symbols such as ``$\forall$'' are represented in plain ASCII as
   123 Mathematical symbols such as ``$\forall$'' are represented in plain ASCII as
   129 ``\verb,\<forall>,''.  Concerning Isabelle itself, any sequence of the form
   124 ``\verb,\<forall>,''.  Concerning Isabelle itself, any sequence of the form
   130 \verb,\<,$ident$\verb,>, (or \verb,\\<,$ident$\verb,>,) is a legal symbol.
   125 \verb,\<,$ident$\verb,>, (or \verb,\\<,$ident$\verb,>,) is a legal symbol.
   131 Greek letters \verb+\<alpha>+, \verb+\<beta>+, etc (apart from
   126 Greek letters \verb+\<alpha>+, \verb+\<beta>+, etc. (apart from
   132 \verb+\<lambda>+), caligraphic letters in various styles, as
   127 \verb+\<lambda>+), as well as the \verb+\<^isub>+ and \verb+\<^isup>+ control
   133 well as the special \verb+\<^isub>+ and \verb+\<^isup>+ sub/superscipt
   128 characters may be used in identifiers as well.
   134 control characters are considered proper letters and can be used as
       
   135 part of any identifier. 
       
   136 
   129 
   137 Display of appropriate glyphs is a matter of front-end tools, say the
   130 Display of appropriate glyphs is a matter of front-end tools, say the
   138 user-interface of Proof~General plus the X-Symbol package, or the {\LaTeX}
   131 user-interface of Proof~General plus the X-Symbol package, or the {\LaTeX}
   139 macro setup of document output.  A list of predefined Isabelle symbols is
   132 macro setup of document output.  A list of predefined Isabelle symbols is
   140 given in \cite[appendix~A]{isabelle-sys}.
   133 given in \cite[appendix~A]{isabelle-sys}.
   144 
   137 
   145 Subsequently, we introduce several basic syntactic entities, such as names,
   138 Subsequently, we introduce several basic syntactic entities, such as names,
   146 terms, and theorem specifications, which have been factored out of the actual
   139 terms, and theorem specifications, which have been factored out of the actual
   147 Isar language elements to be described later.
   140 Isar language elements to be described later.
   148 
   141 
   149 Note that some of the basic syntactic entities introduced below (e.g.\ 
   142 Note that some of the basic syntactic entities introduced below (e.g.\
   150 \railqtok{name}) act much like tokens rather than plain nonterminals (e.g.\ 
   143 \railqtok{name}) act much like tokens rather than plain nonterminals (e.g.\
   151 \railnonterm{sort}), especially for the sake of error messages.  E.g.\ syntax
   144 \railnonterm{sort}), especially for the sake of error messages.  E.g.\ syntax
   152 elements like $\CONSTS$ referring to \railqtok{name} or \railqtok{type} would
   145 elements like $\CONSTS$ referring to \railqtok{name} or \railqtok{type} would
   153 really report a missing name or type rather than any of the constituent
   146 really report a missing name or type rather than any of the constituent
   154 primitive tokens such as \railtok{ident} or \railtok{string}.
   147 primitive tokens such as \railtok{ident} or \railtok{string}.
   155 
   148 
   157 \subsection{Names}
   150 \subsection{Names}
   158 
   151 
   159 Entity \railqtok{name} usually refers to any name of types, constants,
   152 Entity \railqtok{name} usually refers to any name of types, constants,
   160 theorems etc.\ that are to be \emph{declared} or \emph{defined} (so qualified
   153 theorems etc.\ that are to be \emph{declared} or \emph{defined} (so qualified
   161 identifiers are excluded here).  Quoted strings provide an escape for
   154 identifiers are excluded here).  Quoted strings provide an escape for
   162 non-identifier names or those ruled out by outer syntax keywords (e.g.\ 
   155 non-identifier names or those ruled out by outer syntax keywords (e.g.\
   163 \verb|"let"|).  Already existing objects are usually referenced by
   156 \verb|"let"|).  Already existing objects are usually referenced by
   164 \railqtok{nameref}.
   157 \railqtok{nameref}.
   165 
   158 
   166 \indexoutertoken{name}\indexoutertoken{parname}\indexoutertoken{nameref}
   159 \indexoutertoken{name}\indexoutertoken{parname}\indexoutertoken{nameref}
   167 \indexoutertoken{int}
   160 \indexoutertoken{int}
   469 
   462 
   470 Note that the syntax of antiquotations may \emph{not} include source comments
   463 Note that the syntax of antiquotations may \emph{not} include source comments
   471 \texttt{(*~\dots~*)} or verbatim text \verb|{*|~\dots~\verb|*}|.
   464 \texttt{(*~\dots~*)} or verbatim text \verb|{*|~\dots~\verb|*}|.
   472 
   465 
   473 \begin{descr}
   466 \begin{descr}
   474   
   467 
   475 \item [$\at\{thm~\vec a\}$] prints theorems $\vec a$. Note that attribute
   468 \item [$\at\{thm~\vec a\}$] prints theorems $\vec a$. Note that attribute
   476   specifications may be included as well (see also \S\ref{sec:syn-att}); the
   469   specifications may be included as well (see also \S\ref{sec:syn-att}); the
   477   $no_vars$ operation (see \S\ref{sec:misc-meth-att}) would be particularly
   470   $no_vars$ operation (see \S\ref{sec:misc-meth-att}) would be particularly
   478   useful to suppress printing of schematic variables.
   471   useful to suppress printing of schematic variables.
   479 
   472 
   480 \item [$\at\{prop~\phi\}$] prints a well-typed proposition $\phi$.
   473 \item [$\at\{prop~\phi\}$] prints a well-typed proposition $\phi$.
   481 
   474 
   482 \item [$\at\{term~t\}$] prints a well-typed term $t$.
   475 \item [$\at\{term~t\}$] prints a well-typed term $t$.
   483 
   476 
   484 \item [$\at\{typ~\tau\}$] prints a well-formed type $\tau$.
   477 \item [$\at\{typ~\tau\}$] prints a well-formed type $\tau$.
   485   
   478 
   486 \item [$\at\{text~s\}$] prints uninterpreted source text $s$.  This is
   479 \item [$\at\{text~s\}$] prints uninterpreted source text $s$.  This is
   487   particularly useful to print portions of text according to the Isabelle
   480   particularly useful to print portions of text according to the Isabelle
   488   {\LaTeX} output style, without demanding well-formedness (e.g.\ small pieces
   481   {\LaTeX} output style, without demanding well-formedness (e.g.\ small pieces
   489   of terms that should not be parsed or type-checked yet).
   482   of terms that should not be parsed or type-checked yet).
   490   
   483 
   491 \item [$\at\{goals\}$] prints the current \emph{dynamic} goal state.  This is
   484 \item [$\at\{goals\}$] prints the current \emph{dynamic} goal state.  This is
   492   mainly for support of tactic-emulation scripts within Isar --- presentation
   485   mainly for support of tactic-emulation scripts within Isar --- presentation
   493   of goal states does not conform to actual human-readable proof documents.
   486   of goal states does not conform to actual human-readable proof documents.
   494   Please do not include goal states into document output unless you really
   487   Please do not include goal states into document output unless you really
   495   know what you are doing!
   488   know what you are doing!
   536   rather than the actual value.  Note that this does not affect
   529   rather than the actual value.  Note that this does not affect
   537   well-formedness checks of $thm$, $term$, etc. (only the $text$ antiquotation
   530   well-formedness checks of $thm$, $term$, etc. (only the $text$ antiquotation
   538   admits arbitrary output).
   531   admits arbitrary output).
   539 \item[$goals_limit = nat$] determines the maximum number of goals to be
   532 \item[$goals_limit = nat$] determines the maximum number of goals to be
   540   printed.
   533   printed.
       
   534 \item[$locale = name$] specifies an alternative context used for evaluating
       
   535   and printing the subsequent argument.  Note that a proof context is escaped
       
   536   to the enclosing theory context first.
   541 \end{descr}
   537 \end{descr}
   542 
   538 
   543 For boolean flags, ``$name = true$'' may be abbreviated as ``$name$''.  All of
   539 For boolean flags, ``$name = true$'' may be abbreviated as ``$name$''.  All of
   544 the above flags are disabled by default, unless changed from ML.
   540 the above flags are disabled by default, unless changed from ML.
   545 
   541 
   547 typing of logical entities, but also achieve some degree of
   543 typing of logical entities, but also achieve some degree of
   548 consistency-checking of informal explanations with formal developments:
   544 consistency-checking of informal explanations with formal developments:
   549 well-formedness of terms and types with respect to the current theory or proof
   545 well-formedness of terms and types with respect to the current theory or proof
   550 context is ensured here.
   546 context is ensured here.
   551 
   547 
   552 %%% Local Variables: 
   548 %%% Local Variables:
   553 %%% mode: latex
   549 %%% mode: latex
   554 %%% TeX-master: "isar-ref"
   550 %%% TeX-master: "isar-ref"
   555 %%% End: 
   551 %%% End: