-
Notifications
You must be signed in to change notification settings - Fork 1
/
practical-tla9020.html
1618 lines (1365 loc) · 49.7 KB
/
practical-tla9020.html
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
<!DOCTYPE html>
<HTML>
<!-- Mirrored from lamport.azurewebsites.net/tla/practical-tla.html?back-link=learning.html by HTTrack Website Copier/3.x [XR&CO'2014], Thu, 26 Mar 2020 22:34:26 GMT -->
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="GENERATOR" CONTENT="Mozilla/4.05 [en] (X11; I; OSF1 V4.0 alpha)
[Netscape]">
<!--
%&b&<b>#</b>&
%&c& <b>#</b> &
-->
<!-- The following loads the style sheet for the html files of
the tla web site -->
<link rel="stylesheet" type="text/css" href="tlaweb.css">
<!-- FILE SPECIFIC STYLE DECLARATIONS -->
<style type="text/css">
H2 {margin-top:10px;
margin-bottom:5px}
DL {margin-top:-5px;
margin-bottom:-5px}
DT {margin-top:5px;
font-weight:bold}
DD {margin-left:15px}
BLOCKQUOTE {margin-top:0px;
margin-bottom:3px;
margin-left:25px;
font-style:italic}
ul {margin-top:5px}
li {margin-top:5px}
P {margin-top:5px}
</style>
<!--
<DL>
<DT>Page </DT>
<DD>
</DD>
</DL>
<DT>Page </DT>
<DD>
<BLOCKQUOTE>
</BLOCKQUOTE>
</DD>
<BR> <BR>
This is a comment about something else on that page.
 <code></code> 
-->
<script src="tlaweb.js"> </script>
<title>Practical TLA+ by Hillel Wayne</title>
</HEAD>
<BODY onload="initialize()">
<table id="main">
<tr>
<td id="main_leftcolumn" >
</td>
<td id="main_contentcolumn">
<table>
<tr >
<td style="vertical-alight:top">
<div id = "showleftcol"> </div>
<H1><i>Practical TLA+</i>  by Hillel Wayne</H1>
<p style="margin-top:-8px; margin-bottom:-18px">
Leslie Lamport<p style="margin-top:15px">
<font size=-1><I> Last modified on 23 November 2018</I></font>
</td>
<td style="vertical-alight:top;width:auto">
</td>
</tr>
</table>
<HR style="margin-bottom:-5px;margin-top:-11px">
<P style="margin-top:0px"> </P>
<DIV class="hidden-div" style="color:red;margin-bottom:-12px"><b>
You'll miss a lot on this web site unless you enable Javascript
in your browser. </b></DIV>
<DIV>
<H2 id="h2intro" class="show-hide" onclick="showHide('hide-intro','intro')">
The Book
<font id="hide-intro" > [show]</font>
</H2>
<DIV id="intro" class = "hidden-div">
<i>Practial TLA+</i> is a book by Hillel Wayne,
<a
href="https://www.apress.com/de/book/9781484238288">available
from the publisher</a>.
<p style="margin-top:10px">
It provides a good complete course on the PlusCal algorithm
language.
This web page describes a number of minor problems in the book,
including hard to understand statements and small errors.
It also explains why I disagree with a few things the book says.
I want to emphasize that the issues listed here
are small problems in an excellent book.
</DIV>
<H2 id="h2general"
class="show-hide" onclick="showHide('hide-general','general')">
General Remarks
<font id="hide-general" > [show]</font>
</H2>
<DIV id="general" class = "hidden-div">
<h3 style="margin-top:5px">The P Syntax</h3>
PlusCal has two syntaxes: the P syntax inspired by Niklaus Wirth's Pascal
programming language, and the C syntax inspired by the programming language
C.
The book uses the P syntax.
That's the syntax I would prefer if I wrote algorithms only
for my own use and never wrote programs.
Most engineers and programmers will prefer the C syntax, which will look
more familiar to them, so I've used it for all my published algorithms.
You should compare the PlusCal manual's <A HREF = p-manual.pdf>P-Version</A>
and <A HREF = c-manual.pdf>C-Version</A> to see which you prefer.
It should be easy to become bi-syntactic, translating the book's
P syntax to C syntax.
<h3>Copying the Code</h3>
The source files for the specs in the book are available on line.
However, those are the final versions. If you want to follow the
development of the spec in your Toolbox, you'll have to copy the
pieces of the spec from the book. Unfortunately, that removes all
indenting, which makes the result unreadable.
You can try to find the bits of code being added at each step
in the complete spec and copy them from there. It would be nice if
all the code snippets in the book were available in an ascii file,
identified by page and line numbers.
<h3>Possible Typos in the Code</h3>
I noticed one typo in the code in the book (on page 161, Chapter 10).
It probably occurred in copying text from the PlusCal source file to
the book's source file. I didn't read the code carefully, and
there could be more such errors. If some code in the
book doesn't look right, you should try it yourself to see if the
problem is in your understanding or is a typo in the book.
</DIV>
<H2 id="h2title"
class="show-hide" onclick="showHide('hide-title','title')">The Title
<font id="hide-title" > [show]</font>
</H2>
<DIV id="title" class = "hidden-div">
This book is about
<A href="high-level-view.html#plucal?unhideBut=hide-pluscal&unhideDiv=pluscal&back-link=practical-tla.html#title?unhideBut@EQhide-title@AMPunhideDiv@EQtitle">PlusCal</a>, not about TLA+.
It describes all the TLA+ operators for writing ordinary mathematical
expressions and says a little about expressing liveness properties
with TLA+'s temporal operators. However, it doesn't mention some
of the most important features of TLA+, including the ability to state
and check that one specification implements a higher-level
specification. After reading this book, you should find it easy
to learn TLA+. I recommend that you do so. While reading
the book, you might want to look at the TLA+ translation of the
PlusCal specs.
</DIV>
<H2 id="h2intro-section" class="show-hide"
onclick="showHide('hide-features','intro-sec')">
Introduction
<font id="hide-intro-sec" > [show]</font>
</H2>
<DIV id="intro-sec" class = "hidden-div">
<DL>
<!--
<DT> Page xvii</DT>
<DD> This is where I put text describing a problem on this page.
</DD>
-->
<DT> Page xix</DT>
<DD> <blockquote>Without having something to program with, there's really no reason to
use TLA+.
</blockquote>
Wrong!
Here are potential users of TLA+ who don't do any programming.
<ul>
<li> People who need to express precisely what a system or program
should do, including customers hiring someone else to build the
system or software engineers describing a system for others to
build. </li>
<li> Computer scientists who design algorithms, but don't write programs
to implement them. I believe I have written only one concurrent
program in my life, which was used by me and a few other people
for a couple of years in the mid-1980s.
</li>
</ul>
</DL>
</DIV>
<H2 id="h2chap1"
class="show-hide" onclick="showHide('hide-chap1','chap1')">Chapter 1
<font id="hide-chap1" > [show]</font>
</H2>
<DIV id="chap1" class = "hidden-div">
<DL>
<DT>Page 7, line 16</DT>
<DD> <blockquote>
which is closer to what we normally think of programming functions
</blockquote>
This should be something like:
<q>which is closer to what we normally think of in programming as
functions</q>.
</DD>
<DT>Page 14</DT>
<DD>
The text should mention that a state is an assignment of values to variables,
and there is a non-declared variable pc added by the PlusCal to TLA+
translation.
</DD>
<DT>Page 18, line 5</DT>
<DD>
<BLOCKQUOTE>
Every following state highlights with variables that have changed
from the previous state.
</BLOCKQUOTE>
Better would be:
<q>Every following state highlights with red the variables that have
changed from the previous state.</q>
</DD>
<DT>Page 22, line 1</DT>
<DD>
<BLOCKQUOTE>
Unfortunately, there are no good options.
</BLOCKQUOTE>
This is not accurate. In particular, the objection of bullet two is
misleading. First of all, it is impossible to write in TLA+ that the
process can't stutter between the withdrawal and deposit.
(You can understand the book without knowing this,
but if you're curious you can look
<A name = "anchor" href =
"advancedee39.html?unhideBut=hide-stuttering&unhideDiv=stuttering&back-link=practical-tla.html#anchor?unhideBut@EQhide-chap1@AMPunhideDiv@EQchap1"
>here</A>
to find out why not.)
The correct statement is that,
by adding the keyword
 <code>fair</code> 
in front of
 <code>process</code> 
in the code, we can specify that the process doesn't stop until it's
gotten to the end.
<p style="margin-top:10px">
The fact that <q>there's no way to implement it</q> is
irrelevant. It's impossible to implement the safety part of the
spec because a cosmic ray could hit the computer and cause it to do
something not allowed by the spec. Verifying a property shows
that if a behavior satisfies the spec, then it satisfies the
property. This may or may not be useful. Many specs people
write are not implementable--for example, they may contain unbounded
queues, or variables whose value can be an arbitrary integer. It
requires engineering judgment to know whether or not the inability to
implement those things makes it useless to know that the spec
satisfies some property. It's useful to know that the spec with
the fairness assumption satisfies
 <code>EventuallyConsistent</code> .
That's because there would be something seriously wrong with the spec
if fairness didn't imply
 <code>EventuallyConsistent</code> .
<p style="margin-top:10px">
This is not the right place to discuss fairness and
liveness, and that discussion is deferred to Chapter 6 of the book.
However, it would be useful point to that discussion. I think
something like the following belongs here:
<BLOCKQUOTE style="font-style:normal;margin-top:-10px;margin-bottom:10px">
For now, the PlusCal specs we write allow processes to stop
at any time. They therefore describe what a system is allowed
to do, but not what it must do. Chapter 6 explains how we
write specs that specify what must happen.
</BLOCKQUOTE>
</DD>
</DL>
</DIV>
<H2 id="h2chap2"
class="show-hide" onclick="showHide('hide-chap2','chap2')">Chapter 2
<font id="hide-chap2" > [show]</font>
</H2>
<DIV id="chap2" class = "hidden-div">
<DL>
<DT>Page 24, line 3</DT>
<DD>
<BLOCKQUOTE>
This is for backwards compatibility reasons.
</BLOCKQUOTE>
I don't know with what this is supposed to be backwards compatible.
</DD>
<DT>Page 24, line 9</DT>
<DD>
It would be a good idea for item (4) to mention that comments can be
nested to arbitrary depth, since, for some unfathomable reason, that's
not true of most programming languages.
</DD>
<DT>Page 24, lines -5 to -1</DT>
<DD>
This paragraph should refer to the tip on the following page,
which explains how to evaluate expressions
without running the entire spec.
</DD>
<DT>Page 26, lines -10 to -1</DT>
<DD>
In the  <b>= VS :=</b>  section,
I don't like the explanation of
 <code>=</code> 
in the variable declaration as an
initial assignment.
It would be better
to say that a variable's declaration includes its initial value (as an
optional part).
<p style="margin-top:10px">
Also, this would be a good point to introduce the distinction between
legal PlusCal specs and ones that TLC can handle. For example,
this is perfectly legal PlusCal:
<pre>
variables z = (x=y), x = 2, y = 2;
</pre>
The TLAPlus proof system treats it exactly the same as
<pre>
variables x = 2, y = 2, z = (x=y);
</pre>
It's just TLC that can't handle the first.
</DD>
<DT>Page 27, line 3</DT>
<DD>
In introducing the
 <code>..</code> 
