r/tlaplus • • 4d ago

tla-kit: TLC, SANY, TLAPS, cvc5 and ethos in one container image pinned by digest, plus an MCP server over them

3 Upvotes

tla-kit is one container image of the TLA+ tool family, so that the checker and the prover are the same build on a laptop and in CI. It also includes an MCP server over those tools, meant to be used with the writing-tla-specs-and-proofs skill.

Repo: https://github.com/scottcochran/tla-kit. Latest release: v0.5.0.

ghcr.io/scottcochran/tla-kit@sha256:5ee10d3e9b761f91020be2c6b11a16a459966a9a4cf5a105c964ae31a49ab59f

Why

I have a development with 34 TLAPS proof modules (about 13.6k obligations), and CI couldn't rerun any of them. The prover I'd pinned was an arm64-darwin build of tlapm 1.6.0-pre. Upstream rebuilds the rolling 1.6.0-pre tag under the same name, so the tarball I'd pinned is no longer served. "The proofs pass" really meant "they pass on my machine, with a binary nobody else can download."

tla-kit fixes this by keeping its own copy of each input and naming the result by digest:

  • The base image is pinned by digest, and apt comes from a dated Ubuntu snapshot.

  • The TLAPS tarball, and cvc5's and ethos's builds, are kept in this repo's releases. Each is checked by sha256, and so is every one of the 47 files in the tlapm tarball.

  • Every build of one commit gives the same image digest. CI's two runners and the release workflow all agree.

  • Releases come with signed build-provenance and SBOM attestations, which gh attestation verify checks.

  • PINS.json lists everything the image holds. CI fails if it disagrees with the Dockerfile, and tla-kit-selftest checks every installed digest against it in about 30 seconds.

What's in it

ToolVersion
tla2tools.jar (TLC, SANY, PlusCal)v1.7.4
tlapm1.6.0-pre at ff40755, with Z3 4.8.9, Zenon 0.8.4, Isabelle2025 and LS4
cvc5 + ethos + the CPC signature1.4.0 / 0.2.4. A certified run counts an SMT obligation as proved only when ethos accepts cvc5's proof of it
JavaTemurin JRE 25

The image sets TLA_JAR, TLAPM, CVC5 and ETHOS. If your run scripts already read those variables, a mounted project uses the image's tools without changes. You don't have to use the MCP server, either:

docker run --rm -v "$PWD:/work" ghcr.io/scottcochran/tla-kit@sha256:5ee1… tlc -config M.cfg M.tla
docker run --rm -v "$PWD:/work" ghcr.io/scottcochran/tla-kit@sha256:5ee1… tlapm --cleanfp --strict M_proof.tla

The MCP server

tla-kit mcp is an MCP server over stdio. It's written with Python's standard library only and runs inside the image, with your project mounted at /work:

docker run -i --rm --user "$(id -u):$(id -g)" -v "$PWD:/work" \
  ghcr.io/scottcochran/tla-kit@sha256:5ee1… tla-kit mcp

It has 14 tools:

ToolWhat it returns
infoEvery tool in the image, with the digest a results file would cite
parseSANY errors and warnings, with their locations
symbolsA module's constants, variables, definitions (arity, parameters, level), assumptions and theorems, from SANY's XML exporter
evaluateA constant expression evaluated by TLC. Given a module, it can use that module's definitions
tlc_runOne check of one property: HOLDS / COUNTEREXAMPLE / DEADLOCK / ERROR, the state count, and any counterexample as structured states (JSON, not trace text)
simulateRandom behaviours to a depth. Its result is labelled NO-ERROR-SAMPLED, never "holds"
coveragePer-action counts, naming the actions that never fire
state_graphA small model's reachable graph as JSON, with edges labelled by action
proof_checktlapm --summary: whether the module parses and elaborates, and how many obligations it has. No backends run
proveTLAPS on a theorem or step by name, a line, a line range, or the whole module. It reports success only when every obligation in scope is proved. Otherwise it returns each failed obligation's text, the backends tried, and why each one failed
tlc_rowsRuns a list of checks and writes a dated results file stamped with digests, only if every check is as expected
proof_resultsWrites a dated proof results file (--cleanfp --strict), only if every obligation is proved
flip_testA non-vacuity check: flips a hypothesis in a copy of the proof module and confirms the proof then fails where it should
proof_syncReports IN SYNC / STALE / MISSING for every results file against the current modules and tool pins

