Lemma back_sub_inv0 { n : nat } (mat : Matrix F n n) (b : Vector F n) (ut : @is_upper_triangular F _ _ mat) (df : @diagonal_all_nonzero F _ mat) : back_sub_stmt mat b ut df. Proof. exists (back_sub mat b). intros; unfold back_sub. destruct (natchoice0 n) as [eq0 | ?]. { apply funextfun. intros i. apply fromstn0. now rewrite eq0. } apply funextfun; intros i. apply back_sub_internal_inv2; try assumption; unfold dualelement; try easy. 2: {exact (pr2 i). } destruct (natchoice0 _) as [eq0 | ?]. { apply fromempty; now apply negpaths0sx in eq0. } simpl; now rewrite natminuseqn, minuseq0'. 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.