[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tlaplus] On (ENABLED A)'



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:
  1. https://github.com/tlaplus/Examples/blob/334c3983a2f44ac78fce89d1d20aa79ceb3e6987/specifications/SpecifyingSystems/RealTime/RealTime_SS.tla#L5-L8
  2. 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%3DxUWEk3hDa%3DBfBNG38a67tjPbGV%3DUTo%3DaebEp4YcY6DwjVw%40mail.gmail.com.