val eq_lemma: #k:eqtype -> #v:Type -> #f:cmp k -> m1:ordmap k v f -> m2:ordmap k v f
              -> Lemma (requires (equal m1 m2))
                      (ensures (m1 == m2))
                 [SMTPat (equal m1 m2)]
let eq_lemma (#k:eqtype) (#v:Type) #f m1 m2 =
  let Mk_map s1 g1 = m1 in
  let Mk_map s2 g2 = m2 in
  let _ = cut (feq g1 g2) in
  let _ = OrdSet.eq_lemma s1 s2 in
  ()
val eq_lemma: #k:eqtype -> #v:Type -> #f:cmp k -> m1:ordmap k v f -> m2:ordmap k v f
              -> Lemma (requires (equal m1 m2))
                      (ensures (m1 == m2))
                 [SMTPat (equal m1 m2)]
let eq_lemma (#k: eqtype) (#v: Type) #f m1 m2 =
let Mk_map s1 g1 = m1 in
let Mk_map s2 g2 = m2 in
let _ = cut (feq g1 g2) in
let _ = OrdSet.eq_lemma s1 s2 in
()
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.ordset FStar.OrdMap.map_t Prims.unit FStar.OrdSet.eq_lemma Prims.cut FStar.FunctionalExtensionality.feq 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'

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))

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

let equal (#k:eqtype) (#v:Type) (#f:cmp k) (m1:ordmap k v f) (m2:ordmap k v f) =
  forall x. select #k #v #f x m1 == select #k #v #f x m2

let eq_intro (#k:eqtype) (#v:Type) #f m1 m2 = ()
val eq_lemma: #k:eqtype -> #v:Type -> #f:cmp k -> m1:ordmap k v f -> m2:ordmap k v f
              -> Lemma (requires (equal m1 m2))
                      (ensures (m1 == m2))
                 [SMTPat (equal m1 m2)]
m1: FStar.OrdMap.ordmap k v f -> m2: FStar.OrdMap.ordmap k v f
  -> FStar.Pervasives.Lemma (requires FStar.OrdMap.equal m1 m2)
      (ensures m1 == m2)
      [SMTPat (FStar.OrdMap.equal m1 m2)]