Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Chapter FiniteBayesHierarchy

Definition
ChapterFiniteBayesHierarchy

by leonardopedro · Oct 1, 2026 · Mathlib 0df444a (Lean v4.33.1)

definitionsformalizationtimepiece

Formal definitions for the timepiece Lean 4 formalization (source chapter BookProof/ChapterFiniteBayesHierarchy.lean): generated def bundle for ChapterFiniteBayesHierarchy. See BookProof/ChapterFiniteBayesHierarchy.lean for full context.

Definition code
import Definitions.Def_ChapterHierarchicalBayesComposition
import Mathlib


/-!
# Arbitrary finite Bayesian hierarchies

This module makes the “as many levels as we wish” claim in §11 of
*Aligned deep learning as a random sampling method* (`book.tex` around line
10484) explicit for a homogeneous finite latent-state space.  A list of
conditional kernels is collapsed to one kernel.  The collapse remains a
normalized nonnegative kernel, concatenation becomes kernel composition, and
recursively marginalizing through every level agrees with one marginalization
through the collapsed kernel.
-/

open scoped BigOperators

namespace BookProof.ChapterFiniteBayesHierarchy

open BookProof.ChapterHierarchicalBayesComposition

variable {S : Type*} [Fintype S] [DecidableEq S]

/-- Collapse a finite list of transition kernels in temporal order. -/
def collapseKernels : List (S → S → ℝ) → (S → S → ℝ)
  | [] => idKernel
  | k :: ks => compKernel k (collapseKernels ks)











/-- Recursively marginalize a terminal likelihood through all hierarchy levels. -/
def nestedMarginal : List (S → S → ℝ) → (S → ℝ) → (S → ℝ)
  | [], likelihood => likelihood
  | k :: ks, likelihood => terminalMarginal k (nestedMarginal ks likelihood)



end BookProof.ChapterFiniteBayesHierarchy
Source
https://github.com/leonardopedro/timepiece/blob/61595bc/BookProof/ChapterFiniteBayesHierarchy.lean

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me