NLA-lib Explorer

NLAlib.Ops.Examples.runs_add3

Library · theorem

The abstract theorem of add3, for every f that is addition modulo 2 ^ w and every interpretation satisfying the functional contract: two calls of wadd at [w], and r holds the sum of the three numbers modulo 2 ^ w.

NLAlib.Ops.Examples.runs_add3 {f : ℕ → List Bool → List Bool → List Bool}
  (hf : Ops.Examples.AddMod f) {I : Ops.Interp Ops.Examples.WOp Empty Bool}
  (hI : Ops.Examples.IsWAdd f I) (W : Ops.Examples.WOp → List ℕ → ℕ) {τ : Ops.Tape Bool} {w : ℕ}
  {x y z s r : ℕ × ℕ} {m : Ops.Mem Bool} {xs ys zs : List Bool} (hxs : x.1 ≠ s.1) (hys : y.1 ≠ s.1)
  (hzs : z.1 ≠ s.1) (hsr : s.1 ≠ r.1) (hzr : z.1 ≠ r.1) (hx : m.store.readBlock x.1 x.2 w = some xs)
  (hy : m.store.readBlock y.1 y.2 w = some ys) (hz : m.store.readBlock z.1 z.2 w = some zs)
  (hs : s.2 + w ≤ m.store.len s.1) (hr : r.2 + w ≤ m.store.len r.1) (hl : m.Live [x, y, z, s, r]) :
  Ops.ConditionalRuns I W τ Ops.Examples.add3
    { idx := [w, x.2, y.2, z.2, s.2, r.2], buf := [x.1, y.1, z.1, s.1, r.1] } m
    (2 • Ops.Count.one Ops.Examples.WOp.wadd [w]) (W Ops.Examples.WOp.wadd [w]) fun m' ↦
    ∃ ss rs,
      m' = (m.updBlock s ss).updBlock r rs ∧
        Ops.Examples.bitsVal (Ops.vec rs) w =
          (Ops.Examples.bitsVal (Ops.vec xs) w + Ops.Examples.bitsVal (Ops.vec ys) w +
              Ops.Examples.bitsVal (Ops.vec zs) w) %
            2 ^ w

Full source on GitHub

Import NLAlib.Ops.Examples.Bits.