val choose  : #key:eqtype -> #value:Type -> #f:cmp key -> ordmap key value f
              -> Tot (option (key * value))
let choose (#k:eqtype) (#v:Type) #f m =
  match OrdSet.choose (Mk_map?.d m) with
    | None   -> None
    | Some x -> Some (x, Some?.v ((Mk_map?.m m) x))
val choose  : #key:eqtype -> #value:Type -> #f:cmp key -> ordmap key value f
              -> Tot (option (key * value))
let choose (#k: eqtype) (#v: Type) #f m =
match OrdSet.choose (Mk_map?.d m) with
| None -> None
| Some x -> Some (x, Some?.v ((Mk_map?.m m) x))
FStar.OrdMap.fst.checked
prims.fst.checked FStar.Pervasives.Native.fst.checked FStar.Pervasives.fsti.checked FStar.OrdSet.fsti.checked FStar.FunctionalExtensionality.fsti.checked
FStar.OrdMap.fst
Prims.eqtype FStar.OrdSet.cmp FStar.OrdMap.ordmap FStar.OrdSet.choose FStar.OrdMap.__proj__Mk_map__item__d FStar.Pervasives.Native.None FStar.Pervasives.Native.tuple2 FStar.Pervasives.Native.Some FStar.Pervasives.Native.Mktuple2 FStar.Pervasives.Native.__proj__Some__item__v FStar.OrdMap.__proj__Mk_map__item__m FStar.Pervasives.Native.option
(*
   Copyright 2008-2018 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 FStar.OrdMap

open FStar.OrdSet
open FStar.FunctionalExtensionality
module F = FStar.FunctionalExtensionality

let map_t (k:eqtype) (v:Type) (f:cmp k) (d:ordset k f) =
  g:F.restricted_t k (fun _ -> option v){forall x. mem x d == Some? (g x)}

noeq
type ordmap (k:eqtype) (v:Type) (f:cmp k) =
  | Mk_map: d:ordset k f -> m:map_t k v f d -> ordmap k v f

let empty (#k:eqtype) (#v:Type) #f =
  let d = OrdSet.empty in
  let g = F.on_dom k (fun x -> None) in
  Mk_map d g

let const_on (#k:eqtype) (#v:Type) #f d x =
  let g = F.on_dom k (fun y -> if mem y d then Some x else None) in
  Mk_map d g

let select (#k:eqtype) (#v:Type) #f x m = (Mk_map?.m m) x

let insert (#a:eqtype) (#f:cmp a) (x:a) (s:ordset a f) = union #a #f (singleton #a #f x) s

let update (#k:eqtype) (#v:Type) #f x y m =
  let s' = insert x (Mk_map?.d m) in
  let g' = F.on_dom k (fun (x':k) -> if x' = x then Some y else (Mk_map?.m m) x') in
  Mk_map s' g'

let contains (#k:eqtype) (#v:Type) #f x m = mem x (Mk_map?.d m)

let dom (#k:eqtype) (#v:Type) #f m = (Mk_map?.d m)

let remove (#k:eqtype) (#v:Type) #f x m =
  let s' = remove x (Mk_map?.d m) in
  let g' = F.on_dom k (fun x' -> if x' = x then None else (Mk_map?.m m) x') in
  Mk_map s' g'
val choose  : #key:eqtype -> #value:Type -> #f:cmp key -> ordmap key value f
              -> Tot (option (key * value))
m: FStar.OrdMap.ordmap key value f -> FStar.Pervasives.Native.option (key * value)