Section BOOLEAN_EQUALITY.
Variable A: Type.
Variable beqA: A -> A -> bool.
Fixpoint bempty (m: t A) : bool :=
match m with
| Leaf => true
| Node l None r => bempty l && bempty r
| Node l (Some _) r => false
end.
Fixpoint beq (m1 m2: t A) {struct m1} : bool :=
match m1, m2 with
| Leaf, _ => bempty m2
| _, Leaf => bempty m1
| Node l1 o1 r1, Node l2 o2 r2 =>
match o1, o2 with
| None, None => true
| Some y1, Some y2 => beqA y1 y2
| _, _ => false
end
&& beq l1 l2 && beq r1 r2
end.
End BOOLEAN_EQUALITY.
Fixpoint prev_append (i j: positive) {struct i} : positive :=
match i with
| xH => j
| xI i' => prev_append i' (xI j)
| xO i' => prev_append i' (xO j)
end.
Definition prev (i: positive) : positive :=
prev_append i xH.

Lemma prev_append_prev i j:
prev (prev_append i j) = prev_append j i.