Documentation

CslibFrontier.Computability.WordRAM.Signed.ArrayArithmetic.Exec

Complete native signed array arithmetic with exact aliases #

Each input is either separated from the output or has the identical base. Earlier writes then preserve every unread source entry. This supports both disjoint Strassen operand forms and in-place additions/subtractions into output quadrants.

theorem Cslib.WordRAM.Signed.ArrayArithmetic.exec {w n A B : ℕ} (subtract : Bool) (x : Data 16) (u v : ℕ → ℤ) (hlen : x.regs Reg.length = n) (hbound : GenericRAM.Signed.Fits w ↑(A + B)) (hu : ∀ i < n, (u i).natAbs ≤ A) (hv : ∀ i < n, (v i).natAbs ≤ B) (hA : ∀ i < n, x.mem (x.regs Reg.inputA + i) = encode (u i)) (hB : ∀ i < n, x.mem (x.regs Reg.inputB + i) = encode (v i)) (ha : Fits (w + 2) (x.regs Reg.inputA + n)) (hb : Fits (w + 2) (x.regs Reg.inputB + n)) (hout : Fits (w + 2) (x.regs Reg.output + n)) (hsepA : x.regs Reg.inputA + n ≤ x.regs Reg.output ∨ x.regs Reg.output + n ≤ x.regs Reg.inputA ∨ x.regs Reg.inputA = x.regs Reg.output) (hsepB : x.regs Reg.inputB + n ≤ x.regs Reg.output ∨ x.regs Reg.output + n ≤ x.regs Reg.inputB ∨ x.regs Reg.inputB = x.regs Reg.output) :
∃ (y : Data 16), ExecWithin (w + 2) (program subtract) x y (26 * n + 4) ∧ (∀ i < n, y.mem (x.regs Reg.output + i) = encode (if subtract = true then u i - v i else u i + v i)) ∧ (∀ (a : ℕ), a < x.regs Reg.output ∨ x.regs Reg.output + n ≤ a → y.mem a = x.mem a) ∧ ∀ (i : Fin 16), 9 ≤ ↑i ∧ ↑i ≤ 12 → y.regs i = x.regs i

Actual native array addition/subtraction, including setup and all loop/access work. The source-width envelope concerns only original input magnitudes. Dirty output and exact input/output aliases are permitted. The bound excludes the final halt.

Both closed operation choices use fixed standard code and never read physical width.