Some details on how the server behaves:

  • Only tlc_rows and proof_results write into your project, and they write only results files. Every other tool keeps its scratch files outside the project, and paths outside the mount are refused.

  • The proof tools enforce your project's prover pin (tools/TLAPS-PIN). An unpinned run happens only if you ask for one, and its output and results file say so.

  • Every prove call starts a fresh tlapm in its own process group. On a timeout or a cancel, the whole group is killed, so no orphaned Isabelle or Z3 processes are left behind. The server owns the fingerprint cache and allows one run per module at a time. I wrote this concurrency design as a TLA+ spec, spec/ProveRequests.tla, and model-checked it (78 checks), and there's a test that tries to break each of its properties against the real server.

  • The proof tools follow the design of marco6/tlapm-mcp (none of its code is used). The main change is returning the failed obligation's text, not just its location.

  • I checked the server against the commands it wraps. On two real modules, all 84 comparisons between each tool and its command-line equivalent matched.

Does an agent actually do anything useful with it?

I ran one small test. I gave Claude Code only the 14 tools plus Read and Edit, and a 39-line fixture proof with one step broken: the step's BY LimitNat DEF TypeOK, Bounded, Next, Step, vars was cut down to BY DEF Bounded. The agent wasn't told which step was broken.

  1. prove on the module failed at line 15. The obligation text showed only Bounded expanded, so the agent added the DEFs that a sibling lemma uses.

  2. prove failed again, but the text now showed n < Limit and n >= Limit side by side. The agent concluded the prover needed Limit \in Nat and added LimitNat.

  3. prove succeeded with 19/19 obligations proved, 8 of them from the cache, in 0.5 s.

That took 28 seconds and cost $0.15, and the result matched the original byte for byte. Running tlapm --cleanfp --strict directly, outside the server, also proved it. The obligation text is what made the repair possible: a line number and a "failed" verdict would have located the step, but not shown what it was missing.

To be clear about what this shows: it was one run, one model, and an easy repair. Nothing was tried on long proof steps or on repairs that need a new lemma. The full record, with the transcript, is here, and examples/agent-repair/ reproduces it, including an Actions workflow.

Certified proofs

v0.4.0 adds cvc5 and ethos. In the published image, a certified run checked all 263 obligations of one of my proof modules. TLAPS' translation to SMT has known soundness issues (tlapm#309, #310). Having cvc5 proofs checked by ethos doesn't fix those, but it does take the SMT solver itself out of what you have to trust.

Limits

  • Linux x86_64 only. Upstream publishes no Linux arm64 tlapm. On Apple Silicon the image runs under emulation; my full run of 34 proof modules took under 7 minutes on a 12-CPU Mac.

  • One prover build. The image carries tlapm at ff40755. If your project pins a different build, you're comparing obligation counts, not identical results files.

  • About 800 MB.

  • Not in it yet: Apalache, TLATeX, the community modules, and a from-source arm64 tlapm.

  • Only the latest release is supported. Old digests are never deleted, but they get no fixes.

Try it

Point your agent at a TLAPS proof with the server connected. The tool descriptions should be enough for it to work out the server on its own. For the full method (how to write specs so their properties are local, how to structure proofs, and how to keep the evidence honest), add the writing-tla-specs-and-proofs skill, which declares the server for you.

