texlive[44392] Master/texmf-dist: ebproof (17may17)
commits+karl at tug.org
commits+karl at tug.org
Wed May 17 23:51:34 CEST 2017
Revision: 44392
http://tug.org/svn/texlive?view=revision&revision=44392
Author: karl
Date: 2017-05-17 23:51:34 +0200 (Wed, 17 May 2017)
Log Message:
-----------
ebproof (17may17)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/latex/ebproof/ebproof.pdf
trunk/Master/texmf-dist/doc/latex/ebproof/ebproof.tex
trunk/Master/texmf-dist/tex/latex/ebproof/ebproof.sty
Added Paths:
-----------
trunk/Master/texmf-dist/doc/latex/ebproof/README.md
Removed Paths:
-------------
trunk/Master/texmf-dist/doc/latex/ebproof/README
Deleted: trunk/Master/texmf-dist/doc/latex/ebproof/README
===================================================================
--- trunk/Master/texmf-dist/doc/latex/ebproof/README 2017-05-17 18:11:11 UTC (rev 44391)
+++ trunk/Master/texmf-dist/doc/latex/ebproof/README 2017-05-17 21:51:34 UTC (rev 44392)
@@ -1,34 +0,0 @@
-== Presentation ==
-
-The ebproofs package provides commands to typeset proof trees, in the style of
-sequent calculus and related systems. The commands allow for writing
-inferences with any number of premisses and alignment of successive formulas
-on an arbitrary point. Various options allow complete control over spacing,
-styles of inference rules, placement of labels, etc.
-
-The distribution includes the following files:
-
- - ebproof.sty : the package
- - ebproof.pdf : the documentation
- - ebproof.tex : the LaTeX source for the documentation
-
-The package requires pgfkeys (from TikZ/PGF) for the option system.
-
-
-== License ==
-
-Copyright 2015 Emmanuel Beffara <manu at beffara.org>
-
-This work may be distributed and/or modified under the
-conditions of the LaTeX Project Public License, either version 1.3
-of this license or (at your option) any later version.
-The latest version of this license is in
- http://www.latex-project.org/lppl.txt
-and version 1.3 or later is part of all distributions of LaTeX
-version 2005/12/01 or later.
-
-This work has the LPPL maintenance status `maintained'.
-
-The Current Maintainer of this work is Emmanuel Beffara.
-
-This work consists of the files ebproof.sty and ebproof.tex.
Added: trunk/Master/texmf-dist/doc/latex/ebproof/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/ebproof/README.md (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/ebproof/README.md 2017-05-17 21:51:34 UTC (rev 44392)
@@ -0,0 +1,42 @@
+The ebproof package
+===================
+
+A LaTeX package to typeset formal proofs in the style of sequent calculus.
+
+Presentation
+------------
+
+The `ebproof` package provides commands to typeset proof trees, in the style
+of sequent calculus and related systems. The commands allow for writing
+inferences with any number of premisses and alignment of successive formulas
+on an arbitrary point. Various options allow complete control over spacing,
+styles of inference rules, placement of labels, etc.
+
+The distribution includes the following files:
+
+- `ebproof.sty` : the package
+- `ebproof.pdf` : the documentation
+- `ebproof.tex` : the LaTeX source for the documentation
+
+The package requires `expl3` (the LaTeX3 programming environment) which
+provides many useful programming tools.
+
+
+License
+-------
+
+Copyright 2015 Emmanuel Beffara <manu at beffara.org>
+
+This work may be distributed and/or modified under the
+conditions of the LaTeX Project Public License, either version 1.3
+of this license or (at your option) any later version.
+The latest version of this license is in
+ <http://www.latex-project.org/lppl.txt>
+and version 1.3 or later is part of all distributions of LaTeX
+version 2005/12/01 or later.
+
+This work has the LPPL maintenance status “maintained”.
+
+The Current Maintainer of this work is Emmanuel Beffara.
+
+This work consists of the files `ebproof.sty` and `ebproof.tex`.
Property changes on: trunk/Master/texmf-dist/doc/latex/ebproof/README.md
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/doc/latex/ebproof/ebproof.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/doc/latex/ebproof/ebproof.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/ebproof/ebproof.tex 2017-05-17 18:11:11 UTC (rev 44391)
+++ trunk/Master/texmf-dist/doc/latex/ebproof/ebproof.tex 2017-05-17 21:51:34 UTC (rev 44392)
@@ -1,5 +1,5 @@
%% ebproof.sty
-%% Copyright 2015 Emmanuel Beffara <manu at beffara.org>
+%% Copyright 2017 Emmanuel Beffara <manu at beffara.org>
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
@@ -21,7 +21,7 @@
\title{The \package{ebproof} package}
\author{Emmanuel Beffara \\ \url{manu at beffara.org}}
-\date{Version 1.1 \\ March 13, 2015}
+\date{Version 2.0 \\ March 17, 2017}
\usepackage{amssymb}
\usepackage{color}
@@ -40,7 +40,7 @@
\newcommand\env[1]{\lit{#1}}
\newcommand\opt[1]{\lit{#1}}
\newcommand\meta[1]{$\langle$\textit{#1}$\rangle$}
-\newcommand\oarg[1]{\lit{[}\meta{#1}\lit{]}}
+\newcommand\oarg[1]{\lit[\meta{#1}\lit]}
\newcommand\marg[1]{\lit{\{}\meta{#1}\lit{\}}}
\newenvironment{csdoc}[1]{%
@@ -84,10 +84,10 @@
\begin{example}{gobble=2}
\begin{prooftree}
- \Hypo{ \Gamma, A &\vdash B }
- \Infer1[abs]{ \Gamma &\vdash A\to B }
- \Hypo{ \Gamma \vdash A }
- \Infer2[app]{ \Gamma \vdash B }
+ \hypo{ \Gamma, A &\vdash B }
+ \infer1[abs]{ \Gamma &\vdash A\to B }
+ \hypo{ \Gamma \vdash A }
+ \infer2[app]{ \Gamma \vdash B }
\end{prooftree}
\end{example}
@@ -107,7 +107,7 @@
\cs{begin}\lit{\{prooftree\}}\oarg{options}
\meta{statements}
\cs{end}\lit{\{prooftree\}}}
- Typeset the proof tree desribed by the \meta{statements}, as described in
+ Typeset the proof tree described by the \meta{statements}, as described in
section~\ref{sec:statements}.
The \meta{options} provide default formatting options for the proof tree.
This environment can be used either in math mode or in text mode.
@@ -118,8 +118,8 @@
\cs{begin}\lit{\{prooftree*\}}\oarg{options}
\meta{statements}
\cs{end}\lit{\{prooftree*\}}}
- Typeset the proof centered on a line of its own; it is essentially
- equivalent to wrapping the \env{prooftree} environment inside a \env{center}
+ Typeset the proof on a line of its own; it is essentially equivalent to
+ wrapping the \env{prooftree} environment inside a displayed math
environment.
\end{csdoc}
@@ -132,15 +132,15 @@
\begin{example}{gobble=2}
\[
\begin{prooftree}
- \Hypo{ \vdash A }
- \Hypo{ \vdash B } \Infer1{ \vdash B, C }
- \Infer2{ \vdash A\wedge B, C }
+ \infer0{ \vdash A }
+ \hypo{ \vdash B } \infer1{ \vdash B, C }
+ \infer2{ \vdash A\wedge B, C }
\end{prooftree}
\quad \rightsquigarrow \quad
\begin{prooftree}
- \Hypo{ \vdash A } \Hypo{ \vdash B }
- \Infer2{ \vdash A\wedge B }
- \Infer1{ \vdash A\wedge B, C }
+ \infer0{ \vdash A } \hypo{ \vdash B }
+ \infer2{ \vdash A\wedge B }
+ \infer1{ \vdash A\wedge B, C }
\end{prooftree}
\]
\end{example}
@@ -148,10 +148,10 @@
\section{Statements}
\label{sec:statements}
-Statements describes proofs in postfix notation: when typesetting a proof tree
+Statements describe proofs in postfix notation: when typesetting a proof tree
whose last rule has, say, two premisses, you will first write statements for
the subtree of the first premiss, then statements for the subtree of the
-second premiss, then a statement like \cs{Infer2}\{\meta{conclusion}\} to
+second premiss, then a statement like \cs{infer2}\{\meta{conclusion}\} to
build an inference with these two subtrees as premisses and the given text as
conclusion.
@@ -160,17 +160,26 @@
At the end, it must contain exactly one tree, which is the one that will be
printed.
+Note that the commands defined in this section only exist right inside
+\env{prooftree} environments.
+If you have a macro with the same name as one of the statements, for instance
+\cs{hypo}, then this macro will keep its meaning outside \env{prooftree}
+environments as well as inside the arguments of a statement.
+If you really need to access the statements in another context, you can can
+always call them by prefixing their names with \lit{ebproof}, for instance as
+\cs{ebproofhypo}.
+
\subsection{Basic statements}
The basic statements for building proofs are the following, where
\meta{options} stands for arbitrary options as described in
section~\ref{sec:options}.
-\begin{csdoc}{\cs{Hypo}\oarg{options}\marg{text}}
+\begin{csdoc}{\cs{hypo}\oarg{options}\marg{text}}
Push a new proof tree consisting only in one conclusion line, with no
premiss and no line above, in other words a tree with only a leaf
- (\cs{Hypo} stands for \emph{hypothesis}).
+ (\cs{hypo} stands for \emph{hypothesis}).
\end{csdoc}
-\begin{csdoc}{\cs{Infer}\oarg{options}\marg{arity}\oarg{label}\marg{text}}
+\begin{csdoc}{\cs{infer}\oarg{options}\marg{arity}\oarg{label}\marg{text}}
Build an inference step by taking some proof trees from the top of the
stack, assembling them with a rule joining their conclusions and putting a
new conclusion below.
@@ -192,7 +201,7 @@
root of the tree: if \meta{text} contains the alignment character \verb|&|
then the axis is set at that position, otherwise the axis is set at the center
of the conclusion text.
-The \cs{Infer} statement makes sure that the axis of the premiss is at the
+The \cs{infer} statement makes sure that the axis of the premiss is at the
same position as the axis of the conclusion.
If there are several premisses, it places the axis at the center between the
left of the leftmost conclusion and the right of the rightmost conclusion:
@@ -199,63 +208,85 @@
\begin{example}{gobble=2}
\begin{prooftree}
- \Hypo{ &\vdash A, B, C }
- \Infer1{ A &\vdash B, C }
- \Infer1{ A, B &\vdash C }
- \Hypo{ D &\vdash E }
- \Infer2{ A, B, D &\vdash C, E }
- \Infer1{ A, B &\vdash C, D, E }
- \Infer1{ A &\vdash B, C, D, E }
+ \hypo{ &\vdash A, B, C }
+ \infer1{ A &\vdash B, C }
+ \infer1{ A, B &\vdash C }
+ \hypo{ D &\vdash E }
+ \infer2{ A, B, D &\vdash C, E }
+ \infer1{ A, B &\vdash C, D, E }
+ \infer1{ A &\vdash B, C, D, E }
\end{prooftree}
\end{example}
-\subsection{Additional statements}
-
-The following additional statements may be used to affect the format of the
-last proof tree on the stack:
-
-\begin{csdoc}{\cs{Ellipsis}\marg{label}\marg{text}}
+\begin{csdoc}{\cs{ellipsis}\marg{label}\marg{text}}
Typeset vertical dots, with a label on the right, and a new conclusion.
No inference lines are inserted.
\begin{example}{gobble=4}
\begin{prooftree}
- \Hypo{ \Gamma &\vdash A }
- \Ellipsis{foo}{ \Gamma &\vdash A, B }
+ \hypo{ \Gamma &\vdash A }
+ \ellipsis{foo}{ \Gamma &\vdash A, B }
\end{prooftree}
\end{example}
\end{csdoc}
-\begin{csdoc}{\cs{Alter}\marg{code}}
- Modify the proof with arbitrary commands, assuming that these commands do
- not affect the size.
- The \meta{code} is executed in an \cs{hbox} and is followed by the insertion
- of the actual box with the current sub-proof.
- It is mostly useful with \cs{color} commands:
+
+\subsection{Modifying proof trees}
+
+The following additional statements may be used to affect the format of the
+last proof tree on the stack:
+
+\begin{csdoc}{\cs{rewrite}\marg{code}}
+ Rewrite the proof while preserving its size and alignment. The \meta{code}
+ is typeset in horizontal mode, with the following control sequences defined:
+ \begin{itemize}
+ \item \cs{treebox} is a box register that contains the original material,
+ \item \cs{treemark}\marg{name} expands as the position of a given mark with
+ respect to the left of the box.
+ \end{itemize}
+ A simple use of this statement is to change the color of a proof tree:
\begin{example}{gobble=4}
\begin{prooftree}
- \Hypo{ \Gamma, A &\vdash B }
- \Infer1[abs]{ \Gamma &\vdash A\to B }
- \Alter{\color{red}}
- \Hypo{ \Gamma \vdash A }
- \Infer2[app]{ \Gamma \vdash B }
+ \hypo{ \Gamma, A &\vdash B }
+ \infer1[abs]{ \Gamma &\vdash A\to B }
+ \rewrite{\color{red}\box\treebox}
+ \hypo{ \Gamma \vdash A }
+ \infer2[app]{ \Gamma \vdash B }
\end{prooftree}
\end{example}
+ Note the absence of spaces inside the call to \cs{rewrite}, because spaces
+ would affect the position of the tree box.
+ Note also that explicit use of \cs{treebox} is required to actually draw the
+ subtree.
+ Not using it will effectively not render the subtree, while still reserving
+ its space in the enclosing tree:
+ \begin{example}{gobble=4}
+ \begin{prooftree}
+ \hypo{ \Gamma, A &\vdash B }
+ \infer1[abs]{ \Gamma &\vdash A\to B }
+ \rewrite{}
+ \hypo{ \Gamma \vdash A }
+ \infer2[app]{ \Gamma \vdash B }
+ \end{prooftree}
+ \end{example}
+ This kind of manipulation is useful for instance in conjunction with the
+ \package{beamer} package to allow revealing subtrees of a proof tree
+ progressively in successive slides of a given frame.
\end{csdoc}
-\begin{csdoc}{\cs{Delims}\marg{left}\marg{right}}
+\begin{csdoc}{\cs{delims}\marg{left}\marg{right}}
Put left and right delimiters around the whole sub-proof, without changing
the alignment (the spacing is affected by the delimiters, however).
The \meta{left} text must contain an opening occurrence of \cs{left} and the
\meta{right} text must contain a matching occurrence of \cs{right}.
- For instance, \verb|\Delims{\left(}{\right)}| will put the
+ For instance, \verb|\delims{\left(}{\right)}| will put the
sub-proof between parentheses.
\begin{example}{gobble=4}
\begin{prooftree}
- \Hypo{ A_1 \vee \cdots \vee A_n }
- \Hypo{ [A_i] }
- \Ellipsis{}{ B }
- \Delims{ \left( }{ \right)_{1\leq i\leq n} }
- \Infer2{ B }
+ \hypo{ A_1 \vee \cdots \vee A_n }
+ \hypo{ [A_i] }
+ \ellipsis{}{ B }
+ \delims{ \left( }{ \right)_{1\leq i\leq n} }
+ \infer2{ B }
\end{prooftree}
\end{example}
\end{csdoc}
@@ -264,10 +295,8 @@
\label{sec:options}
The formatting of trees, conclusion texts and inference rules is affected by
-options, specfied using the key-value system of PGF/TikZ, provided by the
-\package{pgfkeys} package.
-All options are in the \lit{/ebproof/} path in the key tree of
-\package{pgfkeys}.
+options, specified using the \LaTeX3 key-value system.
+All options are in the \lit{ebproof} module in the key tree.
They can be set locally for a proof tree or for a single statement using
optional arguments in the associated commands.
@@ -297,10 +326,10 @@
Proof trees grow downwards, with conclusions above and premisses below.
\begin{example}{gobble=4}
\begin{prooftree}[proof style=downwards]
- \Hypo{ \Gamma, A &\vdash B }
- \Infer1[abs]{ \Gamma &\vdash A\to B }
- \Hypo{ \Gamma \vdash A }
- \Infer2[app]{ \Gamma \vdash B }
+ \hypo{ \Gamma, A &\vdash B }
+ \infer1[abs]{ \Gamma &\vdash A\to B }
+ \hypo{ \Gamma \vdash A }
+ \infer2[app]{ \Gamma \vdash B }
\end{prooftree}
\end{example}
\end{csdoc}
@@ -319,12 +348,12 @@
The default value is \lit{true}.
\begin{example}{gobble=4}
\begin{prooftree}[center=false]
- \Infer0{ A \vdash A }
+ \infer0{ A \vdash A }
\end{prooftree}
\qquad
\begin{prooftree}[center=false]
- \Hypo{ \Gamma, A \vdash B }
- \Infer1{ \Gamma \vdash A \to B }
+ \hypo{ \Gamma, A \vdash B }
+ \infer1{ \Gamma \vdash A \to B }
\end{prooftree}
\end{example}
\end{csdoc}
@@ -336,9 +365,9 @@
The default value is \lit{1.5em}.
\begin{example}{gobble=4}
\begin{prooftree}[separation=0.5em]
- \Hypo{ A } \Hypo{ B } \Infer2{ C }
- \Hypo{ D } \Hypo{ E } \Hypo{ F } \Infer3{ G }
- \Hypo{ H } \Infer[separation=3em]3{ K }
+ \hypo{ A } \hypo{ B } \infer2{ C }
+ \hypo{ D } \hypo{ E } \hypo{ F } \infer3{ G }
+ \hypo{ H } \infer[separation=3em]3{ K }
\end{prooftree}
\end{example}
\end{csdoc}
@@ -348,10 +377,10 @@
The default value is \lit{0.7ex}.
\begin{example}{gobble=4}
\begin{prooftree}[rule margin=2ex]
- \Hypo{ \Gamma, A &\vdash B }
- \Infer1[abs]{ \Gamma &\vdash A\to B }
- \Hypo{ \Gamma \vdash A }
- \Infer2[app]{ \Gamma \vdash B }
+ \hypo{ \Gamma, A &\vdash B }
+ \infer1[abs]{ \Gamma &\vdash A\to B }
+ \hypo{ \Gamma \vdash A }
+ \infer2[app]{ \Gamma \vdash B }
\end{prooftree}
\end{example}
\end{csdoc}
@@ -377,24 +406,25 @@
\end{csdoc}
The precise rendering is influenced by parameters specified below.
Arbitrary new shapes can defined using the \lit{rule code} option described
- afterwards.
+ below and the \cs{ebproofnewrulestyle} command described in
+ section~\ref{sec:styles}.
\end{csdoc}
-In the optional argument of the \cs{Infer} statement, rule styles can be
+In the optional argument of the \cs{infer} statement, rule styles can be
specified directly, without prefixing the style name by ``\lit{rule style=}''.
-For instance, \cs{Infer}\lit{[dashed]} is equivalent to
-\cs{Infer}\lit{[rule style=dashed]}.
+For instance, \cs{infer}\lit{[dashed]} is equivalent to
+\cs{infer}\lit{[rule style=dashed]}.
\begin{example}{gobble=2}
\begin{prooftree}
- \Hypo{ \Gamma &\vdash A \to B }
- \Infer[no rule]1{ \Gamma &\vdash {!A} \multimap B }
- \Hypo{ \Delta &\vdash A }
- \Infer[rule thickness=2pt]1{ \Delta &\vdash {!A} }
- \Infer0{ B \vdash B }
- \Infer[dashed]2{ \Delta, {!A}\multimap B \vdash B }
- \Infer2{ \Gamma, \Delta &\vdash B }
- \Infer[double]1{ \Gamma \cup \Delta &\vdash B }
+ \hypo{ \Gamma &\vdash A \to B }
+ \infer[no rule]1{ \Gamma &\vdash {!A} \multimap B }
+ \hypo{ \Delta &\vdash A }
+ \infer[rule thickness=2pt]1{ \Delta &\vdash {!A} }
+ \infer0{ B \vdash B }
+ \infer[dashed]2{ \Delta, {!A}\multimap B \vdash B }
+ \infer2{ \Gamma, \Delta &\vdash B }
+ \infer[double]1{ \Gamma \cup \Delta &\vdash B }
\end{prooftree}
\end{example}
@@ -426,10 +456,10 @@
\begin{prooftree}[rule code={\hbox{\tikz
\draw[decorate,decoration={snake,amplitude=.3ex}]
(0,0) -- (\hsize,0);}}]
- \Hypo{ \Gamma &\vdash A }
- \Infer1{ \Gamma &\vdash A, \ldots, A }
- \Hypo{ \Delta, A, \ldots, A \vdash \Theta }
- \Infer2{ \Gamma, \Delta \vdash \Theta }
+ \hypo{ \Gamma &\vdash A }
+ \infer1{ \Gamma &\vdash A, \ldots, A }
+ \hypo{ \Delta, A, \ldots, A \vdash \Theta }
+ \infer2{ \Gamma, \Delta \vdash \Theta }
\end{prooftree}
\end{example}
Note that this example requires the \package{tikz} package, with the
@@ -436,24 +466,6 @@
\package{decorations.pathmorphing} library for the \lit{snake} decoration.
\end{csdoc}
-The option \opt{rule code} is particularly useful in a ``styles'' in the sense of
-\package{pgfkeys} as it allows to define new rule styles.
-The allowed values for \opt{rule style} are actually defined this way.
-The above example could be turned into a new rule style \lit{zigzag} with the
-following command:
-\begin{example}{gobble=2}
- \ebproofset{
- rule style/zigzag/.style={rule code={\hbox{\tikz
- \draw[decorate,decoration={snake,amplitude=.3ex}]
- (0,0) -- (\hsize,0);}}}}
- \begin{prooftree}
- \Hypo{ \Gamma &\vdash A }
- \Infer1{ \Gamma &\vdash A, \ldots, A }
- \Hypo{ \Delta, A, \ldots, A \vdash \Theta }
- \Infer[zigzag]2{ \Gamma, \Delta \vdash \Theta }
- \end{prooftree}
-\end{example}
-
\subsection{Format of conclusions}
\begin{csdoc}{%
@@ -462,8 +474,8 @@
\opt{right template=}\meta{code}}
Defines how conclusions are formatted.
The code is arbitrary \TeX\ code, composed in horizontal mode.
- The macro \cs{inserttext} can be used inside the actual text passed to the
- \cs{Hypo} and \cs{Infer} statements.
+ The macro \cs{inserttext} is used to insert the actual text passed to the
+ \cs{hypo} and \cs{infer} statements.
The \opt{template} value is used for conclusions with no alignment mark.
The \opt{left template} and \opt{right template} values are used on the left
and right side of the alignment mark when it is present.
@@ -471,14 +483,14 @@
conclusions are set in math mode.
The default values for \opt{left template} and \opt{right template} are
similar, with spacing assuming that a relation symbol is put near the
- alignment mark, so that \verb|\Infer1{A &\vdash B}| is spaced correctly.
+ alignment mark, so that \verb|\infer1{A &\vdash B}| is spaced correctly.
\begin{example}{gobble=4}
\begin{prooftree}[template=(\textbf\inserttext)]
- \Hypo{ foo }
- \Hypo{ bar }
- \Infer1{ baz }
- \Infer2{ quux }
+ \hypo{ foo }
+ \hypo{ bar }
+ \infer1{ baz }
+ \infer2{ quux }
\end{prooftree}
\end{example}
\end{csdoc}
@@ -490,8 +502,18 @@
\opt{right label=}\meta{text}}
The text to use as the labels of the rules, on the left and on the right
of the inference line.
- Using the second optional argument in \cs{Infer} is equivalent to setting
+ Using the second optional argument in \cs{infer} is equivalent to setting
the \env{right label} option with the value of that argument.
+
+ \begin{example}{gobble=4}
+ \begin{prooftree}
+ \hypo{ \Gamma, A &\vdash B }
+ \infer[left label=$\lambda$]1[abs]
+ { \Gamma &\vdash A\to B }
+ \hypo{ \Gamma \vdash A }
+ \infer[left label=@]2[app]{ \Gamma \vdash B }
+ \end{prooftree}
+ \end{example}
\end{csdoc}
\begin{csdoc}{%
\opt{left label template=}\meta{code} \\
@@ -508,8 +530,62 @@
The spacing between an inference lines and its labels.
The default value is \lit{0.5em}.
\end{csdoc}
+\begin{csdoc}{\opt{label axis=}\meta{dimension}}
+ The height of the horizontal axis used for aligning the labels with the
+ rules. The default value is \lit{0.5ex}.
+\end{csdoc}
+\subsection{Style macros}
+\label{sec:styles}
+
+The following commands allow for the definition of custom styles using the
+basic style options, in a way similar to PGF's ``styles'' and \LaTeX3's
+``meta-keys''.
+This allows setting a bunch of options with the same values in many proofs
+using a single definition.
+
+\begin{csdoc}{\cs{ebproofnewstyle}\marg{name}\marg{options}}
+ Define a new style option \meta{name} that sets the given \meta{options}.
+
+ For instance, the following code defines a new option \opt{small} that sets
+ various parameters so that proofs are rendered smaller.
+ \begin{example}{gobble=4}
+ \ebproofnewstyle{small}{
+ separation = 1em, rule margin = .5ex,
+ template = \footnotesize$\inserttext$ }
+ \begin{prooftree}[small]
+ \hypo{ \Gamma, A \vdash B }
+ \infer1{ \Gamma \vdash A\to B }
+ \hypo{ \Gamma \vdash A } \infer2{ \Gamma \vdash B }
+ \end{prooftree}
+ \end{example}
+\end{csdoc}
+
+\begin{csdoc}{\cs{ebproofnewrulestyle}\marg{name}\marg{options}}
+ Define a new rule style.
+ The \meta{options} part includes options used to set how to draw rules in
+ the new style.
+
+ The option \opt{rule code} is useful in this command as it allows to
+ define arbitrary rule styles.
+ For instance, the squiggly rule example above could be turned into a new
+ rule style \lit{zigzag} with the following code:
+ \begin{example}{gobble=4}
+ \ebproofnewrulestyle{zigzag}{
+ rule code = {\hbox{\tikz
+ \draw[decorate,decoration={snake,amplitude=.3ex}]
+ (0,0) -- (\hsize,0);}}}
+ \begin{prooftree}
+ \hypo{ \Gamma &\vdash A }
+ \infer1{ \Gamma &\vdash A, \ldots, A }
+ \hypo{ \Delta, A, \ldots, A \vdash \Theta }
+ \infer[zigzag]2{ \Gamma, \Delta \vdash \Theta }
+ \end{prooftree}
+ \end{example}
+\end{csdoc}
+
+
\section{License}
This work may be distributed and/or modified under the
@@ -528,4 +604,35 @@
This work consists of the files \texttt{ebproof.sty} and \texttt{ebproof.tex}.
+
+\section{History}
+
+This section lists the principal evolutions of the package, in reverse
+chronological order.
+\begin{description}
+\item[Version 2.0]
+ A complete rewrite of the code using the \LaTeX3 programming environment.
+ The incompatible changes from the user's point of view are the following:
+ \begin{itemize}
+ \item Proof statements are now writtten in lowercase ({i.e.} \cs{Infer} is
+ now written \cs{infer} etc.) but the syntax is otherwise unchanged.
+ The old uppercase commands still work but produce a deprecation warning,
+ they will be removed in a future version.
+ \item New styles are now defined using \cs{ebproofnewstyle} and
+ \cs{ebproofnewrulestyle}. The previous method using PGF styles does not
+ work anymore (because PGF is not used anymore).
+ \end{itemize}
+ The new commands and options are the following:
+ \begin{itemize}
+ \item The statement \cs{rewrite} generalizes \cs{Alter},
+ \item The option \opt{label axis} controls vertical alignment of labels.
+ \end{itemize}
+\item[Version 1.1]
+ A bugfix release.
+ In \opt{template} options, one now uses \cs{inserttext} instead of \lit{\#1}
+ for the text arguments, which improves robustness.
+\item[Version 1.0]
+ The first public release.
+\end{description}
+
\end{document}
Modified: trunk/Master/texmf-dist/tex/latex/ebproof/ebproof.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/ebproof/ebproof.sty 2017-05-17 18:11:11 UTC (rev 44391)
+++ trunk/Master/texmf-dist/tex/latex/ebproof/ebproof.sty 2017-05-17 21:51:34 UTC (rev 44392)
@@ -1,8 +1,8 @@
% The ebproof package - Formal proofs in the style of sequent calculus
%% ebproof.sty
-%% Copyright 2015 Emmanuel Beffara <manu at beffara.org>
-%
+%% Copyright 2017 Emmanuel Beffara <manu at beffara.org>
+
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
@@ -10,543 +10,758 @@
% http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
-%
+
% This work has the LPPL maintenance status `maintained'.
-%
+
% The Current Maintainer of this work is Emmanuel Beffara.
-%
+
% This work consists of the files ebproof.sty and ebproof.tex.
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{ebproof}[2015/03/13 v1.1 EB's proof trees]
+\RequirePackage{expl3}
+\RequirePackage{xparse}
+\ProvidesExplPackage{ebproof}{2017/05/17}{2.0}{EB's proof trees}
-% The |pgfkeys| package is used for the parameters in proof construction.
-\RequirePackage{pgfkeys}
+%% Parameters
-%%% Registers and internal parameters
+%%% Declaration of the parameters
-\newif\ifebproof at updown \ebproof at updownfalse
-\newif\ifebproof at center \ebproof at centertrue
+\keys_define:nn { ebproof } {
-%%% Parameters
+% general shape
-\def\ebproofset#1{\pgfqkeys{/ebproof}{#1}}
+center .bool_set:N = \l_ebproof_center_bool,
-\ebproofset{
-%
-% general shape
-%
-center/.is if=ebproof at center,
-proof style/.is choice,
-proof style/upwards/.code={\ebproof at updownfalse},
-proof style/downwards/.code={\ebproof at updowntrue},
-%
+proof~style .choice: ,
+proof~style / upwards .code:n = \bool_set_false:N \l_ebproof_updown_bool,
+proof~style / downwards .code:n = \bool_set_true:N \l_ebproof_updown_bool,
+
% spacing
-%
-separation/.initial=1.5em,
-rule margin/.initial=.7ex,
-%
+
+separation .dim_set:N = \l_ebproof_separation_dim,
+rule~margin .dim_set:N = \l_ebproof_rule_margin_dim,
+
% shape of inference lines
-%
-rule thickness/.initial=.4pt,
-rule separation/.initial=2pt,
-rule dash length/.initial=.2em,
-rule dash space/.initial=.3em,
-rule code/.initial=,
-%
+
+rule~thickness .dim_set:N = \l_ebproof_rule_thickness_dim,
+rule~separation .dim_set:N = \l_ebproof_rule_separation_dim,
+rule~dash~length .dim_set:N = \l_ebproof_rule_dash_length_dim,
+rule~dash~space .dim_set:N = \l_ebproof_rule_dash_space_dim,
+rule~code .tl_set:N = \l_ebproof_rule_code_tl,
+
+rule~style .choice:,
+
% templates
-%
-template/.initial=$\inserttext$,
-left template/.initial=$\inserttext\mathrel{}$,
-right template/.initial=$\mathrel{}\inserttext$,
-%
+
+template .tl_set:N = \l_ebproof_template_tl,
+left~template .tl_set:N = \l_ebproof_left_template_tl,
+right~template .tl_set:N = \l_ebproof_right_template_tl,
+
% labels
-%
-left label/.initial=,
-right label/.initial=,
-left label template/.initial=\inserttext,
-right label template/.initial=\inserttext,
-label separation/.initial=0.5em,
+
+left~label .tl_set:N = \l_ebproof_left_label_tl,
+right~label .tl_set:N = \l_ebproof_right_label_tl,
+left~label~template .tl_set:N = \l_ebproof_left_label_template_tl,
+right~label~template .tl_set:N = \l_ebproof_right_label_template_tl,
+label~separation .dim_set:N = \l_ebproof_label_separation_dim,
+label~axis .dim_set:N = \l_ebproof_label_axis_dim,
+
}
-% Rule styles
+%%% Rule styles
-\pgfqkeys{/ebproof/rule style}{
-.is choice,
-.search also=/ebproof,
-simple/.style={/ebproof/rule code={%
- \hrule height \pgfkeysvalueof{/ebproof/rule thickness}\relax
- }},
-%
-no rule/.style={/ebproof/rule code=},
-%
-double/.style={/ebproof/rule code={%
- \hrule height \pgfkeysvalueof{/ebproof/rule thickness}
- \kern\pgfkeysvalueof{/ebproof/rule separation}%
- \hrule height \pgfkeysvalueof{/ebproof/rule thickness}
- }},
-%
-dashed/.style={/ebproof/rule code={%
- \hbox to \hsize{%
- \@tempdima=\pgfkeysvalueof{/ebproof/rule dash space}%
- \divide\@tempdima2%
- \kern-\@tempdima%
- \cleaders\hbox{%
- \kern\@tempdima%
- \vrule
- height \pgfkeysvalueof{/ebproof/rule thickness}
- width \pgfkeysvalueof{/ebproof/rule dash length}%
- \kern\@tempdima
- }\hfill
- \kern-\@tempdima
- }%
- }},
-%
-simple % use the 'simple' rule style by default
+\NewDocumentCommand \ebproofnewrulestyle { mm } {
+ \keys_define:nn { ebproof } {
+ rule~style / #1 .meta:nn = { ebproof } { #2 }
+ }
}
-%%% Storage
+\ebproofnewrulestyle { simple } {
+ rule~code = { \tex_hrule:D height \l_ebproof_rule_thickness_dim }
+}
-% Proof trees are represented as a data structure that consists of the
-% following data:
-%
-% - box : the tree itself, as a box, with the base line on that of
-% the conclusion
-% - left : the distance from the left of the box to the left of the
-% conclusion
-% - right : the distance from the right of the box to the right of the
-% conclusion
-% - axis : the distance from the left of the box to the vertical axis
-% of the conclusion
-%
+\ebproofnewrulestyle { no~rule } {
+ rule~code =
+}
+
+\ebproofnewrulestyle { double } {
+ rule~code = {
+ \tex_hrule:D height \l_ebproof_rule_thickness_dim
+ \skip_vertical:N \l_ebproof_rule_separation_dim
+ \tex_hrule:D height \l_ebproof_rule_thickness_dim
+ }
+}
+
+\ebproofnewrulestyle { dashed } {
+ rule~code = {
+ \hbox_to_wd:nn { \tex_hsize:D } {
+ \dim_set:Nn \l_tmpa_dim { \l_ebproof_rule_dash_space_dim / 2 }
+ \skip_horizontal:n { -\l_tmpa_dim }
+ \tex_cleaders:D \hbox:n {
+ \skip_horizontal:N \l_tmpa_dim
+ \tex_vrule:D
+ height \l_ebproof_rule_thickness_dim
+ width \l_ebproof_rule_dash_length_dim
+ \skip_horizontal:N \l_tmpa_dim
+ }\tex_hfill:D
+ \skip_horizontal:n { -\l_tmpa_dim }
+ }
+ }
+}
+
+%%% Default values
+
+\keys_set:nn { ebproof } {
+ center = true,
+ proof~style = upwards,
+ separation = 1.5em,
+ rule~margin = .7ex,
+ rule~thickness = .4pt,
+ rule~separation = 2pt,
+ rule~dash~length = .2em,
+ rule~dash~space = .3em,
+ rule~style = simple,
+ template = $\inserttext$,
+ left~template = $\inserttext\mathrel{}$,
+ right~template = $\mathrel{}\inserttext$,
+ left~label = ,
+ right~label = ,
+ left~label~template = \inserttext,
+ right~label~template = \inserttext,
+ label~separation = 0.5em,
+ label~axis = 0.5ex
+}
+
+%%% Defining style macros
+
+\NewDocumentCommand \ebproofnewstyle { mm } {
+ \keys_define:nn { ebproof } { #1 .meta:n = { #2 } }
+}
+
+
+%% Proof trees
+
+% Proof trees are represented as a data structure that consists of a box and a
+% set of marks, which are vertical positions in the box (as distances from the
+% left edge). Arbitrary marks can be defined, the folowing are used for
+% alignment:
+% - left : the left of the conclusion
+% - right : the right of the conclusion
+% - axis : the vertical axis of the conclusion
+
+
+%%% Registers
+
% TeX does not actually provide data structures, so we have to encode things.
-% First we provide local allocators, for temporary allocation of registers in
-% a group. Dimensions are initialized to 0pt.
+% We provide an allocator for "registers" holding boxes with attributes. Such
+% a register consists in a box register and a property list for marks, which
+% maps mark names to values as explicit dimensions with units.
-\def\ebproof at localdimen#1{%
- \advance\count11\@ne% \count11 is the number of the last allocated \dimen
- \expandafter\dimendef\csname#1\endcsname=\count11%
- \csname#1\endcsname=0pt\relax}
+% Create a new register.
-% For boxes, the allocator must be used as
-%
-% \ebproof at localbox{NAME}=\hbox{...}
-%
-% in order to set the value of the box.
+\cs_new:Nn \ebproof_new:N {
+ \box_new:N #1
+ \prop_new:c { l_ebproof_marks_ \__int_value:w #1 _prop }
+}
-\def\ebproof at localbox#1{%
- \advance\count14\@ne% \count14 is the number of the last allocated \box
- \expandafter\chardef\csname#1\endcsname\count14%
- \setbox\csname#1\endcsname}
+% Clear a register.
-% From this we deduce an allocator for data structures. This allocator
-% receives a base name |A| and defines the registers |\A at box|, |\A at left|,
-% |\A at right| and |\A at axis|. The macro is used like |\ebproof at localbox|, by
-% providing a value for the box.
+\cs_new:Nn \ebproof_clear:N {
+ \hbox_set:Nn #1 {}
+ % Using \box_clear:N instead would not work because trying to push this box
+ % on the stack would not actually append any box.
+ \prop_clear:c { l_ebproof_marks_ \__int_value:w #1 _prop }
+ \ebproof_set_mark:Nnn #1 { left } { 0pt }
+ \ebproof_set_mark:Nnn #1 { right } { 0pt }
+ \ebproof_set_mark:Nnn #1 { axis } { 0pt }
+}
-\def\ebproof at alloc#1{%
- \ebproof at localdimen{#1 at left}%
- \ebproof at localdimen{#1 at right}%
- \ebproof at localdimen{#1 at axis}%
- \ebproof at localbox{#1 at box}}
-% Logically, such structures are stored on a stack. However, TeX does not
-% provide data structures, so we encode them using what we actually have. A
-% stack for boxes is implemented using a global hbox |\ebproof at box@stack| that
-% contains all the boxes successively, and the |\lastbox| primitive allows us
-% to pop elements from there. A macro |\ebproof at stack| is used to store the
-% dimensions textually: the empty stack is an empty macro, and a non-empty
-% stack is represented as |{left}{right}{axis}{tail}|. We maintain a counter
-% |\ebproof at level| with the number of elements on the stack, for consistency
-% checks.
+%%% Mark operations
-\newcount\ebproof at level
-\newbox\ebproof at box@stack
-\newbox\ebproof at box@temp
+% Set the value of a mark. The third argument is a dimension expression.
-% Clear the stack.
+\dim_new:N \l_ebproof_transit_dim
-\def\ebproof at clear{%
- \global\ebproof at level=0%
- \global\setbox\ebproof at box@stack=\box\voidb at x%
- \gdef\ebproof at stack{}}
+\cs_new:Nn \ebproof_set_mark:Nnn {
+ \dim_set:Nn \l_ebproof_transit_dim { #3 }
+ \prop_put:cnV { l_ebproof_marks_ \__int_value:w #1 _prop } { #2 }
+ \l_ebproof_transit_dim
+}
-% Push an allocated structure (by name) on the stack.
+% Get the value of a mark. This is expandable and can be used in expressions.
-\def\ebproof at push#1{%
- \global\advance\ebproof at level1\relax
- \global\setbox\ebproof at box@stack=\hbox{%
- \unhbox\ebproof at box@stack\copy\csname#1 at box\endcsname}%
- \xdef\ebproof at stack{%
- {\the\csname#1 at left\endcsname}%
- {\the\csname#1 at right\endcsname}%
- {\the\csname#1 at axis\endcsname}%
- {\ebproof at stack}}}
+\cs_new:Nn \ebproof_mark:Nn {
+ \prop_item:cn { l_ebproof_marks_ \__int_value:w #1 _prop } { #2 }
+}
-% Allocate a structure and pop its value from the top of the stack.
+% Shift the marks by a specified amount, without modifying the box.
-\def\ebproof at pop#1{%
- \ifnum\ebproof at level>0\relax
- \global\advance\ebproof at level-1\relax
- \global\setbox\ebproof at box@stack=\hbox{%
- \unhbox\ebproof at box@stack
- \global\setbox\ebproof at box@temp=\lastbox}%
- \ebproof at alloc{#1}=\box\ebproof at box@temp%
- \begingroup\def\pop##1##2##3##4{\endgroup%
- \csname#1 at left\endcsname=##1\relax
- \csname#1 at right\endcsname=##2\relax
- \csname#1 at axis\endcsname=##3\relax
- \gdef\ebproof at stack{##4}}%
- \expandafter\pop\ebproof at stack
- \else
- \PackageError{ebproof}{%
- Missing premiss in a proof tree}{}%
- \ebproof at alloc{#1}=\box\voidb at x%
- \fi}
+\cs_new:Nn \ebproof_shift_x:Nn {
+ \prop_map_inline:cn { l_ebproof_marks_ \__int_value:w #1 _prop } {
+ \ebproof_set_mark:Nnn #1 { ##1 } { ##2 + #2 }
+ }
+}
+% Move the left and right marks of the first tree so that they are at least as
+% far from the axis as they are in the second tree. For instance if the marks
+% are set as
+% 1: L---A-------R
+% 2: L-------A---R
+% then the marks of the first tree are then set as
+% 1: L-------A-------R
+% The contents of the tree are unchanged.
-%%% Making boxes
+\cs_new:Nn \ebproof_enlarge_conclusion:NN {
+ \dim_set:Nn \l_tmpa_dim { \ebproof_mark:Nn #1 {axis}
+ + \ebproof_mark:Nn #2 {left} - \ebproof_mark:Nn #2 {axis} }
+ \dim_compare:nNnT { \l_tmpa_dim } < { \ebproof_mark:Nn #1 {left} } {
+ \ebproof_set_mark:Nnn #1 {left} { \l_tmpa_dim } }
+ \dim_set:Nn \l_tmpa_dim { \ebproof_mark:Nn #1 {axis}
+ + \ebproof_mark:Nn #2 {right} - \ebproof_mark:Nn #2 {axis} }
+ \dim_compare:nNnT { \l_tmpa_dim } > { \ebproof_mark:Nn #1 {right} } {
+ \ebproof_set_mark:Nnn #1 {right} { \l_tmpa_dim } }
+}
-% Push a box with the axis in the middle.
-\def\ebproof at pushsimple#1{%
- \begingroup
- \ebproof at alloc{A}=\hbox{#1}%
- \A at axis=.5\wd\A at box
- \ebproof at push{A}%
- \endgroup}
+%%% Building blocks
-% Push a box made of two halves, with the axis between the halves.
+% Make a tree with explicit material in horizontal mode. Set the left and
+% right marks to extremal positions and set the axis in the middle.
-\def\ebproof at pushsplit#1#2{%
- \begingroup
- \ebproof at alloc{A}=\hbox{#1}%
- \A at axis=\wd\A at box
- \setbox\A at box=\hbox{\unhbox\A at box#2}%
- \ebproof at push{A}%
- \endgroup}
+\cs_new:Nn \ebproof_make_simple:Nn {
+ \hbox_set:Nn #1 { #2 }
+ \ebproof_set_mark:Nnn #1 { left } { 0pt }
+ \ebproof_set_mark:Nnn #1 { axis } { \box_wd:N #1 / 2 }
+ \ebproof_set_mark:Nnn #1 { right } { \box_wd:N #1 }
+}
-% Join horizontally the two elements at the top of the stack.
+% Make a tree with explicit material in horizontal mode, split in two parts.
+% Set the left and right marks to extremal positions and set the axis between
+% the two parts.
-\def\ebproof at joinh{%
- \begingroup
- \ebproof at pop{A}%
- \ebproof at pop{B}%
- \ebproof at alloc{C}=\hbox{%
- \box\B at box
- \kern\pgfkeysvalueof{/ebproof/separation}%
- \box\A at box}%
- \C at left=\B at left
- \C at right=\A at right
- \C at axis=\wd\C at box
- \advance\C at axis\B at left
- \advance\C at axis-\A at right
- \divide\C at axis2\relax
- \ebproof at push{C}%
- \endgroup}
+\cs_new:Nn \ebproof_make_split:Nnn {
+ \ebproof_set_mark:Nnn #1 { left } { 0pt }
+ \hbox_set:Nn #1 { #2 }
+ \ebproof_set_mark:Nnn #1 { axis } { \box_wd:N #1 }
+ \hbox_set:Nn #1 { \hbox_unpack:N #1 #3 }
+ \ebproof_set_mark:Nnn #1 { right } { \box_wd:N #1 }
+}
-% An $n$-ary version of the horizontal join.
+% Make a tree with explicit material in vertical mode, using an explicit width
+% and axis.
-\def\ebproof at joinh@multi#1{%
- \begingroup
- \countdef\c=1
- \c=#1\relax%
- \ifnum\c=0
- \ebproof at alloc{X}=\hbox{}%
- \ebproof at push{X}%
- \else
- \ebproof at joinh@loop
- \fi
- \endgroup}
-\def\ebproof at joinh@loop{%
- \ifnum\c>1
- \ebproof at joinh
- \advance\c-1
- \expandafter\ebproof at joinh@loop
- \fi}
+\cs_new:Nn \ebproof_make_vertical:Nnnn {
+ \ebproof_set_mark:Nnn #1 { left } { 0pt }
+ \ebproof_set_mark:Nnn #1 { axis } { #2 }
+ \ebproof_set_mark:Nnn #1 { right } { #3 }
+ \vbox_set:Nn #1 {
+ \dim_set:Nn \tex_hsize:D { \ebproof_mark:Nn #1 {right} }
+ #4
+ }
+ \box_set_wd:Nn #1 { \ebproof_mark:Nn #1 {right} }
+}
-% Append the last element to the right of the previous one, without changing
-% its alignment.
+%%% Assembling boxes
-\def\ebproof at joinright{%
- \begingroup
- \ebproof at pop{A}%
- \ebproof at pop{B}%
- \ebproof at alloc{C}=\hbox{%
- \box\B at box
- \kern\pgfkeysvalueof{/ebproof/separation}%
- \copy\A at box}%
- \C at left=\B at left
- \C at right=\B at right
- \advance\C at right\wd\A at box
- \advance\C at right\pgfkeysvalueof{/ebproof/separation}%
- \ebproof at push{C}%
- \endgroup}
+% Extend a tree box. The marks are shifted so that alignment is preserved. The
+% arguments are dimensions for the left, top, right and bottom sides
+% respectively.
-% Join vertically the two elements at the top of the stack, with a horizontal
-% rule of the appropriate size.
+\cs_new:Nn \ebproof_extend:Nnnnn {
+ \dim_compare:nNnF { #2 } = { 0pt } {
+ \hbox_set:Nn #1 {
+ \skip_horizontal:n { #2 }
+ \box_use:N #1
+ }
+ \ebproof_shift_x:Nn #1 { #2 }
+ }
+ \box_set_ht:Nn #1 { \box_ht:N #1 + #3 }
+ \box_set_wd:Nn #1 { \box_wd:N #1 + #4 }
+ \box_set_dp:Nn #1 { \box_dp:N #1 + #5 }
+}
-\def\ebproof at joinv{%
- \begingroup
- \ebproof at pop{A}%
- \ebproof at pop{B}%
- %
- \ebproof at alloc{C}=\box\voidb at x%
- \ebproof at localdimen{A at shift}%
- \ebproof at localdimen{B at shift}%
- \ebproof at localdimen{R at shift}%
- \ebproof at localdimen{R at raise}%
- \ebproof at localdimen{R at width}%
- \ebproof at localdimen{C at width}%
- \ebproof at localdimen{tmp}%
- %
- % The placement of the boxes and the axis of the result
- \ifdim\A at axis>\B at axis
- \A at shift=0pt%
- \B at shift=\A at axis
- \advance\B at shift-\B at axis
- \C at axis=\A at axis
- \else
- \A at shift=\B at axis
- \advance\A at shift-\A at axis
- \B at shift=0pt%
- \C at axis=\B at axis
- \fi
- % The paddings of the result
- \C at left=\A at left
- \advance\C at left\A at shift
- \C at right=\A at right
- \tmp=\wd\B at box
- \advance\tmp\B at shift
- \advance\tmp-\wd\A at box
- \advance\tmp-\A at shift
- \ifdim\tmp>0pt%
- \C at width=\wd\B at box
- \advance\C at width\B at shift
- \advance\C at right\tmp
- \else
- \C at width=\wd\A at box
- \advance\C at width\A at shift
- \fi
- % The position of the rule
- \R at shift=\A at left
- \advance\R at shift\A at shift
- \tmp=\B at left
- \advance\tmp\B at shift
- \ifdim\R at shift>\tmp
- \R at shift=\tmp
- \fi
- % The width of the rule
- \R at width=\wd\A at box
- \advance\R at width\A at shift
- \advance\R at width-\A at right
- \tmp=\wd\B at box
- \advance\tmp\B at shift
- \advance\tmp-\B at right
- \ifdim\tmp>\R at width
- \R at width=\tmp
- \fi
- \advance\R at width-\R at shift
- % Make the rule box
- \ebproof at localbox{R at box}=\vbox{%
- \hsize=\R at width
- \hrule width \R at width height 0pt\relax
- \kern\pgfkeysvalueof{/ebproof/rule margin}%
- \pgfkeysgetvalue{/ebproof/rule code}{\@rulecode}%
- \ifx\@rulecode\@empty\else
- \@rulecode
- \unskip% so that only one margin is inserted if no rule is drawn
- \kern\pgfkeysvalueof{/ebproof/rule margin}%
- \fi
- }%
- % Make the label boxes
- \ebproof at localbox{LEFT}=\hbox{%
- \def\inserttext{\pgfkeysvalueof{/ebproof/left label}}%
- \pgfkeysvalueof{/ebproof/left label template}}%
- \ebproof at localbox{RIGHT}=\hbox{%
- \def\inserttext{\pgfkeysvalueof{/ebproof/right label}}%
- \pgfkeysvalueof{/ebproof/right label template}}%
- % Shift things if the left box is wider than |\R at shift|
- \ifvoid\LEFT\else
- \tmp=\wd\LEFT
- \advance\tmp\pgfkeysvalueof{/ebproof/label separation}
- \ifdim\tmp>\R at shift
- \advance\tmp-\R at shift
- \advance\A at shift\tmp
- \advance\B at shift\tmp
- \advance\C at left\tmp
- \advance\C at axis\tmp
- \advance\C at width\tmp
- \R at shift=0pt\relax
- \else
- \advance\R at shift-\tmp
- \fi
- \fi
- % Compute how the rule box must be shifted so that labels are aligned
- \ebproof at localbox{RC at box}=\hbox{$\vcenter{\copy\R at box}$}%
- \R at raise=\ht\R at box
- \advance\R at raise-\ht\RC at box
- % Make the complete rule box
- \setbox\RC at box=\hbox{%
- \ifvoid\LEFT\else
- \box\LEFT
- \kern\pgfkeysvalueof{/ebproof/label separation}
- \fi
- \box\RC at box
- \ifvoid\RIGHT\else
- \kern\pgfkeysvalueof{/ebproof/label separation}
- \box\RIGHT
- \fi}
- % Adapt the dimensions on the right if the total rule width is too large
- \tmp=\wd\RC at box
- \advance\tmp\R at shift
- \ifdim\tmp>\C at width
- \advance\tmp-\C at width
- \advance\C at right\tmp
- \fi
- % Cancel the labels' height and depth
- \setbox\RC at box=\hbox{\raise\R at raise\box\RC at box}
- \ht\RC at box=\ht\R at box
- \dp\RC at box=\dp\R at box
- % Make the box
- \ifebproof at updown
- \setbox\C at box=\vtop{%
- \moveright\A at shift\box\A at box
- \hrule height 0pt
- \moveright\R at shift\box\RC at box%
- \hrule height 0pt
- \moveright\B at shift\box\B at box}%
- \else
- \setbox\C at box=\vbox{%
- \moveright\B at shift\box\B at box
- \hrule height 0pt
- \moveright\R at shift\box\RC at box%
- \hrule height 0pt
- \moveright\A at shift\box\A at box}%
- \fi
- \ebproof at push{C}%
- \endgroup}
+% Append the contents of the second tree to the first one on the right, with
+% matching baselines. The marks of both trees are preserved. The middle
+% argument specifies the space to insert between boxes.
-%%% Modifying boxes
+\cs_new:Nn \ebproof_append_right:NnN {
+ \hbox_set:Nn #1 {
+ \box_use:N #1
+ \dim_compare:nNnF { #2 } = { 0pt } { \skip_horizontal:n { #2 } }
+ \box_use:N #3
+ }
+}
-% Alter a proof with a command that does not affect the size. Typically useful
-% with |\color| commands.
+% Append the contents of the second tree to the first one on the left, with
+% matching baselines. The marks of the first tree are shifted accordingly. The
+% middle argument specifies the space to insert between boxes.
-\def\ebproof at alter#1{%
- \begingroup
- \ebproof at pop{A}%
- \setbox\A at box=\hbox{{#1\box\A at box}}%
- \ebproof at push{A}%
- \endgroup}
+\cs_new:Nn \ebproof_append_left:NnN {
+ \ebproof_shift_x:Nn #1 { \box_wd:N #3 + #2 }
+ \hbox_set:Nn #1 {
+ \box_use:N #3
+ \dim_compare:nNnF { #2 } = { 0pt } { \skip_horizontal:n { #2 } }
+ \box_use:N #1
+ }
+}
-% Insert |\left| and |\right| delimiters without changing the alignment
+% Shift of two trees to the right so that the axes match. The marks of the one
+% that is shifted are updated accordingly.
-\def\ebproof at delims#1#2{%
- \begingroup
- \ebproof at pop{TREE}%
- \ebproof at localbox{@SHIFTED}=%
- \hbox{$\vcenter{\copy\TREE at box}$}%
- \ebproof at localbox{@LEFT}=%
- \hbox{$#1\vrule height \ht\@SHIFTED depth \dp\@SHIFTED width 0pt\right.$}%
- \ebproof at localbox{@RIGHT}=%
- \hbox{$\left.\vrule height \ht\@SHIFTED depth \dp\@SHIFTED width 0pt#2$}%
- \ebproof at localdimen{dy}
- \dy=\dp\@SHIFTED
- \advance\dy-\dp\TREE at box
- \ebproof at alloc{A}=%
- \hbox{\raise\dy\hbox{\copy\@LEFT\box\@SHIFTED\copy\@RIGHT}}%
- \A at left=\wd\@LEFT \advance\A at left\TREE at left
- \A at right=\wd\@RIGHT \advance\A at right\TREE at right
- \A at axis=\wd\@LEFT \advance\A at axis\TREE at axis
- \ebproof at push{A}%
- \endgroup}
+\cs_new:Nn \ebproof_align:NN {
+ \dim_set:Nn \l_tmpa_dim
+ { \ebproof_mark:Nn #2 {axis} - \ebproof_mark:Nn #1 {axis} }
+ \dim_compare:nNnTF \l_tmpa_dim < { 0pt } {
+ \ebproof_extend:Nnnnn #2 { -\l_tmpa_dim } { 0pt } { 0pt } { 0pt }
+ } {
+ \ebproof_extend:Nnnnn #1 { \l_tmpa_dim } { 0pt } { 0pt } { 0pt }
+ }
+}
+% Append the contents of the second tree above the first one, with matching
+% axes. The marks of the first tree are preserved.
+
+\cs_new:Nn \ebproof_append_above:NN {
+ \ebproof_align:NN #1 #2
+ \vbox_set:Nn #1 {
+ \box_use:N #2
+ \tex_prevdepth:D -1000pt
+ \box_use:N #1
+ }
+}
+
+% Append the contents of the second tree below the first one, with matching
+% axes. The marks of the first tree are preserved.
+
+\cs_new:Nn \ebproof_append_below:NN {
+ \ebproof_align:NN #1 #2
+ \vbox_set_top:Nn #1 {
+ \box_use:N #1
+ \tex_prevdepth:D -1000pt
+ \box_use:N #2
+ }
+}
+
+% Shift the material in a tree vertically so that the height and depth are
+% equal (like TeX's \vcenter but around the baseline).
+
+\cs_new:Nn \ebproof_vcenter:N {
+ \dim_set:Nn \l_tmpa_dim { ( \box_ht:N #1 - \box_dp:N #1 ) / 2 }
+ \box_set_eq:NN \l_tmpa_box #1
+ \hbox_set:Nn #1
+ { \box_move_down:nn { \l_tmpa_dim } { \box_use:N \l_tmpa_box } }
+}
+
+
+%% Making inferences
+%
+% The following commands use the parameters defined at the beginning of the
+% package for actually building proof trees using the commands defined above.
+
+% Append the contents of the second tree above or below the first one,
+% depending on current settings. Axes are aligned and the marks of the first
+% tree are preserved.
+
+\cs_new:Nn \ebproof_append_vertical:NN {
+ \bool_if:NTF \l_ebproof_updown_bool
+ { \ebproof_append_below:NN #1 #2 }
+ { \ebproof_append_above:NN #1 #2 }
+}
+
+% Make a box containing an inference rule with labels, using the current
+% settings. The width and axis position are taken as those of the conclusion
+% of another tree box. The third argument is used as a temporary register for
+% building labels.
+
+\cs_new:Nn \ebproof_make_rule_for:NNN {
+
+ % Build the rule.
+
+ \ebproof_make_vertical:Nnnn #1
+ { \ebproof_mark:Nn #2 {axis} - \ebproof_mark:Nn #2 {left} }
+ { \ebproof_mark:Nn #2 {right} - \ebproof_mark:Nn #2 {left} }
+ {
+ \skip_vertical:N \l_ebproof_rule_margin_dim
+ \tl_if_empty:NF { \l_ebproof_rule_code_tl } {
+ \tl_use:N \l_ebproof_rule_code_tl
+ \skip_vertical:N \l_ebproof_rule_margin_dim
+ }
+ }
+ \ebproof_vcenter:N #1
+
+ % Append the left label
+
+ \tl_if_blank:VF \l_ebproof_left_label_tl {
+ \ebproof_make_simple:Nn #3 {
+ \box_move_down:nn { \l_ebproof_label_axis_dim } { \hbox:n {
+ \cs_set_eq:NN \inserttext \l_ebproof_left_label_tl
+ \tl_use:N \l_ebproof_left_label_template_tl
+ } }
+ }
+ \box_set_ht:Nn #3 { 0pt }
+ \box_set_dp:Nn #3 { 0pt }
+ \ebproof_append_left:NnN
+ \l_ebproof_c_box \l_ebproof_label_separation_dim \l_ebproof_d_box
+ }
+
+ % Append the right label
+
+ \tl_if_blank:VF \l_ebproof_right_label_tl {
+ \ebproof_make_simple:Nn #3 {
+ \box_move_down:nn { \l_ebproof_label_axis_dim } { \hbox:n {
+ \cs_set_eq:NN \inserttext \l_ebproof_right_label_tl
+ \tl_use:N \l_ebproof_right_label_template_tl
+ } }
+ }
+ \box_set_ht:Nn #3 { 0pt }
+ \box_set_dp:Nn #3 { 0pt }
+ \ebproof_append_right:NnN
+ \l_ebproof_c_box \l_ebproof_label_separation_dim \l_ebproof_d_box
+ }
+
+}
+
+
+%% Stack-based interface
+
+%%% The stack
+
+% Logically, box structures are stored on a stack. However, TeX does not
+% provide data structures for that and the grouping mechanism is not flexible
+% enough, so we encode them using what we actually have. A stack for boxes is
+% implemented using a global hbox |\g_ebproof_stack_box| that contains all the
+% boxes successively. A sequence |\g_ebproof_stack_seq| is used to store the
+% dimensions property lists textually. We maintain a counter
+% |\g_ebproof_level_int| with the number of elements on the stack, for
+% consistency checks.
+
+\int_new:N \g_ebproof_level_int
+\box_new:N \g_ebproof_stack_box
+\seq_new:N \g_ebproof_stack_seq
+
+% Clear the stack.
+
+\cs_new:Nn \ebproof_clear_stack: {
+ \int_gset:Nn \g_ebproof_level_int { 0 }
+ \hbox_gset:Nn \g_ebproof_stack_box { }
+ \seq_gclear:N \g_ebproof_stack_seq
+}
+
+% Push the contents of a register on the stack.
+
+\cs_new:Nn \ebproof_push:N {
+ \int_gincr:N \g_ebproof_level_int
+ \hbox_gset:Nn \g_ebproof_stack_box
+ { \hbox_unpack:N \g_ebproof_stack_box \box_use:N #1 }
+ \seq_gput_left:Nv \g_ebproof_stack_seq
+ { l_ebproof_marks_ \__int_value:w #1 _prop }
+}
+
+% Pop the value from the top of the stack into a register.
+
+\cs_new:Nn \ebproof_pop:N {
+ \int_compare:nNnTF { \g_ebproof_level_int } > { 0 } {
+ \int_gdecr:N \g_ebproof_level_int
+ \hbox_gset:Nn \g_ebproof_stack_box {
+ \hbox_unpack:N \g_ebproof_stack_box
+ \box_gset_to_last:N \g_tmpa_box
+ }
+ \box_set_eq_clear:NN #1 \g_tmpa_box
+ \seq_gpop_left:NN \g_ebproof_stack_seq \l_tmpa_tl
+ \tl_set_eq:cN { l_ebproof_marks_ \__int_value:w #1 _prop } \l_tmpa_tl
+ } {
+ \PackageError{ebproof}{Missing~premiss~in~a~proof~tree}{}
+ \ebproof_clear:N #1
+ }
+}
+
+%%% Assembling trees
+
+\ebproof_new:N \l_ebproof_a_box
+\ebproof_new:N \l_ebproof_b_box
+\ebproof_new:N \l_ebproof_c_box
+\ebproof_new:N \l_ebproof_d_box
+
+% Join horizontally a number of elements at the top of the stack. If several
+% trees are joined, use the left mark of the left tree, the right mark of the
+% right tree and set the axis in the middle of these marks.
+
+\cs_new:Nn \ebproof_join_horizontal:n {
+ \int_case:nnF { #1 } {
+ { 0 } {
+ \group_begin:
+ \ebproof_clear:N \l_ebproof_a_box
+ \ebproof_push:N \l_ebproof_a_box
+ \group_end:
+ }
+ { 1 } { }
+ } {
+ \group_begin:
+ \ebproof_pop:N \l_ebproof_a_box
+ \prg_replicate:nn { #1 - 1 } {
+ \ebproof_pop:N \l_ebproof_b_box
+ \ebproof_append_left:NnN
+ \l_ebproof_a_box \l_ebproof_separation_dim \l_ebproof_b_box
+ }
+ \ebproof_set_mark:Nnn \l_ebproof_a_box { left }
+ { \ebproof_mark:Nn \l_ebproof_b_box { left } }
+ \ebproof_set_mark:Nnn \l_ebproof_a_box { axis }
+ { ( \ebproof_mark:Nn \l_ebproof_a_box { left }
+ + \ebproof_mark:Nn \l_ebproof_a_box { right } ) / 2 }
+ \ebproof_push:N \l_ebproof_a_box
+ \group_end:
+ }
+}
+
+% Join vertically the two elements at the top of the stack, with a horizontal
+% rule of the appropriate size.
+
+\cs_new:Nn \ebproof_join_vertical: {
+ \group_begin:
+ \ebproof_pop:N \l_ebproof_a_box
+ \ebproof_pop:N \l_ebproof_b_box
+ \ebproof_enlarge_conclusion:NN \l_ebproof_b_box \l_ebproof_a_box
+ \ebproof_make_rule_for:NNN \l_ebproof_c_box \l_ebproof_b_box
+ \l_ebproof_d_box
+ \ebproof_append_vertical:NN \l_ebproof_a_box \l_ebproof_c_box
+ \ebproof_append_vertical:NN \l_ebproof_a_box \l_ebproof_b_box
+ \ebproof_push:N \l_ebproof_a_box
+ \group_end:
+}
+
%%% High-level commands
% Push a box with default formatting, using explicit alignment if the code
% contains a |&| character
-\def\ebproof at hypo@parse#1\ebproof at hypo@stop{
- {\def\ARG{#3}\ifx\ARG\@empty
- \aftergroup\iftrue\@gobble\fi
- \else\aftergroup\iffalse\@gobble\fi\fi}%
- % The above code has produced \iftrue or \iffalse here.
- \ebproof at pushsimple%
- {\def\inserttext{#1}\pgfkeysvalueof{/ebproof/template}}%
- \else
- \ebproof at pushsplit
- {\def\inserttext{#1}\pgfkeysvalueof{/ebproof/left template}}%
- {\def\inserttext{#2}\pgfkeysvalueof{/ebproof/right template}}%
- \fi}
+\cs_new:Npn \ebproof_statement_parse:w #1\ebproof_statement_stop: {
+ \tl_if_empty:nTF { #3 } {
+ \ebproof_make_simple:Nn \l_ebproof_a_box
+ { \cs_set:Npn \inserttext { #1 } \tl_use:N \l_ebproof_template_tl }
+ } {
+ \ebproof_make_split:Nnn \l_ebproof_a_box
+ { \cs_set:Npn \inserttext { #1 } \tl_use:N \l_ebproof_left_template_tl }
+ { \cs_set:Npn \inserttext { #2 } \tl_use:N \l_ebproof_right_template_tl }
+ }
+ \ebproof_push:N \l_ebproof_a_box
+}
-\newcommand\ebproof at hypo[2][]{%
- {\ebproofset{#1}\ebproof at hypo@parse#2&&\ebproof at hypo@stop}}
+\cs_new:Nn \ebproof_push_statement:n {
+ \ebproof_statement_parse:w #1&& \ebproof_statement_stop:
+}
-% Build a n-ary rule
-\def\ebproof at infer{%
- \@ifnextchar[{\ebproof at infer@}{\ebproof at infer@[]}}
-\def\ebproof at infer@[#1]#2{%
- \@ifnextchar[%
- {\ebproof at infer@with at label{#1}{#2}}%
- {\ebproof at infer@@{#1}{#2}}}
-\def\ebproof at infer@with at label#1#2[#3]{%
- \ebproof at infer@@{#1,right label={#3}}{#2}}
-\def\ebproof at infer@@#1#2#3{{%
- \pgfqkeys{/ebproof/rule style}{.search also=/ebproof,#1}%
- \ebproof at joinh@multi{#2}%
- \ebproof at hypo{#3}%
- \ebproof at joinv}}
+%% Document interface
-% Ellipsis with vertical dots
+%%% Functions to define statements
-\def\ebproof at ellipsis#1#2{{%
- \ebproofset{rule code=}%
- \ebproof at pushsplit{}{%
- \setbox0=\vbox{\kern1.2ex\hbox{\ignorespaces#1}\hrule height 0pt\kern1.2ex}%
- \vbox to\ht0{\xleaders\vbox to .8ex{\vss\hbox{.}\vss}\vfill}%
- \rlap{ \box0}}%
- \ebproof at joinv
- \ebproof at hypo{#2}%
- \ebproof at joinv}}
+% The |\g_ebproof_stack_seq| variable contains the list of all defined
+% statements. For each statement |X|, there is a document command |\ebproofX|
+% and the alias |\X| is defined when entering a |prooftree| environment.
+\seq_new:N \g_ebproof_statements_seq
+
+% Install the aliases for statements, saving the original value of the control
+% sequences.
+
+\cs_new:Nn \ebproof_setup_statements: {
+ \seq_map_inline:Nn \g_ebproof_statements_seq {
+ \cs_set_eq:cc { ebproof_saved_ ##1 } { ##1 }
+ \cs_set_eq:cc { ##1 } { ebproof ##1 }
+ }
+}
+
+% Restore the saved meanings of the control sequences. This is useful when
+% interpreting user-provided code in statement arguments. The meanings are
+% automatically restored when leaving a |prooftree| environment because of
+% grouping.
+
+\cs_new:Nn \ebproof_restore_statements: {
+ \seq_map_inline:Nn \g_ebproof_statements_seq {
+ \cs_set_eq:cc { ##1 } { ebproof_saved_ ##1 }
+ }
+}
+
+% Define a new statement. The first argument is the name, the second one is an
+% argument specifier as used by |xparse| and the third one is the body of the
+% command.
+
+\cs_new:Nn \ebproof_new_statement:nnn {
+ \exp_args:Nc \NewDocumentCommand { ebproof#1 }{ #2 } { #3 }
+ \seq_put_right:Nn \g_ebproof_statements_seq { #1 }
+}
+
+% Define a deprecated statement. The syntax is the same as above except that
+% an extra argument in third position indicates what should be used instead.
+% The effect is the same except that a warning message is issued the first
+% time the statement is used.
+
+\cs_new:Nn \ebproof_new_deprecated_statement:nnnn {
+ \cs_new:cpn { ebproof_#1_warning: } {
+ \PackageWarning { ebproof } { \token_to_str:c{#1}~is~deprecated,~#3 }
+ \cs_gset:cn { ebproof_#1_warning: } { }
+ }
+ \ebproof_new_statement:nnn { #1 } { #2 }
+ { \use:c { ebproof_#1_warning: } #4 }
+}
+
+
+%%% Basic commands
+
+\ebproof_new_statement:nnn { set } { m } {
+ \keys_set:nn { ebproof } { #1 }
+}
+
+\ebproof_new_statement:nnn { hypo } { O{} m } {
+ \group_begin:
+ \ebproof_restore_statements:
+ \keys_set:nn { ebproof } { #1 }
+ \ebproof_push_statement:n { #2 }
+ \group_end:
+}
+
+\ebproof_new_statement:nnn { infer } { O{} m O{} m } {
+ \group_begin:
+ \ebproof_restore_statements:
+ \keys_set_known:nnN { ebproof / rule~style } { #1 } \l_tmpa_tl
+ \keys_set:nV { ebproof } \l_tmpa_tl
+ \tl_set:Nn \l_ebproof_right_label_tl { #3 }
+ \ebproof_join_horizontal:n { #2 }
+ \ebproof_push_statement:n { #4 }
+ \ebproof_join_vertical:
+ \group_end:
+}
+
+\ebproof_new_statement:nnn { ellipsis } { m m } {
+ \group_begin:
+ \ebproof_restore_statements:
+ \tl_clear:N \l_ebproof_rule_code_tl
+ \ebproof_make_split:Nnn \l_ebproof_a_box { } {
+ \vbox_set:Nn \l_tmpa_box {
+ \skip_vertical:n { 1.2ex }
+ \hbox:n { \tex_ignorespaces:D #1 }
+ \skip_vertical:n { 1.2ex }
+ }
+ \vbox_to_ht:nn { \box_ht:N \l_tmpa_box } {
+ \tex_xleaders:D \vbox_to_ht:nn { .8ex }
+ { \tex_vss:D \hbox:n { . } \tex_vss:D }
+ \tex_vfill:D
+ }
+ \hbox_overlap_right:n { ~ \box_use:N \l_tmpa_box }
+ }
+ \ebproof_push:N \l_ebproof_a_box
+ \ebproof_join_vertical:
+ \ebproof_push_statement:n {#2}
+ \ebproof_join_vertical:
+ \group_end:
+}
+
+
+%%% Modifying trees
+
+% Rewrite the box at the top of the stack while preserving its dimensions an
+% marks. The code is typeset in horizontal mode, with control sequences to
+% access the original box and its marks:
+% - \treebox is a box register with the original material
+% - \treemark{NAME} provides the value of a given mark
+
+\ebproof_new_statement:nnn { rewrite } { m } {
+ \group_begin:
+ \ebproof_restore_statements:
+ \ebproof_pop:N \l_ebproof_a_box
+ \box_set_eq:NN \l_tmpa_box \l_ebproof_a_box
+ \hbox_set:Nn \l_tmpb_box {
+ \cs_set_eq:NN \treebox \l_tmpa_box
+ \cs_set:Npn \treemark { \ebproof_mark:Nn \l_ebproof_a_box }
+ { #1 }
+ }
+ \box_set_wd:Nn \l_tmpb_box { \box_wd:N \l_ebproof_a_box }
+ \box_set_ht:Nn \l_tmpb_box { \box_ht:N \l_ebproof_a_box }
+ \box_set_dp:Nn \l_tmpb_box { \box_dp:N \l_ebproof_a_box }
+ \box_set_eq:NN \l_ebproof_a_box \l_tmpb_box
+ \ebproof_push:N \l_ebproof_a_box
+ \group_end:
+}
+
+% Insert |\left| and |\right| delimiters without changing the alignment
+
+\ebproof_new_statement:nnn { delims } { m m } {
+ \group_begin:
+ \ebproof_restore_statements:
+ \ebproof_pop:N \l_ebproof_a_box
+ \hbox_set:Nn \l_tmpa_box
+ { $ \tex_vcenter:D { \box_use:N \l_ebproof_a_box } $ }
+ \dim_set:Nn \l_tmpa_dim
+ { \box_ht:N \l_tmpa_box - \box_ht:N \l_ebproof_a_box }
+ \hbox_set:Nn \l_ebproof_a_box {
+ $ #1 \tex_vrule:D
+ height \box_ht:N \l_tmpa_box depth \box_dp:N \l_tmpa_box width 0pt
+ \tex_right:D . $
+ }
+ \ebproof_shift_x:Nn \l_ebproof_a_box { \box_wd:N \l_ebproof_a_box }
+ \hbox_set:Nn \l_ebproof_a_box {
+ \hbox_unpack:N \l_ebproof_a_box
+ $ \tex_left:D . \box_use:N \l_tmpa_box #2 $
+ }
+ \hbox_set:Nn \l_ebproof_a_box
+ { \box_move_down:nn { \l_tmpa_dim } { \box_use:N \l_ebproof_a_box } }
+ \ebproof_push:N \l_ebproof_a_box
+ \group_end:
+}
+
+
+%%% Deprecated statements
+
+% These statements were defined in versions 1.x of the package, they are
+% preserved for temporary upwards compatibility and will be removed in a
+% future version.
+
+\ebproof_new_deprecated_statement:nnnn { Alter } { m }
+ { use~\token_to_str:c{rewrite}~instead } { \ebproofrewrite{ #1 \box\treebox } }
+\ebproof_new_deprecated_statement:nnnn { Delims } { }
+ { use~\token_to_str:c{delims}~instead } { \ebproofdelims }
+\ebproof_new_deprecated_statement:nnnn { Ellipsis } { }
+ { use~\token_to_str:c{ellipsis}~instead } { \ebproofellipsis }
+\ebproof_new_deprecated_statement:nnnn { Hypo } { }
+ { use~\token_to_str:c{hypo}~instead } { \ebproofhypo }
+\ebproof_new_deprecated_statement:nnnn { Infer } { }
+ { use~\token_to_str:c{infer}~instead } { \ebproofinfer }
+
+
%%% Environment interface
-\ebproof at clear
+\ebproof_clear_stack:
-\def\ebproof at begin{%
- \edef\ebproof at start@level{\the\ebproof at level}%
- \setbox1=\vbox\bgroup
- \let\Hypo=\ebproof at hypo
- \let\Infer=\ebproof at infer
- \let\Ellipsis=\ebproof at ellipsis
- \let\Alter=\ebproof at alter
- \let\Delims=\ebproof at delims}
-\def\ebproof at end{%
- \egroup
- \ebproof at pop{X}%
- \ifnum\ebproof at level=\ebproof at start@level\else
- \PackageError{ebproof}{Malformed proof tree}{%
- Some hypotheses were declared but not used in this tree.}%
- \fi
- \ifebproof at center
- \hbox{$\vcenter{\hbox{\box\X at box}}$}%
- \else
- \box\X at box
- \fi
- \global\setbox\ebproof at box@temp=\box1}
+\tl_new:N \l_ebproof_start_level_tl
-\newenvironment{prooftree}[1][]{%
- \pgfqkeys{/ebproof/proof style}{.search also=/ebproof,#1}%
- \leavevmode\ebproof at begin
-}{%
- \ebproof at end}
+\NewDocumentEnvironment { prooftree } { s O{} } {
+ \keys_set_known:nnN { ebproof / proof~style } { #2 } \l_tmpa_tl
+ \keys_set:nV { ebproof } \l_tmpa_tl
+ \tl_set:Nx \l_ebproof_start_level_tl { \int_use:N \g_ebproof_level_int }
+ \vbox_set:Nw \l_tmpa_box
+ \ebproof_setup_statements:
+} {
+ \vbox_set_end:
+ \ebproof_pop:N \l_ebproof_a_box
+ \int_compare:nNnF { \g_ebproof_level_int } = { \tl_use:N \l_ebproof_start_level_tl } {
+ \PackageError{ebproof}{Malformed~proof~tree}{
+ Some~hypotheses~were~declared~but~not~used~in~this~tree.}
+ }
+ \IfBooleanTF { #1 } {
+ \[ \box_use:N \l_ebproof_a_box \]
+ \ignorespacesafterend
+ } {
+ \hbox_unpack:N \c_empty_box
+ \bool_if:NTF \l_ebproof_center_bool {
+ \hbox:n { $ \tex_vcenter:D { \box_use:N \l_ebproof_a_box } $ }
+ } {
+ \box_use:N \l_ebproof_a_box
+ }
+ }
+}
-\newenvironment{prooftree*}[1][]{%
- \center
- \pgfqkeys{/ebproof/proof style}{.search also=/ebproof,#1}%
- \leavevmode\ebproof at begin
-}{%
- \ebproof at end
- \endcenter}
+% A trick for the starred version:
+\cs_new:cpn { prooftree* } { \prooftree* }
+\cs_new:cpn { endprooftree* } { \endprooftree }
More information about the tex-live-commits
mailing list