Docs / Proofs

The fast race check finds every race (fast_sound)

Lean: MojoProof/Sem/Race.lean (fast, clash), MojoProof/Sem/RaceSig.lean (racy_iff, fast_sound).

Scope. Every launch L and every trace tr by threads of L in their blocks of threads that is shaped (Trace.Shaped tr.reverse), racy_iff's premises. racy tr below is the core's racy at sig of tr's core events, oldest first (GPUProof.racy sig ((tr.map (Event.toCore L)).reverse)); MojoProof has no racy of its own. Only fast tr = false → racy tr = false is proved. The converse (fast reports only real races) is not; the tests compare the two on every trace that is short enough for racy.

Definitions

Proof

races_iff, forward (induction on tr; T2 uses the converse, schedule.md L9). Suppose a.races sync tr. Then some access y of tr meets three conditions:

The cases:

racy_iff, forward (induction on tr). If racy tr, some two accesses x, y in (phases tr).1 clash. In the case of a newest access a, the current count of a's block of threads is a's phase, so races_iff gives the clash. The converses are schedule.md's L9.

clash_comm. clash is symmetric because thread inequality, overlaps, conflict and the phase test are symmetric.

Access.overlaps_bytes. Two overlapping accesses share a byte: the larger of their two start offsets. This needs both lengths positive, which overlaps requires.

mem_buckets (induction on the list, with mem_insertAll for one access). After folding bucket, the list of byte b contains every access that touches b.

fast_sound. Suppose racy tr. racy_iff gives clash x y. Their conflict makes one of them a write; by clash_comm, assume it is x. overlaps_bytes gives a common byte b, and mem_buckets puts y in b's list. So fast finds x, b and y, and fast tr = true, which contradicts the hypothesis.

Dependencies