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