Documentation

VCVio.EvalDist.Instances.OptionT

Probability Distributions on Potentially Failing Computations #

This file lifts MonadLiftT _ SetM and MonadLiftT _ SPMF semantics through the OptionT monad transformer.

dt: should add more instances and connecting lemmas

@[implicit_reducible]
noncomputable instance OptionT.instMonadLiftTSetM {m : Type u → Type v} [Monad m] [MonadLiftT m SetM] :

Standalone MonadLiftT (OptionT m) SetM instance under the weaker [MonadLiftT m SetM] assumption. Keeping this standalone means support on OptionT m works without requiring a full MonadLiftT m SPMF lift — only MonadLiftT m SetM is needed.

We declare a MonadLiftT (rather than MonadLift) so the instance has no semiOutParam arguments to synthesize — OptionT m's m cannot be recovered from the SetM codomain.

theorem OptionT.support_def {m : Type u → Type v} [Monad m] {α : Type u} [MonadLiftT m SetM] (mx : OptionT m α) :
@[simp]
theorem OptionT.mem_support_iff {m : Type u → Type v} [Monad m] {α : Type u} [MonadLiftT m SetM] (mx : OptionT m α) (x : α) :
@[simp]
theorem OptionT.support_liftM {m : Type u → Type v} [Monad m] {α : Type u} [MonadLiftT m SetM] [LawfulMonadLiftT m SetM] (mx : m α) :
@[simp]
theorem OptionT.support_lift {m : Type u → Type v} [Monad m] {α : Type u} [MonadLiftT m SetM] [LawfulMonadLiftT m SetM] (mx : m α) :
@[implicit_reducible]
noncomputable instance OptionT.instHasEvalFinset (m : Type u → Type v) [Monad m] [MonadLiftT m SetM] [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} [MonadLiftT m SetM] [HasEvalFinset m] [DecidableEq α] (mx : OptionT m α) :
@[simp]
theorem OptionT.mem_finSupport_iff {m : Type u → Type v} [Monad m] {α : Type u} [MonadLiftT m SetM] [HasEvalFinset m] [DecidableEq α] (mx : OptionT m α) (x : α) :
@[simp]
theorem OptionT.finSupport_liftM {m : Type u → Type v} [Monad m] {α : Type u} [MonadLiftT m SetM] [HasEvalFinset m] [LawfulMonadLiftT m SetM] [LawfulMonad m] [DecidableEq α] (mx : m α) :
@[simp]
@[implicit_reducible]
noncomputable instance OptionT.instMonadLiftTSPMF (m : Type u → Type v) [Monad m] [MonadLiftT m SPMF] [LawfulMonadLiftT m SPMF] :

Lift a MonadLiftT m SPMF instance to MonadLiftT (OptionT m) SPMF. Failure in OptionT contributes to the failure mass of the resulting SPMF.

The SetM-lift of OptionT m (preimage of support mx.run under some) agrees with the SPMF-lift (the OptionT.mapM' bind into SPMF) on outputs, given EvalDistCompatible m.

theorem OptionT.evalDist_eq {m : Type u → Type v} [Monad m] {α : Type u} [MonadLiftT m SPMF] [LawfulMonadLiftT m SPMF] (mx : OptionT m α) :
𝒟[mx] = (fun {α : Type u} (x : OptionT m α) => (OptionT.mapM' (MonadHom.ofLift m SPMF)).toFun α x) mx
theorem OptionT.probOutput_eq {m : Type u → Type v} [Monad m] {α : Type u} [MonadLiftT m SPMF] [LawfulMonadLiftT m SPMF] (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} [MonadLiftT m SPMF] [LawfulMonadLiftT m SPMF] (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} [MonadLiftT m SPMF] [LawfulMonadLiftT m SPMF] (mx : OptionT m α) :
@[simp]
theorem OptionT.probOutput_liftM {m : Type u → Type v} [Monad m] {α : Type u} [MonadLiftT m SPMF] [LawfulMonadLiftT m SPMF] [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} [MonadLiftT m SPMF] [LawfulMonadLiftT m SPMF] [LawfulMonad m] (mx : m α) (x : α) :
@[simp]
theorem OptionT.probEvent_liftM {m : Type u → Type v} [Monad m] {α : Type u} [MonadLiftT m SPMF] [LawfulMonadLiftT m SPMF] [LawfulMonad m] (mx : m α) (p : αProp) :
@[simp]
theorem OptionT.probEvent_lift {m : Type u → Type v} [Monad m] {α : Type u} [MonadLiftT m SPMF] [LawfulMonadLiftT m SPMF] [LawfulMonad m] (mx : m α) (p : αProp) :
@[simp]
theorem OptionT.probFailure_liftM {m : Type u → Type v} [Monad m] {α : Type u} [MonadLiftT m SPMF] [LawfulMonadLiftT m SPMF] [LawfulMonad m] (mx : m α) :
@[simp]
theorem OptionT.probFailure_lift {m : Type u → Type v} [Monad m] {α : Type u} [MonadLiftT m SPMF] [LawfulMonadLiftT m SPMF] [LawfulMonad m] (mx : m α) :