Section Peq.
Load "hCoefStructure".
Load "hOrderStructure".
Load "hOrder".
Definition size := length (A:=Term A n).
Definition sizel m := match m with
| (l1, l2) => size l1 + size l2
end.
Definition lessP m1 m2 := sizel m1 < sizel m2.
Hint Unfold lessP.
red in |- *.
cut (forall (m : nat) a, sizel a < m -> Acc lessP a).
intros H' a.
apply H' with (m := S (sizel a)); auto.
intros m; elim m; clear m.
intros a H; inversion H.
intros m H' a H'0.
apply Acc_intro.
intros y H'1; apply H'.
unfold lessP in H'1.
apply lt_le_trans with (sizel a); auto with arith.
Qed.
Hint Resolve wf_lessP.
intros n1 n2 l1 l2 H' H'0; rewrite H'0; rewrite H'; auto.
Qed.
Hint Resolve pX_inj.
intros a b p q H'; inversion H'; auto.
Qed.
Hint Unfold pX.
unfold pX, pX in |- *.
intros p q a b H'; inversion H'; auto.
Qed.

Theorem canonicalpO : canonical A0 eqA ltM (pO A n).