Feedback is appreciated, especially:

  • Where your agent got stuck, and what the tools returned at that point.

  • Would you use something like this in your own CI, and what would it need to have?

  • Is Apalache or the community modules the more useful next addition?

Code is Apache-2.0 and docs are CC BY 4.0. The bundled tools keep their own licences, and the repo includes the source of the copyleft parts.


r/tlaplus • • 5d ago

TLA+ Community Survey 2026

Thumbnail linuxfoundation.research.net
7 Upvotes

Make your voice heard!


r/tlaplus • • 15d ago

Seeking a sanity check on ~30 TLA+ modules and 24 TLAPS proof modules for a multi-agent AI control plane (solo project)

7 Upvotes

TOPAK is an architecture pattern for multi-agent AI systems: every agent treated as Byzantine, models kept out of the trusted computing base. Nothing is deployable.

Here's an intro post:

https://grippinghand.dev/topak

Here are the specs:

https://github.com/scottcochran/TOPAK/tree/main/spec

Two questions:

  1. Do the specs say what their records claim they say?

  2. Do they check anything useful, or are they true because they constrain nothing?

On the second: every module takes a `Mut` constant, ships with mutations that must break its invariants and witnesses that must be violated, and each TLAPS theorem's hypothesis is exactly the mutations that break it.

If you only read one thing: https://github.com/scottcochran/TOPAK/blob/main/spec/Coupling.tla

Writing the liveness extension of that module turned up two soundness issues in tlapm's translation, filed as tlaplus/tlapm#309 and #310, with reproducers in `spec/defects/`.

Any feedback is welcome.


r/tlaplus • • 15d ago

TLAPlusPlus - A Faster Drop-in TLA+ Checker for TLC

11 Upvotes

Manyan (previously known as TLA++) is a TLA+ Checker that is implemented in C11 without deps and runs faster than TLC (up to 4x to 22x).

https://github.com/soasme/manyan

TLA⁺⁺ v0.5.0 is out! Updated 2026-11-07: Pinned TLAToolbox 1.7.4 as Oracle.
TLA⁺⁺ v0.6.1 is out! Updated 2026-11-08: Pinned TLAToolbox 1.8.0 as Oracle.
TLA⁺⁺ v0.7.0 is out! Updated 2026-11-09: Performance improvement and bugfixes.
Manyan v0.8.0 is out! Updated 2026-11-10: Project TLAPlusPlus is rebranded to Manyan.
Manyan v0.9.0 is out! Updated 2026-11-11: bugfixes.
Manyan v0.10.0 is out! Updated 2026-11-12: Experimental `-symbolic` option to enable similar checks like apalache-mc check.
Manyan v0.11.0 is out! Updated 2026-11-14: Support `-typcheck` like apalache-mc typecheck.
Manyan v0.12.0 is out! Updated 2026-11-15: Faster evaluation and liveness in workers enhancement.
Manyan v0.13.0 is out! Updated 2026-11-16: Reduced memory usage and bugfixes.
Manyan v0.14.0 is out! Updated 2026-11-16: Can run `pip install manyan` or `npm i \@soasme/manyan` to use manyan now.
Manyan v0.16.0 is out! Updated 2026-11-20: run faster and with less memory, and feature parity w/ TLC1.8.0

I pinned TLC & Apalache as the oracles and plan to track whenever a new version is out.

Appreciate it if you can give it a test and send issues on GitHub. Thank you!


r/tlaplus • • 22d ago

TLA+ Quest - LeetCode-style practice platform for TLA+

22 Upvotes

Hi, I built a LeetCode style practice platform for TLA+ that I would like to share (www.tla.quest).

The platform contains a series of specification challenges that are automatically graded against an expected solution. The full state space can be visualized in your browser. Failing submissions with unexpected or missing states are highlighted for feedback.

