Library QedkConcrete.memorymodel

The bounded-memory implementation used by CALL and CREATE

These equations select the actual memory implementation, not a VM preservation assumption. Revision Eleven and the SETCODE experiment both use the revision-Nine extension and remaining-capacity operations. Instruction proofs can therefore share their memory arguments without requiring the entire executor to run at revision Eleven.
From Stdlib Require Import NArith.
Require Import RocqOfOCaml.RocqOfOCaml MonadVM.Vm.
Set Default Goal Selector "!".

Record BoundedMemory {Host_t : Set} (F : @Vm.Make.FArgs Host_t) : Prop := {
  bounded_extend : ∀ start size memory,
    @Vm.Make.Memory.extend_to Host_t F start size memory =
    @Vm.Make.Memory.extend_to_monad_nine Host_t F start size memory;
  bounded_available : ∀ memory,
    @Vm.Make.Memory.available_memory_size Host_t F memory =
    Support.UintN.op_minus (Vm.Make.Memory.t.memory_capacity memory)
      (Vm.Make.Memory.t.active_bytes memory)
}.

Lemma eleven_bounded_memory {Host_t : Set} {F : @Vm.Make.FArgs Host_t} :
  (@Vm.Make.Params Host_t F).(Vm.Make_Params_signature.revision) =
    Support.Variants.Revision.Eleven → BoundedMemory F.
Proof.
  intro Hrevision. constructor; intros;
    unfold Vm.Make.Memory.extend_to, Vm.Make.Memory.available_memory_size;
    rewrite Hrevision; reflexivity.
Qed.