@@ -94,7 +94,8 @@ partial def scanOnce {ρ σ κ : Type} {th₀ : ρ}
9494 scanOnceLoop sys params th maxSteps initSt gen
9595
9696
97- /-- Full trace loop: walk and record every step for counterexample.
97+ /-- Inner loop of a single random trace: walk from `currSt` for up to
98+ `stepsLeft` steps, picking a random enabled transition at each step.
9899Returns `(violation?, updatedRng, stepsTaken)`. Used only for replay. -/
99100@ [inline, specialize]
100101partial def simulateOnceLoop {ρ σ κ : Type } {th₀ : ρ}
@@ -111,6 +112,7 @@ partial def simulateOnceLoop {ρ σ κ : Type} {th₀ : ρ}
111112 | 0 => (none, gen, 0 )
112113 | stepsLeft + 1 =>
113114 let outcomes := sys.tr th currSt
115+ -- Check assertion failures first (highest priority)
114116 let assertionFailures := outcomes.filterMap fun (_, outcome) =>
115117 match outcome with
116118 | .assertionFailure exId _ => some exId
@@ -129,6 +131,7 @@ partial def simulateOnceLoop {ρ σ κ : Type} {th₀ : ρ}
129131 let nexts := Concrete.extractSuccessfulTransitions outcomes
130132 if nexts.isEmpty then
131133 if !params.terminating.holdsOn th currSt then
134+ -- No enabled transitions and not a terminating state: deadlock
132135 (some (.foundViolation () .deadlock (some trace)), gen, trace.steps.size)
133136 else
134137 (none, gen, trace.steps.size)
@@ -144,7 +147,8 @@ partial def simulateOnceLoop {ρ σ κ : Type} {th₀ : ρ}
144147 simulateOnceLoop sys params th stepsLeft nextSt trace gen
145148
146149
147- /-- Full trace run from random init state. Used only for replay. -/
150+ /-- Run a single random trace from a randomly chosen initial state.
151+ Returns `(violation?, updatedRng, stepsTaken)`. Used only for replay. -/
148152@ [inline, specialize]
149153partial def simulateOnce {ρ σ κ : Type } {th₀ : ρ}
150154 (sys : EnumerableTransitionSystem ρ (List ρ) σ (List σ) Int κ (List (κ × ExecutionOutcome Int σ)) th₀)
0 commit comments