(*******************freezing a list of mpreds ******************************)

Fixpoint freezelist_nth (l: list nat) (al: list mpred): (list mpred) * (list mpred) :=
 match l with
 | nil => (nil,al)
 | (n::l') => let (xs, ys) := freezelist_nth l' al
              in (nth n ys emp::xs, delete_nth n ys)
 end.

Lemma fold_right_sepcon_deletenth: forall n (l: list mpred), fold_right_sepcon l = nth n l emp * fold_right_sepcon (delete_nth n l).