Instance THeap_SA: @SeparationAlgebra THeap THeap_Join.
Inductive THeap_order': THeap' -> THeap' -> Prop:=
| THeap_ord (h1 h2:THeap'):
(forall (n:nat) (c:htype), h2 n = Some c ->
exists (c':htype), h1 n = Some c' /\
ht_ord c' c) ->
THeap_order' h2 h1.
Definition THeap_order (h1 h2: THeap): Prop:=
THeap_order' h1 h2.
Instance THeap_preorder': PreOrder THeap_order'.
constructor.
- hnf; intros.
constructor; intros.
exists c; split; auto; constructor.
- hnf; intros.
inversion H;
inversion H0; subst.
constructor; intros.
apply H1 in H2; destruct H2 as [c0 [HH1 HH2]].
apply H4 in HH1; destruct HH1 as [c' [HH3 HH4]].
exists c'; split; auto.
transitivity c0; auto.
Qed.

Lemma THeap_preorder: PreOrder THeap_order.
constructor.