-
Notifications
You must be signed in to change notification settings - Fork 0
/
pf2.sty
1605 lines (1494 loc) · 58.6 KB
/
pf2.sty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% pf.sty
%
% last modified on Tue 27 September 2011 at 7:38:21 PST by lamport
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% THE pf STYLE %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% CONTENTS
% 1. Introduction
% 2. The Basic Commands
% 3. Different Styles of Numbering
% 4. Indentation
% 5. Assumptions
% 6. Suffices
% 7. Portions of a Proof
% 8. Conjunctions and Disjunctions
% 9. Spacing
% 10. Writing Two Versions of a Proof
% 11. Miscellany
% 12. List of all Commands and Environments
%
% 1. INTRODUCTION
%
% The pf style provides commands and environments for typesetting
% hierarchically structured proofs. Below is an example of what
% such a proof looks like, and the commands that generate it.
% The commands are explained individually below. Then
%
% THE OUTPUT THE INPUT
% ~~~~~~~~~~ ~~~~~~~~~
% Any text... Any text
% \begin{proof}
% 1. Text of step 1. \step{label-1}{Text of step 1.}
% \begin{proof}
% 1.1. Text of step. \step{label-1.1}{Text of step}
% \begin{proof}
% Proof: Paragraph \pf\ Paragraph proof.~\qed
% proof. [] \end{proof}
%
% 1.2. Text of step. \step{label-1.2}{Text of step.}
% \begin{proof}
% Proof: Paragraph \pf\ Paragraph proof.~\qed
% proof. [] \end{proof}
%
% 1.3. QED \qedstep
% \begin{proof}
% 1.3.1. Text of step \step{label-1.3.1}{Text...}
% Proof: ... [] \begin{proof} ... \end{proof}
%
% 1.3.2. QED \qedstep
% Proof: ... \begin{proof}...\end{proof}
% \end{proof}
% \end{proof}
%
% 2. Text of step 2. \step{label-2}{Text of step 2.}
% Proof: ... \begin{proof} \pf\ ... \end{proof}
%
% 3. QED \qedstep
% Proof: ... \begin{proof} \pf\ ... \end{proof}
%
%
% The best way to read such proofs is hierarchically. To find out
% how, search below for the \pfhidelevel command and the \hideqedproof
% command.
%
%
% 2. THE BASIC COMMANDS
%
% The proof Environment:
% Increments the proof depth, and indents the enclosed text the
% appropriate amount. For example, if the proof environment follows a
% \step command that produces step number 2.6.7, then the first \step
% command inside the environment will produce step number 2.6.7.1.
%
% \step{LABEL}{TEXT}
% This command produces a proof step such as
% 2.6.7.1. TEXT
% The step number 2.6.7.1 is determined by the position of the \step
% command in the proof. The LABEL is a symbol label used to refer to the
% step number. A subsequent \stepref{LABEL} command will generate the
% step number 2.6.7.1. The same LABEL may be re-used, but
% not in a context where it is legal to refer to a previous step with the
% same label. (See the discussion of step numbering below.)
%
% This command is equivalent to
% \begin{step+}{LABEL}
% TEXT
% \end{step+}
% The step+ environment form is more convenient if TEXT is long or
% complicated.
%
% \qedstep
% This command produces something like
%
% 2.6.7.5. QED
%
% If the proof of step 2.6.7 is a sequence of steps (rather than a
% paragraph proof), then the last step in its proof is normally of this
% form. The "QED" in the statement simply denotes the current
% goal---what must be proved to prove step 2.6.7. The proof of this QED
% step will be followed immediately by the
% \end{proof} command that ends the proof of step 2.6.7.
%
% The pf style does not enforce this method of structuring proofs;
% the proof of statement 2.6.7 could end with an ordinary \step
% command.
%
% \pf, \qed
% These are simple text-producing commands that normally begin and end a
% paragraph-style proof. However, they are not required. Remember to
% put a "\ " after the \pf command, and to tie the \qed command to the
% last word of the proof with a "~".
%
% \pfsketch
%
% An intuitive prook sketch often introduces a multi-step proof, as in
%
% 1.3. All odd numbers are prime.
% Proof sketch: The proof is by induction, with the
% base case proved in step 1 and the induction step in
% step 2.
% 1.3.1. The number 1 is a prime.
% Proof: ...
% 1.3.2. If n is an odd prime, then n+2 is prime.
% Proof: ...
% 1.3.3. QED
% Proof: 1.3.1, 1.3.2, and mathematical induction.
%
% This is entered as
%
% \step{label-1.3}{All odd numbers are prime}
% \begin{proof}
% \pfsketch\ The proof is by induction...
% \step{label-1.3.2}{The number 1 is a prime}
% ...
% \end{proof}
%
% The \pfsketch command is, like \pf, just produces the text. It isn't
% required by the pf style.
%
%
% 3. DIFFERENT STYLES OF NUMBERING
%
% In the long style of proof numbering, a step number is something like
% 2.6.7.5, meaning that it is the fifth step in the proof of statement
% 2.6.7, which is the seventh step in the proof of statement 2.6, which
% is... Statement 2.6.7.5 has the short name <4>5, meaning it is the
% fifth statement in the current level-4 proof. Numbering style is
% controlled by the commands
%
% \pfshortnumbers : Use short step numbers for all levels (the default)
% \pflongnumbers : Use long step numbers for all levels.
%
% Earlier, I thought it might be a good idea to use long numbers for
% higher levels of the proofs and switch to short number for lower
% levels. I therefore implemented this command:
%
% \pfmixednumbers{N} : Use short step numbers for all levels
% >= N (Default is N = 1, using only short
% numbers.
%
% However, it now seems to me to be a silly thing to do.
%
% These are local declarations that obey the usual scoping rules. Thus,
% putting a \pfshortnumbers declarations right after a \begin{proof}
% command causes all steps in that proof to have short numbers.
%
% Steps 2.6.7.5, 2.6.6.5, and 4.9.1.5 all have the same short numbers
% <4>5. However, no ambiguity arises from the use of short numbers
% because at most one of these steps can be mentioned at any point in a
% proof. Let the ANCESTORS of step 2.6.7.5 be steps 2.6.7, 2.6, and 2.
% Let the ELDER SIBLINGS of step 2.6.7.5 be steps 2.6.7.1, 2.6.7.2,
% 2.6.7.3, and 2.6.7.4. The proof statement 2.6.7.5 may refer only
% to steps in the following two sets:
% (i) The elder siblings of itself and of its ancestors.
% (ii) Itself and its ancestors.
% The steps in (i) are the previously-proved assertions that can be used
% in the proof of 2.6.7.5. The assumptions of the steps in (ii) are the
% ones that are being assumed in the proof. (Assumptions are discussed
% below.)
%
% The command \stepref{LABEL} anywhere in the proof of step 2.6.7.5 (or in
% the step itself) produces the step number of a step lying in sets (i)
% or (ii) having LABEL as its label (the first argument of its \step
% command). An error message is generated if the \step command has a
% label that is the label of a step in set (i) or (ii).
%
% Note that the last step of a proof is never an elder sibling, so it
% can't be in the set (i) for any statement. A QED-step has no
% assumptions, so it can't be in the set (ii) for any statement. That is
% why the \qedstep command does not specify a label. Actually, \qedstep
% is defined to equal \label{qedstepN}{...}, where N is the current
%. level number. Thus, an error will be generated if two \qedstep commands
% occur in the same proof, since they will have the same labels.
%
% Short step numbers are really nice. They take up less space and are
% easier to read. They are the preferred form for long proofs. However,
% long step numbers are better for referring to a proof step from outside
% the proof. The pf style allows you to print the long numbers of steps as
% marginal notes, something like
%
% Theorem: ...
% ...
% 2.4.5.6. <4>6. All odd numbers greater than 2 are prime.
% 2.4.5.6.1. <5>1. The number 3 is prime.
% ...
%
% (The long numbers are printed in a smaller font, so it looks
% better than you'd guess from this.) The relevant commands are:
%
% \pfsidenumbers{N}{D}
% Print side numbers for proof steps of all levels \geq N, left-aligned
% a distance D to the left of the left margin of the text.
%
% \pfnosidenumbers
% Do not print side numbers (the default)
%
%
% 4. INDENTATION
%
% There are two styles of indentation:
%
% Long Style
% 1. XXXXX
% 1.1. XXXXX
% 1.1.1. XXXXX
% 1.1.1.1. XXXX
% Proof: ...
%
% Short Style
% 1. XXXXX
% 1.1. XXXXX
% 1.1.1. XXXXX
% 1.1.1.1. XXXX
% Proof: ...
%
% In the long style, the proof of a statement lines up with the text of
% the statement. In the short form, each level is indented the same
% distance from the next higher level. The relevant declarations
% are
%
% \pflongindent
% Indent proofs to full width of item label
%
% \pfshortindent
% Indent proofs by the length parameter \pfindent (the default)
%
%
% 5. ASSUMPTIONS
%
% A common form of a step is
%
% <4>5. Assume: 1. n is an odd number
% 2. n > 2
% Prove: n is prime
%
% This asserts that the Prove clause follows from the Assume clause. The
% "QED" at the end of the proof of this step refers to the Prove clause.
% The input to produce this is
%
% \step{label-4.5}{
% \assume{\begin{pfenum}
% \item $n$ is an odd number
% \item $n>2$
% \end{pfenum}}
% \prove{$n$ is prime}}
%
% The relevant command syntax is
%
% \assume{TEXT}
% \prove{TEXT}
%
% The pfenum environment is like the enumerate environment, except
% it works propertly inside a proof environment. Note that
% \label and \ref command for subitem b of item 3 produces the label
% "3b". Note: there is a pfenum* environment that is like
% pfenum, except it indents the items.
%
%
% Another form of assumption is a Case assumption. The statement
%
% <5>1. Case: n is of the form 4n+1
%
% means
%
% <5>1. Assume: n is of the form 4n+1
% Prove: QED
%
% where QED is the current goal. A proof by cases is structured
% as follows
%
% <4>5. Assume: 1. n is an odd number
% 2. n > 2
% Prove: n is prime
%
% <5>1. Assume: n equals 4m+1 for some m
% Prove: QED
% Proof: ... []
%
% <5>2. Assume: n equals 4m+3 for some m
% Prove: QED
% Proof: ... []
%
% <5>3. QED
% Proof: By <5>1, <5>2, and assumption <4>.2 (which
% states that n is odd), since any odd number has
% the form 4m+1 or 4m+3. []
%
% A case assumption is produced with a \case command, which works like
% \assume and \prove. It has the syntax
%
% \case{TEXT}
%
% Note the reference, in the proof of <5>3, to the second conjunct of the
% Assume clause in statement <4>5 as "assumption <4>.2". Since a proof
% of a step can only use assumptions in that step or its ancestors, a
% level number suffices to identify an assumption. The Assume clause of
% statement <4>5 is called "assumption <4>". The ".2" refers to the
% second item in that clause. As mentioned below, this use of ".2" to
% refer to the second component of a conjunction can be used
% in other circumstances as well.
%
% When long numbering is used, assumptions must be referred to by the
% name of the statement containing the assumption. Thus, "assumption
% 2.6.7.5.2" could potentially mean either the Assume clause of statement
% 2.6.7.5.2, or the second item in the Assume clause of 2.6.7.5. One way
% to remove the ambiguity is to use something other than "." in long step
% numbers. The possibilities 2:6:7:5 and 2-6-7-5 don't look too good;
% the best alternative to "." seems to be a raised period ($\cdot$). The
% "." is changed by redefining \pfdot, as described below. Assumptions
% are referred to with the following commands:
%
% \levelref{LABEL}
% If \stepref{LABEL} produces <4>5, then \levelref{label}
% produces <4>.
% If \stepref{LABEL} produces 2.6.7.5, then \levelref{label} also
% produces 2.6.7.5.
%
% \toplevel
% If \stepref{LABEL} produces <4>5, then \toplevel
% produces "<0>".
% If \stepref{LABEL} produces 2.6.7.5, then \toplevel
% produces "0".
%
% 6. SUFFICES
%
% The step
%
% <3>2. Suffices: stmt
%
% asserts that to prove the current goal, it suffices to prove stmt.
% The body of the step is produced by the command
%
% \suffices{stmt}
%
% The assertion stmt then becomes the current goal of this level-3
% proof. The step
%
% <3>2. Suffices Assume: assump
% Prove: stmt
%
% similarly asserts that to prove the current goal, it suffices to
% assume assump and prove stmt. The assumption assump can then be used
% for the rest of this level-3 proof, and stmt becomes the proofs
% current goal. The body of this step is produced with the commands
%
% \sassume{assump}
% \prove{stmt}
%
%
% 7. PORTIONS OF A PROOF
%
% You may want to format only part of a proof--for example, you might
% want to write the proof of statement 2.1.3 as a separate proof. You'd
% want something like
%
% 2.1.3. All odd numbers are prime.
% 2.1.3.1. ...
%
% To do this, first imagine the shortest proof you can that has a
% statement numbered 2.1.3:
%
% 1. X
% 2. X
% 2.1. X
% 2.1.1. X
% 2.1.2. X
% 2.1.3. All odd numbers are prime.
% 2.1.3.1. ...
%
% Write this using the \step command and prove environment. Now, change
% every \step{LABEL}{X} command to \nostep{LABEL}, and change the proof
% environments surrounding the proofs of steps 2 and 2.1 by noproof
% environments. This yields
%
% \begin{proof}
% \nostep{label-1}
% \nostep{label-2}
% \begin{noproof}
% \nostep{label-2.1}
% \begin{noproof}
% \nostep{label-2.1.1}
% \nostep{label-2.1.2}
%
% \step{label-2.1.3} All oddnumbers are prime
% \begin{proof}
% \step{label-2.1.3.1} ...
% \end{proof}
% \end{noproof}
% \end{noproof}
% \end{proof}
%
% which produces the desired result. Note that the labels of the \nostep
% commands can be used to refer to the corresponding step numbers.
%
% 8. CONJUNCTIONS AND DISJUNCTIONS
%
% It is very convenient to write conjunctions as lists bulleted by \land.
% This is done with the conj environment, where
%
% $X = \begin{conj} PRODUCES X = /\ A
% A \\ B \\ C /\ B
% \end{conj}$ /\ C
%
% The conj* environment is similar, except it numbers the conjuncts.
%
% $X = \begin{conj*} PRODUCES X = 1./\ A
% A \\ B \\ C 2./\ B
% \end{conj*}$ 3./\ C
%
% If X is defined in this way, then X.2 denotes the formula B.
%
% The disj and disj* environments are similar. Disjuncts
% are numbered a, b, c
%
% These environments are implemented with the array environment.
% They should nest properly. They can be used only in math mode.
%
%
% 9. SPACING
%
% The vertical spacing of each level of a proof is specified
% by three parameters:
%
% Before Proof Space: The vertical space added above the proof
% environment, where the \begin{proof} appears.
%
% After Proof Space: The vertical space added below the proof
% environment, where the \end{proof} appears
%
% Inter-Step Space: If a step is preceded by another step, without
% an intervening proof, then this is the amount of space added
% above that step's \step or \qedstep command.
%
% The following three commands specify the amounts of these three spaces
% for each level of proof, where the outermost level (the \begin{proof}
% command that starts the proof) is level 1:
%
% \beforePfSpace
% \afterPfSpace
% \interStepSpace
%
% The argument of each of these commands is a comma-separated list of
% lengths. For example,
%
% \afterPfSpace{10pt, 5pt, 2pt}
%
% specifies that the After Proof Space for the level-1 proof is 10pt,
% for the level-2 proof is 5pt, and for all levels from 3 on is 2pt.
% The proofs at several levels can end at the same point in the document.
% In other words, several \end{proof} commands can follow one another
% with no intervening \step or \qedstep command. In that case, the
% After Proof Space is that of the outermost (lowest level) proof.
%
% 10. WRITING TWO VERSIONS OF A PROOF
%
% A proof* environment specifies both a MAIN version and a SHORT
% version of a proof, as follows:
%
% \begin{proof*}
% The short version
% \mainproof
% The long version.
% \end{proof*}
%
% The declarations \usemainproofs (the default) and \useshortproofs
% determine which proof is used. You can't nest one proof* environment
% inside another.
%
% 11. MISCELLANY
%
% \pfhidelevel : A counter that controls what levels of proof
% are shown. The command \pfhidelevel{2} causes
% only level-1 and level-2 steps to be printed, and the proofs
% of level-2 steps (including all level-3 and higher steps)
% to be omitted. The default value of the counter is very large.
% The value of the counter should be non-negative.
% You cannot use a \pfhidelevel command inside a proof
% environment.
%
% \unhideqedproof
% \hideqedproof : Used in conjunction with the pfhidelevel counter.
% The \unhideqedproof command causes one extra level of proof
% to be displayed for the lowest level \qedstep. The \hideqedproof
% returns to the default of not showing this extra level.
%
% \pflet : Like \case, but with keyword "Let".
% \define : Like \case, but with keyword "Define"
% These two commands can be used inside or outside a proof step
% to introduce definitions local to the current level of proof.
%
% \pfdot : Defines the "." in long step numbers. Try
% \renewcommand{\pfdot}{\mbox{$\cdot$}} for variety.
%
% \pfindent : The amount by which proof levels are indented in
% the short indent option. Changed with \setlength.
% This is a local declaration.
%
% \pflabel{nm}
% \pfref{nm}
% These are like \label and \ref, except for proof-step names. The
% \label command refers to the most recent \step or \nostep command at
% the same proof level. The \pfref command produces the same step name
% as the \step command (or as a \step command replacing the \nostep
% command would). The name nm must be globally unique (among step-label
% references).
%
% \pflonglabel{nm}
% Like \pflabel{nm}, except the corresponding \pfref produces
% a long step number, regardless of whether the \step command
% produces a long or short number.
%
%% THE FOLLOWING ARE OBSOLETE BUT ARE MAINTAINED FOR
%% BACKWARDS COMPATIBILITY
% \pfstepnumber{LEVEL}{NUMBER}{LONGNUMBER} :
% Generates either <LEVEL>NUMBER or LONGNUMBER, depending
% on the numbering style in effect.
%
% \pflevelnumber{LEVEL}{LONGNUMBER} :
% Generates either <LEVEL> or LONGNUMBER, depending
% on the numbering style in effect.
%
% \pf, \qed, \pfsketch : Described above.
%
% \pick : Simply produces the Pick keyword.
% \pfnew : Simply produces the New keyword.
%
% \pfkeywords{STYLE} :
% Chooses the style of keywords like "Assume" and "Proof".
% There are currently two choices for style:
% default : Produces things like \textsc{Assume:}
% tla : Copies the standard TLA+ pretty-printing conventions,
% such as \textsc{assume}.
% You can set how each keyword is printed by redefining the command
% that produces the keyword. For example, the \assumePfkwd produces
% the "Assume" keyword. Here are all the commands:
% \assumePfkwd \provePfkwd \proofPfkwd \pickPfkwd
% \sufficesPfkwd \definePfkwd \proofsketchPfkwd
% \casePfkwd \letPfkwd
% \asufficesPfkwd - The "Suffices" that precedes an "Assume"
% \qedPfkwd - produced by the \qed command
% \qedstepPfkwd - produced by the \qedstep command
%
%
% 12. LIST OF ALL COMMANDS AND ENVIRONMENTS
%
% Text-Producting Commands Environments
% \pf, \pfsketch proof
% \qed noproof
% \step conj, conj*
% \nostep disj, disj*
% \qedstep pfenum, pfenum*
% \assume proof* \mainproof
% \prove
% \suffices
% \pflet
% \define
% \case
% \pfdot ["." in long names]
% \stepref, \levelref, \toplevel
% \pfstepnumber, \pflevelnumber
% \pfref -- with \pflabel and \pflonglabel
% \sassume
% \pick
% \pfnew
%
% Declarations
% \pfshortnumbers
% \pflongnumbers
% \pfmixednumbers
% \pfsidenumbers, \pfnosidenumbers
% \pflongindent, \pfshortindent
% \pfindent
% \beforePfSpace
% \afterPfSpace
% \interStepSpace
% \usemainproofs
% \useshortproofs
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% HORIZONTAL SPACING %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% COMMANDS
% \pflongindent == Indent proofs to full width of item label
% \pfshortindent == Indent proofs by \pfindent [the default]
% \pfindent == indentation at beginning of a proof
\newif\if@pfLongIndent % true if indent proof to width of label.
\@pfLongIndentfalse
\newcommand{\pflongindent}{\@pfLongIndenttrue}
\newcommand{\pfshortindent}{\@pfLongIndentfalse}
\newlength{\pfindent}
\setlength{\pfindent}{1em}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% VERTICAL SPACING %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% COMMANDS
% \beforePfSpace
% \afterPfSpace
% \interStepSpace
% OLD PARAMETERS
% \pftopsep == space above first proof environment
% \pfbotsep == space below first proof environment
% \pfsep == space above and below inner proof environment
% \stepsep == space above and below proof step
% \afterfpsep == space below inner proof environment
% \newlength{\pftopsep}
% \newlength{\pfbotsep}
% \newlength{\pfsep}
% \newlength{\stepsep}
% \newlength{\afterpfsep}
% \setlength{\pftopsep}{1ex} % space above first proof environment
% \setlength{\pfbotsep}{1ex} % space below first proof environment
% \setlength{\pfsep}{0pt} % space above and below inner proof environment
% \setlength{\stepsep}{0pt} % space above and below proof step
% \setlength{\afterpfsep}{0pt} % space above and below inner proof environment
%%%%%%%%%%%%%%%%%%%%%%%%%%%% \@setvectorlength %%%%%%%%%%%%%%%%%%%%%%%%%%
% The following command is used to implement spacing defined by
% \beforePfSpace, \afterPfSpace, and \interStepSpace.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \@setvectorlength{\lenvec}{n}{\len} :
% If * \lenvec is defined by \newcommand{\lenvec}{l_1, ..., l_k},
% where k > 0 and each l_i is a length
% * \len is declared by \newlength{\len}
% * n is an integer > 0
% then this command sets \len to:
% * l_n if n \leq k
% * l_k if n > k
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcounter{@vectorctr}
\def\@eltend{\relax}
\newlength{\@veclen}
\newcommand{\@setvectorlength}[3]{%
\expandafter\@setveclen\expandafter{#1}{#2}{#3}}
\newcommand{\@setveclen}[3]{%
\setlength{\@veclen}{0pt}%
\setcounter{@vectorctr}{#2}%
\@nextlen#1,\relax,%
\setlength{#3}{\@veclen}%
}
\def\@nextlen#1,{%
\def\@thisvectorelt{#1}%
\ifx\@thisvectorelt\@eltend\let\@donext\relax%
\else \setlength{\@veclen}{#1}%
\expandafter\ifnum1=\value{@vectorctr}\let\@donext\@gobblelen
\else \addtocounter{@vectorctr}{-1}%
\let\@donext\@nextlen
\fi
\fi\@donext}
\def\@gobblelen#1,{%
\def\@thisvectorelt{#1}%
\ifx\@thisvectorelt\@eltend\let\@donext\relax
\else \let\@donext\@gobblelen
\fi\@donext}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The commands \beforePfSpace simply defines \@beforePfSpace,
% and similarly for \afterPfSpace and \interPfSpace. They are
% initialized to make all spaces 0 except for the space around
% the outermost proof environment
%
\newcommand{\beforePfSpace}[1]{\def\@beforePfSpace{#1}}
\newcommand{\afterPfSpace}[1]{\def\@afterPfSpace{#1}}
\newcommand{\interStepSpace}[1]{\def\@interStepSpace{#1}}
\beforePfSpace{1ex,0pt}
\afterPfSpace{1ex,0pt}
\interStepSpace{0pt}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The following macro isn't used, but I put it here in case
% I need it some day.
%
% \@vectorelement{v_1, v_2, ... , v_k}{n}
% Expands to: nothing if k = 0
% v_n if n \leq k
% v_k if n > k or n < 1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \newcommand{\@vectorelement}[2]{%
% \def\@vecdefault{}%
% \setcounter{@vectorctr}{#2}
% \@nextvector#1,\relax,%
% }
%
% \def\@nextvector#1,{%
% \def\@thisvectorelt{#1}%
% \ifx\@thisvectorelt\@eltend\def\@donext{\@vecdefault}%
% \else \def\@vecdefault{#1}%
% \expandafter\ifnum1=\value{@vectorctr}\let\@donext\gobblevec
% \else \addtocounter{@vectorctr}{-1}%
% \let\@donext\@nextvector
% \fi
% \fi\@donext}
%
% \def\@gobblevec#1,{%
% \def\@thisvectorelt{#1}%
% \ifx\@thisvectorelt\@eltend\def\@donext{\@vecdefault}%
% \else \let\@donext\@gobblevec
% \fi\@donext}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% PROOF HIDING %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% pfhidelevel == counter, specifying level at which proofs are hidden.
\newbox{\pfbox}
\newcounter{pfhidelevel}
\setcounter{pfhidelevel}{9999}
\newcommand{\pfhidelevel}[1]{\ifnum\pfLevelCount>\z@
\@latex@error{You can't use \string\pfhidelevel\space
in a `proof' environment}{}%
\else\setcounter{pfhidelevel}{#1}\fi}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% STEP NUMBERING %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% COMMANDS
% \pfshortnumbers == Use only short step numbers (the default)
% \pflongnumbers == Use only long step numbers.
% \pfmixednumbers{N} == Use long step numbers for all levels < N,
% and short step numbers for all levels >= N
%
% \pfsidenumbers{N}{D} == print side numbers for proof steps of all
% levels >= N, left-aligned length D
% to left of left margin
% \pfnosidenumbers == do not print side numbers (the default)
\newcommand{\pfmixednumbers}[1]{\pfshortNumberLevel=#1\relax}
\newcommand{\pfshortnumbers}{\pfmixednumbers{0}}
\newcommand{\pflongnumbers}{\pfmixednumbers{999}}
\newcount\pfshortNumberLevel \pfshortNumberLevel=0
% \@pfLongNumbersfalse}
% \newif\if@pfLongNumbers % true if indent proof to width of label.
%\@pfLongNumbersfalse
\newcommand{\pfstepnumber}[3]{%
\ifnum \pfLevelCount < \pfshortNumberLevel
#3%
\else $\langle#1\rangle#2$%
\fi}
\newcommand{\pflevelnumber}[2]{%
\ifnum \pfLevelCount < \pfshortNumberLevel
#2%
\else $\langle#1\rangle$%
\fi}
% The \pflabel, \pflonglabel, and \pfref commands. The code for
% these was obtained by modifying the code for the \label and \ref
% commands, without understanding it very well.
%
\newcommand{\pflabel}[1]{%
\ifx\pfStepName\pf@nothing
\@latex@error{There is no proof step to label here..}{}%
\else
\expandafter\@pflabel\pfStepName{#1}\fi}
\newcommand{\pflonglabel}[1]{%
\ifx\pfStepName\pf@nothing
\@latex@error{There is no proof step to label here..}{}%
\else
\expandafter\@pflabel
\expandafter{\expandafter}\expandafter\pfLongStep{#1}\fi}
\newcommand{\pf@nothing}{}
\def\@pflabel#1#2#3{%
\@bsphack \protected@write \@auxout {}{\string \@newl@bel
\string{pfx\string}\string{#3\string}\string{#2\string}}\@esphack}
\newcommand{\pfref}[1]{\expandafter
\@setpfref \csname pfx@#1\endcsname {#1}}
\newcommand{\@setpfref}[2]{\ifx #1\relax \protect \G@refundefinedtrue
\nfss@text {\reset@font \bfseries ??}\@latex@warning
{Proof-step reference `#2' on page \thepage \space undefined}\else #1\fi}
\newif\if@pfSideNumbers % true if putting long numbers at margin
\@pfSideNumbersfalse
\newcounter{pf@sidenumberdepth}
\newlength{\pf@sidenumberoutdent}
\newcommand{\pfsidenumbers}[2]{\@pfSideNumberstrue
\setcounter{pf@sidenumberdepth}{#1}%
\addtocounter{pf@sidenumberdepth}{-1}%
\setlength{\pf@sidenumberoutdent}{#2}}
\newcommand{\pfnosidenumbers}{\@pfSideNumbersfalse}
\newcount\pfLevelCount \pfLevelCount=0 % current level number
\newcount\pfStepCount \pfStepCount=0 % current step number
\newcommand{\pfLongLevel}{} % The long version of current level--e.g., 2.7.5
\newcommand{\pfLongStep}{} % The long version of current step--e.g., 2.7.5.2
\newcommand{\pfStepName}{} % {current level name}{current step name}
% \pfSetName == LongStep := current long step name
% StepName := current step name
\newcommand{\pfSetName}{%
\edef\pfLongStep{%
\ifnum\pfLevelCount>\@ne
\pfLongLevel\pfdot\the\pfStepCount
\else\the\pfStepCount\fi}%
\edef\pfStepName{%
\ifnum \pfLevelCount < \pfshortNumberLevel
{\pfLongStep}{\pfLongStep}%
\else
{$\langle\the\pfLevelCount\rangle$}%
{$\langle\the\pfLevelCount\rangle\the\pfStepCount$}%
\fi}}
% \pfSetRef{foo} == IF \pf@foo UNDEFINED
% THEN \pf@foo := StepName
% ELSE WARNING
\newcommand{\pfSetRef}[1]{%
\@ifundefined{pf@#1}%
{\expandafter
\edef\csname pf@#1\endcsname{\pfStepName}}%
{\typeout{WARNING:
proof step "#1" (<\the\pfLevelCount>\the\pfStepCount)
already defined}}%
}
\newcommand{\pfPrintStepNumber}[2]{#2}
\newcommand{\pfPrintLevelNumber}[2]{#1}
% \stepref{FOO} == Print \pf@FOO as a step number
\newcommand{\stepref}[1]{\@ifundefined{pf@#1}{{\bf ??}\typeout{WARNING:
proof step "#1" undefined}}{\expandafter\expandafter\expandafter
\pfPrintStepNumber\csname pf@#1\endcsname}}
\newcommand{\levelref}[1]{\@ifundefined{pf@#1}{{\bf ??}\typeout{WARNING:
proof step #1 undefined}}%
{\expandafter\expandafter\expandafter
\pfPrintLevelNumber\csname pf@#1\endcsname}}
\newcommand{\toplevel}{\pflevelnumber{0}{0}}
\newlength{\pf@outdent}
\newcommand{\pfSideNumber}{%
\if@pfSideNumbers
\ifnum\pfLevelCount>\value{pf@sidenumberdepth}%
\hspace*{-\pf@outdent}%
\makebox[0pt][l]{\footnotesize\pfLongStep}%
\hspace*{\pf@outdent}%
\else\fi
\else\fi}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% THE pflist ENVIRONMENT %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%% The pflist environment is the same as list environment except
%% it can be nested deeper.
\def\pflist#1#2{\ifnum \@listdepth >15\relax \@toodeep
\else \global\advance\@listdepth\@ne \fi
\rightmargin \z@ \listparindent\z@ \itemindent\z@
\csname @list\romannumeral\the\@listdepth\endcsname
\def\@itemlabel{#1}\let\makelabel\@mklab \@nmbrlistfalse #2\relax
\@trivlist
\parskip\parsep \parindent\listparindent
\advance\linewidth -\rightmargin \advance\linewidth -\leftmargin
\advance\@totalleftmargin \leftmargin
\parshape \@ne \@totalleftmargin \linewidth
\ignorespaces}
\def\endpflist{\global\advance\@listdepth\m@ne
\endtrivlist}
\let\@listvii=\@listv
\let\@listviii=\@listv
\let\@listix=\@listv
\let\@listx=\@listv
\let\@listxi=\@listv
\let\@listxii=\@listv
\let\@listxiii=\@listv
\let\@listxiv=\@listv
\let\@listxv=\@listv
\let\@listxvi=\@listv
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% THE proof ENVIRONMENT %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% The @noproof switch is set globally false by a \begin{proof} or
% \end{proof} and globally true by a \step or \qedstep command
% Thus, at a \step or \qedstep command, it is true iff an
% Inter-step space needs to be added before it.
%
% However, it is set globally true by the end of a proof at level
% \pfhidelevel (so that proof is hidden), so that After Proof Space
% is not added for a proof that is hidden, and Inter Step Space is
% used instead.
%
\newif\if@noproof
\newlength\@temppflen
\newenvironment{proof}{% BEGIN:
\global\@noprooffalse
\edef\pfLongLevel % LongLevel :=
{\ifnum\pfLevelCount>\z@ % IF LevelCount > 0
\ifnum\pfLevelCount>\@ne% THEN IF LevelCount > 1
\pfLongLevel\pfdot\else\fi % THEN LongLevel * "." FI
\the\pfStepCount % * StepCount
\else\fi}% % ELSE FI
\advance\pfLevelCount\@ne % LevelCount := LevelCount + 1
\@tempcnta=\value{pfhidelevel}%
%% The following modified on 25 Sep 2011 to allow pfhidelevel = 0
%% to hide the entire proof. The simple modifications to the original
%% code produced a bug if \unhideqedproof was in effect.
\ifnum\@tempcnta<\@ne
\hideqedproof
\ifnum\@tempcnta<0\relax
\setcounter{pfhidelevel}{0}%
\typeout{WARNING: pfhidelevel < 0, setting to 0}%
\@tempcnta=0\relax
\fi
\fi
\advance\@tempcnta\@ne
\if@qedstep
\advance\@tempcnta\@ne
\ifnum\pfLevelCount
= \@tempcnta
\begin{lrbox}{\pfbox}\begin{minipage}{\textwidth}\fi
\else
\ifnum\pfLevelCount
= \@tempcnta
\begin{lrbox}{\pfbox}\begin{minipage}{\textwidth}\fi\fi
\pfStepCount=\z@ % StepCount := 0
\ifnum\pfLevelCount>\@ne % IF LevelCount > 1
\begin{pflist}{}{% % THEN Begin List with
%% Skip the Before Proof Space
\@setvectorlength{\@beforePfSpace}{\pfLevelCount}{\@temppflen}
\addvspace{\@temppflen}%
\topsep=\z@ % \topsep := 0
\itemsep=\z@ % \itemsep := 0
\parsep=\z@ % \parsep := 0
\partopsep=\z@ % \partopsep := 0
\if@pfLongIndent % IF LongIndent
\settowidth{\leftmargin}%% THEN
{\expandafter % \leftmargin := width of step name
\pfPrintStepNumber % + \labelsep
\pfStepName.}%
\advance\leftmargin
\labelsep
\else % ELSE
\leftmargin=\pfindent % \leftmargin := \pfindent
\fi\relax
} \item[]
\else \par % ELSE \par
%% Skip the Above Proof Space
\@setvectorlength{\@beforePfSpace}{\pfLevelCount}{\@temppflen}
\addvspace{\@temppflen}%
\parindent=\z@ % \parindent := 0
\parskip = \z@ % \parskip := 0
\@ifundefined{mathindent}{%
\abovedisplayskip=\z@ plus .2ex % set display skips
\abovedisplayshortskip=\z@ plus .2ex
\belowdisplayskip=\z@ plus .2ex