Documentation

GaudisCrypt.Logic.ECLoop

EasyCrypt's splitwhile and unroll #

stmt_splitwhile{i} n : e     -- EC's `splitwhile{i} n : e`
stmt_unroll{i} n             -- EC's `unroll{i} n`

The loop at EC's position n (from 1, the resets inlining leaves not counted, as for stmt_swap [a..b] k) is rewritten by an equivalence of statements: while c b becomes while (c /\ e) b; while c b (splitwhile), or if c { b; while c b } (unroll). On any registered judgment, on side i of a relational one. e is written like a condition of the goal (§x reads the program variable x) and may be a proposition (decided) or a boolean.

After splitwhile the two loops are two statements (the sequence is re-associated), so EC's positions after them count as in EC.

splitwhile holds for every loop, as in EC (Stmt.Equiv.splitwhile'): the split loop's expectation is the original's by the least-fixed-point property of loops alone (Stmt.ewp_while_le), no variant needed.

theorem GaudisCrypt.Stmt.ewp_splitwhile' (c e : Getter Bool ProgramState) (body : Stmt) (g : ProgramState → ENNReal) (σ : ProgramState) :
ewp (GaudiProg[ while (§c) { stmt body; } ]) g σ = ewp (GaudiProg[ while (§(c.andB e)) { stmt body; } while (§c) { stmt body; } ]) g σ

splitwhile, on expectations, for every loop: a loop is the same loop run first while e also holds, then on.

theorem GaudisCrypt.Stmt.Equiv.splitwhile' (c e : Getter Bool ProgramState) (body : Stmt) :
GaudiProg[ while (§c) { stmt body; } ].Equiv (GaudiProg[ while (§(c.andB e)) { stmt body; } while (§c) { stmt body; } ])

splitwhile (EC's splitwhile … : e), as an equivalence of statements, for every loop.

Rewrite the statement at our position p (from 0) along the right-nested sequence s₀ (through the lets of the locals) by f, which gives the new statement and its equivalence to the old one: the new sequence and its equivalence.

The loop while c body of the statement s: (c, body).

Equations
  • One or more equations did not get rendered due to their size.
Instances For

    Our position (from 0) of EC's statement n (from 1) of the statement s: the last of its group (ecGroups: the resets before it come first).

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For

      A condition written like those of the goal's program (§x reads the program variable x), a proposition (decided) or a boolean, as a getter of the program state.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For

        The guard c /\ e of the first loop of a split: for two condition getters Getter.mk f, Getter.mk g (what GaudiExpr[ ] gives) the getter of f st && g st, whose reads the tactics see (and which prints as a condition); Getter.andB c e otherwise.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For

          Is the statement at our position p (from 0) of the statement s₀ a loop?

          The loop at our position p (from 0) of side side? of the judgment g, unrolled (Stmt.Equiv.unroll): if c { body; while c body }.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For

            EC's splitwhile{i} n : e: see the module docstring.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For

              EC's unroll{i} n: see the module docstring.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For