Framing a call by a footprint #
EC's module restrictions (A <: Adv {-Counter}) say that an abstract procedure does not touch
some global state. Here that is a footprint hypothesis,
(procedureDenotation p args).inFootprint (L.footprint)ᶜ, and the rules below turn it into Hoare
reasoning: a call to such a procedure leaves L as it was.
theorem
GaudisCrypt.hoareProc_frame
{sig : ProcedureSignature}
(p : Procedure sig)
{γ : Type u_1}
(L : Lens γ VariableAssignment)
(hp : ∀ (args : sig.ParamType), (procedureDenotation p args).inFootprint L.footprintᶜ)
(P : γ → Prop)
:
hoareProc (fun (x : sig.ParamType) (σ : VariableAssignment) => P (L.get σ)) p
fun (x : sig.ret) (σ : VariableAssignment) => P (L.get σ)
A procedure confined to the complement of L's footprint keeps every property of L.
theorem
GaudisCrypt.hoare_call_frame
{sig : ProcedureSignature}
{x : Setter sig.ret ProgramState}
{p : Procedure sig}
{args : Getter sig.ParamType ProgramState}
{γ : Type u_1}
(L : Lens γ VariableAssignment)
(hp : ∀ (a : sig.ParamType), (procedureDenotation p a).inFootprint L.footprintᶜ)
{B : ProgramState → Prop}
:
hoareStmt
(fun (σ : ProgramState) =>
∀ (r : sig.ret) (g : VariableAssignment), L.get g = L.get σ.globals → B (x.set r (ProgramState.globalL.set g σ)))
(Stmt.call x p args) B
The wp rule for a call to a procedure that does not touch L: B must hold after writing
any result and any globals that agree with the old ones on L. Use it with hoare_call:
hoare_call (hoare_call_frame L hp).