Section MatrixAlgebra.
Variables F : fieldType.
Local Notation "A \in R" := (@submx F _ _ _ (mxvec A) R).
Arguments memmx_subP {m1 m2 n R1 R2}.
Arguments memmx_eqP {m1 m2 n R1 R2}.
Arguments memmx_addsP {m1 m2 n A R1 R2}.
Arguments memmx_sumsP {I P n A R_}.
Definition mulsmx m1 m2 n (R1 : 'A[F]_(m1, n)) (R2 : 'A_(m2, n)) :=
(\sum_i <<R1 *m lin_mx (mulmxr (vec_mx (row i R2)))>>)%MS.
Arguments mulsmx {m1%N m2%N n%N} R1%MS R2%MS.
Local Notation "R1 * R2" := (mulsmx R1 R2) : matrix_set_scope.
Arguments mulsmx_subP {m1 m2 m n R1 R2 R}.
Arguments mulsmxP {m1 m2 n A R1 R2}.
Definition left_mx_ideal m1 m2 n (R1 : 'A_(m1, n)) (R2 : 'A_(m2, n)) :=
(R1 * R2 <= R2)%MS.
Definition right_mx_ideal m1 m2 n (R1 : 'A_(m1, n)) (R2 : 'A_(m2, n)) :=
(R2 * R1 <= R2)%MS.
Definition mx_ideal m1 m2 n (R1 : 'A_(m1, n)) (R2 : 'A_(m2, n)) :=
left_mx_ideal R1 R2 && right_mx_ideal R1 R2.
Definition mxring_id m n (R : 'A_(m, n)) e :=
[/\ e != 0,
e \in R,
forall A, A \in R -> e *m A = A
& forall A, A \in R -> A *m e = A]%MS.
Definition has_mxring_id m n (R : 'A[F]_(m , n)) :=
(R != 0) &&
(row_mx 0 (row_mx (mxvec R) (mxvec R))
<= row_mx (cokermx R) (row_mx (lin_mx (mulmx R \o lin_mulmx))
(lin_mx (mulmx R \o lin_mulmxr))))%MS.
Definition mxring m n (R : 'A_(m, n)) :=
left_mx_ideal R R && has_mxring_id R.

Lemma mxring_idP m n (R : 'A_(m, n)) :
reflect (exists e, mxring_id R e) (has_mxring_id R).