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