I created this project for fun while learning TLA+. I always wanted something like this while I was learning. Note: This is currently still a work in progress. If you are interested, please try it out and let me know what you think. Feedback (both good and bad) is very much appreciated! If there’s interest I will keep improving the site and add more challenges.

www.tla.quest


r/tlaplus • • Oct 21 '26

Blueprints, Not Prompts: Using TLA+ to Guide AI-Written Code

Thumbnail
mulgadc.com
6 Upvotes

Reposting here to gather more thoughts and opinions!


r/tlaplus • • Oct 06 '26

[2607.23425v1] TLA+-Bench: An Execution-Grounded Benchmark and Dataset for Natural-Language to TLA Specification Generation

Thumbnail
arxiv.org
10 Upvotes

r/tlaplus • • Oct 01 '26

What TLA+ can and can't check

Thumbnail reddit.com
6 Upvotes

r/tlaplus • • Sep 10 '26

[Seeking Mentorship/Feedback] Senior CS Students Building an AI + TLA+ Formal Verification System

Thumbnail drive.google.com
6 Upvotes

Hi everyone,

We are a team of 5 senior Computer Science students from Cairo University, Egypt, currently working on a research/graduation project called TraceProof.

A brief introduction

TraceProof is our graduation/research project focused on using AI agents to make formal verification more practical for real-world software.

The idea is to start from an existing codebase rather than requiring an engineer to manually build a formal model from scratch. TraceProof analyzes the repository, extracts important correctness properties (invariants), generates a focused TLA+ model, formally searches for violations, and then attempts to reproduce any discovered counterexample in the actual software.

We have already built a working end-to-end Proof of Concept demonstrating this pipeline on a distributed leased-lock concurrency bug.

We are currently studying formal methods, TLA+, distributed systems, and related research papers as much as we can. However, we have had difficulty finding people around us with hands-on experience in these areas, so we are hoping to get feedback from people who have worked with formal verification, TLA+, distributed systems, or related research.

In particular, we would really appreciate your thoughts on:

Does this workflow make sense from a formal-methods perspective?

What do you see as the biggest risks in automatically mining invariants and generating formal models from existing code?

How would you evaluate whether a generated model is actually faithful to the implementation?

Are there existing systems or papers that we should absolutely be comparing against?

We have attached our project proposal, which describes the architecture and the pipeline we currently envision. At the end of the proposal, there is also a link to our GitHub repository containing the PoC/prototype.

We are looking for someone who might be interested in mentoring us throughout the project. Our goal is to develop this into solid research work and, if the results are strong enough, publish a research paper at the end of our senior year.

We understand that people are busy, so we are not expecting a significant time commitment. Even around one hour every week or two, depending on your availability, would be incredibly valuable to us.

We are students trying to learn and build something meaningful, so any criticism, advice, or pointers toward relevant research that could help us improve the project would be greatly appreciated.

Thank you in advance!


r/tlaplus • • Sep 02 '26

TLA+ in a Web Egnine - follow-up

10 Upvotes

Quick follow-up on https://www.reddit.com/r/tlaplus/comments/1u7c4j0/tla_in_the_context_of_a_web_engine_talk/

I have used TLA+ to model and verify two additional parts of the engine:

- The rendering loop (spec)

- The message port implementation (spec, and also a discussion in this blogpost).

A few words on modelling the rendering loop: in a modern browser engine, showing some pixels on the screen involves multiple processes--a process running the web page and usually producing a "display list" based on the state of the DOM, another process translating various display lists (in the case of cross origin iframes you have multiple processes running the different parts of the "page") and other sources (like video or image frames) into gpu commands, and yet another process presenting the result of running gpu commands--and so such a multi-process workflow is well positioned to benefit from TLA+ modelling. The challenge in that workflow is that for performance you want to update the screen as little as possible, but you also do not want to miss any updates, so there is a liveness angle to it.

