[Prev][Next][Index][Thread]

Updating proof.sty (proof figure LaTeX macros)



I updated my proof figure macros proof.sty so that it can be used for
not only LaTeX 2.09 but also LaTeX 2e.

This package helps you to write proof figures used in Mathematical
Logic easily and beautifully.  Many logicians and computer scientists
use this package since I wrote this package in 1990.

Files:

proof.sty	definitions of the macros
proofeg.tex	examples

The usage is commented in the head of proof.sty. The output of
proofeg.tex will also explain how to use the macros.

Remark that a large proof figure often requires bigLaTeX instead of
usual LaTeX because of its capacity.

			Makoto Tatsuta
			(tatsuta@kusm.kyoto-u.ac.jp)
			Department of Mathematics, Kyoto University

------------------------------ CUT HERE ------------------------------
#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.1).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 1997-03-06 16:21 JST by <tatsuta@tatsuta>.
# Source directory was `/staff/tatsuta/prooftest'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode       name
# ------ ---------- ------------------------------------------
#   7926 -rw-r--r-- proof.sty
#   1752 -rw-r--r-- proofeg.tex
#
touch -am 1231235999 $$.touch >/dev/null 2>&1
if test ! -f 1231235999 && test -f $$.touch; then
  shar_touch=touch
else
  shar_touch=:
  echo
  echo 'WARNING: not restoring timestamps.  Consider getting and'
  echo "installing GNU \`touch', distributed in GNU File Utilities..."
  echo
fi
rm -f 1231235999 $$.touch
#
# ============= proof.sty ==============
if test -f 'proof.sty' && test X"$1" != X"-c"; then
  echo 'x - skipping proof.sty (file already exists)'
else
  echo 'x - extracting proof.sty (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'proof.sty' &&
