Open lemmy opened 3 years ago
Thanks! I will fix that.
Another example of the same problem:
apalache check crdt.tla
gives me
PASS #1: ConfigurationPass I@16:59:52.550
> crdt.cfg: Loading TLC configuration I@16:59:52.554
Operator Spec of 0 arguments is defined as: (Init() ∧ ☐([Next()]_vars())) ∧ (WF_vars()(DeliverOnNode())) E@16:59:52.663
Configuration error (see the manual): crdt.cfg: Expected Spec to be in the canonical form Init /\ [][Next]_vars /\ ... E@16:59:52.666
crdt.tla
---- MODULE crdt ----
EXTENDS TLC, FiniteSets, Naturals, Sequences
CONSTANTS MAX_TIMESTAMP, KEYS, VALUES, N_NODES
VARIABLES timestamp, values, deliverQueues
vars == <<timestamp, values, deliverQueues>>
nodeIds == 1..N_NODES
DeliverSet(n, t, k, v) ==
LET previous == { <<tp, kp, vp>> \in values[n]: kp = k } IN
IF previous = {} \/ \A <<tp, kp, vp>> \in previous : tp < t THEN
values' = [ values EXCEPT ![n] = (values[n] \ previous) \union {<<t, k, v>>} ]
ELSE
UNCHANGED values
DeliverDelete(n, t) ==
values' = [values EXCEPT ![n] = {<<tp, k, v>> \in values[n] : tp /= t }]
Deliver(n, command, payload) ==
\/ command = "set"
/\ DeliverSet(n, payload[1], payload[2], payload[3])
\/ command = "delete"
/\ DeliverDelete(n, payload)
Broadcast(n, command, payload) ==
/\ Deliver(n, command, payload)
/\ deliverQueues' = [
i \in nodeIds |->
IF i = n THEN
deliverQueues[i]
ELSE
Append(deliverQueues[i], <<command, payload>>)
]
RequestSet(n, k, v) ==
/\ timestamp' = timestamp + 1
/\ Broadcast(n, "set", <<timestamp, k, v>>)
RequestDelete(n, k) ==
\E <<t, kp, v>> \in values[n] :
/\ kp = k
/\ Broadcast(n, "delete", t)
RequestSetOnNode ==
/\ timestamp < MAX_TIMESTAMP
/\ \E <<n, k, v>> \in nodeIds \X KEYS \X VALUES : RequestSet(n, k, v)
RequestDeleteOnNode ==
/\ \E <<n, k>> \in nodeIds \X KEYS : RequestDelete(n, k)
/\ UNCHANGED timestamp
DeliverOnNode ==
\E n \in nodeIds :
/\ Len(deliverQueues[n]) > 0
/\ \E <<command, payload>> \in {Head(deliverQueues[n])} :
Deliver(n, command, payload)
/\ deliverQueues' = [deliverQueues EXCEPT ![n] = Tail(deliverQueues[n])]
/\ UNCHANGED timestamp
DeliverQueuesIsEmpty ==
\A n \in nodeIds: Len(deliverQueues[n]) = 0
Terminating ==
/\ DeliverQueuesIsEmpty
/\ UNCHANGED vars
Init ==
/\ values = [i \in nodeIds |-> {}]
/\ deliverQueues = [i \in nodeIds |-> <<>>]
/\ timestamp = 1
Next ==
\/ RequestSetOnNode
\/ RequestDeleteOnNode
\/ DeliverOnNode
\/ Terminating
Spec == Init /\ [][Next]_vars /\ WF_vars(DeliverOnNode)
AllValuesEqual ==
\A <<n1, n2>> \in nodeIds \X nodeIds :
values[n1] = values[n2]
EventuallyConsistent == <>[]AllValuesEqual
====
crdt.cfg
SPECIFICATION Spec
CONSTANTS
MAX_TIMESTAMP = 3
KEYS = {key}
VALUES = {value}
N_NODES = 2
PROPERTIES
EventuallyConsistent
We are going to fix several bugs for the specs mentioned here and cut a new release on Monday
This is fixed now and will be included in the release (today). @lemmy, @Alexander-N, if you have further problems with your specs, open an issue or we could chat on zulip.
The current fix is too narrow:
---- MODULE M ----
EXTENDS Integers
VARIABLE
\* @type: Int;
x
Init ==
x = 0
Next ==
x' \in 0..42
\* No problem if F is in-lined.
F ==
WF_x(Next)
\* Fails with Configuration error (see the manual): M.cfg: Expected Spec to be in the canonical form Init /\ [][Next]_vars /\ ... E@10:51:44.946
SpecF1== Init /\ [][Next]_x /\ F \* This is not uncommon
SpecF2 == x = 0 /\ [][Next]_x /\ WF_x(Next)
SpecF3 == Init /\ [][x' \in 0..42]_x /\ WF_x(Next)
\* Works
SpecW1 == Init /\ [][Next]_x /\ WF_x(Next)
SpecW2 == Init /\ [][Next]_x /\ WF_x(x' \in 0..42) \* Compare SpecF3
====
APALACHE version 0.15.7-SNAPSHOT build v0.15.6-11-g95c1068
Btw. it would be nice if --config=SomeConfigFile.cfg
could be --config SomeConfigFile.cfg
to make the shell's tab-completion work.
Yeah, you are right. We should fix the spec. As for the --config
, we are using an option parser that works that way. Still looking for a good replacement :(
This specification
Spec == /\ Init /\ [][Next]_vars
/\ \A self \in servers : WF_vars(server(self))
Produced by translaction of this PlusCal algorithm
-------------------------- MODULE mod --------------------------
CONSTANT
\* @type: Int;
defaultInitValue,
\* @type: Set(SERVER);
servers
VARIABLES
\* @type: SERVER -> Str;
pc,
\* @type: Int;
s
Inv == TRUE
(*--algorithm main
variables s;
fair process server \in servers
begin
Start:
s := 1;
end process;
end algorithm; *)
=====================================================================
Also gives the same error when checked with config mod.cfg
SPECIFICATION Spec
CONSTANT
defaultInitValue = 0
servers = { "s1_OF_SERVER", "s2_OF_SERVER" }
INVARIANT Inv
apalache-mc check --config=mod.cfg mod.tla
The example below has been fixed. For a follow up, see https://github.com/informalsystems/apalache/issues/468#issuecomment-853259723