Section ScanSection.
(* The algorithm is defined as follows: - if the heap is h1 :+ h2, then recurse over h1 and h2 and concatenate the results. - if the heap is x :-> v, then return [x] - otherwise, return [] *)
(* Structure to control the flow of the algorithm *)
Structure tagged_heap := Tag {untag : heap}.
Local Coercion untag : tagged_heap >-> heap.
Definition default_tag := Tag.
Definition ptr_tag := default_tag.
Canonical Structure union_tag h := ptr_tag h.
Definition axiom h s :=
def h -> uniq s /\ forall x, x \in s -> x \in dom h.
(* Main structure *)
Structure form s := Form {heap_of : tagged_heap; _ : axiom heap_of s}.
Local Coercion heap_of : form >-> tagged_heap.
Canonical Structure union_form s1 s2 h1 h2 :=
Form (@union_pf s1 s2 h1 h2).
Canonical Structure ptr_form A x (v : A) :=
Form (@ptr_pf A x v).
Canonical Structure foundx_form x y (s : Search.form y) :=
Form (foundx_pf x s).
Canonical Structure foundy_form x y (s : Search.form x) :=
Form (foundy_pf y s).
Canonical Structure foundz_form x y z (s : form x y) :=
Form (foundz_pf z s).

Lemma find2E x y (s : form x y) : uniq s -> x != y.