Documentation

GaudisCrypt.Logic.ECAuto

EasyCrypt's auto and rnd steps for hoare and phoare #

phoare_auto, hoare_auto   -- EC's `auto`: wp over the code back to the last call, then `skip`

Our phoare is computed by wp, samplings included (exact averages), so EC's rnd steps on a phoare goal become, once phoare_auto has gone through the code, steps on an expectation d.expected f ≤ r left by a sampling:

rnd_pred1 v    -- EC's `rnd (pred1 v)`: `f a ≤ [v = a]`, bounded by `d {v}`
rnd_bound      -- EC's `rnd` with a lossless distribution: `f a ≤ r` for every `a`
rnd_null       -- EC's `hoare`: `f` is `0` on the support, whatever the bound

Each leaves the pointwise goal (the obligation EC's auto would leave after the step).

theorem GaudisCrypt.SubProbability.expected_le_of_le_pred1 {α : Type} {d : SubProbability α} {f : α → ENNReal} {r : ENNReal} (v : α) (h : ∀ (a : α), f a ≤ indicatorE (v = a)) (hv : ↑d {v} ≤ r) :

EC's rnd (pred1 v) on an upper bound: an expectation below the indicator of v is at most the mass of v.

theorem GaudisCrypt.SubProbability.expected_le_of_le {α : Type} {d : SubProbability α} {f : α → ENNReal} {r : ENNReal} (h : ∀ (a : α), f a ≤ r) :

EC's rnd on a lossless distribution: a pointwise bound is a bound of the expectation (the total mass is at most 1).

theorem GaudisCrypt.SubProbability.expected_le_of_null {α : Type} {d : SubProbability α} {f : α → ENNReal} {r : ENNReal} (h : ∀ a ∈ d.support, f a = 0) :

EC's hoare (probability 0): an expectation null on the support is below anything.

@[simp]

An event's indicator is 1 exactly when the event holds (what a phoare … = 1 leaves).

theorem GaudisCrypt.Lens.get_eq_of_touched_getter_eq {β : Type u_1} {m : Type u_2} (x : Lens β m) {R : Footprint m} (hx : x.footprint ≤ R) {σ σ' : m} (h : R.touched_getter.get σ = R.touched_getter.get σ') :
x.get σ = x.get σ'

Equal on a region R (EC's ={glob C}), so equal on each variable inside it (={C.c, C.queries}, a concrete module's glob being its variables).

EC's ={glob C} as the equalities of C's variables: for each hypothesis R.touched_getter.get a = R.touched_getter.get b, the hypotheses x.get a = x.get b for the variables x read at a or b (in the goal or a hypothesis) that lie inside R: R a region of variables among which x is (fp_le), or a concrete module's footprint and the module writes x (fp_writes).

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

    EC's auto on the statement judgment g (a registered one): wp over the statements from the end (Judgment.wpOne: deterministic code, samplings, conditionals) until a call or skip.

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

      The precondition (argument 0) with its reads of pairs of globals taken apart ((§(Lens.pair X Y)).1 is §X), so that skip generalizes the reads to plain variables (as fel's view of several variables reads them).

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

        hoare_skip with the goal beta-reduced first (as phoare_skip does), so that the reads are generalized to plain variables.

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

          EC's ={glob C} as ={C.c, C.queries} in a closer: see ECAuto.globReads.

          Equations
          Instances For

            The samplings' mass where the distribution is lossless (@[ec_lossless], EC's auto), in the goal, and nothing else: the other reductions of simp (projections, β, ζ, …) are off (Simp.neutralConfig), so that the goal keeps the form the hand proofs after auto read.

            Equations
            Instances For

              EC's auto on a phoare statement judgment: wp back to the last call, then skip if the code is used up, the trivial goals (1 = 1) closed.

              Equations
              Instances For

                EC's auto on a relational judgment about statements: wp, the samplings on both sides by rnd (with wp after each), skip when the code is used up, and the trivial goals closed (simp_all only when it closes the goal).

                Equations
                Instances For

                  EC's auto on a Hoare triple about a statement (the memories of a side goal ∀ σ₁, hoare[ … ] introduced first; the trivial goals closed).

                  Equations
                  Instances For

                    EC's rnd (pred1 v) on a goal d.expected f ≤ r: the goal f a ≤ [v = a] for every a (a introduced), then d {v} ≤ r unless le_rfl closes it.

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

                      EC's rnd with a lossless distribution, on a goal d.expected f ≤ r: the goal f a ≤ r for every a (a introduced).

                      Equations
                      Instances For

                        EC's hoare (probability 0) on a goal d.expected f ≤ r: the goal f a = 0 for every a in the support (a, ha introduced).

                        Equations
                        Instances For