Skip to content

Commit

Permalink
Streamline operator names.
Browse files Browse the repository at this point in the history
  • Loading branch information
lemmy committed Feb 22, 2023
1 parent e5700b6 commit c60e5a7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions modules/VectorClocks.tla
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ LOCAL happenedBefore(v1, v2) ==
/\ \A i \in DOMAIN v1: v1[i] <= v2[i]
/\ \E i \in DOMAIN v1: v1[i] < v2[i]

IsCausallyOrdered(log, clock(_)) ==
IsCausalOrder(log, clock(_)) ==
\A i \in 1..Len(log) :
\A j \in 1..(i - 1) :
\* Align the vector clocks to the same domain (mapping
Expand All @@ -24,7 +24,7 @@ IsCausallyOrdered(log, clock(_)) ==
vcj == Fill(clock(log[j]), D)
IN happenedBefore(vcj, vci) \/ concurrent(vcj, vci)

SortCausally(log, clock(_), node(_), domain(_)) ==
CausalOrder(log, clock(_), node(_), domain(_)) ==
(*
Sort the provided log by the vector clock values indicated on each line
of the log. This operator cannot accommodate "hidden" events, meaning
Expand All @@ -49,7 +49,7 @@ SortCausally(log, clock(_), node(_), domain(_)) ==
...
]
SortCausally(log,
CausalOrder(log,
LAMBDA line: line.pkt.vc,
LAMBDA line: line.node,
LAMBDA vc : DOMAIN vc)
Expand All @@ -58,6 +58,6 @@ SortCausally(log, clock(_), node(_), domain(_)) ==
{ f \in
[ 1..Len(log) -> Range(log)] :
Range(f) = Range(log) } :
IsCausallyOrdered(newlog, clock)
IsCausalOrder(newlog, clock)

===============================================================================
4 changes: 2 additions & 2 deletions modules/tlc2/overrides/VectorClocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ public Value delete() {
* https://github.com/DistributedClocks/shiviz/blob/
* ff02d48ed2bcda065f326aa25409cb317be9feb9/js/model/modelGraph.js
*/
@TLAPlusOperator(identifier = "SortCausally", module = "VectorClocks", warn = false)
public static Value SortCausally(final TupleValue v, final Applicable opClock, final Applicable opNode,
@TLAPlusOperator(identifier = "CausalOrder", module = "VectorClocks", warn = false)
public static Value causalOrder(final TupleValue v, final Applicable opClock, final Applicable opNode,
final Applicable opDomain) {

// A1) Sort each node's individual log which can be totally ordered.
Expand Down
22 changes: 11 additions & 11 deletions tests/VectorClocksTests.tla
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ EXTENDS VectorClocks, Sequences, Naturals, TLC, Json

ASSUME LET T == INSTANCE TLC IN T!PrintT("VectorClocksTests")

ASSUME IsCausallyOrdered(<< >>, LAMBDA l: l)
ASSUME IsCausallyOrdered(<< <<0,0>> >>, LAMBDA l: l)
ASSUME IsCausallyOrdered(<< <<0,0>>, <<0,1>> >>, LAMBDA l: l) \* happened before
ASSUME IsCausallyOrdered(<< <<1,0>>, <<0,1>> >>, LAMBDA l: l) \* concurrent
ASSUME IsCausalOrder(<< >>, LAMBDA l: l)
ASSUME IsCausalOrder(<< <<0,0>> >>, LAMBDA l: l)
ASSUME IsCausalOrder(<< <<0,0>>, <<0,1>> >>, LAMBDA l: l) \* happened before
ASSUME IsCausalOrder(<< <<1,0>>, <<0,1>> >>, LAMBDA l: l) \* concurrent

ASSUME IsCausallyOrdered(<< <<0>>, <<0,1>> >>, LAMBDA l: l) \* happened before
ASSUME IsCausallyOrdered(<< <<1>>, <<0,1>> >>, LAMBDA l: l) \* concurrent
ASSUME IsCausalOrder(<< <<0>>, <<0,1>> >>, LAMBDA l: l) \* happened before
ASSUME IsCausalOrder(<< <<1>>, <<0,1>> >>, LAMBDA l: l) \* concurrent

ASSUME ~IsCausallyOrdered(<< <<0,1>>, <<0,0>> >>, LAMBDA l: l)
ASSUME ~IsCausalOrder(<< <<0,1>>, <<0,0>> >>, LAMBDA l: l)

ASSUME ~IsCausallyOrdered(<< <<1>>, <<0,0>> >>, LAMBDA l: l) \* concurrent
ASSUME ~IsCausalOrder(<< <<1>>, <<0,0>> >>, LAMBDA l: l) \* concurrent

Log ==
ndJsonDeserialize("tests/VectorClocksTests.ndjson")
Expand All @@ -28,10 +28,10 @@ Node(l) ==
\* into a function with domain {0, 1}.
ToString(l.node)

ASSUME ~IsCausallyOrdered(Log, VectorClock)
ASSUME ~IsCausalOrder(Log, VectorClock)

ASSUME IsCausallyOrdered(
SortCausally(Log,
ASSUME IsCausalOrder(
CausalOrder(Log,
VectorClock,
Node,
LAMBDA vc: DOMAIN vc),
Expand Down

0 comments on commit c60e5a7

Please sign in to comment.