Seq-Swap / Reorder Rules #
Relational rules for commuting operations without syntactically rewriting programs.
These are the CatCrypt analogue of Bluebell's seq-swap rule: when the head
operations on two sides of a pRHL judgment don't match, we commute pure or
independent operations past each other to bring them into alignment.
Main theorems #
rHoare_reorder_pure_l— commute anIsPurecomputation past anything on LHSrHoare_reorder_pure_r— symmetric variant for RHSrHoare_sample_comm— both sides sample α,β but in opposite orderrHoare_sample_past_get_l— commute sample past get on LHSrHoare_sample_past_set_l— commute sample past set on LHS
References #
- Bluebell (POPL 2025) —
seq-swaprule for randomness alignment
Pure reordering #
Reorder LHS: commute an IsPure computation past any other computation.
If c is pure (heap-independent), then c >>= fun x => d >>= fun y => k x y
is equivalent to d >>= fun y => c >>= fun x => k x y.
We use this to align heads when the LHS starts with a pure operation
but the RHS starts with something else.
Reorder RHS: symmetric variant for the right-hand side.
Advantage-level reordering #
Factor out a common IsPure prefix from two games.
If both games have the form pfx.bind(p => Gᵢ.bind(r => k p r)),
where pfx is IsPure, then we can commute pfx past Gᵢ and factor:
AdvantageA (pfx.bind(p => G₁.bind(r => k p r))) (pfx.bind(p => G₂.bind(r => k p r))) A = AdvantageA G₁ G₂ (fun r => pfx.bind(p => (k p r).bind A))
This combines isPure_bind_comm + advantage_factorization into a single step,
which is the key pattern in the Double Ratchet inductive step.
Sample commutativity #
Both sides sample α,β but in opposite order: align them.
If the LHS samples α then β, and the RHS samples β then α,
we can swap the RHS to match.
Sample past get/set #
Commute sample past get on the LHS.
sample α >>= fun x => get l >>= fun v => k x v is equivalent to
get l >>= fun v => sample α >>= fun x => k x v because
sample doesn't read the heap and get doesn't modify the distribution.
Commute sample past set on the LHS.
sample α >>= fun x => set l v >> k x is equivalent to
set l v >> sample α >>= fun x => k x because
sample is independent of the heap.