val new_inv (#u:_) (p:vprop)
  : SteelAtomicUT (inv p) u
    p
    (fun i -> active full_perm i)
let new_inv #u p =
  let r = ghost_alloc_pt (Ghost.hide true) in
  ghost_share_pt r;
  intro_exists true (conditional_inv r p);
  let i = new_invariant (ex_conditional_inv r p) in
  rewrite_slprop
    (ghost_pts_to r (half_perm full_perm) true)
    (ghost_pts_to (gref (hide (| r, i |))) (half_perm full_perm) true)
    (fun _ -> ());
  return (| r, i |)
val new_inv (#u:_) (p:vprop)
  : SteelAtomicUT (inv p) u
    p
    (fun i -> active full_perm i)
let new_inv #u p =
let r = ghost_alloc_pt (Ghost.hide true) in
ghost_share_pt r;
intro_exists true (conditional_inv r p);
let i = new_invariant (ex_conditional_inv r p) in
rewrite_slprop (ghost_pts_to r (half_perm full_perm) true)
  (ghost_pts_to (gref (hide (| r, i |))) (half_perm full_perm) true)
  (fun _ -> ());
return (| r, i |)
Steel.DisposableInvariant.fst.checked
Steel.Reference.fsti.checked Steel.Memory.fsti.checked Steel.FractionalPermission.fst.checked Steel.Effect.Atomic.fsti.checked Steel.Effect.fsti.checked prims.fst.checked FStar.Real.fsti.checked FStar.Pervasives.fsti.checked FStar.Ghost.fsti.checked
Steel.DisposableInvariant.fst
Steel.Memory.inames Steel.Effect.Common.vprop Steel.Effect.Atomic.return Steel.DisposableInvariant.inv Steel.Reference.ghost_pts_to Prims.bool Steel.DisposableInvariant.gref Steel.FractionalPermission.half_perm Steel.FractionalPermission.full_perm Prims.Mkdtuple2 Steel.Reference.ghost_ref Steel.Effect.Common.inv Steel.DisposableInvariant.ex_conditional_inv Prims.unit Steel.Effect.Atomic.rewrite_slprop Steel.Memory.mem Steel.Effect.Atomic.new_invariant Steel.Effect.Atomic.intro_exists Steel.DisposableInvariant.conditional_inv Steel.Reference.ghost_share_pt FStar.Ghost.hide Steel.Reference.ghost_alloc_pt
(*
   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.DisposableInvariant

open FStar.Ghost
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
open Steel.FractionalPermission
open Steel.Reference

#push-options "--ide_id_info_off"

[@@__reduce__]
let conditional_inv (r:ghost_ref bool) (p:vprop) =
      (fun (b:bool) ->
         ghost_pts_to r (half_perm full_perm) b `star`
         (if b then p else emp))

[@@__reduce__]
let ex_conditional_inv (r:ghost_ref bool) (p:vprop) =
    h_exists (conditional_inv r p)

let inv (p:vprop) = r:ghost_ref bool & inv (ex_conditional_inv r p)

let name (#p:_) (i:inv p) = name_of_inv (dsnd i)
let gref (#p:_) (i:inv p) = dfst i

[@@__reduce__]
let active (#p:_) ([@@@smt_fallback]f:perm) (i:inv p) =
  ghost_pts_to (gref i) (half_perm f) true
val new_inv (#u:_) (p:vprop)
  : SteelAtomicUT (inv p) u
    p
    (fun i -> active full_perm i)
p: Steel.Effect.Common.vprop -> Steel.Effect.Atomic.SteelAtomicUT (Steel.DisposableInvariant.inv p)