Lemma add_row_mult_matrix_sum { n : nat } ( r1 r2 : ⟦ n ⟧%stn ) (ne : r1 ≠ r2) ( s1 s2 : R ) : ((add_row_mult_matrix r1 r2 s1 ) **' (add_row_mult_matrix r1 r2 s2)) = (add_row_mult_matrix r1 r2 (s1 + s2)%ring). Proof. rewrite add_row_mult_as_matrix; try assumption. apply funextfun; intros i; apply funextfun; intros j. unfold add_row_mult, add_row_mult_matrix. destruct (stn_eq_or_neq i r2) as [i_eq_r2 | i_neq_r2]. 2: {apply idpath. } destruct i_eq_r2. rewrite stn_eq_or_neq_refl, (stn_eq_or_neq_right ne); simpl. unfold scalar_lmult_vec, pointwise, vector_fmap. rewrite (@rigrdistr R), rigcomm1, (@rigassoc1 R). reflexivity. 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.Matrix. Require Import UniMath.Algebra.RigsAndRings. Require Import UniMath.Algebra.IteratedBinaryOperations. Require Import UniMath.Algebra.Domains_and_Fields. Require Import UniMath.Algebra.GaussianElimination.Auxiliary. Require Import UniMath.Algebra.GaussianElimination.Vectors. Require Import UniMath.Algebra.GaussianElimination.Matrices.