Native measure semantics for polynomial free monads #
This module interprets a polynomial free program directly as a Mathlib Measure. Each operation
is assigned a probability measure on its answer type, and PFunctor.FreeM.denote recursively
composes those measures with Measure.bind when the continuation is almost everywhere measurable.
An unmeasurable continuation denotes zero. This convention makes the fold subprobabilistic
without depending on Mathlib's arbitrary default for an unmeasurable pushforward.
Measure α becomes a type only after α receives a MeasurableSpace, so this interpretation is
an explicit fold rather than an unrestricted Lean monad morphism. The measurable-continuation
boundary remains visible in the general laws. Discrete answer types discharge the internal
measurability obligations while leaving the result space arbitrary.
Main definitions #
PFunctor.IsMeasureSpecassigns a probability measure to each operation.PFunctor.IsMeasureSpec.uniformOfFiniteNonemptyassigns the native uniform measure to every finite, nonempty answer type.PFunctor.FreeM.denoteis the measure denoted by a free program.
Main statements #
PFunctor.FreeM.denote_liftidentifies the denotation of one operation.PFunctor.FreeM.denote_bind_of_discreteandPFunctor.FreeM.denote_map_of_discretegive the discrete Giry composition laws.PFunctor.FreeM.denote_bind_bind_prod_mk_eq_prodidentifies two independent executions with Mathlib's product measure.
Per-operation answer measures for a polynomial interface.
The measurable structure on answer types is a separate parameter rather than a field, mirroring
Mathlib's separation of MeasurableSpace from the measures carried on it. Answer types need not
be discrete.
- toMeasure (a : P.A) : MeasureTheory.Measure (P.B a)
The distribution of answers to an operation.
- isProbabilityMeasure (a : P.A) : MeasureTheory.IsProbabilityMeasure (toMeasure a)
Answering an operation is lossless.
Instances
Construct native uniform measure semantics from finite, nonempty answer types.
This is deliberately not an instance: measure semantics remain an explicit choice at each use site, and are never inferred merely from finiteness.
Instances For
The measure denoted by a polynomial free program. A measurable continuation uses Giry bind; an unmeasurable continuation denotes zero. Probability-mass preservation requires measurability.
Instances For
An unmeasurable operation continuation has zero denotation.
A one-operation program denotes its configured answer measure.
A one-operation program is a probability measure whenever its continuation is an almost-everywhere measurable family of probability measures.
This is the continuous composition boundary. For discrete answer types the hypotheses are
automatic; for a genuinely continuous oracle they are precisely the obligations represented by
a Mathlib Kernel.
Giry composition laws #
Every program over discrete answer types denotes a probability measure, independently of the measurable space on its output.
denote preserves bind when the denoted continuation is measurable. Discrete answer types
discharge the recursive measurability obligation inside the free program.
denote preserves bind unconditionally when the program's result type is discrete.
denote turns a measurable map of program outputs into the pushforward measure.
denote preserves every output map from a discrete result type.
Sequentially running two programs whose second execution does not depend on the first result denotes the product of their measures.
Every free program denotes a subprobability measure. Measurable continuations preserve the mass bound through integration; unmeasurable continuations have zero denotation.
The direct free-monad fold supplies measure semantics for a measure-valued specification.
The direct free-monad measure fold preserves pure without any discreteness assumption on oracle answers.
With a measure specification in scope, primary notation is definitionally the direct
free-monad measure fold. 𝒟[…] is the public head: this is a transport lemma, not a simp rule,
so the 𝒟-keyed laws below and in Defs.Measure are the ones simp uses.
A one-operation program denotes its configured answer measure.
A single operation denotes a probability measure, including for continuous answer spaces.
An operation with an almost everywhere measurable continuation denotes Giry bind.
Integrating a single operation uses the tower law under AE-measurable continuation and valuation hypotheses, including for continuous query answers.
A measurable pure function after one operation pushes forward its answer measure. No discreteness assumption on the answer space is needed.
Over a discrete-answer interface, the direct measure semantics satisfies the Giry monad laws.