val rearrange3 (p q r: vprop) : Lemma (((p `star` q) `star` r) `equiv` (p `star` (r `star` q)))
let rearrange3 (p q r:vprop) : Lemma
  (((p `star` q) `star` r) `equiv` (p `star` (r `star` q)))
  = let open FStar.Tactics in
    assert   (((p `star` q) `star` r) `equiv` (p `star` (r `star` q))) by
             (norm [delta_attr [`%__reduce__]]; canon' false (`true_p) (`true_p))
val rearrange3 (p q r: vprop) : Lemma (((p `star` q) `star` r) `equiv` (p `star` (r `star` q)))
let rearrange3 (p q r: vprop) : Lemma (((p `star` q) `star` r) `equiv` (p `star` (r `star` q))) =
let open FStar.Tactics in
FStar.Tactics.Effect.assert_by_tactic (((p `star` q) `star` r) `equiv` (p `star` (r `star` q)))
  (fun _ ->
      ();
      (norm [delta_attr [`%__reduce__]];
        canon' false (`true_p) (`true_p)))
Steel.Primitive.ForkJoin.Unix.fst.checked
Steel.Reference.fsti.checked Steel.Primitive.ForkJoin.fsti.checked Steel.Memory.fsti.checked Steel.FractionalPermission.fst.checked Steel.Effect.Atomic.fsti.checked Steel.Effect.fsti.checked prims.fst.checked FStar.Tactics.Effect.fsti.checked FStar.Tactics.fst.checked FStar.Pervasives.fsti.checked FStar.Ghost.fsti.checked
Steel.Primitive.ForkJoin.Unix.fst
Steel.Effect.Common.vprop FStar.Tactics.Effect.assert_by_tactic Steel.Effect.Common.equiv Steel.Effect.Common.star Prims.unit Steel.Effect.Common.canon' FStar.Tactics.V1.Builtins.norm Prims.Cons FStar.Pervasives.norm_step FStar.Pervasives.delta_attr Prims.string Prims.Nil Prims.l_True Prims.squash 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.Primitive.ForkJoin.Unix

(* This module shows that it's possible to layer continuations on top
of SteelT to get a direct style (or Unix style) fork/join. Very much a
prototype for now. *)

open FStar.Ghost
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
open Steel.Reference
open Steel.Primitive.ForkJoin

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

// (* Some helpers *)
let change_slprop_equiv (p q : vprop)
              (proof : squash (p `equiv` q))
   : SteelT unit p (fun _ -> q)
   = rewrite_slprop p q (fun _ -> proof; reveal_equiv p q)

let change_slprop_imp (p q : vprop)
              (proof : squash (p `can_be_split` q))
   : SteelT unit p (fun _ -> q)
   = rewrite_slprop p q (fun _ -> proof; reveal_can_be_split ())

(* Continuations into unit, but parametrized by the final heap
 * proposition and with an implicit framing. I think ideally these would
 * also be parametric in the final type (instead of being hardcoded to
 * unit) but that means fork needs to be extended to be polymorphic in
 * at least one of the branches. *)
type steelK (t:Type u#aa) (framed:bool) (pre : vprop) (post:t->vprop) =
  #frame:vprop -> #postf:vprop ->
  f:(x:t -> SteelT unit (frame `star` post x) (fun _ -> postf)) ->
  SteelT unit (frame `star` pre) (fun _ -> postf)

(* The classic continuation monad *)
let return_ a (x:a) (#[@@@ framing_implicit] p: a -> vprop) : steelK a true (return_pre (p x)) p =
  fun k -> k x

private
let rearrange3 (p q r:vprop) : Lemma
val rearrange3 (p q r: vprop) : Lemma (((p `star` q) `star` r) `equiv` (p `star` (r `star` q)))
p: Steel.Effect.Common.vprop -> q: Steel.Effect.Common.vprop -> r: Steel.Effect.Common.vprop
  -> FStar.Pervasives.Lemma
    (ensures
      Steel.Effect.Common.equiv (Steel.Effect.Common.star (Steel.Effect.Common.star p q) r)
        (Steel.Effect.Common.star p (Steel.Effect.Common.star r q)))