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.

(* Specifications: *)
Lemma prev_append_prev i j: prev (prev_append i j) = prev_append j i.
Lemma prev_involutive i : prev (prev i) = i.
Lemma prev_append_inj i j j' : prev_append i j = prev_append i j' -> j = j'.