Documentation

LeanPool.OrderMaintenance.Impl.PeakHP

Theorem W, option (A), stage A2: composing peak bounds along a known run #

PK Γ W c s L: the run of c from (s, L) computes nothing at or above 2^W, and a normal end satisfies the invariant Gd Γ. Safe statements have it (PK.of_safe); the rules below compose it along a run whose intermediate states are known (from the agreement lemmas), and the statements that store a computed value (PK.assign, PK.wr, …) take the bound of that value as a hypothesis. These are the rules the per-procedure proofs of stage A2 use.

Nothing here is used by Theorems A and B.

def OrderMaintenance.Impl.PK (K KH : ℕ) (κ : Caps) (Γ : Machine.Reg → ℕ) (W : ℕ) (c : Stm) (s : Model.Core) (L : Loc) :

The peak bound of a run, with the invariant at its normal end, for a run that does not hit a bug.

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    theorem OrderMaintenance.Impl.PK.lt {K KH : ℕ} {κ : Caps} {Γ : Machine.Reg → ℕ} {W : ℕ} {s : Model.Core} {L : Loc} {c : Stm} (h : PK K KH κ Γ W c s L) {s' : Model.Core} {L' : Loc} {n : ℕ} (he : evalF κ c s L = Res.ok s' L' n) :
    pkF κ c s L < 2 ^ W
    theorem OrderMaintenance.Impl.PK.post {K KH : ℕ} {κ : Caps} {Γ : Machine.Reg → ℕ} {W : ℕ} {s : Model.Core} {L : Loc} {c : Stm} (h : PK K KH κ Γ W c s L) {s' : Model.Core} {L' : Loc} {n : ℕ} (he : evalF κ c s L = Res.ok s' L' n) :
    Gd K KH κ Γ s' L'
    theorem OrderMaintenance.Impl.PK.of_safe {K KH : ℕ} {κ : Caps} {Γ : Machine.Reg → ℕ} {W : ℕ} {s : Model.Core} {L : Loc} (hC : CapsW K κ) (hK : 3 ≤ K) (hW : K ≤ W) {c : Stm} (hS : Stm.Safe K KH Γ W c) (hG : Gd K KH κ Γ s L) :
    PK K KH κ Γ W c s L
    theorem OrderMaintenance.Impl.Gd.mono {K KH : ℕ} {κ : Caps} {Γ Γ' : Machine.Reg → ℕ} {s : Model.Core} {L : Loc} (h : Gd K KH κ Γ s L) (hΓ : ∀ (x : Machine.Reg), Γ x ≤ Γ' x) :
    Gd K KH κ Γ' s L
    theorem OrderMaintenance.Impl.PK.mono {K KH : ℕ} {κ : Caps} {Γ Γ' : Machine.Reg → ℕ} {W : ℕ} {s : Model.Core} {L : Loc} {c : Stm} (h : PK K KH κ Γ W c s L) {W' : ℕ} (hW : W ≤ W') (hΓ : ∀ (x : Machine.Reg), Γ x ≤ Γ' x) :
    PK K KH κ Γ' W' c s L
    theorem OrderMaintenance.Impl.PK.seq {K KH : ℕ} {κ : Caps} {Γ Γ' : Machine.Reg → ℕ} {W : ℕ} {s : Model.Core} {L : Loc} {c d : Stm} (hc : PK K KH κ Γ' W c s L) (hd : ∀ (s1 : Model.Core) (L1 : Loc) (n1 : ℕ), evalF κ c s L = Res.ok s1 L1 n1 → PK K KH κ Γ W d s1 L1) :
    PK K KH κ Γ W (c;; d) s L
    theorem OrderMaintenance.Impl.PK.seq_g {K KH : ℕ} {κ : Caps} {Γ Γ' : Machine.Reg → ℕ} {W : ℕ} {s : Model.Core} {L : Loc} {c d : Stm} (hc : PK K KH κ Γ' W c s L) (hd : ∀ (s1 : Model.Core) (L1 : Loc) (n1 : ℕ), evalF κ c s L = Res.ok s1 L1 n1 → Gd K KH κ Γ' s1 L1 → PK K KH κ Γ W d s1 L1) :
    PK K KH κ Γ W (c;; d) s L
    theorem OrderMaintenance.Impl.PK.seq_ok {K KH : ℕ} {κ : Caps} {Γ Γ' : Machine.Reg → ℕ} {W : ℕ} {s s1 : Model.Core} {L L1 : Loc} {c d : Stm} {n1 : ℕ} (h1 : evalF κ c s L = Res.ok s1 L1 n1) (hc : PK K KH κ Γ' W c s L) (hd : PK K KH κ Γ W d s1 L1) :
    PK K KH κ Γ W (c;; d) s L
    theorem OrderMaintenance.Impl.PK.ite {K KH : ℕ} {κ : Caps} {Γ : Machine.Reg → ℕ} {W : ℕ} {s : Model.Core} {L : Loc} {c : Exp} {t f : Stm} {v : ℕ} (hv : Exp.ev κ s L c = some v) (hp : Exp.pk κ s L c < 2 ^ W) (ht : v ≠ 0 → PK K KH κ Γ W t s L) (hf : v = 0 → PK K KH κ Γ W f s L) :
    PK K KH κ Γ W (Stm.ite c t f) s L
    theorem OrderMaintenance.Impl.PK.skip {K KH : ℕ} {κ : Caps} {Γ : Machine.Reg → ℕ} {W : ℕ} {s : Model.Core} {L : Loc} (hG : Gd K KH κ Γ s L) :
    PK K KH κ Γ W Stm.skip s L
    theorem OrderMaintenance.Impl.PK.fail {K KH : ℕ} {κ : Caps} {Γ : Machine.Reg → ℕ} {W : ℕ} {s : Model.Core} {L : Loc} :
    PK K KH κ Γ W Stm.fail s L
    theorem OrderMaintenance.Impl.PK.bug {K KH : ℕ} {κ : Caps} {Γ : Machine.Reg → ℕ} {W : ℕ} {s : Model.Core} {L : Loc} :
    PK K KH κ Γ W Stm.bug s L
    theorem OrderMaintenance.Impl.PK.assign {K KH : ℕ} {κ : Caps} {Γ : Machine.Reg → ℕ} {W : ℕ} {s : Model.Core} {L : Loc} {x : Machine.Reg} {e : Exp} {v : ℕ} (hG : Gd K KH κ Γ s L) (hv : Exp.ev κ s L e = some v) (hp : Exp.pk κ s L e < 2 ^ W) (hx : v < 2 ^ Γ x) :
    PK K KH κ Γ W (x ::= e) s L
    theorem OrderMaintenance.Impl.PK.wr {K KH : ℕ} {κ : Caps} {Γ : Machine.Reg → ℕ} {W : ℕ} {s : Model.Core} {L : Loc} {f : Fld} {i e : Exp} {j v : ℕ} (hG : Gd K KH κ Γ s L) (hi : Exp.ev κ s L i = some j) (he : Exp.ev κ s L e = some v) (hpi : Exp.pk κ s L i < 2 ^ W) (hpe : Exp.pk κ s L e < 2 ^ W) (hv : v < 2 ^ Fld.wd K KH f) :
    PK K KH κ Γ W (Stm.wr f i e) s L
    theorem OrderMaintenance.Impl.PK.catch_bug {K KH : ℕ} {κ : Caps} {Γ : Machine.Reg → ℕ} {W : ℕ} {s : Model.Core} {L : Loc} {c : Stm} (hc : PK K KH κ Γ W c s L) :
    PK K KH κ Γ W (c.catch Stm.bug) s L
    theorem OrderMaintenance.Impl.PK.call {K KH : ℕ} {κ : Caps} {Γ : Machine.Reg → ℕ} {W : ℕ} {s : Model.Core} {L : Loc} {q : Proc} {args : List Exp} {ds : List Machine.Reg} {vs : List ℕ} {Γc : Machine.Reg → ℕ} (hG : Gd K KH κ Γ s L) (ha : evList κ s L args = some vs) (hpa : pkList κ s L args < 2 ^ W) (hb : PK K KH κ Γc W q.body s (Machine.State.setLocs (fun (x : Machine.Reg) => 0) q.params vs)) (hr : ∀ r ∈ q.rets, Γc r ≤ K) (hd : ∀ d ∈ ds, K ≤ Γ d) :
    PK K KH κ Γ W (q.call args ds) s L

    A call: the arguments, the body from the callee's frame, and the results copied back.

    theorem OrderMaintenance.Impl.PK.loop {K KH : ℕ} {κ : Caps} {Γ : Machine.Reg → ℕ} {W : ℕ} {s : Model.Core} {L : Loc} {x : Machine.Reg} {n : Exp} {b : Stm} {N : ℕ} (hn : Exp.ev κ s L n = some N) (hp : Exp.pk κ s L n < 2 ^ W) (I : ℕ → Model.Core → Loc → Prop) (h0 : I 0 s L) (hI : ∀ (k : ℕ) (s : Model.Core) (L : Loc), I k s L → Gd K KH κ Γ s L) (hb : ∀ (k : ℕ) (s : Model.Core) (L : Loc), k < N → I k s L → PK K KH κ Γ W b s (Machine.State.upd L x k) ∧ ∀ (s' : Model.Core) (L' : Loc) (c : ℕ), evalF κ b s (Machine.State.upd L x k) = Res.ok s' L' c → I (k + 1) s' L') :
    PK K KH κ Γ W (Stm.loop x n b) s L

    A loop, with an invariant I k before iteration k that gives the invariant Gd and the body's peak bound.

    Expressions under the invariant, with any width #

    theorem OrderMaintenance.Impl.Gd.pkS {K KH : ℕ} {κ : Caps} {Γ : Machine.Reg → ℕ} {s : Model.Core} {L : Loc} (hG : Gd K KH κ Γ s L) (hC : CapsW K κ) {e : Exp} (hs : Exp.ShOK κ s L K e) {v : ℕ} (hv : Exp.ev κ s L e = some v) {W : ℕ} (hw : Exp.wq Γ K KH K e ≤ W) :
    Exp.pk κ s L e < 2 ^ W

    The peak of an expression (shifts allowed, with their amounts at most K).

    theorem OrderMaintenance.Impl.Gd.valS {K KH : ℕ} {κ : Caps} {Γ : Machine.Reg → ℕ} {s : Model.Core} {L : Loc} (hG : Gd K KH κ Γ s L) (hC : CapsW K κ) {e : Exp} (hs : Exp.ShOK κ s L K e) {v : ℕ} (hv : Exp.ev κ s L e = some v) {w : ℕ} (hw : Exp.vw Γ K KH K e ≤ w) :
    v < 2 ^ w

    Normal runs only #

    def OrderMaintenance.Impl.PKok (K KH : ℕ) (κ : Caps) (Γ : Machine.Reg → ℕ) (W : ℕ) (c : Stm) (s : Model.Core) (L : Loc) :

    PK for a normal run: if the run of c ends normally, it computed nothing at or above 2^W and ends with the invariant. Enough for the machine theorem (every core call there ends normally), and it lets a proof use what the end state of the run satisfies.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      theorem OrderMaintenance.Impl.PK.ok {K KH : ℕ} {κ : Caps} {Γ : Machine.Reg → ℕ} {W : ℕ} {s : Model.Core} {L : Loc} {c : Stm} (h : PK K KH κ Γ W c s L) :
      PKok K KH κ Γ W c s L
      theorem OrderMaintenance.Impl.PKok.seq {K KH : ℕ} {κ : Caps} {Γ Γ' : Machine.Reg → ℕ} {W : ℕ} {s : Model.Core} {L : Loc} {c d : Stm} (hc : PKok K KH κ Γ' W c s L) (hd : ∀ (s1 : Model.Core) (L1 : Loc) (n1 : ℕ), evalF κ c s L = Res.ok s1 L1 n1 → Gd K KH κ Γ' s1 L1 → PKok K KH κ Γ W d s1 L1) :
      PKok K KH κ Γ W (c;; d) s L
      theorem OrderMaintenance.Impl.PKok.ite {K KH : ℕ} {κ : Caps} {Γ : Machine.Reg → ℕ} {W : ℕ} {s : Model.Core} {L : Loc} {c : Exp} {t f : Stm} {v : ℕ} (hv : Exp.ev κ s L c = some v) (hp : Exp.pk κ s L c < 2 ^ W) (ht : v ≠ 0 → PKok K KH κ Γ W t s L) (hf : v = 0 → PKok K KH κ Γ W f s L) :
      PKok K KH κ Γ W (Stm.ite c t f) s L
      theorem OrderMaintenance.Impl.PKok.catch_bug {K KH : ℕ} {κ : Caps} {Γ : Machine.Reg → ℕ} {W : ℕ} {s : Model.Core} {L : Loc} {c : Stm} (hc : PKok K KH κ Γ W c s L) :
      PKok K KH κ Γ W (c.catch Stm.bug) s L
      theorem OrderMaintenance.Impl.PKok.call {K KH : ℕ} {κ : Caps} {Γ : Machine.Reg → ℕ} {W : ℕ} {s : Model.Core} {L : Loc} {q : Proc} {args : List Exp} {ds : List Machine.Reg} {vs : List ℕ} {Γc : Machine.Reg → ℕ} (hG : Gd K KH κ Γ s L) (ha : evList κ s L args = some vs) (hpa : pkList κ s L args < 2 ^ W) (hb : PKok K KH κ Γc W q.body s (Machine.State.setLocs (fun (x : Machine.Reg) => 0) q.params vs)) (hr : ∀ r ∈ q.rets, Γc r ≤ K) (hd : ∀ d ∈ ds, K ≤ Γ d) :
      PKok K KH κ Γ W (q.call args ds) s L
      theorem OrderMaintenance.Impl.runForF_ok_inv {κ : Caps} {b : Stm} {x : Machine.Reg} {k m : ℕ} {s s' : Model.Core} {L L' : Loc} {c : ℕ} (h : runForF (evalF κ b) x k (m + 1) s L = Res.ok s' L' c) :
      ∃ (s1 : Model.Core) (L1 : Loc) (c1 : ℕ) (c2 : ℕ), evalF κ b s (Machine.State.upd L x k) = Res.ok s1 L1 c1 ∧ runForF (evalF κ b) x (k + 1) m s1 L1 = Res.ok s' L' c2
      theorem OrderMaintenance.Impl.PKok.loop {K KH : ℕ} {κ : Caps} {Γ : Machine.Reg → ℕ} {W : ℕ} {s : Model.Core} {L : Loc} {x : Machine.Reg} {n : Exp} {b : Stm} {N : ℕ} (hn : Exp.ev κ s L n = some N) (hp : Exp.pk κ s L n < 2 ^ W) (I : ℕ → Model.Core → Loc → Prop) (h0 : I 0 s L) (hI : ∀ (k : ℕ) (s : Model.Core) (L : Loc), I k s L → Gd K KH κ Γ s L) (hb : ∀ (k : ℕ) (s : Model.Core) (L : Loc), k < N → I k s L → ∀ (s' : Model.Core) (L' : Loc) (c : ℕ), evalF κ b s (Machine.State.upd L x k) = Res.ok s' L' c → pkF κ b s (Machine.State.upd L x k) < 2 ^ W ∧ I (k + 1) s' L') :
      PKok K KH κ Γ W (Stm.loop x n b) s L

      A loop, for a normal run, with an invariant I k before iteration k.