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).

Lemma default_pf h : axiom (default_tag h) [::].