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