Documentation

GaudisCrypt.Logic.PHoareExact

pHL on exact bounds: seq, case, conseq #

The rules EasyCrypt's scripts use on phoare[ c : P ==> Q ] = r when r is not 1 (PIR.ec's Pr_PIR_s, vonNeumann.eca):

The tactics are in Logic/PHoareExactTactics.lean.

theorem GaudisCrypt.Stmt.ewp_congr_of_hoare {s : Stmt} {B : ProgramState → Prop} {σ : ProgramState} (h : hoare[ CurrentState.state = σ ==> B CurrentState.state ] { stmt s; }) {F G : ProgramState → ENNReal} (hFG : ∀ (τ : ProgramState), B τ → F τ = G τ) :
s.ewp F σ = s.ewp G σ

Under a Hoare triple of s from σ, expectations that agree on its postcondition have the same expected value.

theorem GaudisCrypt.EC.ge0_mu {α : Type} (d : SubProbability α) (E : α → Prop) :
0 ≤ mu d E

EC's ge0_mu.

theorem GaudisCrypt.EC.le1_mu {α : Type} (d : SubProbability α) (E : α → Prop) :
mu d E ≤ 1

EC's le1_mu.

theorem GaudisCrypt.hoareStmt_true (A : ProgramState → Prop) (s : Stmt) :
hoare[ A CurrentState.state ==> True ] { stmt s; }

Every statement satisfies the postcondition true.

theorem GaudisCrypt.Stmt.ewp_zero (s : Stmt) (σ : ProgramState) :
s.ewp (fun (x : ProgramState) => 0) σ = 0

The expected value of 0 is 0.

def GaudisCrypt.PHoareSeqBranch (A : ProgramState → Prop) (s₁ s₂ : Stmt) (E : ProgramState → Prop) (Q : ProgramState → ENNReal) (p q : ENNReal) :

The contribution of one branch of pHL's seq: the runs of s₁ that end in E, then s₂ to Q, have probability p * q.

