Loop transformations and statement-level transitivity #
EasyCrypt rewrites loops in a relational judgment before reasoning about them: splitwhile{i} k : e (a loop while c b becomes while (c /\ e) b; while c b) and unroll{i} k (one iteration
peeled off as a conditional). Here both are denotational equivalences of statements
(StmtWithHoles.Equiv), moved into a judgment with prhlStmt_of_equiv_left/_right.
splitwhile is proven for loops whose first part terminates by a variant (every SHA-3 loop is
bounded): the remaining loop's expectation is then a fixed point of the first part's loop, from
above (Stmt.ewp_while_le) and from below (Stmt.ewp_while_ge_variant).
EasyCrypt's transitivity{i} { code } P Q at the statement level is prhlStmt.trans.
Equivalence from denotations #
Statements with the same run are equivalent.
Statements with the same expectations have the same run.
The guard c /\ e of the first loop of a split.
Instances For
splitwhile, on expectations: a loop is the same loop run first while e also holds,
then on. V decreases on every round of the first loop.
splitwhile (EC's splitwhile … : e), as an equivalence of statements.
unroll (EC's unroll): one round of a loop, peeled off as a conditional.
A conditional followed by code #
The code after a conditional goes into both branches (what EC's if does with the rest of the
code).
In judgments, for a trailing loop #
splitwhile{1} on a trailing loop.
splitwhile{2} on a trailing loop.
unroll{1} on a trailing loop.
unroll{2} on a trailing loop.
splitwhile{1} on a loop that is the whole left statement.
splitwhile{2} on a loop that is the whole right statement.
unroll{1} on a loop that is the whole left statement.
unroll{2} on a loop that is the whole right statement.
Induction #
A judgment by cases on a measure of the initial states (for an induction on it, e.g. on the
rounds a loop has left: EC's elim on an integer in a proof by induction).
Transitivity #
Transitivity of statement judgments (EC's transitivity{i} { code } P Q, with code the
middle statement): the preconditions and postconditions compose through a middle state.