val alloc (#a:Type)
          (#pcm:pcm a)
          (x:a)
  : Steel (ref a pcm)
          emp
          (fun r -> pts_to r x)
          (requires fun _ -> pcm.refine x)
          (ensures fun _ _ _ -> True)
let alloc #_ #pcm x = rewrite_slprop emp (to_vprop Mem.emp) (fun _ -> reveal_emp ());
              compatible_refl pcm x;
              alloc' x
val alloc (#a:Type)
          (#pcm:pcm a)
          (x:a)
  : Steel (ref a pcm)
          emp
          (fun r -> pts_to r x)
          (requires fun _ -> pcm.refine x)
          (ensures fun _ _ _ -> True)
let alloc #_ #pcm x =
rewrite_slprop emp (to_vprop Mem.emp) (fun _ -> reveal_emp ());
compatible_refl pcm x;
alloc' x
Steel.PCMReference.fst.checked
Steel.Memory.fsti.checked prims.fst.checked FStar.Set.fsti.checked FStar.Pervasives.fsti.checked FStar.PCM.fst.checked
Steel.PCMReference.fst
FStar.PCM.pcm Steel.PCMReference.alloc' Steel.Memory.ref Prims.unit FStar.PCM.compatible_refl Steel.Effect.Atomic.rewrite_slprop FStar.Ghost.hide FStar.Set.set Steel.Memory.iname FStar.Set.empty Steel.Effect.Common.emp Steel.Effect.Common.to_vprop Steel.Memory.emp Steel.Memory.mem Steel.Effect.Common.reveal_emp
(*
   Copyright 2020 Microsoft Research

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*)


module Steel.PCMReference

module Mem = Steel.Memory

let read r v0 = let v = as_action (sel_action FStar.Set.empty r v0) in v
let write r v0 v1 = as_action (upd_action FStar.Set.empty r v0 v1)

val alloc' (#a:Type)
           (#pcm:pcm a)
           (x:a)
  : Steel (ref a pcm)
          (to_vprop Mem.emp)
          (fun r -> pts_to r x)
          (requires fun _ -> compatible pcm x x /\ pcm.refine x)
          (ensures fun _ _ _ -> True)

let alloc' x = as_action (alloc_action FStar.Set.empty x)
val alloc (#a:Type)
          (#pcm:pcm a)
          (x:a)
  : Steel (ref a pcm)
          emp
          (fun r -> pts_to r x)
          (requires fun _ -> pcm.refine x)
          (ensures fun _ _ _ -> True)
x: a -> Steel.Effect.Steel (Steel.Memory.ref a pcm)