Documentation

CslibFrontier.Probability.PMF.Coupling

Revealing a hidden sample along an experiment #

A real experiment runs on states a. An ideal experiment first draws a hidden sample k and then runs on smaller states that depend on it. The two are linked by a law exp a of the hidden sample given the real state and by a representation rep a: the real state together with the explained sample, (exp a).map (·, rep a), has the law of the ideal pair. Lazy and eager sampling of a random function are an example, where exp completes the table that a lazy state has not yet sampled.

Such a link is preserved by a step that keeps it on reachable real states. The lemmas carry an invariant of those states, so the local link need only hold where the invariant does. A trivial hidden sample turns the link into a plain state representation, (d.map rep).

Main definitions #

Main results #

structure Cslib.Probability.PMF.HiddenCoupling {α : Type w} {β : Type x} {γ : Type y} (d₁ : PMF α) (exp₀ : PMF γ) (exp : α → PMF γ) (rep : α → β) (d₂ : γ → PMF β) (inv : α → Prop) :

Couple a concrete distribution d₁ with an ideal two-stage distribution drawing k ← exp₀ and running d₂ k, linked by the conditional law exp a of the hidden sample and representation rep a, carrying inv on d₁.support.

  • bind_eq : (d₁.bind fun (a : α) => PMF.map (fun (x : γ) => (x, rep a)) (exp a)) = exp₀.bind fun (k : γ) => PMF.map (fun (x : β) => (k, x)) (d₂ k)

    Joint law of the concrete outcome with its explained sample matches the ideal pair.

  • support_inv (a : α) : a ∈ d₁.support → inv a

    Every reachable concrete outcome satisfies inv.

theorem Cslib.Probability.PMF.HiddenCoupling.pure {α : Type w} {β : Type x} {γ : Type y} {a : α} {exp₀ : PMF γ} {exp : α → PMF γ} {rep : α → β} {b : γ → β} {inv : α → Prop} (hexp : exp a = exp₀) (hrep : ∀ k ∈ exp₀.support, rep a = b k) (hinv : inv a) :
HiddenCoupling (PMF.pure a) exp₀ exp rep (fun (k : γ) => PMF.pure (b k)) inv

Pointwise hidden-sample coupling on PMF.pure.

theorem Cslib.Probability.PMF.HiddenCoupling.congr {α : Type w} {β : Type x} {γ : Type y} {d₁ d₁' : PMF α} {exp₀ : PMF γ} {exp : α → PMF γ} {rep : α → β} {d₂ d₂' : γ → PMF β} {inv₁ inv₂ : α → Prop} (h : HiddenCoupling d₁ exp₀ exp rep d₂ inv₁) (hd₁ : d₁ = d₁') (hd₂ : ∀ k ∈ exp₀.support, d₂ k = d₂' k) (hinv : ∀ a ∈ d₁.support, inv₁ a → inv₂ a) :
HiddenCoupling d₁' exp₀ exp rep d₂' inv₂

Transport HiddenCoupling along distribution equalities on support and invariant weakening.

theorem Cslib.Probability.PMF.HiddenCoupling.bind {α₁ : Type u} {β₁ : Type v} {α : Type w} {β : Type x} {γ : Type y} {d₁ : PMF α₁} {exp₀ : PMF γ} {exp₁ : α₁ → PMF γ} {rep₁ : α₁ → β₁} {d₂ : γ → PMF β₁} {inv₁ : α₁ → Prop} {f₁ : α₁ → PMF α} {exp : α → PMF γ} {rep : α → β} {f₂ : γ → β₁ → PMF β} {inv : α → Prop} (hd : HiddenCoupling d₁ exp₀ exp₁ rep₁ d₂ inv₁) (hf : ∀ a ∈ d₁.support, inv₁ a → HiddenCoupling (f₁ a) (exp₁ a) exp rep (fun (k : γ) => f₂ k (rep₁ a)) inv) :
HiddenCoupling (d₁.bind f₁) exp₀ exp rep (fun (k : γ) => (d₂ k).bind (f₂ k)) inv

