Library mcertikos.ticketlog.TicketLockOpGenSpec


This file provide the contextual refinement proof between MBoot layer and MALInit layer
Require Import Coqlib.
Require Import Errors.
Require Import AST.
Require Import Integers.
Require Import Floats.
Require Import Op.
Require Import Asm.
Require Import Events.
Require Import Globalenvs.
Require Import Smallstep.
Require Import Values.
Require Import Memory.
Require Import Maps.
Require Import AuxLemma.
Require Import FlatMemory.
Require Import AuxStateDataType.
Require Import Constant.
Require Import GlobIdent.
Require Import RealParams.
Require Import AsmImplLemma.
Require Import GenSem.
Require Import PrimSemantics.

Require Import liblayers.logic.PTreeModules.
Require Import liblayers.logic.LayerLogicImpl.
Require Import liblayers.compcertx.Stencil.
Require Import liblayers.compcertx.MakeProgram.
Require Import liblayers.compat.CompatLayers.
Require Import liblayers.compat.CompatGenSem.
Require Import compcert.cfrontend.Ctypes.

Local Open Scope string_scope.
Local Open Scope error_monad_scope.
Local Open Scope Z_scope.

Require Import AbstractDataType.
Require Import MTicketLockIntro.

Definition of the refinement relation

Section TICKETLOCKOP_DEFINE.

  Context `{real_params: RealParams}.
  Context `{multi_oracle_prop: MultiOracleProp}.

  Notation LDATAOps := (cdata RData).

  Inductive ticket_lock_init_spec_low_step `{StencilOps} `{Mem.MemoryModelOps} `{UseMemWithData mem}:
    sextcall_sem (mem := mwd LDATAOps):=
  | ticket_lock_init_spec_low_intro s (WB: _Prop) m´0 labd labd´ mbi_adr:
      ticket_lock_init_spec (Int.unsigned mbi_adr) labd = Some labd´
      kernel_mode labd
      high_level_invariant labd
      ticket_lock_init_spec_low_step s WB (Vint mbi_adr :: nil) (m´0, labd) Vundef (m´0, labd´).

  Inductive pass_lock_spec_low_step `{StencilOps} `{Mem.MemoryModelOps} `{UseMemWithData mem}:
    sextcall_sem (mem := mwd LDATAOps):=
  | pass_lock_spec_low_intro s (WB: _Prop) m´0 labd labd´ i ofs:
      pass_lock_spec (Int.unsigned i) (Int.unsigned ofs) labd = Some labd´
      kernel_mode labd
      high_level_invariant labd
      pass_lock_spec_low_step s WB (Vint i :: Vint ofs :: nil) (m´0, labd) Vundef (m´0, labd´).

  Inductive wait_lock_spec_low_step `{StencilOps} `{Mem.MemoryModelOps} `{UseMemWithData mem}:
    sextcall_sem (mem := mwd LDATAOps):=
  | wait_lock_spec_low_intro s (WB: _Prop) m´0 labd labd´ bound i ofs:
      wait_lock_spec_wraparound (Int.unsigned bound) (Int.unsigned i) (Int.unsigned ofs) labd = Some labd´
      kernel_mode labd
      high_level_invariant labd
      wait_lock_spec_low_step s WB (Vint bound :: Vint i :: Vint ofs :: nil) (m´0, labd) Vundef (m´0, labd´).

  Section WITHMEM.

    Context `{Hstencil: Stencil}.
    Context `{Hmem: Mem.MemoryModelX}.
    Context `{Hmwd: UseMemWithData mem}.

    Definition ticket_lock_init_spec_low: compatsem LDATAOps :=
      csem ticket_lock_init_spec_low_step (type_of_list_type (Tint32::nil)) Tvoid.

    Definition wait_lock_spec_low: compatsem LDATAOps :=
      csem wait_lock_spec_low_step (type_of_list_type (Tint32::Tint32::Tint32::nil)) Tvoid.

    Definition pass_lock_spec_low: compatsem LDATAOps :=
      csem pass_lock_spec_low_step (type_of_list_type (Tint32::Tint32::nil)) Tvoid.

  End WITHMEM.

End TICKETLOCKOP_DEFINE.