(* methods *)

Definition def h := if h is Def _ _ then true else false.Definition empty := @Def (finmap.nil _ _) is_true_true.Definition free x h := 
  if h is Def hs ns then Def (free_nullP x ns) else Undef.Definition find (x : ptr) h := 
  if h is Def hs _ then fnd x hs else None.Definition union h1 h2 := 
  if (h1, h2) is (Def hs1 ns1, Def hs2 ns2) then  
    if disj hs1 hs2 then 
       Def (@un_nullP _ _ ns1 ns2)
    else Undef
  else Undef.Definition um_filter q f := 
  if f is Def fs pf then Def (@filt_nullP fs q pf) else Undef.Definition pts (x : ptr) v := upd x v empty.Definition undefb h := if h is Undef then true else false.Definition from (f : heap) : base :=
  if f is Def hs ns then UM.Def (heap_base ns) else UM.Undef _ _.Definition to (b : base) : heap := 
  if b is UM.Def hs ns then Def (base_heap ns) else Undef.

(* Specifications: *)
Lemma ftE b : from (to b) = b.
Lemma tfE f : to (from f) = f.
Lemma undefE : Undef = to (@UM.Undef _ _ _).
Lemma defE f : def f = UM.valid (from f).
Lemma emptyE : empty = to (@UM.empty _ _ _).
Lemma updE k v f : upd k v f = to (UM.upd k v (from f)).
Lemma domE f : dom f = UM.dom (from f).
Lemma dom_eqE f1 f2 : dom_eq f1 f2 = UM.dom_eq (from f1) (from f2).
Lemma freeE k f : free k f = to (UM.free k (from f)).
Lemma findE k f : find k f = UM.find k (from f).
Lemma unionE f1 f2 : union f1 f2 = to (UM.union (from f1) (from f2)).
Lemma umfiltE q f : um_filter q f = to (UM.um_filter q (from f)).
Lemma empbE f : empb f = UM.empb (from f).
Lemma undefbE f : undefb f = UM.undefb (from f).
Lemma ptsE k (v : dynamic id) : pts k v = to (@UM.pts _ _ _ k v).