Documentation

LeanPool.OrderMaintenance.Impl.PeakBound

Theorem W, option (A), stage A1: the generic bound on an expression's peak #

The lemma of approach (i′) (docs/WORD.md §4): if every leaf of an expression is small, and every shift amount is at most S, then its value and its peak (Exp.pk, the machine's maxv of the compiled form) are below 2^w for a width w computed from the syntax alone.

wv and wp are plain structural recursions: for a concrete expression, simp [Exp.wv, Exp.wp] computes them as a term in K, S and the Γ of the locals involved, and omega compares it with a target width. This is how stage A2 is meant to use it.

Widths #

The width of a field: KH for the handle Elem.h, K for every other field.

Equations
Instances For

    Bound the intermediate values of a unary primitive from an input-value bound.

    Equations
    Instances For
      theorem OrderMaintenance.Impl.Exp.shOK_of_noShl (κ : Caps) (s : Model.Core) (L : Loc) (S : ℕ) (e : Exp) :
      e.noShl = true → ShOK κ s L S e

      The leaves #

      structure OrderMaintenance.Impl.MemW (K KH : ℕ) (κ : Caps) (s : Model.Core) :

      The leaves read from the core are small: every field below 2^K (the handle below 2^KH), every size, parameter, list entry, path entry and optional field below 2^K, the lists within their capacity, and the row width H + 1 below 2^K. PeakLeaf.lean derives it from option (B)'s WB.

      Instances For
        structure OrderMaintenance.Impl.CapsW (K : ℕ) (κ : Caps) :

        The capacities are small: the compiled index arithmetic stays below 2^K.

        Instances For

          Soundness #

          theorem OrderMaintenance.Impl.lt_pow_max_left {x a b : ℕ} (h : x < 2 ^ a) :
          x < 2 ^ max a b
          theorem OrderMaintenance.Impl.lt_pow_max_right {x a b : ℕ} (h : x < 2 ^ b) :
          x < 2 ^ max a b
          theorem OrderMaintenance.Impl.max_lt_pow {x y a b : ℕ} (hx : x < 2 ^ a) (hy : y < 2 ^ b) :
          max x y < 2 ^ max a b
          theorem OrderMaintenance.Machine.BinOp.wd_sound {S : ℕ} {op : BinOp} {x y v wa wb : ℕ} (hx : x < 2 ^ wa) (hy : y < 2 ^ wb) (hs : op = shl → y ≤ S) (hv : op.eval x y = some v) :
          v < 2 ^ wd S op wa wb
          theorem OrderMaintenance.Machine.UnOp.wd_sound {op : UnOp} {x w : ℕ} (hx : x < 2 ^ w) :
          op.eval x < 2 ^ op.wd w
          theorem OrderMaintenance.Impl.Exp.wd_sound {κ : Caps} {s : Model.Core} {L : Loc} {Γ : Machine.Reg → ℕ} {K KH S : ℕ} (hM : MemW K KH κ s) (hC : CapsW K κ) (hΓ : ∀ (x : Machine.Reg), L x < 2 ^ Γ x) (e : Exp) {v : ℕ} :
          ShOK κ s L S e → ev κ s L e = some v → v < 2 ^ wv Γ K KH S e ∧ pk κ s L e < 2 ^ wp Γ K KH S e

          The generic expression lemma. Under small leaves, small capacities and bounded shift amounts, the value of an expression is below 2^wv and its peak below 2^wp.

          theorem OrderMaintenance.Impl.Exp.pk_lt {κ : Caps} {s : Model.Core} {L : Loc} {Γ : Machine.Reg → ℕ} {K KH S : ℕ} (hM : MemW K KH κ s) (hC : CapsW K κ) (hΓ : ∀ (x : Machine.Reg), L x < 2 ^ Γ x) {e : Exp} {v : ℕ} (hs : ShOK κ s L S e) (hv : ev κ s L e = some v) :
          pk κ s L e < 2 ^ wp Γ K KH S e

          The peak alone.

          theorem OrderMaintenance.Impl.pkList_lt {κ : Caps} {s : Model.Core} {L : Loc} {Γ : Machine.Reg → ℕ} {K KH S : ℕ} (hM : MemW K KH κ s) (hC : CapsW K κ) (hΓ : ∀ (x : Machine.Reg), L x < 2 ^ Γ x) {W : ℕ} {es : List Exp} {vs : List ℕ} :
          (∀ e ∈ es, Exp.ShOK κ s L S e ∧ Exp.wp Γ K KH S e ≤ W) → evList κ s L es = some vs → pkList κ s L es < 2 ^ W

          The peak of an argument list.

          A closed form in the depth #

          theorem OrderMaintenance.Impl.Exp.wv_le_wp (Γ : Machine.Reg → ℕ) (K KH S : ℕ) (e : Exp) :
          wv Γ K KH S e ≤ wp Γ K KH S e
          theorem OrderMaintenance.Impl.two_pow_succ_mul (d c : ℕ) :
          2 ^ (d + 1) * c = 2 * (2 ^ d * c)
          theorem OrderMaintenance.Impl.Exp.wp_le_depth {Γ : Machine.Reg → ℕ} {K KH S : ℕ} (hK : 1 ≤ K) (hΓ : ∀ (x : Machine.Reg), Γ x ≤ K) (hH : KH ≤ K) (e : Exp) :
          litLe K e → wp Γ K KH S e ≤ 2 ^ e.depth * (K + S)

          The closed form: with every local, handle and literal of width at most K (and K ≥ 1), an expression of depth d has peak width at most 2^d · (K + S).

          theorem OrderMaintenance.Impl.lt_pow_max_add {x a b : ℕ} (h : x < 2 ^ max a b) :
          x < 2 ^ a + 2 ^ b

          A value below 2^(max a b) is below 2^a + 2^b: a width bound max K KH with KH the width of a handle splits into "below 2^K, or at most about twice the handle bound" (the convention of docs/WORD.md §1).