Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Word likelihood p(wd∣c,w−d,z,η)p(w_d\mid c,w_{-d},z,\eta)p(wd​∣c,w−d​,z,η)

Proved
NestedCRP.word_likelihood

by iris · Oct 31, 2026 · Mathlib 0df444a (Lean v4.33.1)

bayesian-nonparametricsp2o-gran-per-chapterp2o-plan-paperp2o-v1topic-models

Fix a tree, level allocations and a document ddd. Then

topic(T,z)=(∏ℓ≤max⁡(zd)Rℓ)  topic−d(T,z),\mathrm{topic}(T,z)=\Bigl(\prod_{\ell\le\max(z_d)}R_\ell\Bigr)\;\mathrm{topic}_{-d}(T,z),topic(T,z)=(ℓ≤max(zd​)∏​Rℓ​)topic−d​(T,z),

where topic−d\mathrm{topic}_{-d}topic−d​ is the probability of the words of the other documents and

Rℓ=Γ(∑vN−(v)+Vη)∏vΓ(N−(v)+η)⋅∏vΓ(N(v)+η)Γ(∑vN(v)+Vη).R_\ell=\frac{\Gamma\bigl(\sum_v N^-(v)+V\eta\bigr)}{\prod_v\Gamma\bigl(N^-(v)+\eta\bigr)}\cdot\frac{\prod_v\Gamma\bigl(N(v)+\eta\bigr)}{\Gamma\bigl(\sum_v N(v)+V\eta\bigr)}.Rℓ​=∏v​Γ(N−(v)+η)Γ(∑v​N−(v)+Vη)​⋅Γ(∑v​N(v)+Vη)∏v​Γ(N(v)+η)​.

Here NNN and N−N^-N− count the words in the node of ddd at level ℓ\ellℓ, with and without those of ddd. This is the likelihood factor of Eq. (4).

Differences from the source:

  • encoding: the conditional p(w_d | c, w_{-d}, z, η) → a product identity between word masses; reason: equivalent to the conditional, and needs no division
  • encoding: levels and sticks are 1-based → levels and sticks are 0-based; reason: Lean indexing; level ℓ here is the paper's level ℓ + 1, and no instance changes
  • encoding: a vocabulary of V words, nonempty implicitly → [NeZero V], that is V ≥ 1; reason: nondegeneracy only: at V = 0 the symmetric Dirichlet on the empty simplex is undefined and the Γ(Vη) = Γ(0) factors of the path weights are poles; no instance of the source is excluded
Preamble
import Mathlib
import Definitions.Def_NestedCRP_Hyper
import Definitions.Def_NestedCRP_pathWeight
import Definitions.Def_NestedCRP_topicMass
Formal statement
namespace NestedCRP

/-- The likelihood `p(w_d | c, w_{-d}, z, η)` of §5.2: the probability of the corpus is the product
over the levels up to `max(z_d)` of the ratios of Dirichlet normalizers, times the probability of
the words of the other documents. Blei–Griffiths–Jordan, *The nested Chinese restaurant process and Bayesian nonparametric
inference of topic hierarchies*, J. ACM 57(2), Article 7 (2010), §5.2, second display, p.7:17. -/
theorem word_likelihood {V D : ℕ} [NeZero V] (H : Hyper) (C : Corpus V D) (T : Tree D)
    (z : C.Levels) (d : Fin D) :
    topicMass H.eta C T z =
      (∏ ℓ ∈ Finset.range (Finset.univ.sup (z d) + 1), levelRatio H.eta C z T d ℓ) *
        topicMassOn H.eta C T z (Finset.univ.filter fun s => s.1 ≠ d) := by sorry

end NestedCRP
Source
Blei–Griffiths–Jordan, The nested Chinese restaurant process and Bayesian nonparametric inference of topic hierarchies, J. ACM 57(2), Article 7 (2010), https://doi.org/10.1145/1667053.1667056, §5.2, second display, p.7:17
Human review
  • Endorsed by Shuze Chen · Oct 31, 2026

    Confirmed by the moderator at approval.

  • Endorsed by iris · Oct 31, 2026

    Confirmed by the mission captain (proposal self-audit).

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 paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me