Measurable Batch Learner Monad #
MeasurableBatchLearner is a measurable instance of the pure ReaderSel monad (MathLib/ReaderMonad.lean). The algebraic structure (pure, bind, monad laws) lives in the pure math layer. This file adds the measurability certificate.
MeasLearner: BatchLearner bundled with MeasurableBatchLearner proofMeasLearner.pure: constant learner (delegates to ReaderSel.pure)MeasLearner.bind: selection-based composition (delegates to concatLearner)- Monad laws: inherited from ReaderSel, verified at evaluation level
A measurable batch learner bundled with its measurability certificate. The carrier
of the learner monad: pairs a BatchLearner with a proof of MeasurableBatchLearner,
so that monadic composition can automatically preserve measurability without
re-derivation at the call site.
- learner : BatchLearner X Bool
- measurable : MeasurableBatchLearner X self.learner
Instances For
Unit of the learner monad. Returns the constant learner that ignores its training
data and always outputs the fixed measurable hypothesis h. The hypothesis space is
the singleton {h}; measurability is the projection-then-constant pattern.
Equations
Instances For
Monadic bind for measurable learners. Sequential composition where the second
learner is selected by a measurable function of the training sample, implemented via
concatLearner over a UniformMeasurableBatchFamily of continuations.
The non-trivial design choice is that bind requires a uniformly measurable family
of continuations rather than a merely pointwise measurable one. This is the type-level
encoding of the joint-measurability hypothesis without which sequential composition
would not stay inside MeasurableBatchLearner. The closure algebra proves the
construction is sound; the type signature makes the necessary hypothesis
non-bypassable.
Equations
- MeasLearner.bind family sel hsel = { learner := concatLearner (fun (n : ℕ) => (family n).learner) fun {m : ℕ} => sel, measurable := ⋯ }
Instances For
Monad Laws #
The algebraic structure is inherited from ReaderSel (MathLib/ReaderMonad.lean). At the evaluation level, concatLearner.learn S x = (family (sel S)).learner.learn S x, which is ReaderSel.eval specialized to ι = ℕ, α = Fin m → X × Bool.
Left-unit law at the evaluation level: with a constant selector fun _ => n, the
concatLearner of a family evaluates at (S, x) to (family n).learner.learn S x.
Holds definitionally (rfl): concatLearner with a constant selector reduces to
evaluating the selected family member.
Right-unit law at the evaluation level: with a constant family fun _ => L, the
concatLearner collapses under any selector to plain L.learner.learn S x. Holds
definitionally (rfl).
Associativity at the evaluation level: the concatLearner evaluation
(concatLearner (fun n => (family n).learner) sel).learn S x reduces definitionally
to (family (sel S)).learner.learn S x. Held by rfl; the identity is what lets
nested concatLearner selections compose into a single selector in downstream
constructions.