Proofs by calculation on kernels are rare in Mathlib: each step, such as reassociating a composition, marginalizing with Kernel.discard, or moving a kernel along Kernel.copy, needs its own lemma or a computation with integrals. With Kernel-Hom, these steps are closed by kernel_disch, in the same way as cat_disch closes easy steps of categorical proofs.
A proof can therefore be written as a calc whose lines are the mathematically meaningful rewrites, typically by hypotheses. To apply a rewrite, the kernels are first arranged so that the hypothesis appears, and the remaining equality only differs by the structure of the kernels (composition, parallel composition, copy, discard, swap). kernel_disch closes it. Each step of the calculation can moreover be visualized with string diagrams.
As an example, we formalize Theorem 15.8 of (Fritz, 2020)Tobias Fritz, 2020. “A synthetic approach to Markov kernels, conditional independence and theorems
on sufficient statistics”. In Advances in Mathematics., which is the main ingredient of the classical Basu theorem: a complete sufficient statistic is independent of any ancillary statistic, for every value of the parameter. A statistical model is a Markov kernel p : Kernel Θ X, and almost sure equality, sufficiency, completeness and ancillarity are all defined by equalities of kernels:
/-- The kernels `f` and `g` are `p`-almost surely equal (Definition 13.1). -/defAEEq{Y:Type*}[MeasurableSpaceY](p:KernelΘX)(fg:KernelXY):Prop:=(f∥ₖKernel.id)∘ₖcopyX∘ₖp=(g∥ₖKernel.id)∘ₖcopyX∘ₖp/-- The statistic `s` is sufficient for the statistical model `p` (Definition 14.3). -/defIsSufficient(p:KernelΘX)(s:KernelXV):Prop:=∃α:KernelVX,IsMarkovKernelα∧(Kernel.id∥ₖs)∘ₖcopyX∘ₖp=(α∥ₖKernel.id)∘ₖcopyV∘ₖs∘ₖp/-- The kernel `f` is complete with respect to kernels with values in `Z` (Definition 15.1, which
quantifies over all `Z`). -/defIsComplete(f:KernelΘX)(Z:Type*)[MeasurableSpaceZ]:Prop:=∀(gh:KernelXZ)[IsMarkovKernelg][IsMarkovKernelh],g∘ₖf=h∘ₖf→AEEqfgh/-- The statistic `a` is ancillary for the statistical model `p` (Definition 15.7). -/defIsAncillary(p:KernelΘX)(a:KernelXW):Prop:=∃ψ:KernelUnitW,IsMarkovKernelψ∧a∘ₖp=ψ∘ₖdiscardΘ
The proof consists of two calculations. The first one shows that a ∘ₖ α and ψ ∘ₖ discard V agree after s ∘ₖ p, where α witnesses the sufficiency of s and ψ the ancillarity of a:
/-- The kernels `a ∘ₖ α` and `ψ ∘ₖ discard V` agree after `s ∘ₖ p`, where `α` witnesses the
sufficiency of `s` and `ψ` the ancillarity of `a` (first computation of the proof of
Theorem 15.8). -/lemmabasu_aux(hα:(Kernel.id∥ₖs)∘ₖcopyX∘ₖp=(α∥ₖKernel.id)∘ₖcopyV∘ₖs∘ₖp)(hψ:a∘ₖp=ψ∘ₖdiscardΘ):(a∘ₖα)∘ₖ(s∘ₖp)=(ψ∘ₖdiscardV)∘ₖ(s∘ₖp):=Θ:Type u_1X:Type u_2V:Type u_3W:Type u_4inst✝⁸:MeasurableSpaceΘinst✝⁷:MeasurableSpaceXinst✝⁶:MeasurableSpaceVinst✝⁵:MeasurableSpaceWp:KernelΘXs:KernelXVa:KernelXWα:KernelVXψ:KernelUnitWinst✝⁴:IsMarkovKernelpinst✝³:IsMarkovKernelsinst✝²:IsMarkovKernelainst✝¹:IsMarkovKernelαinst✝:IsMarkovKernelψhα:Kernel.id∥ₖs∘ₖcopyX∘ₖp=α∥ₖKernel.id∘ₖcopyV∘ₖs∘ₖphψ:a∘ₖp=ψ∘ₖdiscardΘ⊢ a∘ₖα∘ₖ(s∘ₖp)=ψ∘ₖdiscardV∘ₖ(s∘ₖp)calc(a∘ₖα)∘ₖ(s∘ₖp)_=Kernel.id.mapProd.fst∘ₖ(a∥ₖ(discardV:KernelVUnit))∘ₖ((α∥ₖKernel.id)∘ₖcopyV∘ₖs∘ₖp):=Θ:Type u_1X:Type u_2V:Type u_3W:Type u_4inst✝⁸:MeasurableSpaceΘinst✝⁷:MeasurableSpaceXinst✝⁶:MeasurableSpaceVinst✝⁵:MeasurableSpaceWp:KernelΘXs:KernelXVa:KernelXWα:KernelVXψ:KernelUnitWinst✝⁴:IsMarkovKernelpinst✝³:IsMarkovKernelsinst✝²:IsMarkovKernelainst✝¹:IsMarkovKernelαinst✝:IsMarkovKernelψhα:Kernel.id∥ₖs∘ₖcopyX∘ₖp=α∥ₖKernel.id∘ₖcopyV∘ₖs∘ₖphψ:a∘ₖp=ψ∘ₖdiscardΘ⊢ a∘ₖα∘ₖ(s∘ₖp)=Kernel.id.mapProd.fst∘ₖ(a∥ₖdiscardV)∘ₖ(α∥ₖKernel.id∘ₖcopyV∘ₖs∘ₖp)All goals completed! 🐙_=a∘ₖp:=Θ:Type u_1X:Type u_2V:Type u_3W:Type u_4inst✝⁸:MeasurableSpaceΘinst✝⁷:MeasurableSpaceXinst✝⁶:MeasurableSpaceVinst✝⁵:MeasurableSpaceWp:KernelΘXs:KernelXVa:KernelXWα:KernelVXψ:KernelUnitWinst✝⁴:IsMarkovKernelpinst✝³:IsMarkovKernelsinst✝²:IsMarkovKernelainst✝¹:IsMarkovKernelαinst✝:IsMarkovKernelψhα:Kernel.id∥ₖs∘ₖcopyX∘ₖp=α∥ₖKernel.id∘ₖcopyV∘ₖs∘ₖphψ:a∘ₖp=ψ∘ₖdiscardΘ⊢ Kernel.id.mapProd.fst∘ₖ(a∥ₖdiscardV)∘ₖ(α∥ₖKernel.id∘ₖcopyV∘ₖs∘ₖp)=a∘ₖpΘ:Type u_1X:Type u_2V:Type u_3W:Type u_4inst✝⁸:MeasurableSpaceΘinst✝⁷:MeasurableSpaceXinst✝⁶:MeasurableSpaceVinst✝⁵:MeasurableSpaceWp:KernelΘXs:KernelXVa:KernelXWα:KernelVXψ:KernelUnitWinst✝⁴:IsMarkovKernelpinst✝³:IsMarkovKernelsinst✝²:IsMarkovKernelainst✝¹:IsMarkovKernelαinst✝:IsMarkovKernelψhα:Kernel.id∥ₖs∘ₖcopyX∘ₖp=α∥ₖKernel.id∘ₖcopyV∘ₖs∘ₖphψ:a∘ₖp=ψ∘ₖdiscardΘ⊢ Kernel.id.mapProd.fst∘ₖ(a∥ₖdiscardV)∘ₖ(Kernel.id∥ₖs∘ₖcopyX∘ₖp)=a∘ₖpkernel_dischAll goals completed! 🐙_=(ψ∘ₖdiscardV)∘ₖ(s∘ₖp):=byΘ:Type u_1X:Type u_2V:Type u_3W:Type u_4inst✝⁸:MeasurableSpaceΘinst✝⁷:MeasurableSpaceXinst✝⁶:MeasurableSpaceVinst✝⁵:MeasurableSpaceWp:KernelΘXs:KernelXVa:KernelXWα:KernelVXψ:KernelUnitWinst✝⁴:IsMarkovKernelpinst✝³:IsMarkovKernelsinst✝²:IsMarkovKernelainst✝¹:IsMarkovKernelαinst✝:IsMarkovKernelψhα:Kernel.id∥ₖs∘ₖcopyX∘ₖp=α∥ₖKernel.id∘ₖcopyV∘ₖs∘ₖphψ:a∘ₖp=ψ∘ₖdiscardΘ⊢ a∘ₖp=ψ∘ₖdiscardV∘ₖ(s∘ₖp)rw[hψΘ:Type u_1X:Type u_2V:Type u_3W:Type u_4inst✝⁸:MeasurableSpaceΘinst✝⁷:MeasurableSpaceXinst✝⁶:MeasurableSpaceVinst✝⁵:MeasurableSpaceWp:KernelΘXs:KernelXVa:KernelXWα:KernelVXψ:KernelUnitWinst✝⁴:IsMarkovKernelpinst✝³:IsMarkovKernelsinst✝²:IsMarkovKernelainst✝¹:IsMarkovKernelαinst✝:IsMarkovKernelψhα:Kernel.id∥ₖs∘ₖcopyX∘ₖp=α∥ₖKernel.id∘ₖcopyV∘ₖs∘ₖphψ:a∘ₖp=ψ∘ₖdiscardΘ⊢ ψ∘ₖdiscardΘ=ψ∘ₖdiscardV∘ₖ(s∘ₖp)]Θ:Type u_1X:Type u_2V:Type u_3W:Type u_4inst✝⁸:MeasurableSpaceΘinst✝⁷:MeasurableSpaceXinst✝⁶:MeasurableSpaceVinst✝⁵:MeasurableSpaceWp:KernelΘXs:KernelXVa:KernelXWα:KernelVXψ:KernelUnitWinst✝⁴:IsMarkovKernelpinst✝³:IsMarkovKernelsinst✝²:IsMarkovKernelainst✝¹:IsMarkovKernelαinst✝:IsMarkovKernelψhα:Kernel.id∥ₖs∘ₖcopyX∘ₖp=α∥ₖKernel.id∘ₖcopyV∘ₖs∘ₖphψ:a∘ₖp=ψ∘ₖdiscardΘ⊢ ψ∘ₖdiscardΘ=ψ∘ₖdiscardV∘ₖ(s∘ₖp)kernel_dischAll goals completed! 🐙
The visible rewrites are the sufficiency equation hα and the ancillarity equation hψ. The first line marginalizes the right-hand side of the sufficiency equation, so that hα can be applied. After each rewrite, kernel_disch proves the remaining equality.
The second calculation uses the completeness of s ∘ₖ p on the first one:
/-- **Theorem 15.8** of Fritz: if `s` is a sufficient statistic such that `s ∘ₖ p` is complete, and
`a` is ancillary, then for every value of the parameter, the joint distribution of `s` and `a` is
the product of their distributions. The kernel `a` does not need to be deterministic. -/theorembasu{p:KernelΘX}[IsMarkovKernelp]{s:KernelXV}[IsMarkovKernels]{a:KernelXW}[IsMarkovKernela](hs:IsSufficientps)(hc:IsComplete(s∘ₖp)W)(ha:IsAncillarypa):(s∥ₖa)∘ₖcopyX∘ₖp=(s∘ₖp)×ₖ(a∘ₖp):=byΘ:Type u_1X:Type u_2V:Type u_3W:Type u_4inst✝⁶:MeasurableSpaceΘinst✝⁵:MeasurableSpaceXinst✝⁴:MeasurableSpaceVinst✝³:MeasurableSpaceWp:KernelΘXinst✝²:IsMarkovKernelps:KernelXVinst✝¹:IsMarkovKernelsa:KernelXWinst✝:IsMarkovKernelahs:p.IsSufficientshc:(s∘ₖp).IsCompleteWha:p.IsAncillarya⊢ s∥ₖa∘ₖcopyX∘ₖp=s∘ₖp×ₖ(a∘ₖp)with_panel_widgets[Mathlib.Tactic.Widget.StringDiagram,KernelDiagram]obtain⟨α,_,hα⟩:=hsΘ:Type u_1X:Type u_2V:Type u_3W:Type u_4inst✝⁶:MeasurableSpaceΘinst✝⁵:MeasurableSpaceXinst✝⁴:MeasurableSpaceVinst✝³:MeasurableSpaceWp:KernelΘXinst✝²:IsMarkovKernelps:KernelXVinst✝¹:IsMarkovKernelsa:KernelXWinst✝:IsMarkovKernelahc:(s∘ₖp).IsCompleteWha:p.IsAncillaryaα:KernelVXleft✝:IsMarkovKernelαhα:Kernel.id∥ₖs∘ₖcopyX∘ₖp=α∥ₖKernel.id∘ₖcopyV∘ₖs∘ₖp⊢ s∥ₖa∘ₖcopyX∘ₖp=s∘ₖp×ₖ(a∘ₖp)obtain⟨ψ,_,hψ⟩:=haΘ:Type u_1X:Type u_2V:Type u_3W:Type u_4inst✝⁶:MeasurableSpaceΘinst✝⁵:MeasurableSpaceXinst✝⁴:MeasurableSpaceVinst✝³:MeasurableSpaceWp:KernelΘXinst✝²:IsMarkovKernelps:KernelXVinst✝¹:IsMarkovKernelsa:KernelXWinst✝:IsMarkovKernelahc:(s∘ₖp).IsCompleteWα:KernelVXleft✝¹:IsMarkovKernelαhα:Kernel.id∥ₖs∘ₖcopyX∘ₖp=α∥ₖKernel.id∘ₖcopyV∘ₖs∘ₖpψ:KernelUnitWleft✝:IsMarkovKernelψhψ:a∘ₖp=ψ∘ₖdiscardΘ⊢ s∥ₖa∘ₖcopyX∘ₖp=s∘ₖp×ₖ(a∘ₖp)haveh:=hc(a∘ₖα)(ψ∘ₖdiscardV)(basu_auxhαhψ)Θ:Type u_1X:Type u_2V:Type u_3W:Type u_4inst✝⁶:MeasurableSpaceΘinst✝⁵:MeasurableSpaceXinst✝⁴:MeasurableSpaceVinst✝³:MeasurableSpaceWp:KernelΘXinst✝²:IsMarkovKernelps:KernelXVinst✝¹:IsMarkovKernelsa:KernelXWinst✝:IsMarkovKernelahc:(s∘ₖp).IsCompleteWα:KernelVXleft✝¹:IsMarkovKernelαhα:Kernel.id∥ₖs∘ₖcopyX∘ₖp=α∥ₖKernel.id∘ₖcopyV∘ₖs∘ₖpψ:KernelUnitWleft✝:IsMarkovKernelψhψ:a∘ₖp=ψ∘ₖdiscardΘh:(s∘ₖp).AEEq(a∘ₖα)(ψ∘ₖdiscardV)⊢ s∥ₖa∘ₖcopyX∘ₖp=s∘ₖp×ₖ(a∘ₖp)calc(s∥ₖa)∘ₖcopyX∘ₖp_=swapWV∘ₖ((a∥ₖKernel.id)∘ₖ((Kernel.id∥ₖs)∘ₖcopyX∘ₖp)):=byΘ:Type u_1X:Type u_2V:Type u_3W:Type u_4inst✝⁶:MeasurableSpaceΘinst✝⁵:MeasurableSpaceXinst✝⁴:MeasurableSpaceVinst✝³:MeasurableSpaceWp:KernelΘXinst✝²:IsMarkovKernelps:KernelXVinst✝¹:IsMarkovKernelsa:KernelXWinst✝:IsMarkovKernelahc:(s∘ₖp).IsCompleteWα:KernelVXleft✝¹:IsMarkovKernelαhα:Kernel.id∥ₖs∘ₖcopyX∘ₖp=α∥ₖKernel.id∘ₖcopyV∘ₖs∘ₖpψ:KernelUnitWleft✝:IsMarkovKernelψhψ:a∘ₖp=ψ∘ₖdiscardΘh:(s∘ₖp).AEEq(a∘ₖα)(ψ∘ₖdiscardV)⊢ s∥ₖa∘ₖcopyX∘ₖp=swapWV∘ₖ(a∥ₖKernel.id∘ₖ(Kernel.id∥ₖs∘ₖcopyX∘ₖp))kernel_dischAll goals completed! 🐙_=swapWV∘ₖ(((a∘ₖα)∥ₖKernel.id)∘ₖcopyV∘ₖ(s∘ₖp)):=byΘ:Type u_1X:Type u_2V:Type u_3W:Type u_4inst✝⁶:MeasurableSpaceΘinst✝⁵:MeasurableSpaceXinst✝⁴:MeasurableSpaceVinst✝³:MeasurableSpaceWp:KernelΘXinst✝²:IsMarkovKernelps:KernelXVinst✝¹:IsMarkovKernelsa:KernelXWinst✝:IsMarkovKernelahc:(s∘ₖp).IsCompleteWα:KernelVXleft✝¹:IsMarkovKernelαhα:Kernel.id∥ₖs∘ₖcopyX∘ₖp=α∥ₖKernel.id∘ₖcopyV∘ₖs∘ₖpψ:KernelUnitWleft✝:IsMarkovKernelψhψ:a∘ₖp=ψ∘ₖdiscardΘh:(s∘ₖp).AEEq(a∘ₖα)(ψ∘ₖdiscardV)⊢ swapWV∘ₖ(a∥ₖKernel.id∘ₖ(Kernel.id∥ₖs∘ₖcopyX∘ₖp))=swapWV∘ₖ(a∘ₖα∥ₖKernel.id∘ₖcopyV∘ₖ(s∘ₖp))rw[hαΘ:Type u_1X:Type u_2V:Type u_3W:Type u_4inst✝⁶:MeasurableSpaceΘinst✝⁵:MeasurableSpaceXinst✝⁴:MeasurableSpaceVinst✝³:MeasurableSpaceWp:KernelΘXinst✝²:IsMarkovKernelps:KernelXVinst✝¹:IsMarkovKernelsa:KernelXWinst✝:IsMarkovKernelahc:(s∘ₖp).IsCompleteWα:KernelVXleft✝¹:IsMarkovKernelαhα:Kernel.id∥ₖs∘ₖcopyX∘ₖp=α∥ₖKernel.id∘ₖcopyV∘ₖs∘ₖpψ:KernelUnitWleft✝:IsMarkovKernelψhψ:a∘ₖp=ψ∘ₖdiscardΘh:(s∘ₖp).AEEq(a∘ₖα)(ψ∘ₖdiscardV)⊢ swapWV∘ₖ(a∥ₖKernel.id∘ₖ(α∥ₖKernel.id∘ₖcopyV∘ₖs∘ₖp))=swapWV∘ₖ(a∘ₖα∥ₖKernel.id∘ₖcopyV∘ₖ(s∘ₖp))]Θ:Type u_1X:Type u_2V:Type u_3W:Type u_4inst✝⁶:MeasurableSpaceΘinst✝⁵:MeasurableSpaceXinst✝⁴:MeasurableSpaceVinst✝³:MeasurableSpaceWp:KernelΘXinst✝²:IsMarkovKernelps:KernelXVinst✝¹:IsMarkovKernelsa:KernelXWinst✝:IsMarkovKernelahc:(s∘ₖp).IsCompleteWα:KernelVXleft✝¹:IsMarkovKernelαhα:Kernel.id∥ₖs∘ₖcopyX∘ₖp=α∥ₖKernel.id∘ₖcopyV∘ₖs∘ₖpψ:KernelUnitWleft✝:IsMarkovKernelψhψ:a∘ₖp=ψ∘ₖdiscardΘh:(s∘ₖp).AEEq(a∘ₖα)(ψ∘ₖdiscardV)⊢ swapWV∘ₖ(a∥ₖKernel.id∘ₖ(α∥ₖKernel.id∘ₖcopyV∘ₖs∘ₖp))=swapWV∘ₖ(a∘ₖα∥ₖKernel.id∘ₖcopyV∘ₖ(s∘ₖp))kernel_dischAll goals completed! 🐙_=swapWV∘ₖ(((ψ∘ₖdiscardV)∥ₖKernel.id)∘ₖcopyV∘ₖ(s∘ₖp)):=byΘ:Type u_1X:Type u_2V:Type u_3W:Type u_4inst✝⁶:MeasurableSpaceΘinst✝⁵:MeasurableSpaceXinst✝⁴:MeasurableSpaceVinst✝³:MeasurableSpaceWp:KernelΘXinst✝²:IsMarkovKernelps:KernelXVinst✝¹:IsMarkovKernelsa:KernelXWinst✝:IsMarkovKernelahc:(s∘ₖp).IsCompleteWα:KernelVXleft✝¹:IsMarkovKernelαhα:Kernel.id∥ₖs∘ₖcopyX∘ₖp=α∥ₖKernel.id∘ₖcopyV∘ₖs∘ₖpψ:KernelUnitWleft✝:IsMarkovKernelψhψ:a∘ₖp=ψ∘ₖdiscardΘh:(s∘ₖp).AEEq(a∘ₖα)(ψ∘ₖdiscardV)⊢ swapWV∘ₖ(a∘ₖα∥ₖKernel.id∘ₖcopyV∘ₖ(s∘ₖp))=swapWV∘ₖ(ψ∘ₖdiscardV∥ₖKernel.id∘ₖcopyV∘ₖ(s∘ₖp))rw[hΘ:Type u_1X:Type u_2V:Type u_3W:Type u_4inst✝⁶:MeasurableSpaceΘinst✝⁵:MeasurableSpaceXinst✝⁴:MeasurableSpaceVinst✝³:MeasurableSpaceWp:KernelΘXinst✝²:IsMarkovKernelps:KernelXVinst✝¹:IsMarkovKernelsa:KernelXWinst✝:IsMarkovKernelahc:(s∘ₖp).IsCompleteWα:KernelVXleft✝¹:IsMarkovKernelαhα:Kernel.id∥ₖs∘ₖcopyX∘ₖp=α∥ₖKernel.id∘ₖcopyV∘ₖs∘ₖpψ:KernelUnitWleft✝:IsMarkovKernelψhψ:a∘ₖp=ψ∘ₖdiscardΘh:(s∘ₖp).AEEq(a∘ₖα)(ψ∘ₖdiscardV)⊢ swapWV∘ₖ(ψ∘ₖdiscardV∥ₖKernel.id∘ₖcopyV∘ₖ(s∘ₖp))=swapWV∘ₖ(ψ∘ₖdiscardV∥ₖKernel.id∘ₖcopyV∘ₖ(s∘ₖp))]All goals completed! 🐙_=(s∘ₖp)×ₖ(ψ∘ₖdiscardΘ):=byΘ:Type u_1X:Type u_2V:Type u_3W:Type u_4inst✝⁶:MeasurableSpaceΘinst✝⁵:MeasurableSpaceXinst✝⁴:MeasurableSpaceVinst✝³:MeasurableSpaceWp:KernelΘXinst✝²:IsMarkovKernelps:KernelXVinst✝¹:IsMarkovKernelsa:KernelXWinst✝:IsMarkovKernelahc:(s∘ₖp).IsCompleteWα:KernelVXleft✝¹:IsMarkovKernelαhα:Kernel.id∥ₖs∘ₖcopyX∘ₖp=α∥ₖKernel.id∘ₖcopyV∘ₖs∘ₖpψ:KernelUnitWleft✝:IsMarkovKernelψhψ:a∘ₖp=ψ∘ₖdiscardΘh:(s∘ₖp).AEEq(a∘ₖα)(ψ∘ₖdiscardV)⊢ swapWV∘ₖ(ψ∘ₖdiscardV∥ₖKernel.id∘ₖcopyV∘ₖ(s∘ₖp))=s∘ₖp×ₖ(ψ∘ₖdiscardΘ)kernel_dischAll goals completed! 🐙_=(s∘ₖp)×ₖ(a∘ₖp):=byΘ:Type u_1X:Type u_2V:Type u_3W:Type u_4inst✝⁶:MeasurableSpaceΘinst✝⁵:MeasurableSpaceXinst✝⁴:MeasurableSpaceVinst✝³:MeasurableSpaceWp:KernelΘXinst✝²:IsMarkovKernelps:KernelXVinst✝¹:IsMarkovKernelsa:KernelXWinst✝:IsMarkovKernelahc:(s∘ₖp).IsCompleteWα:KernelVXleft✝¹:IsMarkovKernelαhα:Kernel.id∥ₖs∘ₖcopyX∘ₖp=α∥ₖKernel.id∘ₖcopyV∘ₖs∘ₖpψ:KernelUnitWleft✝:IsMarkovKernelψhψ:a∘ₖp=ψ∘ₖdiscardΘh:(s∘ₖp).AEEq(a∘ₖα)(ψ∘ₖdiscardV)⊢ s∘ₖp×ₖ(ψ∘ₖdiscardΘ)=s∘ₖp×ₖ(a∘ₖp)rw[hψΘ:Type u_1X:Type u_2V:Type u_3W:Type u_4inst✝⁶:MeasurableSpaceΘinst✝⁵:MeasurableSpaceXinst✝⁴:MeasurableSpaceVinst✝³:MeasurableSpaceWp:KernelΘXinst✝²:IsMarkovKernelps:KernelXVinst✝¹:IsMarkovKernelsa:KernelXWinst✝:IsMarkovKernelahc:(s∘ₖp).IsCompleteWα:KernelVXleft✝¹:IsMarkovKernelαhα:Kernel.id∥ₖs∘ₖcopyX∘ₖp=α∥ₖKernel.id∘ₖcopyV∘ₖs∘ₖpψ:KernelUnitWleft✝:IsMarkovKernelψhψ:a∘ₖp=ψ∘ₖdiscardΘh:(s∘ₖp).AEEq(a∘ₖα)(ψ∘ₖdiscardV)⊢ s∘ₖp×ₖ(ψ∘ₖdiscardΘ)=s∘ₖp×ₖ(ψ∘ₖdiscardΘ)]All goals completed! 🐙
The visible rewrites are the sufficiency equation hα, the completeness of s ∘ₖ p (h) and the ancillarity equation hψ. The last calculation step before the ancillarity is the factorization of Theorem 15.8 of (Fritz, 2020)Tobias Fritz, 2020. “A synthetic approach to Markov kernels, conditional independence and theorems
on sufficient statistics”. In Advances in Mathematics., where the joint distribution of s and a is the product of s ∘ₖ p and of the distribution ψ.
Each step of the two calculations is stated as a lemma in KernelHomTests/Basu.lean, so that its string diagrams can be drawn. The diagrams are read from top to bottom.