mirror of
https://github.com/zaphar/merkle-dag.git
synced 2025-07-22 18:50:13 -04:00
TLA+ Specification
This commit is contained in:
parent
44121516fc
commit
d0faf6ffe1
3
.gitignore
vendored
3
.gitignore
vendored
@ -4,3 +4,6 @@
|
||||
|
||||
/target
|
||||
/Cargo.lock
|
||||
tla/*.old
|
||||
tla/*.out
|
||||
tla/states
|
12
tla/check.cfg
Normal file
12
tla/check.cfg
Normal file
@ -0,0 +1,12 @@
|
||||
CONSTANT
|
||||
Null = Null
|
||||
NumNodes = 2
|
||||
|
||||
SPECIFICATION
|
||||
Spec
|
||||
|
||||
\* PROPERTY
|
||||
\* Uncomment the previous line and add property names
|
||||
|
||||
\* INVARIANT
|
||||
\* Uncomment the previous line and add invariant names
|
4
tla/check.tla
Normal file
4
tla/check.tla
Normal file
@ -0,0 +1,4 @@
|
||||
---- MODULE check ----
|
||||
EXTENDS TLC, dag
|
||||
|
||||
====
|
40
tla/dag.tla
Normal file
40
tla/dag.tla
Normal file
@ -0,0 +1,40 @@
|
||||
---- MODULE dag ----
|
||||
EXTENDS TLC, Integers
|
||||
CONSTANT
|
||||
NumNodes, Null
|
||||
|
||||
Nodes == 1..NumNodes
|
||||
|
||||
VARIABLE graph, pc, tmp, edges
|
||||
|
||||
vars == << graph, pc, tmp, edges >>
|
||||
|
||||
Init == /\ graph = {}
|
||||
/\ pc = "GetEdge"
|
||||
/\ tmp = Null
|
||||
/\ edges = {x \in (Nodes \X Nodes): x[1] # x[2]}
|
||||
|
||||
GetEdge == /\ tmp = Null
|
||||
/\ \/ /\ graph = {}
|
||||
/\ tmp' = Null
|
||||
\/ tmp' = CHOOSE e \in edges: (e \notin graph /\ e[1] # e[2])
|
||||
/\ edges' = edges \ {tmp'}
|
||||
/\ pc' = "AddEdge"
|
||||
/\ UNCHANGED graph
|
||||
|
||||
AddEdge == /\ tmp # Null
|
||||
/\ graph' = (graph \union {tmp})
|
||||
/\ pc' = "Done"
|
||||
/\ tmp' = Null
|
||||
/\ UNCHANGED edges
|
||||
|
||||
Terminating == /\ pc = "Done"
|
||||
/\ UNCHANGED vars
|
||||
|
||||
Next == \/ GetEdge \/ AddEdge
|
||||
\/ Terminating
|
||||
|
||||
Termination == <>(pc = "Done")
|
||||
|
||||
Spec == Init /\ [][Next]_vars
|
||||
====
|
10
tla/scratch.cfg
Normal file
10
tla/scratch.cfg
Normal file
@ -0,0 +1,10 @@
|
||||
SPECIFICATION
|
||||
Eval
|
||||
\* Uncomment the previous line and provide the specification name if it's declared
|
||||
\* in the specification file. Comment INIT / NEXT parameters if you use SPECIFICATION.
|
||||
|
||||
\* PROPERTY
|
||||
\* Uncomment the previous line and add property names
|
||||
|
||||
\* INVARIANT
|
||||
\* Uncomment the previous line and add invariant names
|
10
tla/scratch.tla
Normal file
10
tla/scratch.tla
Normal file
@ -0,0 +1,10 @@
|
||||
---- MODULE scratch ----
|
||||
EXTENDS TLC, Integers
|
||||
LOCAL INSTANCE Naturals
|
||||
LOCAL INSTANCE Sequences
|
||||
|
||||
Boolean == {TRUE, FALSE}
|
||||
Node == 1..10
|
||||
GraphType == [Node \X Node -> Boolean]
|
||||
Eval == GraphType
|
||||
====
|
Loading…
x
Reference in New Issue
Block a user