(**

There follows the boilerplate to use the proof GI_subring in order to
canonically provide a subring structure to the predicate gaussInteger.

*)
Fact GI_key : pred_key gaussInteger.Canonical GI_keyed := KeyedQualifier GI_key.Canonical GI_opprPred := OpprPred GI_subring.Canonical GI_addrPred := AddrPred GI_subring.Canonical GI_mulrPred := MulrPred GI_subring.Canonical GI_zmodPred := ZmodPred GI_subring.Canonical GI_semiringPred := SemiringPred GI_subring.Canonical GI_smulrPred := SmulrPred GI_subring.Canonical GI_subringPred := SubringPred GI_subring.Canonical ReGI x := GIof (Cint_GI (GIRe x)).Canonical ImGI x := GIof (Cint_GI (GIIm x)).Canonical eqGIType := EqType GI eqGIMixin.Canonical GI_choiceType := ChoiceType GI GI_choiceMixin.Canonical GI_countType := CountType GI GI_countMixin.Canonical GI_zmodType := ZmodType GI GI_zmodMixin.Canonical GI_ringType := RingType GI GI_ringMixin.Canonical GI_comRingType := ComRingType GI GI_comRingMixin.(* Definition GI_unitRingMixin := [unitRingMixin of GI by <:]. *)
(* Canonical GI_unitRingType := UnitRingType GI GI_unitRingMixin. *)
(**

 - Now we build the unitRing and comUnitRing structure of gauss
   integers. Contrarily to the previous structures, the operator is
   not the same as on algebraics. Indeed the invertible algebraics are
   not necessarily invertible gauss integers.

 - Hence, we define the inverse of gauss integers as follow : if the
   algebraic inverse happens to be a gauss integer we recover the
   proof and package it together with the element and get a gauss
   integer, otherwise, we default to the identity.

 - A gauss integer is invertible if the algbraic inverse is a gauss
   integer.

*)
Definition invGI (x : GI) := insubd x (val x)^-1.Fact unitGIP (x y : GI) : y * x = 1 -> unitGI x.Definition GI_comUnitRingMixin :=
  ComUnitRingMixin mulGIr unitGIP unitGI_out.Canonical GI_unitRingType := UnitRingType GI GI_comUnitRingMixin.Canonical conjGI x := GIof (conjGI_subproof x).Canonical conjGI_additive := Additive conjGI_sub.Fact conjGI_multiplicative : multiplicative conjGI.Canonical conjGI_rmorphism := AddRMorphism conjGI_multiplicative.

Lemma conjGIK : involutive conjGI.