Documentation

CslibFrontier.Languages.Probabilistic.Lift

Programs inside distributions #

A closed probabilistic program denotes a distribution, its law ProbComp.eval, and ProbComp.eval commutes with pure and bind: it is a monad morphism from ProbComp to PMF. This module makes it the monad lift, so a distribution written with do notation binds a program directly:

noncomputable def game : PMF Bool := do
  let ((x, y), s) ← A.choose ()      -- `A.choose () : ProbComp _`, lifted by its law
  let c ← conversation x y           -- a distribution
  A.guess s c                        -- a program again, lifted

Lean inserts liftM around each program. The lift is ProbComp.eval by definition, and ProbComp.monadLift_eq_eval (a simp and pmf_norm lemma) rewrites it back, so every lemma about ProbComp.eval applies after one simp only [pmf_norm].

Main definitions #

Main results #

@[instance_reducible]

A program lifts into a distribution by its law, so a PMF written with do notation can bind a program with ←.

@[simp]
theorem Cslib.ProbComp.monadLift_eq_eval {α : Type} (program : ProbComp α) :
monadLift program = program.eval

Lifting a program into a distribution takes its law.

theorem Cslib.ProbComp.liftM_eq_eval {α : Type} (program : ProbComp α) :
liftM program = program.eval

The liftM form of monadLift_eq_eval, the term Lean inserts for a lifted bind; rw matches it only in this form.