Definition complete MAX l := l ++ repeat (vptrofs 0) (Z.to_nat MAX - length l).

(* Specifications: *)
Lemma upd_complete : forall l x MAX, Zlength l < MAX ->
upd_Znth (Zlength l) (complete MAX l) x = complete MAX (l ++ [x]).
Lemma Znth_complete : forall n l MAX, n < Zlength l ->
Znth n (complete MAX l) = Znth n l.
Lemma remove_complete : forall l x MAX, Zlength l < MAX ->
upd_Znth (Zlength l) (complete MAX (l ++ [x])) (vptrofs 0) = complete MAX l.
Lemma Forall_app : forall {A} (P : A -> Prop) l1 l2,
Forall P (l1 ++ l2) <-> Forall P l1 /\ Forall P l2.
Lemma Forall_incl : forall {A} (P : A -> Prop) l1 l2 (Hall : Forall P l2) (Hincl : incl l1 l2),
Forall P l1.
Lemma repeat_plus : forall {A} (x : A) i j, repeat x (i + j) = repeat x i ++ repeat x j.
Lemma in_insert_iff : forall {A} (x y : A) l1 l2, In x (l1 ++ y :: l2) <-> x = y \/ In x (l1 ++ l2).
Definition remove_at {A} i (l : list A) := firstn i l ++ skipn (S i) l.
Lemma Forall_firstn : forall {A} (P : A -> Prop) l i, Forall P l ->
Forall P (firstn i l).
Lemma Forall_skipn : forall {A} (P : A -> Prop) l i, Forall P l ->
Forall P (skipn i l).
Lemma Forall_upd_Znth : forall {A} (P : A -> Prop) x l i, Forall P l -> P x ->
Forall P (upd_Znth i l x).
Lemma last_cons : forall {A} (d : A) l x, l <> [] -> last (x :: l) d = last l d.
Lemma nth_last : forall {A} (d : A) l, nth (length l - 1) l d = last l d.
Lemma Znth_last : forall {A}{d: Inhabitant A} l, Znth (Zlength l - 1) l = last l default.
Lemma last_app : forall {A} l1 l2 (d : A), l2 <> [] -> last (l1 ++ l2) d = last l2 d.
Lemma nat_sorted_list_eq : forall d n l (Hl : forall i, (i < n)%nat <-> In i l) (Hlen : length l = n)
(Hsorted : forall i j, (i < j < n -> nth i l d < nth j l d)%nat) i (Hi : (i < n)%nat), nth i l d = i.
Lemma Forall2_In_l : forall {A B} (P : A -> B -> Prop) x l1 l2, Forall2 P l1 l2 -> In x l1 ->
exists y, In y l2 /\ P x y.
Lemma Forall2_In_r : forall {A B} (P : A -> B -> Prop) x l1 l2, Forall2 P l1 l2 -> In x l2 ->
exists y, In y l1 /\ P y x.
Lemma last_snoc : forall {A} (d : A) x l, last (l ++ [x]) d = x.
Lemma iter_sepcon_sepcon: forall {A} f g1 g2 l, (forall b : A, f b = g1 b * g2 b) ->
iter_sepcon f l = iter_sepcon g1 l * iter_sepcon g2 l.
Lemma sepcon_app : forall l1 l2, fold_right sepcon emp (l1 ++ l2) =
fold_right sepcon emp l1 * fold_right sepcon emp l2.