Debian Codegraph @

texmf-dist/source/latex/logicproof/logicproof.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 2014 by Alan Davidson <[email protected]>
4 % ---------------------------------------------------------------------------
5 % This work may be distributed and/or modified under the
6 % conditions of the LaTeX Project Public License, either version 1.3
7 % of this license or (at your option) any later version.
8 % The latest version of this license is in
9 % http://www.latex-project.org/lppl.txt
10 % and version 1.3 or later is part of all distributions of LaTeX
11 % version 2005/12/01 or later.
12 %
13 % This work has the LPPL maintenance status `maintained'.
14 %
15 % The Current Maintainer of this work is Alan Davidson.
16 %
17 % This work consists of the files logicproof.dtx and logicproof.ins
18 % and the derived filebase logicproof.sty.
19 %
20 % \fi
21 %
22 % \iffalse
23 %<*driver>
24 \ProvidesFile{logicproof.dtx}
25 %</driver>
26 %<package>\NeedsTeXFormat{LaTeX2e}
27 %<package>\ProvidesPackage{logicproof}[2014/03/20 v1.0 Box proofs for propositional logic]
28 %
29 %<*driver>
30 \documentclass{ltxdoc}
31 \usepackage{logicproof}[2014/03/20]
32 \EnableCrossrefs
33 \CodelineIndex
34 \RecordChanges
35 \begin{document}
36 \DocInput{logicproof.dtx}
37 \PrintChanges
38 \PrintIndex
39 \end{document}
40 %</driver>
41 % \fi
42 %
43 % \CheckSum{0}
44 %
45 % \CharacterTable
46 % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
47 % Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
48 % Digits \0\1\2\3\4\5\6\7\8\9
49 % Exclamation \! Double quote \" Hash (number) \#
50 % Dollar \$ Percent \% Ampersand \&
51 % Acute accent \' Left paren \( Right paren \)
52 % Asterisk \* Plus \+ Comma \,
53 % Minus \- Point \. Solidus \/
54 % Colon \: Semicolon \; Less than \<
55 % Equals \= Greater than \> Question mark \?
56 % Commercial at \@ Left bracket \[ Backslash \\
57 % Right bracket \] Circumflex \^ Underscore \_
58 % Grave accent \` Left brace \{ Vertical bar \|
59 % Right brace \} Tilde \~}
60 %
61 %
62 % \changes{1.0}{2014/03/20}{First version for public release}
63 % \changes{0.1}{2004/12/05}{Initial version created}
64 % \GetFileInfo{logicproof.dtx}
65 %
66 % \DoNotIndex{\newcommand,\newenvironment}
67 %
68 % \providecommand*{\url}{\texttt}
69 % \title{The \textsf{logicproof} package}
70 % \author{Alan Davidson \\ \url{[email protected]}}
71 % \date{20 March 2014}
72 %
73 % \maketitle
74 %
75 % \section{Introduction}
76 %
77 % This package provides support for Fitch-style box proofs, intended to be used
78 % for proofs in propositional logic and predicate logic. In this proof style,
79 % each statement of the proof is accompanied by a justification, and subproofs
80 % or lemmata within a larger proof are enclosed in boxes to separate them from
81 % the rest of the proof.
82 %
83 % \section{Usage}
84 %
85 % \DescribeEnv{logicproof}
86 % The |logicproof| environment takes a single argument, which should be a
87 % nonnegative integer describing the maximum number of nested subproofs that
88 % this proof will contain. Each line of the proof consists of two main
89 % columns: the proof statement of the current line, followed by an ampersand
90 % (|&|), followed by the justification for the statement.
91 % Lines should be separated from each other by a |\\|.
92 % The column of proof statements defaults to
93 % math mode, while the justification column defaults to normal text.
94 %
95 % If you add a |\label| within a proof, the corresponding |\ref| will be the
96 % current line number.
97 %
98 % \DescribeEnv{subproof}
99 % Within these logic proofs, it is often necessary to make subproofs which begin
100 % by making some sort of assumption that does not necessarily hold in the
101 % broader proof. To delineate the scope of these assumptions, use the |subproof|
102 % environment, which will draw a box around the statements of the proof for
103 % which these assumptions should hold. Subproofs can be nested within each
104 % other, up to the maximum level provided as an argument to the |logicproof|
105 % environment.
106 %
107 % Within a subproof, the format of each line is exactly the same as in the
108 % |logicproof| environment: a proof statement, followed by an ampersand (|&|),
109 % followed by a justification for the statement, with |\\| at the end of every
110 % line except the last one (which instead ends with |\end{subproof}|).
111 %
112 % If a statement has an empty justification, it is still important to put in the
113 % |&| to separate out the column in which the justification would go, or else
114 % the right sides of the subproof boxes will be misaligned for this statement.
115 %
116 % The previous line before a subproof begins should end in either |\\| or
117 % |\end{subproof}|.
118 %
119 % A warning for advanced \LaTeX~users: although most environments make their own
120 % groups (such that changes made within an environment go out of scope at the
121 % end of it), the |subproof| environment does not! Any changes made within a
122 % |subproof|
123 % environment will not go out of scope until the enclosing |logicproof|
124 % environment ends. This was done because groups cannot cross alignment tabs,
125 % but the |subproof| environment needs to use the same alignment as the
126 % enclosing |logicproof| environment does (or else they won't line up together).
127 % An inconvenient side effect of this is that when you forget to put in a
128 % |\end{subproof}|, the error message about mismatched environments points to
129 % the line number where the enclosing |logicproof| environment started, rather
130 % than the offending |subproof| environment.
131 %
132 % \section{Example}
133 %
134 % This example proves the validity of the sequent
135 % $(p\lor q)\lor r\vdash p\lor (q\lor r)$. There are many different styles that
136 % can be used for the justification of each step; we are using the style found
137 % in \emph{Logic in Computer Science: Modelling and Reasoning about Systems} by
138 % Huth and Ryan.
139 %
140 %\begin{verbatim}
141 %\begin{logicproof}{2}
142 % (p\lor q)\lor r & premise\\
143 % \begin{subproof}
144 % (p\lor q) & assumption\\
145 % \begin{subproof}
146 % p & assumption\\
147 % p\lor (q\lor r) & $\lor\mathrm{i}_1$, 3
148 % \end{subproof}
149 % \begin{subproof}
150 % q & assumption\\
151 % q\lor r & $\lor\mathrm{i}_1$, 5\\
152 % p\lor (q\lor r) & $\lor\mathrm{i}_2$, 6
153 % \end{subproof}
154 % p\lor (q\lor r) & $\lor$e, 2, 3--4, 5--7
155 % \end{subproof}
156 % \begin{subproof}
157 % r & assumption\\
158 % q\lor r & $\lor\mathrm{i}_2$, 9\\
159 % p\lor (q\lor r) & $\lor\mathrm{i}_2$, 10
160 % \end{subproof}
161 % p\lor (q\lor r) & $\lor$e, 1, 2--8, 9--11
162 %\end{logicproof}
163 %\end{verbatim}
164 % This compiles into the following:
165 %\begin{logicproof}{2}
166 % (p\lor q)\lor r & premise\\
167 % \begin{subproof}
168 % (p\lor q) & assumption\\
169 % \begin{subproof}
170 % p & assumption\\
171 % p\lor (q\lor r) & $\lor\mathrm{i}_1$, 3
172 % \end{subproof}
173 % \begin{subproof}
174 % q & assumption\\
175 % q\lor r & $\lor\mathrm{i}_1$, 5\\
176 % p\lor (q\lor r) & $\lor\mathrm{i}_2$, 6
177 % \end{subproof}
178 % p\lor (q\lor r) & $\lor$e, 2, 3--4, 5--7
179 % \end{subproof}
180 % \begin{subproof}
181 % r & assumption\\
182 % q\lor r & $\lor\mathrm{i}_2$, 9\\
183 % p\lor (q\lor r) & $\lor\mathrm{i}_2$, 10
184 % \end{subproof}
185 % p\lor (q\lor r) & $\lor$e, 1, 2--8, 9--11
186 %\end{logicproof}
187 %
188 % \section{Advanced Configuration}
189 %
190 % There are two lengths that can be configured manually if desired.
191 %
192 % \DescribeMacro{\subproofhorizspace}
193 % The
194 % horizontal distance between the sides of nested boxes is the length stored in
195 % |\subproofhorizspace|. If you have many nested subproofs, it might be
196 % desirable to make this space larger so that it is easier to distinguish
197 % between them.
198 %
199 % \DescribeMacro{\intersubproofvertspace}
200 % An extra vertical space of length
201 % |\intersubproofvertspace| is added after each statement in the proof. The
202 % intention here is to have this much space between consecutive subproofs. This
203 % is to say, when one subproof ends
204 % and the next subproof begins immediately, this is the distance between the
205 % bottom edge of the ending subproof and the top edge of the beginning subproof.
206 % This space is inserted after each line, however, so that the vertical spacing
207 % between them is consistent regardless of whether subproofs are begun or ended.
208 % If you want more compact proofs and you never use consecutive
209 % subproofs, it might be useful to reduce or remove this extra space.
210 %
211 % \section{Constraints}
212 % The environments in this package might not work properly if any of the
213 % following constraints are violated. These should not be difficult burdens;
214 % they are listed here mainly for completeness.
215 % \begin{itemize}
216 % \item Each proof and each subproof must be at least 1 statement long.
217 % \item Each subproof must start with at least 1 statement before containing
218 % another subproof inside itself. You should not have a subproof that
219 % immediately begins with a nested subproof.
220 % \item The end of each subproof must have at least 1 statement (or
221 % a new subproof) following
222 % it; a single proof statement cannot end multiple subproofs at once.
223 % Consequently, the last
224 % statement of the top-level proof must be outside of all subproofs. It is okay
225 % to immediately start a new subproof after ending a previous subproof.
226 % \end{itemize}
227 %
228 % \StopEventually{\PrintIndex\PrintChanges}
229 %
230 % \section{Summary of Implementation}
231 %
232 % The |logicproof| environment is built on the |tabular| environment. It has a
233 % column for the line number, a column for each possible nested subproof, a
234 % column for the statement, a column for the justification, and then a second
235 % column for each possible nested subproof.
236 % The columns corresponding to nested subproofs either contain a |\vline| if the
237 % subproof is currently being used, or nothing if the subproof is not being
238 % used.
239 % When a subproof is begun or ended, a |\cline| is used to draw
240 % horizontal lines between the columns corresponding to that subproof. In order
241 % to prevent multiple |\cline|'s from overlapping when one subproof is ended and
242 % another is immediately begun, each statement in the proof actually ends with
243 % a negative vertical space backing up to the previous line, then a space down
244 % |\intersubproofvertspace| and a redrawing of the subproof lines again to cover
245 % the extra space.
246 %
247 % \section{Implementation}
248 %
249 % \iffalse
250 %<*package>
251 % \fi
252 %
253 % \begin{macrocode}
254 \RequirePackage{array}
255 \RequirePackage{ifthen}
256 % \end{macrocode}
257 % \begin{macro}{\subproofhorizspace}
258 % \begin{macro}{\intersubproofvertspace}
259 % We allow the user to configure the horizontal and vertical distance between
260 % the edges of the boxes.
261 % \begin{macrocode}
262 \newlength{\subproofhorizspace}
263 \setlength{\subproofhorizspace}{0.5em}
264 \newlength{\intersubproofvertspace}
265 \setlength{\intersubproofvertspace}{0.333em}
266 % \end{macrocode}
267 % \end{macro}
268 % \end{macro}
269 % We use a variety of counters to keep track of the state.
270 % \begin{macrocode}
271 \newcounter{lp@line}% Current line number on the proof
272 \newcounter{lp@nested}% Number of nested subproofs we're currently in
273 \newcounter{lp@total@nests}% Maximum number of nested subproofs allowed
274 \newcounter{lp@cline@1}% Used to draw horizontal lines in subproofs
275 \newcounter{lp@cline@2}% Also used to draw horizontal lines in subproofs
276 \newcounter{lp@temp}% Temporary storage counter
277 % \end{macrocode}
278 %
279 % \begin{environment}{logicproof}
280 % Use this to make a logic proof. The argument it takes is the
281 % maximum number of nested subproofs you will use.
282 % \begin{macrocode}
283 \newenvironment{logicproof}[1]{%
284 \setcounter{lp@line}{0}%
285 \setcounter{lp@nested}{0}%
286 \setcounter{lp@total@nests}{#1}%
287 \setlength{\tabcolsep}{0mm}%
288 % \end{macrocode}
289 % When using the array package, the tabular environment contains the statement
290 % |\let\\\@arraycr| (note that with the array package, |\@tabularcr| is replaced
291 % with |\@arraycr| even within the tabular environment). So, to modify the
292 % behavior of |\\|, we're actually going to modify |\@arraycr|. Save a copy of the
293 % original definition first, so that we can use it inside our new definition.
294 % Remember that when the logicproof environment finishes, this redefinition
295 % will go out of scope and revert to the previous version, so we won't ruin
296 % any future uses of the tabular environment.
297 % \begin{macrocode}
298 \let\lp@orig@arraycr\@arraycr%
299 \renewcommand{\@arraycr}{\lp@cr}%
300 % \end{macrocode}
301 % Get labels to work in proofs by defining |\@currentlabel| to always be the
302 % line number, regardless of where we are in the proof. Note that the usual
303 % approach of using
304 % |\refstepcounter{lp@line}| doesn't work because it goes out of scope by the
305 % time we get to the next cell in the tabular environment.
306 % \begin{macrocode}
307 \renewcommand{\@currentlabel}{\p@lp@line\thelp@line}%
308 % \end{macrocode}
309 % If the maximum number of nested subproofs is 0, we need a slightly different
310 % column format, because the array environment doesn't like it when you repeat a
311 % formatting group 0 times.
312 % \begin{macrocode}
313 \ifthenelse{%
314 0=#1%
315 }{%
316 \def\lp@tab@format{{r@{~~~}>{$}l<{$}@{~~~~}l}}%
317 }{%
318 % \end{macrocode}
319 % Although we could use the |array| package's |>{...}| and |<{...}| features to
320 % have automatic placement of the vertical lines on the sides of subproofs,
321 % we would not be able to get the horizontal lines at the tops and bottoms
322 % of the subproofs to line up properly. Consequently, we go with the ``old
323 % school'' approach of putting subproofs in their own columns, so that we
324 % can use |\cline| to put the horizontal lines in their proper places.
325 % \begin{macrocode}
326 \def\lp@tab@format%
327 {{r@{~~~}*{#1}{l}@{~}>{$}l<{$}@{~~~~}l@{~}*{#1}{r}}}
328 }%
329 \center%
330 % \end{macrocode}
331 % We use the |tabular| environment instead of the |array| environment because
332 % we want
333 % to be able to have labels on individual lines. Since the entirety of the
334 % |array| environment is in math mode, it does not support more than one label
335 % per array.
336 % \begin{macrocode}
337 \expandafter\tabular\lp@tab@format%
338 \lp@start@proof@line%
339 }{%
340 \lp@stop@proof@line%
341 \endtabular%
342 \endcenter%
343 % \end{macrocode}
344 % To ensure that no one tries using the subproof environment outside of the
345 % logicproof environment, set the maximum number of nested subproofs to 0.
346 % \begin{macrocode}
347 \setcounter{lp@total@nests}{0}%
348 % \end{macrocode}
349 % Finally, make sure that all open subproofs have been closed. We do this last
350 % because if a subproof is still open, we need to set |\@currenvir| properly
351 % for |\end| to check and throw errors on, but previous commands have
352 % |\endgroup|'s that make it revert to previous definitions.
353 % \begin{macrocode}
354 \ifthenelse{%
355 0=\value{lp@nested}
356 }{% All is well.
357 }{% There are still open subproofs.
358 \def\@currenvir{subproof}%
359 }
360 }
361 % \end{macrocode}
362 % \end{environment}
363 % \begin{environment}{subproof}
364 % This environment puts a box around the lines of the proof within it. It
365 % should come right after either a |\\| or a |\end{subproof}|.
366 % \begin{macrocode}
367 \newenvironment{subproof}{%
368 % \end{macrocode}
369 % Make sure we don't start more nested subproofs than the current logicproof
370 % environment can handle.
371 % \begin{macrocode}
372 \ifthenelse{%
373 \value{lp@total@nests}>\value{lp@nested}%
374 }{% All is well; don't do anything.
375 }{%
376 \PackageError{logicproof}{Too many nested subproofs!}{%
377 Increase the maximum number of nested subproofs allowed
378 in the current logicproof environment.%
379 }%
380 }%
381 % \end{macrocode}
382 % The |\begin| and |\end| parts of an environment start and end a group, so that
383 % macros defined within them have local scope. However, a group cannot cross
384 % alignment tabs (|&|'s), which means that this subproof environment, which must
385 % cross them, needs to get rid of those extra groups first. So, we immediately
386 % end the group that |\begin| created before going on with the subproof. Note
387 % that this means any redefinitions of any macros we might have will persist
388 % outside this subproof and will not go out of scope until the entire
389 % logicproof environment is over. Note also that this approach is slightly
390 % brittle: if the implementation of |\begin| and |\end| ever changes, this
391 % subproof environment is likely to break.
392 % \begin{macrocode}
393 \endgroup%
394 \lp@stop@proof@line%
395 % \end{macrocode}
396 % Ideally, we'd use |\lp@extend@space| here. However, we first need to end the
397 % current line, which means putting in |\lp@orig@arraycr| and then going up an
398 % extra line in the tabular environment via |\lp@add@space|.
399 % \begin{macrocode}
400 \lp@orig@arraycr%
401 \lp@add@space%
402 \lp@go@up@a@line%
403 \stepcounter{lp@nested}%
404 \lp@cr@clines%
405 % \end{macrocode}
406 % The current line number was added in before this subproof was started. Do
407 % not add it in again now; just skip over the line number entry and go
408 % straight on to the subproof-drawing stuff.
409 % \begin{macrocode}
410 &%
411 \lp@continue@proof@line%
412 }{%
413 % \end{macrocode}
414 % If we try ending a subproof that has not yet begun, we will run into trouble
415 % with |\cline| trying to draw a horizontal line to a column past the end of the
416 % tabular environment. This happens before |\end| actually checks whether we're
417 % ending the right environment. In order to get a more useful error message,
418 % we first check that there is at least 1 open subproof.
419 % \begin{macrocode}
420 \ifthenelse{%
421 0<\value{lp@nested}%
422 }{% All is well; don't do anything.
423 }{%
424 \PackageError{logicproof}{Cannot end a subproof before it begins}{%
425 You must have a \protect\begin{subproof} before you can use %
426 \protect\end{subproof}.%
427 }%
428 }%
429 \lp@stop@proof@line%
430 \lp@cr@clines%
431 \addtocounter{lp@nested}{-1}%
432 \lp@extend@space%
433 \lp@start@proof@line%
434 % \end{macrocode}
435 % Now that we're done with the subproof, we need to create a group because
436 % |\end| is expecting us to still be in the group that was started in |\begin|. We
437 % also must redefine |\@currenvir| within that group, or the error-checking in
438 % |\end| will think we've ended the wrong environment (its previous redefinition
439 % went out of scope when we ended the group created by |\begin|).
440 % \begin{macrocode}
441 \begingroup%
442 \def\@currenvir{subproof}%
443 }
444 % \end{macrocode}
445 % \end{environment}
446 % \begin{macro}{\lp@cr}
447 % This is what the |\\| will be defined as inside the logicproof environment.
448 % \begin{macrocode}
449 \newcommand{\lp@cr}{%
450 \lp@stop@proof@line%
451 \lp@orig@arraycr%
452 \lp@extend@space%
453 \lp@start@proof@line%
454 }
455 % \end{macrocode}
456 % \end{macro}
457 % \begin{macro}{\lp@go@up@a@line}
458 % This moves up one entire line in the proof.
459 % \begin{macrocode}
460 \newcommand{\lp@go@up@a@line}{%
461 \vspace{-\ht\@arstrutbox}%
462 \vspace{-\dp\@arstrutbox}%
463 \vspace{-\intersubproofvertspace}%
464 }
465 % \end{macrocode}
466 % \end{macro}
467 % \begin{macro}{\lp@add@space}
468 % Extends the vertical lines at the sides of the proof down slightly, so that
469 % the horizontal lines at the end of the previous subproof and the start of the
470 % next one don't overlap. This basically inserts a blank row in the proof (no
471 % line number, no statement, no justification; just the subproof lines), then
472 % backs up part of a line.
473 % \begin{macrocode}
474 \newcommand{\lp@add@space}{%
475 \lp@extend@space%
476 % \end{macrocode}
477 % The |\@arstrutbox| is a box containing the minimum array height. Remember that
478 % the height of the strut is spread between the height above the baseline and
479 % the depth below it!
480 % \begin{macrocode}
481 \vspace{-\ht\@arstrutbox}%
482 \vspace{-\dp\@arstrutbox}%
483 % \end{macrocode}
484 % Uncommenting this would line things up exactly where they started.
485 % \begin{macrocode}
486 %\vspace{-\intersubproofvertspace}%
487 }
488 % \end{macrocode}
489 % \end{macro}
490 % \begin{macro}{\lp@extend@space}
491 % This extends the vertical lines at the sides of the subproofs down by
492 % an extra |\intersubproofvertspace.| This is done so that two subproofs in a
493 % row don't have their horizontal lines overlap each other.
494 % \begin{macrocode}
495 \newcommand{\lp@extend@space}{%
496 \vspace{-\ht\@arstrutbox}%
497 \vspace{-\dp\@arstrutbox}%
498 \vspace{\intersubproofvertspace}%
499 % \end{macrocode}
500 % Now, insert a row that has vertical lines for the subproofs but no line
501 % number, proof statement, or justification.
502 % \begin{macrocode}
503 &%
504 \lp@continue@proof@line%
505 &%
506 \lp@stop@proof@line%
507 \lp@orig@arraycr%
508 }
509 % \end{macrocode}
510 % \end{macro}
511 % \begin{macro}{\lp@amper}
512 % You can't have a |&| in a |\whiledo| loop, but this works instead.
513 % \begin{macrocode}
514 \newcommand{\lp@amper}{&}
515 % \end{macrocode}
516 % \end{macro}
517 % \begin{macro}{\lp@start@proof@line}
518 % This macro does everything on a proof line before the statement itself: it
519 % increments and prints the line number, then calls
520 % |\lp@continue@proof@line| to put in the vertical lines of any subproofs we're
521 % currently in.
522 % \begin{macrocode}
523 \newcommand{\lp@start@proof@line}{%
524 % \end{macrocode}
525 % We use |\stepcounter| instead of |\refstepcounter| here because the changes made
526 % by |\refstepcounter| to how labels get made would go out of scope by the time
527 % we got to the next cell of the tabular environment (i.e., 2 lines from
528 % here). Instead, we redefined |\@currentlabel| at the beginning of the
529 % environment to always contain the current value of the |lp@line| counter.
530 % \begin{macrocode}
531 \stepcounter{lp@line}%
532 \arabic{lp@line}.%
533 &%
534 \lp@continue@proof@line%
535 }
536 % \end{macrocode}
537 % \end{macro}
538 % \begin{macro}{\lp@continue@proof@line}
539 % This macro makes the vertical lines of the subproof boxes on the left side of
540 % the proof (i.e., the ones that come between the line numbers and the proof
541 % statements). We use |\lp@amper| here because the raw |&| token doesn't play
542 % well with |\whiledo| loops.
543 % \begin{macrocode}
544 \newcommand{\lp@continue@proof@line}{%
545 \setcounter{lp@temp}{0}%
546 \whiledo{\value{lp@temp}<\value{lp@nested}}{%
547 \vline%
548 \hspace*{\subproofhorizspace}%
549 \lp@amper%
550 \stepcounter{lp@temp}%
551 }%
552 \whiledo{\value{lp@temp}<\value{lp@total@nests}}{%
553 \hspace*{\subproofhorizspace}%
554 \lp@amper%
555 \stepcounter{lp@temp}%
556 }%
557 }
558 % \end{macrocode}
559 % \end{macro}
560 % \begin{macro}{\lp@stop@proof@line}
561 % This macro makes the vertical lines of the subproof boxes on the right side
562 % of the proof (i.e., the ones that come after the justifications for each
563 % step). It basically does the same thing as |\lp@continue@proof@line|, but in
564 % reverse order. We use |\lp@amper| here because the raw |&| token doesn't play
565 % well with |\whiledo| loops.
566 % \begin{macrocode}
567 \newcommand{\lp@stop@proof@line}{%
568 \whiledo{\value{lp@temp}>\value{lp@nested}}{%
569 \addtocounter{lp@temp}{-1}%
570 \lp@amper%
571 \hspace*{\subproofhorizspace}%
572 }%
573 \whiledo{\value{lp@temp}>0}{%
574 \addtocounter{lp@temp}{-1}%
575 \lp@amper%
576 \hspace*{\subproofhorizspace}%
577 \vline%
578 }%
579 }
580 % \end{macrocode}
581 % \end{macro}
582 % \begin{macro}{\lp@subtract@from@counter}
583 % Subtraction by a value in another counter is annoying, but with this we can
584 % use |\expandafter| and make it easier.
585 % \begin{macrocode}
586 \newcommand{\lp@subtract@from@counter}[2]{%
587 \addtocounter{#2}{-#1}%
588 }
589 % \end{macrocode}
590 % \end{macro}
591 % \begin{macro}{\lp@set@clines}
592 % This macro sets up where the horizontal bars go for subproofs.
593 % \begin{macrocode}
594 \newcommand{\lp@set@clines}{%
595 % \end{macrocode}
596 % |lp@cline@1 = lp@nested + 1|
597 % \begin{macrocode}
598 \setcounter{lp@cline@1}{\value{lp@nested}}%
599 \stepcounter{lp@cline@1}%
600 % \end{macrocode}
601 % |lp@cline@2 = 2 * lp@total@nests + 4 - lp@nested|
602 % \begin{macrocode}
603 \setcounter{lp@cline@2}{\value{lp@total@nests}}%
604 \addtocounter{lp@cline@2}{\value{lp@total@nests}}%
605 \addtocounter{lp@cline@2}{4}%
606 % \end{macrocode}
607 % Subtracting one counter from another is tricky. We need to expand the value
608 % of the counter being subtracted first.
609 % \begin{macrocode}
610 \expandafter\lp@subtract@from@counter\expandafter{%
611 \value{lp@nested}}{lp@cline@2}%
612 }
613 % \end{macrocode}
614 % \end{macro}
615 % \begin{macro}{\lp@cr@clines}
616 % This macro goes to the next line of the tabular environment and puts in a
617 % horizontal line for the beginning or end of the current subproof.
618 % \begin{macrocode}
619 \newcommand{\lp@cr@clines}{%
620 \lp@set@clines%
621 % \end{macrocode}
622 % We put the |\lp@orig@arraycr| here instead of in |\lp@stop@proof@line| because
623 % |\cline| doesn't seem to work properly unless it's right after the carriage
624 % return. Even moving it up above |\lp@set@clines| on the previous line messes
625 % it up.
626 % \begin{macrocode}
627 \lp@orig@arraycr%
628 \cline{\value{lp@cline@1}-\value{lp@cline@2}}%
629 }
630 % \end{macrocode}
631 % \end{macro}
632 %
633 % \iffalse
634 %</package>
635 % \fi
636 %
637 % \Finale
638 \endinput