operator, it should be mentioned
that
 <code>3..1</code> 
equals
 <code>{}</code>  (the empty set).
</DD>
<DT>Page 27, line 10</DT>
<DD>
<BLOCKQUOTE>
All elements in the set must have the same type
</BLOCKQUOTE>
This is inaccurate. First,
 <code>{"a", 1}</code> 
is a legal PlusCal expression; it's TLC that can't deal with it.
Second, being of the same type is a sufficient but not necessary
condition for TLC to be able to deal with an expression. For example,
it has no trouble with
<pre>
{{1}, {"a", "b"}}
</pre>
It's usually the case that TLC cannot handle sets containing
elements of different types. However, there's one important
exception: sets of structures. (Structures are introduced on
page 29.) TLC can handle sets of structures whose elements
don't all have the same set of keys.
</DD>
<DT>Page 29, Note</DT>
<DD>
Mathematically, a structure is a function whose
domain is a set of strings, and a sequence is a function whose domain
is a set of integers. I doubt if many people would say that these
kinds of functions have the same type. It would be better to say that
structures and sequences are both instances of a more general class of
values called functions.
</DD>
<DT>Page 31, line 11</DT>
<DD>
<BLOCKQUOTE>
For example, the following is a spec error:
</BLOCKQUOTE>
This does not mean that the following is incorrect
PlusCal code. It means that an execution of the
spec evaluates the assert statement with
 <code>x</code> 
