Documentation

VCVio.EvalDist.Monad.Basic

Evaluation Distributions of Computations with Bind #

File for lemmas about evalDist and support involving the monadic pure and bind.

@[simp]
theorem support_pure {α : Type u} {m : Type u → Type v} [Monad m] [HasEvalSet m] (x : α) :
theorem mem_support_pure_iff {α : Type u} {m : Type u → Type v} [Monad m] [HasEvalSet m] (x y : α) :
x support (pure y) x = y
theorem mem_support_pure_iff' {α : Type u} {m : Type u → Type v} [Monad m] [HasEvalSet m] (x y : α) :
x support (pure y) y = x
@[simp]
theorem finSupport_pure {α : Type u} {m : Type u → Type v} [Monad m] [HasEvalSet m] [HasEvalFinset m] [DecidableEq α] (x : α) :
theorem mem_finSupport_pure_iff {α : Type u} {m : Type u → Type v} [Monad m] [HasEvalSet m] [HasEvalFinset m] [DecidableEq α] (x y : α) :
x finSupport (pure y) x = y
theorem mem_finSupport_pure_iff' {α : Type u} {m : Type u → Type v} [Monad m] [HasEvalSet m] [HasEvalFinset m] [DecidableEq α] (x y : α) :
x finSupport (pure y) y = x
@[simp]
theorem evalDist_pure {m : Type u → Type v} [Monad m] [HasEvalSPMF m] {α : Type u} (x : α) :
@[simp]
theorem evalDist_comp_pure {α : Type u} {m : Type u → Type v} [Monad m] [HasEvalSPMF m] :
@[simp]
theorem evalDist_comp_pure' {α β : Type u} {m : Type u → Type v} [Monad m] [HasEvalSPMF m] (f : αβ) :
@[simp]
theorem probOutput_pure {α : Type u} {m : Type u → Type v} [Monad m] [HasEvalSPMF m] [DecidableEq α] (x y : α) :
Pr[=x | pure y] = if x = y then 1 else 0
@[simp]
theorem probOutput_pure_self {α : Type u} {m : Type u → Type v} [Monad m] [HasEvalSPMF m] (x : α) :
Pr[=x | pure x] = 1
theorem probOutput_pure_eq_indicator {α : Type u} {m : Type u → Type v} [Monad m] [HasEvalSPMF m] (x y : α) :

Fallback when we don't have decidable equality.

@[simp]
theorem probEvent_pure {α : Type u} {m : Type u → Type v} [Monad m] [HasEvalSPMF m] (x : α) (p : αProp) [DecidablePred p] :
Pr[p | pure x] = if p x then 1 else 0
theorem probEvent_pure_eq_indicator {α : Type u} {m : Type u → Type v} [Monad m] [HasEvalSPMF m] (x : α) (p : αProp) :
Pr[p | pure x] = {x : α | p x}.indicator (Function.const α 1) x

Fallback when we don't have decidable equality.

