val un_build (#a: _) (s: seq a {length s > 0}) : seq a & a
let un_build (#a:_) (s:seq a{length s > 0})
  : seq a & a
  = take s (length s - 1),
    s $@ (length s - 1)
val un_build (#a: _) (s: seq a {length s > 0}) : seq a & a
let un_build (#a: _) (s: seq a {length s > 0}) : seq a & a =
take s (length s - 1), s $@ (length s - 1)
FStar.Sequence.Util.fst.checked
prims.fst.checked FStar.Sequence.Base.fsti.checked FStar.Pervasives.Native.fst.checked FStar.Pervasives.fsti.checked
FStar.Sequence.Util.fst
FStar.Sequence.Base.seq Prims.b2t Prims.op_GreaterThan FStar.Sequence.Base.length FStar.Pervasives.Native.Mktuple2 FStar.Sequence.Base.take Prims.op_Subtraction FStar.Sequence.Base.op_Dollar_At FStar.Pervasives.Native.tuple2
(*
   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.

   Author: N. Swamy
*)

(** This module provides some utilities on top of FStar.Sequence *)
module FStar.Sequence.Util
open FStar.Sequence.Base


/// For convenience, we define `slice` to represent Dafny sequence slices.
let slice (#ty: Type) (s: seq ty) (i: nat) (j: nat{j >= i && j <= length s})
  : seq ty
  = all_seq_facts_lemma();
    drop (take s j) i

let cons #a (x:a) (s:seq a) = singleton x `append` s

let head #a (s:seq a{length s > 0}) = s $@ 0

let tail #a (s:seq a{length s > 0}) = drop s 1

/// Split a sequences into a prefix and the last element
/// This is the inverse of the Sequence.build
let un_build (#a:_) (s:seq a{length s > 0})
val un_build (#a: _) (s: seq a {length s > 0}) : seq a & a
s: FStar.Sequence.Base.seq a {FStar.Sequence.Base.length s > 0} -> FStar.Sequence.Base.seq a * a