Section IterTreeSepCon2.
Context {A : Type}.
Context {B1 B2 : Type}.
Context {ND : NatDed A}.
Context {SL : SepLog A}.
Context {ClS: ClassicalSep A}.
Context {CoSL: CorableSepLog A}.
Context (p : B1 -> B2 -> A).
Fixpoint iter_tree_sepcon2 (t1 : tree B1) : tree B2 -> A :=
match t1 with
| E => fun t2 =>
match t2 with
| E => emp
| _ => FF
end
| T xa x xb => fun t2 =>
match t2 with
| E => FF
| T ya y yb => p x y * iter_tree_sepcon2 xa ya * iter_tree_sepcon2 xb yb
end
end.
End IterTreeSepCon2.
(* X_DEFS *)
Inductive XTree: Type :=
| XLeaf: XTree
| XNode: list XTree -> Z -> XTree.
Fixpoint xtree_rep (t: XTree) (p: val): mpred :=
match t with
| XLeaf =>
!!(p = nullval) && emp
| XNode tl v =>
EX q: val,
data_at Tsh t_struct_Xnode (q, Vint (Int.repr v)) p *
EX r: list val,
list_rep (fun (p: val) (n: val) (q: val) => data_at Tsh t_struct_Xlist (p, n) q) r q *
iter_sepcon2 xtree_rep tl r
end.
Hint Resolve xtree_rep_valid_pointer: valid_pointer.
Hint Resolve xtree_rep_local_facts: saturate_local.
Hint Resolve list_rep_Xlist_valid_pointer: valid_pointer.
Hint Resolve list_rep_Xlist_local_facts: saturate_local.

Lemma xtree_rep_nullval: forall t,
xtree_rep t nullval |-- !! (t = XLeaf).