(*************************************)
(* the automation of the PtUn lemmas *)
(*************************************)
(* First, the mechanism for search-and-replace for the overloaded lemas, *)
(* pattern-matching on heap expressions.                                 *)
Structure tagged_heap := Tag {untag :> heap}.
Definition right_tag := Tag.
Definition left_tag := right_tag.
Canonical found_tag i := left_tag i.
Definition partition_axiom k r (h : tagged_heap) := untag h = k \+ r.
Structure partition (k r : heap) :=
Partition {heap_of :> tagged_heap;
_ : partition_axiom k r heap_of}.

Lemma first_exists A p h (ls : seq A) :
p != null -> llist p ls h ->
exists x r h',
[/\ ls = x :: behead ls, h = p :-> (x, r) \+ h' &
llist r (behead ls) h'].