I'm using the TLA specs both to guide the agentic implementation, and also to verify it via traces. So giving a spec to an agent forces it to think harder about how to implement the design (the formal spec is paired with an informal design doc), and then telling it to actually trace the code further focuses it (in my anecdotal experience so far). The whole process is iterative of course, in that sometimes you end-up going back to the model to change it, and you can have a whole discussion with the agent about whether a given failure is something that should result in fixing the spec, the code, or the tracing.

In conclusion: a very good experience so far, and I think it is worth posting because a web engine is not the usual stuff to which TLA+ is applied.


r/tlaplus • • Jul 12 '26

Why your integration tests pass but your message queue still double-processes in production

1 Upvotes

You know the story. You write a consumer, test it locally, deploy to staging, everything green. Then in production, the same message gets processed twice. Orders are duplicated. Notifications go out twice. Everyone blames "a race condition" and moves on.

We spent the last few months formally verifying what actually happens when consumers crash with at-least-once delivery semantics. The short version: it doesn't matter which broker you use. The race condition is a property of the delivery contract, not a bug in the implementation.

What we did

Instead of writing more integration tests hoping to reproduce the timing, we wrote a formal specification of the consumer-broker interaction in TLA+ (the specification language by Leslie Lamport). The model checker exhaustively explores every possible interleaving of events — not just the ones you think to test.

Then we took the counterexamples from the model and validated them in real running systems using Docker + Toxiproxy (network fault injection). If the math said "double-execution is possible", we confirmed it with actual containers.

What we found

We applied this pipeline to five different systems:

Celery — ACK timeout + network blip: the model found the crash window at depth 9 (444 states). Chaos confirmed it: task executed twice.

RabbitMQ — consumer stores result, drops connection before AMQP ACK. Same pattern. 108 states, depth 7. Chaos confirmed.

NATS JetStream — consumer crashes after DB write, before ACK. 47 states, depth 6. Docker kill + Toxiproxy confirmed: duplicate execution.

Apache Pulsar — batch consumer crashes between Process and SendAck. 21 states, depth 4. Chaos confirmed: 2 DB rows for 1 message.

Kafka — consumer commits offset after processing. Crash between StoreResult and commitSync(). Same result: double execution.

Every single time, the model predicted the collision and chaos confirmed it.

The insight

The spec is the same across all five systems. The variable names change, but the topology is identical:

Consumer:
  1. Receive message
  2. Store result in DB
  3. Acknowledge/commit offset
  [crash window lives between 2 and 3]

This isn't a bug in Celery, RabbitMQ, NATS, Pulsar, or Kafka. It's a fundamental property of any at-least-once delivery system with a stateful consumer. You cannot eliminate this window without changing the delivery semantic or adding an idempotency shield on the consumer side.

What this means for your code

The fix isn't new — idempotent consumers, deduplication keys, exactly-once processing patterns. Everyone knows about these. What's new is that we now have:

  1. A formal proof that the problem must exist under at-least-once, regardless of broker

  2. A reusable specification that works across brokers without modification

  3. Physical validation that the model is correct (6/6 confirmed)

This shifts the conversation from "did we test enough?" to "does our system design provably avoid this class of errors?"

Why not just test more?

Because testing samples the state space. Formal verification exhausts it. Integration tests won't find the crash window unless they happen to hit the exact nanosecond where the consumer crashes between the DB write and the ACK. Model checking finds it systematically.

Discussion

Have you run into this in production? What patterns do you use to handle consumer crashes — idempotency keys, outbox pattern, something else?

I'm curious whether teams treat this as a known limitation they work around, or whether it's still a source of surprises. Let me know your experience.


Full disclosure: I'm the author of the toolchain we used. Preprint: https://zenodo.org/records/21298530 — happy to share details if anyone's interested, drop a comment.


r/tlaplus • • Jun 16 '26

TLA+ in the context of a Web engine: talk

8 Upvotes

