Probabilistic list traversal #
The support of ordinary List.mapM consists exactly of the lists whose entries are supported
by the corresponding calls. The relation also records the exact output length. These are
semantic laws; computational efficiency is provided separately in Computability.Probabilistic.
Main results #
Cslib.ProbComp.mem_support_mapM_iff: pointwise support characterizes list traversal.Cslib.ProbComp.eval_mapM_splice: sample a designated coordinate before its surrounding traversal without changing the joint distribution.Cslib.ProbComp.eval_mapM_range: traversingList.range kequals pushingPMF.piFinthroughList.ofFn.
theorem Cslib.ProbComp.mem_support_mapM_iff {α β : Type} (program : α → ProbComp β) (inputs : List α) (outputs : List β) :
The support of list traversal is exactly the pointwise support of the individual calls.
theorem Cslib.ProbComp.eval_mapM_splice {α β : Type} (program : α → ProbComp β) (before : List α) (middle : α) (after : List α) :
Sampling a designated coordinate before its prefix and suffix preserves the full traversal law. The three computations use independent randomness, and the returned order is unchanged.
theorem Cslib.ProbComp.eval_mapM_range {β : Type} (k : ℕ) (f : ℕ → ProbComp β) :
(List.mapM f (List.range k)).eval = PMF.map List.ofFn (Probability.PMF.piFin fun (i : Fin k) => (f ↑i).eval)
Traversing List.range k with an indexed probabilistic computation has the law of drawing
independent coordinates via PMF.piFin and converting to a list via List.ofFn.