Library mcertikos.mm.ContainerGenSpec
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.
Require Import AbstractDataType.
Require Import MContainerIntro.
Local Open Scope string_scope.
Local Open Scope error_monad_scope.
Local Open Scope Z_scope.
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.
Require Import AbstractDataType.
Require Import MContainerIntro.
Local Open Scope string_scope.
Local Open Scope error_monad_scope.
Local Open Scope Z_scope.
Section CONTAINERGEN_DEFINE.
Context `{real_params: RealParams}.
Context `{multi_oracle_prop: MultiOracleProp}.
Notation LDATAOps := (cdata RData).
Inductive container_init_low_step `{StencilOps} `{Mem.MemoryModelOps} `{UseMemWithData mem}:
sextcall_sem (mem := mwd LDATAOps):=
| container_init_spec_low_intro s (WB: _ → Prop) m´0 labd labd´ mbi_adr:
container_init_spec (Int.unsigned mbi_adr) labd = Some labd´ →
kernel_mode labd →
high_level_invariant labd →
container_init_low_step s WB (Vint mbi_adr :: nil) (m´0, labd) Vundef (m´0, labd´).
Function container_split_low_spec (id: Z) (q: Z) (adt: RData) : option (RData×Z) :=
if zle_lt 0 id num_proc then
if zle (cquota (ZMap.get id (AC adt))) Int.max_unsigned then
if zle_le 0 (cusage (ZMap.get id (AC adt))) (cquota (ZMap.get id (AC adt))) then
let c := ZMap.get id (AC adt) in
let i := id × max_children + 1 + Z_of_nat (length (cchildren c)) in
match (init adt, ikern adt, ihost adt, cused c, cused (ZMap.get i (AC adt)), zle_lt 0 i num_proc,
zlt (Z_of_nat (length (cchildren c))) max_children,
zle_le 0 q (cquota c - cusage c)) with
| (true, true, true, true, false, left _, left _, left _) ⇒
let child := mkContainer q 0 id nil true in
let cur := mkContainer (cquota c) (cusage c + q) (cparent c)
(i :: cchildren c) (cused c) in
Some (adt {AC: ZMap.set i child (ZMap.set id cur (AC adt))}, i)
| _ ⇒ None
end
else None
else None
else None.
Inductive container_split_low_step `{StencilOps} `{Mem.MemoryModelOps} `{UseMemWithData mem}:
sextcall_sem (mem := mwd LDATAOps) :=
| container_split_low_intro s (WB: _ → Prop) m´0 labd labd´ i n c:
container_split_low_spec (Int.unsigned i) (Int.unsigned n) labd = Some (labd´, c) →
kernel_mode labd →
high_level_invariant labd →
container_split_low_step s WB (Vint i :: Vint n :: nil) (m´0, labd) (Vint (Int.repr c)) (m´0, labd´).
Section WITHMEM.
Context `{Hstencil: Stencil}.
Context `{Hmem: Mem.MemoryModel}.
Context `{Hmwd: UseMemWithData mem}.
Definition container_init_spec_low: compatsem LDATAOps :=
csem container_init_low_step (type_of_list_type (Tint32::nil)) Tvoid.
Definition container_split_spec_low: compatsem LDATAOps :=
csem container_split_low_step (type_of_list_type (Tint32::Tint32::nil)) Tint32.
End WITHMEM.
End CONTAINERGEN_DEFINE.
Context `{real_params: RealParams}.
Context `{multi_oracle_prop: MultiOracleProp}.
Notation LDATAOps := (cdata RData).
Inductive container_init_low_step `{StencilOps} `{Mem.MemoryModelOps} `{UseMemWithData mem}:
sextcall_sem (mem := mwd LDATAOps):=
| container_init_spec_low_intro s (WB: _ → Prop) m´0 labd labd´ mbi_adr:
container_init_spec (Int.unsigned mbi_adr) labd = Some labd´ →
kernel_mode labd →
high_level_invariant labd →
container_init_low_step s WB (Vint mbi_adr :: nil) (m´0, labd) Vundef (m´0, labd´).
Function container_split_low_spec (id: Z) (q: Z) (adt: RData) : option (RData×Z) :=
if zle_lt 0 id num_proc then
if zle (cquota (ZMap.get id (AC adt))) Int.max_unsigned then
if zle_le 0 (cusage (ZMap.get id (AC adt))) (cquota (ZMap.get id (AC adt))) then
let c := ZMap.get id (AC adt) in
let i := id × max_children + 1 + Z_of_nat (length (cchildren c)) in
match (init adt, ikern adt, ihost adt, cused c, cused (ZMap.get i (AC adt)), zle_lt 0 i num_proc,
zlt (Z_of_nat (length (cchildren c))) max_children,
zle_le 0 q (cquota c - cusage c)) with
| (true, true, true, true, false, left _, left _, left _) ⇒
let child := mkContainer q 0 id nil true in
let cur := mkContainer (cquota c) (cusage c + q) (cparent c)
(i :: cchildren c) (cused c) in
Some (adt {AC: ZMap.set i child (ZMap.set id cur (AC adt))}, i)
| _ ⇒ None
end
else None
else None
else None.
Inductive container_split_low_step `{StencilOps} `{Mem.MemoryModelOps} `{UseMemWithData mem}:
sextcall_sem (mem := mwd LDATAOps) :=
| container_split_low_intro s (WB: _ → Prop) m´0 labd labd´ i n c:
container_split_low_spec (Int.unsigned i) (Int.unsigned n) labd = Some (labd´, c) →
kernel_mode labd →
high_level_invariant labd →
container_split_low_step s WB (Vint i :: Vint n :: nil) (m´0, labd) (Vint (Int.repr c)) (m´0, labd´).
Section WITHMEM.
Context `{Hstencil: Stencil}.
Context `{Hmem: Mem.MemoryModel}.
Context `{Hmwd: UseMemWithData mem}.
Definition container_init_spec_low: compatsem LDATAOps :=
csem container_init_low_step (type_of_list_type (Tint32::nil)) Tvoid.
Definition container_split_spec_low: compatsem LDATAOps :=
csem container_split_low_step (type_of_list_type (Tint32::Tint32::nil)) Tint32.
End WITHMEM.
End CONTAINERGEN_DEFINE.