-
-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reviewing the Entry-level Model Checker Tutorial #2017
Comments
Update, I checked |
Many thanks for this deep and thoughtful feedback, @hwayne! From my preliminary skim here, it seems to offer many critical insights on how we can improve -- not just this tutorial, but -- our instructional material more generally. I just wanted to let you know that Igor is currently on well-deserved vacation, so if there's some delay in detailed replies and redress on his side, this is the reason. Those are sure to follow shortly! :) |
I went through this tutorial and wanted to create an issue, but I see that most of the things are already covered here, so I'll just add a couple of points: Step 2: the last snippet misses Step 5: I believe that |
Thanks @not-azat! You are right. We should explain that. In short, normally data structures contain an integer counter that keeps the number of the elements in the data structure. As this counter is an integer, it should not go over |
I was asked by Igor to do a review of the binary search tutorial and provide feedback. First some general thoughts, then specific notes:
First, I do not think the binary search is a good introductory tutorial for Apalache. This is for several reasons:
I raised this with Igor and here's his response:
I'll think a bit more about something that covers (2) and (3) well. In the meantime, specific comments about this example:
https://github.com/informalsystems/apalache/blob/b627481fca3677b15457c704fdd6f8aab66b6d84/docs/src/tutorials/entry-tutorial.md?plain=1#L84-L88 Don’t mention other model checkers if you don’t have to. It’s good to have full disclosure, but better to set up the context that you don’t need to disclose other model checkers at all.
https://github.com/informalsystems/apalache/blob/b627481fca3677b15457c704fdd6f8aab66b6d84/docs/src/tutorials/entry-tutorial.md?plain=1#L98 It's not clear whether the reader is supposed to be typing everything themselves or following along with these files. The tone of the tutorial seems to suggest the first, but there's places where not everything in the file is shown, like the full definition of
Next
. If the reader is supposed to download the files, make that clear from the start.https://github.com/informalsystems/apalache/blob/b627481fca3677b15457c704fdd6f8aab66b6d84/docs/src/tutorials/entry-tutorial.md?plain=1#L114
Emphasize here that the module name must match the filename or else apalache won't check it.
https://github.com/informalsystems/apalache/blob/b627481fca3677b15457c704fdd6f8aab66b6d84/docs/src/tutorials/entry-tutorial.md?plain=1#L121-L125
Also emphasize to the reader that
==
is definition.https://github.com/informalsystems/apalache/blob/b627481fca3677b15457c704fdd6f8aab66b6d84/docs/src/tutorials/entry-tutorial.md?plain=1#L138 This is only for Unix. For Windows, the command is
java -jar path-to-apalache.jar check …
https://github.com/informalsystems/apalache/blob/b627481fca3677b15457c704fdd6f8aab66b6d84/docs/src/tutorials/entry-tutorial.md?plain=1#L141-L142 I agree, it's very hard to know what's important information. Maybe add a
--concise
flag?https://github.com/informalsystems/apalache/blob/b627481fca3677b15457c704fdd6f8aab66b6d84/docs/src/tutorials/entry-tutorial.md?plain=1#L186 This should be "1-indexed".
https://github.com/informalsystems/apalache/blob/b627481fca3677b15457c704fdd6f8aab66b6d84/docs/src/tutorials/entry-tutorial.md?plain=1#L238-L244 This needs to be explained better. Is binary search really a state machine? What does it mean that variables are never “introduced or removed”? Why are you telling me that global variables are easier to reason about?
https://github.com/informalsystems/apalache/blob/b627481fca3677b15457c704fdd6f8aab66b6d84/docs/src/tutorials/entry-tutorial.md?plain=1#L390-L394 Having to create a separate model value file feels really messy, especially considering that you only have one model per spec. Why not just inline that all into
BinSearch
?https://github.com/informalsystems/apalache/blob/b627481fca3677b15457c704fdd6f8aab66b6d84/docs/src/tutorials/entry-tutorial.md?plain=1#L402-L405 I find this confusing.
https://github.com/informalsystems/apalache/blob/b627481fca3677b15457c704fdd6f8aab66b6d84/docs/src/tutorials/entry-tutorial.md?plain=1#L451-L462
I think the property can be simplified to:
https://github.com/informalsystems/apalache/blob/b627481fca3677b15457c704fdd6f8aab66b6d84/docs/src/tutorials/entry-tutorial.md?plain=1#L458 Be careful about local constant: People get confused with how TLA+ constants aren't programming constants, and then this introduces the word "constant" again.
https://github.com/informalsystems/apalache/blob/b627481fca3677b15457c704fdd6f8aab66b6d84/docs/src/tutorials/entry-tutorial.md?plain=1#L482-L483
Where is
counterexample1.tla
coming from? You only tell the reader about the counterexample files later on.https://github.com/informalsystems/apalache/blob/b627481fca3677b15457c704fdd6f8aab66b6d84/docs/src/tutorials/entry-tutorial.md?plain=1#L497 Tell the reader that “disjunction” is the same thing as “or”.
https://github.com/informalsystems/apalache/blob/b627481fca3677b15457c704fdd6f8aab66b6d84/docs/src/tutorials/entry-tutorial.md?plain=1#L604-L615 I'd remove this entire section, or at the very least move it to a footnote.
https://github.com/informalsystems/apalache/blob/b627481fca3677b15457c704fdd6f8aab66b6d84/docs/src/tutorials/entry-tutorial.md?plain=1#L643-L644 There's two improvements here:
--cinit
earlier, possibly as a way to test both 4- and 8-bit integers without having to create separate model files.https://github.com/informalsystems/apalache/blob/b627481fca3677b15457c704fdd6f8aab66b6d84/docs/src/tutorials/entry-tutorial.md?plain=1#L667-L671 I don't understand what this is saying.
https://github.com/informalsystems/apalache/blob/b627481fca3677b15457c704fdd6f8aab66b6d84/docs/src/tutorials/entry-tutorial.md?plain=1#L687
INPUT_KEY \in Int
. Might be easier for people than explaining whatGen(1)
is.MAX_INT
and notMAX_UINT
?https://github.com/informalsystems/apalache/blob/b627481fca3677b15457c704fdd6f8aab66b6d84/docs/src/tutorials/entry-tutorial.md?plain=1#L712-L718 I did not have
counterexample1.tla
. Instead I hadviolation.tla
.https://github.com/informalsystems/apalache/blob/b627481fca3677b15457c704fdd6f8aab66b6d84/docs/src/tutorials/entry-tutorial.md?plain=1#L720 Let the reader know they may not get this exact counterexample.
Also, having to navigate to the folder (different for each execution!) is inconvenient. Is there a more convenient way to find the tool output?
https://github.com/informalsystems/apalache/blob/b627481fca3677b15457c704fdd6f8aab66b6d84/docs/src/tutorials/entry-tutorial.md?plain=1#L758-L759
no-pre
footnote, this is more conceptually an error in the precondition. Saying it's an imprecision in the postcondition confused me for a while. The reason you give for not adding a precondition (testing it terminates on all sequences) doesn't become relevant until later. A more intuitive sequence would be 1) adding a newConstInit
with the precondtion, 2) raising the termination issue, and 3) adding a secondConstInit
for general sequences.https://github.com/informalsystems/apalache/blob/b627481fca3677b15457c704fdd6f8aab66b6d84/docs/src/tutorials/entry-tutorial.md?plain=1#L780 Is specifying things in the "straightforward" way that much of a performance regression? Do people have to know how to optimize Apalache to get anything of value out of it?
https://github.com/informalsystems/apalache/blob/b627481fca3677b15457c704fdd6f8aab66b6d84/docs/src/tutorials/entry-tutorial.md?plain=1#L782 It's really weird to say "the list isn't sorted" is a "postcondition" of the algorithm. I'd instead write it like this:
https://github.com/informalsystems/apalache/blob/b627481fca3677b15457c704fdd6f8aab66b6d84/docs/src/tutorials/entry-tutorial.md?plain=1#L794-L797 Do not ask the reader to wait hours for results. Waiting several hours to continue the tutorial is the opposite of "not bad". Switch to 4-bit integers.
(Also, if you're saying how long things take, tell us the system you're running on. I have a workstation desktop and it only took 5 minutes to run.)
https://github.com/informalsystems/apalache/blob/b627481fca3677b15457c704fdd6f8aab66b6d84/docs/src/tutorials/entry-tutorial.md?plain=1#L822-L824
Many engineers reading this will not know off the top of their head the complexity of binary search so can't "recall" it. Better to just say "Binary search is guaranteed to terminate within XYZ steps."
https://github.com/informalsystems/apalache/blob/b627481fca3677b15457c704fdd6f8aab66b6d84/docs/src/tutorials/entry-tutorial.md?plain=1#L837-L857
If you can, it's better to show this as a diff change.
https://github.com/informalsystems/apalache/blob/b627481fca3677b15457c704fdd6f8aab66b6d84/docs/src/tutorials/entry-tutorial.md?plain=1#L861-L865
Termination
is too weak, as it passes if you setINT_WIDTH == 8
, and then a length-four sequence takes six steps. What you actually want is2^nSteps >= Len(INPUT_SEQ) + 1 => Termination
(or2^nSteps <= Len(INPUT_SEQ) + 1
).(Note that actually trying those invariants causes apalache to throw an error. Would you like a bug report from me?)
If you decide to stick with
INT_WIDTH
, you should explain thatINT_WIDTH = ceil(log2(MAX_UINT))
.https://github.com/informalsystems/apalache/blob/b627481fca3677b15457c704fdd6f8aab66b6d84/docs/src/tutorials/entry-tutorial.md?plain=1#L879-L882 This is a complicated property, both in terms of what it's doing (why does the second clause mean it's progressing?) and in terms of what's happening conceptually (what does it mean to put primes in properties?) I suggest dropping it entirely.
https://github.com/informalsystems/apalache/blob/b627481fca3677b15457c704fdd6f8aab66b6d84/docs/src/tutorials/entry-tutorial.md?plain=1#L905-L912 Would it make more sense to just add the invariant "NoOverflows" that checks all values (including
mid
) are aboveINT_MAX
?If the issue is that you don't have access to
mid
, why not make that an extra variable? This would also fix the issue onInBounds
where you have to calculatemid
a second time.(And also is a good place to discuss the difference between
x
andx'
when both are used in the same step!)https://github.com/informalsystems/apalache/blob/b627481fca3677b15457c704fdd6f8aab66b6d84/docs/src/tutorials/entry-tutorial.md?plain=1#L925-L941
Do I have to check every property separately? That puts every single violation into a separate folder.
(Also, it surprises me that it passes with no properties checked at all! I expected it to have an overflow, which you do discuss later.)
https://github.com/informalsystems/apalache/blob/b627481fca3677b15457c704fdd6f8aab66b6d84/docs/src/tutorials/entry-tutorial.md?plain=1#L1000-L1001
At this point I started running Apalache in a background job, partially out of convenience and partially out of fear of a model check taking several minutes. Is it okay to run multiple jobs in parallel?
https://github.com/informalsystems/apalache/blob/b627481fca3677b15457c704fdd6f8aab66b6d84/docs/src/tutorials/entry-tutorial.md?plain=1#L1090-L1091
This should be
INT_WIDTH=10
. I don't know if 16 bits is even checkable on commodity hardware.https://github.com/informalsystems/apalache/blob/b627481fca3677b15457c704fdd6f8aab66b6d84/docs/src/tutorials/entry-tutorial.md?plain=1#L1143-L1146
I should really emphasize that 35 minutes is too long a runtime to expect for a tutorial.
The text was updated successfully, but these errors were encountered: