[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [tlaplus] Re: On (ENABLED A)'
Very cool project, Igor! I have been dreaming of generative testing like this for TLA+ since going to BugBash 2025.
The idea of making a formally verified oracle interpreter for TLA+ in Lean or similar is very interesting. I do wonder whether it will run afoul of the same issue parsing has, which is that the only way to formally specify what should be parsed is with a grammar - and writing a grammar is pretty close to writing a parser anyway, so it is easy to have bugs sneak in to the specification! TLA+ syntax itself cannot even be expressed in a EBNF context-free grammar, due to context-sensitive features like vertically-aligned conjunction & disjunction lists as well as proof levels. I don't know what formalism could even be used for it.
When I last looked into this a few years ago, I found the K Framework for executable formal language semantics, which might be interesting to look into:
https://kframework.org/
I find TLA+ formal semantics very difficult to understand. I tried reading the paper by Lamport and Gonthier about recursive operator definitions and did not get very far. I recall it defines various things in terms of unbounded CHOOSE.
Andrew Helwer
Hi Andrew,
> So I think it is a good idea to explicitly add a spec that exercises this functionality to the tlaplus/examples, or some future standardized TLA+ interpreter test corpus! It seems Lamport's MCRealTime.tla usage might not be enough to expose differences from TLC in terms of state counts or other more-noticeable failures.
I have been working on a black box fuzzer for TLC vs. Apalache for
several months [1], supported by the TLA+ Foundation. The idea is to
increase the test coverage via PBT-like generators, mutation testing,
metamorphic testing, etc. The tool is already capable of producing the
_expression_ you mentioned. Unfortunately, it was overshadowed by other
issues discovered in Manyan in a campaign I ran yesterday.
IMO, we have to define a simple interpreter in something like Lean
4/Rocq/Isabelle, in order to test all of our tools. The point would be
to define a general definition of semantics (most-likely,
non-computable) that the other tools may specialize in, but they
should not deviate from the standard definition. TLC is the de-facto
interpreter on finite-state systems, but we recently saw an example
that was treated incorrectly by both TLC and Apalache, but not by
TLAPS [2, 3]. Maybe, we could reuse some parts of TLAPS for this
already.
> The two extant vibe-coded TLA+ model-checkers, https://github.com/fabracht/tla-rs and https://github.com/soasme/manyan, both mishandle this case. I might bear some responsibility here as I believe the author of the rust interpreter stated he referenced my Create Your Own TLA+ Tools guide.
Re: Manyan, I ran a 500k campaign on TLC vs. Manyan yesterday. It
uncovered 14 issues [4], e.g., a segfault [5] and memory exhaustion
[6]. These are probably of interest to Ju Lin.
Re: tla-rs, the fuzzer was blocked on a simple parsing issue [7],
which is just produced by the parenthesized TLA+ output via Apalache.
Writing TLA+ parsers is hard.
[1] https://github.com/tlaplus/model-checker-hardening
[2] https://github.com/tlaplus/model-checker-hardening/blob/main/findings/TLC/tlc-022.md
[3] https://github.com/tlaplus/model-checker-hardening/blob/main/findings/apalache-bmc/apalache-bmc-002.md
[4] https://github.com/tlaplus/model-checker-hardening/issues?q=is%3Aissue+state%3Aopen+label%3Amanyan
[5] https://github.com/tlaplus/model-checker-hardening/issues/395
[6] https://github.com/tlaplus/model-checker-hardening/issues/407
[7] https://github.com/fabracht/tla-rs/issues/250
Best,
Igor
On Fri, Nov 20, 2026 at 7:01 PM Andrew Helwer <andrew.helwer@xxxxxxxxx> wrote:
>
> Since this is such a weird case I figured I would see how the tools all handle it:
>
> TLC handles it just fine, without even treating it as a special case; it appropriately isolates evaluation of ENABLED, and TLC handles the priming operator by moving the next state into the current state so the interior ENABLED A functions without any special handling.
> Spectacle unfortunately has a bug here: https://github.com/will62794/spectacle/issues/90
> Apalache does not support ENABLED
> The simple model-checker in my Create Your Own TLA+ Tools guide mis-handles this; this week I was working through & validating it, which was how I first considered the possibility of (ENABLED A)'. It will be fixed soon.
> The two extant vibe-coded TLA+ model-checkers, https://github.com/fabracht/tla-rs and https://github.com/soasme/manyan, both mishandle this case. I might bear some responsibility here as I believe the author of the rust interpreter stated he referenced my Create Your Own TLA+ Tools guide.
>
> So I think it is a good idea to explicitly add a spec that exercises this functionality to the tlaplus/examples, or some future standardized TLA+ interpreter test corpus! It seems Lamport's MCRealTime.tla usage might not be enough to expose differences from TLC in terms of state counts or other more-noticeable failures.
>
> Andrew Helwer
>
> On Thu, Nov 19, 2026 at 4:52 PM Andrew Helwer <andrew.helwer@xxxxxxxxx> wrote:
>>
>> Weird thing I noticed recently is that (ENABLED A)' is a valid TLA+ _expression_. This seems like the closest you can get to writing a legal double-primed _expression_ in TLA+. It has to do with the unique property of the ENABLED operator, which is that it is the only operator in TLA which accepts an action-level argument and transmutes it into a lower state-level _expression_. Every other operator either produces an _expression_ with the same level as its argument (ex. [A]_v, <<A>>_v) or an increased level (ex. P', []P). So this lets us legally write (ENABLED A)', which looks like it should be a double-primed _expression_ (since A is usually action-level) even though it isn't. In contrast, ENABLED (A') is an invalid double-primed _expression_.
>>
>> But what does (ENABLED A)' mean? It's quite interesting because it lets you see two steps ahead of the current state! (ENABLED A)' evaluates to TRUE if, in the next state, ENABLED A is TRUE. So it is looking one step beyond the next state - this is what I meant by being the closest thing you can get to writing a double-primed _expression_ in TLA+.
>>
>> Is (ENABLED A)' actually used anywhere? Surprisingly, yes. Lamport uses it twice in the RealTime modules of Specifying Systems:
>>
>> https://github.com/tlaplus/Examples/blob/334c3983a2f44ac78fce89d1d20aa79ceb3e6987/specifications/SpecifyingSystems/RealTime/RealTime_SS.tla#L5-L8
>> https://github.com/tlaplus/Examples/blob/334c3983a2f44ac78fce89d1d20aa79ceb3e6987/specifications/SpecifyingSystems/RealTime/MCRealTime.tla#L18-L21
>>
>> Both usages have the form:
>>
>> TimerNext(t, A, v, D, E) ==
>> /\ t' = IF <<A>>_v \/ ~(ENABLED <<A>>_v)'
>> THEN 0
>> ELSE t + (now'-now)
>>
>> The way to read this (I think) is that the timer variable t is measuring how long an action has been waiting while still remaining possible, facilitating writing a property like "once this action becomes enabled and remains enabled, it must occur within X amount of time". If something happens which - in the next state - would make an action no longer possible (enabled), then the timer should be canceled (set to 0). For example, if a user cancels a request before it receives a response then the real-time response obligation should be lifted.
>>
>> Anyway, just a weird corner of the language I noticed that was new to me so is perhaps new to you.
>>
>> Andrew Helwer
>
> --
> You received this message because you are subscribed to the Google Groups "tlaplus" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to tlaplus+unsubscribe@xxxxxxxxxxxxxxxx.
> To view this discussion visit https://groups.google.com/d/msgid/tlaplus/CABj%3DxUVfo1ubm9ir8Tuy8AOE9TosP_WqSN_YQ221XC2G1M5qxg%40mail.gmail.com.
--
You received this message because you are subscribed to a topic in the Google Groups "tlaplus" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tlaplus/qhx5kJswAyY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tlaplus+unsubscribe@xxxxxxxxxxxxxxxx.
To view this discussion visit https://groups.google.com/d/msgid/tlaplus/CACooHMC8fyWN-B5h752Sv_8ezZLJZ_ZKgBrpFgQ23qHLjxBe5A%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "tlaplus" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tlaplus+unsubscribe@xxxxxxxxxxxxxxxx.
To view this discussion visit https://groups.google.com/d/msgid/tlaplus/CABj%3DxUUbrj-_y%3DvLSLHktoBd5oGfsY%2BxpQr16WAoLt-fHHrXgw%40mail.gmail.com.