Denotational Semantics for Output Distributions #
This file defines a typeclass for monads that can be canonically embedded in the SPMF
monad.
We require this embedding respect the basic monad laws.
We also define a number of specific cases:
Pr[= x | mx]
/probOutput mx x
for odds ofmx
returningx
Pr[p | mx]
/probEvent mx p
for odds ofmx
's result satisfyingp
Pr[e | x ← mx]
wherex
is free in the expressione
Pr{x ← mx}[e]
wherex
is free in the expressione
Pr[⊥ | mx]
/probFailure mx
for odds ofmx
resulting in failure
For the last case, we assume mx
has an OptionT
transformer to represent the failure.
In future it may be nice to generalize to any AlternativeMonad
using an additional typeclass
(note that it can't extend the existing one as it outputs in an SPMF
).
Equations
- SPMF.instFunLikeENNReal = { coe := fun (sp : SPMF α) (x : α) => (OptionT.run sp) (some x), coe_injective' := ⋯ }
The monad m
has a well-behaved embedding into the SPMF
monad.
TODO: modify this to extend MonadHom
to get some lemmas for free.
Instances
Probability that a compuutation mx
will fail to return a value.
Instances For
Probability that a computation returns a particular output.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Probability that a computation returns a value satisfying a predicate.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Probability that a computation fails to return a value.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Probability that a computation returns a value satisfying a predicate.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Probability that a computation returns a value satisfying a predicate.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Add instance for SPMF
just to give access to notation.
Equations
- SPMF.hasEvalDist = { evalDist := fun {α : Type ?u.4} => id, evalDist_pure := @SPMF.hasEvalDist._proof_1, evalDist_bind := @SPMF.hasEvalDist._proof_2 }
Equations
- One or more equations did not get rendered due to their size.