End ChangeOfField.
(* Construction of a splitting field FA of an irreducible representation, for *)
(* a matrix A in the centraliser of the representation. FA is the row-vector  *)
(* space of the matrix algebra generated by A with basis 1, A, ..., A ^+ d.-1 *)
(* or, equivalently, the polynomials in {poly F} taken mod the (irreducible)  *)
(* minimal polynomial pA of A (of degree d).                                  *)
(* The details of the construction of FA are encapsulated in a submodule.     *)
Module Import MatrixGenField.
(* The type definition must come before the main section so that the Bind     *)
(* Scope directive applies to all lemmas and definition discharged at the     *)
(* of the section.                                                            *)
Record gen_of {F : fieldType} {gT : finGroupType} {G : {group gT}} {n' : nat}
{rG : mx_representation F G n'.+1} {A : 'M[F]_n'.+1}
(irrG : mx_irreducible rG) (cGA : centgmx rG A) :=
Gen {rVval : 'rV[F]_(degree_mxminpoly A)}.
Local Arguments rVval {F gT G%G n'%N rG A%R irrG cGA} x%R : rename.
Bind Scope ring_scope with gen_of.
Section GenField.
Variables (F : fieldType) (gT : finGroupType) (G : {group gT}) (n' : nat).
Local Notation n := n'.+1.
Variables (rG : mx_representation F G n) (A : 'M[F]_n).
Local Notation d := (degree_mxminpoly A).
Local Notation Ad := (powers_mx A d).
Local Notation pA := (mxminpoly A).
Let d_gt0 := mxminpoly_nonconstant A.
Local Notation irr := mx_irreducible.
Hypotheses (irrG : irr rG) (cGA : centgmx rG A).
Notation FA := (gen_of irrG cGA).
Let inFA := Gen irrG cGA.
Canonical gen_subType := Eval hnf in [newType for rVval : FA -> 'rV_d].
Definition gen_eqMixin := Eval hnf in [eqMixin of FA by <:].
Canonical gen_eqType := Eval hnf in EqType FA gen_eqMixin.
Definition gen_choiceMixin := [choiceMixin of FA by <:].
Canonical gen_choiceType := Eval hnf in ChoiceType FA gen_choiceMixin.
Definition gen0 := inFA 0.
Definition genN (x : FA) := inFA (- val x).
Definition genD (x y : FA) := inFA (val x + val y).

Lemma gen_ntriv : gen1 != 0.