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.
split; auto.
apply olistO.
red in |- *; simpl in |- *; auto.
Qed.
intros a H; split; simpl in |- *; auto.
red in |- *; simpl in |- *; apply Relation_Operators_compat.d_one.
Qed.
Hint Resolve canonicalp1 canonical0.
Inductive eqP : list (Term A n) -> list (Term A n) -> Prop :=
| eqP0 : eqP (pO A n) (pO A n)
| eqpP1 :
forall ma mb p q,
eqTerm (A:=A) eqA (n:=n) ma mb -> eqP p q -> eqP (pX ma p) (pX mb q).
Hint Resolve eqP0 eqpP1.
red in |- *.
intros x; elim x; auto.
intros a l H; change (eqP (pX a l) (pX a l)) in |- *; apply eqpP1; auto.
Qed.
red in |- *.
intros x y H'; elim H'; auto.
intros ma mb p q H H0 H1.
apply eqpP1; auto.
apply (eqTerm_sym _ _ _ _ _ _ _ _ _ cs n); auto.
Qed.
unfold pO in |- *; intros p H'; inversion H'; auto.
Qed.
unfold pO in |- *; intros p H'; inversion H'; auto.
Qed.
intros a b p q H'; simple inversion H'; auto.
unfold pO in H0; inversion H0.
rewrite (pX_invl ma a p0 p); auto; rewrite (pX_invl mb b q0 q); auto.
Qed.

Theorem eqp_inv3r : forall a b p q, eqP (pX a p) (pX b q) -> eqP p q.