Documentation

VCVio.EvalDist.Instances.OptionT

Probability Distributions on Potentially Failing Computations #

This file gives an instance to extend a evalDist instance on a monad to one transformed by the OptionT monad transformer.

dt: should add more instances and connecting lemmas

@[implicit_reducible]
noncomputable instance OptionT.instHasEvalSet (m : Type u → Type v) [Monad m] [HasEvalSet m] :

Standalone HasEvalSet (OptionT m) instance under the weaker [HasEvalSet m] assumption.

This is deliberately kept separate from the HasEvalSPMF (OptionT m) instance below, which re-exports the same toSet to make the resulting typeclass diamond definitionally equal. Keeping this standalone instance means support on OptionT m works without requiring a full HasEvalSPMF m — only HasEvalSet m is needed (e.g., for support_liftM).

theorem OptionT.support_def {m : Type u → Type v} [Monad m] {α : Type u} [HasEvalSet m] (mx : OptionT m α) :
@[simp]
theorem OptionT.mem_support_iff {m : Type u → Type v} [Monad m] {α : Type u} [HasEvalSet m] (mx : OptionT m α) (x : α) :
@[simp]
theorem OptionT.support_liftM {m : Type u → Type v} [Monad m] {α : Type u} [HasEvalSet m] (mx : m α) :
@[simp]
theorem OptionT.support_lift {m : Type u → Type v} [Monad m] {α : Type u} [HasEvalSet m] (mx : m α) :
@[implicit_reducible]
noncomputable instance OptionT.instHasEvalFinset (m : Type u → Type v) [Monad m] [HasEvalSet m] [HasEvalFinset m] :

Lift a HasEvalFinset instance to OptionT. by just taking preimage under some.

theorem OptionT.finSupport_def {m : Type u → Type v} [Monad m] {α : Type u} [HasEvalSet m] [HasEvalFinset m] [DecidableEq α] (mx : OptionT m α) :
@[simp]
theorem OptionT.mem_finSupport_iff {m : Type u → Type v} [Monad m] {α : Type u} [HasEvalSet m] [HasEvalFinset m] [DecidableEq α] (mx : OptionT m α) (x : α) :
@[simp]
theorem OptionT.finSupport_liftM {m : Type u → Type v} [Monad m] {α : Type u} [HasEvalSet m] [HasEvalFinset m] [DecidableEq α] (mx : m α) :
@[simp]
theorem OptionT.finSupport_lift {m : Type u → Type v} [Monad m] {α : Type u} [HasEvalSet m] [HasEvalFinset m] [DecidableEq α] (mx : m α) :
@[implicit_reducible]
noncomputable instance OptionT.instHasEvalSPMF (m : Type u → Type v) [Monad m] [HasEvalSPMF m] :

Lift a HasEvalSPMF m instance to HasEvalSPMF (OptionT m). Note: a more specific HasEvalPMF m → HasEvalSPMF (OptionT m) path would make explicit that failure comes solely from OptionT, but this general instance subsumes it.

Lean 4 automatically synthesizes toSet from the standalone HasEvalSet (OptionT m) instance above, ensuring the diamond is definitionally equal (per Mathlib convention). The support_eq field then serves as the coherence proof between the set-path and distribution-path.

theorem OptionT.evalDist_eq {m : Type u → Type v} [Monad m] {α : Type u} [HasEvalSPMF m] (mx : OptionT m α) :
evalDist mx = (fun {α : Type u} (x : OptionT m α) => (OptionT.mapM' HasEvalSPMF.toSPMF).toFun α x) mx
theorem OptionT.probOutput_eq {m : Type u → Type v} [Monad m] {α : Type u} [HasEvalSPMF m] (mx : OptionT m α) (x : α) :
Pr[= x | mx] = Pr[= some x | mx.run]
theorem OptionT.probEvent_eq {m : Type u → Type v} [Monad m] {α : Type u} [HasEvalSPMF m] (mx : OptionT m α) (p : αProp) [DecidablePred p] :
probEvent mx p + Pr[= none | mx.run] = probEvent mx.run fun (x : Option α) => Option.all (fun (b : α) => decide (p b)) x = true
theorem OptionT.probFailure_eq {m : Type u → Type v} [Monad m] {α : Type u} [HasEvalSPMF m] (mx : OptionT m α) :
@[simp]
theorem OptionT.probOutput_liftM {m : Type u → Type v} [Monad m] {α : Type u} [HasEvalSPMF m] [LawfulMonad m] (mx : m α) (x : α) :
Pr[= x | liftM mx] = Pr[= x | mx]
@[simp]
theorem OptionT.probOutput_lift {m : Type u → Type v} [Monad m] {α : Type u} [HasEvalSPMF m] [LawfulMonad m] (mx : m α) (x : α) :
@[simp]
theorem OptionT.probEvent_liftM {m : Type u → Type v} [Monad m] {α : Type u} [HasEvalSPMF m] [LawfulMonad m] (mx : m α) (p : αProp) :
@[simp]
theorem OptionT.probEvent_lift {m : Type u → Type v} [Monad m] {α : Type u} [HasEvalSPMF m] [LawfulMonad m] (mx : m α) (p : αProp) :
@[simp]
theorem OptionT.probFailure_liftM {m : Type u → Type v} [Monad m] {α : Type u} [HasEvalSPMF m] [LawfulMonad m] (mx : m α) :
@[simp]
theorem OptionT.probFailure_lift {m : Type u → Type v} [Monad m] {α : Type u} [HasEvalSPMF m] [LawfulMonad m] (mx : m α) :