Skip to content

Commit

Permalink
Added Pluscal version of the key-value store with snapshot isolation,…
Browse files Browse the repository at this point in the history
… instantiated clientcentric checking to model check for snapshot isolation properly, added LICENSE for clientcentric module and modified manifest

Signed-off-by: Murat Demirbas <[email protected]>
  • Loading branch information
Murat Demirbas committed Aug 5, 2023
1 parent 386b1f1 commit f4f5984
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 18 deletions.
5 changes: 2 additions & 3 deletions specifications/KeyValueStore/KVsnap.tla
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ variables
define {
\* for instantiating the ClientCentric module
InitialState == [k \in Key |-> NoVal]
IsInjective(f) == \A a,b \in DOMAIN f : f[a] = f[b] => a = b
SetToSeq(S) == CHOOSE f \in [1..Cardinality(S) -> S] : IsInjective(f)

\* snapshot isolation invariant
Expand Down Expand Up @@ -101,12 +100,12 @@ COMMIT: \* Commit the transaction to the database if there is no conflict
}
*)

\* BEGIN TRANSLATION (chksum(pcal) = "38698f36" /\ chksum(tla) = "2d9d1e7d")
\* BEGIN TRANSLATION (chksum(pcal) = "2e9a6c18" /\ chksum(tla) = "5ad2eccd")
VARIABLES store, tx, snapshotStore, written, missed, ops, pc

(* define statement *)
InitialState == [k \in Key |-> NoVal]
IsInjective(f) == \A a,b \in DOMAIN f : f[a] = f[b] => a = b

SetToSeq(S) == CHOOSE f \in [1..Cardinality(S) -> S] : IsInjective(f)


Expand Down
25 changes: 25 additions & 0 deletions specifications/KeyValueStore/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
BSD 2-Clause License for ClientCentric.tla

Copyright (c) 2020, ING Bank / CWI
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 changes: 11 additions & 15 deletions specifications/KeyValueStore/Util.tla
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
-------------------------------- MODULE Util --------------------------------
EXTENDS Sequences, FiniteSets, Naturals, TLC
EXTENDS Sequences, FiniteSets, Functions, Naturals, TLC
\* Simple utility functions
intersects(a, b) == (Cardinality(a \cap b) > 0)
max(s) == CHOOSE i \in s : (~\E j \in s : j > i)
min(s) == CHOOSE i \in s : (~\E j \in s : j < i)

\* Utilies from Practical TLA+
ReduceSet(op(_, _), set, acc) ==
LET f[s \in SUBSET set] == \* here's where the magic is
IF s = {} THEN acc
ELSE LET x == CHOOSE x \in s: TRUE
IN op(x, f[s \ {x}])
IN f[set]
ReduceSeq(op(_, _), seq, acc) ==
ReduceSet(LAMBDA i, a: op(seq[i], a), DOMAIN seq, acc)
\* Pulls an indice of the sequence for elem.
Index(seq, elem) == CHOOSE i \in 1..Len(seq): seq[i] = elem
\* end from Practical TLA+

Range(T) == { T[x] : x \in DOMAIN T }
ReduceSet(op(_, _), set, base) ==
LET iter[s \in SUBSET set] ==
IF s = {} THEN base
ELSE LET x == CHOOSE x \in s: TRUE
IN op(x, iter[s \ {x}])
IN iter[set]

ReduceSeq(op(_, _), seq, acc) == FoldFunction(op, acc, seq)

Index(seq, e) == CHOOSE i \in 1..Len(seq): seq[i] = e

SeqToSet(s) == {s[i] : i \in DOMAIN s}
Last(seq) == seq[Len(seq)]
Expand Down

0 comments on commit f4f5984

Please sign in to comment.