Definition switch_row_involution {m n : nat} (r1 r2 : ⟦ m ⟧%stn) (mat : Matrix R m n) : switch_row r1 r2 (switch_row r1 r2 mat) = mat. Proof. apply funextfun; intros i; apply funextfun; intros j. destruct (stn_eq_or_neq i r1) as [ e_i_r1 | ne_i_r1 ]; [ | destruct (stn_eq_or_neq i r2) as [ e_i_r2 | ne_i_r2 ]]. - destruct e_i_r1. etrans. { apply switch_row_former_row. } apply switch_row_latter_row. - destruct e_i_r2. etrans. { apply switch_row_latter_row. } apply switch_row_former_row. - etrans; apply switch_row_other_row; assumption. 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.