(********)
(* free *)
(********)

(* Specifications: *)
Lemma free0 x : free x empty = empty.
Lemma freeF h x y :
free x (free y h) = if x == y then free x h else free y (free x h).
Lemma freeUnD h1 h2 x :
def (h1 :+ h2) -> free x (h1 :+ h2) = free x h1 :+ free x h2.
Lemma freeUnl h1 h2 x : x \notin dom h1 -> free x (h1 :+ h2) = h1 :+ free x h2.
Lemma freeUnr h1 h2 x : x \notin dom h2 -> free x (h1 :+ h2) = free x h1 :+ h2.
Lemma lookF h x y :
look x (free y h) = if x == y then dyn tt else look x h.
Lemma lookUnr h1 h2 x :
def (h1 :+ h2) ->
look x (h1 :+ h2) = if x \in dom h2 then look x h2 else look x h1.
Lemma empU h x d : empb (upd h x d) = false.
Lemma empPt A x (v : A) : empb (x :-> v) = false.
(* some transformation lemmas *)
Lemma empbE h : h = empty <-> empb h.
Lemma defUnhh h : def (h :+ h) = empb h.
(*********)
(* fresh *)
(*********)
Lemma path_last n s x : path ord x s -> ord x (last x s).+(n+1).
Lemma path_filter (A : ordType) (s : seq A) (p : pred A) x :
path ord x s -> path ord x (filter p s).
Lemma dom_fresh h n : (fresh h).+n \notin dom h.
Lemma fresh_null h : fresh h != null.
Lemma pickP h : def h && ~~ empb h = (pick h \in dom h).
(**********)
(* subdom *)
(**********)
Lemma subdom_def h1 h2 : subdom h1 h2 -> def h1 && def h2.
Lemma subdomQ x h1 h2 : subdom h1 h2 -> x \in dom h1 -> x \in dom h2.
Lemma subdom_refl h : def h -> subdom h h.
Lemma subdomE h1 h2 h :
def (h2 :+ h) -> subdom h1 h2 -> subdom (h1 :+ h) (h2 :+ h).
Lemma subdomUE h1 h2 h1' h2' :
def (h2 :+ h2') -> subdom h1 h2 -> subdom h1' h2' ->
subdom (h1 :+ h1') (h2 :+ h2').
Lemma subdom_emp h : def h -> subdom empty h.
Lemma subdomPE A B x (v1 : A) (v2 : B) :
x != null -> subdom (x :-> v1) (x :-> v2).
Lemma subdom_trans h2 h1 h3 : subdom h1 h2 -> subdom h2 h3 -> subdom h1 h3.
Hint Resolve subdom_emp subdomPE : core.