equal to
 <code>FALSE</code> , generating an
assertion failure.
<p style="margin-top:10px">
Formally, a spec is a definition, and a definition can be incorrect
only if it is syntactically illegal. Informally, a definition is
called incorrect if it doesn't define what we think it should.
</DD>
<DT>Page 32ff</DT>
<DD>
In the example, the variable curr can be eliminated by updating
 <code>items</code> 
at the end of the <b>while</b> loop and replacing occurrences of
 <code>curr</code> 
by
 <code>Head(items)</code> .
</DD>
</DL>
</DIV>
<H2 id="h2chap3"
class="show-hide" onclick="showHide('hide-chap3','chap3')">Chapter 3
<font id="hide-chap3" > [show]</font>
</H2>
<DIV id="chap3" class = "hidden-div">
<DL>
<DT>Page 44, line 3</DT>
<DD>
<BLOCKQUOTE>
The TLA+ does not use semicolons; only the PlusCal computations
need semicolons.
</BLOCKQUOTE>
This should be:
<BLOCKQUOTE style="font-style:normal;margin-bottom:10px">
TLA+ does not use semicolons; only the PlusCal code
that gets translated to TLA+ uses semicolons.
</BLOCKQUOTE>
</DD>
<DT>Page 45, line 15</DT>
<DD>
<BLOCKQUOTE>
<code>>> Apply(Add, 1, 2)</code>
</BLOCKQUOTE>
You can also write this as
 <code>Apply(+, 1, 2)</code> ;