On Wednesday the 17th, I will be discussing the TLA+ based verification approach taken by https://github.com/gterzian/formal-web, which itself is based on https://arxiv.org/abs/2404.16075

For details see: https://github.com/Igalia/webengineshackfest/issues/77

The event can be attended remotely (I will myself be presenting remotely).

-----

Since it wasn't recorded, here is a quick overview:

I am using the approach described in Validating Traces of Distributed Programs Against TLA+ Specifications to verify parts of certain web standard algorithm I implement in my new web engine project. The verification related code is at here.

Currently I have done only a small part of the navigation algorithm--the part where an ongoing navigation needs to be wait the before unload steps to have run for the documents that will be unloaded by the navigation if not aborted-- the spec is here.

Re the setup: there is basically a thread in the main process of the engine that is the recipient of logs coming from any thread in any other process in the engine. This monitor thread runs when a flag is turned on, and then on shutdown of the engine the tlc based verification of the collected logs kick in.

I intend to use fro a small number of key algorithms in web standards that are concurrent semantics that make verification worthwhile.


r/tlaplus • • Jun 12 '26

TLA+ spec for a toy reactor-protection state machine

9 Upvotes

I added a small TLA+ spec to an educational open-source simulator I’m building:

https://github.com/gabrielbotandev/rbmk-sim

The project is an RBMK-1000-inspired toy simulator, but the part I’m posting here about is the protection-system state machine: trips, alarms, latching, reset permissives, and fault handling.

It is not a real reactor model. I’m using it as a learning project for safety-related software, deterministic replay, and formal specification.

I’d like feedback on the TLA+ side: what invariants would you expect here, what is under-specified, and what would make the model more useful?


r/tlaplus • • May 25 '26

New to TLA+, question regarding specification of WriteThroughCache in section 5.6 of "Specifying Systems, TLA+".

6 Upvotes

Hi All,

I am pretty confused regarding the WriteThroughCache specification, would be much appreciated if someone could help me sort out these concepts,

  1. Why do we really need to include the temporal existential quantifier in Module Memory to hide the variables of InternalMemory?

  2. Why WriteThroughCache can't just reuse the ISpec of the InternalMemory but has to instantiate the Memory and use its ISpec?

  3. Maybe a follow up question is what differences the temporal existential quantifier introduce?

Thanks in advance!


r/tlaplus • • May 25 '26

TLA-MCP: Quick follow-up to last week's announcement

Thumbnail reddit.com
3 Upvotes

r/tlaplus • • May 18 '26

MCP server for the TLA+ model checker tla-rs

12 Upvotes

Hello everyone,

It's been a while since I last posted about the tla crate in Rust (https://github.com/fabracht/tla-rs). We had many contributions over the months and interest seems to be steadily increasing. I would like to thank everyone for the support and interest.

I'm here today to announce a new experiment with tla-rs: the `tla-mcp server`. It exposes the model checker as a Model Context Protocol server so agentic clients can call it as a first-class tool to validate a spec, run a bounded check, inspect counterexamples, replay scenarios, all from inside the chat.

Install instructions, client config, and a quick tour of the four tools are on the landing page: **https://fabracht.github.io/tla-rs/**

It's an experiment. I have started simple, so feedback, bug reports, and war stories welcome.


r/tlaplus • • May 01 '26

Data Structure Proof in TLA+

8 Upvotes

Hello all, I was wondering where I can find examples of lock-free data structures being proved to be linearizable in TLA+. I can find examples of programs in the book but not much on data structures. For example, I would love a proof of correctness for the Fomitchev and Ruppert lock-free list however I can't find anything. I am very new to formal verification. My hope is that I can prove the correctness of my own tree data structure using TLA+. Please let me know of any resources or guides, or if I am barking up the wrong tree / proof software.


r/tlaplus • • Apr 15 '26

Solution For Fly Puzzle, Continuous?

3 Upvotes

Hello, i have recently taken to https://docs.tlapl.us/learning:exercises to learn some tla+

