| > And it's quite tightly bound to their particular UI tool, which makes keeping the models in git possible but somewhat quirky. I couldn't find a way of tracking the TLA+ Toolkit's files nicely in git, but with a bit of manual work it's possible, using the `tlc-bin` CLI[0]. I used the TLA+ Toolkit to write the spec[1], but wrote the models by hand (eg. [2]). This was before I heard of the VS-Code extension. I think it's quite good now, so there might be a better workflow that avoids the TLA+ toolkit altogether. > What I'd honestly like more is to be able to make some files which could be compiled either in the real software project, or as part of a formal verification testing step. Do you mean you'd like to generate a TLA+ spec from your source code? [0] https://github.com/pmer/tla-bin [1] https://github.com/statechannels/tla-specs/blob/6d7227e2d183... [2] https://github.com/statechannels/tla-specs/blob/6d7227e2d183... |
I'm not sure what you're calling "spec" vs "model"; I wrote stuff in PlusCal, which I checked into git; then used `make` to translate that into .tla automatically as needed. The .tla files are .gitignored, so don't choke up your commit history with machine-generated stuff.
Here's a snippet of my Makefile:
The idea here is that doing "make" would simply compile all the .pcal files into .tla files (thus effectively doing a syntax check); but if you wanted to run any specific test, you would name the output file the test would generate.You can see how I'm working against the way TLA wants to work: It wants to take your PlusCal code at the beginning of the file and rewrite the end of the file, "helpfully" backing up the old file with a ".old" extension; I want to take plain PlusCal code and generate an intermediate file (like an object file) which is not checked in. So I have to copy $FOO.pcal to $FOO.tla, run `pcal.trans` on $FOO.tla, and then delete the useless "$FOO.tla.old" file.
I always meant to publish these after XSA-299 went public, but haven't gotten around to it.
> Do you mean you'd like to generate a TLA+ spec from your source code?
Well obviously the whole project is so large as to be completely prohibitive. The model is written in the C-like variant of PlusCal, and uses a lot of the same variable names and such to help make sure they match the real C functions; and then translated into TLA. It would be nice if I could designate just one file (written in C) whose functions would be translated into TLA. The properties you want to verify about those functions would obviously need to be written in TLA directly.