Formal Methods in Practice: Using TLA+ at ESpark
medium.com
medium.com
https://groups.google.com/forum/m/#!topic/tlaplus/C7Rmka3iSG...
Alloy is a nice tool. I've seen it in my field used to verify transaction handling in simple databases and part of a high-assurance VPN. Another person here said they check data structures with it.
But because a model-checker makes a huge difference in productivity (it is usually the difference between worth it and not worth it), it TLA+ is similar to Alloy in terms of the effort required. Also, while it is harder to learn than Alloy, it is much easier to learn than Coq or Isabelle; partly due to design and partly due to the fact you can use it without learning how to be effective at writing formal, mechanically-chcekable proofs. It takes about two weeks to learn TLA+ well enough to start getting real work done.
OTOH, while TLA+ can in principle be used to prove general mathematical theorems, it was designed with a focus on discrete systems (i.e., software and hardware) and targeted at engineers, not mathematicians/logicians, so if you want to do general formal math, Isabelle or Coq would be a better choice.
The apps, while critical to the effectiveness of the product, are also the most complicated component. Each student needs a different set of apps, which change as they complete lessons. We have to be able to track and adjust them in near-real time, so that students aren’t left without a next lesson. In extreme cases a student might need six apps in the morning and six completely different apps in the afternoon. We also have to be mindful of school budgets, so we have a limited number of the paid apps and shuttle them between students. Finally, since we need to do this at scale, the entire system has to run automatically with no teacher or admin intervention.
This seems to be re-inventing the Web, but with more DRM. It's a lot like running a corporate intranet. Ten years ago, this could all have been done easily with Java applets or Flash programs. The actual apps look like Flash projects.[1] Most of this could probably be done with some toolkit for generating browser games in HTML.
Does this thing really need to be this complicated? Or has it been overdesigned?
Mandatory XKCD: [2]
[1] https://www.youtube.com/watch?v=p6deAYxzlCc [2] https://xkcd.com/1367/
And what are some suggested resources for filling those prerequisites?
On this note, "non-trivial" formal verification can often be very, very non-trivial, depending on how you approach it. And I mean that in the sense that actually writing the specifications and proving them can be extremely hard, depending on the tools -- even if the problem itself may 'seem' easy. Think "I have a 1000 line program that needs 10,000 lines of proofs". (1-2 orders of magnitude is probably a good ballpark estimate, if you're doing things with tools like Coq.)
Luckily, TLA+ in particular is pretty easy to learn and you can get productive in a few weeks I think, and it's geared more towards engineers than e.g. general mathematicians or whatever. This introduction is pretty good:
- https://learntla.com/introduction/
If you want a more general background... Go pick up some books on logic and computability. The things you learn here will apply deeply to nearly every approach to formal verification you can think of. Start with simple propositional logic, and you can move up to first-order logic, higher-order logics or type theory later on. This will help you understand logical systems, how to prove propositions, their relations, what can be decided etc, which will be deeply useful, forever.If you want the book on this stuff, I strongly recommend the following one. It is dense but it is, in short, the bible of automated computer-based theorem proving, as far as I'm concerned, and has substantial code to back it up. (The author does formal verification of FPUs at Intel):
https://www.amazon.com/Handbook-Practical-Logic-Automated-Re...
First, TLA+ is not a model checker. It is a specification and proof language that also has tools in the form of a model checker (more than one, actually) and a mechanical proof system.
Second, it is absolutely true that TLA+'s focus is not general mathematical theorem proving, and its intended audience are engineers, but it is not so much designed around concurrent hardware/software but that it is designed for algorithms in general. This means that it is also very appropriate for reasoning about concurrent or interactive (which is just a form of concurrency), whereas general mathematical tools that are often designed to reason about constructive functions rather than algorithms, and so can naturally reason about sequential algorithms, but need extra effort to reason about interaction or concurrency.
Finally, a strong focus of TLA+ is that it can serve as a refinement calculus, namely reason about the same system/algorithm at different abstraction levels, and explore the precise relationship between the different levels.
I agree that TLA+'s most practical advantage is that for its power, it is exceptionally easy to learn and apply in practice (much of this is due to the availability of a model checker). I also agree that ultimately, the specification, reasoning, and proof work in pretty much all formal tools is much more similar than different.
https://www.cis.upenn.edu/~bcpierce/sf/current/index.html
http://adam.chlipala.net/cpdt/
A book on refinement calculus that connects high-level specs to low-level implementations:
http://lara.epfl.ch/w/_media/sav08:backwright98refinementcal...
My favorite illustration using Event-B of how requirements and specs can explode into many verification conditions for even something simple. You're explicitly handling both the stuff that's usually unstated and the needs of the tool.
If you want freedom, air cover, and resources to apply formal methods to real production systems but haven't found that sponsor, try me: username at gmail.
Any advice for those of us who'd like to introduce this to a team rather than play with it on our own?
(For example: it's tempting to think of variables as some sort of communication channel – they're not. And fairness can be hard to conceptualize until it's put to a real-world use.)
Definitely use PlusCal. It's a little more to learn, and a little more restrictive, than straight TLA+, but most TLA+ specs you write will end up looking like the output of PlusCal anyway, and the PlusCal version will be much more compact and easy-to-follow. Just remember that PlusCal is not like any other programming language; especially the "await" statement can throw newcomers off (it's not like "await" in other languages).