open Fstarcompiler
open Prims
type ('a, 'b, 'x) opt = 'b FStar_Pervasives_Native.option
type ('a, 'b) partial_dependent_map =
  ('a, ('a, 'b, unit) opt) FStar_DependentMap.t
let empty_partial_dependent_map (uu___ : unit) :
  ('a, 'b) partial_dependent_map=
  FStar_DependentMap.create (fun x -> FStar_Pervasives_Native.None)
type ('a, 'b) map = ('a, 'b) Fstarcompiler.Prims.dtuple2 Prims.list
let empty (uu___ : unit) : ('a, 'b) map= []
let rec sel : 'a 'b . ('a, 'b) map -> 'a -> 'b FStar_Pervasives_Native.option
  =
  fun r x ->
    match r with
    | [] -> FStar_Pervasives_Native.None
    | (Fstarcompiler.Prims.Mkdtuple2 (x', y))::tl ->
        if x = x' then FStar_Pervasives_Native.Some y else sel tl x
let upd (r : ('a, 'b) map) (x : 'a) (v : 'b) : ('a, 'b) map=
  (Fstarcompiler.Prims.Mkdtuple2 (x, v)) :: r
type ('a, 'b, 'inv) imap = ('a, 'b) map
type ('a, 'b, 'inv, 'm1, 'm2) grows' = unit
type ('a, 'b, 'inv, 'uuuuu, 'uuuuu1) grows = unit
type ('r, 'a, 'b, 'inv) t =
  ('r, ('a, 'b, 'inv) imap, unit) FStar_HyperStack_ST.m_rref
type ('a, 'b, 'inv, 'r, 't1, 'x, 'h) defined = unit
type ('a, 'b, 'inv, 'r, 't1, 'x, 'h) fresh = unit
type ('a, 'b, 'inv, 'r, 't1, 'x, 'y, 'h) contains = unit
let alloc (r : unit) (uu___ : unit) : (Obj.t, 'a, 'b, 'inv) t=
  FStar_HyperStack_ST.ralloc () []
let extend (r : unit) (t1 : (Obj.t, 'a, 'b, 'inv) t) (x : 'a) (y : 'b) :
  unit=
  FStar_HyperStack_ST.recall t1;
  (let cur = FStar_HyperStack_ST.op_Bang t1 in
   FStar_HyperStack_ST.op_Colon_Equals t1 (upd cur x y);
   FStar_HyperStack_ST.mr_witness () () () (Obj.magic t1) ())
let lookup (r : unit) (t1 : (Obj.t, 'a, 'b, 'inv) t) (x : 'a) :
  'b FStar_Pervasives_Native.option=
  let m = FStar_HyperStack_ST.op_Bang t1 in
  let y = sel m x in
  match y with
  | FStar_Pervasives_Native.None -> y
  | FStar_Pervasives_Native.Some b1 ->
      (FStar_HyperStack_ST.mr_witness () () () (Obj.magic t1) (); y)
type ('a, 'b, 'inv, 'r, 't1, 'h, 'pred) forall_t = unit
let f_opt (f : 'a -> 'b -> 'c) (x : 'a)
  (y : 'b FStar_Pervasives_Native.option) :
  'c FStar_Pervasives_Native.option=
  match y with
  | FStar_Pervasives_Native.None -> FStar_Pervasives_Native.None
  | FStar_Pervasives_Native.Some y1 -> FStar_Pervasives_Native.Some (f x y1)
let rec mmap_f : 'a 'b 'c . ('a, 'b) map -> ('a -> 'b -> 'c) -> ('a, 'c) map
  =
  fun m f ->
    match m with
    | [] -> []
    | (Fstarcompiler.Prims.Mkdtuple2 (x, y))::tl ->
        (Fstarcompiler.Prims.Mkdtuple2 (x, (f x y))) :: (mmap_f tl f)
let map_f (r : unit) (r' : unit) (t1 : (Obj.t, 'a, 'b, 'inv) t)
  (f : 'a -> 'b -> 'c) : (Obj.t, 'a, 'c, 'invu) t=
  let m = FStar_HyperStack_ST.op_Bang t1 in
  FStar_HyperStack_ST.ralloc () (mmap_f m f)