@[simp]
theorem probFailure_pure {α : Type u} {m : Type u → Type v} [Monad m] [HasEvalSPMF m] (x : α) :
@[simp]
theorem tsum_probOutput_pure {α : Type u} {m : Type u → Type v} [Monad m] [HasEvalSPMF m] (x : α) :
∑' (y : α), Pr[=y | pure x] = 1
@[simp]
theorem tsum_probOutput_pure' {α : Type u} {m : Type u → Type v} [Monad m] [HasEvalSPMF m] (x : α) :
∑' (y : α), Pr[=x | pure y] = 1
@[simp]
theorem sum_probOutput_pure {α : Type u} {m : Type u → Type v} [Monad m] [Fintype α] [HasEvalSPMF m] (x : α) :
y : α, Pr[=y | pure x] = 1
@[simp]
theorem sum_probOutput_pure' {α : Type u} {m : Type u → Type v} [Monad m] [Fintype α] [HasEvalSPMF m] (x : α) :
y : α, Pr[=x | pure y] = 1
@[simp]
theorem support_bind {α β : Type u} {m : Type u → Type v} [Monad m] [HasEvalSet m] (mx : m α) (my : αm β) :
support (mx >>= my) = xsupport mx, support (my x)
theorem mem_support_bind_iff {α β : Type u} {m : Type u → Type v} [Monad m] [HasEvalSet m] (mx : m α) (my : αm β) (y : β) :
y support (mx >>= my) xsupport mx, y support (my x)
@[simp]
theorem finSupport_bind {α β : Type u} {m : Type u → Type v} [Monad m] [HasEvalSet m] [HasEvalFinset m] [DecidableEq α] [DecidableEq β] (mx : m α) (my : αm β) :
finSupport (mx >>= my) = (finSupport mx).biUnion fun (x : α) => finSupport (my x)
theorem mem_finSupport_bind_iff {α β : Type u} {m : Type u → Type v} [Monad m] [HasEvalSet m] [HasEvalFinset m] [DecidableEq α] [DecidableEq β] (mx : m α) (my : αm β) (y : β) :
y finSupport (mx >>= my) xfinSupport mx, y finSupport (my x)
@[simp]
theorem evalDist_bind {α β : Type u} {m : Type u → Type v} [Monad m] [HasEvalSPMF m] (mx : m α) (my : αm β) :
evalDist (mx >>= my) = do let xevalDist mx evalDist (my x)
theorem evalDist_bind_of_support_eq_empty {α β : Type u} {m : Type u → Type v} [Monad m] [HasEvalSPMF m] (mx : m α) (my : αm β) (h : support mx = ) :
theorem probOutput_bind_eq_tsum {α β : Type u} {m : Type u → Type v} [Monad m] [HasEvalSPMF m] (mx : m α) (my : αm β) (y : β) :
Pr[=y | mx >>= my] = ∑' (x : α), Pr[=x | mx] * Pr[=y | my x]
theorem probEvent_bind_eq_tsum {α β : Type u} {m : Type u → Type v} [Monad m] [HasEvalSPMF m] (mx : m α) (my : αm β) (q : βProp) :
Pr[q | mx >>= my] = ∑' (x : α), Pr[=x | mx] * Pr[q | my x]
theorem probFailure_bind_eq_add_tsum {α β : Type u} {m : Type u → Type v} [Monad m] [HasEvalSPMF m] (mx : m α) (my : αm β) :
Pr[⊥ | mx >>= my] = Pr[⊥ | mx] + ∑' (x : α), Pr[=x | mx] * Pr[⊥ | my x]
theorem probFailure_bind_eq_add_tsum_support {α β : Type u} {m : Type u → Type v} [Monad m] [HasEvalSPMF m] (mx : m α) (my : αm β) :
Pr[⊥ | mx >>= my] = Pr[⊥ | mx] + ∑' (x : (support mx)), Pr[=x | mx] * Pr[⊥ | my x]
@[simp]
theorem probFailure_bind_eq_zero_iff {α β : Type u} {m : Type u → Type v} [Monad m] [HasEvalSPMF m] (mx : m α) (my : αm β) :
Pr[⊥ | mx >>= my] = 0 Pr[⊥ | mx] = 0 xsupport mx, Pr[⊥ | my x] = 0
theorem probOutput_bind_eq_tsum_subtype {α β : Type u} {m : Type u → Type v} [Monad m] [HasEvalSPMF m] (mx : m α) (my : αm β) (y : β) :
Pr[=y | mx >>= my] = ∑' (x : (support mx)), Pr[=x | mx] * Pr[=y | my x]

Version of probOutput_bind_eq_tsum that sums only over the subtype given by the support of the first computation. This can be useful to avoid looking at edge cases that can't actually happen in practice after the first computation. A common example is if the first computation does some error handling to avoids returning malformed outputs.