there's no need to define
 <code>Add</code>  or use a
 <code>LAMBDA</code>  expression.
</DD>
<DT>Page 46, line 7</DT>
<DD>
<BLOCKQUOTE>
Not all models you write will check all invariants.
You have to specify what you actually care about.
</BLOCKQUOTE>
I believe this means that an invariant is just a formula,
and a spec can define lots of formulas.
TLC has no way of knowing by itself which of those formulas are
supposed to be invariants; you have to tell it in the model.
</DD>
<DT>Page 47, line 2</DT>
<DD>
<BLOCKQUOTE>
However, creating dedicated operators is cleaner and better signals
your intent to anybody else who reads your spec.
</BLOCKQUOTE>
Defining an operator signals to the reader that the operator is
supposed to be an invariant only if you write in a comment that it's
supposed to be one.
</DD>
<DT>Page 48 and elsewhere</DT>
<DD>
I believe that the quantifiers  <code>\A</code>  and
 <code>\E</code>  are the first TLA+ operators described
so far that declare bound identifiers—for example, the formula
<pre>
\A num \in set: num < max
</pre>
declares the bound identifier  <code>num</code> 
in the scope of the subformula
 <code>num < max</code> .
It should be mentioned that in TLA+, it is illegal to
give a meaning to an identifier that already has a meaning.
Thus, the formula above would be illegal if  <code>num</code> 
had already been defined.
This means that the formula
<pre>
\A x \in S : (... /\ \E x \in T : ...)
</pre>
is illegal because the inner
 <code>\E</code>  assigns a meaning to
 <code>x</code>  in a context
