Lemma matrix_mult_rdistr {m n p} (mat1 : Matrix R m n) (mat2 : Matrix R m n) (mat3 : Matrix R n p) : (mat1 ++' mat2) ** mat3 = (mat1 ** mat3) ++' (mat2 ** mat3). Proof. intros. rewrite matrix_mult_eq. unfold matrix_mult_unf, matrix_add. unfold entrywise, pointwise. apply funextfun. intros i. apply funextfun. intros j. etrans. { apply maponpaths, funextfun; intros k. rewrite rigrdistr. exact (idpath _). } apply vecsum_add. Defined.
Require Import UniMath.Foundations.All. Require Import UniMath.MoreFoundations.All. Require Import UniMath.Combinatorics.StandardFiniteSets. Require Import UniMath.Combinatorics.Vectors. Require Import UniMath.Algebra.RigsAndRings. Require Import UniMath.Algebra.IteratedBinaryOperations. Require Import UniMath.Algebra.Matrix. Require Import UniMath.Algebra.Domains_and_Fields. Require Import UniMath.Algebra.GaussianElimination.Auxiliary. Require Import UniMath.Algebra.GaussianElimination.Vectors.