Correctness of compiled pointer-machine instructions #
Each instruction's memory and register effect is implemented by its compiled word-RAM code. Scalar implementations discharge only scalar operations; the pointer-access and allocation proofs use the explicit memory representation.
theorem Cslib.PointerMachine.WordRAM.Scalars.effect_correct {M : Model} {L : Layout} (S : Scalars M L) (i : Instr M L) {w : ℕ} {x : State M L} {y : WordRAM.Data (regCount L)} (hv : x.Valid) (h : Repr S.encode x y) (hf : Fits S.encode w x) (hf' : Fits S.encode w (Instr.effect x i)) (hs : S.Safe w x i) :
∃ (z : WordRAM.Data (regCount L)),
WordRAM.ExecWithin w (S.effect i) y z (S.effectTime i) ∧ Repr S.encode (Instr.effect x i) z ∧ match i, hf', hs with
| Instr.ifTest p a b label, hf', hs =>
z.regs (valueReg L) = if M.evalTest p (x.data a) (x.data b) = true then 1 else 0
| x_1, hf', hs => True
The compiled effect performs the source instruction, within its explicit instruction bound. For a scalar branch it also leaves the predicate result in the temporary value register.