val array_literal_inv:
    #a: Type0 ->
    n: US.t ->
    arr: A.array a ->
    f: (i: US.t{US.v i < US.v n} -> a) ->
    i: Loops.nat_at_most n ->
    Seq.seq a
  -> vprop
let array_literal_inv
  (#a:Type0)
  (n:US.t)
  (arr:A.array a)
  (f:(i:US.t{US.v i < US.v n} -> a))
  (i:Loops.nat_at_most n)
  : Seq.seq a -> vprop
  = fun s ->
    A.pts_to arr full_perm s
      `star`
    pure (array_literal_inv_pure n f i s)
val array_literal_inv:
    #a: Type0 ->
    n: US.t ->
    arr: A.array a ->
    f: (i: US.t{US.v i < US.v n} -> a) ->
    i: Loops.nat_at_most n ->
    Seq.seq a
  -> vprop
let array_literal_inv
      (#a: Type0)
      (n: US.t)
      (arr: A.array a)
      (f: (i: US.t{US.v i < US.v n} -> a))
      (i: Loops.nat_at_most n)
    :  Seq.seq a -> vprop =
fun s -> (A.pts_to arr full_perm s) `star` (pure (array_literal_inv_pure n f i s))
Steel.ST.Array.Util.fst.checked
Steel.ST.Util.fsti.checked Steel.ST.Reference.fsti.checked Steel.ST.Loops.fsti.checked Steel.ST.Effect.fsti.checked Steel.ST.Array.fsti.checked Steel.FractionalPermission.fst.checked prims.fst.checked FStar.SizeT.fsti.checked FStar.Seq.fst.checked FStar.Pervasives.fsti.checked FStar.Ghost.fsti.checked
Steel.ST.Array.Util.fst
FStar.SizeT.t Steel.ST.Array.array Prims.b2t Prims.op_LessThan FStar.SizeT.v Steel.ST.Loops.nat_at_most FStar.Seq.Base.seq Steel.Effect.Common.star Steel.ST.Array.pts_to Steel.FractionalPermission.full_perm Steel.ST.Util.pure Steel.ST.Array.Util.array_literal_inv_pure Steel.Effect.Common.vprop
(*
   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.
*)

module Steel.ST.Array.Util

module G = FStar.Ghost
module US = FStar.SizeT

module R = Steel.ST.Reference
module A = Steel.ST.Array
module Loops = Steel.ST.Loops

open Steel.FractionalPermission
open Steel.ST.Effect
open Steel.ST.Util

/// Implementation of array_literal using a for loop


let array_literal_inv_pure
  (#a:Type0)
  (n:US.t)
  (f:(i:US.t{US.v i < US.v n} -> a))
  (i:Loops.nat_at_most n)
  (s:Seq.seq a)
  : prop
  = forall (j:nat).
      (j < i /\ j < Seq.length s) ==> Seq.index s j == f (US.uint_to_t j)

[@@ __reduce__]
let array_literal_inv
  (#a:Type0)
  (n:US.t)
  (arr:A.array a)
  (f:(i:US.t{US.v i < US.v n} -> a))
  (i:Loops.nat_at_most n)
val array_literal_inv:
    #a: Type0 ->
    n: US.t ->
    arr: A.array a ->
    f: (i: US.t{US.v i < US.v n} -> a) ->
    i: Loops.nat_at_most n ->
    Seq.seq a
  -> vprop

    n: FStar.SizeT.t ->
    arr: Steel.ST.Array.array a ->
    f: (i: FStar.SizeT.t{FStar.SizeT.v i < FStar.SizeT.v n} -> a) ->
    i: Steel.ST.Loops.nat_at_most n ->
    _: FStar.Seq.Base.seq a
  -> Steel.Effect.Common.vprop