Definition gauss_clear_row { m n : nat } (mat : Matrix F m n) (row : (⟦ m ⟧%stn)) : Matrix F m n. Proof. destruct (natchoice0 n) as [contr_eq | p]. { unfold Matrix, Vector; intros; apply fromstn0. now rewrite contr_eq. } destruct (select_uncleared_column _ mat row p) as [[piv_col [? [piv_row ?]]] | none]. 2: {exact mat. } refine (gauss_clear_column _ row piv_col (m,, natlthnsn _)). exact (@switch_row F _ _ row piv_row mat). Defined.
Require Import UniMath.Foundations.PartA. Require Import UniMath.Foundations.NaturalNumbers. Require Import UniMath.MoreFoundations.PartA. Require Import UniMath.MoreFoundations.Nat. Require Import UniMath.MoreFoundations.Tactics. Require Import UniMath.Combinatorics.StandardFiniteSets. Require Import UniMath.Combinatorics.FiniteSequences. Require Import UniMath.Combinatorics.Vectors. Require Import UniMath.Combinatorics.Maybe. Require Import UniMath.Algebra.BinaryOperations. Require Import UniMath.Algebra.IteratedBinaryOperations. Require Import UniMath.Algebra.RigsAndRings. Require Import UniMath.Algebra.Matrix. 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. Require Import UniMath.Algebra.GaussianElimination.RowOps.