was doing the following exercise

Two trains start L kilometers apart, heading toward each other at constant speeds v1 and v2. A fly starts on the nose of the first train and flies back and forth between the trains at speed f until the trains meet. How far does the fly travel?

I created this model for the solution

---- MODULE TrainFly ----


EXTENDS Integers, FiniteSets


CONSTANTS L, v1, v2, fv, dt


VARIABLES fdist, tapart, seconds


TypeOK == 
  /\ L > 0
  /\ tapart >= 0
  /\ fv > v1 
  /\ fv > v2 


Init == 
  /\ tapart = L
  /\ seconds = 0
  /\ fdist = 0


  Max(a, b) == IF a >= b THEN a ELSE b


Next == 
  /\ seconds' = seconds + dt
  /\ tapart' = Max(0, tapart - (v1 + v2)*dt)
  /\ fdist' = fdist + fv


\* Violated when trains meet (tapart = 0)
Solution == tapart /= 0
====


---- CONFIG ----
CONSTANTS
  L = 50
  v1 = 2
  v2 = 2 
  fv = 4 
  dt = 1


INIT Init
NEXT Next


INVARIANTS
  TypeOK
  Solution
====

which is basically a simulation with a time step of one second, and setting all velocities as distance/1

this incorrectly finds the solution of `fdist = 52` which is incorrect, b/c the trains meet at 12.5 steps it should be fidist=50.

I tried asking an llm about this and it pretty much has told me that tla+ is for discrete modeling and there's no way to write this continuously. I also cannot find a solution to this based on the one linked in the question. Is this an impossible thing to model in tla+ ? or am i just misunderstanding something? would appreciate some direction here!


r/tlaplus • • Apr 10 '26

A pub/sub behavior specified—with TLA+ thus verified

Thumbnail
fuzzypixelz.com
6 Upvotes

I would appreciate any feedback :)


r/tlaplus • • Mar 31 '26

How to reference values across two states in a behavior in properties?

5 Upvotes

I'm currently learning TLA+, and am modelling a simple UI where a user can click and move items.

I have a simple spec:

---- MODULE container ----
EXTENDS TLC, Sequences, FiniteSets, Naturals


EmptyItem == ""
Items == {"item1", "item2"}


VARIABLES
    cursor,
    container


vars == <<cursor, container>>


Init ==
    /\ cursor = EmptyItem
    /\ container = <<"item1", EmptyItem>>


ClickSlot ==
    \E slot \in 1..Len(container) :
        /\ cursor' = container[slot]
        /\ container' = [container EXCEPT ![slot] = cursor]


Next == ClickSlot


Spec == Init /\ [][Next]_vars


====

How would I be able to express a liveness property that for any two slots, it's always possible to swap the items in them?

I'm not sure exactly how to say something like "if container[i] = A and container[j] = B, then at some later point it's always possible that container[i] = B and container[j] = A".

I'm assuming I want to do something with quantification and []<>, but I can't really crack the nut. I'm having difficulties understanding when a given expression refers to the "current" state and when it refers to a future state, when a sub-formula is within a temporal operator.


r/tlaplus • • Mar 28 '26

Examples for specifying user interactions?

5 Upvotes

I'm a TLA+ beginner, with a fair familiarity with first order logic and set theory. I'm looking to learn to use TLA+ to help with writing specs for user interactions. I'm working on a project where we support multiple input devices (mouse + keyboard, gamepad, touch input) where the user can freely switch input method at any time, and some input gestures require us to keep some interaction state to track to translate certain input sequences into something semantic (e.g. think, double click, long press).

I think TLA+ could be a useful tool here, so that I can design this "interaction state" and make sure that the application is updated as expected in response to all combinations of user input.

I read through learntla.com and attempted to write a simple spec for moving items around in a window, but I got stuck very quickly on stuttering issues.

