Documentation

CslibFrontier.Computability.WordRAM.Signed.ArrayArithmetic.Body

Charged native pointwise signed array operations #

Both operands are read before the output store, so exact input/output aliases are valid. The enclosing array loop is responsible for proving that earlier stores preserve unread input cells. The numerical premises here concern only the two original values and addresses.

The arithmetic workspace, index and address are the only body modifications.

Instances For
    theorem Cslib.WordRAM.Signed.ArrayArithmetic.exec_body {w : ℕ} (subtract : Bool) (x : Data 16) (a b : ℤ) (ha : GenericRAM.Signed.Fits w a) (hb : GenericRAM.Signed.Fits w b) (hA : x.mem (x.regs Reg.inputA + x.regs Reg.index) = encode a) (hB : x.mem (x.regs Reg.inputB + x.regs Reg.index) = encode b) (haddrA : Fits (w + 2) (x.regs Reg.inputA + x.regs Reg.index)) (haddrB : Fits (w + 2) (x.regs Reg.inputB + x.regs Reg.index)) (haddrOut : Fits (w + 2) (x.regs Reg.output + x.regs Reg.index)) (hnext : Fits (w + 2) (x.regs Reg.index + 1)) (hone : x.regs Reg.one = 1) :
    ∃ (y : Data 16), ExecWithin (w + 2) (body subtract) x y 24 ∧ y.regs Reg.index = x.regs Reg.index + 1 ∧ y.mem = Function.update x.mem (x.regs Reg.output + x.regs Reg.index) (encode (if subtract = true then a - b else a + b)) ∧ ∀ (i : Fin 16), ¬BodyLocal i → y.regs i = x.regs i

    One complete pointwise operation costs at most twenty-four native instructions.