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