val equiv_middle_left_assoc (a b c d: slprop)
    : Lemma
    ((((a `Mem.star` b) `Mem.star` c) `Mem.star` d)
      `Mem.equiv`
      ((a `Mem.star` (b `Mem.star` c)) `Mem.star` d))
let equiv_middle_left_assoc (a b c d:slprop)
  : Lemma (((a `Mem.star` b) `Mem.star` c `Mem.star` d) `Mem.equiv`
            (a `Mem.star` (b `Mem.star` c) `Mem.star` d))
  = let open Steel.Memory in
    star_associative a b c;
    star_congruence ((a `star` b) `star` c) d (a `star` (b `star` c)) d
val equiv_middle_left_assoc (a b c d: slprop)
    : Lemma
    ((((a `Mem.star` b) `Mem.star` c) `Mem.star` d)
      `Mem.equiv`
      ((a `Mem.star` (b `Mem.star` c)) `Mem.star` d))
let equiv_middle_left_assoc (a b c d: slprop)
    : Lemma
    ((((a `Mem.star` b) `Mem.star` c) `Mem.star` d)
      `Mem.equiv`
      ((a `Mem.star` (b `Mem.star` c)) `Mem.star` d)) =
let open Steel.Memory in
star_associative a b c;
star_congruence ((a `star` b) `star` c) d (a `star` (b `star` c)) d
Steel.Effect.Atomic.fst.checked
Steel.Semantics.Hoare.MST.fst.checked Steel.Memory.fsti.checked Steel.Effect.fst.checked Steel.Effect.fst.checked prims.fst.checked FStar.Pervasives.Native.fst.checked FStar.Pervasives.fsti.checked FStar.NMSTTotal.fst.checked FStar.Monotonic.Pure.fst.checked FStar.Ghost.fsti.checked FStar.Classical.fsti.checked
Steel.Effect.Atomic.fst
Steel.Memory.slprop Steel.Memory.star_congruence Steel.Memory.star Prims.unit Steel.Memory.star_associative Prims.l_True Prims.squash Steel.Memory.equiv Prims.Nil FStar.Pervasives.pattern
(*
   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.Effect.Atomic

open Steel.Effect
friend Steel.Effect

#set-options "--warn_error -330"  //turn off the experimental feature warning

let _ : squash (forall (pre:pre_t) (m0:mem{interp (hp_of pre) m0}) (m1:mem{disjoint m0 m1}).
  mk_rmem pre m0 == mk_rmem pre (join m0 m1)) = Classical.forall_intro rmem_depends_only_on

let req_to_act_req (#pre:vprop) (req:req_t pre) : mprop (hp_of pre) =
  fun m ->
    rmem_depends_only_on pre;
    interp (hp_of pre) m /\ req (mk_rmem pre m)

unfold
let to_post (#a:Type) (post:post_t a) = fun x -> (hp_of (post x))

let ens_to_act_ens (#pre:pre_t) (#a:Type) (#post:post_t a) (ens:ens_t pre a post)
: mprop2 (hp_of pre) (to_post post)
= fun m0 x m1 -> interp (hp_of pre) m0 /\ interp (hp_of (post x)) m1 /\
    ens (mk_rmem pre m0) x (mk_rmem (post x) m1)

let repr a framed opened f pre post req ens =
  action_except_full a opened (hp_of pre) (to_post post)
    (req_to_act_req req) (ens_to_act_ens ens)

let return_ a x opened #p = fun _ ->
  let m0:full_mem = NMSTTotal.get () in
  let h0 = mk_rmem (p x) (core_mem m0) in
  lemma_frame_equalities_refl (p x) h0;
  x

#push-options "--fuel 0 --ifuel 0"

#push-options "--z3rlimit 20 --fuel 1 --ifuel 1"

val frame00 (#a:Type)
          (#framed:bool)
          (#opened:inames)
          (#obs:observability)
          (#pre:pre_t)
          (#post:post_t a)
          (#req:req_t pre)
          (#ens:ens_t pre a post)
          ($f:repr a framed opened obs pre post req ens)
          (frame:vprop)
  : repr a
    true
    opened
    obs
    (pre `star` frame)
    (fun x -> post x `star` frame)
    (fun h -> req (focus_rmem h pre))
    (fun h0 r h1 -> req (focus_rmem h0 pre) /\ ens (focus_rmem h0 pre) r (focus_rmem h1 (post r)) /\
      frame_opaque frame (focus_rmem h0 frame) (focus_rmem h1 frame))

module Sem = Steel.Semantics.Hoare.MST
module Mem = Steel.Memory

let equiv_middle_left_assoc (a b c d:slprop)
  : Lemma (((a `Mem.star` b) `Mem.star` c `Mem.star` d) `Mem.equiv`
val equiv_middle_left_assoc (a b c d: slprop)
    : Lemma
    ((((a `Mem.star` b) `Mem.star` c) `Mem.star` d)
      `Mem.equiv`
      ((a `Mem.star` (b `Mem.star` c)) `Mem.star` d))
a: Steel.Memory.slprop -> b: Steel.Memory.slprop -> c: Steel.Memory.slprop -> d: Steel.Memory.slprop
  -> FStar.Pervasives.Lemma
    (ensures
      Steel.Memory.equiv (Steel.Memory.star (Steel.Memory.star (Steel.Memory.star a b) c) d)
        (Steel.Memory.star (Steel.Memory.star a (Steel.Memory.star b c)) d))