(the outer  <code>\A x</code> )
in which  <code>x</code>  already has a meaning. Note that
<pre>
P == \E x \in T : ...
Q == \A x \in S : (... /\ P)
</pre>
is legal because the use of
 <code>x</code>  inside the
definition of
 <code>P</code>  doesn't
<q>leak out of</q> that definition. The rule that
you can't assign a meaning to an identifier that already has a meaning also
makes this illegal
<pre>
VARIABLE x
...
P(x) == ...
</pre>
This is also illegal:
<pre>
\E x \in S : 2*x \in {x \in Nat : ... }
</pre>
It should be mentioned that the scope of
 <code>\A</code>  and  <code>\E</code> 
extends
<q>as far as possible</q>. For example, this is illegal
<pre>
\A x \in S : x > 1
=>
\E x \in T : x < 23
</pre>
because it's parsed as
<pre>
\A x in S : (x > 1 => \E x \in T : x < 23)
</pre>
The following is legal
<pre>
(\A x \in S : x > 1) => \E x \in T : x < 23
</pre>
as is
<pre>
/\ \A x \in S : x > 1
/\ \E x \in T : x < 23
</pre>
Extending <q>as far as possible</q> applies to other TLA+ constructs signaled
by a prefix.
</DD>
<DT>Page 49, line 11</DT>
<DD>
<BLOCKQUOTE>
<code style="font-style:normal">\A <<x, y>> \in S \X S:
Op(x, y) = Op(y, x)</code>
</BLOCKQUOTE>
Please don't use quantifiers over tuples like this. I think it was a
mistake to allow them in TLA+ because it adds a bit of complexity
for something that's seldom useful. That construct
isn't supported by the TLA+ prover, and probably won't be supported by
new tools. Some day, I expect it no longer to be accepted by the
parser.
</DD>
<DT>Page 49, line 17</DT>
<DD>
People are often confused because
 <code>P => Q</code> 
is not really equivalent
to the informal use of the phrase <q>if P then Q</q>.
The informal phrase means that
 <code>P</code> 
being true causes
 <code>Q</code> 
to be true, while
 <code>P => Q</code> 
does not imply causality.
</DD>
<DT>Page 51, line 15</DT>
<DD>
<BLOCKQUOTE>
make sure your statements are mutually exclusive
</BLOCKQUOTE>
If you make all the cases mutually exclusive, there's little
difference between a CASE and a sequence of nested IF/THEN/ELSEs. One
reason for having a CASE statement is to emphasize symmetry that is
hidden by an IF/THEN/ELSE. For example, compare
<pre>
AbsoluteValue(x) == CASE x >= 0 -> x [] x =< 0 -> -x
</pre>
with the equivalent IF/THEN/ELSE.
</DD>
<DT>Page 53, line -7</DT>
<DD>
<BLOCKQUOTE>
This has five states, three of which are distinct.
</BLOCKQUOTE>
This presumably means that TLC reports finding five states, three
of which are distinct.
</DD>
<DT>Page 53, line -7</DT>
<DD>
<BLOCKQUOTE>
On execution, TLC will set one of the flags to true while
leaving the other false.
</BLOCKQUOTE>
I don't know what this means and I advise not trying to
figure it out. You shouldn't think of TLC setting variables to
values. TLC conceptually computes all possible executions of the
spec, where an execution is a sequence of states and a state is
defined by the values of all the spec's variables. In the course of
computing all executions, TLC computes all reachable states.
</DD>
<DT>Page 53, line -4</DT>
<DD>
<BLOCKQUOTE>
You can make a function as an operator. If the operator doesn't
take any arguments, ...
</BLOCKQUOTE>
This means that, since a function is an ordinary value, you can
define an operator to equal a function. If the operator takes no
arguments, you can use the special syntax
<pre>
Op[x \in S] == ...
</pre>
for the definition. As is suggested by the example on the next
page, this special syntax can be used for recursive definitions.
If the ordinary syntax is used, a recursive function definition must
be preceded by a  <code>RECURSIVE</code>  statement.
</DD>
<DT>Pages 55 and 56 </DT>
<DD>
It should be mentioned that TLC uses the operators
 <code>@@</code>  and  <code>:></code> 
