Section Def.
Variable R : CFIELD.
Record Ctype : Type :=  {real :> R; imag : R}.
Definition Cadd (z z' : Ctype) : Ctype :=
Build_Ctype (sgroup_law R (real z) (real z'))
(sgroup_law R (imag z) (imag z')).
Definition Cmult (z z' : Ctype) : Ctype :=
Build_Ctype
(sgroup_law R (ring_mult (real z) (real z'))
(group_inverse R (ring_mult (imag z) (imag z'))))
(sgroup_law R (ring_mult (real z) (imag z'))
(ring_mult (imag z) (real z'))).
Definition Copp (z : Ctype) : Ctype :=
Build_Ctype (group_inverse R (real z)) (group_inverse R (imag z)).
Definition Cone : Ctype := Build_Ctype (ring_unit R) (monoid_unit R).
Definition Czero : Ctype := Build_Ctype (monoid_unit R) (monoid_unit R).
Definition Ceq (z z' : Ctype) :=
Equal (real z) (real z') /\ Equal (imag z) (imag z').
Definition Cset : Setoid.
apply (Build_Setoid (Carrier:=Ctype) (Equal:=Ceq)).
red in |- *.
split; [ red in |- * | red in |- * ].
intros x; red in |- *; red in |- *; auto with algebra.
split; [ red in |- * | red in |- * ].
unfold app_rel, Ceq in |- *.
intros x y z H' H'0; split; [ try assumption | idtac ].
apply Trans with (real y); intuition.
apply Trans with (imag y); intuition.
unfold app_rel, Ceq in |- *.
intuition.
Defined.
Require Export Ring_util.
intros x x' y y' H' H'0; try assumption.
simpl in |- *.
red in |- *; auto with algebra.
Qed.
Hint Resolve Build_Ctype_comp: algebra.

Lemma real_comp : forall x x' : Cset, Equal x x' -> Equal (real x) (real x').