theorem probEvent_bind_eq_tsum_subtype {α β : Type u} {m : Type u → Type v} [Monad m] [HasEvalSPMF m] (mx : m α) (my : αm β) (q : βProp) :
Pr[q | mx >>= my] = ∑' (x : (support mx)), Pr[=x | mx] * Pr[q | my x]
theorem probOutput_bind_eq_sum_finSupport {α β : Type u} {m : Type u → Type v} [Monad m] [HasEvalSPMF m] [HasEvalFinset m] (mx : m α) (my : αm β) [DecidableEq α] (y : β) :
Pr[=y | mx >>= my] = xfinSupport mx, Pr[=x | mx] * Pr[=y | my x]
theorem probEvent_bind_eq_sum_finSupport {α β : Type u} {m : Type u → Type v} [Monad m] [HasEvalSPMF m] [HasEvalFinset m] (mx : m α) (my : αm β) [DecidableEq α] (q : βProp) :
Pr[q | mx >>= my] = xfinSupport mx, Pr[=x | mx] * Pr[q | my x]
@[simp]
theorem support_bind_const {α β : Type u} {m : Type u → Type v} [Monad m] [HasEvalSet m] (mx : m α) (my : m β) :
(support do let _ ← mx my) = {y : β | y support my (support mx).Nonempty}
@[simp]
theorem finSupport_bind_const {α β : Type u} {m : Type u → Type v} [Monad m] [HasEvalSet m] [HasEvalFinset m] [DecidableEq β] [DecidableEq α] (mx : m α) (my : m β) :
(finSupport do let _ ← mx my) = if (finSupport mx).Nonempty then finSupport my else
theorem probOutput_bind_of_const {α β : Type u} {m : Type u → Type v} [Monad m] [HasEvalSPMF m] (mx : m α) {my : αm β} {y : β} {r : ENNReal} (h : xsupport mx, Pr[=y | my x] = r) :
Pr[=y | mx >>= my] = (1 - Pr[⊥ | mx]) * r
@[simp]
theorem probOutput_bind_const {α β : Type u} {m : Type u → Type v} [Monad m] [HasEvalSPMF m] (mx : m α) (my : m β) (y : β) :
Pr[=y | do let _ ← mx my] = (1 - Pr[⊥ | mx]) * Pr[=y | my]
theorem probEvent_bind_of_const {α β : Type u} {m : Type u → Type v} [Monad m] [HasEvalSPMF m] (mx : m α) {my : αm β} {p : βProp} {r : ENNReal} (h : xsupport mx, Pr[p | my x] = r) :
Pr[p | mx >>= my] = (1 - Pr[⊥ | mx]) * r
@[simp]
theorem probEvent_bind_const {α β : Type u} {m : Type u → Type v} [Monad m] [HasEvalSPMF m] (mx : m α) (my : m β) (p : βProp) :
Pr[p | do let _ ← mx my] = (1 - Pr[⊥ | mx]) * Pr[p | my]
theorem probFailure_bind_of_const {α β : Type u} {m : Type u → Type v} [Monad m] [HasEvalSPMF m] {mx : m α} {my : αm β} {r : ENNReal} (h : xsupport mx, Pr[⊥ | my x] = r) :
Pr[⊥ | mx >>= my] = Pr[⊥ | mx] + r * (1 - Pr[⊥ | mx])

Write the probability of mx >>= my failing given that my has constant failure chance over the possible outputs in support mx as a fixed expression without any sums.

theorem probFailure_bind_of_const' {α β : Type u} {m : Type u → Type v} [Monad m] [HasEvalSPMF m] {mx : m α} {my : αm β} {r : ENNReal} (hr : r ) (h : xsupport mx, Pr[⊥ | my x] = r) :
Pr[⊥ | mx >>= my] = Pr[⊥ | mx] + r - Pr[⊥ | mx] * r
@[simp]
theorem probFailure_bind_const {α β : Type u} {m : Type u → Type v} [Monad m] [HasEvalSPMF m] (mx : m α) (my : m β) :
Pr[⊥ | do let _ ← mx my] = Pr[⊥ | mx] + Pr[⊥ | my] - Pr[⊥ | mx] * Pr[⊥ | my]
theorem probFailure_bind_eq_sub_mul {α β : Type u} {m : Type u → Type v} [Monad m] [HasEvalSPMF m] (mx : m α) (my : αm β) (r : ENNReal) (hr : r ) (h : xsupport mx, Pr[⊥ | my x] = r) :
Pr[⊥ | mx >>= my] = 1 - (1 - Pr[⊥ | mx]) * (1 - r)
theorem probFailure_bind_le_of_forall {α β : Type u} {m : Type u → Type v} [Monad m] [HasEvalSPMF m] {mx : m α} {s : ENNReal} (h' : Pr[⊥ | mx] s) (my : αm β) {r : ENNReal} (hr : xsupport mx, Pr[⊥ | my x] r) :
Pr[⊥ | mx >>= my] s + (1 - s) * r
theorem probFailure_bind_le_of_forall' {α β : Type u} {m : Type u → Type v} [Monad m] [HasEvalSPMF m] {mx : m α} {s : ENNReal} (h' : Pr[⊥ | mx] = s) (my : αm β) {r : ENNReal} (hr : xsupport mx, Pr[⊥ | my x] r) :
Pr[⊥ | mx >>= my] s + r

Version of probFailure_bind_le_of_forall with the 1 - s factor ommited for convenience.

theorem probFailure_bind_le_of_le_of_probFailure_eq_zero {α β : Type u} {m : Type u → Type v} [Monad m] [HasEvalSPMF m] {mx : m α} (h' : Pr[⊥ | mx] = 0) {my : αm β} {r : ENNReal} (hr : xsupport mx, Pr[⊥ | my x] r) :
Pr[⊥ | mx >>= my] r

Version of probFailure_bind_le_of_forall when mx never fails.

theorem probFailure_bind_of_probFailure_eq_zero {α β : Type u} {m : Type u → Type v} [Monad m] [HasEvalSPMF m] {mx : m α} (h' : Pr[⊥ | mx] = 0) {my : αm β} :
Pr[⊥ | mx >>= my] = ∑' (x : α), Pr[=x | mx] * Pr[⊥ | my x]