Lemma back_sub_internal_inv0 { n : nat } (mat : Matrix F n n) (x : Vector F n) (b : Vector F n) (ut : @is_upper_triangular F _ _ mat) (sep : ⟦ S n ⟧%stn) (row : ⟦ S n ⟧%stn) : ∏ (i : ⟦ n ⟧%stn), i >= row -> (col_vec (back_sub_internal mat x b sep row)) i = (col_vec x) i. Proof. destruct sep as [sep p]. induction sep as [| sep IH]. { intros i H; now destruct (natchoice0 (S n)) in H. } unfold back_sub_internal. intros i i_lt_row. rewrite nat_rect_step. destruct (natlthorgeh _ _) as [lt | geh]. 2: {reflexivity. } assert (p': sep < S n). { apply (istransnatlth _ _ _ (natgthsnn sep) p). } rewrite <- (IH p'); try assumption. unfold back_sub_internal. rewrite back_sub_step_inv1; try easy. {apply maponpaths_2, maponpaths, proofirrelevance, propproperty. } apply natgthtoneq. refine (natlthlehtrans _ _ _ lt i_lt_row). Defined.
Require Import UniMath.MoreFoundations.PartA. Require Import UniMath.MoreFoundations.Nat. Require Import UniMath.MoreFoundations.Tactics. Require Import UniMath.Algebra.Matrix. Require Import UniMath.Algebra.Domains_and_Fields. Require Import UniMath.Algebra.Matrix. Require Import UniMath.Algebra.RigsAndRings. Require Import UniMath.Algebra.IteratedBinaryOperations. Require Import UniMath.Algebra.GaussianElimination.Auxiliary. Require Import UniMath.Algebra.GaussianElimination.Vectors. Require Import UniMath.Algebra.GaussianElimination.Matrices. Require Import UniMath.Algebra.GaussianElimination.Elimination.