Sequence two HiddenCoupling stages with distributions and continuations inferred.

theorem Cslib.Probability.PMF.HiddenCoupling.bind_pure {α₁ : Type u} {β₁ : Type v} {α : Type w} {β : Type x} {γ : Type y} {d₁ : PMF α₁} {exp₀ : PMF γ} {exp₁ : α₁ → PMF γ} {rep₁ : α₁ → β₁} {b : γ → β₁} {inv₁ : α₁ → Prop} {f₁ : α₁ → PMF α} {exp : α → PMF γ} {rep : α → β} {f₂ : γ → β₁ → PMF β} {inv : α → Prop} (hd : HiddenCoupling d₁ exp₀ exp₁ rep₁ (fun (k : γ) => PMF.pure (b k)) inv₁) (hf : ∀ a ∈ d₁.support, inv₁ a → HiddenCoupling (f₁ a) (exp₁ a) exp rep (fun (k : γ) => f₂ k (rep₁ a)) inv) :
HiddenCoupling (d₁.bind f₁) exp₀ exp rep (fun (k : γ) => f₂ k (b k)) inv

Sequence a HiddenCoupling whose ideal first stage is PMF.pure (b k) with a continuation fun k => f₂ k (b k).

theorem Cslib.Probability.PMF.HiddenCoupling.map {α₁ : Type u} {β₁ : Type v} {α : Type w} {β : Type x} {γ : Type y} {d₁ : PMF α₁} {exp₀ : PMF γ} {exp₁ : α₁ → PMF γ} {rep₁ : α₁ → β₁} {d₂ : γ → PMF β₁} {inv₁ : α₁ → Prop} {g₁ : α₁ → α} {exp : α → PMF γ} {rep : α → β} {g₂ : γ → β₁ → β} {inv : α → Prop} (hd : HiddenCoupling d₁ exp₀ exp₁ rep₁ d₂ inv₁) (hg : ∀ a ∈ d₁.support, inv₁ a → exp (g₁ a) = exp₁ a ∧ (∀ k ∈ (exp₁ a).support, rep (g₁ a) = g₂ k (rep₁ a)) ∧ inv (g₁ a)) :
HiddenCoupling (PMF.map g₁ d₁) exp₀ exp rep (fun (k : γ) => PMF.map (g₂ k) (d₂ k)) inv

Postprocess both sides of a HiddenCoupling on d₁.support and (exp₁ a).support.

theorem Cslib.Probability.PMF.HiddenCoupling.iterate {α : Type w} {β : Type x} {γ : Type y} {step₁ : α → PMF α} {step₂ : γ → β → PMF β} {exp₀ : PMF γ} {exp : α → PMF γ} {rep : α → β} (inv : ℕ → α → Prop) {m : ℕ} {init : α} {init₂ : γ → β} (hexp₀ : exp init = exp₀) (hrep₀ : ∀ k ∈ exp₀.support, rep init = init₂ k) (hinit : inv 0 init) (hstep : ∀ i < m, ∀ (a : α), inv i a → HiddenCoupling (step₁ a) (exp a) exp rep (fun (k : γ) => step₂ k (rep a)) (inv (i + 1))) :
HiddenCoupling ((fun (d : PMF α) => d.bind step₁)^[m] (PMF.pure init)) exp₀ exp rep (fun (k : γ) => (fun (d : PMF β) => d.bind (step₂ k))^[m] (PMF.pure (init₂ k))) (inv m)

Lift a step-wise HiddenCoupling across m monadic iterations.

structure Cslib.Probability.PMF.RepInv {α : Type w} {β : Type x} (d₁ : PMF α) (d₂ : PMF β) (rep : α → β) (inv : α → Prop) :

