NLA-lib Explorer

NLAlib.Ops.Examples.ripple_wp_step

Library · theorem

One position of the adder: the sum bit is appended to the block, the carry cell is updated.

NLAlib.Ops.Examples.ripple_wp_step {I : Ops.Interp Ops.Examples.BitOp Empty Bool}
  (hI : Ops.Examples.IsBits I) {md : Ops.Mode} {τ : Ops.Tape Bool} {w i : ℕ} (hi : i < w)
  {x y z : ℕ × ℕ} {s : Ops.Store Bool} {p : ℕ} {xs ys : List Bool} (hxz : x.1 ≠ z.1)
  (hyz : y.1 ≠ z.1) (hx : s.readBlock x.1 x.2 w = some xs) (hy : s.readBlock y.1 y.2 w = some ys)
  (hz : z.2 + w ≤ s.len z.1) {Q : Ops.Mem Bool → Prop}
  (hQ :
    Q
      {
        store :=
          s.updBlock z.1 z.2 (Ops.Examples.ripplePrefix (Ops.vec xs) (Ops.vec ys) (i + 1)) ++
            [[some (Ops.Examples.carry (Ops.vec xs) (Ops.vec ys) (i + 1))]],
        pos := p }) :
  Ops.Wp md I τ
    ((Ops.Stmt.call Ops.Examples.BitOp.xor3 []
          [{ buf := 0, off := Ops.IExp.var 1 + Ops.IExp.var 4 },
            { buf := 1, off := Ops.IExp.var 2 + Ops.IExp.var 4 },
            { buf := 3, off := Ops.IExp.const 0 }]
          [{ buf := 2, off := Ops.IExp.var 3 + Ops.IExp.var 4 }]).seq
      (Ops.Stmt.call Ops.Examples.BitOp.maj []
        [{ buf := 0, off := Ops.IExp.var 1 + Ops.IExp.var 4 },
          { buf := 1, off := Ops.IExp.var 2 + Ops.IExp.var 4 },
          { buf := 3, off := Ops.IExp.const 0 }]
        [{ buf := 3, off := Ops.IExp.const 0 }]))
    { idx := [w, x.2, y.2, z.2, i], buf := [x.1, y.1, z.1, List.length s] } Q
    {
      store :=
        s.updBlock z.1 z.2 (Ops.Examples.ripplePrefix (Ops.vec xs) (Ops.vec ys) i) ++
          [[some (Ops.Examples.carry (Ops.vec xs) (Ops.vec ys) i)]],
      pos := p }

Full source on GitHub

Import NLAlib.Ops.Examples.Bits.