PMFs from rational score vectors #
RSA-style models compute unnormalized scores in ℚ≥0 — exact, computable,
and with order decidable by kernel reduction — and state predictions about
the normalized distributions. This file provides the constructor and its
comparison calculus.
Fallback σ completes zero-mass score rows: a study declares one fallback
per normalization site, and both faces read it — the ℚ≥0 values through
scoresWith, the distribution through ofScores — so the two cannot
diverge and the bridge ofScores_apply is total (a rfl). Comparison,
threshold, product, and event lemmas then reduce every prediction to a
ℚ≥0 inequality between scoresWith values, closed by decide +kernel.
normalizeOrUniform is the generic ℝ≥0∞ total normalizer (the total
sibling of PMF.normalize); [UPSTREAM] candidate.
Main definitions #
PMF.Fallback— total fallback distribution (value + nonzero-mass witness) with smart constructorspure,uniform,uniformOn.PMF.normalizeScores f—f x / ∑ f, the ℚ≥0 shadow ofPMF.normalize.PMF.scoresWith fb f— the normalizedℚ≥0score function both faces read.PMF.ofScores fb f— the induced PMF;ofScores_applyisrfl.PMF.normalizeOrUniform— totalℝ≥0∞normalization.
Main results #
ofScores_lt/ofScores_lt_cross/_le/_eq— predictions fromscoresWithcomparisons.ofScores_lt_ratCastand companions — thresholds againstℚ≥0literals.prod_ofScores_apply,prod_ofScores_lt— chain-rule trajectory products.eventMass,ofScores_event_eq,ofScores_event_lt— event marginals.
Total normalization #
Total normalization: normalize f when it has positive finite mass,
else fall back to the uniform distribution. Unlike PMF.normalize, no
positivity witness is needed at the definition site, so
u ↦ normalizeOrUniform (score u) is a well-defined kernel even when some
rows are dead. [UPSTREAM] candidate (total sibling of PMF.normalize).
Equations
- PMF.normalizeOrUniform f = if h : ∑' (x : σ), f x ≠ 0 ∧ ∑' (x : σ), f x ≠ ⊤ then PMF.normalize f ⋯ ⋯ else PMF.uniformOfFintype σ
Instances For
Comparison of normalizeOrUniform values built from nonnegative real
scores: reduces to the normalized-score inequality. Real-face analogue of
ofScores_lt_cross.
Posterior dominance #
Comparing two posteriors at a cell needs no global algebra: pointwise
dominance of the odds f a : f c by g a : g c (strict at one cell)
transfers to the normalized values. This is Bayes-factor monotonicity.
Pointwise odds dominance implies posterior dominance: if
f a · g c ≤ g a · f c at every cell, strictly at one, then
f a / ∑ f < g a / ∑ g.
Fallbacks #
A total fallback distribution completing a zero-mass score row: a ℚ≥0
weight vector with nonzero mass. A study declares one fallback per
normalization site; scoresWith and ofScores both read it, so the ℚ≥0
and PMF faces agree by construction.
- dist : σ → ℚ≥0
The fallback weights (normalized by
scoresWith). - ne_zero : ∑ x : σ, self.dist x ≠ 0
The weights carry mass.
Instances For
Point-mass fallback (e.g. a designated null utterance).
Equations
- PMF.Fallback.pure a = { dist := fun (x : σ) => if x = a then 1 else 0, ne_zero := ⋯ }
Instances For
Uniform fallback.
Equations
- PMF.Fallback.uniform = { dist := fun (x : σ) => 1, ne_zero := ⋯ }
Instances For
Uniform fallback over a nonempty subset (e.g. words with viable continuations, scene members).
Equations
- PMF.Fallback.uniformOn S hS = { dist := fun (x : σ) => if x ∈ S then 1 else 0, ne_zero := ⋯ }
Instances For
Scores #
Normalize a score vector into a distribution function (÷0 = 0 gives
the zero function on a dead vector) — the ℚ≥0 shadow of PMF.normalize.
Studies define each agent of a model tower as one normalizeScores
application over the agents below it.
Equations
- PMF.normalizeScores f x = f x / ∑ y : σ, f y
Instances For
Normalization is scale-invariant: a common nonzero factor cancels. The reason RSA chains may drop constant factors mid-tower.
The normalized score function both faces read: f normalized when it
has mass, else the fallback normalized.
Kernel hygiene: comparisons of scoresWith values reduce under
decide +kernel provided the score chain's base tables are pattern
matches or Bool-valued tables — a propositional if x = y then … else …
over a derived DecidableEq anywhere in the chain blocks kernel reduction
of order comparisons (equalities still reduce).
Equations
- PMF.scoresWith fb f x = if 0 < ∑ y : σ, f y then PMF.normalizeScores f x else PMF.normalizeScores fb.dist x
Instances For
The PMF induced by a score vector and a fallback: pointwise the
coercion of scoresWith, so the ℚ≥0 face and the PMF face agree
definitionally.
Equations
- PMF.ofScores fb f = ⟨fun (x : σ) => ↑↑(PMF.scoresWith fb f x), ⋯⟩
Instances For
The total bridge: ofScores values are exactly the coerced scoresWith
values — no hypotheses, by definition.
Comparisons #
Each lemma reduces a PMF-level prediction to a ℚ≥0 inequality between
scoresWith values, which decide +kernel closes.
Thresholds against rational literals #
Chain-rule products #
Event marginals #
Mass of a decidable event under a ℚ≥0 weight vector.
Equations
- PMF.eventMass g P = ∑ x : σ, if P x = true then g x else 0
Instances For
Exact-value form: an event mass that is a rational literal on the ℚ≥0 face is that literal on the PMF face.