The one-run theorem (Confluent.one_run)
Lean: GPUProof/OneRun.lean.
Scope. Every type α, step relation r, relation e and set Bad. Nothing here is about kernels.
It is Newman's random descent with an equivalence and a bad set (van Oostrom and Toyama, FSCD 2016); not
a new principle.
Statement
Path r n a z: a run of exactly n steps of r from a to z. Normal r z: z has no step.
Hypothesis h : Confluent r e Bad:
eis an equivalence (refl,symm,trans);eis a simulation forr(bisim):e a a'andr a bgiveb'withr a' b'ande b b';Badis closed undere(bad_eqv) and under steps (bad_step);- the one-step diamond (
diamond): stepsr a bandr a cgivee b c, or bothBad bandBad c, ord,d'withr b d,r c d'and eithere d d'or bothBad dandBad d'.
The alternative Bad b ∧ Bad c is for T2 (schedule.md, S1): two conflicting steps of a grid
give two grids that are bad at once, from which the other step may fault rather than step.
Further hypotheses: hp : Path r n a z, hz : Normal r z, hb : ¬ Bad z.
Conclusions:
Acc (fun b a => r a b) a: every run fromais finite;- no state reachable from
ais bad; - every normal state reachable from
aise-equivalent toz; - every state
greachable fromahas a run ofm ≤ nsteps to somez'withe z z'.
The diamond must be the one-step form. Plain confluence is not enough: s → s and s → done is confluent
and has an infinite run.
Proof
A (normal_eqv). If e a a' and a is normal, so is a': a step r a' b gives, by bisim with
e a' a, a step from a.
B (path_eqv). If Path r n a z and e a a', then Path r n a' z' with e z z', by induction on the
path, using bisim at each step.
C (bad_path). If Path r n a z and Bad a, then Bad z, by induction, using bad_step.
Key lemma (key). If Path r n a z, z is normal and not bad, e a a' and r a' b, then n = m + 1
and Path r m b z' with e z z'. The proof is by induction on n.
n = 0: thena = z, soa'is normal by A, which contradictsr a' b.n + 1: the run isr a a₁followed byPath r n a₁ z.bisimgivesr a' a₁'withe a₁ a₁'. The diamond onr a' bandr a' a₁'gives four cases.e b a₁': thene a₁ b, and B onPath r n a₁ zgivesPath r n b z''withe z z''.r b dandr a₁' d'withe d d': the induction hypothesis onPath r n a₁ z, withe a₁ a₁'andr a₁' d', givesn = m + 1andPath r m d' z''withe z z''. B, withe d' d, givesPath r m d z₃withe z'' z₃. SoPath r (m + 1) b z₃,n + 1 = (m + 1) + 1, ande z z₃.Bad a₁'(withBad b): B onPath r n a₁ zwithe a₁ a₁'givesPath r n a₁' z''withe z z''. C givesBad z'', andbad_eqvgivesBad z, which contradictshb.r b dandr a₁' d'withBad d': the induction hypothesis givesPath r m d' z''withe z z''. C givesBad z'', andbad_eqvgivesBad z, which contradictshb.
Termination (acc). By induction on n. For n = 0, a = z has no step. For n + 1, every step
r a b gives, by the key lemma with e a a, Path r n b z' with e z z'. z' is normal (A) and not bad
(bad_eqv), so the induction hypothesis gives Acc at b.
Reachable states (reach). If g is reachable from a, then Path r m g z' with m ≤ n and e z z'.
The proof is by induction on reachability. The base is hp. For a step g → g': z' is normal and not bad
(A, bad_eqv), and the key lemma gives Path r m' g' z'' with m = m' + 1 and e z' z''.
one_run. (1) is acc. (2): if Bad g, then reach and C give Bad z', so Bad z. (3): if g is
normal, the path reach gives has no step, so z' = g. (4) is reach.
Dependencies
Relation.ReflTransGen (Mathlib) and Acc (Lean core); no MojoProof definition. Axioms: none beyond
propext, Classical.choice and Quot.sound.
Instances
Outside GPUProof/OneRun.lean its one caller is GPUProof.Clean.of_lift (GPUProof/Sound.lean), for every
machine; Sound.of_lift, Sound.of_one_run and MojoProof's Grid.sound_of_one_run (the adapter,
adapter.md) are its cases. The adapter's instances are Grid.start_sound (states are the grids
reachable from a start grid; e is Grid.Same; Bad is a fault, a race or a broken !invariant.load
promise) and Grid.sound_returning (states are the sets of returned threads; e is =; Bad is empty).