lib/texinputs/isabelle.sty
author wenzelm
Fri Nov 06 23:31:50 2015 +0100 (2015-11-06)
changeset 61595 3591274c607e
parent 61473 34d1913f0b20
child 63590 4854f7ee0987
permissions -rw-r--r--
more formal treatment of control symbols;
     1 %%
     2 %% macros for Isabelle generated LaTeX output
     3 %%
     4 
     5 %%% Simple document preparation (based on theory token language and symbols)
     6 
     7 % isabelle environments
     8 
     9 \newcommand{\isabellecontext}{UNKNOWN}
    10 \newcommand{\setisabellecontext}[1]{\def\isabellecontext{#1}}
    11 
    12 \newcommand{\isastyle}{\UNDEF}
    13 \newcommand{\isastylett}{\UNDEF}
    14 \newcommand{\isastyleminor}{\UNDEF}
    15 \newcommand{\isastyleminortt}{\UNDEF}
    16 \newcommand{\isastylescript}{\UNDEF}
    17 \newcommand{\isastyletext}{\normalsize\rm}
    18 \newcommand{\isastyletxt}{\rm}
    19 \newcommand{\isastylecmt}{\rm}
    20 
    21 \newcommand{\isaspacing}{%
    22   \sfcode 42 1000 % .
    23   \sfcode 63 1000 % ?
    24   \sfcode 33 1000 % !
    25   \sfcode 58 1000 % :
    26   \sfcode 59 1000 % ;
    27   \sfcode 44 1000 % ,
    28 }
    29 
    30 %symbol markup -- \emph achieves decent spacing via italic corrections
    31 \newcommand{\isamath}[1]{\emph{$#1$}}
    32 \newcommand{\isatext}[1]{\emph{#1}}
    33 \DeclareRobustCommand{\isascriptstyle}{\def\isamath##1{##1}\def\isatext##1{\mbox{\isaspacing\isastylescript##1}}}
    34 \newcommand{\isactrlsub}[1]{\emph{\isascriptstyle${}\sb{#1}$}}
    35 \newcommand{\isactrlsup}[1]{\emph{\isascriptstyle${}\sp{#1}$}}
    36 \DeclareRobustCommand{\isactrlbsub}{\emph\bgroup\math{}\sb\bgroup\mbox\bgroup\isaspacing\isastylescript}
    37 \DeclareRobustCommand{\isactrlesub}{\egroup\egroup\endmath\egroup}
    38 \DeclareRobustCommand{\isactrlbsup}{\emph\bgroup\math{}\sp\bgroup\mbox\bgroup\isaspacing\isastylescript}
    39 \DeclareRobustCommand{\isactrlesup}{\egroup\egroup\endmath\egroup}
    40 \newcommand{\isactrlbold}[1]{{\bfseries\upshape\boldmath#1}}
    41 
    42 \newcommand{\isaantiqcontrol}[1]{\isatt{{\char`\\}{\char`\<}{\char`\^}#1{\char`\>}}}
    43 \newenvironment{isaantiq}{{\isacharat\isacharbraceleft}}{{\isacharbraceright}}
    44 
    45 \newdimen\isa@parindent\newdimen\isa@parskip
    46 
    47 \newenvironment{isabellebody}{%
    48 \isamarkuptrue\par%
    49 \isa@parindent\parindent\parindent0pt%
    50 \isa@parskip\parskip\parskip0pt%
    51 \isaspacing\isastyle}{\par}
    52 
    53 \newenvironment{isabellebodytt}{%
    54 \isamarkuptrue\par%
    55 \isa@parindent\parindent\parindent0pt%
    56 \isa@parskip\parskip\parskip0pt%
    57 \isaspacing\isastylett}{\par}
    58 
    59 \newenvironment{isabelle}
    60 {\begin{trivlist}\begin{isabellebody}\item\relax}
    61 {\end{isabellebody}\end{trivlist}}
    62 
    63 \newenvironment{isabellett}
    64 {\begin{trivlist}\begin{isabellebodytt}\item\relax}
    65 {\end{isabellebodytt}\end{trivlist}}
    66 
    67 \newcommand{\isa}[1]{\emph{\isaspacing\isastyleminor #1}}
    68 \newcommand{\isatt}[1]{\emph{\isaspacing\isastyleminortt #1}}
    69 
    70 \newcommand{\isaindent}[1]{\hphantom{#1}}
    71 \newcommand{\isanewline}{\mbox{}\par\mbox{}}
    72 \newcommand{\isasep}{}
    73 \newcommand{\isadigit}[1]{#1}
    74 
    75 \newcommand{\isachardefaults}{%
    76 \chardef\isacharbang=`\!%
    77 \chardef\isachardoublequote=`\"%
    78 \chardef\isachardoublequoteopen=`\"%
    79 \chardef\isachardoublequoteclose=`\"%
    80 \chardef\isacharhash=`\#%
    81 \chardef\isachardollar=`\$%
    82 \chardef\isacharpercent=`\%%
    83 \chardef\isacharampersand=`\&%
    84 \chardef\isacharprime=`\'%
    85 \chardef\isacharparenleft=`\(%
    86 \chardef\isacharparenright=`\)%
    87 \chardef\isacharasterisk=`\*%
    88 \chardef\isacharplus=`\+%
    89 \chardef\isacharcomma=`\,%
    90 \chardef\isacharminus=`\-%
    91 \chardef\isachardot=`\.%
    92 \chardef\isacharslash=`\/%
    93 \chardef\isacharcolon=`\:%
    94 \chardef\isacharsemicolon=`\;%
    95 \chardef\isacharless=`\<%
    96 \chardef\isacharequal=`\=%
    97 \chardef\isachargreater=`\>%
    98 \chardef\isacharquery=`\?%
    99 \chardef\isacharat=`\@%
   100 \chardef\isacharbrackleft=`\[%
   101 \chardef\isacharbackslash=`\\%
   102 \chardef\isacharbrackright=`\]%
   103 \chardef\isacharcircum=`\^%
   104 \chardef\isacharunderscore=`\_%
   105 \def\isacharunderscorekeyword{\_}%
   106 \chardef\isacharbackquote=`\`%
   107 \chardef\isacharbackquoteopen=`\`%
   108 \chardef\isacharbackquoteclose=`\`%
   109 \chardef\isacharbraceleft=`\{%
   110 \chardef\isacharbar=`\|%
   111 \chardef\isacharbraceright=`\}%
   112 \chardef\isachartilde=`\~%
   113 \def\isacharverbatimopen{\isacharbraceleft\isacharasterisk}%
   114 \def\isacharverbatimclose{\isacharasterisk\isacharbraceright}%
   115 \def\isacartoucheopen{\isatext{\raise.3ex\hbox{$\scriptscriptstyle\langle$}}}%
   116 \def\isacartoucheclose{\isatext{\raise.3ex\hbox{$\scriptscriptstyle\rangle$}}}%
   117 }
   118 
   119 
   120 % keyword and section markup
   121 
   122 \newcommand{\isakeyword}[1]
   123 {\emph{\bf\def\isachardot{.}\def\isacharunderscore{\isacharunderscorekeyword}%
   124 \def\isacharbraceleft{\{}\def\isacharbraceright{\}}#1}}
   125 \newcommand{\isacommand}[1]{\isakeyword{#1}}
   126 
   127 \newcommand{\isamarkupheader}[1]{\section{#1}}
   128 \newcommand{\isamarkupchapter}[1]{\chapter{#1}}
   129 \newcommand{\isamarkupsection}[1]{\section{#1}}
   130 \newcommand{\isamarkupsubsection}[1]{\subsection{#1}}
   131 \newcommand{\isamarkupsubsubsection}[1]{\subsubsection{#1}}
   132 \newcommand{\isamarkupparagraph}[1]{\paragraph{#1}}
   133 \newcommand{\isamarkupsubparagraph}[1]{\subparagraph{#1}}
   134 
   135 \newif\ifisamarkup
   136 \newcommand{\isabeginpar}{\par\ifisamarkup\relax\else\medskip\fi}
   137 \newcommand{\isaendpar}{\par\medskip}
   138 \newenvironment{isapar}{\parindent\isa@parindent\parskip\isa@parskip\isabeginpar}{\isaendpar}
   139 \newenvironment{isamarkuptext}{\par\isastyletext\begin{isapar}}{\end{isapar}}
   140 \newenvironment{isamarkuptxt}{\par\isastyletxt\begin{isapar}}{\end{isapar}}
   141 \newcommand{\isamarkupcmt}[1]{{\isastylecmt--- #1}}
   142 
   143 
   144 % styles
   145 
   146 \def\isabellestyle#1{\csname isabellestyle#1\endcsname}
   147 
   148 \newcommand{\isabellestyledefault}{%
   149 \def\isastyle{\small\tt\slshape}%
   150 \def\isastylett{\small\tt}%
   151 \def\isastyleminor{\small\tt\slshape}%
   152 \def\isastyleminortt{\small\tt}%
   153 \def\isastylescript{\footnotesize\tt\slshape}%
   154 \isachardefaults%
   155 }
   156 \isabellestyledefault
   157 
   158 \newcommand{\isabellestylett}{%
   159 \def\isastyle{\small\tt}%
   160 \def\isastylett{\small\tt}%
   161 \def\isastyleminor{\small\tt}%
   162 \def\isastyleminortt{\small\tt}%
   163 \def\isastylescript{\footnotesize\tt}%
   164 \isachardefaults%
   165 }
   166 
   167 \newcommand{\isabellestyleit}{%
   168 \def\isastyle{\small\it}%
   169 \def\isastylett{\small\tt}%
   170 \def\isastyleminor{\it}%
   171 \def\isastyleminortt{\tt}%
   172 \def\isastylescript{\footnotesize\it}%
   173 \isachardefaults%
   174 \def\isacharunderscorekeyword{\mbox{-}}%
   175 \def\isacharbang{\isamath{!}}%
   176 \def\isachardoublequote{}%
   177 \def\isachardoublequoteopen{}%
   178 \def\isachardoublequoteclose{}%
   179 \def\isacharhash{\isamath{\#}}%
   180 \def\isachardollar{\isamath{\$}}%
   181 \def\isacharpercent{\isamath{\%}}%
   182 \def\isacharampersand{\isamath{\&}}%
   183 \def\isacharprime{\isamath{\mskip2mu{'}\mskip-2mu}}%
   184 \def\isacharparenleft{\isamath{(}}%
   185 \def\isacharparenright{\isamath{)}}%
   186 \def\isacharasterisk{\isamath{*}}%
   187 \def\isacharplus{\isamath{+}}%
   188 \def\isacharcomma{\isamath{\mathord,}}%
   189 \def\isacharminus{\isamath{-}}%
   190 \def\isachardot{\isamath{\mathord.}}%
   191 \def\isacharslash{\isamath{/}}%
   192 \def\isacharcolon{\isamath{\mathord:}}%
   193 \def\isacharsemicolon{\isamath{\mathord;}}%
   194 \def\isacharless{\isamath{<}}%
   195 \def\isacharequal{\isamath{=}}%
   196 \def\isachargreater{\isamath{>}}%
   197 \def\isacharat{\isamath{@}}%
   198 \def\isacharbrackleft{\isamath{[}}%
   199 \def\isacharbackslash{\isamath{\backslash}}%
   200 \def\isacharbrackright{\isamath{]}}%
   201 \def\isacharunderscore{\mbox{-}}%
   202 \def\isacharbraceleft{\isamath{\{}}%
   203 \def\isacharbar{\isamath{\mid}}%
   204 \def\isacharbraceright{\isamath{\}}}%
   205 \def\isachartilde{\isamath{{}\sp{\sim}}}%
   206 \def\isacharbackquoteopen{\isatext{\raise.3ex\hbox{$\scriptscriptstyle\langle$}}}%
   207 \def\isacharbackquoteclose{\isatext{\raise.3ex\hbox{$\scriptscriptstyle\rangle$}}}%
   208 \def\isacharverbatimopen{\isamath{\langle\!\langle}}%
   209 \def\isacharverbatimclose{\isamath{\rangle\!\rangle}}%
   210 }
   211 
   212 \newcommand{\isabellestyleliteral}{%
   213 \isabellestyleit%
   214 \def\isacharunderscore{\_}%
   215 \def\isacharunderscorekeyword{\_}%
   216 \chardef\isacharbackquoteopen=`\`%
   217 \chardef\isacharbackquoteclose=`\`%
   218 }
   219 
   220 \newcommand{\isabellestyleliteralunderscore}{%
   221 \isabellestyleliteral%
   222 \def\isacharunderscore{\textunderscore}%
   223 \def\isacharunderscorekeyword{\textunderscore}%
   224 }
   225 
   226 \newcommand{\isabellestylesl}{%
   227 \isabellestyleit%
   228 \def\isastyle{\small\sl}%
   229 \def\isastylett{\small\tt}%
   230 \def\isastyleminor{\sl}%
   231 \def\isastyleminortt{\tt}%
   232 \def\isastylescript{\footnotesize\sl}%
   233 }
   234 
   235 
   236 % tagged regions
   237 
   238 %plain TeX version of comment package -- much faster!
   239 \let\isafmtname\fmtname\def\fmtname{plain}
   240 \usepackage{comment}
   241 \let\fmtname\isafmtname
   242 
   243 \newcommand{\isafold}[1]{\emph{$\langle\mathord{\mathit{#1}}\rangle$}}
   244 
   245 \newcommand{\isakeeptag}[1]%
   246 {\includecomment{isadelim#1}\includecomment{isatag#1}\csarg\def{isafold#1}{}}
   247 \newcommand{\isadroptag}[1]%
   248 {\excludecomment{isadelim#1}\excludecomment{isatag#1}\csarg\def{isafold#1}{}}
   249 \newcommand{\isafoldtag}[1]%
   250 {\includecomment{isadelim#1}\excludecomment{isatag#1}\csarg\def{isafold#1}{\isafold{#1}}}
   251 
   252 \isakeeptag{theory}
   253 \isakeeptag{proof}
   254 \isakeeptag{ML}
   255 \isakeeptag{visible}
   256 \isadroptag{invisible}
   257 
   258 \IfFileExists{isabelletags.sty}{\usepackage{isabelletags}}{}