%	proof.sty	(Proof Figure Macros)
%
% 	version 3.0 (for both LaTeX 2.09 and LaTeX 2e)
%	Mar 6, 1997
% 	Copyright (C) 1990 -- 1997, Makoto Tatsuta (tatsuta@kusm.kyoto-u.ac.jp)
% 
% This program is free software; you can redistribute it or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either versions 1, or (at your option)
% any later version.
% 
% This program is distributed in the hope that it will be useful
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
%	Usage:
%		In \documentstyle, specify an optional style `proof', say,
%			\documentstyle[proof]{article}.
%
%	The following macros are available:
%
%	In all the following macros, all the arguments such as
%	<Lowers> and <Uppers> are processed in math mode.
%
%	\infer<Lower><Uppers>
%		draws an inference.
%
%		Use & in <Uppers> to delimit upper formulae.
%		<Uppers> consists more than 0 formulae.
%
%		\infer returns \hbox{ ... } or \vbox{ ... } and
%		sets \@LeftOffset and \@RightOffset globally.
%
%	\infer[<Label>]<Lower><Uppers>
%		draws an inference labeled with <Label>.
%
%	\infer*<Lower><Uppers>
%		draws a many step deduction.
%
%	\infer*[<Label>]<Lower><Uppers>
%		draws a many step deduction labeled with <Label>.
%
%	\infer=<Lower><Uppers>
%		draws a double-ruled deduction.
%
%	\infer=[<Label>]<Lower><Uppers>
%		draws a double-ruled deduction labeled with <Label>.
%
%	\deduce<Lower><Uppers>
%		draws an inference without a rule.
%
%	\deduce[<Proof>]<Lower><Uppers>
%		draws a many step deduction with a proof name.
%
%	Example:
%		If you want to write
%       	       	    B C
%		 	   -----
%		       A     D
%		      ----------
%			  E
%	use
%		\infer{E}{
%			A
%			&
%			\infer{D}{B & C}
%		}
%
X
%	Style Parameters
X
\newdimen\inferLineSkip		\inferLineSkip=2pt
\newdimen\inferLabelSkip	\inferLabelSkip=5pt
\def\inferTabSkip{\quad}
X
%	Variables
X
\newdimen\@LeftOffset	% global
\newdimen\@RightOffset	% global
\newdimen\@SavedLeftOffset	% safe from users
X
\newdimen\UpperWidth
\newdimen\LowerWidth
\newdimen\LowerHeight
\newdimen\UpperLeftOffset
\newdimen\UpperRightOffset
\newdimen\UpperCenter
\newdimen\LowerCenter
\newdimen\UpperAdjust
\newdimen\RuleAdjust
\newdimen\LowerAdjust
\newdimen\RuleWidth
\newdimen\HLabelAdjust
\newdimen\VLabelAdjust
\newdimen\WidthAdjust
X
\newbox\@UpperPart
\newbox\@LowerPart
\newbox\@LabelPart
\newbox\ResultBox
X
%	Flags
X
\newif\if@inferRule	% whether \@infer draws a rule.
\newif\if@DoubleRule	% whether \@infer draws doulbe rules.
\newif\if@ReturnLeftOffset	% whether \@infer returns \@LeftOffset.
\newif\if@MathSaved	% whether inner math mode where \infer or
X			% \deduce appears.
X
%	Special Fonts
X
\def\DeduceSym{\vtop{\baselineskip4\p@ \lineskiplimit\z@
X    \vbox{\hbox{.}\hbox{.}\hbox{.}}\hbox{.}}}
X
%	Math Save Macros
%
%	\@SaveMath is called in the very begining of toplevel macros
%	which are \infer and \deduce.
%	\@RestoreMath is called in the very last before toplevel macros end.
%	Remark \infer and \deduce ends calling \@infer.
X
\def\@SaveMath{\@MathSavedfalse \ifmmode \ifinner
X	\relax $\relax \@MathSavedtrue \fi\fi }
X
\def\@RestoreMath{\if@MathSaved \relax $\relax\fi }
X
%	Macros
X
% Renaming @ifnextchar and @ifnch of LaTeX2e to @IFnextchar and @IFnch.
X
\def\@IFnextchar#1#2#3{%
X  \let\reserved@e=#1\def\reserved@a{#2}\def\reserved@b{#3}\futurelet
X    \reserved@c\@IFnch}
\def\@IFnch{\ifx \reserved@c \@sptoken \let\reserved@d\@xifnch
X      \else \ifx \reserved@c \reserved@e\let\reserved@d\reserved@a\else
X          \let\reserved@d\reserved@b\fi
X      \fi \reserved@d}
X
\def\@ifEmpty#1#2#3{\def\@tempa{\@empty}\def\@tempb{#1}\relax
X	\ifx \@tempa \@tempb #2\else #3\fi }
X
\def\infer{\@SaveMath \@IFnextchar *{\@inferSteps}{\relax
X	\@IFnextchar ={\@inferDoubleRule}{\@inferOneStep}}}
X
\def\@inferOneStep{\@inferRuletrue \@DoubleRulefalse
X	\@IFnextchar [{\@infer}{\@infer[\@empty]}}
X
\def\@inferDoubleRule={\@inferRuletrue \@DoubleRuletrue
X	\@IFnextchar [{\@infer}{\@infer[\@empty]}}
X
\def\@inferSteps*{\@IFnextchar [{\@@inferSteps}{\@@inferSteps[\@empty]}}
X
\def\@@inferSteps[#1]{\@deduce{#1}[\DeduceSym]}
X
\def\deduce{\@SaveMath \@IFnextchar [{\@deduce{\@empty}}
X	{\@inferRulefalse \@infer[\@empty]}}
X
%	\@deduce<Proof Label>[<Proof>]<Lower><Uppers>
X
\def\@deduce#1[#2]#3#4{\@inferRulefalse
X	\@infer[\@empty]{#3}{\@SaveMath \@infer[{#1}]{#2}{#4}}}
X
%	\@infer[<Label>]<Lower><Uppers>
%		If \@inferRuletrue, it draws a rule and <Label> is right to
%		a rule. In this case, if \@DoubleRuletrue, it draws
%		double rules.
%
%		Otherwise, draws no rule and <Label> is right to <Lower>.
X
\def\@infer[#1]#2#3{\relax
% Get parameters
X	\if@ReturnLeftOffset \else \@SavedLeftOffset=\@LeftOffset \fi
X	\setbox\@LabelPart=\hbox{$#1$}\relax
X	\setbox\@LowerPart=\hbox{$#2$}\relax
%
X	\global\@LeftOffset=0pt
X	\setbox\@UpperPart=\vbox{\tabskip=0pt \halign{\relax
X		\global\@RightOffset=0pt \@ReturnLeftOffsettrue $##$&&
X		\inferTabSkip
X		\global\@RightOffset=0pt \@ReturnLeftOffsetfalse $##$\cr
X		#3\cr}}\relax
%			Here is a little trick.
%			\@ReturnLeftOffsettrue(false) influences on \infer or
%			\deduce placed in ## locally
%			because of \@SaveMath and \@RestoreMath.
X	\UpperLeftOffset=\@LeftOffset
X	\UpperRightOffset=\@RightOffset
% Calculate Adjustments
X	\LowerWidth=\wd\@LowerPart
X	\LowerHeight=\ht\@LowerPart
X	\LowerCenter=0.5\LowerWidth
%
X	\UpperWidth=\wd\@UpperPart \advance\UpperWidth by -\UpperLeftOffset
X	\advance\UpperWidth by -\UpperRightOffset
X	\UpperCenter=\UpperLeftOffset
X	\advance\UpperCenter by 0.5\UpperWidth
%
X	\ifdim \UpperWidth > \LowerWidth
X		% \UpperCenter > \LowerCenter
X	\UpperAdjust=0pt
X	\RuleAdjust=\UpperLeftOffset
X	\LowerAdjust=\UpperCenter \advance\LowerAdjust by -\LowerCenter
X	\RuleWidth=\UpperWidth
X	\global\@LeftOffset=\LowerAdjust
%
X	\else	% \UpperWidth <= \LowerWidth
X	\ifdim \UpperCenter > \LowerCenter
%
X	\UpperAdjust=0pt
X	\RuleAdjust=\UpperCenter \advance\RuleAdjust by -\LowerCenter
X	\LowerAdjust=\RuleAdjust
X	\RuleWidth=\LowerWidth
X	\global\@LeftOffset=\LowerAdjust
%
X	\else	% \UpperWidth <= \LowerWidth
X		% \UpperCenter <= \LowerCenter
%
X	\UpperAdjust=\LowerCenter \advance\UpperAdjust by -\UpperCenter
X	\RuleAdjust=0pt
X	\LowerAdjust=0pt
X	\RuleWidth=\LowerWidth
X	\global\@LeftOffset=0pt
%
X	\fi\fi
% Make a box
X	\if@inferRule
%
X	\setbox\ResultBox=\vbox{
X		\moveright \UpperAdjust \box\@UpperPart
X		\nointerlineskip \kern\inferLineSkip
X		\if@DoubleRule
X		\moveright \RuleAdjust \vbox{\hrule width\RuleWidth
X			\kern 1pt\hrule width\RuleWidth}\relax
X		\else
X		\moveright \RuleAdjust \vbox{\hrule width\RuleWidth}\relax
X		\fi
X		\nointerlineskip \kern\inferLineSkip
X		\moveright \LowerAdjust \box\@LowerPart }\relax
%
X	\@ifEmpty{#1}{}{\relax
%
X	\HLabelAdjust=\wd\ResultBox	\advance\HLabelAdjust by -\RuleAdjust
X	\advance\HLabelAdjust by -\RuleWidth
X	\WidthAdjust=\HLabelAdjust
X	\advance\WidthAdjust by -\inferLabelSkip
X	\advance\WidthAdjust by -\wd\@LabelPart
X	\ifdim \WidthAdjust < 0pt \WidthAdjust=0pt \fi
%
X	\VLabelAdjust=\dp\@LabelPart
X	\advance\VLabelAdjust by -\ht\@LabelPart
X	\VLabelAdjust=0.5\VLabelAdjust	\advance\VLabelAdjust by \LowerHeight
X	\advance\VLabelAdjust by \inferLineSkip
%
X	\setbox\ResultBox=\hbox{\box\ResultBox
X		\kern -\HLabelAdjust \kern\inferLabelSkip
X		\raise\VLabelAdjust \box\@LabelPart \kern\WidthAdjust}\relax
%
X	}\relax % end @ifEmpty
%
X	\else % \@inferRulefalse
%
X	\setbox\ResultBox=\vbox{
X		\moveright \UpperAdjust \box\@UpperPart
X		\nointerlineskip \kern\inferLineSkip
X		\moveright \LowerAdjust \hbox{\unhbox\@LowerPart
X			\@ifEmpty{#1}{}{\relax
X			\kern\inferLabelSkip \unhbox\@LabelPart}}}\relax
X	\fi
%
X	\global\@RightOffset=\wd\ResultBox
X	\global\advance\@RightOffset by -\@LeftOffset
X	\global\advance\@RightOffset by -\LowerWidth
X	\if@ReturnLeftOffset \else \global\@LeftOffset=\@SavedLeftOffset \fi
%
X	\box\ResultBox
X	\@RestoreMath
}
SHAR_EOF
  $shar_touch -am 0306160497 'proof.sty' &&
  chmod 0644 'proof.sty' ||
  echo 'restore of proof.sty failed'
  shar_count="`wc -c < 'proof.sty'`"
  test 7926 -eq "$shar_count" ||
    echo "proof.sty: original size 7926, current size $shar_count"
fi
# ============= proofeg.tex ==============
if test -f 'proofeg.tex' && test X"$1" != X"-c"; then
  echo 'x - skipping proofeg.tex (file already exists)'
else
  echo 'x - extracting proofeg.tex (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'proofeg.tex' &&
%	proofeg.tex	(An example file for proof.sty)
%
%		Mar 6, 1997
%		Makoto Tatsuta
%
%	I hope you can learn how to use proof figure macros easily
%	by these examples.
X
\def\imp{\to}
\def\land{\mathbin\&}
X
\documentstyle[proof]{article}
X
% for LaTeX 2e naitive mode.
%\documentclass[]{article}
%\usepackage{proof}
X
\begin{document}
\section*{Examples of proof.sty}
X
\verb|\infer| draws beautiful proof figures easily:
X
\noindent (1)
$$
\infer{A}{
X	\infer{B}{
X		B11\land B12\land B13
X		&
X		B21\land B22\land B23
X	}
X	&
X	C
}
$$
X
\noindent (2)
$$
\infer{A1\land A2\land A3\land A4\land A5\land A6}{
X	\infer{B}{
X		B11\land B12\land B13
X		&
X		B21\land B22\land B23
X	}
X	&
X	C
}
$$
X
\noindent (3)
$$
\infer{A1\land A2\land A3\land A4\land A5\land A6}{
X	C
X	&
X	\infer{B}{
X		B11\land B12\land B13
X		&
X		B21\land B22\land B23
X	}
}
$$
X
You can use also some variations:
X
\noindent (4)
$$
\infer[(1)]{A}{
X	\infer*{B}{
X		B11\land B12\land B13
X		&
X		B21\land B22\land B23
X	}
X	&
X	C
}
$$
X
\noindent (5)
$$
\infer*[(1)]{A1\land A2\land A3\land A4\land A5\land A6}{
X	\deduce[{\displaystyle \sum}]{B}{
X		B11\land B12\land B13
X		&
X		B21\land B22\land B23
X	}
X	&
X	\deduce{C}{(2)}
}
$$
X
\noindent (6)
$$
\infer={A}{A \land B \land C}
$$
X
Here are more practical examples:
X
\noindent (7)
$$
\infer[(\land I)]{A \land B}{A & B}
\qquad
\infer[(\land E_l)]A{A\land B}
\qquad
\infer[(\land E_r)]B{A\land B}
$$
X
$$
\infer[(\imp I)]{A \imp B}{
X	\infer*{B}{[A]}
}
\qquad
\infer[(\imp E)]{B}{
X	A \imp B
X	&
X	A
}
$$
X
Some techniques:
Use \verb|\vcenter| for an equation of proofs.
X
\noindent (8)
$$
\pi = \vcenter{
\infer{E}{
X	A
X	&
X	\infer{D}{B & C}
}
}
$$
X
Use \verb|\kern| to adjust the form of a proof.
X
\noindent (9)
$$
\infer{E}{
X	A
X	&
X	\infer{D}{B & C} \kern 0.5cm
}
$$
X
\end{document}
SHAR_EOF
  $shar_touch -am 0306160797 'proofeg.tex' &&
  chmod 0644 'proofeg.tex' ||
  echo 'restore of proofeg.tex failed'
  shar_count="`wc -c < 'proofeg.tex'`"
  test 1752 -eq "$shar_count" ||
    echo "proofeg.tex: original size 1752, current size $shar_count"
fi
exit 0