to represent functions that aren't sequences or records.
</DD>
<DT>Page 57, line -9</DT>
<DD>
The example has an unnecessary bit of complexity. The knapsack
problem is stated as fitting any number of each item into the
knapsack. Since two different items can have the same size and value,
the knapsack problem remains the same if each item appears in the
knapsack at most once. A knapsack then just becomes a set of items,
not a function from items to natural numbers.
</DD>
</DL>
</DIV>
<H2 id="h2chap4"
class="show-hide" onclick="showHide('hide-chap4','chap4')">Chapter 4
<font id="hide-chap4" > [show]</font>
</H2>
<DIV id="chap4" class = "hidden-div">
<DL>
<DT>Page 68, line 4</DT>
<DD>
<BLOCKQUOTE>
In general it is safe.
</BLOCKQUOTE>
<q>In general</q> here means <q>usually</q>.
The most common case in which it's not safe to use a symmetry set
is when your spec uses the  <code>CHOOSE</code> 
operator. Read the Toolbox's help page titled
<i>Model Values and Symmetry</i> to find out precisely
when you can use a symmetry set.
</DD>
<DT>Page 68, line -9</DT>
<DD>
<BLOCKQUOTE>
In 99% of the cases you work with, you want finite sets.
</BLOCKQUOTE>
Here, <q>work with</q> probably means <q>define to be CONSTANTS</q>.
It's not that uncommon to use infinite sets like
 <code>Nat</code> 
in a spec.
</DD>
<DT>Page 68, line -5</DT>
<DD>
<BLOCKQUOTE>
We could also EXTEND Naturals to get the set Nat
</BLOCKQUOTE>
<code>Nat</code> 
is also defined in the
 <code>Integers</code>  module;
but
 <code>Int</code> 
is not defined in the
 <code>Naturals</code> 
module. Very rarely will there be any reason to
 <code>EXTEND</code> 
 <code>Naturals</code> 
instead of
 <code>Integers</code> .
</DD>
<DT>Page 73, line -5ff</DT>
<DD>
As the example shows, strings in TLA+ are defined to be sequences of
characters, though the only way to refer to the character
 <code>a</code> 
is with
an expression like
 <code>"abc"[1]</code>  .
However, TLC cannot evaluate that expression.
The only operations on sequences that TLC can evaluate on strings are
 <code>\o</code> ,  <code>Tail</code> ,
and  <code>Len</code> .
</DD>
<DT>Page 75, line 4</DT>
<DD>
The section on  <code>EXTENDS</code>  should say that
the  <code>EXTENDS</code>  statement must be
the first statement in the module. (It can be preceded only by
comments.)
</DD>
<DT>Page 75, line 5</DT>
<DD>
<BLOCKQUOTE>
The module may not have any constants.
</BLOCKQUOTE>
That's not true.
Declared  <code>CONSTANTS</code>  can be
imported by
 <code>EXTENDS</code> 
just like defined operators.
</DD>
</DL>
</DIV>
<H2 id="h2chap5"
class="show-hide" onclick="showHide('hide-chap5','chap5')">Chapter 5
<font id="hide-chap5" > [show]</font>
</H2>
<DIV id="chap5" class = "hidden-div">
<DL>
<DT>Page 80, line 1</DT>
<DD>
It should be noted that the variable  <code>pc</code>  is
not created if each process has the form
<pre>
process ...
begin label: while TRUE do ... end while ;
end process
</pre>
and there are no other labels and no
 <code>goto</code> 
statement in the code. This
kind of spec is often written for distributed algorithms.
</DD>
</DL>
</DIV>
<H2 id="h2chap6"
class="show-hide" onclick="showHide('hide-chap6','chap6')">Chapter 6
<font id="hide-chap6" > [show]</font>
</H2>
<DIV id="chap6" class = "hidden-div">
<DL>
<DT>Page 99, line -4</DT>
<DD>
<BLOCKQUOTE>
Most temporal properties, though, are what's called liveness checks.
</BLOCKQUOTE>
In my experience, the temporal properties engineers check most often
are invariance properties. Perhaps they are not considered here
to be temporal properties because they are usually not written as
temporal formulas when entered in a TLC model to be checked.
</DD>
<DT>Page 101, line 16</DT>
<DD>
<BLOCKQUOTE>
For label
 <code style="font-style:normal">A:</code> 
