Slot marginal law and insertion kernels (margLaw, insKernel)
DefinitionmargLawFor a law on packets supported on slot set , the slot- marginal law is the pushforward. The insertion kernel inserts at slot when the existing entries agree with and the marginal is positive, and is the zero kernel otherwise.
import Mathlib.Algebra.BigOperators.Group.Finset.Basic
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Fintype.Pi
import Mathlib.Data.Real.Basic
/-!
# Filtered descent — insertion kernels (paper (13)–(16))
Finite model of the descent's insertion kernels. Paper (13) defines, for
slot sets `A ⊆ B`, the conditional law
`K_{A,B}(x_B | x_A) = P_B(x_B) / (P_A(x_A) * 1_{x_B|_A = x_A})`
of the `B`-slots given the `A`-slots. Paper (14) is the chain rule
`K_{A,C} = K_{B,C} * K_{A,B}`, paper (15) the pull-push (Fubini) identity,
and paper (16) the confluence of insertions.
-/
namespace FilteredDescent
/-- Marginal of a joint packet law on a slot set `A`, as a function on full
assignments (it depends only on the values on `A`). Setup for paper (13). -/
noncomputable def margLaw {m n : ℕ} (P : (Fin m → Fin n) → ℝ)
(A : Finset (Fin m)) : (Fin m → Fin n) → ℝ :=
fun x => ∑ y : Fin m → Fin n, if ∀ a ∈ A, y a = x a then P y else 0
/-- Insertion kernel `K_{A,B}(x_B | x_A)`: conditional law of the `B`-slots
given the `A`-slots. Paper (13):
`K_{A,B}(x_B | x_A) = P_B(x_B) / (P_A(x_A) * 1_{x_B|_A = x_A})`
implemented with the agreement indicator in the branch condition (the
`1_{…}` factor is `0/1`-valued, so dividing by it is the same as
conditioning on agreement). -/
noncomputable def insKernel {m n : ℕ} (P : (Fin m → Fin n) → ℝ)
(A B : Finset (Fin m)) : (Fin m → Fin n) → (Fin m → Fin n) → ℝ :=
fun xB xA =>
if (∀ a ∈ A, xB a = xA a) ∧ margLaw P A xA ≠ 0
then margLaw P B xB / margLaw P A xA
else 0
end FilteredDescent
Read-back
What the Lean code literally says, in plain math · muse-spark
I have read the auditor instructions and the Lean file. I have not consulted any other files. Here are the read-backs.
Read-back for margLaw
For any natural numbers and (implicitly quantified, including the degenerate cases or ), any real-valued function defined on full assignments — i.e. on all functions from the slots to the values — and any finite set of slots, the declaration defines a new real-valued function on full assignments. Given a full assignment , its value is the finite sum, over all full assignments , of when agrees with on every slot , and when disagrees with on at least one slot of :
In particular the value at depends only on the restriction of to . Edge cases: if is empty, the agreement condition is vacuous and the value is the total sum regardless of ; if is the set of all slots, only contributes and the value is ; if and there are no assignments at all, so the sum is over the empty type and the value is . No hypothesis is placed on — it need not be nonnegative, need not sum to , and may be identically zero (in which case the marginal is identically zero).
Read-back for insKernel
For any natural numbers and , any real-valued function on full assignments (functions from the slots to the values), and any two finite sets of slots and , the declaration defines a real-valued function of two full assignments. Despite the argument names and , both arguments are full assignments — the code does not restrict them to or , and it imposes no requirement that . The value is defined by cases: if and agree on every slot and the marginal is nonzero, the value is the quotient
otherwise — i.e. if and disagree on some slot of , or if the denominator equals — the value is . Because the denominator is checked to be nonzero in the branch where division occurs, the division never hits a zero denominator; the numerator is unrestricted and may be zero or negative since is arbitrary. Edge cases: if is empty, the agreement condition holds vacuously and the denominator is the total mass (the value is whenever that total mass is ); if is empty, the numerator is the total mass; if the agreement condition is automatic but the nonzero-denominator check still applies. The declaration is noncomputable and carries no positivity, normalization, or subset hypotheses.