pRHL with couplings as the primitive judgment (CLAUDE.md subtask 3) #
The candidate definition under evaluation:
prhl A c d B := ∀ m₁ m₂, A (m₁, m₂) →
∃ μ, map fst μ = c m₁ ∧ map snd μ = d m₂ ∧ satisfy (μ, B)
Here ProgramDenotation.prhl A c d B := ∀ σ₁ σ₂, A σ₁ σ₂ → Nonempty (Coupling …),
with ProgramDenotation.Coupling (PRHL/Coupling.lean) playing the role of the
existential: its marg₁/marg₂ fields state the marginal conditions in
expected-value form (Coupling.map_fst/map_snd below recover the literal
map fst μ = c m₁ form), and its supp field is CertiCrypt's range-form
of satisfy. SubProbability.satisfies below is the subtask's literal
pointwise form ∀ x, μ x ≠ 0 → B x; the two are equivalent for discrete
(countable) state — see satisfies_iff_range, whose → direction is
exactly where countability is needed.
Evaluation findings (discrete setting) #
- The textbook obstacle dissolves. In a general Giry-monad setting the
seq rule needs a measurable choice of continuation couplings. With the
⊤σ-algebra every function is measurable, soClassical.choicecomposes pointwise andCoupling.comp(below) provesprhl.bindwith no side conditions. This is the rule that costs CertiCrypt/SSProve real infrastructure. - Soundness is one line:
prhl.to_relEviarelE.of_coupling— every coupling-judgment yields the wp-lifting judgment, so allrelEelimination forms (wp_eq,bad_eq,up_to_bad) apply toprhl. - Open: completeness (discrete Strassen). The converse
c.relE d A B → ProgramDenotation.prhl A c d Bis true for countable state but amounts to a countable max-flow/min-cut (Hall) argument constructing a witness from the family of wp-inequalities; it is not formalized here. Until it is,prhlis a (possibly strictly) stronger judgment per instance, and the two logics interoperate one-way. - Open: transitivity. Gluing two couplings along the common middle
marginal needs discrete disintegration (division by the middle weights
in
ENNReal); deferred. The wp-liftingrel.transneeds nothing. - Open: while. A coupling for a loop needs a fixed point of a
coupling transformer; deferred (the wp-lifting
rel.while_loopcovers loops, and transports toprhl-provable goals viato_relE).
The judgment #
Coupling-based pRHL (subtask-3 argument order: predicate, program, program, predicate).
Equations
- GaudisCrypt.ProgramDenotation.prhl A c d B = ∀ (σ₁ : s₁) (σ₂ : s₂), A σ₁ σ₂ → Nonempty (c.Coupling d σ₁ σ₂ B)
Instances For
The witness fields recover the literal subtask-3 conditions #
Subprobabilities with equal expected values are equal.
map fst μ = c m₁, literally.
map snd μ = d m₂, literally.
Expected values agree for posts that agree on the support.
The pointwise satisfy and discreteness #
Subtask 3 defines satisfy (μ, B) := ∀ x, μ x ≠ 0 → B x. The witness
structure uses the range form instead (∀ f vanishing on B, ∫ f dμ = 0),
which needs no decidability or countability. The two agree for discrete
state — and the proof shows exactly where countability enters: only in
the direction pointwise → range (summing the atoms).
Range form implies pointwise form — no countability needed.
Pointwise form implies range form — this is where discreteness is used: the integral is the
sum of its atoms. Countability-free (subtask 4): via the discreteness invariant
(lintegral_eq_tsum_smul) rather than lintegral_countable'.
Soundness with respect to the wp-lifting #
Every coupling judgment yields the (two-sided) wp-lifting judgment;
all relE elimination forms transfer. The converse is discrete
Strassen — see the module header.
Structural rules on the coupling judgment #
Consequence. The same witness works: the support condition only weakens.
Diagonal coupling: any program relates to itself at equal states.
Equations
Instances For
Reflexivity.
The rnd rule: uniform samples coupled along a bijection.
Case split / existential / disjunction on the precondition.
The seq rule (the crux of the evaluation) #
In a general measure-theoretic setting this rule requires a measurable
selection of continuation couplings — the main technical burden of
coupling-based pRHL semantics. With the ⊤ σ-algebra, every function is
measurable, so a plain Classical.choice per support point suffices and
the composite below typechecks with no side conditions.
Composition of couplings through bind: a coupling for the
prefixes plus a coupling for the continuations at every support point
yields a coupling for the composites.
Equations
Instances For
The seq rule.
Footprint rules: almost-sure unary facts strengthen the post #
Strengthen the post with an almost-sure left-side fact (the witness is
unchanged; only the support condition is rebalanced). This is how
inRange-style footprint facts enter the coupling logic.
Equations
- c.strengthen_left hC = { w := c.w, marg₁ := ⋯, marg₂ := ⋯, supp := ⋯ }