val bv_set
  (#n:US.t)
  (#s:G.erased repr)
  (bv:bv_t n)
  (i:US.t{US.v i < Seq.length s})
  : STT unit
       (pts_to bv full_perm s)
       (fun _ -> pts_to bv full_perm (Seq.upd s (US.v i) true))
let bv_set #_ #s bv i = A.write #_ bv #s i true
val bv_set
  (#n:US.t)
  (#s:G.erased repr)
  (bv:bv_t n)
  (i:US.t{US.v i < Seq.length s})
  : STT unit
       (pts_to bv full_perm s)
       (fun _ -> pts_to bv full_perm (Seq.upd s (US.v i) true))
let bv_set #_ #s bv i =
A.write #_ bv #s i true
Steel.ST.BitVector.fst.checked
Steel.ST.Util.fsti.checked Steel.ST.Effect.Ghost.fsti.checked Steel.ST.Effect.fsti.checked Steel.ST.Array.fsti.checked prims.fst.checked FStar.SizeT.fsti.checked FStar.Pervasives.fsti.checked FStar.Ghost.fsti.checked
Steel.ST.BitVector.fst
FStar.SizeT.t FStar.Ghost.erased Steel.ST.BitVector.repr Steel.ST.BitVector.bv_t Prims.b2t Prims.op_LessThan FStar.SizeT.v FStar.Seq.Base.length Prims.bool FStar.Ghost.reveal Steel.ST.Array.write Prims.unit
(*
   Copyright 2021 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.

   Authors: Aseem Rastogi
*)

module Steel.ST.BitVector

open Steel.ST.Effect.Ghost
open Steel.ST.Effect
open Steel.ST.Util

module US = FStar.SizeT
module G = FStar.Ghost
module A = Steel.ST.Array

/// Implementation of bv_t using an array of bool

type bv_t n = a:A.array bool{A.length a == US.v n /\ A.is_full_array a}

let pts_to bv p s = A.pts_to bv p s

let pts_to_length bv s = A.pts_to_length bv s

let alloc n = A.alloc false n

let bv_is_set bv i = A.read bv i
val bv_set
  (#n:US.t)
  (#s:G.erased repr)
  (bv:bv_t n)
  (i:US.t{US.v i < Seq.length s})
  : STT unit
       (pts_to bv full_perm s)
       (fun _ -> pts_to bv full_perm (Seq.upd s (US.v i) true))

    bv: Steel.ST.BitVector.bv_t n ->
    i: FStar.SizeT.t{FStar.SizeT.v i < FStar.Seq.Base.length (FStar.Ghost.reveal s)}
  -> Steel.ST.Effect.STT Prims.unit