Is there a collection of useful examples for checking that a sequence of user input results in expected application state updates? I'm less interested in concurrency per se as much as I want to explore a reasonable large state tree based on all the user inputs.


r/tlaplus • • Mar 27 '26

Need advice on coding style/idioms

4 Upvotes

I'm writing a spec of a system, and I get hundreds of lines of TLA+, which is a bit overwhelming for a person new to TLA+, so I try to invent ways to deal with the complexity.


At first, I found that writing UNCHANGED is difficult, especially when you introduce new variables, so I tried to use a single variable:

Instead of

SendXxx ==
  /\ reqid' = reqid + 1
  /\ pending' = pending + 1
  /\ backend!SendXxx(reqid, ...)
  /\ UNCHANGED ...
  
ReceiveXxx ==
  /\ UNCHANGED reqid
  /\ pending' = pending - 1
  ...

I tried

SendXxx ==
  /\ state' = [state EXCEPT
    !.reqid = state.reqid + 1,
    !.pending' = state.pending + 1]
  /\ backend!SendXxx(state.reqid, ...)

ReceiveXxx ==
  /\ state' = [state EXCEPT
    !.pending' = state.pending + 1,
  ...

However, in some cases this dramatically increases number of distinct states.


Another challenge is modifying a variable twice, or conditional modifications in general.

\* Remove operation from the queue, start next operation.
...
/\ op = Head(queue) /\ queue' = Tail(queue)
/\ operation_state' = IF Len(queue) = 1
    THEN [operation_state EXCEPT ![op] = "done"]
    ELSE [operation_state EXCEPT ![op] = "done", ![queue[2]] = "working"]

I tried two different approaches,

  1. Chain "functions"

LOCAL OpState_SetDone(op, old_state) == [old_state EXCEPT ![op] = "done"]
LOCAL OpState_MaybeResumeNext(old_state) ==
  IF Len(queue) = 1 THEN old_state 
  ELSE [old_state EXCEPT ![queue[2]] = "working"]

...
/\ operation_state' =
  OpState_SetDone(op,
    OpState_MaybeResumeNext(
      operation_state))

2) (ab)use LET and write in single static assignment style

/\ LET operation_state_1 == OpState_SetDone(op, operation_state)
       operation_state_2 == OpState_MaybeResumeNext(operation_state_1)
   IN operation_state' = operation_state_2

Long story short, are there idioms that reduce complexity of the TLA+ code?


r/tlaplus • • Mar 24 '26

TLA+ for Single-Page Web Applications | by Sam Miller | Mar, 2026

Thumbnail medium.com
11 Upvotes

r/tlaplus • • Mar 22 '26

Formalizing MessagePort in Servo with TLA+

13 Upvotes

I implemented MessagePort in Servo back in 2019 — it was the hardest concurrency problem I'd encountered, because ports can be transferred between event loops while messages are still in flight. This weekend I finally got around to formalizing it in TLA+, with Claude helping with the typing.

The interesting outcome: the abstract spec (following the HTML standard) is so simple that the refinement proof itself serves as the inductive invariant. No additional invariants needed. TLC found no bugs in the Servo implementation, though it did help me make explicit a sequencing assumption that was implicit in the code.

Happy to answer questions about the TLA+ approach or the Servo implementation.

Specs and blog at https://medium.com/@polyglot_factotum/formalizing-messageport-afbe7846578d


r/tlaplus • • Mar 13 '26

Will I benefit from TLA+ as a web dev?

10 Upvotes

I'm a dev who likes to experiment with new concepts, I use FP (with Haskell and PureScript) and I had few attempts to learn something like Lean and Dafny (not really successful). I've found TDD to be very useful for my mind when I'm developing and designing systems. I like things that teach me to think. But is TLA+ even something that is applicable? It seems like it's best use with distributed systems, while must of my work is single threaded. Will I find some practical applications of TLA+ as a humble dev with curiosity?