TLA+ Specification

This commit is contained in:
Jeremy Wall 2022-11-26 18:13:23 -05:00
parent 44121516fc
commit d0faf6ffe1
6 changed files with 79 additions and 0 deletions

3
.gitignore vendored
View File

@ -4,3 +4,6 @@
/target
/Cargo.lock
tla/*.old
tla/*.out
tla/states

12
tla/check.cfg Normal file
View 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
View File

@ -0,0 +1,4 @@
---- MODULE check ----
EXTENDS TLC, dag
====

40
tla/dag.tla Normal file
View 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
View 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
View 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
====