in an unfair process, writing
 <code style="font-style:normal">A:+</code> 
will make it weakly fair.
</BLOCKQUOTE>
This is incorrect. To make some actions weakly fair, you have to
write
 <code>fair process</code> 
and write
 <code>label:-</code> 
for each action
 <code>label</code> 
that you don't want to be weakly fair. Writing
 <code>label:+</code> 
in a
 <code>fair process</code> 
makes action
 <code>label</code> 
strongly fair. Modifying labels with
 <code>+</code> 
and
 <code>-</code> 
in this way allows you to declare some actions unfair,
some weakly fair, and some strongly fair.
</DD>
<DT>Page 101, line -9</DT>
<DD>
<BLOCKQUOTE>
You can also make the spec globally fair by writing
 <code style="font-style:normal">--fair algorithm</code> 
instead of
 <code style="font-style:normal">--algorithm</code> 
</BLOCKQUOTE>
Note that this is not always equivalent to making each process fair.
</DD>
<DT>Page 101, line -2</DT>
<DD>
<BLOCKQUOTE>
TLC uses a much faster algorithm to evaluate invariants.
</BLOCKQUOTE>
It should be noted that TLC uses this faster algorithm no matter which
way you declare the invariant.
</DD>
<DT>Page 102, line 16</DT>
<DD>
<BLOCKQUOTE>
The current version of TLC cannot check set membership of a variable
set as part of a property with
 <code style="font-style:normal"><></code> .
So you can't write...
</BLOCKQUOTE>
This is false. (I don't remember TLC ever having this limitation.)
</DD>
<DT>Page 102, line -7</DT>
<DD>
<BLOCKQUOTE>
 <code style="font-style:normal">P ~> Q</code> 
means that if there is some state where
 <code style="font-style:normal">P</code> 
is true, then either
 <code style="font-style:normal">Q</code> 
is true either now or in some future state.
</BLOCKQUOTE>
This can be more clearly stated as:
<BLOCKQUOTE style="font-style:normal">
 <code>P ~> Q</code> 
means that for any state in which
 <code style="font-style:normal">P</code> 
is true,
 <code style="font-style:normal">Q</code> 
must be true in that state or in some later state.
</BLOCKQUOTE>
It should also be noted that
 <code>P ~> Q</code> 
is defined to equal
 <code>[](P => <>Q)</code> .
</DD>
<DT>Page 103, line 14</DT>
<DD>
<BLOCKQUOTE>
For a finite spec, these mean the same thing...
</BLOCKQUOTE>
</DD>
Here, <q>finite spec</q> and <q>infinite spec</q> mean
<q>terminating spec</q> and <q>nonterminating spec</q>, respectively.
<DT>Page 103, line -2</DT>
<DD>
<BLOCKQUOTE>
As with
 <code style="font-style:normal"><></code> ,
TLC cannot check set membership of a variable set
as part of a property with
 <code style="font-style:normal"><>[]</code> ,
or
 <code style="font-style:normal">[]<></code> .
</BLOCKQUOTE>
As with  <code style="font-style:normal"><></code> ,
this statement is false.
</DD>
<DT>Page 104, line 10</DT>
<DD>
<BLOCKQUOTE>
TLC uses a different algorithm for this, which is slower and
is not parallelizable.
</BLOCKQUOTE>
This is true now, but we hope to enhance TLC to use a parallel
liveness checking algorithm. However, checking liveness will always
be slower than checking safety.
</DD>
<DT>Page 105, libe -8</DT>
<DD>
<BLOCKQUOTE>
Since this is best represented by a check on pc, we need to
place this after the PlusCal translation.
</BLOCKQUOTE>
It could instead go in the algorithm's
 <code>define</code>  section.