Section Term.
Load "hCoefStructure".
Load "mCoefStructure".
Load "hOrderStructure".
Load "mOrderStructure".
Definition M1 := zero_mon n.
Definition Term := (A * mon n)%type.
Set Implicit Arguments.
Unset Strict Implicit.
Definition zeroP : Term -> Prop.
intros H'; case H'.
intros a H'1; exact (eqA a A0).
Defined.
Definition eqTerm : Term -> Term -> Prop.
intros H'; case H'.
intros a a' H'2; case H'2.
intros b b'; exact (eqA a b /\ a' = b').
Defined.
Set Strict Implicit.
Unset Implicit Arguments.
red in |- *.
intros x; case x; simpl in |- *; auto.
Qed.
red in |- *.
intros x y; case x; case y; simpl in |- *; intuition.
apply (eqA_sym _ _ _ _ _ _ _ _ _ cs); auto.
Qed.
red in |- *.
intros x y z; case x; case y; case z; simpl in |- *; intuition.
apply (eqA_trans _ _ _ _ _ _ _ _ _ cs) with (y := a0); auto.
rewrite H2; auto.
Qed.
Set Implicit Arguments.
Unset Strict Implicit.
Definition T2M : Term -> mon n.
intros t; case t; intros a m; exact m.
Defined.
Set Strict Implicit.
Unset Implicit Arguments.
Set Implicit Arguments.
Unset Strict Implicit.
Definition eqT (a b : Term) : Prop := T2M a = T2M b.
Hint Unfold eqT.
Set Strict Implicit.
Unset Implicit Arguments.
red in |- *; auto.
Qed.
red in |- *; auto.
Qed.
red in |- *; unfold eqT in |- *.
intros x y z H' H'0; rewrite H'; auto.
Qed.
intros a b; case a; case b; simpl in |- *; intuition.
Qed.
intros x y; case x; case y; simpl in |- *.
intros b2 c2 b3 c3.
case (eqA_dec b3 b2); intros eqAZ; auto.
case (eqmon_dec n c3 c2); intros eqAZ1; auto.
right; red in |- *; intros H'; elim H'; intros H'0 H'1; clear H'; auto.
right; red in |- *; intros H'; elim H'; intros H'0 H'1; clear H'; auto.
Qed.
intros a b; case a; case b; simpl in |- *; auto.
intuition.
apply (eqA_trans _ _ _ _ _ _ _ _ _ cs) with (y := A0); auto.
apply (eqA_sym _ _ _ _ _ _ _ _ _ cs); auto.
Qed.
intros x; case x; simpl in |- *.
intros b H'.
apply eqA_dec; auto.
Qed.
intros a b; case a; case b; simpl in |- *; auto.
intuition.
apply (eqA_trans _ _ _ _ _ _ _ _ _ cs) with (y := a1); auto;
apply (eqA_sym _ _ _ _ _ _ _ _ _ cs); auto.
Qed.
intros a b H' H'0; red in |- *; intros H'1.
apply H'.
apply zeroP_comp_eqTerm with (a := b); auto.
apply eqTerm_sym; auto.
Qed.
Set Implicit Arguments.
Unset Strict Implicit.
Definition plusTerm : Term -> Term -> Term.
intros x; case x; intros b2 c2; intros y; case y; intros b3 c3;
exact (plusA b2 b3, c2).
Defined.
Set Strict Implicit.
Unset Implicit Arguments.
intros a b; case a; case b; simpl in |- *; auto.
intros a1 m1 a2 m2 H1 H2; split; auto.
apply (eqA_trans _ _ _ _ _ _ _ _ _ cs) with (y := plusA a2 A0); auto.
apply (eqA_sym _ _ _ _ _ _ _ _ _ cs); auto.
Qed.
intros a b; case a; case b; simpl in |- *; auto.
intros a1 m1 a2 m2 H1 H2; split; auto.
apply (eqA_trans _ _ _ _ _ _ _ _ _ cs) with (y := plusA A0 a1); auto.
apply (eqA_trans _ _ _ _ _ _ _ _ _ cs) with (y := plusA a1 A0); auto.
apply (eqA_sym _ _ _ _ _ _ _ _ _ cs); auto.
Qed.
intros a b c; case a; case b; case c; simpl in |- *; auto.
intuition.
Qed.
intros a b c; case a; case b; case c; simpl in |- *; auto.
intuition.
Qed.
intros a b; case a; case b; simpl in |- *; auto.
Qed.
intros a b; case a; case b; simpl in |- *; auto.
Qed.
intros a b; case a; case b; simpl in |- *; auto.
Qed.
intros a b c; case a; case b; case c; simpl in |- *; auto.
intuition.
apply (eqA_sym _ _ _ _ _ _ _ _ _ cs).
apply plusA_assoc with (1 := cs).
Qed.
intros a b c d; case a; case b; case c; case d; simpl in |- *; auto.
intuition.
Qed.
Hint Resolve eqTerm_plusTerm_comp.
Set Implicit Arguments.
Unset Strict Implicit.
Definition multTerm : Term -> Term -> Term.
intros H'; case H'; intros b2 c2 H1'; case H1'; intros b3 c3;
exact (multA b2 b3, mult_mon n c2 c3).
Defined.
Set Strict Implicit.
Unset Implicit Arguments.
intros a b; case a; case b; simpl in |- *; auto.
intros a1 H' b2 H'0 H'1;
apply (eqA_trans _ _ _ _ _ _ _ _ _ cs) with (y := multA A0 a1);
auto.
Qed.
intros a b; case a; case b; simpl in |- *; auto.
intros a1 H' b2 H'0 H'1;
apply (eqA_trans _ _ _ _ _ _ _ _ _ cs) with (y := multA a1 A0);
auto.
apply (eqA_trans _ _ _ _ _ _ _ _ _ cs) with (y := multA A0 a1); auto.
Qed.
intros a b c; case a; case b; case c; simpl in |- *; auto.
intros a1 m1 a2 m2 a3 m3; split; auto.
apply
(eqA_trans _ _ _ _ _ _ _ _ _ cs) with (plusA (multA a1 a3) (multA a1 a2));
auto.
apply (eqA_trans _ _ _ _ _ _ _ _ _ cs) with (multA a1 (plusA a3 a2)); auto.
Qed.
intros a b c; case a; case b; case c; simpl in |- *; auto.
Qed.
intros a b c d; case a; case b; case c; case d; unfold eqT in |- *;
simpl in |- *; auto.
intros H' c0 H'0 c2 H'1 c3 H'2 c4 H'3 H'4; rewrite H'3; rewrite H'4; auto.
Qed.
intros a b c; case a; case b; case c; simpl in |- *; auto.
intros a0 m a1 m0 a2 m1; split; auto.
apply multA_assoc with (1 := cs); auto.
apply mult_mon_assoc.
Qed.
intros a b; case a; case b; simpl in |- *; auto.
intros a0 m a1 m0; split; auto.
apply mult_mon_com.
Qed.
intros a b c d; case a; case b; case c; case d; simpl in |- *; auto.
intros a1 m1 a2 m2 a3 m3 a4 m4; intros H1; case H1; intros H2 H3 H4; case H4;
intros H5 H6; split; auto.
rewrite H3; rewrite H6; auto.
Qed.
Hint Resolve eqTerm_multTerm_comp.
Set Implicit Arguments.
Unset Strict Implicit.
Definition invTerm : Term -> Term.
intros H; case H; intros b2 c2; exact (invA b2, c2).
Defined.
Set Strict Implicit.
Unset Implicit Arguments.
intros a; case a; simpl in |- *; auto.
intros; apply (eqA_sym _ _ _ _ _ _ _ _ _ cs); apply invA_plusA with (1 := cs);
auto.
Qed.

Theorem zeroP_invTerm_zeroP : forall a : Term, zeroP a -> zeroP (invTerm a).