Nondeterminism
Nondeterministically chooses from a collection:
# Choose one value
value = oneof [1, 2, 3, 4, 5]
# Choose with condition
value = oneof [x for x in options if x != previous]
# Choose from range
index = oneof range(10)
Behavior: Model checker explores all possible choices
Important: If no elements match the condition, the action is disabled:
atomic action ProcessLargeValues:
# If all values are <= 10, this action is disabled
x = oneof [1, 2, 3, 4, 5] if x > 10
# This line never executes
Use case: Conditional action enabling based on available choices
# Fair choice (eventually tries all)
fair action Choose:
value = fair oneof options
oneof has two forms. Prefer the concise form — it keeps code flat and readable:
# ✅ Concise form (preferred): assigns and continues
n = oneof nodes
require status[n] == "active"
status[n] = "done"
# Block form: runs indented block for chosen value
oneof n in nodes:
require status[n] == "active"
status[n] = "done"
Both are semantically equivalent. The block form is the older pattern; the concise form avoids unnecessary indentation.
oneof is used in two distinct but related ways:
# 1. Choose a value from a collection (∃ — existential)
x = oneof [1, 2, 3] # picks one value, assigns it
# 2. Choose a branch to execute (∨ — disjunction)
oneof:
x = 1
x = 2
x = 3
Both mean “nondeterministically pick one”. The syntax makes the semantics clear:
x = oneof collection→ pick an element (existential choice)oneof:block → pick a branch (disjunctive choice)
Note: any is a deprecated alias for the existential form (x = oneof collection).
It still works but emits a DeprecationWarning. Prefer oneof.
Any statement for nondeterministic choice from a collection
Demonstrates: any statement, exploring all possibilities
|
|
Expected result (from fizz):
StateSpaceOptions: options:{max_actions:100 max_concurrent_actions:2}
Nodes: 11, queued: 0
Valid Nodes: 11 Unique states: 7
IsLive: true
PASSED: Model checker completed successfully
Nondeterministic choice with filtering
Demonstrates: any with if condition syntax
|
|
Expected result (from fizz):
StateSpaceOptions: options:{max_actions:100 max_concurrent_actions:2}
Nodes: 11, queued: 0
Valid Nodes: 11 Unique states: 7
IsLive: true
PASSED: Model checker completed successfully
Fair choice ensures all values eventually selected
Demonstrates: fair any with liveness assertion
|
|
Expected result (from fizz):
StateSpaceOptions: options:{max_actions:100 max_concurrent_actions:2}
Nodes: 16, queued: 0
Valid Nodes: 16 Unique states: 8
Checking always eventually AllValuesSelected
IsLive: true
PASSED: Model checker completed successfully
Demonstrates: combining any features together
|
|
Expected result (from fizz):
StateSpaceOptions: options:{max_actions:100 max_concurrent_actions:2}
Nodes: 79, queued: 0
Valid Nodes: 79 Unique states: 28
Checking always eventually FairChoiceMade
IsLive: true
PASSED: Model checker completed successfully