doc-src/proof.sty
author haftmann
Tue Oct 10 13:59:12 2006 +0200 (2006-10-10)
changeset 20950 981fa0ce23ed
parent 3126 feb7a5d01c1e
permissions -rw-r--r--
added IsarAdvanced material
paulson@3126
     1
\ProvidesPackage{proof}[1995/05/22]
paulson@3126
     2
%       proof.sty       (Proof Figure Macros)
berghofe@3095
     3
%
paulson@3126
     4
%       version 2.0
paulson@3126
     5
%       June 24, 1991
paulson@3126
     6
%       Copyright (C) 1990,1991 Makoto Tatsuta (tatsuta@riec.tohoku.ac.jp)
paulson@3126
     7
%
paulson@3126
     8
%Modified for LaTeX-2e by L. C. Paulson
berghofe@3095
     9
% 
berghofe@3095
    10
% This program is free software; you can redistribute it or modify
berghofe@3095
    11
% it under the terms of the GNU General Public License as published by
berghofe@3095
    12
% the Free Software Foundation; either versions 1, or (at your option)
berghofe@3095
    13
% any later version.
berghofe@3095
    14
% 
berghofe@3095
    15
% This program is distributed in the hope that it will be useful
berghofe@3095
    16
% but WITHOUT ANY WARRANTY; without even the implied warranty of
berghofe@3095
    17
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
berghofe@3095
    18
% GNU General Public License for more details.
berghofe@3095
    19
%
paulson@3126
    20
%       Usage:
paulson@3126
    21
