Documentation

GaudisCrypt.Logic.GlobWrites

Lower bounds of footprints: a module's writes #

fp_le bounds FVP.fvP M from above. EC's ={glob M} of a concrete module M is the equality of M's variables; ours is the equality on FVP.fvP M's touched getter (glob M is the region M may touch), and to get a variable's equality back, the variable must lie inside that region: a lower bound.

A region containing every constant write of a lens x (Footprint.HasWrites) contains x's tests (Footprint.HasWrites.testKer_mem, the argument of Lens.testKer_mem_footprint), and the tests read x: equal on the region, so equal on x (Lens.get_eq_of_touched_getter_eq_of_hasWrites). A procedure whose code assigns the global x somewhere (its callees included) has all of x's constant writes in its footprint: an assignment's footprint is that of the writes of every value (FVP.fvpInductiveFunctionGS.setter).

fp_writes   -- `(FVP.fvP M).HasWrites x`, `M` a concrete module assigning `x` somewhere

fp_writes goes down M's module type to its procedures (Module.fst'/Module.snd', each a lower bound of M's footprint), unfolds each as the inliner does (Flatten.unfoldProcedure) and looks for an assignment of x in its code (callees' bodies included). EC reads a concrete module's globals off its code; this is that reading, for the variables the module writes.

def GaudisCrypt.Footprint.HasWrites {a : Type u_1} {m : Type u_2} (R : Footprint m) (X : Lens a m) :

R contains every constant write of X.

Equations
Instances For
    theorem GaudisCrypt.Footprint.HasWrites.mono {a : Type u_1} {m : Type u_2} {R S : Footprint m} {X : Lens a m} (h : R ≤ S) (hR : R.HasWrites X) :
    theorem GaudisCrypt.Footprint.HasWrites.testKer_mem {a : Type u_1} {m : Type u_2} {R : Footprint m} {X : Lens a m} (hR : R.HasWrites X) (x₀ : a) :

    A region with X's constant writes contains X's tests (as Lens.testKer_mem_footprint: a kernel commuting with the writes keeps X's content, so the test passes it or kills it).

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

    EC's ={glob M} gives ={x} for a variable x whose writes lie in the region.

    theorem GaudisCrypt.Footprint.HasWrites.pair {a : Type u_1} {b : Type u_2} {m : Type u_3} {R : Footprint m} {x : Lens a m} {y : Lens b m} [x.Disjoint y] (hx : R.HasWrites x) (hy : R.HasWrites y) :
    R.HasWrites (x.pair y)

    The writes of a pair of variables: one's after the other's.

    theorem GaudisCrypt.touched_getter_eq_iff_of_writes {β : Type u_1} {m : Type u_2} {X : Lens β m} {R : Footprint m} (hle : R ≤ X.footprint) (hw : R.HasWrites X) (a b : m) :

    EC's glob M of a concrete module is its variables X: a region between X's writes and X's footprint is equal exactly where X is.

    The writes of code #

    theorem GaudisCrypt.GlobWrites.setter {α : Type} (x : Setter α ProgramState) (Y : Lens α ProgramState) (hx : ∀ (v : α) (σ : ProgramState), x.set v σ = Y.set v σ) :

    An assignment's footprint has the writes of its variable.

    The globals' share of a statement has the writes of a global it assigns.

    A callee's globals' share, back in the caller's state, has the writes of a global the callee assigns.

    theorem GaudisCrypt.GlobWrites.ite_left {h : HoleSigs} (c : Getter Bool ProgramState) (s t : StmtWithHoles h) {β : Type} {Y : Lens β ProgramState} (hs : (FVP.fvpInductiveFunctionGS.stmt s).HasWrites Y) :
    (FVP.fvpInductiveFunctionGS.stmt (GaudiProg[ if (§c) { stmt s; } else { stmt t; } ])).HasWrites Y
    theorem GaudisCrypt.GlobWrites.ite_right {h : HoleSigs} (c : Getter Bool ProgramState) (s t : StmtWithHoles h) {β : Type} {Y : Lens β ProgramState} (ht : (FVP.fvpInductiveFunctionGS.stmt t).HasWrites Y) :
    (FVP.fvpInductiveFunctionGS.stmt (GaudiProg[ if (§c) { stmt s; } else { stmt t; } ])).HasWrites Y

    A procedure's footprint has the writes of a global its body assigns.

    A procedure module's footprint is its procedure's.

    Apply lem to g, the new goals (the hypotheses left open).

    Equations
    Instances For

      Run k, restoring the state if it fails.

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

        Rewrite the procedure p (a Module.Proc.procedure M in g's goal) to its code, as the inliner does.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          partial def GaudisCrypt.GlobWrites.goStmt (g : Lean.MVarId) (fuel : ℕ := 256) :

          Close (st s).HasWrites Y (Y a global's lens in the program state) by an assignment of Y in s, callees' bodies included.

          Close (FVP.fvP M).HasWrites X by an assignment of X in one of M's procedures.

          The procedures of a module (Module.Proc leaves of its module type, by Module.fst' and Module.snd').

          The globals the statement s assigns (liftLens X, X a lens into the globals), callees' bodies included, added to acc.

          The globals the module M's code assigns.

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

            R.HasWrites X for X a Lens.pair of variables a concrete module (R = FVP.fvP M) writes.

            EC's glob M of a concrete module, off its code: for R = FVP.fvP M, the variables X M writes, if M touches nothing else (fp_le): the proof of ∀ a b, (R.touched_getter.get a = R.touched_getter.get b) = (X.get a = X.get b).

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

              fp_writes: close (FVP.fvP M).HasWrites x for a concrete module M whose code assigns the global x somewhere (one of its procedures, a callee's body included).

              Equations
              Instances For