TLA+ Modeling Tips

(muratbuffalo.blogspot.com)

60 points | by birdculture 7 hours ago

4 comments

  • walski 4 hours ago
    > TLA+ is a formal specification language developed by Leslie Lamport. It is used for designing, modelling, documentation, and verification of programs, especially concurrent systems and distributed systems. TLA+ is considered to be exhaustively-testable pseudocode, and its use likened to drawing blueprints for software systems;

    https://en.wikipedia.org/wiki/TLA+

    • tpoacher 3 hours ago
      In theory (according to Wikipedia at least) the acronym stands for "Temporal Logic for Actions" ... but the pun in the standard meaning of the acronym TLA (i.e. "Three Letter Acronym") is far too enticing for me to believe the choice was fully accidental. :D
  • plainOldText 2 hours ago
    This Scott Wlaschin talk [1] is a good introduction to TLA+. And the slides [2].

    [1] https://www.youtube.com/watch?v=qs_mmezrOWs

    [2] https://speakerdeck.com/swlaschin/tla-plus-for-programmers

  • ngruhn 4 hours ago
    To me the modeling is not that hard but I struggle to come up with properties/invariants.

    Take something like Google Docs. I'm sure they have some websocket protocol to handle collaborative text editing:

    - establish connection

    - do a few retries if connection is lost

    - always accept edits even when there is no connection

    - send queued edits when connection is back

    - etc

    But what properties can you imagine here?

    We never enter an error state? Not really. Error states are unavoidable / outside the control of the system.

    We always recover from errors? Not really. Connection might never come back. Or the error requires action from the user (e.g. authentication issues).

    • skydhash 1 hour ago
      TCP already provides a model for that one [0] and you can also use logical clocks [1], which is a more generic concept. Now that the whole reliability is out of the way and you're already using a queue for the ordering of the edits, then all you need to care is about the collaborative aspects.

      [0]: https://en.wikipedia.org/wiki/Transmission_Control_Protocol#...

      [1]: https://dl.acm.org/doi/abs/10.1145/359545.359563

    • RealityVoid 3 hours ago
      We never enter error state as long as XYZ properties are satisfied, I guess... I will admit, this is probably a naive take, I'm currently trying to go through the TLA+ videos and have trouble wrapping my head around it.
    • anonymousDan 3 hours ago
      Some kind of casual or eventual consistency related invariants perhaps?
  • fl4tul4 2 hours ago
    The strange case of "TLA+" topics reaching HN's Front Page without any reason.
    • baq 2 hours ago
      The reason is obvious - LLMs got good at writing them, initial cost to write went down 99%, toil to keep them up to date with code went down 99% and some people noticed. Value proposition went from ‘you must be joking unless we’re AWS and you’re proposing an IAM code change’ to ‘plan mode may also emit TLA+ spec as an intermediate implementation artifact’.
      • skydhash 1 hour ago
        Just like with code, the issue was never about writing a TLA+ spec. It was about writing a good TLA+ spec. Anyone can press a piano's key, but not everyone can write the Moonlight Sonata.
        • elcapitan 1 hour ago
          Yes, but the accessibility of TLA+, if you come from traditional programming languages, is quite harsh. I have 2 books about it and keep coming back to it every once in a while, but every single time there is a lot of investment into the exact syntax of certain things. Better tooling like AI autocomplete is a huge step there. I can still think about the spec, but not get stuck every single time on minor details.
          • skydhash 1 hour ago
            The devil is in the details. That's the whole point of formalism. There should be no ambiguity meaning what's written is what you want to be written. If you generate and can't prove what's generated is what you intended, the whole point of even writing it is moot.
    • plainOldText 2 hours ago
      It's not strange at all.

      The second story, and highly upvoted, on HN right now is: "AI will make formal verification go mainstream"[1].

      [1] https://news.ycombinator.com/item?id=46294574

      • elcapitan 1 hour ago
        It's interesting btw that Martin Kleppmann lists a couple of proof assistants, but not model checkers like TLA+. With him working extensively on distributed systems, I would have thought that would be on the list as well.