%               In \documentstyle, specify an optional style `proof', say,
paulson@3126
    22
%                       \documentstyle[proof]{article}.
paulson@3126
    23
%
paulson@3126
    24
%       The following macros are available:
berghofe@3095
    25
%
paulson@3126
    26
%       In all the following macros, all the arguments such as
paulson@3126
    27
%       <Lowers> and <Uppers> are processed in math mode.
berghofe@3095
    28
%
paulson@3126
    29
%       \infer<Lower><Uppers>
paulson@3126
    30
%               draws an inference.
berghofe@3095
    31
%
paulson@3126
    32
%               Use & in <Uppers> to delimit upper formulae.
paulson@3126
    33
%               <Uppers> consists more than 0 formulae.
berghofe@3095
    34
%
paulson@3126
    35
%               \infer returns \hbox{ ... } or \vbox{ ... } and
paulson@3126
    36
%               sets \@LeftOffset and \@RightOffset globally.
berghofe@3095
    37
%
paulson@3126
    38
%       \infer[<Label>]<Lower><Uppers>
paulson@3126
    39
%               draws an inference labeled with <Label>.
berghofe@3095
    40
%
paulson@3126
    41
%       \infer*<Lower><Uppers>
paulson@3126
    42
%               draws a many step deduction.
berghofe@3095
    43
%
paulson@3126
    44
%       \infer*[<Label>]<Lower><Uppers>
paulson@3126
    45
%               draws a many step deduction labeled with <Label>.
berghofe@3095
    46
%
paulson@3126
    47
%       \infer=<Lower><Uppers>
paulson@3126
    48
%               draws a double-ruled deduction.
berghofe@3095
    49
%
paulson@3126
    50
%       \infer=[<Label>]<Lower><Uppers>
paulson@3126
    51
%               draws a double-ruled deduction labeled with <Label>.
berghofe@3095
    52
%
paulson@3126
    53
%       \deduce<Lower><Uppers>
paulson@3126
    54
%               draws an inference without a rule.
berghofe@3095
    55
%
paulson@3126
    56
%       \deduce[<Proof>]<Lower><Uppers>
paulson@3126
    57
%               draws a many step deduction with a proof name.
paulson@3126
    58
%
paulson@3126
    59
%       Example:
paulson@3126
    60
%               If you want to write
paulson@3126
    61
%                           B C
paulson@3126
    62
%                          -----
paulson@3126
    63
%                      A     D
paulson@3126
    64
%                     ----------
paulson@3126
    65
%                         E
paulson@3126
    66
%       use
paulson@3126
    67
%               \infer{E}{
paulson@3126
    68
%                       A
paulson@3126
    69
%                       &
paulson@3126
    70
%                       \infer{D}{B & C}
paulson@3126
    71
%               }
berghofe@3095
    72
%
berghofe@3095
    73
paulson@3126
    74
%       Style Parameters
berghofe@3095
    75
paulson@3126
    76
\newdimen\inferLineSkip         \inferLineSkip=2pt
paulson@3126
    77
\newdimen\inferLabelSkip        \inferLabelSkip=5pt
berghofe@3095
    78
\def\inferTabSkip{\quad}
berghofe@3095
    79
paulson@3126
    80
%       Variables
berghofe@3095
    81
paulson@3126
    82
\newdimen\@LeftOffset   % global
paulson@3126
    83
\newdimen\@RightOffset  % global
paulson@3126
    84
\newdimen\@SavedLeftOffset      % safe from users
berghofe@3095
    85
berghofe@3095
    86
\newdimen\UpperWidth
berghofe@3095
    87
\newdimen\LowerWidth
berghofe@3095
    88
\newdimen\LowerHeight
berghofe@3095
    89
\newdimen\UpperLeftOffset
berghofe@3095
    90
\newdimen\UpperRightOffset
berghofe@3095
    91
\newdimen\UpperCenter
berghofe@3095
    92
\newdimen\LowerCenter
berghofe@3095
    93
\newdimen\UpperAdjust
berghofe@3095
    94
\newdimen\RuleAdjust
berghofe@3095
    95
\newdimen\LowerAdjust
berghofe@3095
    96
\newdimen\RuleWidth
berghofe@3095
    97
\newdimen\HLabelAdjust
berghofe@3095
    98
\newdimen\VLabelAdjust
berghofe@3095
    99
\newdimen\WidthAdjust
berghofe@3095
   100
berghofe@3095
   101
\newbox\@UpperPart
berghofe@3095
   102
\newbox\@LowerPart
berghofe@3095
   103
\newbox\@LabelPart
berghofe@3095
   104
\newbox\ResultBox
berghofe@3095
   105
paulson@3126
   106
%       Flags
berghofe@3095
   107
paulson@3126
   108
\newif\if@inferRule     % whether \@infer draws a rule.
paulson@3126
   109
\newif\if@DoubleRule    % whether \@infer draws doulbe rules.
paulson@3126
   110
\newif\if@ReturnLeftOffset      % whether \@infer returns \@LeftOffset.
paulson@3126
   111
\newif\if@MathSaved     % whether inner math mode where \infer or
paulson@3126
   112
                        % \deduce appears.
berghofe@3095
   113
paulson@3126
   114
%       Special Fonts
berghofe@3095
   115
berghofe@3095
   116
\def\DeduceSym{\vtop{\baselineskip4\p@ \lineskiplimit\z@
berghofe@3095
   117
    \vbox{\hbox{.}\hbox{.}\hbox{.}}\hbox{.}}}
berghofe@3095
   118
paulson@3126
   119
%       Math Save Macros
berghofe@3095
   120
%
paulson@3126
   121
%       \@SaveMath is called in the very begining of toplevel macros
paulson@3126
   122
%       which are \infer and \deduce.
paulson@3126
   123
%       \@RestoreMath is called in the very last before toplevel macros end.
paulson@3126
   124
%       Remark \infer and \deduce ends calling \@infer.
paulson@3126
   125
%TEMPORARILY DELETED BY LCP DUE TO CONFLICT WITH CLASS "amsmath.sty"
berghofe@3095
   126
paulson@3126
   127
\def\@SaveMath{}
berghofe@3095
   128
paulson@3126
   129
\def\@RestoreMath{}
berghofe@3095
   130
paulson@3126
   131
%       Macros
berghofe@3095
   132
berghofe@3095
   133
\def\@ifEmpty#1#2#3{\def\@tempa{\@empty}\def\@tempb{#1}\relax
paulson@3126
   134
        \ifx \@tempa \@tempb #2\else #3\fi }
paulson@3126
   135
paulson@3126
   136
\def\infer{\@SaveMath \@ifnextchar *{\@inferSteps}{\relax
paulson@3126
   137
        \@ifnextchar ={\@inferDoubleRule}{\@inferOneStep}}}
berghofe@3095
   138
paulson@3126
   139
\def\@inferOneStep{\@inferRuletrue \@DoubleRulefalse
paulson@3126
   140
        \@ifnextchar [{\@infer}{\@infer[\@empty]}}
berghofe@3095
   141
paulson@3126
   142
\def\@inferDoubleRule={\@inferRuletrue \@DoubleRuletrue
paulson@3126
   143
        \@ifnextchar [{\@infer}{\@infer[\@empty]}}
berghofe@3095
   144
berghofe@3095
   145
\def\@inferSteps*{\@ifnextchar [{\@@inferSteps}{\@@inferSteps[\@empty]}}
berghofe@3095
   146
berghofe@3095
   147
\def\@@inferSteps[#1]{\@deduce{#1}[\DeduceSym]}
berghofe@3095
   148
berghofe@3095
   149
\def\deduce{\@SaveMath \@ifnextchar [{\@deduce{\@empty}}
paulson@3126
   150
        {\@inferRulefalse \@infer[\@empty]}}
berghofe@3095
   151
paulson@3126
   152
%       \@deduce<Proof Label>[<Proof>]<Lower><Uppers>
berghofe@3095
   153
berghofe@3095
   154
\def\@deduce#1[#2]#3#4{\@inferRulefalse
paulson@3126
   155
        \@infer[\@empty]{#3}{\@SaveMath \@infer[{#1}]{#2}{#4}}}
berghofe@3095
   156
paulson@3126
   157
%       \@infer[<Label>]<Lower><Uppers>
paulson@3126
   158
%               If \@inferRuletrue, it draws a rule and <Label> is right to
paulson@3126
   159
%               a rule. In this case, if \@DoubleRuletrue, it draws
paulson@3126
   160
%               double rules.
paulson@3126
   161
%
paulson@3126
   162
%               Otherwise, draws no rule and <Label> is right to <Lower>.
berghofe@3095
   163
berghofe@3095
   164
\def\@infer[#1]#2#3{\relax
berghofe@3095
   165
% Get parameters
paulson@3126
   166
        \if@ReturnLeftOffset \else \@SavedLeftOffset=\@LeftOffset \fi
paulson@3126
   167
        \setbox\@LabelPart=\hbox{$#1$}\relax
paulson@3126
   168
        \setbox\@LowerPart=\hbox{$#2$}\relax
berghofe@3095
   169
%
paulson@3126
   170
        \global\@LeftOffset=0pt
paulson@3126
   171
        \setbox\@UpperPart=\vbox{\tabskip=0pt \halign{\relax
paulson@3126
   172
                \global\@RightOffset=0pt \@ReturnLeftOffsettrue $##$&&
paulson@3126
   173
                \inferTabSkip
paulson@3126
   174
                \global\@RightOffset=0pt \@ReturnLeftOffsetfalse $##$\cr
paulson@3126
   175
                #3\cr}}\relax
paulson@3126
   176
%                       Here is a little trick.
paulson@3126
   177
%                       \@ReturnLeftOffsettrue(false) influences on \infer or
paulson@3126
   178
%                       \deduce placed in ## locally
paulson@3126
   179
%                       because of \@SaveMath and \@RestoreMath.
paulson@3126
   180
        \UpperLeftOffset=\@LeftOffset
paulson@3126
   181
        \UpperRightOffset=\@RightOffset
berghofe@3095
   182
% Calculate Adjustments
paulson@3126
   183
        \LowerWidth=\wd\@LowerPart
paulson@3126
   184
        \LowerHeight=\ht\@LowerPart
paulson@3126
   185
        \LowerCenter=0.5\LowerWidth
paulson@3126
   186
%
paulson@3126
   187
        \UpperWidth=\wd\@UpperPart \advance\UpperWidth by -\UpperLeftOffset
paulson@3126
   188
        \advance\UpperWidth by -\UpperRightOffset
paulson@3126
   189
        \UpperCenter=\UpperLeftOffset
paulson@3126
   190
        \advance\UpperCenter by 0.5\UpperWidth
berghofe@3095
   191
%
paulson@3126
   192
        \ifdim \UpperWidth > \LowerWidth
paulson@3126
   193
                % \UpperCenter > \LowerCenter
paulson@3126
   194
        \UpperAdjust=0pt
paulson@3126
   195
        \RuleAdjust=\UpperLeftOffset
paulson@3126
   196
        \LowerAdjust=\UpperCenter \advance\LowerAdjust by -\LowerCenter
paulson@3126
   197
        \RuleWidth=\UpperWidth
paulson@3126
   198
        \global\@LeftOffset=\LowerAdjust
paulson@3126
   199
%
paulson@3126
   200
        \else   % \UpperWidth <= \LowerWidth
paulson@3126
   201
        \ifdim \UpperCenter > \LowerCenter
berghofe@3095
   202
%
paulson@3126
   203
        \UpperAdjust=0pt
paulson@3126
   204
        \RuleAdjust=\UpperCenter \advance\RuleAdjust by -\LowerCenter
paulson@3126
   205
        \LowerAdjust=\RuleAdjust
paulson@3126
   206
        \RuleWidth=\LowerWidth
paulson@3126
   207
        \global\@LeftOffset=\LowerAdjust
berghofe@3095
   208
%
paulson@3126
   209
        \else   % \UpperWidth <= \LowerWidth
paulson@3126
   210
                % \UpperCenter <= \LowerCenter
berghofe@3095
   211
%
paulson@3126
   212
        \UpperAdjust=\LowerCenter \advance\UpperAdjust by -\UpperCenter
paulson@3126
   213
        \RuleAdjust=0pt
paulson@3126
   214
        \LowerAdjust=0pt
paulson@3126
   215
        \RuleWidth=\LowerWidth
paulson@3126
   216
        \global\@LeftOffset=0pt
berghofe@3095
   217
%
paulson@3126
   218
        \fi\fi
berghofe@3095
   219
% Make a box
paulson@3126
   220
        \if@inferRule
berghofe@3095
   221
%
paulson@3126
   222
        \setbox\ResultBox=\vbox{
paulson@3126
   223
                \moveright \UpperAdjust \box\@UpperPart
paulson@3126
   224
                \nointerlineskip \kern\inferLineSkip
paulson@3126
   225
                \if@DoubleRule
paulson@3126
   226
                \moveright \RuleAdjust \vbox{\hrule width\RuleWidth
paulson@3126
   227
                        \kern 1pt\hrule width\RuleWidth}\relax
paulson@3126
   228
                \else
paulson@3126
   229
                \moveright \RuleAdjust \vbox{\hrule width\RuleWidth}\relax
paulson@3126
   230
                \fi
paulson@3126
   231
                \nointerlineskip \kern\inferLineSkip
paulson@3126
   232
                \moveright \LowerAdjust \box\@LowerPart }\relax
berghofe@3095
   233
%
paulson@3126
   234
        \@ifEmpty{#1}{}{\relax
berghofe@3095
   235
%
paulson@3126
   236
        \HLabelAdjust=\wd\ResultBox     \advance\HLabelAdjust by -\RuleAdjust
paulson@3126
   237
        \advance\HLabelAdjust by -\RuleWidth
paulson@3126
   238
        \WidthAdjust=\HLabelAdjust
paulson@3126
   239
        \advance\WidthAdjust by -\inferLabelSkip
paulson@3126
   240
        \advance\WidthAdjust by -\wd\@LabelPart
paulson@3126
   241
        \ifdim \WidthAdjust < 0pt \WidthAdjust=0pt \fi
berghofe@3095
   242
%
paulson@3126
   243
        \VLabelAdjust=\dp\@LabelPart
paulson@3126
   244
        \advance\VLabelAdjust by -\ht\@LabelPart
paulson@3126
   245
        \VLabelAdjust=0.5\VLabelAdjust  \advance\VLabelAdjust by \LowerHeight
paulson@3126
   246
        \advance\VLabelAdjust by \inferLineSkip
berghofe@3095
   247
%
paulson@3126
   248
        \setbox\ResultBox=\hbox{\box\ResultBox
paulson@3126
   249
                \kern -\HLabelAdjust \kern\inferLabelSkip
paulson@3126
   250
                \raise\VLabelAdjust \box\@LabelPart \kern\WidthAdjust}\relax
berghofe@3095
   251
%
paulson@3126
   252
        }\relax % end @ifEmpty
berghofe@3095
   253
%
paulson@3126
   254
        \else % \@inferRulefalse
berghofe@3095
   255
%
paulson@3126
   256
        \setbox\ResultBox=\vbox{
paulson@3126
   257
                \moveright \UpperAdjust \box\@UpperPart
paulson@3126
   258
                \nointerlineskip \kern\inferLineSkip
paulson@3126
   259
                \moveright \LowerAdjust \hbox{\unhbox\@LowerPart
paulson@3126
   260
                        \@ifEmpty{#1}{}{\relax
paulson@3126
   261
                        \kern\inferLabelSkip \unhbox\@LabelPart}}}\relax
paulson@3126
   262
        \fi
berghofe@3095
   263
%
paulson@3126
   264
        \global\@RightOffset=\wd\ResultBox
paulson@3126
   265
        \global\advance\@RightOffset by -\@LeftOffset
paulson@3126
   266
        \global\advance\@RightOffset by -\LowerWidth
paulson@3126
   267
        \if@ReturnLeftOffset \else \global\@LeftOffset=\@SavedLeftOffset \fi
berghofe@3095
   268
%
paulson@3126
   269
        \box\ResultBox
paulson@3126
   270
        \@RestoreMath
berghofe@3095
   271
}
paulson@3126
   272
\endinput