Equations
Instances For
    theorem GaudisCrypt.phoareStmt_seq_eq {A : ProgramState → Prop} {s₁ s₂ : Stmt} (E I : ProgramState → Prop) {Q : ProgramState → ENNReal} (p₁ p₂ p₃ p₄ : ℝ) {r : ProgramState → ENNReal} (h0 : 0 ≤ p₁ ∧ 0 ≤ p₂ ∧ 0 ≤ p₃ ∧ 0 ≤ p₄) (hI : hoare[ A CurrentState.state ==> I CurrentState.state ] { stmt s₁; }) (hE : PHoareSeqBranch A s₁ s₂ (fun (τ : ProgramState) => E τ ∧ I τ) Q (ENNReal.ofReal p₁) (ENNReal.ofReal p₂)) (hN : PHoareSeqBranch A s₁ s₂ (fun (τ : ProgramState) => ¬E τ ∧ I τ) Q (ENNReal.ofReal p₃) (ENNReal.ofReal p₄)) (hr : ∀ (σ : ProgramState), A σ → r σ = ENNReal.ofReal (p₁ * p₂ + p₃ * p₄)) :
    phoare[ A CurrentState.state ==> Q CurrentState.state ] = (r CurrentState.state) { stmt s₁; stmt s₂; }

    pHL's seq with five bounds, for an exact bound, from its two branches.

    theorem GaudisCrypt.PHoareSeqBranch.both {A : ProgramState → Prop} {s₁ s₂ : Stmt} {E I : ProgramState → Prop} {Q : ProgramState → ENNReal} {p q : ENNReal} (hI : hoare[ A CurrentState.state ==> I CurrentState.state ] { stmt s₁; }) (h₁ : phoare[ A CurrentState.state ==> E CurrentState.state ] = p { stmt s₁; }) (h₂ : phoare[ E CurrentState.state ∧ I CurrentState.state ==> Q CurrentState.state ] = q { stmt s₂; }) :
    PHoareSeqBranch A s₁ s₂ (fun (τ : ProgramState) => E τ ∧ I τ) Q p q

    A branch of seq from its two judgments.

    theorem GaudisCrypt.PHoareSeqBranch.second_zero {A : ProgramState → Prop} {s₁ s₂ : Stmt} {E : ProgramState → Prop} {Q : ProgramState → ENNReal} (p : ENNReal) (h₂ : phoare[ E CurrentState.state ==> Q CurrentState.state ] = 0 { stmt s₂; }) :
    PHoareSeqBranch A s₁ s₂ E Q p (ENNReal.ofReal 0)

    A branch of seq whose second bound is 0: the first is not needed (EC's _).

    theorem GaudisCrypt.PHoareSeqBranch.first_zero {A : ProgramState → Prop} {s₁ s₂ : Stmt} {E I : ProgramState → Prop} {Q : ProgramState → ENNReal} (q : ENNReal) (hQ : ∀ (τ : ProgramState), Q τ ≤ 1) (h₁ : phoare[ A CurrentState.state ==> E CurrentState.state ] = 0 { stmt s₁; }) :
    PHoareSeqBranch A s₁ s₂ (fun (τ : ProgramState) => E τ ∧ I τ) Q (ENNReal.ofReal 0) q

    A branch of seq whose first bound is 0, for a postcondition at most 1 (an event): the second is not needed (EC's _).

    theorem GaudisCrypt.phoareStmt_seq_ge {A : ProgramState → Prop} {s₁ s₂ : Stmt} (E I : ProgramState → Prop) {Q : ProgramState → ENNReal} (p₁ p₂ p₃ p₄ : ℝ) {r : ProgramState → ENNReal} (h0 : 0 ≤ p₁ ∧ 0 ≤ p₂ ∧ 0 ≤ p₃ ∧ 0 ≤ p₄) (hI : hoare[ A CurrentState.state ==> I CurrentState.state ] { stmt s₁; }) (h₁ : phoare[ A CurrentState.state ==> E CurrentState.state ] ≥ (ENNReal.ofReal p₁) { stmt s₁; }) (h₂ : phoare[ E CurrentState.state ∧ I CurrentState.state ==> Q CurrentState.state ] ≥ (ENNReal.ofReal p₂) { stmt s₂; }) (h₃ : phoare[ A CurrentState.state ==> ¬E CurrentState.state ] ≥ (ENNReal.ofReal p₃) { stmt s₁; }) (h₄ : phoare[ ¬E CurrentState.state ∧ I CurrentState.state ==> Q CurrentState.state ] ≥ (ENNReal.ofReal p₄) { stmt s₂; }) (hr : ∀ (σ : ProgramState), A σ → r σ ≤ ENNReal.ofReal (p₁ * p₂ + p₃ * p₄)) :
    phoare[ A CurrentState.state ==> Q CurrentState.state ] ≥ (r CurrentState.state) { stmt s₁; stmt s₂; }

    pHL's seq with five bounds, for a lower bound.

    Every expectation is at least 0 (a bound _ of seq on a lower bound).

    theorem GaudisCrypt.phoareStmt_case {A : ProgramState → Prop} {s : Stmt} {Q : ProgramState → ENNReal} {ρ : ENNReal → ENNReal → Prop} {r : ProgramState → ENNReal} (E : ProgramState → Prop) (h₁ : phoareStmt (fun (σ : ProgramState) => A σ ∧ E σ) s Q ρ r) (h₂ : phoareStmt (fun (σ : ProgramState) => A σ ∧ ¬E σ) s Q ρ r) :
    phoareStmt A s Q ρ r

    pHL's case E.

    theorem GaudisCrypt.phoareStmt_conseq_bound {A : ProgramState → Prop} {s : Stmt} {Q : ProgramState → ENNReal} {ρ : ENNReal → ENNReal → Prop} {r : ProgramState → ENNReal} (r' : ProgramState → ENNReal) (hr : ∀ (σ : ProgramState), A σ → r σ = r' σ) (h : phoareStmt A s Q ρ r') :
    phoareStmt A s Q ρ r

    pHL's conseq (: _ ==> _ : = e): another bound, equal to the judgment's under the precondition.

    theorem GaudisCrypt.phoareStmt_conseq_pre {A : ProgramState → Prop} {s : Stmt} {Q : ProgramState → ENNReal} {ρ : ENNReal → ENNReal → Prop} {r : ProgramState → ENNReal} (A' : ProgramState → Prop) (hA : ∀ (σ : ProgramState), A σ → A' σ) (h : phoareStmt A' s Q ρ r) :
    phoareStmt A s Q ρ r

    pHL's conseq (: P ==> _): a weaker precondition.

    theorem GaudisCrypt.phoareStmt_conseq_hoare {A : ProgramState → Prop} {s : Stmt} {Q : ProgramState → Prop} {r : ProgramState → ENNReal} (Q₁ Q₂ : ProgramState → Prop) (hpost : ∀ (τ : ProgramState), Q₂ τ → (Q₁ τ ↔ Q τ)) (hh : hoare[ A CurrentState.state ==> Q₂ CurrentState.state ] { stmt s; }) (hp : phoare[ A CurrentState.state ==> Q₁ CurrentState.state ] = (r CurrentState.state) { stmt s; }) :
    phoare[ A CurrentState.state ==> Q CurrentState.state ] = (r CurrentState.state) { stmt s; }

    pHL's conseq (: _ ==> Q₁) (: _ ==> Q₂) on an exact bound: the event Q₁ with the bound, and Q₂ in Hoare logic, under which Q₁ and the judgment's event agree.

    theorem GaudisCrypt.phoareStmt_conseq_of {A A' : ProgramState → Prop} {s : Stmt} {Q : ProgramState → ENNReal} {ρ : ENNReal → ENNReal → Prop} {r r' : ProgramState → ENNReal} (H : phoareStmt A' s Q ρ r') (hA : ∀ (σ : ProgramState), A σ → A' σ) (hr : ∀ (σ : ProgramState), A σ → r σ = r' σ) :
    phoareStmt A s Q ρ r

    pHL's conseq H: from a judgment H about the same statement and postcondition, with a weaker precondition and a bound equal under the goal's precondition.