Prenex Implicits unitmx invmx invmxK.
Canonical matrix_countUnitRingType (R : countComUnitRingType) n :=
[countUnitRingType of 'M[R]_n.+1].
(* Finite inversible matrices and the general linear group. *)
Section FinUnitMatrix.
Variables (n : nat) (R : finComUnitRingType).
Canonical matrix_finUnitRingType n' :=
Eval hnf in [finUnitRingType of 'M[R]_n'.+1].
Definition GLtype of phant R := {unit 'M[R]_n.-1.+1}.
Coercion GLval ph (u : GLtype ph) : 'M[R]_n.-1.+1 :=
let: FinRing.Unit A _ := u in A.
End FinUnitMatrix.
Bind Scope group_scope with GLtype.
Arguments GLval {n%N R ph} u%g.
Notation "{ ''GL_' n [ R ] }" := (GLtype n (Phant R))
(at level 0, n at level 2, format "{ ''GL_' n [ R ] }") : type_scope.
Notation "{ ''GL_' n ( p ) }" := {'GL_n['F_p]}
(at level 0, n at level 2, p at level 10,
format "{ ''GL_' n ( p ) }") : type_scope.
Section GL_unit.
Variables (n : nat) (R : finComUnitRingType).
Canonical GL_subType := [subType of {'GL_n[R]} for GLval].
Definition GL_eqMixin := Eval hnf in [eqMixin of {'GL_n[R]} by <:].
Canonical GL_eqType := Eval hnf in EqType {'GL_n[R]} GL_eqMixin.
Canonical GL_choiceType := Eval hnf in [choiceType of {'GL_n[R]}].
Canonical GL_countType := Eval hnf in [countType of {'GL_n[R]}].
Canonical GL_subCountType := Eval hnf in [subCountType of {'GL_n[R]}].
Canonical GL_finType := Eval hnf in [finType of {'GL_n[R]}].
Canonical GL_subFinType := Eval hnf in [subFinType of {'GL_n[R]}].
Canonical GL_baseFinGroupType := Eval hnf in [baseFinGroupType of {'GL_n[R]}].
Canonical GL_finGroupType := Eval hnf in [finGroupType of {'GL_n[R]}].
Definition GLgroup of phant R := [set: {'GL_n[R]}].
Canonical GLgroup_group ph := Eval hnf in [group of GLgroup ph].
Implicit Types u v : {'GL_n[R]}.

Lemma GL_unit u : GLval u \is a GRing.unit. Proof. exact: valP. Qed.