src/Doc/IsarRef/Document_Preparation.thy
changeset 55112 b1a5d603fd12
parent 55029 61a6bf7d4b02
child 55113 497693486858
equal deleted inserted replaced
55111:5792f5106c40 55112:b1a5d603fd12
    45 
    45 
    46   Note that formal comments (\secref{sec:comments}) are similar to
    46   Note that formal comments (\secref{sec:comments}) are similar to
    47   markup commands, but have a different status within Isabelle/Isar
    47   markup commands, but have a different status within Isabelle/Isar
    48   syntax.
    48   syntax.
    49 
    49 
    50   @{rail "
    50   @{rail \<open>
    51     (@@{command chapter} | @@{command section} | @@{command subsection} |
    51     (@@{command chapter} | @@{command section} | @@{command subsection} |
    52       @@{command subsubsection} | @@{command text}) @{syntax target}? @{syntax text}
    52       @@{command subsubsection} | @@{command text}) @{syntax target}? @{syntax text}
    53     ;
    53     ;
    54     (@@{command header} | @@{command text_raw} | @@{command sect} | @@{command subsect} |
    54     (@@{command header} | @@{command text_raw} | @@{command sect} | @@{command subsect} |
    55       @@{command subsubsect} | @@{command txt} | @@{command txt_raw}) @{syntax text}
    55       @@{command subsubsect} | @@{command txt} | @@{command txt_raw}) @{syntax text}
    56   "}
    56   \<close>}
    57 
    57 
    58   \begin{description}
    58   \begin{description}
    59 
    59 
    60   \item @{command header} provides plain text markup just preceding
    60   \item @{command header} provides plain text markup just preceding
    61   the formal beginning of a theory.  The corresponding {\LaTeX} macro
    61   the formal beginning of a theory.  The corresponding {\LaTeX} macro
   146   informal explanation is achieved, since terms and types appearing in
   146   informal explanation is achieved, since terms and types appearing in
   147   antiquotations are checked within the current theory or proof
   147   antiquotations are checked within the current theory or proof
   148   context.
   148   context.
   149 
   149 
   150   %% FIXME less monolithic presentation, move to individual sections!?
   150   %% FIXME less monolithic presentation, move to individual sections!?
   151   @{rail "
   151   @{rail \<open>
   152     '@{' antiquotation '}'
   152     '@{' antiquotation '}'
   153     ;
   153     ;
   154     @{syntax_def antiquotation}:
   154     @{syntax_def antiquotation}:
   155       @@{antiquotation theory} options @{syntax name} |
   155       @@{antiquotation theory} options @{syntax name} |
   156       @@{antiquotation thm} options styles @{syntax thmrefs} |
   156       @@{antiquotation thm} options styles @{syntax thmrefs} |
   174       @@{antiquotation full_prf} options @{syntax thmrefs} |
   174       @@{antiquotation full_prf} options @{syntax thmrefs} |
   175       @@{antiquotation ML} options @{syntax name} |
   175       @@{antiquotation ML} options @{syntax name} |
   176       @@{antiquotation ML_op} options @{syntax name} |
   176       @@{antiquotation ML_op} options @{syntax name} |
   177       @@{antiquotation ML_type} options @{syntax name} |
   177       @@{antiquotation ML_type} options @{syntax name} |
   178       @@{antiquotation ML_struct} options @{syntax name} |
   178       @@{antiquotation ML_struct} options @{syntax name} |
   179       @@{antiquotation \"file\"} options @{syntax name} |
   179       @@{antiquotation "file"} options @{syntax name} |
   180       @@{antiquotation file_unchecked} options @{syntax name} |
   180       @@{antiquotation file_unchecked} options @{syntax name} |
   181       @@{antiquotation url} options @{syntax name}
   181       @@{antiquotation url} options @{syntax name}
   182     ;
   182     ;
   183     options: '[' (option * ',') ']'
   183     options: '[' (option * ',') ']'
   184     ;
   184     ;
   185     option: @{syntax name} | @{syntax name} '=' @{syntax name}
   185     option: @{syntax name} | @{syntax name} '=' @{syntax name}
   186     ;
   186     ;
   187     styles: '(' (style + ',') ')'
   187     styles: '(' (style + ',') ')'
   188     ;
   188     ;
   189     style: (@{syntax name} +)
   189     style: (@{syntax name} +)
   190   "}
   190   \<close>}
   191 
   191 
   192   Note that the syntax of antiquotations may \emph{not} include source
   192   Note that the syntax of antiquotations may \emph{not} include source
   193   comments @{verbatim "(*"}~@{text "\<dots>"}~@{verbatim "*)"} nor verbatim
   193   comments @{verbatim "(*"}~@{text "\<dots>"}~@{verbatim "*)"} nor verbatim
   194   text @{verbatim "{"}@{verbatim "*"}~@{text "\<dots>"}~@{verbatim
   194   text @{verbatim "{"}@{verbatim "*"}~@{text "\<dots>"}~@{verbatim
   195   "*"}@{verbatim "}"}.
   195   "*"}@{verbatim "}"}.
   402 
   402 
   403 text {* Each Isabelle/Isar command may be decorated by additional
   403 text {* Each Isabelle/Isar command may be decorated by additional
   404   presentation tags, to indicate some modification in the way it is
   404   presentation tags, to indicate some modification in the way it is
   405   printed in the document.
   405   printed in the document.
   406 
   406 
   407   @{rail "
   407   @{rail \<open>
   408     @{syntax_def tags}: ( tag * )
   408     @{syntax_def tags}: ( tag * )
   409     ;
   409     ;
   410     tag: '%' (@{syntax ident} | @{syntax string})
   410     tag: '%' (@{syntax ident} | @{syntax string})
   411   "}
   411   \<close>}
   412 
   412 
   413   Some tags are pre-declared for certain classes of commands, serving
   413   Some tags are pre-declared for certain classes of commands, serving
   414   as default markup if no tags are given in the text:
   414   as default markup if no tags are given in the text:
   415 
   415 
   416   \medskip
   416   \medskip
   455 text {*
   455 text {*
   456   \begin{matharray}{rcl}
   456   \begin{matharray}{rcl}
   457     @{antiquotation_def "rail"} & : & @{text antiquotation} \\
   457     @{antiquotation_def "rail"} & : & @{text antiquotation} \\
   458   \end{matharray}
   458   \end{matharray}
   459 
   459 
   460   @{rail "'rail' string"}
   460   @{rail \<open>'rail' (string | cartouche)\<close>}
   461 
   461 
   462   The @{antiquotation rail} antiquotation allows to include syntax
   462   The @{antiquotation rail} antiquotation allows to include syntax
   463   diagrams into Isabelle documents.  {\LaTeX} requires the style file
   463   diagrams into Isabelle documents.  {\LaTeX} requires the style file
   464   @{file "~~/lib/texinputs/pdfsetup.sty"}, which can be used via
   464   @{file "~~/lib/texinputs/pdfsetup.sty"}, which can be used via
   465   @{verbatim "\\usepackage{pdfsetup}"} in @{verbatim "root.tex"}, for
   465   @{verbatim "\\usepackage{pdfsetup}"} in @{verbatim "root.tex"}, for
   466   example.
   466   example.
   467 
   467 
   468   The rail specification language is quoted here as Isabelle @{syntax
   468   The rail specification language is quoted here as Isabelle @{syntax
   469   string}; it has its own grammar given below.
   469   string}; it has its own grammar given below.
   470 
   470 
   471   @{rail "
   471   @{rail \<open>
   472   rule? + ';'
   472   rule? + ';'
   473   ;
   473   ;
   474   rule: ((identifier | @{syntax antiquotation}) ':')? body
   474   rule: ((identifier | @{syntax antiquotation}) ':')? body
   475   ;
   475   ;
   476   body: concatenation + '|'
   476   body: concatenation + '|'
   477   ;
   477   ;
   478   concatenation: ((atom '?'?) +) (('*' | '+') atom?)?
   478   concatenation: ((atom '?'?) +) (('*' | '+') atom?)?
   479   ;
   479   ;
   480   atom: '(' body? ')' | identifier |
   480   atom: '(' body? ')' | identifier |
   481     '@'? (string | @{syntax antiquotation}) |
   481     '@'? (string | @{syntax antiquotation}) |
   482     '\\\\\\\\'
   482     '\<newline>'
   483   "}
   483   \<close>}
   484 
   484 
   485   The lexical syntax of @{text "identifier"} coincides with that of
   485   The lexical syntax of @{text "identifier"} coincides with that of
   486   @{syntax ident} in regular Isabelle syntax, but @{text string} uses
   486   @{syntax ident} in regular Isabelle syntax, but @{text string} uses
   487   single quotes instead of double quotes of the standard @{syntax
   487   single quotes instead of double quotes of the standard @{syntax
   488   string} category, to avoid extra escapes.
   488   string} category, to avoid extra escapes.
   494 
   494 
   495   \begin{itemize}
   495   \begin{itemize}
   496 
   496 
   497   \item Empty @{verbatim "()"}
   497   \item Empty @{verbatim "()"}
   498 
   498 
   499   @{rail "()"}
   499   @{rail \<open>()\<close>}
   500 
   500 
   501   \item Nonterminal @{verbatim "A"}
   501   \item Nonterminal @{verbatim "A"}
   502 
   502 
   503   @{rail "A"}
   503   @{rail \<open>A\<close>}
   504 
   504 
   505   \item Nonterminal via Isabelle antiquotation
   505   \item Nonterminal via Isabelle antiquotation
   506   @{verbatim "@{syntax method}"}
   506   @{verbatim "@{syntax method}"}
   507 
   507 
   508   @{rail "@{syntax method}"}
   508   @{rail \<open>@{syntax method}\<close>}
   509 
   509 
   510   \item Terminal @{verbatim "'xyz'"}
   510   \item Terminal @{verbatim "'xyz'"}
   511 
   511 
   512   @{rail "'xyz'"}
   512   @{rail \<open>'xyz'\<close>}
   513 
   513 
   514   \item Terminal in keyword style @{verbatim "@'xyz'"}
   514   \item Terminal in keyword style @{verbatim "@'xyz'"}
   515 
   515 
   516   @{rail "@'xyz'"}
   516   @{rail \<open>@'xyz'\<close>}
   517 
   517 
   518   \item Terminal via Isabelle antiquotation
   518   \item Terminal via Isabelle antiquotation
   519   @{verbatim "@@{method rule}"}
   519   @{verbatim "@@{method rule}"}
   520 
   520 
   521   @{rail "@@{method rule}"}
   521   @{rail \<open>@@{method rule}\<close>}
   522 
   522 
   523   \item Concatenation @{verbatim "A B C"}
   523   \item Concatenation @{verbatim "A B C"}
   524 
   524 
   525   @{rail "A B C"}
   525   @{rail \<open>A B C\<close>}
   526 
   526 
   527   \item Newline inside concatenation
   527   \item Newline inside concatenation
   528   @{verbatim "A B C \<newline> D E F"}
   528   @{verbatim "A B C \<newline> D E F"}
   529 
   529 
   530   @{rail "A B C \<newline> D E F"}
   530   @{rail \<open>A B C \<newline> D E F\<close>}
   531 
   531 
   532   \item Variants @{verbatim "A | B | C"}
   532   \item Variants @{verbatim "A | B | C"}
   533 
   533 
   534   @{rail "A | B | C"}
   534   @{rail \<open>A | B | C\<close>}
   535 
   535 
   536   \item Option @{verbatim "A ?"}
   536   \item Option @{verbatim "A ?"}
   537 
   537 
   538   @{rail "A ?"}
   538   @{rail \<open>A ?\<close>}
   539 
   539 
   540   \item Repetition @{verbatim "A *"}
   540   \item Repetition @{verbatim "A *"}
   541 
   541 
   542   @{rail "A *"}
   542   @{rail \<open>A *\<close>}
   543 
   543 
   544   \item Repetition with separator @{verbatim "A * sep"}
   544   \item Repetition with separator @{verbatim "A * sep"}
   545 
   545 
   546   @{rail "A * sep"}
   546   @{rail \<open>A * sep\<close>}
   547 
   547 
   548   \item Strict repetition @{verbatim "A +"}
   548   \item Strict repetition @{verbatim "A +"}
   549 
   549 
   550   @{rail "A +"}
   550   @{rail \<open>A +\<close>}
   551 
   551 
   552   \item Strict repetition with separator @{verbatim "A + sep"}
   552   \item Strict repetition with separator @{verbatim "A + sep"}
   553 
   553 
   554   @{rail "A + sep"}
   554   @{rail \<open>A + sep\<close>}
   555 
   555 
   556   \end{itemize}
   556   \end{itemize}
   557 *}
   557 *}
   558 
   558 
   559 
   559 
   562 text {*
   562 text {*
   563   \begin{matharray}{rcl}
   563   \begin{matharray}{rcl}
   564     @{command_def "display_drafts"}@{text "\<^sup>*"} & : & @{text "any \<rightarrow>"} \\
   564     @{command_def "display_drafts"}@{text "\<^sup>*"} & : & @{text "any \<rightarrow>"} \\
   565   \end{matharray}
   565   \end{matharray}
   566 
   566 
   567   @{rail "
   567   @{rail \<open>
   568     @@{command display_drafts} (@{syntax name} +)
   568     @@{command display_drafts} (@{syntax name} +)
   569 
   569   \<close>}
   570   "}
       
   571 
   570 
   572   \begin{description}
   571   \begin{description}
   573 
   572 
   574   \item @{command "display_drafts"}~@{text paths} performs simple output of a
   573   \item @{command "display_drafts"}~@{text paths} performs simple output of a
   575   given list of raw source files. Only those symbols that do not require
   574   given list of raw source files. Only those symbols that do not require