Definition lfresh h := (last null (get_lows h)) .+ 2.
Definition hfresh h := (last (null .+ 1) (get_highs h)) .+ 2.

(* Specifications: *)
Lemma last_inv A B (f : A -> B) (x1 x2 : A) (h : seq A) :
f x1 = f x2 -> f (last x1 h) = f (last x2 h).
Lemma hfresh_high h n : high (hfresh h) .+ (2*n).
Lemma dom_lfresh h n : (lfresh h) .+ (2*n) \notin dom h.
Lemma dom_hfresh h n : (hfresh h) .+ (2*n) \notin dom h.
Lemma lfresh_null h : lfresh h != null.
Lemma modnS x1 x2 : (x1 == x2 %[mod 2]) = (x1.+1 == x2.+1 %[mod 2]).
Lemma hlE x : high x = ~~ low x.
Lemma lhE x : low x = ~~ high x.
Lemma loweqK h1 h2 t1 t2 :
def (h1 :+ t1) -> def (h2 :+ t2) ->
h1 =~ h2 -> h1 :+ t1 =~ h2 :+ t2 -> t1 =~ t2.
Lemma loweqE h1 h2 : h1 =~ h2 -> lfresh h1 = lfresh h2.
Lemma lowPn A1 A2 (x : ptr) (v1 : A1) (v2 : A2) : x :-> v1 =~ x :-> v2.
Lemma lowPtUn A1 A2 h1 h2 (x : ptr) (v1 : A1) (v2 : A2) :
def (x :-> v1 :+ h1) ->
def (x :-> v2 :+ h2) ->
(x :-> v1 :+ h1 =~ x :-> v2 :+ h2) = (h1 =~ h2).
Lemma highPtUn A h1 h2 (x : ptr) (v : A) :
def (x :-> v :+ h1) -> high x ->
(x :-> v :+ h1 =~ h2) = (h1 =~ h2).
Lemma highPtUn2 A1 A2 h1 h2 (x1 x2 : ptr) (v1 : A1) (v2 : A2) :
def (x1 :-> v1 :+ h1) ->
def (x2 :-> v2 :+ h2) ->
high x1 -> high x2 ->
h1 =~ h2 -> x1 :-> v1 :+ h1 =~ x2 :-> v2 :+ h2.
Lemma unKhr2 h h1 h2 : def2 (h2 :++ h) -> h1 :++ h = h2 :++ h -> h1 = h2.
Lemma unDl2 h1 h2 : def2 (h1 :++ h2) -> def2 h1.
Lemma exit4 h : def h -> h = h -> def empty /\ empty = empty.
Lemma sexit2 h1 h :
def (h1 :+ h) -> (def h1 -> supdom h1 empty) ->
supdom (h1 :+ h) h.
Lemma sexit3 h1 h :
def h -> (def empty -> supdom empty h1) ->
supdom h (h :+ h1).
Lemma sexit4 h : def h -> (def empty -> empty = empty) -> supdom h h.
Lemma supdomeqUh h1 h2 h :
def (h2 :+ h) -> (def h2 -> supdom h2 h1) -> supdom (h2 :+ h) (h1 :+ h).