Definition conjC {C : numClosedFieldType} : {rmorphism C -> C} :=
ClosedField.conj_op (ClosedField.conj_mixin (ClosedField.class C)).
Notation "z ^*" := (@conjC _ z) (at level 2, format "z ^*") : ring_scope.
Definition imaginaryC {C : numClosedFieldType} : C :=
ClosedField.imaginary (ClosedField.conj_mixin (ClosedField.class C)).
Notation "'i" := (@imaginaryC _) (at level 0) : ring_scope.
Section ClosedFieldTheory.
Variable C : numClosedFieldType.
Implicit Types a x y z : C.
Definition normCK x : `|x| ^+ 2 = x * x^*.
Let Re2 z := z + z^*.
Definition nnegIm z := (0 <= imaginaryC * (z^* - z)).
Definition argCle y z := nnegIm z ==> nnegIm y && (Re2 z <= Re2 y).
Variant rootC_spec n (x : C) : Type :=
RootCspec (y : C) of if (n > 0)%N then y ^+ n = x else y = 0
& forall z, (n > 0)%N -> z ^+ n = x -> argCle y z.
Fact rootC_subproof n x : rootC_spec n x.
Definition nthroot n x := let: RootCspec y _ _ := rootC_subproof n x in y.
Notation "n .-root" := (nthroot n) (at level 2, format "n .-root") : ring_core_scope.
Notation "n .-root" := (nthroot n) (only parsing) : ring_scope.
Notation sqrtC := 2.-root.
Definition Re x := (x + x^*) / 2%:R.
Definition Im x := 'i * (x^* - x) / 2%:R.
Notation "'Re z" := (Re z) (at level 10, z at level 8) : ring_scope.
Notation "'Im z" := (Im z) (at level 10, z at level 8) : ring_scope.
Let nz2 : 2%:R != 0 :> C. Proof. by rewrite pnatr_eq0. Qed.

(* Specifications: *)
Lemma normCKC x : `|x| ^+ 2 = x^* * x. Proof. by rewrite normCK mulrC. Qed.
Lemma mul_conjC_ge0 x : 0 <= x * x^*.
Lemma mul_conjC_eq0 x : (x * x^* == 0) = (x == 0).
Lemma conjC_nat n : (n%:R)^* = n%:R :> C. Proof. exact: rmorph_nat. Qed.
Lemma conjC0 : 0^* = 0 :> C. Proof. exact: rmorph0. Qed.
Lemma conjC1 : 1^* = 1 :> C. Proof. exact: rmorph1. Qed.
Lemma conjC_eq0 x : (x^* == 0) = (x == 0). Proof. exact: fmorph_eq0. Qed.
Lemma invC_norm x : x^-1 = `|x| ^- 2 * x^*.
(* Real number subset. *)
Lemma CrealE x : (x \is real) = (x^* == x).
Lemma CrealP {x} : reflect (x^* = x) (x \is real).
Lemma rootC_inj n : (n > 0)%N -> injective n.-root.
Lemma invCi : 'i^-1 = - 'i :> C.
Lemma Creal_Re x : 'Re x \is real.
Hint Resolve Creal_Re Creal_Im : core.