Section hfs.
Definition hfs : Set := sig (fun t => bt_norm t = t).
Definition bt_cls (t : bt) : hfs.
Fact hfs_repr_bt_cls t : hfs_repr (bt_cls t) ≈ t.
Fact bt_cls_equiv s t : bt_cls s = bt_cls t <-> s ≈ t.
Fact bt_cls_hfs_repr_iff t s : cls t = s <-> t ≈ repr s.
Definition hfs_eq_dec : forall (s t : hfs), { s = t } + { s <> t }.
Definition hfs_mem s t := bt_mem (repr s) (repr t).
Infix "∈" := hfs_mem.
Arguments hfs_mem s t /.
Fact btm_cls_repr t s : cls t ∈ s <-> bt_mem t (repr s).
Fact btm_repr_cls t s : t ∈ cls s <-> bt_mem (repr t) s.
Fact hfs_mem_btm s t : cls s ∈ cls t <-> bt_mem s t.
Fact hfs_mem_wf : well_founded hfs_mem.
Fact hfs_mem_dec : forall s t, { s ∈ t } + { ~ s ∈ t }.
Definition hfs_empty : hfs := exist _ bt_leaf eq_refl.
Notation "∅" := hfs_empty.
Fact hfs_empty_prop : forall x, ~ x ∈ ∅.
Fact hfs_empty_spec x : x ∈ ∅ <-> False.
Definition hfs_cons x t := cls ((repr x)⪧(repr t)).
Fact hfs_cons_spec y x t : y ∈ hfs_cons x t <-> y = x \/ y ∈ t.
Opaque hfs_empty hfs_cons hfs_mem.

Theorem hfs_comprehension X (P : X -> Prop) (f : X -> hfs) :
fin_t P
-> { s | forall a, a ∈ s <-> exists x, P x /\ f x = a }.