Couple a concrete distribution d₁ with an abstract distribution d₂ via d₁.map rep = d₂, carrying inv on d₁.support.

  • map_eq : PMF.map rep d₁ = d₂

    Pushforward of d₁ along rep equals d₂.

  • support_inv (a : α) : a ∈ d₁.support → inv a

    Every reachable concrete outcome satisfies inv.

theorem Cslib.Probability.PMF.RepInv.pure {α : Type w} {β : Type x} {a : α} {b : β} {rep : α → β} {inv : α → Prop} (hrep : rep a = b) (hinv : inv a) :
RepInv (PMF.pure a) (PMF.pure b) rep inv

Pointwise representation and invariant on PMF.pure.

theorem Cslib.Probability.PMF.RepInv.of_eq {α : Type w} {β : Type x} {d₁ : PMF α} {d₂ : PMF β} {rep : α → β} (h : PMF.map rep d₁ = d₂) :
RepInv d₁ d₂ rep fun (x : α) => True

Package an unconditional equality d₁.map rep = d₂ with the trivial invariant.

theorem Cslib.Probability.PMF.RepInv.bind {α₁ : Type u} {β₁ : Type v} {α : Type w} {β : Type x} {d₁ : PMF α₁} {d₂ : PMF β₁} {rep₁ : α₁ → β₁} {inv₁ : α₁ → Prop} {f₁ : α₁ → PMF α} {f₂ : β₁ → PMF β} {rep : α → β} {inv : α → Prop} (hd : RepInv d₁ d₂ rep₁ inv₁) (hf : ∀ a ∈ d₁.support, inv₁ a → RepInv (f₁ a) (f₂ (rep₁ a)) rep inv) :
RepInv (d₁.bind f₁) (d₂.bind f₂) rep inv

Sequence two RepInv stages with distributions and continuations inferred.

theorem Cslib.Probability.PMF.RepInv.map {α₁ : Type u} {β₁ : Type v} {α : Type w} {β : Type x} {d₁ : PMF α₁} {d₂ : PMF β₁} {rep₁ : α₁ → β₁} {inv₁ : α₁ → Prop} {g₁ : α₁ → α} {g₂ : β₁ → β} {rep : α → β} {inv : α → Prop} (hd : RepInv d₁ d₂ rep₁ inv₁) (hg : ∀ a ∈ d₁.support, inv₁ a → rep (g₁ a) = g₂ (rep₁ a) ∧ inv (g₁ a)) :
RepInv (PMF.map g₁ d₁) (PMF.map g₂ d₂) rep inv

Postprocess both sides of a RepInv coupling on d₁.support.

theorem Cslib.Probability.PMF.RepInv.iterate {α : Type w} {β : Type x} {step₁ : α → PMF α} {step₂ : β → PMF β} {rep : α → β} (inv : ℕ → α → Prop) {m : ℕ} {init : α} {init₂ : β} (hrep₀ : rep init = init₂) (hinit : inv 0 init) (hstep : ∀ i < m, ∀ (a : α), inv i a → RepInv (step₁ a) (step₂ (rep a)) rep (inv (i + 1))) :
RepInv ((fun (d : PMF α) => d.bind step₁)^[m] (PMF.pure init)) ((fun (d : PMF β) => d.bind step₂)^[m] (PMF.pure init₂)) rep (inv m)

Lift a step-wise RepInv coupling across m monadic iterations.

theorem Cslib.Probability.PMF.iterate_bind_invariant {α : Type w} (step : α → PMF α) (inv : ℕ → α → Prop) (m : ℕ) (init : α) (hinit : inv 0 init) (hstep : ∀ i < m, ∀ (a : α), inv i a → ∀ a' ∈ (step a).support, inv (i + 1) a') (a : α) :
a ∈ ((fun (d : PMF α) => d.bind step)^[m] (PMF.pure init)).support → inv m a

Every reachable state of a chain of m steps satisfies an invariant indexed by the round, when every possible step from a state satisfying the invariant of its round preserves it.