(*************************************)
(* 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}.

(* Specifications: *)
Lemma partitionE r k (f : partition k r) : untag f = k \+ r.
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'].
Lemma llist_null A (xs : seq A) h :
valid h -> llist null xs h -> xs = [::] /\ h = Unit.