Relational program-logic baseline #
This file defines RelTriple via the generic two-monad algebra interface
MAlgRelOrdered, instantiated for OracleComp using coupling semantics.
HasCoupling and coupling lemmas remain as semantic bridge lemmas.
Relational postconditions over two output spaces.
Instances For
Equality relation helper for same-type outputs.
Instances For
Coupling-based semantic relational WP for OracleComp.
Instances For
Relational algebra instance for OracleComp, based on coupling semantics.
Anchoring instance for the qualitative Prop-valued relational logic on OracleComp.
When one of the two computations is pure, the relational coupling logic collapses to the
unary support-based logic of the other side. This is the relational analogue of the
Dirac coupling identity c (a, b) = (evalDist y) b whenever c couples pure a with y.
Together with the unary Prop algebra in VCVio/ProgramLogic/Unary/HoarePropTriple.lean,
this lets wpExc / rwpExc-style honest exception combinators (in
ToMathlib/Control/Monad/RelationalAlgebraAnchored.lean) be derived uniformly.
Relational weakest precondition induced by MAlgRelOrdered for OracleComp.
Instances For
Relational Hoare-style triple with implicit precondition True.
Instances For
Existence of an SPMF coupling witness between two computations.
Instances For
Any relational triple yields a coupling witness.
Pure values on both sides: R a b implies the coupling.
Reflexivity rule for relational triples on equality.
Postcondition monotonicity for relational triples.
The trivial product coupling always exists for OracleComp, so any pair of computations
satisfies the constantly-true postcondition.
The witness is the product coupling evalDist oa ⊗ evalDist ob, which is well-defined because
OracleComp computations have no failure mass. This discharges any RelTriple goal whose
postcondition is structurally fun _ _ => True and is the foundation of the trivial-leaf
closer in tryCloseRelGoalImmediate.
Any postcondition that is unconditionally true gives a valid relational triple, via the product coupling. Useful as a closing rule for vacuous postconditions.
Symmetry for relational triples, swapping the two computations and the postcondition.
Transport a relational triple across equality of the left output distribution.
Transport a relational triple across equality of the right output distribution.
Bind composition rule for relational triples.
Equality of programs gives an equality-relation relational triple.
Equality of evaluation distributions gives an equality-relation relational triple.
If two computations have equal output distributions, any reflexive postcondition holds.
Pointwise output-probability equality gives an equality-relation relational triple.
Swapping two adjacent independent binds preserves the output distribution.
Equality-relation relational triples imply equality of point output probabilities.
Equality-relation relational triples imply equality of evaluation distributions.
Transitivity through an intermediate computation related to the left side by EqRel.
Transitivity through an intermediate computation related to the right side by EqRel.
Transitivity of equality-relation relational triples through an intermediate computation.
Bool-specialized bridge from relational triples to game success equality.
Oracle query coupling rules (pRHL level) #
Same-type identity coupling: querying the same oracle on both sides yields equal outputs.
Bijection coupling (the "rnd" rule from EasyCrypt):
querying the same oracle on both sides, related by a bijection f.
Bind rule specialized to two equal oracle queries coupled by a bijection.
The continuation is stated over the left sample only, with the right sample
already rewritten to f a. This is the stable continuation shape used by
the relational tactic for unary bijection hints.
If a relational triple holds for fun a b => f a = g b, then mapping by f and g
produces equal distributions. Generalizes evalDist_eq_of_relTriple_eqRel.
Lift a one-step coupling through bounded iteration.
Equality coupling version of relTriple_replicate.
Lift pointwise relational reasoning through finite list traversals.
Same-input equality-coupling specialization of relTriple_list_mapM.
Loop-invariant rule for bounded left folds over related input lists.
Same-input specialization of relTriple_list_foldlM.
Synchronized branching rule #
Synchronized conditional: if both sides branch on the same condition, the relational triple holds if it holds on both branches.
Pure-left rule: the left side is a pure value, applied via bind decomposition.
Pure-right rule: the right side is a pure value, applied via bind decomposition.
Relational coupling for uniform sampling via bijection.
Given a bijection f : α → α such that R x (f x) for all x,
the two uniform samples are related by R.
Bind rule specialized to two uniform samples coupled by a bijection.
The continuation is stated over the left sample only, with the right sample
already rewritten to f a. This avoids exposing an auxiliary equality witness
to proof scripts after rvcstep using f.
Identity coupling for uniform sampling.