Documentation

VCVio.EvalDist.PFunctor

Probability Semantics for Polynomial Free Monads #

This module equips an arbitrary polynomial functor with per-operation probability semantics and interprets its free monad in PMF. It also provides the syntax-only support interpretation in SetM. The API is independent of OracleSpec; oracle computations inherit it through their underlying polynomial functor.

Per-operation probability distributions for a polynomial interface.

  • toPMF : Handler PMF P

    The distribution of directions available at an operation.

Instances

    A finitely branching polynomial interface whose operation responses use the canonical uniform distribution.

    Instances
      @[reducible]
      noncomputable def PFunctor.IsUniformSpec.ofFintypeInhabited (P : PFunctor.{uA, u}) [hF : (a : P.A) → Fintype (P.B a)] [hI : (a : P.A) → Inhabited (P.B a)] :

      Construct uniform probability semantics from finite, inhabited direction types. This is deliberately not an instance: probability semantics remain an explicit opt-in.

      Instances For
        @[instance_reducible]

        Interpret a polynomial free program using its per-operation probability distributions.

        @[instance_reducible]

        Interpret support syntactically by allowing every direction at every operation. This does not require probability or finiteness assumptions.

        The distribution semantics of a polynomial free program is its universal fold into PMF.

        theorem PFunctor.FreeM.support_eq_liftM {P : PFunctor.{uA, u}} {α : Type u} (program : P.FreeM α) :
        support program = (FreeM.liftM (fun (x : P.A) => Set.univ) program).run

        The support semantics of a polynomial free program is its universal fold with every operation direction available.

        @[simp]

        A single operation evaluates to its configured direction distribution.

        theorem PFunctor.FreeM.evalSPMF_lift_eq_uniform {P : PFunctor.{uA, u}} [h : P.IsUniformSpec] (operation : P.A) :
        𝒮[lift operation] = liftM (PMF.uniformOfFintype (P.B operation))

        A single operation on a uniform polynomial interface evaluates to the canonical uniform distribution on its directions.

        theorem PFunctor.FreeM.support_lift_eq_univ {P : PFunctor.{uA, u}} (operation : P.A) :
        support (lift operation) = Set.univ

        Every direction of a single operation belongs to its SetM-fold support.

        This name distinguishes VCVio's denotational support from PolyFun's structural MonadAttach.support_lift theorem.

        @[instance 100]

        Syntactic support and distribution support agree for a uniformly interpreted polynomial free monad.

        For an oracle spec this is reached explicitly, not by synthesis: OracleComp.instEvalDistCompatible supplies the IsUniformSpec premise through OracleSpec.IsUniformSpec.toPFunctor, which is deliberately a definition rather than an instance so that nothing unifies against the reducible head spec.toPFunctor. Keep it that way — promoting that conversion would make this instance and the oracle-level one both applicable to the same goal.