Documentation

LeanPool.OrderMaintenance.Impl.PeakSafe

Theorem W, option (A), stage A2: statements whose peak follows from their syntax #

Stm.Safe Γ W c says that every expression of c (and of the procedures it calls) has no shift and a peak width (Exp.wp) at most W, and that every value c stores is no wider than its destination: Γ x for a local x, K for the core (KH for the handle field). Calls are checked with every local of the callee at width K.

Stm.safe_run: from a state with the invariant Gd (an encoding, small stored values VB, and every local x below 2^(Γ x)), a safe statement that does not hit a bug computes nothing at or above 2^W (pkF < 2^W) and ends, normally or with a failed guard, in a state with Gd. Most core procedures are safe; the others are composed from safe pieces with the rules of PeakHP.lean.

Nothing here is used by Theorems A and B.

structure OrderMaintenance.Impl.Gd (K KH : ℕ) (κ : Caps) (Γ : Machine.Reg → ℕ) (s : Model.Core) (L : Loc) :

The invariant of stage A2: an encoding exists, the stored values are small, and every local x is below 2^(Γ x).

Instances For
    def OrderMaintenance.Impl.Exp.OK (Γ : Machine.Reg → ℕ) (K KH W : ℕ) (e : Exp) :

    An expression without shifts whose peak width is at most W.

    Equations
    Instances For
      def OrderMaintenance.Impl.Stm.Safe (K KH : ℕ) (Γ : Machine.Reg → ℕ) (W : ℕ) :
      Stm → Prop

      A statement whose peak follows from its syntax.

      Equations
      Instances For

        Expressions under the invariant #

        theorem OrderMaintenance.Impl.Gd.memW {K KH : ℕ} {κ : Caps} {Γ : Machine.Reg → ℕ} {s : Model.Core} {L : Loc} (hG : Gd K KH κ Γ s L) (hC : CapsW K κ) :
        MemW K KH κ s
        theorem OrderMaintenance.Impl.Gd.pk {K KH : ℕ} {κ : Caps} {Γ : Machine.Reg → ℕ} {s : Model.Core} {L : Loc} {W : ℕ} (hG : Gd K KH κ Γ s L) (hC : CapsW K κ) {e : Exp} (he : Exp.OK Γ K KH W e) {v : ℕ} (hv : Exp.ev κ s L e = some v) :
        Exp.pk κ s L e < 2 ^ W
        theorem OrderMaintenance.Impl.Gd.val {K KH : ℕ} {κ : Caps} {Γ : Machine.Reg → ℕ} {s : Model.Core} {L : Loc} {W : ℕ} (hG : Gd K KH κ Γ s L) (hC : CapsW K κ) {e : Exp} (he : Exp.OK Γ K KH W e) {v : ℕ} (hv : Exp.ev κ s L e = some v) :
        v < 2 ^ Exp.vw Γ K KH K e
        theorem OrderMaintenance.Impl.Gd.valW {K KH : ℕ} {κ : Caps} {Γ : Machine.Reg → ℕ} {s : Model.Core} {L : Loc} {W : ℕ} (hG : Gd K KH κ Γ s L) (hC : CapsW K κ) {e : Exp} (he : Exp.OK Γ K KH W e) {w : ℕ} (hw : Exp.vw Γ K KH K e ≤ w) {v : ℕ} (hv : Exp.ev κ s L e = some v) :
        v < 2 ^ w
        theorem OrderMaintenance.Impl.Gd.valN {K KH : ℕ} {κ : Caps} {Γ : Machine.Reg → ℕ} {s : Model.Core} {L : Loc} (hG : Gd K KH κ Γ s L) (hC : CapsW K κ) {e : Exp} (he : e.noShl = true) {w : ℕ} (hw : Exp.vw Γ K KH K e ≤ w) {v : ℕ} (hv : Exp.ev κ s L e = some v) :
        v < 2 ^ w
        theorem OrderMaintenance.Impl.Gd.pkList {K KH : ℕ} {κ : Caps} {Γ : Machine.Reg → ℕ} {s : Model.Core} {L : Loc} {W : ℕ} (hG : Gd K KH κ Γ s L) (hC : CapsW K κ) {es : List Exp} (h : ∀ e ∈ es, Exp.OK Γ K KH W e) {vs : List ℕ} (hv : evList κ s L es = some vs) :
        Impl.pkList κ s L es < 2 ^ W
        theorem OrderMaintenance.Impl.Gd.vals {K KH : ℕ} {κ : Caps} {Γ : Machine.Reg → ℕ} {s : Model.Core} {L : Loc} {W : ℕ} (hG : Gd K KH κ Γ s L) (hC : CapsW K κ) {es : List Exp} :
        (∀ e ∈ es, Exp.OK Γ K KH W e ∧ Exp.vw Γ K KH K e ≤ K) → ∀ {vs : List ℕ}, evList κ s L es = some vs → ∀ v ∈ vs, v < 2 ^ K

        Locals #

        theorem OrderMaintenance.Impl.upd_lt {Γ : Machine.Reg → ℕ} {L : Loc} (hL : ∀ (x : Machine.Reg), L x < 2 ^ Γ x) {y : Machine.Reg} {v : ℕ} (hv : v < 2 ^ Γ y) (x : Machine.Reg) :
        Machine.State.upd L y v x < 2 ^ Γ x
        theorem OrderMaintenance.Impl.setLocs_lt {Γ : Machine.Reg → ℕ} {K : ℕ} {L : Loc} {xs : List Machine.Reg} {vs : List ℕ} :
        (∀ (x : Machine.Reg), L x < 2 ^ Γ x) → (∀ x ∈ xs, K ≤ Γ x) → (∀ v ∈ vs, v < 2 ^ K) → ∀ (x : Machine.Reg), Machine.State.setLocs L xs vs x < 2 ^ Γ x
        theorem OrderMaintenance.Impl.zero_locs (Γ : Machine.Reg → ℕ) (x : Machine.Reg) :
        (fun (x : Machine.Reg) => 0) x < 2 ^ Γ x
        theorem OrderMaintenance.Impl.pow_mono_lt {x a b : ℕ} (h : x < 2 ^ a) (hab : a ≤ b) :
        x < 2 ^ b

        The theorem #

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

        What safe_run proves of a statement at one state.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          theorem OrderMaintenance.Impl.lt_pow_of_lt_K {K W : ℕ} (hW : K ≤ W) {x : ℕ} (h : x < 2 ^ K) :
          x < 2 ^ W
          theorem OrderMaintenance.Impl.safe_loop {K KH : ℕ} {κ : Caps} {Γ : Machine.Reg → ℕ} {W : ℕ} {b : Stm} {x : Machine.Reg} {N : ℕ} (hC : CapsW K κ) (hN : N ≤ 2 ^ Γ x) (ih : ∀ (s : Model.Core) (L : Loc), Gd K KH κ Γ s L → evalF κ b s L ≠ Res.bug → SafeAt K KH κ Γ W b s L) (m k : ℕ) (s : Model.Core) (L : Loc) :
          Gd K KH κ Γ s L → k + m ≤ N → runForF (evalF κ b) x k m s L ≠ Res.bug → pkFor (evalF κ b) (pkF κ b) x k m s L < 2 ^ W ∧ (∀ (s' : Model.Core) (L' : Loc) (n : ℕ), runForF (evalF κ b) x k m s L = Res.ok s' L' n → Gd K KH κ Γ s' L') ∧ ∀ (s' : Model.Core) (L' : Loc) (n : ℕ), runForF (evalF κ b) x k m s L = Res.fail s' L' n → Gd K KH κ Γ s' L'

          The loop of a safe statement.

          theorem OrderMaintenance.Impl.two_le_pow {K : ℕ} (hK : 3 ≤ K) :
          2 ≤ 2 ^ K
          theorem OrderMaintenance.Impl.rowPk_lt {K : ℕ} {κ : Caps} {s : Model.Core} (hE : EncOK κ s) (hC : CapsW K κ) :
          rowPk s < 2 ^ K
          theorem OrderMaintenance.Impl.lidx_lt {K : ℕ} {κ : Caps} (hC : CapsW K κ) {k : LK} {x y : ℕ} (hx : x < κ.lrec k) (hy : y < κ.lcap k) :
          x * LK.stride κ.lcap k + y < 2 ^ K
          theorem OrderMaintenance.Impl.Stm.safe_run {K KH : ℕ} {κ : Caps} {W : ℕ} (hC : CapsW K κ) (hK : 3 ≤ K) (hW : K ≤ W) (c : Stm) {Γ : Machine.Reg → ℕ} {s : Model.Core} {L : Loc} :
          Safe K KH Γ W c → Gd K KH κ Γ s L → evalF κ c s L ≠ Res.bug → SafeAt K KH κ Γ W c s L

          Safe statements.