Hi Pavel,
>> For what I see, both Inv and THEOREM can be removed from this file, and the spec will remain rigorous
>> what value does the Inv and THEOREM
bring to this spec, given that it only states a necessary but not
sufficient invariant for consensus?
On Inv being removed:
TypeOK states that
chosen is a finite subset of
Value, so
chosen can be a finite set of any size.
Inv states that
TypeOK is true and that the cardinality of `
chosen` is zero or one.
So TypeOK is weaker than Inv. Should we remove it too?
There's nothing wrong with stating that the spec satisfies “weak” properties.
On THEOREM being removed and rigor:
Some more advanced users might explain it better than I do, but here's my take on proofs and rigor:
A THEOREM statement in a TLA+ specification serves as documentation to state something you believe to be true.
TLC ignores THEOREM statements because theorems can't be proved by model checking or simulation.
TLAPS,
on the other hand, does not ignore THEOREM statements. You can see in the `Consensus.tla` file that there's a proof. This proof must've been checked by TLAPS.
So, in that regard, theorem proofs are the golden standard for rigor, even if these theorems are obvious to us.
Specifications with more proofs are more rigorous than specifications with fewer proofs.
>> can we state a more rigorous property here, instead of Inv, such as: [...]
Sure! What you seem to be trying to express is a liveness property instead of an invariant.
Just be careful not to assert about values in the next state, such as chosen'.
The Consensus module already contains a liveness property: Success.
Success states that chosen eventually isn't empty.
You might say that it doesn't assert about chosen's cardinality, and conclude it's a “weak” property.
So let's define a stricter liveness property: “a single value is eventually chosen and stays chosen”.
StaysChosen == <>[](\E v \in Value: chosen = { v })
To check a liveness property, you must specify liveness properties for your specification.
If your spec doesn't have liveness at all, you can't guarantee something happens: something might happen in some behaviors, nothing at all might happen in others.
In this case, that means the formulas Spec => Success and Spec => StaysChosen are false because they don't have liveness.
We usually specify the liveness of a TLA+ spec by declaring fairness for sub-actions of Next or Next itself.
In this case, Next doesn't contain sub-actions, so we'd declare weak or strong fairness for Next itself.
You can see that Consensus already defines a LiveSpec formula conjoining Spec with weak fairness for Next.
By specifying liveness for Spec, both formulas LiveSpec => Success and LiveSpec => StaysChosen will be true.
Jones