-
Notifications
You must be signed in to change notification settings - Fork 217
TLCMC: non-strict BFS, BFS level tracking, state constraints, and refinement to MCReachability. #204
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
Open
lemmy
wants to merge
3
commits into
master
Choose a base branch
from
mku-TLCMultipleWorkers
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
TLCMC: non-strict BFS, BFS level tracking, state constraints, and refinement to MCReachability. #204
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,158 @@ | ||
| ---------------------------- MODULE MCReachability ---------------------------- | ||
| EXTENDS Naturals, Sequences, TLC | ||
| (***************************************************************************) | ||
| (* High-level specification of a state-graph explorer that does NOT *) | ||
| (* enforce BFS ordering. The frontier S is a set and the next state *) | ||
| (* to explore is chosen non-deterministically from S. *) | ||
| (***************************************************************************) | ||
|
|
||
| (***************************************************************************) | ||
| (* A (state) graph G is a directed graph represented by a record with *) | ||
| (* 'states', 'initials', and 'actions' components. *) | ||
| (* *) | ||
| (* The CommunityModules Graphs.tla module is not used here because its *) | ||
| (* representation [node, edge] differs from ours: we use an adjacency *) | ||
| (* function (actions \in [states -> SUBSET states]) rather than an *) | ||
| (* explicit edge set (edge \subseteq node \X node), and carry a *) | ||
| (* distinguished 'initials' component that Graphs.tla does not model. *) | ||
| (***************************************************************************) | ||
| IsGraph(G) == /\ {"states", "initials", "actions"} = DOMAIN G | ||
| /\ G.actions \in [G.states -> SUBSET G.states] | ||
| /\ G.initials \subseteq G.states | ||
|
|
||
| (***************************************************************************) | ||
| (* Successor states of s, excluding self-loops. *) | ||
| (***************************************************************************) | ||
| SuccessorsOf(s, SG) == {t \in SG.actions[s] : t # s} | ||
|
|
||
| (***************************************************************************) | ||
| (* The predecessor of v in a spanning tree t (a set of *) | ||
| (* <<predecessor, successor>> pairs) is the first element of the *) | ||
| (* unique pair whose second element equals v. *) | ||
| (***************************************************************************) | ||
| Predecessor(t, v) == (CHOOSE pair \in t : pair[2] = v)[1] | ||
|
|
||
| CONSTANT StateGraph, ViolationStates | ||
|
|
||
| ASSUME /\ IsGraph(StateGraph) | ||
| /\ ViolationStates \subseteq StateGraph.states | ||
|
|
||
| VARIABLES S, \* Frontier: set of states yet to explore | ||
| C, \* Set of visited states | ||
| T, \* Set of <<predecessor, successor>> pairs (spanning tree) | ||
| L, \* BFS level of each state that has been assigned a level | ||
| successors, \* Triples <<lvl, t, s>> still to process for the current | ||
| \* Explore step: t is the successor at BFS level lvl, | ||
| \* s is the predecessor that generated it. | ||
| done, \* TRUE after violation or deadlock detected | ||
| counterexample \* Path from initial state to violation/deadlock state | ||
|
|
||
| vars == <<S, C, successors, done, T, counterexample, L>> | ||
|
|
||
| Init == /\ S = StateGraph.initials | ||
| /\ C = {} | ||
| /\ successors = {} | ||
| /\ done = FALSE | ||
| /\ T = {} | ||
| /\ counterexample = <<>> | ||
| /\ L = [s \in {} |-> 0] | ||
|
|
||
| --------------------------------------------------------------------------- | ||
|
|
||
| (***************************************************************************) | ||
| (* Check an initial state for a safety violation. *) | ||
| (***************************************************************************) | ||
| InitCheck == | ||
| /\ ~done | ||
| /\ successors = {} | ||
| /\ \E s \in S \ C : | ||
| /\ C' = C \cup {s} | ||
| /\ L' = (s :> 0) @@ L | ||
| /\ done' = (s \in ViolationStates) | ||
| /\ counterexample' = IF s \in ViolationStates | ||
| THEN <<s>> ELSE counterexample | ||
| /\ UNCHANGED <<S, successors, T>> | ||
|
|
||
| --------------------------------------------------------------------------- | ||
|
|
||
| (***************************************************************************) | ||
| (* Pick any state from the frontier S for exploration. The next state *) | ||
| (* is chosen non-deterministically (\E s \in S), so no ordering is *) | ||
| (* imposed on the exploration. Predecessor pairs for all new successors *) | ||
| (* are added to T here. *) | ||
| (***************************************************************************) | ||
| Explore == | ||
| /\ ~done | ||
| /\ successors = {} | ||
| /\ S \subseteq C | ||
| /\ S # {} | ||
| /\ \E s \in S : | ||
| LET succs == SuccessorsOf(s, StateGraph) \ C | ||
| lvl == L[s] + 1 | ||
| IN /\ S' = S \ {s} | ||
| /\ successors' = {<<lvl, t, s>> : t \in succs} | ||
| /\ T' = T \cup {<<s, t>> : t \in succs} | ||
| /\ done' = (SuccessorsOf(s, StateGraph) = {}) | ||
| /\ counterexample' = IF SuccessorsOf(s, StateGraph) = {} | ||
| THEN <<s>> ELSE counterexample | ||
| /\ UNCHANGED <<C, L>> | ||
|
|
||
| --------------------------------------------------------------------------- | ||
|
|
||
| (***************************************************************************) | ||
| (* Process one successor: mark visited, add to frontier, check violation. *) | ||
| (***************************************************************************) | ||
| Each == | ||
| /\ ~done | ||
| /\ successors # {} | ||
| /\ \E succ \in successors : | ||
| /\ successors' = successors \ {succ} | ||
| /\ C' = C \cup {succ[2]} | ||
| /\ S' = S \cup {succ[2]} | ||
| /\ L' = (succ[2] :> succ[1]) @@ L | ||
| /\ done' = (succ[2] \in ViolationStates) | ||
| /\ counterexample' = IF succ[2] \in ViolationStates | ||
| THEN <<succ[3], succ[2]>> ELSE counterexample | ||
| /\ UNCHANGED T | ||
|
|
||
| --------------------------------------------------------------------------- | ||
|
|
||
| (***************************************************************************) | ||
| (* Trace reconstruction: walk backward through T, prepending *) | ||
| (* predecessors to the counterexample until an initial state is reached. *) | ||
| (***************************************************************************) | ||
| Trc == | ||
| /\ done | ||
| /\ counterexample # <<>> | ||
| /\ Head(counterexample) \notin StateGraph.initials | ||
| /\ counterexample' = <<Predecessor(T, Head(counterexample))>> | ||
| \o counterexample | ||
| /\ UNCHANGED <<S, C, successors, done, T, L>> | ||
|
|
||
| --------------------------------------------------------------------------- | ||
|
|
||
| Terminating == done /\ UNCHANGED vars | ||
|
|
||
| Next == | ||
| \/ InitCheck | ||
| \/ Explore | ||
| \/ Each | ||
| \/ Trc | ||
| \/ Terminating | ||
|
|
||
| Spec == | ||
| /\ Init /\ [][Next]_vars | ||
| /\ WF_vars(Next) | ||
|
|
||
| Termination == <>(done \/ (S = {} /\ successors = {})) | ||
|
|
||
| (***************************************************************************) | ||
| (* If violation states exist, the explorer eventually finds one and *) | ||
| (* constructs a valid counterexample path from an initial state to it. *) | ||
| (***************************************************************************) | ||
| Live == ViolationStates # {} => | ||
| <>[](/\ counterexample # <<>> | ||
| /\ counterexample[Len(counterexample)] \in ViolationStates | ||
| /\ counterexample[1] \in StateGraph.initials) | ||
|
|
||
| ============================================================================= | ||
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.