-
Notifications
You must be signed in to change notification settings - Fork 220
Add German cache-coherence protocol example (Murphi > TLA+) #214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4115b7d
Add German cache-coherence protocol example with TLC and Apalache models
lemmy af48e03
Document ABS_RecvInvAck's noninterference conjunct
lemmy 1244293
Towards idiomatic TLA+: Merge shared/exclusive action pairs.
lemmy c0fad65
Simplify exGntd reset on invalidation acknowledgment
lemmy 2a56f7e
Use set difference for distinct-node quantification
lemmy 10fcc1f
Enable node and data symmetry for GermanWithMutex
lemmy 1133ada
Document Apalache commands, bounds, and runtimes
lemmy 6fef511
Strengthen command types in German protocol models
lemmy 4d865af
Represent German directory membership as sets
lemmy 8f1791c
Document CMP abstract-environment actions
lemmy e33fca3
Check GermanCoherence refinement of the CMP abstraction
lemmy 475781d
Rename German models by abstraction level
lemmy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| CONSTANT | ||
| NODE <- NodeVal | ||
| Other <- OtherVal | ||
| NoNode <- NoNodeVal | ||
|
|
||
| INVARIANT | ||
| TypeOK | ||
| Coherence | ||
| Lemma_1 | ||
|
|
||
| SPECIFICATION Spec |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| ----------------------------- MODULE APGerman ----------------------------- | ||
| (* Apalache type annotations for German.tla, applied via INSTANCE so the | ||
| original spec remains free of tool-specific idiosyncrasies. | ||
|
|
||
| Nodes are modelled as an uninterpreted Apalache type (NODE); the abstract | ||
| environment node Other and the NoNode sentinel share that type so that | ||
| `curPtr \in NODE \cup {Other, NoNode}` is well typed. *) | ||
|
|
||
| CONSTANTS | ||
| \* @type: Set(NODE); | ||
| NODE, | ||
| \* @type: NODE; | ||
| Other, | ||
| \* @type: NODE; | ||
| NoNode | ||
|
|
||
| VARIABLES | ||
| \* @type: NODE -> Str; | ||
| cache, | ||
| \* @type: NODE -> Str; | ||
| chan1, | ||
| \* @type: NODE -> Str; | ||
| chan2, | ||
| \* @type: NODE -> Str; | ||
| chan3, | ||
| \* @type: NODE -> Bool; | ||
| invSet, | ||
| \* @type: NODE -> Bool; | ||
| shrSet, | ||
| \* @type: Bool; | ||
| exGntd, | ||
| \* @type: Str; | ||
| curCmd, | ||
| \* @type: NODE; | ||
| curPtr | ||
|
|
||
| INSTANCE German | ||
|
|
||
| \* Concrete values for the constants used by APGerman.cfg. | ||
| NodeVal == { "n1_OF_NODE", "n2_OF_NODE" } | ||
| OtherVal == "other_OF_NODE" | ||
| NoNodeVal == "noNode_OF_NODE" | ||
|
|
||
| ============================================================================== | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| CONSTANT | ||
| NODE <- NodeVal | ||
| NoNode <- NoNodeVal | ||
|
|
||
| INVARIANT | ||
| TypeOK | ||
| Coherence | ||
|
|
||
| SPECIFICATION Spec |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| ------------------------- MODULE APGermanCoherence ------------------------- | ||
| (* Apalache type annotations for GermanCoherence.tla, applied via INSTANCE so | ||
| the original spec remains free of tool-specific idiosyncrasies. | ||
|
|
||
| Nodes are modelled as an uninterpreted Apalache type (NODE); the NoNode | ||
| sentinel shares that type so that `curPtr \in NODE \cup {NoNode}` is well | ||
| typed. *) | ||
|
|
||
| CONSTANTS | ||
| \* @type: Set(NODE); | ||
| NODE, | ||
| \* @type: NODE; | ||
| NoNode | ||
|
|
||
| VARIABLES | ||
| \* @type: NODE -> Str; | ||
| cache, | ||
| \* @type: NODE -> Str; | ||
| chan1, | ||
| \* @type: NODE -> Str; | ||
| chan2, | ||
| \* @type: NODE -> Str; | ||
| chan3, | ||
| \* @type: NODE -> Bool; | ||
| invSet, | ||
| \* @type: NODE -> Bool; | ||
| shrSet, | ||
| \* @type: Bool; | ||
| exGntd, | ||
| \* @type: Str; | ||
| curCmd, | ||
| \* @type: NODE; | ||
| curPtr | ||
|
|
||
| INSTANCE GermanCoherence | ||
|
|
||
| \* Concrete values for the constants used by APGermanCoherence.cfg. | ||
| NodeVal == { "n1_OF_NODE", "n2_OF_NODE" } | ||
| NoNodeVal == "noNode_OF_NODE" | ||
|
|
||
| ============================================================================== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| CONSTANT | ||
| NODE <- NodeVal | ||
| DATA <- DataVal | ||
| NoData <- NoDataVal | ||
| NoNode <- NoNodeVal | ||
|
|
||
| INVARIANT | ||
| TypeOK | ||
| Coherence | ||
| DataProp | ||
| ChannelWellFormed | ||
| TransactionConsistency | ||
| DirectoryAccurate | ||
| ExclusiveIsolation | ||
| WritebackCarriesLatest | ||
|
|
||
| SPECIFICATION Spec |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| ------------------------- MODULE APGermanWithMutex ------------------------- | ||
| (* Apalache type annotations for GermanWithMutex.tla, applied via INSTANCE so | ||
| the original spec remains free of tool-specific idiosyncrasies. | ||
|
|
||
| Nodes and data values are modelled as uninterpreted Apalache types (NODE, | ||
| DATA). The NoNode / NoData sentinels share those types so that the union | ||
| sets in TypeOK are well typed. Only the safety invariants are checked; | ||
| Apalache does not verify the liveness properties (FairSpec) of the spec. *) | ||
|
|
||
| CONSTANTS | ||
| \* @type: Set(NODE); | ||
| NODE, | ||
| \* @type: Set(DATA); | ||
| DATA, | ||
| \* @type: DATA; | ||
| NoData, | ||
| \* @type: NODE; | ||
| NoNode | ||
|
|
||
| VARIABLES | ||
| \* @type: NODE -> { state: Str, data: DATA }; | ||
| cache, | ||
| \* @type: NODE -> { cmd: Str, data: DATA }; | ||
| chan1, | ||
| \* @type: NODE -> { cmd: Str, data: DATA }; | ||
| chan2, | ||
| \* @type: NODE -> { cmd: Str, data: DATA }; | ||
| chan3, | ||
| \* @type: NODE -> Bool; | ||
| invSet, | ||
| \* @type: NODE -> Bool; | ||
| shrSet, | ||
| \* @type: Bool; | ||
| exGntd, | ||
| \* @type: Str; | ||
| curCmd, | ||
| \* @type: NODE; | ||
| curPtr, | ||
| \* @type: DATA; | ||
| memData, | ||
| \* @type: DATA; | ||
| auxData | ||
|
|
||
| INSTANCE GermanWithMutex | ||
|
|
||
| \* Concrete values for the constants used by APGermanWithMutex.cfg. | ||
| NodeVal == { "n1_OF_NODE", "n2_OF_NODE" } | ||
| DataVal == { "d1_OF_DATA", "d2_OF_DATA" } | ||
| NoDataVal == "noData_OF_DATA" | ||
| NoNodeVal == "noNode_OF_NODE" | ||
|
|
||
| ============================================================================== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,175 @@ | ||
| -------------------------------- MODULE German -------------------------------- | ||
|
lemmy marked this conversation as resolved.
Outdated
|
||
| CONSTANTS | ||
| NODE, | ||
| Other, | ||
| NoNode | ||
|
|
||
| ASSUME Other \notin NODE | ||
| ASSUME NoNode \notin NODE /\ NoNode # Other | ||
|
|
||
| CacheState == {"I", "S", "E"} | ||
| MsgCmd == {"Empty", "ReqS", "ReqE", "Inv", "InvAck", "GntS", "GntE"} | ||
|
|
||
| VARIABLES | ||
| cache, chan1, chan2, chan3, invSet, shrSet, exGntd, curCmd, curPtr | ||
|
|
||
| vars == <<cache, chan1, chan2, chan3, invSet, shrSet, exGntd, curCmd, curPtr>> | ||
|
|
||
| ------------------------------------------------------------------------------- | ||
|
|
||
| TypeOK == | ||
| /\ cache \in [NODE -> CacheState] | ||
| /\ chan1 \in [NODE -> MsgCmd] | ||
| /\ chan2 \in [NODE -> MsgCmd] | ||
| /\ chan3 \in [NODE -> MsgCmd] | ||
| /\ invSet \in [NODE -> BOOLEAN] | ||
|
lemmy marked this conversation as resolved.
Outdated
|
||
| /\ shrSet \in [NODE -> BOOLEAN] | ||
| /\ exGntd \in BOOLEAN | ||
| /\ curCmd \in MsgCmd | ||
| /\ curPtr \in NODE \cup {Other, NoNode} | ||
|
|
||
| Init == | ||
| /\ cache = [i \in NODE |-> "I"] | ||
| /\ chan1 = [i \in NODE |-> "Empty"] | ||
| /\ chan2 = [i \in NODE |-> "Empty"] | ||
| /\ chan3 = [i \in NODE |-> "Empty"] | ||
| /\ invSet = [i \in NODE |-> FALSE] | ||
| /\ shrSet = [i \in NODE |-> FALSE] | ||
| /\ exGntd = FALSE | ||
| /\ curCmd = "Empty" | ||
| /\ curPtr = NoNode | ||
|
|
||
| ------------------------------------------------------------------------------- | ||
|
|
||
| SendReq(i) == | ||
| /\ chan1[i] = "Empty" | ||
| /\ \E c \in {"ReqS", "ReqE"} : | ||
| /\ cache[i] \in (IF c = "ReqS" THEN {"I"} ELSE {"I", "S"}) | ||
| /\ chan1' = [chan1 EXCEPT ![i] = c] | ||
| /\ UNCHANGED <<cache, chan2, chan3, invSet, shrSet, exGntd, curCmd, curPtr>> | ||
|
|
||
| RecvReq(i) == | ||
| /\ curCmd = "Empty" | ||
| /\ chan1[i] \in {"ReqS", "ReqE"} | ||
| /\ curCmd' = chan1[i] | ||
| /\ curPtr' = i | ||
| /\ chan1' = [chan1 EXCEPT ![i] = "Empty"] | ||
| /\ invSet' = shrSet | ||
| /\ UNCHANGED <<cache, chan2, chan3, shrSet, exGntd>> | ||
|
|
||
| SendInv(i) == | ||
| /\ chan2[i] = "Empty" | ||
| /\ invSet[i] = TRUE | ||
| /\ (curCmd = "ReqE" \/ (curCmd = "ReqS" /\ exGntd = TRUE)) | ||
| /\ chan2' = [chan2 EXCEPT ![i] = "Inv"] | ||
| /\ invSet' = [invSet EXCEPT ![i] = FALSE] | ||
| /\ UNCHANGED <<cache, chan1, chan3, shrSet, exGntd, curCmd, curPtr>> | ||
|
|
||
| SendInvAck(i) == | ||
| /\ chan2[i] = "Inv" | ||
| /\ chan3[i] = "Empty" | ||
| /\ chan2' = [chan2 EXCEPT ![i] = "Empty"] | ||
| /\ chan3' = [chan3 EXCEPT ![i] = "InvAck"] | ||
| /\ cache' = [cache EXCEPT ![i] = "I"] | ||
| /\ UNCHANGED <<chan1, invSet, shrSet, exGntd, curCmd, curPtr>> | ||
|
|
||
| RecvInvAck(i) == | ||
| /\ chan3[i] = "InvAck" | ||
| /\ curCmd # "Empty" | ||
| /\ chan3' = [chan3 EXCEPT ![i] = "Empty"] | ||
| /\ shrSet' = [shrSet EXCEPT ![i] = FALSE] | ||
| /\ exGntd' = IF exGntd = TRUE THEN FALSE ELSE exGntd | ||
|
lemmy marked this conversation as resolved.
Outdated
|
||
| /\ UNCHANGED <<cache, chan1, chan2, invSet, curCmd, curPtr>> | ||
|
|
||
| SendGnt(i) == | ||
| /\ curCmd \in {"ReqS", "ReqE"} | ||
| /\ curPtr = i | ||
| /\ chan2[i] = "Empty" | ||
| /\ exGntd = FALSE | ||
| /\ curCmd = "ReqE" => \A j \in NODE : shrSet[j] = FALSE | ||
| /\ chan2' = [chan2 EXCEPT ![i] = IF curCmd = "ReqS" THEN "GntS" ELSE "GntE"] | ||
| /\ shrSet' = [shrSet EXCEPT ![i] = TRUE] | ||
| /\ exGntd' = (curCmd = "ReqE") | ||
| /\ curCmd' = "Empty" | ||
| /\ curPtr' = NoNode | ||
| /\ UNCHANGED <<cache, chan1, chan3, invSet>> | ||
|
|
||
| RecvGnt(i) == | ||
| /\ chan2[i] \in {"GntS", "GntE"} | ||
| /\ cache' = [cache EXCEPT ![i] = IF chan2[i] = "GntS" THEN "S" ELSE "E"] | ||
| /\ chan2' = [chan2 EXCEPT ![i] = "Empty"] | ||
| /\ UNCHANGED <<chan1, chan3, invSet, shrSet, exGntd, curCmd, curPtr>> | ||
|
|
||
| ------------------------------------------------------------------------------- | ||
|
|
||
| ABS_RecvReq == | ||
| /\ curCmd = "Empty" | ||
| /\ \E c \in {"ReqS", "ReqE"} : curCmd' = c | ||
| /\ curPtr' = Other | ||
| /\ invSet' = shrSet | ||
| /\ UNCHANGED <<cache, chan1, chan2, chan3, shrSet, exGntd>> | ||
|
|
||
| ABS_SendGnt == | ||
| /\ curCmd \in {"ReqS", "ReqE"} | ||
| /\ curPtr = Other | ||
| /\ exGntd = FALSE | ||
| /\ curCmd = "ReqE" => \A j \in NODE : shrSet[j] = FALSE | ||
| /\ exGntd' = (curCmd = "ReqE") | ||
| /\ curCmd' = "Empty" | ||
| /\ curPtr' = NoNode | ||
| /\ UNCHANGED <<cache, chan1, chan2, chan3, invSet, shrSet>> | ||
|
|
||
| \* Other acknowledges relinquishing its exclusive copy. Guarded (as in | ||
| \* german.m) so it only fires when no concrete node is exclusive / mid-grant / | ||
| \* mid-ack -- the noninterference condition that keeps the abstraction sound. | ||
| ABS_RecvInvAck == | ||
| /\ curCmd # "Empty" | ||
| /\ exGntd = TRUE | ||
| \* Operational form of the mutual-exclusion noninterference lemma ("Lemma_1" | ||
| \* of Chou, Mannava & Park, FMCAD 2004 = ref [11] of Sethi, Talupur & Malik, | ||
| \* arXiv:1407.7468, whose online models these are). germanWithMutex.m is the | ||
| \* CMP-strengthened abstraction that conjoins this guard onto absRecvInvAck; | ||
| \* germanNoMutex.m omits it on purpose -- the deadlock-study model that needs | ||
| \* no noninterference lemma -- so it admits the spurious "bogus InvAck from | ||
| \* Other" counterexample to mutual exclusion. Dropping this one conjunct makes | ||
| \* German.tla bisimilar to germanNoMutex.m. | ||
| /\ \A j \in NODE : | ||
| /\ cache[j] # "E" | ||
| /\ chan2[j] # "GntE" | ||
| /\ chan3[j] # "InvAck" | ||
| /\ exGntd' = FALSE | ||
| /\ UNCHANGED <<cache, chan1, chan2, chan3, invSet, shrSet, curCmd, curPtr>> | ||
|
|
||
| ------------------------------------------------------------------------------- | ||
|
|
||
| Next == | ||
| \/ \E i \in NODE : | ||
| \/ SendReq(i) | ||
| \/ RecvReq(i) | ||
| \/ SendInv(i) \/ SendInvAck(i) \/ RecvInvAck(i) | ||
| \/ SendGnt(i) | ||
| \/ RecvGnt(i) | ||
| \/ ABS_RecvReq | ||
| \/ ABS_SendGnt | ||
| \/ ABS_RecvInvAck | ||
|
|
||
| Spec == Init /\ [][Next]_vars | ||
|
|
||
| ------------------------------------------------------------------------------- | ||
|
|
||
| Coherence == | ||
| \A i, j \in NODE : | ||
| i # j => | ||
| /\ (cache[i] = "E" => cache[j] = "I") | ||
| /\ (cache[i] = "S" => cache[j] \in {"I", "S"}) | ||
|
|
||
| Lemma_1 == | ||
| \A i \in NODE : | ||
| (chan3[i] = "InvAck" /\ curCmd # "Empty" /\ exGntd = TRUE) => | ||
| \A j \in NODE : | ||
|
lemmy marked this conversation as resolved.
Outdated
|
||
| j # i => | ||
| /\ cache[j] # "E" | ||
| /\ chan2[j] # "GntE" | ||
| /\ chan3[j] # "InvAck" | ||
|
|
||
| ============================================================================= | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.