Footprint and frame tactics, invariant Hoare rules #
Small helpers for game proofs that frame oracles against an abstract adversary:
fp_mem:X ≤ A₁ ⊔ … ⊔ AₙforXone of the joinands;fp_sub: a join below a join;writes_keep':writes_keepwith the footprint hypotheses found syntactically;hoareProc_const,hoare_if_inv,hoare_seq_inv: Hoare rules for an invariant.
X ≤ A₁ ⊔ … ⊔ Aₙ for X one of the joinands (nested joins included), by backtracking.
Equations
- GaudisCrypt.tacticFp_mem = Lean.ParserDescr.node `GaudisCrypt.tacticFp_mem 1024 (Lean.ParserDescr.nonReservedSymbol "fp_mem" false)
Instances For
A join of footprints below a join containing each of its joinands (fp_mem, splitting the
left-hand join).
Equations
- GaudisCrypt.tacticFp_sub = Lean.ParserDescr.node `GaudisCrypt.tacticFp_sub 1024 (Lean.ParserDescr.nonReservedSymbol "fp_sub" false)
Instances For
writes_keep, the writes to global lenses closed by touched_set_of_le_compl with a hypothesis
X.footprint ≤ Fᶜ about the written lens X itself (found syntactically, not by assumption,
which compares the footprints of different lenses by unfolding them).
Equations
- GaudisCrypt.tacticWrites_keep' = Lean.ParserDescr.node `GaudisCrypt.tacticWrites_keep' 1024 (Lean.ParserDescr.nonReservedSymbol "writes_keep'" false)
Instances For
theorem
GaudisCrypt.hoareProc_const
{sig : ProcedureSignature}
(p : Procedure sig)
(P : Prop)
:
hoareProc (fun (x : sig.ParamType) (x_1 : VariableAssignment) => P) p fun (x : sig.ret) (x_1 : VariableAssignment) => P
A Hoare triple whose pre- and postcondition are the same proposition, independent of the state.
theorem
GaudisCrypt.hoare_if_inv
{c : Getter Bool ProgramState}
{p q : Stmt}
{J B : ProgramState → Prop}
(ht : hoareStmt J p B)
(he : hoareStmt J q B)
:
hoareStmt J
(GaudiProg[
if (§c) {
stmt p;
} else {
stmt q;
}
])
B
A conditional keeps an invariant when both branches do.
theorem
GaudisCrypt.hoare_seq_inv
{J C : ProgramState → Prop}
{p q : Stmt}
(hq : hoareStmt J q C)
(hp : hoareStmt J p J)
:
hoareStmt J
(GaudiProg[
stmt p;
stmt q;
])
C
Sequencing through an invariant: the first part keeps the precondition.