lib/texinputs/isabelle.sty
author wenzelm
Sun Nov 02 16:09:35 2014 +0100 (2014-11-02)
changeset 58870 e2c0d8ef29cb
parent 58868 c5e1cce7ace3
child 61405 d2ce32c5793a
permissions -rw-r--r--
more flexibile \setisabellecontext, independently of header;
     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 \newenvironment{isaantiq}{{\isacharat\isacharbraceleft}}{{\isacharbraceright}}
    43 
    44 \newdimen\isa@parindent\newdimen\isa@parskip
    45 
    46 \newenvironment{isabellebody}{%
    47 \isamarkuptrue\par%
    48 \isa@parindent\parindent\parindent0pt%
    49 \isa@parskip\parskip\parskip0pt%
    50 \isaspacing\isastyle}{\par}
    51 
    52 \newenvironment{isabellebodytt}{%
    53 \isamarkuptrue\par%
    54 \isa@parindent\parindent\parindent0pt%
    55 \isa@parskip\parskip\parskip0pt%
    56 \isaspacing\isastylett}{\par}
    57 
    58 \newenvironment{isabelle}
    59 {\begin{trivlist}\begin{isabellebody}\item\relax}
    60 {\end{isabellebody}\end{trivlist}}
    61 
    62 \newenvironment{isabellett}
    63 {\begin{trivlist}\begin{isabellebodytt}\item\relax}
    64 {\end{isabellebodytt}\end{trivlist}}
    65 
    66 \newcommand{\isa}[1]{\emph{\isaspacing\isastyleminor #1}}
    67 \newcommand{\isatt}[1]{\emph{\isaspacing\isastyleminortt #1}}
    68 
    69 \newcommand{\isaindent}[1]{\hphantom{#1}}
    70 \newcommand{\isanewline}{\mbox{}\par\mbox{}}
    71 \newcommand{\isasep}{}
    72 \newcommand{\isadigit}[1]{#1}
    73 
    74 \newcommand{\isachardefaults}{%
    75 \chardef\isacharbang=`\!%
    76 \chardef\isachardoublequote=`\"%
    77 \chardef\isachardoublequoteopen=`\"%
    78 \chardef\isachardoublequoteclose=`\"%
    79 \chardef\isacharhash=`\#%
    80 \chardef\isachardollar=`\$%
    81 \chardef\isacharpercent=`\%%
    82 \chardef\isacharampersand=`\&%
    83 \chardef\isacharprime=`\'%
    84 \chardef\isacharparenleft=`\(%
    85 \chardef\isacharparenright=`\)%
    86 \chardef\isacharasterisk=`\*%
    87 \chardef\isacharplus=`\+%
    88 \chardef\isacharcomma=`\,%
    89 \chardef\isacharminus=`\-%
    90 \chardef\isachardot=`\.%
    91 \chardef\isacharslash=`\/%
    92 \chardef\isacharcolon=`\:%
    93 \chardef\isacharsemicolon=`\;%
    94 \chardef\isacharless=`\<%
    95 \chardef\isacharequal=`\=%
    96 \chardef\isachargreater=`\>%
    97 \chardef\isacharquery=`\?%
    98 \chardef\isacharat=`\@%
    99 \chardef\isacharbrackleft=`\[%
   100 \chardef\isacharbackslash=`\\%
   101 \chardef\isacharbrackright=`\]%
   102 \chardef\isacharcircum=`\^%
   103 \chardef\isacharunderscore=`\_%
   104 \def\isacharunderscorekeyword{\_}%
   105 \chardef\isacharbackquote=`\`%
   106 \chardef\isacharbackquoteopen=`\`%
   107 \chardef\isacharbackquoteclose=`\`%
   108 \chardef\isacharbraceleft=`\{%
   109 \chardef\isacharbar=`\|%
   110 \chardef\isacharbraceright=`\}%
   111 \chardef\isachartilde=`\~%
   112 \def\isacharverbatimopen{\isacharbraceleft\isacharasterisk}%
   113 \def\isacharverbatimclose{\isacharasterisk\isacharbraceright}%
   114 \def\isacartoucheopen{\isatext{\raise.3ex\hbox{$\scriptscriptstyle\langle$}}}%
   115 \def\isacartoucheclose{\isatext{\raise.3ex\hbox{$\scriptscriptstyle\rangle$}}}%
   116 }
   117 
   118 
   119 % keyword and section markup
   120 
   121 \newcommand{\isakeyword}[1]
   122 {\emph{\bf\def\isachardot{.}\def\isacharunderscore{\isacharunderscorekeyword}%
   123 \def\isacharbraceleft{\{}\def\isacharbraceright{\}}#1}}
   124 \newcommand{\isacommand}[1]{\isakeyword{#1}}
   125 
   126 \newcommand{\isamarkupheader}[1]{\section{#1}}
   127 \newcommand{\isamarkupchapter}[1]{\chapter{#1}}
   128 \newcommand{\isamarkupsection}[1]{\section{#1}}
   129 \newcommand{\isamarkupsubsection}[1]{\subsection{#1}}
   130 \newcommand{\isamarkupsubsubsection}[1]{\subsubsection{#1}}
   131 
   132 \newif\ifisamarkup
   133 \newcommand{\isabeginpar}{\par\ifisamarkup\relax\else\medskip\fi}
   134 \newcommand{\isaendpar}{\par\medskip}
   135 \newenvironment{isapar}{\parindent\isa@parindent\parskip\isa@parskip\isabeginpar}{\isaendpar}
   136 \newenvironment{isamarkuptext}{\par\isastyletext\begin{isapar}}{\end{isapar}}
   137 \newenvironment{isamarkuptxt}{\par\isastyletxt\begin{isapar}}{\end{isapar}}
   138 \newcommand{\isamarkupcmt}[1]{{\isastylecmt--- #1}}
   139 
   140 
   141 % styles
   142 
   143 \def\isabellestyle#1{\csname isabellestyle#1\endcsname}
   144 
   145 \newcommand{\isabellestyledefault}{%
   146 \def\isastyle{\small\tt\slshape}%
   147 \def\isastylett{\small\tt}%
   148 \def\isastyleminor{\small\tt\slshape}%
   149 \def\isastyleminortt{\small\tt}%
   150 \def\isastylescript{\footnotesize\tt\slshape}%
   151 \isachardefaults%
   152 }
   153 \isabellestyledefault
   154 
   155 \newcommand{\isabellestylett}{%
   156 \def\isastyle{\small\tt}%
   157 \def\isastylett{\small\tt}%
   158 \def\isastyleminor{\small\tt}%
   159 \def\isastyleminortt{\small\tt}%
   160 \def\isastylescript{\footnotesize\tt}%
   161 \isachardefaults%
   162 }
   163 
   164 \newcommand{\isabellestyleit}{%
   165 \def\isastyle{\small\it}%
   166 \def\isastylett{\small\tt}%
   167 \def\isastyleminor{\it}%
   168 \def\isastyleminortt{\tt}%
   169 \def\isastylescript{\footnotesize\it}%
   170 \isachardefaults%
   171 \def\isacharunderscorekeyword{\mbox{-}}%
   172 \def\isacharbang{\isamath{!}}%
   173 \def\isachardoublequote{}%
   174 \def\isachardoublequoteopen{}%
   175 \def\isachardoublequoteclose{}%
   176 \def\isacharhash{\isamath{\#}}%
   177 \def\isachardollar{\isamath{\$}}%
   178 \def\isacharpercent{\isamath{\%}}%
   179 \def\isacharampersand{\isamath{\&}}%
   180 \def\isacharprime{\isamath{\mskip2mu{'}\mskip-2mu}}%
   181 \def\isacharparenleft{\isamath{(}}%
   182 \def\isacharparenright{\isamath{)}}%
   183 \def\isacharasterisk{\isamath{*}}%
   184 \def\isacharplus{\isamath{+}}%
   185 \def\isacharcomma{\isamath{\mathord,}}%
   186 \def\isacharminus{\isamath{-}}%
   187 \def\isachardot{\isamath{\mathord.}}%
   188 \def\isacharslash{\isamath{/}}%
   189 \def\isacharcolon{\isamath{\mathord:}}%
   190 \def\isacharsemicolon{\isamath{\mathord;}}%
   191 \def\isacharless{\isamath{<}}%
   192 \def\isacharequal{\isamath{=}}%
   193 \def\isachargreater{\isamath{>}}%
   194 \def\isacharat{\isamath{@}}%
   195 \def\isacharbrackleft{\isamath{[}}%
   196 \def\isacharbackslash{\isamath{\backslash}}%
   197 \def\isacharbrackright{\isamath{]}}%
   198 \def\isacharunderscore{\mbox{-}}%
   199 \def\isacharbraceleft{\isamath{\{}}%
   200 \def\isacharbar{\isamath{\mid}}%
   201 \def\isacharbraceright{\isamath{\}}}%
   202 \def\isachartilde{\isamath{{}\sp{\sim}}}%
   203 \def\isacharbackquoteopen{\isatext{\raise.3ex\hbox{$\scriptscriptstyle\langle$}}}%
   204 \def\isacharbackquoteclose{\isatext{\raise.3ex\hbox{$\scriptscriptstyle\rangle$}}}%
   205 \def\isacharverbatimopen{\isamath{\langle\!\langle}}%
   206 \def\isacharverbatimclose{\isamath{\rangle\!\rangle}}%
   207 }
   208 
   209 \newcommand{\isabellestyleliteral}{%
   210 \isabellestyleit%
   211 \def\isacharunderscore{\_}%
   212 \def\isacharunderscorekeyword{\_}%
   213 \chardef\isacharbackquoteopen=`\`%
   214 \chardef\isacharbackquoteclose=`\`%
   215 }
   216 
   217 \newcommand{\isabellestyleliteralunderscore}{%
   218 \isabellestyleliteral%
   219 \def\isacharunderscore{\textunderscore}%
   220 \def\isacharunderscorekeyword{\textunderscore}%
   221 }
   222 
   223 \newcommand{\isabellestylesl}{%
   224 \isabellestyleit%
   225 \def\isastyle{\small\sl}%
   226 \def\isastylett{\small\tt}%
   227 \def\isastyleminor{\sl}%
   228 \def\isastyleminortt{\tt}%
   229 \def\isastylescript{\footnotesize\sl}%
   230 }
   231 
   232 
   233 % tagged regions
   234 
   235 %plain TeX version of comment package -- much faster!
   236 \let\isafmtname\fmtname\def\fmtname{plain}
   237 \usepackage{comment}
   238 \let\fmtname\isafmtname
   239 
   240 \newcommand{\isafold}[1]{\emph{$\langle\mathord{\mathit{#1}}\rangle$}}
   241 
   242 \newcommand{\isakeeptag}[1]%
   243 {\includecomment{isadelim#1}\includecomment{isatag#1}\csarg\def{isafold#1}{}}
   244 \newcommand{\isadroptag}[1]%
   245 {\excludecomment{isadelim#1}\excludecomment{isatag#1}\csarg\def{isafold#1}{}}
   246 \newcommand{\isafoldtag}[1]%
   247 {\includecomment{isadelim#1}\excludecomment{isatag#1}\csarg\def{isafold#1}{\isafold{#1}}}
   248 
   249 \isakeeptag{theory}
   250 \isakeeptag{proof}
   251 \isakeeptag{ML}
   252 \isakeeptag{visible}
   253 \isadroptag{invisible}
   254 
   255 \IfFileExists{isabelletags.sty}{\usepackage{isabelletags}}{}