Documentation

CslibFrontier.Crypto.Protocols.UC.KernelIntertwine

Relating two machines through a state kernel #

Two machines over the same export interface can hold the same information in different shapes. A typical case is a machine that samples a value when it starts and a machine that samples the value only when it is first needed. No function between the two state spaces relates such a pair, because a state of the first machine contains a value that the second has not drawn yet. A kernel does: a map sending each state of the second machine to a distribution over states of the first, which records the law of the values still to be drawn.

This file shows that a kernel which commutes with every activation, on the states satisfying an invariant that activations preserve, commutes with the run of every program, and that two machines related in this way give every program the same outcome distribution. The statements are exact equalities of outcome distributions, with no error term. They are bookkeeping lemmas for the machine model of this library and are not taken from the literature.

Main results #

References #

theorem Cslib.Crypto.Protocols.UC.Machine.closeEval_runFrom_kernel {ιE : Type} {E : ιE → Type} {α : Type} (M₁ M₂ : Machine OracleSpec.empty E) (Inv : M₂.State → Prop) (μ : M₂.State → PMF M₁.State) (step : ∀ (q : ιE) (s : M₂.State), Inv s → ((μ s).bind fun (s₁ : M₁.State) => closeEval ((M₁.handle q).run s₁)) = (closeEval ((M₂.handle q).run s)).bind fun (y : E q × M₂.State) => PMF.map (fun (s₁ : M₁.State) => (y.1, s₁)) (μ y.2)) (keep : ∀ (q : ιE) (s : M₂.State), Inv s → ∀ y ∈ (closeEval ((M₂.handle q).run s)).support, Inv y.2) (program : ProbOracleComp E α) (s : M₂.State) (hs : Inv s) :
((μ s).bind fun (s₁ : M₁.State) => closeEval (M₁.runFrom program s₁)) = (closeEval (M₂.runFrom program s)).bind fun (y : α × M₂.State) => PMF.map (fun (s₁ : M₁.State) => (y.1, s₁)) (μ y.2)

Kernel intertwining for runs. Let μ send each state of M₂ to a distribution over states of M₁. Suppose that on every state s of M₂ satisfying Inv, drawing a state of M₁ from μ s and then running an activation of M₁ gives the same joint distribution of reply and state as running the activation of M₂ from s and then drawing the state of M₁ from μ at the new state (step), and that activations of M₂ preserve Inv (keep). Then the same holds with any program in place of a single activation.

A relation between single states cannot express this when one machine samples early what the other samples late: the kernel carries the distribution of the values not drawn yet.

theorem Cslib.Crypto.Protocols.UC.Machine.eval_run_eq_of_kernel {ιE : Type} {E : ιE → Type} {α : Type} (M₁ M₂ : Machine OracleSpec.empty E) (Inv : M₂.State → Prop) (μ : M₂.State → PMF M₁.State) (step : ∀ (q : ιE) (s : M₂.State), Inv s → ((μ s).bind fun (s₁ : M₁.State) => closeEval ((M₁.handle q).run s₁)) = (closeEval ((M₂.handle q).run s)).bind fun (y : E q × M₂.State) => PMF.map (fun (s₁ : M₁.State) => (y.1, s₁)) (μ y.2)) (keep : ∀ (q : ιE) (s : M₂.State), Inv s → ∀ y ∈ (closeEval ((M₂.handle q).run s)).support, Inv y.2) (init : M₁.init.eval = M₂.init.eval.bind μ) (hinit : ∀ s ∈ M₂.init.eval.support, Inv s) (program : ProbOracleComp E α) :
(M₁.run program).eval = (M₂.run program).eval

Two machines related by a kernel as in Machine.closeEval_runFrom_kernel give every program the same outcome distribution, provided the kernel carries the initial distribution of M₂ to that of M₁ (init) and every initial state of M₂ satisfies the invariant (hinit).