Ltac spec H := match type of H with ?A -> _ =>
let H' := fresh in (assert (H' : A); [ | specialize (H H'); clear H']) end.

(* Specifications: *)
Lemma treeify_g_length:
forall n l, S (length l) >= nat_of_P n ->
length(snd(treeify_g n l))+nat_of_P n = S (length l).
Lemma eq1dec: forall n, {n=1%positive}+{n<>1%positive}.
Lemma treeify_g_induc:
forall fP gP : positive -> list key -> tree * list key -> Prop,
(forall l n' t1 x l2 t2 l3
(LEN: length l >= nat_of_P n')
(LEN2: length l2 >= nat_of_P n'),
fP n' l (t1, x::l2) ->  treeify_f n' l = (t1, x::l2) -> fP n' l2 (t2, l3) ->
treeify_f n' l2 = (t2, l3) -> fP (xI n') l (T Black t1 x t2, l3)) ->
(forall  l n' t1 x l2 t2 l3
(LEN: length l >= nat_of_P n')
(LEN2: S (length l2) >= nat_of_P n'),
fP n' l (t1, x :: l2) -> treeify_f n' l = (t1, x :: l2) -> gP n' l2 (t2, l3) ->
treeify_g n' l2 = (t2, l3) -> fP (xO n') l (T Black t1 x t2, l3)) ->
(forall x l1, fP xH (x :: l1) (T Red EE x EE, l1)) ->
(forall  l n' t1 x l2 t2 l3
(LEN: length l >= nat_of_P n')
(LEN2: S (length l2) >= nat_of_P n'),
fP n' l (t1, x :: l2) -> treeify_f n' l = (t1, x :: l2) -> gP n' l2 (t2, l3) ->
treeify_g n' l2 = (t2, l3) -> gP (xI n') l (T Black t1 x t2, l3)) ->
(forall l n' t1 x l2 t2 l3
(LEN: S (length l) >= nat_of_P n')
(LEN2: S (length l2) >= nat_of_P n'),
gP n' l (t1, x :: l2) -> treeify_g n' l = (t1, x :: l2) ->
gP n' l2 (t2, l3) -> treeify_g n' l2 = (t2, l3) -> gP (xO n') l (T Black t1 x t2, l3)) ->
(forall l, gP xH l (EE, l)) ->
forall n l, S (length l) >= nat_of_P n -> gP n l (treeify_g n l).
Lemma treeify'_g_is_redblack:
forall n l,
S (length l) >= nat_of_P n ->
is_redblack (fst (treeify_g n l)) Red (plog2 n).
Lemma nat_of_poslength:
forall A (l: list A), nat_of_P (poslength l) = S (length l).
Lemma treeify_is_redblack:
forall l, exists n, is_redblack (treeify l) Red n.