lib/texinputs/isabelle.sty
author wenzelm
Wed Sep 12 12:09:40 2012 +0200 (2012-09-12)
changeset 49320 94bd2fb83d11
parent 45646 02afa20cf397
child 53021 d0fa3f446b9d
permissions -rw-r--r--
discontinued experiment with literal replacement text in PDF (cf. b646316f8b3c, 2ff10e613689);
     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{\isastyleminor}{\UNDEF}
    13 \newcommand{\isastylescript}{\UNDEF}
    14 \newcommand{\isastyletext}{\normalsize\rm}
    15 \newcommand{\isastyletxt}{\rm}
    16 \newcommand{\isastylecmt}{\rm}
    17 
    18 \newcommand{\isaspacing}{%
    19   \sfcode 42 1000 % .
    20   \sfcode 63 1000 % ?
    21   \sfcode 33 1000 % !
    22   \sfcode 58 1000 % :
    23   \sfcode 59 1000 % ;
    24   \sfcode 44 1000 % ,
    25 }
    26 
    27 %symbol markup -- \emph achieves decent spacing via italic corrections
    28 \newcommand{\isamath}[1]{\emph{$#1$}}
    29 \newcommand{\isatext}[1]{\emph{#1}}
    30 \DeclareRobustCommand{\isascriptstyle}{\def\isamath##1{##1}\def\isatext##1{\mbox{\isaspacing\isastylescript##1}}}
    31 \newcommand{\isactrlsub}[1]{\emph{\isascriptstyle${}\sb{#1}$}}
    32 \newcommand{\isactrlsup}[1]{\emph{\isascriptstyle${}\sp{#1}$}}
    33 \newcommand{\isactrlisub}[1]{\emph{\isascriptstyle${}\sb{#1}$}}
    34 \newcommand{\isactrlisup}[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 \newcommand{\isaantiqopen}{\isakeyword{\isacharbraceleft}}
    43 \newcommand{\isaantiqclose}{\isakeyword{\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{isabelle}
    54 {\begin{trivlist}\begin{isabellebody}\item\relax}
    55 {\end{isabellebody}\end{trivlist}}
    56 
    57 \newcommand{\isa}[1]{\emph{\isaspacing\isastyleminor #1}}
    58 
    59 \newcommand{\isaindent}[1]{\hphantom{#1}}
    60 \newcommand{\isanewline}{\mbox{}\par\mbox{}}
    61 \newcommand{\isasep}{}
    62 \newcommand{\isadigit}[1]{#1}
    63 
    64 \newcommand{\isachardefaults}{%
    65 \chardef\isacharbang=`\!%
    66 \chardef\isachardoublequote=`\"%
    67 \chardef\isachardoublequoteopen=`\"%
    68 \chardef\isachardoublequoteclose=`\"%
    69 \chardef\isacharhash=`\#%
    70 \chardef\isachardollar=`\$%
    71 \chardef\isacharpercent=`\%%
    72 \chardef\isacharampersand=`\&%
    73 \chardef\isacharprime=`\'%
    74 \chardef\isacharparenleft=`\(%
    75 \chardef\isacharparenright=`\)%
    76 \chardef\isacharasterisk=`\*%
    77 \chardef\isacharplus=`\+%
    78 \chardef\isacharcomma=`\,%
    79 \chardef\isacharminus=`\-%
    80 \chardef\isachardot=`\.%
    81 \chardef\isacharslash=`\/%
    82 \chardef\isacharcolon=`\:%
    83 \chardef\isacharsemicolon=`\;%
    84 \chardef\isacharless=`\<%
    85 \chardef\isacharequal=`\=%
    86 \chardef\isachargreater=`\>%
    87 \chardef\isacharquery=`\?%
    88 \chardef\isacharat=`\@%
    89 \chardef\isacharbrackleft=`\[%
    90 \chardef\isacharbackslash=`\\%
    91 \chardef\isacharbrackright=`\]%
    92 \chardef\isacharcircum=`\^%
    93 \chardef\isacharunderscore=`\_%
    94 \def\isacharunderscorekeyword{\_}%
    95 \chardef\isacharbackquote=`\`%
    96 \chardef\isacharbackquoteopen=`\`%
    97 \chardef\isacharbackquoteclose=`\`%
    98 \chardef\isacharbraceleft=`\{%
    99 \chardef\isacharbar=`\|%
   100 \chardef\isacharbraceright=`\}%
   101 \chardef\isachartilde=`\~%
   102 \def\isacharverbatimopen{\isacharbraceleft\isacharasterisk}%
   103 \def\isacharverbatimclose{\isacharasterisk\isacharbraceright}%
   104 }
   105 
   106 
   107 % keyword and section markup
   108 
   109 \newcommand{\isakeyword}[1]
   110 {\emph{\bf\def\isachardot{.}\def\isacharunderscore{\isacharunderscorekeyword}%
   111 \def\isacharbraceleft{\{}\def\isacharbraceright{\}}#1}}
   112 \newcommand{\isacommand}[1]{\isakeyword{#1}}
   113 
   114 \newcommand{\isamarkupheader}[1]{\section{#1}}
   115 \newcommand{\isamarkupchapter}[1]{\chapter{#1}}
   116 \newcommand{\isamarkupsection}[1]{\section{#1}}
   117 \newcommand{\isamarkupsubsection}[1]{\subsection{#1}}
   118 \newcommand{\isamarkupsubsubsection}[1]{\subsubsection{#1}}
   119 \newcommand{\isamarkupsect}[1]{\section{#1}}
   120 \newcommand{\isamarkupsubsect}[1]{\subsection{#1}}
   121 \newcommand{\isamarkupsubsubsect}[1]{\subsubsection{#1}}
   122 
   123 \newif\ifisamarkup
   124 \newcommand{\isabeginpar}{\par\ifisamarkup\relax\else\medskip\fi}
   125 \newcommand{\isaendpar}{\par\medskip}
   126 \newenvironment{isapar}{\parindent\isa@parindent\parskip\isa@parskip\isabeginpar}{\isaendpar}
   127 \newenvironment{isamarkuptext}{\par\isastyletext\begin{isapar}}{\end{isapar}}
   128 \newenvironment{isamarkuptxt}{\par\isastyletxt\begin{isapar}}{\end{isapar}}
   129 \newcommand{\isamarkupcmt}[1]{{\isastylecmt--- #1}}
   130 
   131 
   132 % styles
   133 
   134 \def\isabellestyle#1{\csname isabellestyle#1\endcsname}
   135 
   136 \newcommand{\isabellestyledefault}{%
   137 \def\isastyle{\small\tt\slshape}%
   138 \def\isastyleminor{\small\tt\slshape}%
   139 \def\isastylescript{\footnotesize\tt\slshape}%
   140 \isachardefaults%
   141 }
   142 \isabellestyledefault
   143 
   144 \newcommand{\isabellestylett}{%
   145 \def\isastyle{\small\tt}%
   146 \def\isastyleminor{\small\tt}%
   147 \def\isastylescript{\footnotesize\tt}%
   148 \isachardefaults%
   149 }
   150 
   151 \newcommand{\isabellestyleit}{%
   152 \def\isastyle{\small\it}%
   153 \def\isastyleminor{\it}%
   154 \def\isastylescript{\footnotesize\it}%
   155 \isachardefaults%
   156 \def\isacharunderscorekeyword{\mbox{-}}%
   157 \def\isacharbang{\isamath{!}}%
   158 \def\isachardoublequote{}%
   159 \def\isachardoublequoteopen{}%
   160 \def\isachardoublequoteclose{}%
   161 \def\isacharhash{\isamath{\#}}%
   162 \def\isachardollar{\isamath{\$}}%
   163 \def\isacharpercent{\isamath{\%}}%
   164 \def\isacharampersand{\isamath{\&}}%
   165 \def\isacharprime{\isamath{\mskip2mu{'}\mskip-2mu}}%
   166 \def\isacharparenleft{\isamath{(}}%
   167 \def\isacharparenright{\isamath{)}}%
   168 \def\isacharasterisk{\isamath{*}}%
   169 \def\isacharplus{\isamath{+}}%
   170 \def\isacharcomma{\isamath{\mathord,}}%
   171 \def\isacharminus{\isamath{-}}%
   172 \def\isachardot{\isamath{\mathord.}}%
   173 \def\isacharslash{\isamath{/}}%
   174 \def\isacharcolon{\isamath{\mathord:}}%
   175 \def\isacharsemicolon{\isamath{\mathord;}}%
   176 \def\isacharless{\isamath{<}}%
   177 \def\isacharequal{\isamath{=}}%
   178 \def\isachargreater{\isamath{>}}%
   179 \def\isacharat{\isamath{@}}%
   180 \def\isacharbrackleft{\isamath{[}}%
   181 \def\isacharbackslash{\isamath{\backslash}}%
   182 \def\isacharbrackright{\isamath{]}}%
   183 \def\isacharunderscore{\mbox{-}}%
   184 \def\isacharbraceleft{\isamath{\{}}%
   185 \def\isacharbar{\isamath{\mid}}%
   186 \def\isacharbraceright{\isamath{\}}}%
   187 \def\isachartilde{\isamath{{}\sp{\sim}}}%
   188 \def\isacharbackquoteopen{\isatext{\raise.3ex\hbox{$\scriptscriptstyle\langle$}}}%
   189 \def\isacharbackquoteclose{\isatext{\raise.3ex\hbox{$\scriptscriptstyle\rangle$}}}%
   190 \def\isacharverbatimopen{\isamath{\langle\!\langle}}%
   191 \def\isacharverbatimclose{\isamath{\rangle\!\rangle}}%
   192 }
   193 
   194 \newcommand{\isabellestyleliteral}{%
   195 \isabellestyleit%
   196 \def\isacharunderscore{\_}%
   197 \def\isacharunderscorekeyword{\_}%
   198 \chardef\isacharbackquoteopen=`\`%
   199 \chardef\isacharbackquoteclose=`\`%
   200 }
   201 
   202 \newcommand{\isabellestylesl}{%
   203 \isabellestyleit%
   204 \def\isastyle{\small\sl}%
   205 \def\isastyleminor{\sl}%
   206 \def\isastylescript{\footnotesize\sl}%
   207 }
   208 
   209 
   210 % tagged regions
   211 
   212 %plain TeX version of comment package -- much faster!
   213 \let\isafmtname\fmtname\def\fmtname{plain}
   214 \usepackage{comment}
   215 \let\fmtname\isafmtname
   216 
   217 \newcommand{\isafold}[1]{\emph{$\langle\mathord{\mathit{#1}}\rangle$}}
   218 
   219 \newcommand{\isakeeptag}[1]%
   220 {\includecomment{isadelim#1}\includecomment{isatag#1}\csarg\def{isafold#1}{}}
   221 \newcommand{\isadroptag}[1]%
   222 {\excludecomment{isadelim#1}\excludecomment{isatag#1}\csarg\def{isafold#1}{}}
   223 \newcommand{\isafoldtag}[1]%
   224 {\includecomment{isadelim#1}\excludecomment{isatag#1}\csarg\def{isafold#1}{\isafold{#1}}}
   225 
   226 \isakeeptag{theory}
   227 \isakeeptag{proof}
   228 \isakeeptag{ML}
   229 \isakeeptag{visible}
   230 \isadroptag{invisible}
   231 
   232 \IfFileExists{isabelletags.sty}{\usepackage{isabelletags}}{}