NLA-lib Explorer

NLAlib.Ops.Examples.runs_add3_link

Library · theorem

The concrete corollary: add3 linked down to bit operations computes the sum of three w-bit numbers modulo 2 ^ w, within the pushed-forward counts and one scratch cell.

NLAlib.Ops.Examples.runs_add3_link {I : Ops.Interp Ops.Examples.BitOp Empty Bool}
  (hI : Ops.Examples.IsBits I) {τ : 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 (fun x x_1 ↦ 0) τ (Ops.Stmt.link Ops.Examples.wordTable 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.BitOp.zero [] +
      (2 * w) •
        (Ops.Count.one Ops.Examples.BitOp.xor3 [] + Ops.Count.one Ops.Examples.BitOp.maj []))
    1 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.