MATRIX13

index · ← VECTSP10 · MATRIX15 →
:: Basic Properties of the Rank of Matrices over a Field
::  by Karol P\c{a}k
::
:: Received August 28, 2007
:: Copyright (c) 2007-2026 Association of Mizar Users
::           (Stowarzyszenie Uzytkownikow Mizara, Bialystok, Poland).
:: This code can be distributed under the GNU General Public Licence
:: version 3.0 or later, or the Creative Commons Attribution-ShareAlike
:: License version 3.0 or later, subject to the binding interpretation
:: detailed in file COPYING.interpretation.
:: See COPYING.GPL and COPYING.CC-BY-SA for the full text of these
:: licenses, or see http://www.gnu.org/licenses/gpl.html and
:: http://creativecommons.org/licenses/by-sa/3.0/.

environ

 vocabularies NUMBERS, XBOOLE_0, NAT_1, XCMPLX_0, VECTSP_1, SUBSET_1, FINSEQ_1,
      MATRIX_1, CARD_1, TREES_1, XXREAL_0, QC_LANG1, RELAT_1, SUPINF_2,
      ARYTM_3, MATRIX_3, FUNCT_1, ZFMISC_1, FINSEQ_2, FUNCT_2, ARYTM_1,
      FINSET_1, TARSKI, SGRAPH1, CARD_3, ALGSTR_0, SETWISEO, ABIAN, FINSUB_1,
      BINOP_1, FINSOP_1, CARD_FIN, FUNCOP_1, FUNCT_4, MATRIX11, FINSEQ_5,
      INT_1, GROUP_1, ABSVALUE, RVSUM_1, STRUCT_0, INCSP_1, FVSUM_1, FREEALG,
      FINSEQ_3, LAPLACE, CLASSES1, AFINSQ_1, PRVECT_1, RLVECT_2, LMOD_7,
      VALUED_1, PARTFUN1, RLVECT_3, RLSUB_1, MESFUNC1, RLVECT_5, MATRIX13,
      RLVECT_1, FUNCT_7, NUMBER09;
 notations TARSKI, XBOOLE_0, ZFMISC_1, SUBSET_1, CARD_1, ORDINAL1, NUMBERS,
      XCMPLX_0, XXREAL_0, NAT_D, FINSET_1, RELAT_1, RELSET_1, FUNCT_1,
      PARTFUN1, FUNCT_2, NAT_1, SETWOP_2, FINSEQ_1, BINOP_1, STRUCT_0,
      ALGSTR_0, FUNCOP_1, RLVECT_1, GROUP_1, VECTSP_1, SETWISEO, FINSEQ_2,
      MATRIX_0, FINSUB_1, MATRIX_1, FVSUM_1, FINSOP_1, GROUP_4, MATRIX_3,
      FINSEQ_7, FUNCT_4, SGRAPH1, NEWTON, FINSEQ_5, DOMAIN_1, MATRIX_6,
      MATRIX_7, MATRIX11, CARD_FIN, FINSEQ_3, LAPLACE, MEASURE6, PRVECT_1,
      VECTSP_4, VECTSP_6, VECTSP_7, MATRLIN, VECTSP_9;
 constructors SETWISEO, FINSOP_1, ALGSTR_1, FVSUM_1, DOMAIN_1, FINSEQ_5,
      GROUP_4, FINSEQ_7, WELLORD2, NEWTON, CARD_FIN, MATRIX_6, MATRIX_7,
      MATRIX11, LAPLACE, PRVECT_1, VECTSP_6, VECTSP_7, VECTSP_9, BINOP_2,
      RELSET_1, VECTSP_2, MATRIX_3;
 registrations SUBSET_1, FUNCT_1, FINSET_1, STRUCT_0, FVSUM_1, VECTSP_1,
      FUNCT_2, ORDINAL1, XXREAL_0, NAT_1, FINSEQ_1, RELAT_1, CARD_1, SGRAPH1,
      MATRIX_0, FUNCOP_1, MATRIX11, SETFAM_1, FINSEQ_2, PRVECT_1, XREAL_0,
      XBOOLE_0, VALUED_0, VECTSP_7, RELSET_1, MATRIX_1, MATRIX_6, VECTSP_2,
      MATRIX_3;
 requirements ARITHM, NUMERALS, REAL, BOOLE, SUBSET;
 definitions TARSKI, MATRIX_7, MEASURE6, VECTSP_7, FUNCT_1, ALGSTR_0, FINSEQ_1;
 equalities FINSEQ_2, FINSEQ_1, MATRIX_0, FVSUM_1, GROUP_4, MATRIX_3, MATRIX11,
      LAPLACE, VECTSP_1, RELAT_1, STRUCT_0, ALGSTR_0, FUNCOP_1;
 expansions FINSEQ_1, TARSKI, MEASURE6, VECTSP_7, FUNCT_1, STRUCT_0;
 theorems NAT_D, CARD_1, CARD_2, CARD_FIN, COMPUT_1, ENUMSET1, FINSEQ_1,
      FINSEQ_2, FINSEQ_3, FINSEQ_4, FINSEQ_5, FINSOP_1, FINSUB_1, FRECHET,
      FUNCT_1, FUNCT_2, FUNCT_4, FUNCT_7, FUNCOP_1, FVSUM_1, GRAPH_2, GROUP_1,
      LAPLACE, MATRIX_0, MATRIX_3, MATRIX_7, MATRIX_9, MATRIX11, MATRIXR1,
      NAT_1, ORDINAL1, PRVECT_1, RELAT_1, RLVECT_1, SETWISEO, SETWOP_2,
      SGRAPH1, STIRL2_1, TARSKI, VECTSP_1, VECTSP_2, VECTSP_4, VECTSP_6,
      VECTSP_7, VECTSP_9, VECTSP10, WELLORD2, XBOOLE_0, XBOOLE_1, XREAL_1,
      ZFMISC_1, XXREAL_0, FINSEQOP, MATRIXR2, PARTFUN1, MATRLIN, XREAL_0,
      MEASURE6, MATRIX_1, SUBSET_1, FINSEQ_6;
 schemes FINSEQ_1, FINSEQ_2, FUNCT_1, FUNCT_2, NAT_1, PRE_POLY, MATRIX_0;

begin :: Triangular Matrices

reserve x,y for object,X,Y for set,
  D for non empty set,
  i,j,k,l,m,n,m9,n9 for Nat,
  i0,j0,n0,m0 for non zero Nat,
  K for Field,
  a,b for Element of K,
  p for FinSequence of K,
  M for Matrix of n,K;

theorem Th1:
  for A be Matrix of n,m,D holds (n=0 implies m=0) iff len A = n & width A = m
proof
  let A be Matrix of n,m,D;
  thus (n=0 implies m=0) implies len A = n & width A = m
  proof
    assume
A1: n=0 implies m=0;
    per cases;
    suppose
A2:   n=0;
      then len A=0 by MATRIX_0:def 2;
      hence thesis by A1,A2,MATRIX_0:def 3;
    end;
    suppose
A3:   n>0;
      len A=n by MATRIX_0:def 2;
      hence thesis by A3,MATRIX_0:20;
    end;
  end;
  thus thesis by MATRIX_0:def 3;
end;

theorem Th2:
  M is lower_triangular Matrix of n,K iff M@ is upper_triangular Matrix of n,K
proof
  thus M is lower_triangular Matrix of n,K implies M@ is
  upper_triangular Matrix of n,K
  proof
    assume
A1: M is lower_triangular Matrix of n,K;
    now
      let i,j such that
A2:   [i,j] in Indices M@ and
A3:   i>j;
A4:   [j,i] in Indices M by A2,MATRIX_0:def 6;
      then M*(j,i)=0.K by A1,A3,MATRIX_1:def 13;
      hence M@*(i,j) = 0.K by A4,MATRIX_0:def 6;
    end;
    hence thesis by MATRIX_1:def 12;
  end;
  assume
A5: M@ is upper_triangular Matrix of n,K;
  now
    let i,j such that
A6: [i,j] in Indices M and
A7: i<j;
    [j,i] in Indices M@ by A6,MATRIX_0:def 6;
    then M@*(j,i)=0.K by A5,A7,MATRIX_1:def 12;
    hence M*(i,j) = 0.K by A6,MATRIX_0:def 6;
  end;
  hence thesis by MATRIX_1:def 13;
end;

theorem Th3:
  diagonal_of_Matrix M = diagonal_of_Matrix M@
proof
  set DM=diagonal_of_Matrix M;
  set DM9=diagonal_of_Matrix M@;
A1: len DM=n by MATRIX_3:def 10;
A2: now
    let i such that
A3: 1<= i and
A4: i <= len DM;
A5: i in Seg n by A1,A3,A4;
    then
A6: DM9.i=M@*(i,i) by MATRIX_3:def 10;
    Indices M=[:Seg n,Seg n:] by MATRIX_0:24;
    then
A7: [i,i] in Indices M by A5,ZFMISC_1:87;
    DM.i=M*(i,i) by A5,MATRIX_3:def 10;
    hence DM.i=DM9.i by A7,A6,MATRIX_0:def 6;
  end;
  len DM9=n by MATRIX_3:def 10;
  hence thesis by A1,A2;
end;

theorem Th4:
  for perm being Element of Permutations n st perm <> idseq n holds
  (ex i st i in Seg n & perm.i > i) & ex j st j in Seg n & perm.j < j
proof
  let p be Element of Permutations n such that
A1: p <> idseq n;
  reconsider p9=p as Permutation of Seg n by MATRIX_1:def 16;
  dom p9=Seg n by FUNCT_2:52;
  then consider x be object such that
A2: x in Seg n and
A3: p.x<>x by A1,FUNCT_1:17;
  consider i be Nat such that
A4: i=x and
A5: 1<=i and
A6: i<=n by A2;
  now
    per cases by A3,A4,XXREAL_0:1;
    suppose
      p.i>i;
      hence ex j st j in Seg n & p.j > j by A2,A4;
    end;
    suppose
A7:   p.i<i;
      then reconsider i1=i-1 as Nat by NAT_1:20;
      thus ex j st j in Seg n & p.j > j
      proof
        reconsider pS=p9.:Seg i as finite set;
A8:     dom p9=Seg n by FUNCT_2:52;
        Seg i c= Seg n by A6,FINSEQ_1:5;
        then (Seg i),pS are_equipotent by A8,CARD_1:33;
        then
A9:     card Seg i=card pS by CARD_1:5;
        assume
A10:    for j st j in Seg n holds p.j<=j;
        p.:Seg i c= Seg i1
        proof
          let x be object;
          assume x in p.:Seg i;
          then consider y be object such that
A11:      y in dom p9 and
A12:      y in Seg i and
A13:      p.y=x by FUNCT_1:def 6;
          consider j be Nat such that
A14:      j=y and
          1<=j and
A15:      j<=i by A12;
          per cases by A15,XXREAL_0:1;
          suppose
            j=i;
            then p.j<i1+1 by A7;
            then
A16:        p.j <= i1 by NAT_1:13;
A17:        rng p9=Seg n by FUNCT_2:def 3;
            p.j in rng p by A11,A14,FUNCT_1:def 3;
            then p.j>=1 by A17,FINSEQ_1:1;
            hence thesis by A13,A14,A16;
          end;
          suppose
A18:        j<i;
            p.j <=j by A10,A11,A14;
            then p.j < i1+1 by A18,XXREAL_0:2;
            then
A19:        p.j<= i1 by NAT_1:13;
A20:        rng p9=Seg n by FUNCT_2:def 3;
            p.j in rng p by A11,A14,FUNCT_1:def 3;
            then p.j>=1 by A20,FINSEQ_1:1;
            hence thesis by A13,A14,A19;
          end;
        end;
        then
A21:    card pS <= card Seg i1 by NAT_1:43;
        card Seg i=i by FINSEQ_1:57;
        then i1+1 <= i1 by A9,A21,FINSEQ_1:57;
        hence thesis by NAT_1:13;
      end;
    end;
  end;
  hence ex j st j in Seg n & p.j > j;
  per cases by A3,A4,XXREAL_0:1;
  suppose
    p.i<i;
    hence thesis by A2,A4;
  end;
  suppose
A22: p.i>i;
    thus ex j st j in Seg n & p.j < j
    proof
      set NI=nat_interval(i,n);
      reconsider pN=p9.:NI as finite set;
A23:  i in NI by A6,SGRAPH1:2;
      assume
A24:  for j st j in Seg n holds p.j>=j;
A25:  pN c= NI
      proof
        let x be object;
A26:    rng p9=Seg n by FUNCT_2:def 3;
        assume x in pN;
        then consider j be object such that
A27:    j in dom p9 and
A28:    j in NI and
A29:    p.j=x by FUNCT_1:def 6;
        reconsider j as Nat by A28;
        reconsider pj=p.j as Element of NAT by ORDINAL1:def 12;
A30:    j<=pj by A24,A27;
        i<=j by A28,SGRAPH1:2;
        then
A31:    i <=pj by A30,XXREAL_0:2;
        pj in rng p9 by A27,FUNCT_1:def 3;
        then pj<=n by A26,FINSEQ_1:1;
        hence thesis by A29,A31,SGRAPH1:1;
      end;
      dom p9=Seg n by FUNCT_2:52;
      then NI, pN are_equipotent by A5,CARD_1:33,SGRAPH1:4;
      then card NI=card pN by CARD_1:5;
      then NI=pN by A25,CARD_2:102;
      then consider j be object such that
A32:  j in dom p9 and
A33:  j in NI and
A34:  p.j=i by A23,FUNCT_1:def 6;
      reconsider j as Nat by A33;
A35:  i<=j by A33,SGRAPH1:2;
      j <= i by A24,A32,A34;
      hence thesis by A22,A34,A35,XXREAL_0:1;
    end;
  end;
end;

theorem Th5:
  for M be (Matrix of n,K),perm being Element of Permutations n st
  perm <> idseq n & ( M is lower_triangular Matrix of n,K or M is
  upper_triangular Matrix of n,K ) holds (Path_product(M)).perm = 0.K
proof
  let M be (Matrix of n,K),p be Element of Permutations n such that
A1: p <> idseq n and
A2: M is lower_triangular Matrix of n,K or M is upper_triangular Matrix of n,K;
  reconsider p9=p as Permutation of Seg n by MATRIX_1:def 16;
  set PP=Path_product(M);
  set PATH=Path_matrix(p,M);
  now
    per cases by A2;
    suppose
A3:   M is lower_triangular Matrix of n,K;
A4:   rng p9=Seg n by FUNCT_2:def 3;
A5:   Indices M=[:Seg n,Seg n :] by MATRIX_0:24;
      consider i such that
A6:   i in Seg n and
A7:   p.i>i by A1,Th4;
      reconsider Pi=p.i as Nat;
      dom p9=Seg n by FUNCT_2:52;
      then p9.i in Seg n by A6,A4,FUNCT_1:def 3;
      then [i,Pi] in [:Seg n,Seg n:] by A6,ZFMISC_1:87;
      then
A8:   M*(i,Pi)=0.K by A3,A7,A5,MATRIX_1:def 13;
      len PATH=n by MATRIX_3:def 7;
      then
A9:   dom PATH=Seg n by FINSEQ_1:def 3;
      then PATH.i=M*(i,Pi) by A6,MATRIX_3:def 7;
      hence ex i st i in dom PATH & PATH.i=0.K by A6,A9,A8;
    end;
    suppose
A10:  M is upper_triangular Matrix of n,K;
A11:  rng p9=Seg n by FUNCT_2:def 3;
A12:  Indices M=[:Seg n,Seg n :] by MATRIX_0:24;
      consider i such that
A13:  i in Seg n and
A14:  p.i<i by A1,Th4;
      reconsider Pi=p.i as Nat;
      dom p9=Seg n by FUNCT_2:52;
      then p9.i in Seg n by A13,A11,FUNCT_1:def 3;
      then [i,Pi] in [:Seg n,Seg n:] by A13,ZFMISC_1:87;
      then
A15:  M*(i,Pi)=0.K by A10,A14,A12,MATRIX_1:def 12;
      len PATH=n by MATRIX_3:def 7;
      then
A16:  dom PATH=Seg n by FINSEQ_1:def 3;
      then PATH.i=M*(i,Pi) by A13,MATRIX_3:def 7;
      hence ex i st i in dom PATH & PATH.i=0.K by A13,A16,A15;
    end;
  end;
  then Product PATH=0.K by FVSUM_1:82;
  then
A17: PP.p=-(0.K,p) by MATRIX_3:def 8;
  -(0.K,p)=0.K or -(0.K,p)=-0.K by MATRIX_1:def 20;
  hence thesis by A17,RLVECT_1:12;
end;

theorem Th6:
  for M be (Matrix of n,K), I be Element of Permutations n st I =
  idseq n holds diagonal_of_Matrix M = Path_matrix(I,M)
proof
  let M be (Matrix of n,K), I be Element of Permutations n such that
A1: I=idseq n;
  set P=Path_matrix(I,M);
  set D=diagonal_of_Matrix M;
A2: len P=n by MATRIX_3:def 7;
A3: now
    let i such that
A4: 1<=i and
A5: i<= n;
A6: i in Seg n by A4,A5;
    then
A7: I.i=i by A1,FINSEQ_2:49;
    i in dom P by A2,A6,FINSEQ_1:def 3;
    then P.i=M*(i,i) by A7,MATRIX_3:def 7;
    hence P.i=D.i by A6,MATRIX_3:def 10;
  end;
  len D=n by MATRIX_3:def 10;
  hence thesis by A2,A3;
end;

theorem Th7:
  for M be upper_triangular Matrix of n,K holds Det M = (the multF
  of K) $$ diagonal_of_Matrix M
proof
  let M be upper_triangular Matrix of n,K;
  set aa=the addF of K;
  set mm=the multF of K;
  set P=Permutations n;
  set F=In(P,Fin P);
  set PP=Path_product M;
  idseq n is Element of Group_of_Perm(n) by MATRIX_1:11;
  then reconsider I=idseq n as Element of P by MATRIX_1:def 17;
  len P=n by MATRIX_1:9;
  then
A1: I is even by MATRIX_1:16;
  reconsider II={I},PI=P\{I} as Element of Fin P by FINSUB_1:def 5;
   P in Fin P by FINSUB_1:def 5; then
A2: F=P by SUBSET_1:def 8;
  now
    per cases;
    suppose
      PI={};
      then P c= II by XBOOLE_1:37;
      hence aa $$ (F,PP)=aa $$ (II,PP) by A2,XBOOLE_0:def 10;
    end;
    suppose
A3:   PI<>{};
A4:   PP.:PI c= {0.K}
      proof
        let y be object;
        assume y in PP.:PI;
        then consider x being object such that
A5:     x in dom PP and
A6:     x in PI and
A7:     y = PP.x by FUNCT_1:def 6;
        reconsider f=x as Element of P by A5;
        not f in {I} by A6,XBOOLE_0:def 5;
        then f <> I by TARSKI:def 1;
        then PP.f=0.K by Th5;
        hence thesis by A7,TARSKI:def 1;
      end;
A8:   0.K = the_unity_wrt aa by FVSUM_1:7;
      dom PP=P by FUNCT_2:def 1;
      then PP.:PI={0.K} by A3,A4,ZFMISC_1:33;
      then
A9:   aa $$ (PI,PP)=0.K by A8,FVSUM_1:8,SETWOP_2:8;
A10:  PI\/II=II\/P by XBOOLE_1:39;
A11:  II\/P=P by XBOOLE_1:12;
      PI misses II by XBOOLE_1:79;
      hence aa $$ (F,PP) = aa $$ (II,PP)+0.K by A2,A3,A9,A10,A11,SETWOP_2:4
        .= aa $$ (II,PP) by RLVECT_1:def 4;
    end;
  end;
  hence Det M = PP.I by SETWISEO:17
    .= -(mm"**"Path_matrix(I,M),I) by MATRIX_3:def 8
    .= mm"**"Path_matrix(I,M) by A1,MATRIX_1:def 20
    .= mm"**"diagonal_of_Matrix M by Th6;
end;

theorem Th8:
  for M be lower_triangular Matrix of n,K holds Det M=(the multF of
  K) $$ diagonal_of_Matrix M
proof
  let M be lower_triangular Matrix of n,K;
A1: Det M = Det M@ by MATRIXR2:43;
  M@ is upper_triangular Matrix of n,K by Th2;
  hence Det M= (the multF of K) $$ diagonal_of_Matrix M@ by A1,Th7
    .=(the multF of K) $$ diagonal_of_Matrix M by Th3;
end;

theorem Th9:
  for X be finite set, n holds card {Y where Y is Subset of X: card
  Y = n} = card X choose n
proof
  let X be finite set, n;
  reconsider N=n as Element of NAT by ORDINAL1:def 12;
  set YY={Y where Y is Subset of X: card Y=n};
  set CH=Choose(X,N,1,0);
  deffunc F(set)=(X-->0)+*($1-->1);
  consider f be Function such that
A1: dom f = YY & for x being set st x in YY holds f.x = F(x)
     from FUNCT_1:sch 5;
A2: CH c= rng f
  proof
    let y be object;
A3: dom (X-->0)= X;
    assume y in CH;
    then consider g be Function of X,{0,1} such that
A4: g = y and
A5: card (g"{1})=n by CARD_FIN:def 1;
    X=dom g by FUNCT_2:def 1;
    then reconsider Y=g"{1} as Subset of X by RELAT_1:132;
A6: Y in YY by A5;
A7: now
      let x being object such that
A8:   x in dom g;
      now
        per cases;
        suppose
A9:       x in Y;
          then g.x in {1} by FUNCT_1:def 7;
          then
A10:      g.x=1 by TARSKI:def 1;
A11:      (Y-->1).x=1 by A9,FUNCOP_1:7;
          x in dom (Y-->1) by A9;
          hence g.x=F(Y).x by A11,A10,FUNCT_4:13;
        end;
        suppose
A12:      not x in Y;
          then not g.x in {1} by A8,FUNCT_1:def 7;
          then
A13:      g.x<> 1 by TARSKI:def 1;
A14:      rng g c= {0,1} by RELAT_1:def 19;
A15:      (X-->0).x=0 by A8,FUNCOP_1:7;
A16:      dom (Y-->1)=Y;
          g.x in rng g by A8,FUNCT_1:def 3;
          then g.x=0 by A14,A13,TARSKI:def 2;
          hence g.x=F(Y).x by A12,A15,A16,FUNCT_4:11;
        end;
      end;
      hence g.x=F(Y).x;
    end;
    dom (Y-->1)= Y;
    then
A17: dom F(Y) = X\/Y by A3,FUNCT_4:def 1
      .= X by XBOOLE_1:12;
    dom g=X by FUNCT_2:def 1;
    then F(Y)=g by A17,A7;
    then f.Y=g by A1,A6;
    hence thesis by A1,A4,A6,FUNCT_1:def 3;
  end;
  for x1,x2 be object st x1 in dom f & x2 in dom f & f.x1 = f.x2 holds x1 = x2
  proof
    let x1,x2 be object such that
A18: x1 in dom f and
A19: x2 in dom f and
A20: f.x1 = f.x2;
    consider Y2 be Subset of X such that
A21: x2=Y2 and
A22: card Y2=n by A1,A19;
    consider Y1 be Subset of X such that
A23: x1=Y1 and
A24: card Y1=n by A1,A18;
    Y1 c= Y2
    proof
A25:  dom (Y1-->1)=Y1;
      let y be object such that
A26:  y in Y1;
      (Y1-->1).y=1 by A26,FUNCOP_1:7;
      then
A27:  F(Y1).y=1 by A26,A25,FUNCT_4:13;
A28:  F(Y1)=f.x1 by A1,A18,A23;
A29:  dom (Y2-->1)=Y2;
      assume
A30:  not y in Y2;
      (X-->0).y=0 by A26,FUNCOP_1:7;
      then F(Y2).y=0 by A30,A29,FUNCT_4:11;
      hence thesis by A1,A19,A20,A21,A27,A28;
    end;
    hence thesis by A23,A24,A21,A22,CARD_2:102;
  end;
  then
A31: f is one-to-one;
  rng f c= CH
  proof
    let y be object;
    assume y in rng f;
    then consider x being object such that
A32: x in dom f and
A33: f.x=y by FUNCT_1:def 3;
    consider Y be Subset of X such that
A34: x=Y and
A35: card Y=n by A1,A32;
    Y\/X=X by XBOOLE_1:12;
    then F(Y) in CH by A35,CARD_FIN:17;
    hence thesis by A1,A32,A33,A34;
  end;
  then rng f=CH by A2,XBOOLE_0:def 10;
  then YY,CH are_equipotent by A1,A31,WELLORD2:def 4;
  then card YY=card CH by CARD_1:5;
  hence thesis by CARD_FIN:16;
end;

theorem Th10:
  card 2Set Seg n = n choose 2
proof
  {Y where Y is Subset of Seg n: card Y = 2} = 2Set Seg n by SGRAPH1:def 2;
  hence card 2Set Seg n = card (Seg n) choose 2 by Th9
    .= n choose 2 by FINSEQ_1:57;
end;

theorem
  for R be Element of Permutations(n) st R=Rev idseq n holds R is even
  iff (n choose 2) mod 2 = 0
proof
  let r be Element of Permutations(n) such that
A1: r=Rev idseq n;
  per cases;
  suppose
A2: n<2;
    then
 n=0 or n=1 by NAT_1:23;
    then n*(n-1)/2=0;
    then n choose 2=0 by STIRL2_1:51;
    hence thesis by A2,LAPLACE:11,NAT_D:26;
  end;
  suppose
A3: n>=2;
    set CH=n choose 2;
    reconsider n2=n-2 as Nat by A3,NAT_1:21;
    reconsider R=r as Element of Permutations(n2+2);
    set K = the Fanoian Field;
    set S=2Set Seg (n2+2);
    S in Fin S by FINSUB_1:def 5; then
A4: In(S,Fin S)=S by SUBSET_1:def 8;
    idseq (n2+2) is Element of Group_of_Perm(n2+2) by MATRIX_1:11;
    then reconsider I=idseq (n2+2) as Element of Permutations(n2+2) by
MATRIX_1:def 17;
    set D={s where s is Element of S:s in S & Part_sgn(I,K).s <> Part_sgn(R,K)
    .s};
A5: D c= S
    proof
      let x be object;
      assume x in D;
      then
      ex s be Element of S st x=s & s in S & Part_sgn(I,K).s <> Part_sgn(
      R,K).s;
      hence thesis;
    end;
    then reconsider D as finite set;
    S c= D
    proof
      let x be object;
      assume x in S;
      then reconsider s=x as Element of S;
      consider i,j such that
A6:   i in Seg (n2+2) and
A7:   j in Seg (n2+2) and
A8:   i < j and
A9:  s={i,j} by MATRIX11:1;
A10:  I.j=j by A7,FUNCT_1:17;
      reconsider i9=i,j9=j,n29=n2 as Element of NAT by ORDINAL1:def 12;
A11:  j9<=n2+2 by A7,FINSEQ_1:1;
      i9<=n29+2 by A6,FINSEQ_1:1;
      then reconsider ni=(n29+2)-i9+1,nj=(n29+2)-j9+1 as Element of NAT by A11,
FINSEQ_5:1;
      ni in Seg (n2+2) by A6,FINSEQ_5:2;
      then
A12:  I.ni=ni by FUNCT_1:17;
A13:  len idseq (n2+2)=n29+2 by CARD_1:def 7;
      i in dom I by A6;
      then
A14:  R.i9=I.ni by A1,A13,FINSEQ_5:58;
      j in dom I by A7;
      then
A15:  R.j9=I.nj by A1,A13,FINSEQ_5:58;
      nj in Seg (n2+2) by A7,FINSEQ_5:2;
      then
A16:  I.nj=nj by FUNCT_1:17;
      I.i=i by A6,FUNCT_1:17;
      then
A17:  Part_sgn(I,K).s=1_K by A6,A7,A8,A9,A10,MATRIX11:def 1;
      (n29+2)+1-i9 > (n29+2)+1-j9 by A8,XREAL_1:15;
      then Part_sgn(R,K).s=-1_K by A6,A7,A8,A9,A14,A15,A12,A16,MATRIX11:def 1;
      then Part_sgn(I,K).s <> Part_sgn(R,K).s by A17,MATRIX11:22;
      hence thesis;
    end;
    then
A18: S=D by A5,XBOOLE_0:def 10;
A19: card S=n choose 2 by Th10;
    per cases by NAT_D:12;
    suppose
A20:  CH mod 2=0;
A21:  sgn (I,K)=1_K by MATRIX11:12;
      sgn(I,K)= sgn(R,K) by A18,A4,A19,A20,MATRIX11:7;
      hence thesis by A20,A21,MATRIX11:23;
    end;
    suppose
A22:  CH mod 2=1;
A23:  sgn (I,K)=1_K by MATRIX11:12;
      sgn(R,K)= -sgn(I,K) by A18,A4,A19,A22,MATRIX11:7;
      hence thesis by A22,A23,MATRIX11:23;
    end;
  end;
end;

theorem Th12:
  for M be (Matrix of n,K),R be Permutation of Seg n st R=Rev
  idseq n & for i,j st i in Seg n & j in Seg n & i+j <= n holds M*(i,j) = 0.K
  holds M*R is upper_triangular Matrix of n,K
proof
  let M be (Matrix of n,K),R be Permutation of Seg n such that
A1: R=Rev idseq n and
A2: for i,j st i in Seg n & j in Seg n & i+j <= n holds M*(i,j)=0.K;
  set I=idseq n;
  set MR=M*R;
  now
    let i,j such that
A3: [i,j] in Indices MR and
A4: i>j;
    reconsider i9=i as Element of NAT by ORDINAL1:def 12;
A5: Indices MR=[:Seg n,Seg n:] by MATRIX_0:24;
    then
A6: i in Seg n by A3,ZFMISC_1:87;
    then i<= n by FINSEQ_1:1;
    then reconsider ni=n-i9+1 as Element of NAT by FINSEQ_5:1;
A7: ni in Seg n by A6,FINSEQ_5:2;
    then
A8: I.ni=ni by FUNCT_1:17;
    n+1-i<n+1-j by A4,XREAL_1:15;
    then ni+j<(n+1-j)+j by XREAL_1:8;
    then
A9: ni+j<=n by NAT_1:13;
    j in Seg n by A3,A5,ZFMISC_1:87;
    then
A10: M*(ni,j)=0.K by A2,A7,A9;
A11: len I=n by CARD_1:def 7;
A12: Indices M=[:Seg n,Seg n:] by MATRIX_0:24;
    dom I=Seg len I by FINSEQ_1:def 3;
    then R.i=I.ni by A1,A6,A11,FINSEQ_5:58;
    hence MR*(i,j)=0.K by A3,A5,A12,A8,A10,MATRIX11:def 4;
  end;
  hence thesis by MATRIX_1:def 12;
end;

theorem Th13:
  for M be (Matrix of n,K),R be Permutation of Seg n st R=Rev
  idseq n & for i,j st i in Seg n & j in Seg n & i+j > n+1 holds M*(i,j) = 0.K
  holds M*R is lower_triangular Matrix of n,K
proof
  let M be (Matrix of n,K),R be Permutation of Seg n such that
A1: R=Rev idseq n and
A2: for i,j st i in Seg n & j in Seg n & i+j > n+1 holds M*(i,j)=0.K;
  set I=idseq n;
  set MR=M*R;
  now
    let i,j such that
A3: [i,j] in Indices MR and
A4: i<j;
    reconsider i9=i as Element of NAT by ORDINAL1:def 12;
A5: Indices MR=[:Seg n,Seg n:] by MATRIX_0:24;
    then
A6: i in Seg n by A3,ZFMISC_1:87;
    then i<= n by FINSEQ_1:1;
    then reconsider ni=n-i9+1 as Element of NAT by FINSEQ_5:1;
    n+1-i>n+1-j by A4,XREAL_1:15;
    then
A7: ni+j>(n+1-j)+j by XREAL_1:8;
A8: len I=n by CARD_1:def 7;
A9: Indices M=[:Seg n,Seg n:] by MATRIX_0:24;
A10: ni in Seg n by A6,FINSEQ_5:2;
    then
A11: I.ni=ni by FUNCT_1:17;
    j in Seg n by A3,A5,ZFMISC_1:87;
    then
A12: M*(ni,j)=0.K by A2,A7,A10;
    dom I=Seg len I by FINSEQ_1:def 3;
    then R.i=I.ni by A1,A6,A8,FINSEQ_5:58;
    hence MR*(i,j) = 0.K by A3,A5,A9,A11,A12,MATRIX11:def 4;
  end;
  hence thesis by MATRIX_1:def 13;
end;

theorem
  for M be (Matrix of n,K),R be Element of Permutations(n) st R = Rev
idseq n & ((for i,j st i in Seg n & j in Seg n & i+j <= n holds M*(i,j) = 0.K)
or (for i,j st i in Seg n & j in Seg n & i+j > n+1 holds M*(i,j) = 0.K)) holds
  Det M = -((the multF of K) "**" Path_matrix(R,M), R)
proof
  let M be (Matrix of n,K),R be Element of Permutations(n) such that
A1: R=Rev idseq n and
A2: (for i,j st i in Seg n & j in Seg n & i+j <= n holds M*(i,j)=0.K)or
  for i,j st i in Seg n & j in Seg n & i+j > n+1 holds M*(i,j)=0.K;
  set mm=the multF of K;
  idseq n is Element of Group_of_Perm(n) by MATRIX_1:11;
  then reconsider I=idseq n as Element of Permutations(n) by MATRIX_1:def 17;
  set X=Seg n;
  reconsider r=Rev idseq n as Permutation of X by A1,MATRIX_1:def 16;
  set Mr=M*r;
  set PR=Path_matrix(R,M);
  set PI=Path_matrix(I,Mr);
A3: len PR=n by MATRIX_3:def 7;
A4: len PI=n by MATRIX_3:def 7;
A5: now
    per cases;
    suppose
A6:   n<1;
      then
A7:   PR={} by A3,NAT_1:14;
      PI={} by A4,A6,NAT_1:14;
      hence mm "**"PI=mm "**"PR by A7;
    end;
    suppose
A8:   n>=1;
      rng I=X;
      then
A9:   rng (Rev idseq n)=X by FINSEQ_5:57;
      reconsider PRR=PR*R as FinSequence of K by A3,A8,MATRIX_7:34;
A10:  dom r=X by FUNCT_2:52;
      dom PR=X by A3,FINSEQ_1:def 3;
      then
A11:  dom PRR=dom R by A1,A9,RELAT_1:27;
A12:  now
A13:    dom PR=Seg n by A3,FINSEQ_1:def 3;
A14:    dom PI=Seg n by A4,FINSEQ_1:def 3;
        let k such that
A15:    1 <=k and
A16:    k <= len PI;
A17:    k in Seg n by A4,A15,A16;
        then
A18:    n-k+1 in X by FINSEQ_5:2;
        I.k=k by A17,FUNCT_1:17;
        then
A19:    PI.k=Mr*(k,k) by A17,A14,MATRIX_3:def 7;
A20:    len idseq n = n by CARD_1:def 7;
        then r.k=I.(n-k+1) by A10,A17,FINSEQ_5:def 3;
        then
A21:    r.k=n-k+1 by A18,FUNCT_1:17;
A22:    Indices M=[:Seg n,Seg n:] by MATRIX_0:24;
        then [k,k] in Indices M by A17,ZFMISC_1:87;
        then consider m such that
A23:    r.k = m and
A24:    [m,k] in Indices M and
A25:    Mr*(k,k) = M*(m,k) by MATRIX11:37;
A26:    m in X by A22,A24,ZFMISC_1:87;
        then
A27:    n-m+1 in X by FINSEQ_5:2;
        r.m=I.(n-m+1) by A10,A20,A26,FINSEQ_5:def 3;
        then
A28:    R.m=k by A1,A23,A27,A21,FUNCT_1:17;
        m in Seg n by A22,A24,ZFMISC_1:87;
        then PR.m=M*(m,k) by A13,A28,MATRIX_3:def 7;
        hence PI.k=PRR.k by A1,A11,A10,A17,A23,A25,A19,FUNCT_1:12;
      end;
      n is Element of NAT by ORDINAL1:def 12;
      then len PRR=n by A1,A11,A10,FINSEQ_1:def 3;
      hence mm "**"PI=mm "**"PR by A4,A3,A8,A12,FINSEQ_1:14,MATRIX_7:33;
    end;
  end;
  Mr is upper_triangular Matrix of n,K or Mr is lower_triangular Matrix
  of n,K by A2,Th12,Th13;
  then
A29: mm $$ diagonal_of_Matrix Mr = Det Mr by Th7,Th8
    .= -(Det M,R) by A1,MATRIX11:46;
  then
A30: -(Det M,R)=mm $$ PR by A5,Th6;
  per cases;
  suppose
    R is even;
    then -(Det M,R)=Det M by MATRIX_1:def 20;
    hence thesis by A5,A29,Th6;
  end;
  suppose
A31: R is odd;
    then
A32: -(mm"**"PR,R)= -mm"**"PR by MATRIX_1:def 20;
    -(Det M,R)= -Det M by A31,MATRIX_1:def 20;
    then -(mm"**"PR,R)+(-Det M) =0.K by A30,A32,VECTSP_1:19;
    hence thesis by VECTSP_1:19;
  end;
end;

theorem Th15:
  for M be Matrix of n,K for M1,M2 be upper_triangular Matrix of n
,K st M = M1*M2 holds M is upper_triangular Matrix of n,K & diagonal_of_Matrix
  M = mlt(diagonal_of_Matrix M1,diagonal_of_Matrix M2)
proof
  let M be Matrix of n,K;
  reconsider N=n as Element of NAT by ORDINAL1:def 12;
  let M1,M2 be upper_triangular Matrix of n,K such that
A1: M = M1*M2;
  set SS=[:Seg n,Seg n:];
  set KK=the carrier of K;
A2: len M2=n by MATRIX_0:24;
A3: width M1=n by MATRIX_0:24;
  now
    set n0=n|->0.K;
    let i,j such that
A4: [i,j] in Indices M and
A5: i>j;
    set C=Col(M2,j);
    set L=Line(M1,i);
    reconsider L9=L,C9=C as Element of N-tuples_on KK by MATRIX_0:24;
    set m=mlt(L9,C9);
A6: len m=n by CARD_1:def 7;
A7: now
      let k such that
A8:   1<= k and
A9:   k<= n;
A10:  k in Seg n by A8,A9;
      then
A11:  n0.k=0.K by FINSEQ_2:57;
A12:  Indices M2=SS by MATRIX_0:24;
A13:  Indices M1=SS by MATRIX_0:24;
A14:  L.k=M1*(i,k) by A3,A10,MATRIX_0:def 7;
A15:  Indices M = SS by MATRIX_0:24;
      then i in Seg n by A4,ZFMISC_1:87;
      then
A16:  [i,k] in Indices M1 by A10,A13,ZFMISC_1:87;
      j in Seg n by A4,A15,ZFMISC_1:87;
      then
A17:  [k,j] in Indices M2 by A10,A12,ZFMISC_1:87;
A18:  dom m = Seg n by A6,FINSEQ_1:def 3;
A19:  k in Seg n by A8,A9;
      dom M2=Seg n by A2,FINSEQ_1:def 3;
      then
A20:  C.k=M2*(k,j) by A10,MATRIX_0:def 8;
      per cases;
      suppose
        k<=j;
        then k<i by A5,XXREAL_0:2;
        then
A21:    M1*(i,k)=0.K by A16,MATRIX_1:def 12;
        m.k=(M1*(i,k))*(M2*(k,j)) by A14,A20,A18,A19,FVSUM_1:60;
        hence m.k=n0.k by A11,A21;
      end;
      suppose
        k>j;
        then
A22:    M2*(k,j)=0.K by A17,MATRIX_1:def 12;
        m.k=(M1*(i,k))*(M2*(k,j)) by A14,A20,A18,A19,FVSUM_1:60;
        hence m.k=n0.k by A11,A22;
      end;
    end;
    len n0= n by CARD_1:def 7;
    then m=n0 by A6,A7;
    hence 0.K = L "*" C by MATRIX_3:11
      .= M*(i,j) by A1,A3,A2,A4,MATRIX_3:def 4;
  end;
  hence M is upper_triangular Matrix of n,K by MATRIX_1:def 12;
  set D2=diagonal_of_Matrix M2;
  set D1=diagonal_of_Matrix M1;
  set DM=diagonal_of_Matrix M;
A23: len D2=n by MATRIX_3:def 10;
  len D1=n by MATRIX_3:def 10;
  then reconsider D19=D1,D29=D2 as Element of N-tuples_on KK by A23,FINSEQ_2:92
;
  set m=mlt(D19,D29);
A24: len m = n by CARD_1:def 7;
A25: now
    set aa=the addF of K;
    let i such that
A26: 1<=i and
A27: i<=n;
A28: i in Seg n by A26,A27;
    then
A29: DM.i=M*(i,i) by MATRIX_3:def 10;
    set C=Col(M2,i);
    set L=Line(M1,i);
    reconsider L9=L,C9=C as Element of N-tuples_on KK by MATRIX_0:24;
    set mLC=mlt(L9,C9);
A30: aa is having_a_unity by FVSUM_1:8;
    Indices M=SS by MATRIX_0:24;
    then [i,i] in Indices M by A28,ZFMISC_1:87;
    then
A31: DM.i=L"*"C by A1,A3,A2,A29,MATRIX_3:def 4;
A32: D2.i=M2*(i,i) by A28,MATRIX_3:def 10;
A33: D1.i=M1*(i,i) by A28,MATRIX_3:def 10;
    len mLC=n by CARD_1:def 7;
    then consider f be sequence of KK such that
A34: f.1 = mLC.1 and
A35: for k be Nat st 0 <> k & k < n holds f.(k+1) = aa.(f.k
    ,mLC.(k+1)) and
A36: DM.i = f.n by A26,A27,A31,A30,FINSOP_1:def 1;
    defpred P[Nat] means 1<=$1 & $1 <= n implies ($1 < i implies f.$1=0.K) & (
    $1 >= i implies f.$1=m.i);
    i in dom m by A24,A28,FINSEQ_1:def 3;
    then
A37: m.i=(M1*(i,i))*(M2*(i,i)) by A33,A32,FVSUM_1:60;
A38: for j st j in Seg n holds (j<>i implies mLC.j=0.K) & (j=i implies mLC
    .j=m.i)
    proof
A39:  i in Seg n by A26,A27;
      let j such that
A40:  j in Seg n;
A41:  L.j=M1*(i,j) by A3,A40,MATRIX_0:def 7;
      Indices M1=SS by MATRIX_0:24;
      then
A42:  [i,j] in Indices M1 by A40,A39,ZFMISC_1:87;
      dom M2=Seg n by A2,FINSEQ_1:def 3;
      then
A43:  C.j=M2*(j,i) by A40,MATRIX_0:def 8;
      Indices M2=SS by MATRIX_0:24;
      then
A44:  [j,i] in Indices M2 by A40,A39,ZFMISC_1:87;
      per cases;
      suppose
A45:    i<>j;
        then i<j or j<i by XXREAL_0:1;
        then
A46:    M1*(i,j)=0.K or M2*(j,i)=0.K by A42,A44,MATRIX_1:def 12;
        mLC.j=(M1*(i,j))*(M2*(j,i)) by A40,A41,A43,FVSUM_1:61;
        hence thesis by A45,A46;
      end;
      suppose
        i=j;
        hence thesis by A37,A40,A41,A43,FVSUM_1:61;
      end;
    end;
A47: for k st P[k] holds P[k+1]
    proof
      let k such that
A48:  P[k];
      set k1=k+1;
      assume that
A49:  1<=k1 and
A50:  k1 <= n;
A51:  k1 in Seg n by A49,A50;
      per cases;
      suppose
        k=0;
        then f.k1=0.K & k1<i or f.k1=mLC.k1 & k1=i by A26,A38,A34,A51,
XXREAL_0:1;
        hence thesis by A38,A51;
      end;
      suppose
A52:    k>0;
        k<n by A50,NAT_1:13;
        then
A53:    f.k1 = aa.(f.k,mLC.k1) by A35,A52;
        per cases by XXREAL_0:1;
        suppose
A54:      k1<i;
          then f.k1=0.K+0.K by A38,A48,A50,A51,A52,A53,NAT_1:13,14;
          hence thesis by A54,RLVECT_1:def 4;
        end;
        suppose
A55:      k1=i;
          then f.k1=0.K+(M1*(i,i))*(M2*(i,i)) by A37,A38,A48,A50,A51,A52,A53,
NAT_1:13,14;
          hence thesis by A37,A55,RLVECT_1:def 4;
        end;
        suppose
A56:      k1>i;
          then f.k1=(M1*(i,i))*(M2*(i,i))+0.K by A37,A38,A48,A50,A51,A52,A53,
NAT_1:13,14;
          hence thesis by A37,A56,RLVECT_1:def 4;
        end;
      end;
    end;
A57: 1<=n by A26,A27,NAT_1:14;
A58: P[0];
    for k holds P[k] from NAT_1:sch 2(A58,A47);
    hence m.i=DM.i by A27,A36,A57;
  end;
  len DM=n by MATRIX_3:def 10;
  hence thesis by A24,A25;
end;

theorem
  for M be Matrix of n,K for M1,M2 be lower_triangular Matrix of n,K st
  M = M1*M2 holds M is lower_triangular Matrix of n,K & diagonal_of_Matrix M =
  mlt(diagonal_of_Matrix M1,diagonal_of_Matrix M2)
proof
  let M be Matrix of n,K;
  reconsider N=n as Element of NAT by ORDINAL1:def 12;
  let M1,M2 be lower_triangular Matrix of n,K such that
A1: M = M1*M2;
A2: width M2=n by MATRIX_0:24;
A3: len M2=n by MATRIX_0:24;
A4: width M1=n by MATRIX_0:24;
A5: now
    per cases;
    suppose
A6:   n=0;
      then len (M2@*M1@) =0 by MATRIX_0:24;
      then
A7:   M2@*M1@={};
      len (M@)=0 by A6,MATRIX_0:24;
      hence M@ = M2@*M1@ by A7;
    end;
    suppose
      n>0;
      hence M@ = (M2@)*(M1@) by A1,A4,A2,A3,MATRIX_3:22;
    end;
  end;
  set D29=diagonal_of_Matrix M2@;
  set D2=diagonal_of_Matrix M2;
  set D19=diagonal_of_Matrix M1@;
  set D1=diagonal_of_Matrix M1;
A8: len D2=n by MATRIX_3:def 10;
  len D1=n by MATRIX_3:def 10;
  then reconsider d1=D1,d2=D2 as Element of N-tuples_on the carrier of K by A8,
FINSEQ_2:92;
A9: M2@ is upper_triangular Matrix of n,K by Th2;
A10: M1@ is upper_triangular Matrix of n,K by Th2;
  then diagonal_of_Matrix M@ = mlt(D29,D19) by A5,A9,Th15;
  then
A11: diagonal_of_Matrix M = mlt(D29,D19) by Th3
    .= mlt(D2,D19) by Th3
    .= mlt(d2,d1) by Th3
    .= mlt(D1,D2) by FVSUM_1:63;
  M@ is upper_triangular Matrix of n,K by A5,A10,A9,Th15;
  hence thesis by A11,Th2;
end;

begin :: The Rank of Matrices

definition
  let D be non empty set;
  let M be Matrix of D;
  let n,m;
  let nt be Element of n-tuples_on NAT;
  let mt be Element of m-tuples_on NAT;
  func Segm(M,nt,mt) -> Matrix of n,m,D means
  :Def1:
  for i,j being Nat st [i,j ] in Indices it holds it*(i,j)=M*(nt.i,mt.j);
  existence
  proof
    reconsider m9=m,n9=n as Element of NAT by ORDINAL1:def 12;
    deffunc s(set,set)=M*(nt.$1,mt.$2);
    ex S be Matrix of n9,m9,D st for i,j being Nat st [i,j] in Indices S
    holds S*(i,j) = s(i,j) from MATRIX_0:sch 1;
    then consider S be Matrix of n9,m9,D such that
A1: for i,j being Nat st [i,j] in Indices S holds S*(i,j) = s(i,j);
    reconsider S as Matrix of n,m,D;
    take S;
    thus thesis by A1;
  end;
  uniqueness
  proof
    let S1,S2 be Matrix of n,m,D such that
A2: for i,j st [i,j] in Indices S1 holds S1*(i,j)=M*(nt.i,mt.j) and
A3: for i,j st [i,j] in Indices S2 holds S2*(i,j)=M*(nt.i,mt.j);
    now
      let i,j such that
A4:   [i,j] in Indices S1;
A5:   [i,j] in Indices S2 by A4,MATRIX_0:26;
      reconsider i9=i,j9=j as Element of NAT by ORDINAL1:def 12;
      S1*(i,j)=M*(nt.i9,mt.j9) by A2,A4;
      hence S1*(i,j)=S2*(i,j) by A3,A5;
    end;
    hence thesis by MATRIX_0:27;
  end;
end;

reserve A for (Matrix of D),
  A9 for Matrix of n9,m9,D,
  M9 for Matrix of n9, m9,K,
  nt,nt1,nt2 for Element of n-tuples_on NAT,
  mt,mt1 for Element of m -tuples_on NAT,
  M for Matrix of K;

theorem Th17:
  [:rng nt,rng mt:] c= Indices A implies ( [i,j] in Indices Segm(A
  ,nt,mt) iff [nt.i,mt.j] in Indices A )
proof
  set S=Segm(A,nt,mt);
A1: dom mt=Seg m by FINSEQ_2:124;
  assume
A2: [:rng nt,rng mt:] c= Indices A;
  thus [i,j] in Indices Segm(A,nt,mt) implies [nt.i,mt.j] in Indices A
  proof
A3: dom mt=Seg m by FINSEQ_2:124;
    assume
A4: [i,j] in Indices S;
    then
A5: j in Seg width S by ZFMISC_1:87;
    [i,j] in [:Seg n,Seg width S:] by A4,MATRIX_0:25;
    then
A6: i in Seg n by ZFMISC_1:87;
    then
A7: n <> 0;
    dom nt=Seg n by FINSEQ_2:124;
    then
A8: nt.i in rng nt by A6,FUNCT_1:def 3;
    width S=m by Th1,A7;
    then mt.j in rng mt by A5,A3,FUNCT_1:def 3;
    then [nt.i,mt.j] in [:rng nt,rng mt:] by A8,ZFMISC_1:87;
    hence thesis by A2;
  end;
  assume
A9: [nt.i,mt.j] in Indices A;
A10: j in dom mt
  proof
    assume not j in dom mt;
    then mt.j = {} by FUNCT_1:def 2;
    then 0 in Seg width A by A9,ZFMISC_1:87;
    hence thesis by FINSEQ_1:1;
  end;
A11: i in dom nt
  proof
    assume not i in dom nt;
    then
A12: nt.i = {} by FUNCT_1:def 2;
    dom A=Seg len A by FINSEQ_1:def 3;
    then 0 in Seg len A by A9,A12,ZFMISC_1:87;
    hence thesis by FINSEQ_1:1;
  end;
  then n<>0;
  then
A13: width S=m by Th1;
  dom nt=Seg n by FINSEQ_2:124;
  then [i,j] in [:Seg n,Seg width S:] by A11,A10,A13,A1,ZFMISC_1:87;
  hence thesis by MATRIX_0:25;
end;

theorem Th18:
  [:rng nt,rng mt:] c= Indices A & (n = 0 iff m = 0) implies Segm(
  A,nt,mt)@ = Segm(A@,mt,nt)
proof
  assume that
A1: [:rng nt,rng mt:] c= Indices A and
A2: n = 0 iff m = 0;
  set A9=A@;
  set SA=Segm(A,nt,mt);
  set SA9=Segm(A9,mt,nt);
  per cases;
  suppose
A3: n=0;
    then width SA=0 by A2,Th1;
    then len (SA@)=0 by MATRIX_0:def 6;
    then
A4: SA@ ={};
    len SA9=0 by A2,A3,Th1;
    hence thesis by A4;
  end;
  suppose
A5: n>0;
    then
A6: width SA=m by Th1;
A7: width SA9=n by A2,Th1;
A8: now
A9:   Indices SA9=[:Seg m,Seg n:] by A7,MATRIX_0:25;
      let i,j such that
A10:  [i,j] in Indices (SA@);
      reconsider i9=i,j9=j as Element of NAT by ORDINAL1:def 12;
A11:  [j9,i9] in Indices SA by A10,MATRIX_0:def 6;
      then
A12:  (SA@)*(i9,j9)=SA*(j9,i9) by MATRIX_0:def 6;
      Indices SA=[:Seg n,Seg m:] by A6,MATRIX_0:25;
      then
A13:  j9 in Seg n by A11,ZFMISC_1:87;
      i9 in Seg m by A6,A11,ZFMISC_1:87;
      then
A14:  [i9,j9] in Indices SA9 by A13,A9,ZFMISC_1:87;
A15:  SA*(j9,i9)=A*(nt.j,mt.i) by A11,Def1;
      [nt.j,mt.i] in Indices A by A1,A11,Th17;
      then (SA@)*(i9,j9)=A9*(mt.i,nt.j) by A15,A12,MATRIX_0:def 6;
      hence (SA@)*(i,j)=SA9* (i,j) by A14,Def1;
    end;
    len SA9=m by A2,Th1;
    then
A16: len (SA@) = len SA9 by A2,A5,A6,MATRIX_0:54;
    len SA=n by A5,Th1;
    hence thesis by A2,A5,A6,A7,A16,A8,MATRIX_0:21,54;
  end;
end;

theorem Th19:
  [:rng nt,rng mt:] c= Indices A & (m=0 implies n=0) implies Segm(
  A,nt,mt) = Segm(A@,mt,nt)@
proof
  assume that
A1: [:rng nt,rng mt:] c= Indices A and
A2: m=0 implies n=0;
  set S9=Segm(A@,mt,nt);
  set S=Segm(A,nt,mt);
  per cases;
  suppose
A3: n=0;
    len S9=0 or len S9>0 & len S9=m by MATRIX_0:def 2;
    then width S9=0 by A3,MATRIX_0:23,def 3;
    then
A4: len (S9@)=0 by MATRIX_0:def 6;
    len S=0 by A3,MATRIX_0:def 2;
    then S={};
    hence thesis by A4;
  end;
  suppose
A5: n>0;
    then
A6: width S=m by Th1;
    len S=n by A5,Th1;
    then (S@)@ = S by A2,A5,A6,MATRIX_0:57;
    hence thesis by A1,A2,A5,Th18;
  end;
end;

theorem Th20:
  for A be Matrix of 1,D holds A = <*<* A*(1,1) *>*>
proof
  let A be Matrix of 1,D;
  reconsider AA=<*<* A*(1,1) *>*> as Matrix of 1,D by MATRIX_0:15;
  now
A1: Indices A=[:Seg 1,Seg 1:] by MATRIX_0:24;
    let i,j such that
A2: [i,j] in Indices A;
    j in {1} by A2,A1,FINSEQ_1:2,ZFMISC_1:87;
    then
A3: j=1 by TARSKI:def 1;
    i in {1} by A2,A1,FINSEQ_1:2,ZFMISC_1:87;
    then i=1 by TARSKI:def 1;
    hence AA*(i,j)=A*(i,j) by A3,MATRIX_0:49;
  end;
  hence thesis by MATRIX_0:27;
end;

theorem Th21:
  n = 1 & m = 1 implies Segm(A,nt,mt) = <*<* A*(nt.1,mt.1) *>*>
proof
A1: 1 in Seg 1;
  assume that
A2: n = 1 and
A3: m = 1;
  Indices Segm(A,nt,mt)=[:Seg 1,Seg 1:] by A2,A3,MATRIX_0:24;
  then [1,1] in Indices Segm(A,nt,mt) by A1,ZFMISC_1:87;
  then Segm(A,nt,mt)*(1,1)=A*(nt.1,mt.1) by Def1;
  hence thesis by A2,A3,Th20;
end;

theorem Th22:
  for A be Matrix of 2,D holds A = ( A*(1,1),A*(1,2) )][( A*(2,1), A*(2,2) )
proof
  let A be Matrix of 2,D;
  reconsider AA=(A*(1,1),A*(1,2))][(A*(2,1),A*(2,2)) as Matrix of 2,D;
  now
A1: Indices A=[:Seg 2,Seg 2:] by MATRIX_0:24;
    let i,j such that
A2: [i,j] in Indices A;
    j in {1,2} by A2,A1,FINSEQ_1:2,ZFMISC_1:87;
    then
A3: j=1 or j=2 by TARSKI:def 2;
    i in {1,2} by A2,A1,FINSEQ_1:2,ZFMISC_1:87;
    then i=1 or i=2 by TARSKI:def 2;
    hence AA*(i,j)=A*(i,j) by A3,MATRIX_0:50;
  end;
  hence thesis by MATRIX_0:27;
end;

theorem Th23:
  n = 2 & m = 2 implies Segm(A,nt,mt) = ( A*(nt.1,mt.1),A*(nt.1,mt
  .2) )][( A*(nt.2,mt.1),A*(nt.2,mt.2) )
proof
  set S=Segm(A,nt,mt);
  set I=Indices S;
  assume that
A1: n = 2 and
A2: m = 2;
A3: I=[:Seg 2,Seg 2:] by A1,A2,MATRIX_0:24;
A4: 2 in Seg 2;
  then [2,2] in I by A3,ZFMISC_1:87;
  then
A5: S*(2,2)=A*(nt.2,mt.2) by Def1;
A6: 1 in Seg 2;
  then [1,1] in I by A3,ZFMISC_1:87;
  then
A7: S*(1,1)=A*(nt.1,mt.1) by Def1;
  [2,1] in I by A6,A4,A3,ZFMISC_1:87;
  then
A8: S*(2,1)=A*(nt.2,mt.1) by Def1;
  [1,2] in I by A6,A4,A3,ZFMISC_1:87;
  then S*(1,2)=A*(nt.1,mt.2) by Def1;
  hence thesis by A1,A2,A7,A8,A5,Th22;
end;

theorem Th24:
  i in Seg n & rng mt c= Seg width A implies Line(Segm(A,nt,mt),i)
  = Line(A,nt.i) * mt
proof
  set S=Segm(A,nt,mt);
  set Li=Line(S,i);
  set LA=Line(A,nt.i);
  assume that
A1: i in Seg n and
A2: rng mt c= Seg width A;
  n <> 0 by A1;
  then
A3: width S=m by Th1;
  then len Li=m by MATRIX_0:def 7;
  then
A4: dom Li=Seg m by FINSEQ_1:def 3;
A5: dom mt=Seg m by FINSEQ_2:124;
  len LA=width A by MATRIX_0:def 7;
  then dom LA=Seg width A by FINSEQ_1:def 3;
  then
A6: dom (LA*mt)=dom mt by A2,RELAT_1:27;
  now
    let x being object such that
A7: x in dom Li;
    consider k be Nat such that
A8: k=x and
    1<=k and
    k<=m by A4,A7;
A9: Li.k=S*(i,k) by A3,A4,A7,A8,MATRIX_0:def 7;
    [i,k] in [:Seg n,Seg width S:] by A1,A3,A4,A7,A8,ZFMISC_1:87;
    then
A10: [i,k] in Indices S by MATRIX_0:25;
    mt.k in rng mt by A5,A4,A7,A8,FUNCT_1:def 3;
    then
A11: LA.(mt.k)=A*(nt.i,mt.k) by A2,MATRIX_0:def 7;
    (LA*mt).k=LA.(mt.k) by A6,A5,A4,A7,A8,FUNCT_1:12;
    hence Li.x=(LA*mt).x by A8,A11,A10,A9,Def1;
  end;
  hence thesis by A6,A5,A4;
end;

theorem Th25:
  i in Seg n & j in Seg n & nt.i = nt.j implies Line(Segm(A,nt,mt)
  ,i) = Line(Segm(A,nt,mt),j)
proof
  set S=Segm(A,nt,mt);
  set Li=Line(S,i);
  set Lj=Line(S,j);
  assume that
A1: i in Seg n and
A2: j in Seg n and
A3: nt.i=nt.j;
A4: now
    let k such that
A5: 1<=k and
A6: k<=width S;
A7: k in Seg width S by A5,A6;
    then [i,k] in [:Seg n,Seg width S:] by A1,ZFMISC_1:87;
    then [i,k] in Indices S by MATRIX_0:25;
    then
A8: S*(i,k)=A*(nt.i,mt.k) by Def1;
    [j,k] in [:Seg n,Seg width S:] by A2,A7,ZFMISC_1:87;
    then [j,k] in Indices S by MATRIX_0:25;
    then
A9: S*(j,k)=A*(nt.j,mt.k) by Def1;
    S*(i,k) =Li.k by A7,MATRIX_0:def 7;
    hence Li.k=Lj.k by A3,A7,A8,A9,MATRIX_0:def 7;
  end;
A10: len Lj=width S by MATRIX_0:def 7;
  len Li=width S by MATRIX_0:def 7;
  hence thesis by A10,A4;
end;

theorem Th26:
  i in Seg n & j in Seg n & nt.i = nt.j & i<>j implies Det Segm(M,
  nt,nt1) = 0.K
proof
  assume that
A1: i in Seg n and
A2: j in Seg n and
A3: nt.i = nt.j and
A4: i<>j;
A5: i<j or j<i by A4,XXREAL_0:1;
  Line(Segm(M,nt,nt1),i) = Line(Segm(M,nt,nt1),j) by A1,A2,A3,Th25;
  hence thesis by A1,A2,A5,MATRIX11:50;
end;

theorem Th27:
  not nt is one-to-one implies Det Segm(M,nt,nt1) = 0.K
proof
  assume not nt is one-to-one;
  then consider x,y being object such that
A1: x in dom nt and
A2: y in dom nt and
A3: nt.x=nt.y and
A4: x<>y;
A5: dom nt=Seg n by FINSEQ_2:124;
  then consider i be Nat such that
A6: x=i and
A7: 1<=i and
A8: i<=n by A1;
  consider j be Nat such that
A9: y=j and
A10: 1<=j and
A11: j<=n by A2,A5;
A12: j in Seg n by A10,A11;
  i in Seg n by A7,A8;
  hence thesis by A3,A4,A6,A9,A12,Th26;
end;

theorem Th28:
  j in Seg m & rng nt c= Seg len A implies Col(Segm(A,nt,mt),j) =
  Col(A,mt.j) * nt
proof
  set S=Segm(A,nt,mt);
  set Cj=Col(S,j);
  set CA=Col(A,mt.j);
  assume that
A1: j in Seg m and
A2: rng nt c= Seg len A;
  len CA=len A by MATRIX_0:def 8;
  then dom CA=Seg len A by FINSEQ_1:def 3;
  then
A3: dom (CA*nt)=dom nt by A2,RELAT_1:27;
A4: dom nt=Seg n by FINSEQ_2:124;
A5: len S=n by MATRIX_0:def 2;
  then
A6: dom S=Seg n by FINSEQ_1:def 3;
  len Cj=n by A5,MATRIX_0:def 8;
  then
A7: dom Cj=Seg n by FINSEQ_1:def 3;
A8: dom A=Seg len A by FINSEQ_1:def 3;
  now
    let x being object such that
A9: x in dom Cj;
    consider k be Nat such that
A10: k=x and
A11: 1<=k and
A12: k<=n by A7,A9;
A13: Cj.k=S*(k,j) by A6,A7,A9,A10,MATRIX_0:def 8;
    nt.k in rng nt by A4,A7,A9,A10,FUNCT_1:def 3;
    then
A14: CA.(nt.k)=A*(nt.k,mt.j) by A2,A8,MATRIX_0:def 8;
    [k,j] in [:Seg n,Seg m:] by A1,A7,A9,A10,ZFMISC_1:87;
    then
A15: [k,j] in Indices S by A6,A11,A12,Th1;
    (CA*nt).k=CA.(nt.k) by A3,A4,A7,A9,A10,FUNCT_1:12;
    hence Cj.x=(CA*nt).x by A10,A14,A15,A13,Def1;
  end;
  hence thesis by A3,A4,A7;
end;

theorem Th29:
  i in Seg m & j in Seg m & mt.i = mt.j implies Col(Segm(A,nt,mt),
  i) = Col(Segm(A,nt,mt),j)
proof
  set S=Segm(A,nt,mt);
  set Ci=Col(S,i);
  set Cj=Col(S,j);
  assume that
A1: i in Seg m and
A2: j in Seg m and
A3: mt.i=mt.j;
A4: now
    let k such that
A5: 1<=k and
A6: k<=len S;
A7: k in Seg len S by A5,A6;
    then
A8: k in Seg n by MATRIX_0:def 2;
    then n <> 0;
    then
A9: width S = m by Th1;
    [k,j] in [:Seg n,Seg m:] by A2,A8,ZFMISC_1:87;
    then [k,j] in Indices S by A9,MATRIX_0:25;
    then
A10: S*(k,j)=A*(nt.k,mt.j) by Def1;
    [k,i] in [:Seg n,Seg m:] by A1,A8,ZFMISC_1:87;
    then [k,i] in Indices S by A9,MATRIX_0:25;
    then
A11: S*(k,i)=A*(nt.k,mt.i) by Def1;
A12: k in dom S by A7,FINSEQ_1:def 3;
    then S*(k,i) =Ci.k by MATRIX_0:def 8;
    hence Ci.k=Cj.k by A3,A12,A11,A10,MATRIX_0:def 8;
  end;
A13: len Cj=len S by MATRIX_0:def 8;
  len Ci=len S by MATRIX_0:def 8;
  hence thesis by A13,A4;
end;

theorem Th30:
  i in Seg m & j in Seg m & mt.i = mt.j & i<>j implies Det Segm(M,
  mt1,mt) = 0.K
proof
  assume that
A1: i in Seg m and
A2: j in Seg m and
A3: mt.i = mt.j and
A4: i<>j;
A5: i<j or j<i by A4,XXREAL_0:1;
  set S = Segm(M,mt1,mt);
A6: width S=m by MATRIX_0:24;
  then
A7: Col(S,j)=Line(S@,j) by A2,MATRIX_0:59;
  Col(S,i)=Line(S@,i) by A1,A6,MATRIX_0:59;
  hence 0.K = Det (S@) by A1,A2,A3,A7,A5,Th29,MATRIX11:50
    .= Det S by MATRIXR2:43;
end;

theorem Th31:
  not mt is one-to-one implies Det Segm(M,mt1,mt) = 0.K
proof
  assume not mt is one-to-one;
  then consider x,y being object such that
A1: x in dom mt and
A2: y in dom mt and
A3: mt.x=mt.y and
A4: x<>y;
A5: dom mt=Seg m by FINSEQ_2:124;
  then consider i be Nat such that
A6: x=i and
A7: 1<=i and
A8: i<=m by A1;
  consider j be Nat such that
A9: y=j and
A10: 1<=j and
A11: j<=m by A2,A5;
A12: j in Seg m by A10,A11;
  i in Seg m by A7,A8;
  hence thesis by A3,A4,A6,A9,A12,Th30;
end;

theorem Th32:
  for nt,nt1 be Element of n-tuples_on NAT st nt is one-to-one &
  nt1 is one-to-one & rng nt = rng nt1 ex perm be Permutation of Seg n st nt1 =
  nt * perm
proof
  let nt,nt1 such that
A1: nt is one-to-one and
A2: nt1 is one-to-one and
A3: rng nt = rng nt1;
  reconsider nt9=nt" as Function;
A4: dom nt9 = rng nt1 by A1,A3,FUNCT_1:33;
A5: dom nt=Seg n by FINSEQ_2:124;
  rng nt9 = dom nt by A1,FUNCT_1:33;
  then
A6: rng (nt9*nt1)=Seg n by A5,A4,RELAT_1:28;
  dom nt1 = Seg n by FINSEQ_2:124;
  then dom (nt9*nt1)=Seg n by A4,RELAT_1:27;
  then reconsider nn=nt9*nt1 as Function of Seg n,Seg n by A6,FUNCT_2:1;
  nn is one-to-one onto by A1,A2,A6,FUNCT_2:def 3;
  then reconsider nn as Permutation of Seg n;
  take nn;
  thus nt * nn = (nt*nt9)*nt1 by RELAT_1:36
    .= (id rng nt1)*nt1 by A1,A3,FUNCT_1:39
    .= nt1 by RELAT_1:54;
end;

theorem Th33:
  for f be Function of Seg n,Seg n st nt1 = nt * f holds Segm(A,
  nt1,mt) = Segm(A,nt,mt) * f
proof
  let f be Function of Seg n,Seg n such that
A1: nt1 = nt * f;
  set S=Segm(A,nt,mt);
  set S1=Segm(A,nt1,mt);
  set Sf=S*f;
  now
    let i,j such that
A2: [i,j] in Indices S1;
    Indices S1=[:Seg n,Seg width S1:] by MATRIX_0:25;
    then
A3: i in Seg n by A2,ZFMISC_1:87;
    Indices S1=Indices S by MATRIX_0:26;
    then consider k such that
A4: f.i = k and
A5: [k,j] in Indices S and
A6: Sf*(i,j) = S*(k,j) by A2,MATRIX11:37;
    reconsider i9=i,j9=j,k9=k as Element of NAT by ORDINAL1:def 12;
    Seg n=dom nt1 by FINSEQ_2:124;
    then nt1.i9=nt.(f.i) by A1,A3,FUNCT_1:12;
    hence S1*(i,j) = A*(nt.k9,mt.j9) by A2,A4,Def1
      .= Sf*(i,j) by A5,A6,Def1;
  end;
  hence thesis by MATRIX_0:27;
end;

theorem Th34:
  for f be Function of Seg m,Seg m st mt1 = mt * f holds Segm(A,nt
  ,mt1)@ = Segm(A,nt,mt)@ * f
proof
  let f be Function of Seg m,Seg m such that
A1: mt1 = mt * f;
  set S=Segm(A,nt,mt);
  set S1=Segm(A,nt,mt1);
  per cases;
  suppose
A2: m=0 or n=0;
    len S=n by MATRIX_0:def 2;
    then width S=0 by A2,Th1,MATRIX_0:def 3;
    then len (S@)=0 by MATRIX_0:def 6;
    then
A3: S@={};
    len S1=n by MATRIX_0:def 2;
    then width S1=0 by A2,Th1,MATRIX_0:def 3;
    then len (S1@)=0 by MATRIX_0:def 6;
    then S1@={};
    hence thesis by A3;
  end;
  suppose
A4: m>0 & n>0;
    then
A5: width S1=m by Th1;
    then
A6: len (S1@)=m by A4,MATRIX_0:54;
    len S1=n by A4,Th1;
    then
A7: width (S1@)=n by A4,A5,MATRIX_0:54;
A8: width S=m by A4,Th1;
    len S=n by A4,Th1;
    then
A9: width (S@)=n by A4,A8,MATRIX_0:54;
    len (S@)=m by A4,A8,MATRIX_0:54;
    then reconsider S9=S@,S19=S1@ as Matrix of m,n,D by A4,A9,A7,A6,MATRIX_0:20
;
    set Sf=S9*f;
    now
      let i,j such that
A10:  [i,j] in Indices S19;
A11:  [j,i] in Indices S1 by A10,MATRIX_0:def 6;
      then
A12:  S19*(i,j) = S1*(j,i) by MATRIX_0:def 6;
      Indices S19=[:Seg m,Seg n:] by A7,MATRIX_0:25;
      then
A13:  i in Seg m by A10,ZFMISC_1:87;
      Indices S19=Indices S9 by MATRIX_0:26;
      then consider k such that
A14:  f.i=k and
A15:  [k,j] in Indices S9 and
A16:  Sf*(i,j)=S9*(k,j) by A10,MATRIX11:37;
      reconsider i9=i,j9=j,k9=k as Element of NAT by ORDINAL1:def 12;
      Seg m=dom mt1 by FINSEQ_2:124;
      then mt1.i9=mt.(f.i) by A1,A13,FUNCT_1:12;
      then
A17:  S1*(j9,i9) = A*(nt.j9,mt.k9) by A14,A11,Def1;
A18:  [j,k] in Indices S by A15,MATRIX_0:def 6;
      then S9*(k,j) = S*(j,k) by MATRIX_0:def 6;
      hence S19*(i,j)=Sf*(i,j) by A16,A18,A12,A17,Def1;
    end;
    hence thesis by MATRIX_0:27;
  end;
end;

theorem Th35:
  for perm be Element of Permutations n st nt1 = nt2 * perm holds
  Det Segm(M,nt1,nt) = -(Det Segm(M,nt2,nt),perm) & Det Segm(M,nt,nt1) = -(Det
  Segm(M,nt,nt2),perm)
proof
  let perm be Element of Permutations n such that
A1: nt1=nt2*perm;
  reconsider Perm=perm as Permutation of Seg n by MATRIX_1:def 16;
  Segm(M,nt1,nt) = Segm(M,nt2,nt) * Perm by A1,Th33;
  hence Det Segm(M,nt1,nt) = -(Det Segm(M,nt2,nt),perm) by MATRIX11:46;
  thus Det Segm(M,nt,nt1) = Det Segm(M,nt,nt1)@ by MATRIXR2:43
    .= Det (Segm(M,nt,nt2)@ * Perm) by A1,Th34
    .= -(Det (Segm(M,nt,nt2)@),perm) by MATRIX11:46
    .= -(Det Segm(M,nt,nt2),perm) by MATRIXR2:43;
end;

Lm1: rng nt = rng nt1 & nt is one-to-one implies nt1 is one-to-one
proof
  assume that
A1: rng nt = rng nt1 and
A2: nt is one-to-one;
A3: len nt1=n by CARD_1:def 7;
  len nt=n by CARD_1:def 7;
  hence thesis by A1,A2,A3,FINSEQ_4:61;
end;

theorem Th36:
  for nt,nt1,nt9,nt19 be Element of n-tuples_on NAT st rng nt =
rng nt9 & rng nt1 = rng nt19 holds Det Segm(M,nt,nt1) = Det Segm(M,nt9,nt19) or
  Det Segm(M,nt,nt1) = -Det Segm(M,nt9,nt19)
proof
  let nt,nt1,nt9,nt19 be Element of n-tuples_on NAT such that
A1: rng nt=rng nt9 and
A2: rng nt1=rng nt19;
  set S19=Segm(M,nt,nt19);
  set S9=Segm(M,nt9,nt19);
  set S=Segm(M,nt,nt1);
  per cases;
  suppose
A3: not nt is one-to-one or not nt1 is one-to-one;
    then
A4: Det S=0.K by Th27,Th31;
    not nt9 is one-to-one or not nt19 is one-to-one by A1,A2,A3,Lm1;
    hence thesis by A4,Th27,Th31;
  end;
  suppose
A5: nt is one-to-one & nt1 is one-to-one;
    then nt19 is one-to-one by A2,Lm1;
    then consider perm1 be Permutation of Seg n such that
A6: nt1 = nt19 * perm1 by A2,A5,Th32;
    nt9 is one-to-one by A1,A5,Lm1;
    then consider perm be Permutation of Seg n such that
A7: nt = nt9 * perm by A1,A5,Th32;
    reconsider perm,perm1 as Element of Permutations n by MATRIX_1:def 16;
    per cases;
    suppose
A8:   perm1 is even;
      Det S = -(Det S19,perm1) by A6,Th35;
      then
A9:   Det S=Det S19 by A8,MATRIX_1:def 20;
      Det S19 = -(Det S9,perm) by A7,Th35;
      hence thesis by A9,MATRIX_1:def 20;
    end;
    suppose
A10:  perm1 is odd;
      Det S19 = -(Det S9,perm) by A7,Th35;
      then
A11:  Det S19=Det S9 or Det S19=-Det S9 by MATRIX_1:def 20;
      Det S = -(Det S19,perm1) by A6,Th35;
      then Det S=-Det S19 by A10,MATRIX_1:def 20;
      then Det S=-Det S9 or Det S = 0.K + --Det S9 by A11,RLVECT_1:def 4;
      then Det S=-Det S9 or Det S = 0.K -(-Det S9);
      then Det S=-Det S9 or Det S +(- Det S9) =0.K by VECTSP_2:2;
      hence thesis by VECTSP_1:19;
    end;
  end;
end;

theorem Th37:
  for F,Fmt be FinSequence of D,nt,mt st len F = width A9 & Fmt =
  F * mt & [:rng nt,rng mt:] c= Indices A9 for i,j st nt"{j} = {i} holds RLine(
  Segm(A9,nt,mt),i,Fmt) = Segm(RLine(A9,j,F),nt,mt)
proof
  let F,Fmt be FinSequence of D,nt,mt such that
A1: len F = width A9 and
A2: Fmt = F * mt and
A3: [:rng nt,rng mt:]c=Indices A9;
  let i,j such that
A4: nt"{j} = {i};
A5: i in {i} by TARSKI:def 1;
  then
A6: i in dom nt by A4,FUNCT_1:def 7;
  then nt.i in rng nt by FUNCT_1:def 3;
  then rng mt={} or [:rng nt,rng mt:]<>{};
  then
A7: rng mt c= Seg width A9 by A3,ZFMISC_1:114;
  nt.i in {j} by A4,A5,FUNCT_1:def 7;
  then
A8: nt.i=j by TARSKI:def 1;
  set R=RLine(A9,j,F);
  set SR=Segm(R,nt,mt);
  set S=Segm(A9,nt,mt);
A9: dom mt=Seg m by FINSEQ_2:124;
  set RS=RLine(S,i,Fmt);
A10: Indices SR=Indices S by MATRIX_0:26;
  dom F=Seg width A9 by A1,FINSEQ_1:def 3;
  then
A11: dom Fmt=dom mt by A2,A7,RELAT_1:27;
A12: width S in NAT by ORDINAL1:def 12;
A13: n<>0 by A6;
  then width S=m by MATRIX_0:23;
  then
A14: len Fmt=width S by A11,A9,A12,FINSEQ_1:def 3;
A15: Indices A9=Indices R by MATRIX_0:26;
  now
A16: dom nt=Seg n by FINSEQ_2:124;
    let k,l such that
A17: [k,l] in Indices SR;
A18: Indices S=[:Seg n,Seg m:] by A13,MATRIX_0:23;
    then
A19: k in Seg n by A10,A17,ZFMISC_1:87;
    reconsider k9=k,l9=l as Element of NAT by ORDINAL1:def 12;
A20: SR*(k,l) = R*(nt.k9,mt.l9) by A17,Def1;
A21: [nt.k9,mt.l9] in Indices A9 by A3,A15,A17,Th17;
A22: l in dom mt by A9,A10,A17,A18,ZFMISC_1:87;
    per cases;
    suppose
A23:  k=i;
      then
A24:  RS*(k,l)= Fmt.l by A14,A10,A17,MATRIX11:def 3;
      SR*(k,l)=F.(mt.l) by A1,A8,A20,A21,A23,MATRIX11:def 3;
      hence RS*(k,l)=SR*(k,l) by A2,A22,A24,FUNCT_1:13;
    end;
    suppose
      k<>i;
      then not k in nt"{j} by A4,TARSKI:def 1;
      then not nt.k in {j} by A19,A16,FUNCT_1:def 7;
      then
A25:  nt.k<>j by TARSKI:def 1;
      then
A26:  SR*(k,l)=A9*(nt.k9,mt.l9) by A1,A20,A21,MATRIX11:def 3;
      RS*(k,l)=S*(k,l) by A8,A14,A10,A17,A25,MATRIX11:def 3;
      hence RS*(k,l)=SR*(k,l) by A10,A17,A26,Def1;
    end;
  end;
  hence thesis by MATRIX_0:27;
end;

theorem Th38:
  for F be FinSequence of D,i,nt st not i in rng nt & [:rng nt,rng
  mt:] c= Indices A9 holds Segm(A9,nt,mt) = Segm(RLine(A9,i,F),nt,mt)
proof
  let F be FinSequence of D,i,nt such that
A1: not i in rng nt and
A2: [:rng nt,rng mt:] c= Indices A9;
  set S=Segm(A9,nt,mt);
  set R=RLine(A9,i,F);
  set SR=Segm(R,nt,mt);
  per cases;
  suppose
    len F<>width A9;
    hence thesis by MATRIX11:def 3;
  end;
  suppose
A3: len F=width A9;
A4: Indices SR = Indices S by MATRIX_0:26;
    now
A5:   dom nt=Seg n by FINSEQ_2:124;
      let k,m such that
A6:   [k,m] in Indices SR;
      Indices SR=[:Seg n,Seg width SR:] by MATRIX_0:25;
      then k in Seg n by A6,ZFMISC_1:87;
      then
A7:   i <> nt.k by A1,A5,FUNCT_1:def 3;
      reconsider K=k,M=m as Element of NAT by ORDINAL1:def 12;
      [nt.K,mt.M] in Indices A9 by A2,A4,A6,Th17;
      then
A8:   A9*(nt.K,mt.M)=R*(nt.K,mt.M) by A3,A7,MATRIX11:def 3;
      S*(K,M)=A9*(nt.K,mt.M) by A4,A6,Def1;
      hence SR*(k,m)=S*(k,m) by A6,A8,Def1;
    end;
    hence thesis by MATRIX_0:27;
  end;
end;

theorem Th39:
  i in rng nt & [:rng nt,rng mt:] c= Indices A9 implies ex nt1 st
rng nt1 = rng nt\{i} \/ {j} & Segm(RLine(A9,i,Line(A9,j)),nt,mt) = Segm(A9,nt1,
  mt)
proof
  assume that
A1: i in rng nt and
A2: [:rng nt,rng mt:] c= Indices A9;
  defpred P[set,set] means for k st k=$1 holds (nt.k=i implies $2=j) & (nt.k<>
  i implies $2=nt.k);
A3: for k st k in Seg n ex x be Element of NAT st P[k,x]
  proof
    let k such that
    k in Seg n;
    per cases;
    suppose
A4:   nt.k=i;
      reconsider J=j as Element of NAT by ORDINAL1:def 12;
      take J;
      thus thesis by A4;
    end;
    suppose
A5:   nt.k<>i;
      reconsider ntk=nt.k as Element of NAT by ORDINAL1:def 12;
      take ntk;
      thus thesis by A5;
    end;
  end;
  consider p be FinSequence of NAT such that
A6: dom p = Seg n and
A7: for k being Nat st k in Seg n holds P[k,p.k] from FINSEQ_1:sch 5(A3);
  n in NAT by ORDINAL1:def 12;
  then len p = n by A6,FINSEQ_1:def 3;
  then reconsider p9=p as Element of n-tuples_on NAT by FINSEQ_2:92;
A8: rng p9 c= (rng nt\{i}) \/ {j}
  proof
    let y be object;
A9: dom nt=Seg n by FINSEQ_2:124;
    assume y in rng p9;
    then consider x be object such that
A10: x in dom p and
A11: p.x=y by FUNCT_1:def 3;
    consider k be Nat such that
A12: x=k and
    1<=k and
    k<=n by A6,A10;
    p.k=j & nt.k=i or p.k=nt.k& nt.k<>i & nt.k in rng nt by A6,A7,A10,A12,A9,
FUNCT_1:def 3;
    then p.k in {j} or p.k in rng nt & not p.k in {i} by TARSKI:def 1;
    then p.k in {j} or p.k in rng nt\{i} by XBOOLE_0:def 5;
    hence thesis by A11,A12,XBOOLE_0:def 3;
  end;
  take p9;
  (rng nt\{i}) \/ {j} c= rng p9
  proof
    let y be object such that
A13: y in (rng nt\{i}) \/ {j};
    per cases by A13,XBOOLE_0:def 3;
    suppose
A14:  y in rng nt\{i};
      then consider x be object such that
A15:  x in dom nt and
A16:  nt.x=y by FUNCT_1:def 3;
A17:  dom nt=Seg n by FINSEQ_2:124;
      then consider k be Nat such that
A18:  x=k and
      1<=k and
      k<=n by A15;
      not y in {i} by A14,XBOOLE_0:def 5;
      then y<>i by TARSKI:def 1;
      then p.k=y by A7,A15,A16,A17,A18;
      hence thesis by A6,A15,A17,A18,FUNCT_1:def 3;
    end;
    suppose
      y in {j};
      then
A19:  y=j by TARSKI:def 1;
      consider x be object such that
A20:  x in dom nt and
A21:  nt.x=i by A1,FUNCT_1:def 3;
A22:  dom nt=Seg n by FINSEQ_2:124;
      then consider k be Nat such that
A23:  x=k and
      1<=k and
      k<=n by A20;
      p.k=j by A7,A20,A21,A22,A23;
      hence thesis by A6,A20,A22,A23,A19,FUNCT_1:def 3;
    end;
  end;
  hence rng p9 =(rng nt\{i}) \/ {j} by A8,XBOOLE_0:def 10;
  set S=Segm(A9,p9,mt);
  set LA=Line(A9,j);
  set R=RLine(A9,i,LA);
  set SR=Segm(R,nt,mt);
A24: Indices A9=Indices R by MATRIX_0:26;
A25: len LA=width A9 by MATRIX_0:def 7;
A26: Indices S=Indices SR by MATRIX_0:26;
  now
    let k,l such that
A27: [k,l] in Indices SR;
    reconsider K=k,L=l as Element of NAT by ORDINAL1:def 12;
A28: SR*(K,L)=R*(nt.K,mt.L) by A27,Def1;
    Indices SR=[:Seg n,Seg width SR:] by MATRIX_0:25;
    then
A29: K in Seg n by A27,ZFMISC_1:87;
A30: nt.K=i or nt.K<>i;
A31: [nt.K,mt.L] in Indices A9 by A2,A24,A27,Th17;
    then mt.L in Seg width A9 by ZFMISC_1:87;
    then SR*(K,L)=LA.(mt.L) & p9.K=j & LA.(mt.L)=A9*(j,mt.L) or SR*(K,L)=A9*(
    nt.K,mt.L) & p9.K=nt.K by A7,A25,A31,A28,A30,A29,MATRIX11:def 3
,MATRIX_0:def 7;
    hence SR*(k,l)=S*(k,l) by A26,A27,Def1;
  end;
  hence thesis by MATRIX_0:27;
end;

theorem Th40:
  for F be FinSequence of D holds not i in Seg len A9 implies
  RLine(A9,i,F) = A9
proof
  let F be FinSequence of D;
  assume
A1: not i in Seg len A9;
  set R=RLine(A9,i,F);
  per cases;
  suppose
A2: len F=width A9;
A3: now
      let k such that
A4:   1 <= k and
A5:   k <= len A9;
A6:   k in Seg len A9 by A4,A5;
A7:   len A9=n9 by MATRIX_0:def 2;
      then
A8:   R.k=Line(R,k) by A6,MATRIX_0:52;
      Line(R,k)=Line(A9,k) by A1,A6,A7,MATRIX11:28;
      hence R.k=A9.k by A6,A7,A8,MATRIX_0:52;
    end;
    len A9=len R by A2,MATRIX11:def 3;
    hence thesis by A3;
  end;
  suppose
    len F<>width A9;
    hence thesis by MATRIX11:def 3;
  end;
end;

theorem Th41:
  [:rng nt,rng mt:] c= Indices M implies a * Segm(M,nt,mt) = Segm( a * M,nt,mt)
proof
  set Sa=Segm(a * M,nt,mt);
  set S=Segm(M,nt,mt);
  set aS=a*S;
A1: Indices (a*M)=Indices M by MATRIXR1:18;
A2: Indices Sa=Indices S by MATRIX_0:26;
  assume
A3: [:rng nt,rng mt:] c= Indices M;
  now
    let i,j such that
A4: [i,j] in Indices Sa;
A5: aS*(i,j)=a * (S*(i,j)) by A2,A4,MATRIX_3:def 5;
    reconsider i9=i,j9=j as Element of NAT by ORDINAL1:def 12;
A6: Sa*(i9,j9)=(a*M)*(nt.i,mt.j) by A4,Def1;
A7: S*(i9,j9)=M*(nt.i,mt.j) by A2,A4,Def1;
    [nt.i9,mt.j9] in Indices M by A3,A1,A4,Th17;
    hence Sa*(i,j)=aS*(i,j) by A6,A5,A7,MATRIX_3:def 5;
  end;
  hence thesis by MATRIX_0:27;
end;

theorem Th42:
  nt = idseq len A & mt = idseq width A implies Segm(A,nt,mt) = A
proof
  set S=Segm(A,nt,mt);
  assume that
A1: nt = idseq len A and
A2: mt = idseq width A;
A3: len nt=n by CARD_1:def 7;
A4: len idseq width A=width A by CARD_1:def 7;
A5: len idseq len A =len A by CARD_1:def 7;
A6: len mt=m by CARD_1:def 7;
  per cases;
  suppose
A7: n=0;
    then
A8: len S=0 by MATRIX_0:def 2;
    A={} by A1,A7;
    hence thesis by A8;
  end;
  suppose
A9: n>0;
    then
A10: width S=m by Th1;
    then
A11: Indices S=[:Seg n,Seg m:] by MATRIX_0:25;
A12: now
      let i,j such that
A13:  [i,j] in Indices S;
      reconsider i9=i,j9=j as Element of NAT by ORDINAL1:def 12;
      j in Seg m by A10,A13,ZFMISC_1:87;
      then
A14:  mt.j9=j by A2,A6,A4,FINSEQ_2:49;
      i in Seg n by A11,A13,ZFMISC_1:87;
      then nt.i9=i by A1,A3,A5,FINSEQ_2:49;
      hence S*(i,j)=A*(i,j) by A13,A14,Def1;
    end;
    len S=n by A9,Th1;
    hence thesis by A1,A2,A3,A6,A5,A4,A10,A12,MATRIX_0:21;
  end;
end;

registration
  cluster empty without_zero finite for Subset of NAT;
  existence
  proof
    {}NAT is without_zero;
    hence thesis;
  end;
  cluster non empty without_zero finite for Subset of NAT;
  existence
  proof
    {1} is Subset of NAT;
    hence thesis;
  end;
end;

registration
  let n;
  cluster Seg n -> without_zero;
  coherence
  by FINSEQ_1:1;
end;

registration
  let X be without_zero set, Y be set;
  cluster X \ Y -> without_zero;
  coherence;
end;

definition
  let i be Nat;
  redefine func {i} -> Subset of NAT;  :: redefines { (TARSKI, definition)
  coherence by ORDINAL1:def 12,ZFMISC_1:31;
  let j be Nat;
  redefine func {i,j} -> Subset of NAT;  :: redefines { (TARSKI, definition)
  coherence
  proof
    i in NAT & j in NAT by ORDINAL1:def 12;
    hence thesis by ZFMISC_1:32;
  end;
end;

theorem Th43:
  for N be finite without_zero Subset of NAT holds N is included_in_Seg
proof
  let N be finite without_zero Subset of NAT;
  consider k be Nat such that
A1: for n be Nat st n in N holds n<=k by STIRL2_1:56;
  take k;
  N c= Seg k
  proof
    let x be object;
    assume
A2: x in N;
    then consider n be Element of NAT such that
A3: n=x;
A4: n>=1 by A2,A3,NAT_1:14;
    n<=k by A1,A2,A3;
    hence thesis by A3,A4;
  end;
  hence thesis;
end;

registration
  cluster finite without_zero -> included_in_Seg for Subset of NAT;
  coherence by Th43;
end;

definition
  let N be finite without_zero Subset of NAT;
  redefine func Sgm N -> Element of (card N)-tuples_on NAT;  :: redefines Sgm (FINSEQ_1, definition)
  coherence
  proof
    len(Sgm N)=card N by FINSEQ_3:39;
    hence thesis by FINSEQ_2:92;
  end;
end;

definition
  let D be non empty set,A be Matrix of D;
  let P,Q be without_zero finite Subset of NAT;
  func Segm(A,P,Q) -> Matrix of card P,card Q,D equals
  Segm(A,Sgm P,Sgm Q);
  coherence;
end;

theorem Th44:
  Segm(A,{i0},{j0}) = <*<* A*(i0,j0) *>*>
proof
A1: card {j0}=1 by CARD_1:30;
A2: Sgm {i0}=<*i0*> by FINSEQ_3:44;
A3: <*j0*>.1=j0;
A4: <*i0*>.1=i0;
A5: Sgm {j0}=<*j0*> by FINSEQ_3:44;
  card {i0}= 1 by CARD_1:30;
  hence thesis by A1,A2,A5,A4,A3,Th21;
end;

theorem Th45:
  i0 < j0 & n0 < m0 implies Segm(A,{i0,j0},{n0,m0}) = ( A*(i0,n0),
  A*(i0,m0) )][( A*(j0,n0),A*(j0,m0) )
proof
  assume that
A1: i0 < j0 and
A2: n0 < m0;
A3: card {n0,m0}=2 by A2,CARD_2:57;
A4: Sgm {n0,m0}=<*n0,m0*> by A2,FINSEQ_3:45;
  then
A5: Sgm {n0,m0}.1=n0;
A6: Sgm {i0,j0}=<*i0,j0*> by A1,FINSEQ_3:45;
  then
A7: Sgm {i0,j0}.1=i0;
A8: Sgm {i0,j0}.2=j0 by A6;
A9: Sgm {n0,m0}.2=m0 by A4;
  card {i0,j0}= 2 by A1,CARD_2:57;
  hence thesis by A3,A5,A9,A7,A8,Th23;
end;

reserve P,P1,P2,Q,Q1,Q2 for without_zero finite Subset of NAT;

theorem Th46:
  Segm(A,Seg len A,Seg width A) = A
proof
A1: Sgm Seg width A=idseq width A by FINSEQ_3:48;
  Sgm Seg len A=idseq len A by FINSEQ_3:48;
  hence thesis by A1,Th42;
end;

theorem Th47:
  i in Seg card P & Q c= Seg width A implies Line(Segm(A,P,Q),i) =
  Line(A,Sgm P.i) * Sgm Q
proof
  rng (Sgm Q)=Q by FINSEQ_1:def 14;
  hence thesis by Th24;
end;

theorem Th48:
  i in Seg card P implies Line(Segm(A,P,Seg width A),i) = Line(A, Sgm P.i)
proof
  assume
A1: i in Seg card P;
  set S=Seg width A;
  set sP=Sgm P;
  len Line(A,sP.i)=width A by MATRIX_0:def 7;
  then
A2: dom Line(A,sP.i)=S by FINSEQ_1:def 3;
  Sgm S = idseq width A by FINSEQ_3:48;
  then Line(A,sP.i) * Sgm S = Line(A,sP.i) by A2,RELAT_1:52;
  hence thesis by A1,Th47;
end;

theorem Th49:
  j in Seg card Q & P c= Seg len A implies Col(Segm(A,P,Q),j) =
  Col(A,Sgm Q.j) * Sgm P
proof
  rng (Sgm P)=P by FINSEQ_1:def 14;
  hence thesis by Th28;
end;

theorem Th50:
  j in Seg card Q implies Col(Segm(A,Seg len A,Q),j) = Col(A,Sgm Q .j)
proof
  assume
A1: j in Seg card Q;
  set S=Seg len A;
  set sQ=Sgm Q;
  len Col(A,sQ.j)=len A by MATRIX_0:def 8;
  then
A2: dom Col(A,sQ.j)=S by FINSEQ_1:def 3;
  Sgm S = idseq len A by FINSEQ_3:48;
  then Col(A,sQ.j) * Sgm S = Col(A,sQ.j) by A2,RELAT_1:52;
  hence thesis by A1,Th49;
end;

theorem Th51:
  Segm(A,Seg len A \ {i},Seg width A) = Del(A,i)
proof
  set SLA=Seg len A;
  set Si=SLA\{i};
  set S= Segm(A,Si,Seg width A);
A1: dom A=SLA by FINSEQ_1:def 3;
  per cases;
  suppose
A2: not i in dom A;
    then
A3: Del(A,i)=A by FINSEQ_3:104;
    Si=SLA by A1,A2,ZFMISC_1:57;
    hence thesis by A3,Th46;
  end;
  suppose
A4: i in dom A;
    then consider m such that
A5: len A = m + 1 and
A6: len Del(A,i) = m by FINSEQ_3:104;
    reconsider m as Element of NAT by ORDINAL1:def 12;
    card SLA = m+1 by A5,FINSEQ_1:57;
    then
A7: card Si=m by A1,A4,STIRL2_1:55;
A8: now
      reconsider A9=A as Matrix of m+1,width A,D by A5,MATRIX_0:20;
      let j such that
A9:   1<=j and
A10:  j<=m;
A11:  j in Seg m by A9,A10;
A12:  dom A=Seg len A by FINSEQ_1:def 3;
A13:  Del(A,i)=A*Sgm Si by A1,FINSEQ_3:def 2;
A14:  dom Del(A,i)=Seg m by A6,FINSEQ_1:def 3;
      then
A15:  Sgm Si.j in dom A by A11,A13,FUNCT_1:11;
      Del(A,i).j=A9.(Sgm Si.j) by A14,A11,A13,FUNCT_1:12;
      hence Del(A,i).j = Line(A9,Sgm Si.j) by A5,A15,A12,MATRIX_0:52
        .= Line(S,j) by A7,A11,Th48
        .= S.j by A7,A11,MATRIX_0:52;
    end;
    len S=m by A7,MATRIX_0:def 2;
    hence thesis by A6,A8;
  end;
end;

theorem Th52:
  Segm(M,Seg len M,Seg width M\{i}) = DelCol(M,i)
proof
  set SW=Seg width M;
  set Si=SW\{i};
  set SL=Seg len M;
  set SEGM=Segm(M,SL,Si);
  set D=DelCol(M,i);
  card SL=len M by FINSEQ_1:57;
  then
A1: len SEGM=len M by MATRIX_0:def 2;
A2: now
    let j such that
A3: 1<=j and
A4: j<=len M;
A5: j in Seg len M by A3,A4;
    then
A6: j in dom M by FINSEQ_1:def 3;
    Sgm SL=idseq len M by FINSEQ_3:48;
    then
A7: Sgm SL.j=j by A5,FINSEQ_2:49;
    len Line(M,j)=width M by MATRIX_0:def 7;
    then
A8: dom Line(M,j)=SW by FINSEQ_1:def 3;
A9: card SL=len M by FINSEQ_1:57;
    then
A10: Line(SEGM,j)=SEGM.j by A5,MATRIX_0:52;
    Line(SEGM,j) = Line(M,Sgm SL.j) * Sgm Si by A9,A5,Th47,XBOOLE_1:36;
    then SEGM.j = Del(Line(M,j),i) by A7,A10,A8,FINSEQ_3:def 2;
    hence SEGM.j=D.j by A6,MATRIX_0:def 13;
  end;
  len D=len M by MATRIX_0:def 13;
  hence thesis by A1,A2;
end;

theorem Th53:
  Sgm P " X is without_zero finite Subset of NAT
proof
A1: Sgm P " X c= dom (Sgm P) by RELAT_1:132;
  dom (Sgm P) = Seg card P by FINSEQ_3:40;
  then not 0 in Sgm P"X by A1;
  hence thesis by A1,MEASURE6:def 2,XBOOLE_1:1;
end;

theorem Th54:
  X c= P implies Sgm X = Sgm P * Sgm (Sgm P " X)
proof
  assume
A1: X c= P;
A2: Sgm P " X c= dom Sgm P by RELAT_1:132;
A3:  P is included_in_Seg;
A4: rng Sgm P=P by FINSEQ_1:def 14;
  rng ((Sgm P) | (Sgm P " X)) = (Sgm P).:(Sgm P " X) by RELAT_1:115
    .= X by A1,A4,FUNCT_1:77;
  hence thesis by A3,A2,FINSEQ_6:129;
end;

Lm2: X c= P implies card X = card (Sgm P " X)
proof
  assume
A1: X c= P;
  rng Sgm P=P by FINSEQ_1:def 14;
  then
A3: Sgm P.:(Sgm P " X) = X by A1,FUNCT_1:77;
A4: Sgm P " X c= dom Sgm P by RELAT_1:132;
  Sgm P is one-to-one by FINSEQ_3:92;
  then X,Sgm P " X are_equipotent by A3,A4,CARD_1:33;
  hence thesis by CARD_1:5;
end;

theorem Th55:
  [:Sgm P " X,Sgm Q " Y:] c= Indices Segm(A,P,Q)
proof
  set SP=Sgm P;
  set SQ=Sgm Q;
  set I=Indices Segm(A,P,Q);
A1: now
    per cases;
    suppose
A2:   card P=0;
      then Seg card P = {};
      then [:Seg card P,Seg card Q:]={} by ZFMISC_1:90;
      hence [:Seg card P,Seg card Q:]=I by A2,MATRIX_0:22;
    end;
    suppose
      card P>0;
      hence [:Seg card P,Seg card Q:]=I by MATRIX_0:23;
    end;
  end;
  dom SQ=Seg card Q by FINSEQ_3:40;
  then
A3: SQ " Y c= Seg card Q by RELAT_1:132;
  dom SP=Seg card P by FINSEQ_3:40;
  then SP " X c= Seg card P by RELAT_1:132;
  hence thesis by A3,A1,ZFMISC_1:96;
end;

theorem Th56:
  P c= P1 & Q c= Q1 & P2 = Sgm P1 " P & Q2 = Sgm Q1 " Q implies [:
rng Sgm P2,rng Sgm Q2:] c= Indices Segm(A,P1,Q1) & Segm(Segm(A,P1,Q1),P2,Q2) =
  Segm(A,P,Q)
proof
  assume that
A1: P c= P1 and
A2: Q c= Q1 and
A3: P2 = Sgm P1 " P and
A4: Q2 = Sgm Q1 " Q;
  set SA=Segm(A,P1,Q1);
A5: card Q=card Q2 by A2,A4,Lm2;
  card P=card P2 by A1,A3,Lm2;
  then reconsider SAA=Segm(SA,P2,Q2) as Matrix of card P,card Q,D by A5;
  set Sq2=Sgm Q2;
  set Sp2=Sgm P2;
  set Sq1=Sgm Q1;
  set Sp1=Sgm P1;
  set S=Segm(A,P,Q);
A7: rng Sq2=Q2 by FINSEQ_1:def 14;
  rng Sp2=P2 by FINSEQ_1:def 14;
  hence
A9: [:rng Sp2,rng Sq2:] c= Indices SA by A3,A4,A7,Th55;
  now
A10: Sq1*Sq2=Sgm Q by A2,A4,Th54;
    let i,j such that
A11: [i,j] in Indices S;
A12: [i,j] in Indices SAA by A11,MATRIX_0:26;
    then
A13: j in Seg width SAA by ZFMISC_1:87;
    reconsider Sp2i=Sp2.i,Sq2j=Sq2.j as Element of NAT by ORDINAL1:def 12;
A14: Sp1*Sp2=Sgm P by A1,A3,Th54;
    Indices SAA=[:Seg card P2,Seg width SAA:] by MATRIX_0:25;
    then
A15: i in Seg card P2 by A12,ZFMISC_1:87;
    then card P2 <> 0;
    then width SAA = card Q2 by Th1;
    then j in dom Sq2 by A13,FINSEQ_3:40;
    then
A16: Sq1.Sq2j=Sgm Q.j by A10,FUNCT_1:13;
    reconsider i9=i,j9=j as Element of NAT by ORDINAL1:def 12;
A17: [i9,j9] in Indices SAA by A11,MATRIX_0:26;
    then
A18: SAA*(i,j)=SA*(Sp2i,Sq2j) by Def1;
    i in dom Sp2 by A15,FINSEQ_3:40;
    then
A19: Sp1.Sp2i=Sgm P.i by A14,FUNCT_1:13;
    [Sp2i,Sq2j] in Indices SA by A9,A17,Th17;
    then SAA*(i,j)=A*(Sp1.Sp2i,Sq1.Sq2j) by A18,Def1;
    hence S*(i,j) = SAA*(i,j) by A11,A19,A16,Def1;
  end;
  hence thesis by MATRIX_0:27;
end;

theorem Th57:
  (P = {} iff Q={}) & [:P,Q:] c= Indices Segm(A,P1,Q1) implies ex
P2,Q2 st P2 c= P1 & Q2 c= Q1 & P2 = Sgm P1.:P & Q2=Sgm Q1.:Q & card P2=card P &
  card Q2=card Q & Segm(Segm(A,P1,Q1),P,Q) = Segm(A,P2,Q2)
proof
  assume that
A1: P = {} iff Q={} and
A2: [:P,Q:] c= Indices Segm(A,P1,Q1);
  set S=Segm(A,P1,Q1);
A3: now
    per cases;
    suppose
      P={};
      hence P c= Seg card P1 & Q c= Seg card Q1 by A1;
    end;
    suppose
A4:   P<>{};
      then
A5:   Q c= Seg width S by A2,ZFMISC_1:114;
A6:   len S=card P1 by MATRIX_0:def 2;
A7:   Indices S=[:Seg len S,Seg width S:] by FINSEQ_1:def 3;
      then len S<>0 by A1,A2,A4;
      hence P c= Seg card P1 & Q c= Seg card Q1 by A1,A2,A7,A5,A6,Th1,
ZFMISC_1:114;
    end;
  end;
  set SQ=Sgm Q1;
  set SP=Sgm P1;
A9: SP is one-to-one by FINSEQ_3:92;
A11: SQ is one-to-one by FINSEQ_3:92;
A12: rng SQ=Q1 by FINSEQ_1:def 14;
  then
A13: SQ.:Q c= Q1 by RELAT_1:111;
  then
A14: not 0 in SQ.:Q;
  rng SP=P1 by FINSEQ_1:def 14;
  then
A15: SP.:P c= P1 by RELAT_1:111;
  then not 0 in SP.:P;
  then reconsider
  P2=SP.:P,Q2=SQ.:Q as without_zero finite Subset of NAT by A15,A13,A14,
MEASURE6:def 2,XBOOLE_1:1;
A16: dom SQ=Seg card Q1 by FINSEQ_3:40;
  then
A17: SQ " Q2 = Q by A3,A11,FUNCT_1:94;
A18: dom SP=Seg card P1 by FINSEQ_3:40;
  then P,P2 are_equipotent by A3,A9,CARD_1:33;
  then
A19: card P=card P2 by CARD_1:5;
  Q,Q2 are_equipotent by A3,A16,A11,CARD_1:33;
  then
A20: card Q=card Q2 by CARD_1:5;
  SP " P2 = P by A3,A18,A9,FUNCT_1:94;
  then Segm(Segm(A,P1,Q1),P,Q)=Segm(A,P2,Q2) by A15,A13,A17,Th56;
  hence thesis by A12,A15,A19,A20,RELAT_1:111;
end;

theorem Th58:
  for M be Matrix of n,K holds Segm(M,Seg n\{i},Seg n\{j}) = Deleting(M,i,j)
proof
  let M be Matrix of n,K;
A1: width M=n by MATRIX_0:24;
A2: len M = n by MATRIX_0:24;
  then
A3: dom M=Seg n by FINSEQ_1:def 3;
  per cases;
  suppose
A4: not i in Seg n;
    then
A5: Seg n=Seg n\{i} by ZFMISC_1:57;
    Del(M,i)=M by A3,A4,FINSEQ_3:104;
    hence thesis by A2,A1,A5,Th52;
  end;
  suppose
A6: i in Seg n;
    set Q1=Seg n;
    set Q=Seg n\{j};
    set P=Seg n\{i};
    set SS=Segm(M,P,Q1);
    consider m such that
A7: len M = m + 1 and
A8: len Del(M,i) = m by A3,A6,FINSEQ_3:104;
    per cases;
    suppose
A9:   m=0;
      then len Deleting(M,i,j) = 0 by A8,MATRIX_0:def 13;
      then
A10:  Deleting(M,i,j) = {};
A11:  Q1\{1} = {} by A2,A7,A9,FINSEQ_1:2,XBOOLE_1:37;
      i = 1 by A2,A6,A7,A9,FINSEQ_1:2,TARSKI:def 1;
      then len Segm(M,P,Q) = 0 by A11,MATRIX_0:def 2;
      hence thesis by A10;
    end;
    suppose
      m>0;
      then n > 1+0 by A2,A7,XREAL_1:8;
      then
A12:  n = width DelLine(M,i) by A2,A1,LAPLACE:4;
A13:  Q c= Seg n by XBOOLE_1:36;
A14:  rng Sgm P = P by FINSEQ_1:def 14;
      dom Sgm P = Seg card P by FINSEQ_3:40;
      then
A15:  Sgm P"P = Seg card P by A14,RELAT_1:134
        .= Seg len SS by MATRIX_0:def 2;
A16:  SS = Del(M,i) by A2,A1,Th51;
      then
A17:  Deleting(M,i,j)=Segm(SS,Seg len SS,Seg width SS\{j}) by Th52;
      Sgm Q1 =idseq n by FINSEQ_3:48;
      then Sgm Q1"Q =Seg width SS\{j} by A13,A12,A16,FUNCT_2:94;
      hence thesis by A13,A15,A17,Th56;
    end;
  end;
end;

theorem Th59:
  for F,FQ be FinSequence of D st len F = width A9 &
  FQ = F * Sgm Q & [:P,Q:] c= Indices A9 holds
  RLine(Segm(A9,P,Q),i,FQ) = Segm(RLine(A9,Sgm P. i,F),P,Q)
proof
  let F,FQ be FinSequence of D such that
A1: len F = width A9 and
A2: FQ = F * Sgm Q and
A3: [:P,Q:] c= Indices A9;
  set SQ=Sgm Q;
  set SP=Sgm P;
A4: card P=len Segm(A9,P,Q) by MATRIX_0:def 2;
A5: rng SQ=Q by FINSEQ_1:def 14;
A7: rng SP=P by FINSEQ_1:def 14;
A8: SP is one-to-one by FINSEQ_3:92;
A9: dom SP=Seg card P by FINSEQ_3:40;
  per cases;
  suppose
    i in dom SP;
    then SP"{SP.i} = {i} by A8,FINSEQ_5:4;
    hence thesis by A1,A2,A3,A7,A5,Th37;
  end;
  suppose
A10: not i in dom SP;
A11: not 0 in Seg len A9;
    SP.i=0 by A10,FUNCT_1:def 2;
    hence Segm(RLine(A9,SP.i,F),P,Q) = Segm(A9,P,Q) by A11,Th40
      .= RLine(Segm(A9,P,Q),i,FQ) by A9,A4,A10,Th40;
  end;
end;

theorem Th60:
  for F be FinSequence of D,i,P st not i in P & [:P,Q:] c= Indices A9
  holds Segm(A9,P,Q) = Segm(RLine(A9,i,F),P,Q)
proof
  let F be FinSequence of D,i,P such that
A1: not i in P and
A2: [:P,Q:] c= Indices A9;
  rng Sgm Q=Q & rng Sgm P=P by FINSEQ_1:def 14;
  hence thesis by A1,A2,Th38;
end;

theorem
  [:P,Q:] c= Indices A & (card P=0 iff card Q=0) implies
  Segm(A,P,Q)@ = Segm(A@,Q,P)
proof
  rng Sgm Q=Q & rng Sgm P=P by FINSEQ_1:def 14;
  hence thesis by Th18;
end;

theorem Th62:
  [:P,Q:] c= Indices A & (card Q=0 implies card P = 0) implies
  Segm(A,P,Q) = Segm(A@,Q,P)@
proof
  rng Sgm Q=Q & rng Sgm P=P by FINSEQ_1:def 14;
  hence thesis by Th19;
end;

theorem Th63:
  [:P,Q:] c= Indices M implies a * Segm(M,P,Q) = Segm(a * M,P,Q)
proof
  rng Sgm P=P & rng Sgm Q=Q by FINSEQ_1:def 14;
  hence thesis by Th41;
end;

definition
  let D be non empty set,A be Matrix of D;
  let P,Q be without_zero finite Subset of NAT;
  assume
A1: card P = card Q;
  func EqSegm(A,P,Q) -> Matrix of card P,D equals
  :Def3:
  Segm(A,P,Q);
  coherence by A1;
end;

theorem Th64:
  for P,Q,i,j st i in Seg card P & j in Seg card P & card P = card
Q holds Delete(EqSegm(M,P,Q),i,j) = EqSegm(M,P\{Sgm P.i},Q\{Sgm Q.j}) & card (P
  \{Sgm P.i}) = card (Q\{Sgm Q.j})
proof
  let P1,Q1,i,j such that
A1: i in Seg card P1 and
A2: j in Seg card P1 and
A3: card P1 = card Q1;
  set SQ1=Sgm Q1;
A5: dom SQ1=Seg card Q1 by FINSEQ_3:40;
A6: rng SQ1=Q1 by FINSEQ_1:def 14;
  then
A7: SQ1"Q1 = Seg card P1 by A3,A5,RELAT_1:134;
  set Q=Q1\{SQ1.j};
  set Q2=Seg card Q1\{j};
A8: Q c= Q1 by XBOOLE_1:36;
  set SP1=Sgm P1;
A10: dom SP1=Seg card P1 by FINSEQ_3:40;
A11: rng SP1=P1 by FINSEQ_1:def 14;
  then
A12: SP1"P1 = Seg card P1 by A10,RELAT_1:134;
  SQ1 is one-to-one by FINSEQ_3:92;
  then SQ1"{SQ1.j}={j} by A2,A3,A5,FINSEQ_5:4;
  then
A13: Q2 = SQ1 " Q by A3,A7,FUNCT_1:69;
A14: SP1.i in P1 by A1,A10,A11,FUNCT_1:def 3;
  set P2=Seg card P1\{i};
  set P=P1\{SP1.i};
  SP1 is one-to-one by FINSEQ_3:92;
  then SP1"{SP1.i}={i} by A1,A10,FINSEQ_5:4;
  then
A15: P2 = SP1 " P by A12,FUNCT_1:69;
  set E=EqSegm(M,P1,Q1);
A16: P c= P1 by XBOOLE_1:36;
  card P1<>0 by A1;
  then reconsider C=card P1-1 as Element of NAT by NAT_1:20;
A17: card P1=C+1;
  SQ1.j in Q1 by A2,A3,A5,A6,FUNCT_1:def 3;
  then
A18: card Q = C by A3,A17,STIRL2_1:55;
  Delete(E,i,j)=Deleting(E,i,j) by A1,A2,LAPLACE:def 1
    .=Segm(E,P2,Q2) by A3,Th58
    .=Segm(Segm(M,P1,Q1),P2,Q2) by A3,Def3
    .=Segm(M,P,Q) by A16,A8,A15,A13,Th56
    .=EqSegm(M,P,Q) by A14,A17,A18,Def3,STIRL2_1:55;
  hence thesis by A14,A17,A18,STIRL2_1:55;
end;

Lm3: for M,P,Q,i st i in Seg card P & Det EqSegm(M,P,Q)<>0.K ex j st j in Seg
card P & Det Delete(EqSegm(M,P,Q),i,j) <> 0.K
proof
  let M,P,Q,i such that
A1: i in Seg card P and
A2: Det EqSegm(M,P,Q) <> 0.K;
  set C=card P;
  set E=EqSegm(M,P,Q);
  set LL=LaplaceExpL(E,i);
  set CC=C |-> 0.K;
  Sum CC=0.K by MATRIX_3:11;
  then
A3: LL<>CC by A1,A2,LAPLACE:25;
  len LL=C by LAPLACE:def 7;
  then
A4: dom LL=Seg C by FINSEQ_1:def 3;
  consider j such that
A5: j in dom LL and
A6: LL.j <> CC.j by A3,A4;
A7: LL.j=E*(i,j)*Cofactor(E,i,j) by A5,LAPLACE:def 7;
  CC.j=0.K by A4,A5,FINSEQ_2:57;
  then Cofactor(E,i,j)<>0.K by A6,A7;
  then Minor(E,i,j)<>0.K;
  hence thesis by A4,A5;
end;

theorem Th65:
  for M,P,P1,Q1 st card P1 = card Q1 & P c= P1 & Det EqSegm(M,P1,
  Q1) <> 0.K ex Q st Q c= Q1 & card P = card Q & Det EqSegm(M,P,Q) <> 0.K
proof
  let M,P,P1,Q1 such that
A1: card P1 = card Q1 and
A2: P c= P1 and
A3: Det EqSegm(M,P1,Q1) <> 0.K;
  defpred Q[Nat] means for P st P c= P1 & card P=$1 ex Q st Q c= Q1 & card P=
  card Q & Det EqSegm(M,P,Q) <> 0.K;
A4: for k be Element of NAT st k < card P1 & Q[k+1] holds Q[k]
  proof
    let k be Element of NAT such that
A5: k < card P1 and
A6: Q[k+1];
    let P such that
A7: P c= P1 and
A8: card P=k;
    P c< P1 by A5,A7,A8,XBOOLE_0:def 8;
    then P1\P<>{} by XBOOLE_1:105;
    then consider x being object such that
A9: x in P1\P by XBOOLE_0:def 1;
    reconsider x as non zero Element of NAT by A9;
    reconsider Px=P\/{x} as without_zero finite Subset of NAT;
A10: not x in P by A9,XBOOLE_0:def 5;
    then
A11: card Px=k+1 by A8,CARD_2:41;
    x in P1 by A9,XBOOLE_0:def 5;
    then {x} c= P1 by ZFMISC_1:31;
    then Px c= P1 by A7,XBOOLE_1:8;
    then consider Q2 such that
A12: Q2 c= Q1 and
A13: card Px=card Q2 and
A14: Det EqSegm(M,Px,Q2) <> 0.K by A6,A8,A10,CARD_2:41;
    set E=EqSegm(M,Px,Q2);
A15: Px\{x}=P by A10,ZFMISC_1:117;
    x in {x} by TARSKI:def 1;
    then
A16: x in Px by XBOOLE_0:def 3;
A18: dom Sgm Px = Seg card Px by FINSEQ_3:40;
    rng Sgm Px = Px by FINSEQ_1:def 14;
    then consider i be object such that
A19: i in Seg card Px and
A20: Sgm Px.i=x by A18,A16,FUNCT_1:def 3;
A21: k+1-'1=k+1-1 by XREAL_0:def 2;
    reconsider i as Element of NAT by A19;
    consider j such that
A22: j in Seg card Px and
A23: Det Delete(E,i,j) <> 0.K by A14,A19,Lm3;
    take Q=Q2\{Sgm Q2.j};
    Q c= Q2 by XBOOLE_1:36;
    hence thesis by A8,A11,A12,A13,A19,A20,A22,A23,A15,A21,Th64;
  end;
A24: Q[card P1]
  proof
    let P;
    assume that
A25: P c= P1 and
A26: card P=card P1;
    P=P1 by A25,A26,CARD_2:102;
    hence thesis by A1,A3;
  end;
  for k be Element of NAT st k <= card P1 holds Q[k]
   from PRE_POLY:sch 1(A24,A4);
  hence thesis by A2,NAT_1:43;
end;

Lm4: for M,P,Q,i st j in Seg card P & Det EqSegm(M,P,Q)<>0.K ex i st i in Seg
card P & Det Delete(EqSegm(M,P,Q),i,j) <> 0.K
proof
  let M,P,Q,i such that
A1: j in Seg card P and
A2: Det EqSegm(M,P,Q) <> 0.K;
  set C=card P;
  set E=EqSegm(M,P,Q);
  set LC=LaplaceExpC(E,j);
  set CC=C |-> 0.K;
  Sum CC=0.K by MATRIX_3:11;
  then
A3: LC<>CC by A1,A2,LAPLACE:27;
  len LC=C by LAPLACE:def 8;
  then
A4: dom LC=Seg C by FINSEQ_1:def 3;
  consider i such that
A5: i in dom LC and
A6: LC.i <> CC.i by A3,A4;
A7: LC.i=E*(i,j)*Cofactor(E,i,j) by A5,LAPLACE:def 8;
  CC.i=0.K by A4,A5,FINSEQ_2:57;
  then Cofactor(E,i,j)<>0.K by A6,A7;
  then Minor(E,i,j)<>0.K;
  hence thesis by A4,A5;
end;

theorem
  for M,P1,Q,Q1 st card P1 = card Q1 & Q c= Q1 & Det EqSegm(M,P1,Q1) <>
  0.K ex P st P c= P1 & card P = card Q & Det EqSegm(M,P,Q) <> 0.K
proof
  let M,P1,Q,Q1 such that
A1: card P1 = card Q1 and
A2: Q c= Q1 and
A3: Det EqSegm(M,P1,Q1) <> 0.K;
  defpred R[Nat] means for Q st Q c= Q1 & card Q=$1 ex P st P c= P1 & card P=
  card Q & Det EqSegm(M,P,Q) <> 0.K;
A4: for k be Element of NAT st k < card Q1 & R[k+1] holds R[k]
  proof
    let k be Element of NAT such that
A5: k < card Q1 and
A6: R[k+1];
    let Q such that
A7: Q c= Q1 and
A8: card Q=k;
    Q c< Q1 by A5,A7,A8,XBOOLE_0:def 8;
    then Q1\Q<>{} by XBOOLE_1:105;
    then consider x being object such that
A9: x in Q1\Q by XBOOLE_0:def 1;
    reconsider x as non zero Element of NAT by A9;
    reconsider Qx=Q\/{x} as without_zero finite Subset of NAT;
A10: not x in Q by A9,XBOOLE_0:def 5;
    then
A11: card Qx=k+1 by A8,CARD_2:41;
    x in Q1 by A9,XBOOLE_0:def 5;
    then {x} c= Q1 by ZFMISC_1:31;
    then Qx c= Q1 by A7,XBOOLE_1:8;
    then consider P2 such that
A12: P2 c= P1 and
A13: card Qx=card P2 and
A14: Det EqSegm(M,P2,Qx) <> 0.K by A6,A8,A10,CARD_2:41;
A15: k+1-'1=k+1-1 by XREAL_0:def 2;
    x in {x} by TARSKI:def 1;
    then
A16: x in Qx by XBOOLE_0:def 3;
A18: dom Sgm Qx = Seg card Qx by FINSEQ_3:40;
    rng Sgm Qx = Qx by FINSEQ_1:def 14;
    then consider j be object such that
A19: j in Seg card Qx and
A20: Sgm Qx.j=x by A18,A16,FUNCT_1:def 3;
    set E=EqSegm(M,P2,Qx);
    reconsider j as Element of NAT by A19;
    consider i such that
A21: i in Seg card Qx and
A22: Det Delete(E,i,j) <> 0.K by A13,A14,A19,Lm4;
    take P=P2\{Sgm P2.i};
A23: P c= P2 by XBOOLE_1:36;
A24: Qx\{x}=Q by A10,ZFMISC_1:117;
    then card P=card Q by A13,A19,A20,A21,Th64;
    hence thesis by A8,A11,A12,A13,A19,A20,A21,A22,A24,A23,A15,Th64;
  end;
A25: R[card Q1]
  proof
    let Q;
    assume that
A26: Q c= Q1 and
A27: card Q=card Q1;
    Q=Q1 by A26,A27,CARD_2:102;
    hence thesis by A1,A3;
  end;
  for k be Element of NAT st k <= card Q1 holds R[k]
   from PRE_POLY:sch 1(A25,A4);
  hence thesis by A2,NAT_1:43;
end;

theorem Th67:
  card P=card Q implies ([:P,Q:] c= Indices A iff P c= Seg len A &
  Q c= Seg width A)
proof
A1: Indices A=[:Seg len A,Seg width A:] by FINSEQ_1:def 3;
  assume
A2: card P = card Q;
  thus [:P,Q:] c= Indices A implies P c= Seg len A & Q c= Seg width A
  proof
    assume
A3: [:P,Q:] c= Indices A;
    per cases;
    suppose
      [:P,Q:]<>{};
      hence thesis by A1,A3,ZFMISC_1:114;
    end;
    suppose
A4:   [:P,Q:]={};
      then
A5:   Q={} by A2,CARD_1:27,ZFMISC_1:90;
      P={} by A2,A4,CARD_1:27,ZFMISC_1:90;
      hence thesis by A5;
    end;
  end;
  thus thesis by A1,ZFMISC_1:96;
end;

theorem Th68:
  for P,Q,i,j0 st j0 in Seg n9 & i in P & not j0 in P & card P =
card Q & [:P,Q:] c= Indices M9 holds card P = card (P\{i}\/{j0}) & [:P\{i}\/{j0
},Q:] c= Indices M9 & (Det EqSegm(RLine(M9,i,Line(M9,j0)),P,Q) = Det EqSegm(M9,
P\{i}\/{j0},Q) or Det EqSegm(RLine(M9,i,Line(M9,j0)),P,Q) = -Det EqSegm(M9,P\{i
  }\/{j0},Q))
proof
  let P,Q,i,j0 such that
A1: j0 in Seg n9 and
A2: i in P and
A3: not j0 in P and
A4: card P = card Q and
A5: [:P,Q:] c= Indices M9;
  set Pi=P\{i};
A6: Pi c= P by XBOOLE_1:36;
  set SQ=Sgm Q;
  set Pij=Pi\/{j0};
  set SPij=Sgm Pij;
A7: rng SPij=Pij by FINSEQ_1:def 14;
  card P>0 by A2;
  then reconsider C=card P - 1 as Element of NAT by NAT_1:20;
  card P=C+1;
  then
A8: card Pi=C by A2,STIRL2_1:55;
  not j0 in Pi by A3,XBOOLE_0:def 5;
  hence
A9: card Pij = C+1 by A8,CARD_2:41
    .= card P;
  then reconsider SPij,SQ9=SQ as Element of (card P)-tuples_on NAT by A4;
A10: Segm(M9,SPij,SQ9) = Segm(M9,Pij,Q) by A4,A9
    .= EqSegm(M9,Pij,Q) by A4,A9,Def3;
  P c= Seg len M9 by A4,A5,Th67;
  then
A11: Pi c= Seg len M9 by A6;
  n9=len M9 by MATRIX_0:def 2;
  then {j0} c= Seg len M9 by A1,ZFMISC_1:31;
  then
A12: Pij c= Seg len M9 by A11,XBOOLE_1:8;
  set SP=Sgm P;
A13: rng SQ=Q by FINSEQ_1:def 14;
  rng SP=P by FINSEQ_1:def 14;
  then consider PT be Element of (card P)-tuples_on NAT such that
A14: rng PT=Pij and
A15: Segm(RLine(M9,i,Line(M9,j0)),SP,SQ) = Segm(M9,PT,SQ) by A2,A5,A13,Th39;
  Q c= Seg width M9 by A4,A5,Th67;
  hence [:Pij,Q:] c= Indices M9 by A4,A9,A12,Th67;
  EqSegm(RLine(M9,i,Line(M9,j0)),P,Q) = Segm(RLine(M9,i,Line(M9,j0)),P,Q)
  by A4,Def3
    .= Segm(M9,PT,SQ9) by A4,A15;
  hence thesis by A9,A7,A13,A14,A10,Th36;
end;

theorem Th69:
  card P = card Q implies ([:P,Q:] c= Indices A iff [:Q,P:] c= Indices A@)
proof
  assume
A1: card P = card Q;
  per cases;
  suppose
A2: Q={};
    then
A3: [:Q,P:] = {} by ZFMISC_1:90;
    [:P,Q:] = {} by A2,ZFMISC_1:90;
    hence thesis by A3;
  end;
  suppose
A4: Q<>{};
    thus [:P,Q:] c= Indices A implies [:Q,P:] c= Indices A@
    proof
      assume
A5:   [:P,Q:] c= Indices A;
      then
A6:   P c= Seg len A by A1,Th67;
A7:   Q c= Seg width A by A1,A5,Th67;
      then
A8:   width A<>0 by A4;
      then
A9:   len (A@)=width A by MATRIX_0:54;
      len A=width (A@) by A8,MATRIX_0:54;
      hence thesis by A1,A7,A9,A6,Th67;
    end;
    thus [:Q,P:] c= Indices A@ implies [:P,Q:] c= Indices A
    proof
      assume
A10:  [:Q,P:] c= Indices A@;
      then
A11:  Q c= Seg len (A@) by A1,Th67;
      then len (A@)<>0 by A4;
      then width A>0 by MATRIX_0:def 6;
      then
A12:  len A=width (A@) by MATRIX_0:54;
A13:  len (A@)=width A by MATRIX_0:def 6;
      P c= Seg width (A@) by A1,A10,Th67;
      hence thesis by A1,A11,A12,A13,Th67;
    end;
  end;
end;

theorem Th70:
  [:P,Q:] c= Indices M & card P = card Q implies Det EqSegm(M,P,Q)
  = Det EqSegm(M@,Q,P)
proof
  assume that
A1: [:P,Q:] c= Indices M and
A2: card P = card Q;
  EqSegm(M,P,Q)= Segm(M,P,Q) by A2,Def3
    .=Segm(M@,Q,P)@ by A1,A2,Th62
    .=EqSegm(M@,Q,P)@ by A2,Def3;
  hence thesis by A2,MATRIXR2:43;
end;

theorem Th71:
  for M be Matrix of n,K holds Det (a*M) = power(K).(a,n) * Det M
proof
  let M be Matrix of n,K;
  defpred P[Nat] means for k st k=$1 & k <=n ex aM be Matrix of n,K st Det aM
= power(K).(a,k) * Det M & for i st i in Seg n holds (i<=k implies Line(aM,i)=a
  * Line(M,i)) & (i > k implies Line(aM,i)=Line(M,i));
A1: for m st P[m] holds P[m+1]
  proof
    let m such that
A2: P[m];
    let k such that
A3: k=m+1 and
A4: k <=n;
    m<=n by A3,A4,NAT_1:13;
    then consider aM be Matrix of n,K such that
A5: Det aM = power(K).(a,m) * Det M and
A6: for i st i in Seg n holds (i<=m implies Line(aM,i)=a*Line(M,i))&
    (i>m implies Line(aM,i)=Line(M,i)) by A2;
    take R=RLine(aM,k,a*Line(aM,k));
    0+1<=k by A3,XREAL_1:7;
    then k in Seg n by A4;
    hence Det R = a * (power(K).(a,m) * Det M) by A5,MATRIX11:35
      .= power(K).(a,m) *a * Det M by GROUP_1:def 3
      .= power(K).(a,k) *Det M by A3,GROUP_1:def 7;
    let i such that
A7: i in Seg n;
    per cases by XXREAL_0:1;
    suppose
A8:   i< k or i>k;
      then
A9:  i<=m & i<k or i>m & i>k by A3,NAT_1:13;
      Line(R,i)=Line(aM,i) by A7,A8,MATRIX11:28;
      hence thesis by A6,A7,A9;
    end;
    suppose
A10:  i=k;
      len (a*Line(aM,k)) = len Line(aM,k) by MATRIXR1:16
        .= width aM by MATRIX_0:def 7;
      then
A11:  Line(R,i)=a*Line(aM,k) by A7,A10,MATRIX11:28;
      i > m by A3,A10,NAT_1:13;
      hence thesis by A6,A7,A10,A11;
    end;
  end;
A12: P[0]
  proof
    let k such that
A13: k=0 and
    k <=n;
    take aM=M;
    power(K).(a,0)=1_K by GROUP_1:def 7;
    hence Det aM = power(K).(a,k) * Det M by A13;
    let i;
    assume i in Seg n;
    hence thesis by A13;
  end;
  for m holds P[m] from NAT_1:sch 2(A12,A1);
  then consider aM be Matrix of n,K such that
A14: Det aM = power(K).(a,n) * Det M and
A15: for i st i in Seg n holds (i<=n implies Line(aM,i)=a*Line(M,i))&(i>
  n implies Line(aM,i)=Line(M,i));
  set AM=a*M;
A16: len AM = n by MATRIX_0:def 2;
A17: len M=n by MATRIX_0:def 2;
A18: now
    let i such that
A19: 1<=i and
A20: i<=n;
A21: i in Seg n by A19,A20;
    hence aM.i = Line(aM,i) by MATRIX_0:52
      .= a*Line(M,i) by A15,A20,A21
      .= Line(AM,i) by A17,A19,A20,MATRIXR1:20
      .= AM.i by A21,MATRIX_0:52;
  end;
  len aM=n by MATRIX_0:def 2;
  hence thesis by A14,A16,A18,FINSEQ_1:14;
end;

theorem Th72:
  [:P,Q:] c= Indices M & card P = card Q implies Det EqSegm(a*M,P,
  Q) = power(K).(a,card P) * Det EqSegm(M,P,Q)
proof
  assume that
A1: [:P,Q:] c= Indices M and
A2: card P = card Q;
  EqSegm(a*M,P,Q) = Segm(a*M,P,Q) by A2,Def3
    .= a * Segm(M,P,Q) by A1,Th63
    .= a * EqSegm(M,P,Q) by A2,Def3;
  hence thesis by Th71;
end;

definition
  let K be Field;
  let M be Matrix of K;
  func the_rank_of M -> Element of NAT means
  :Def4:
  (ex P,Q st [:P,Q:] c=
Indices M & card P = card Q & card P = it & Det EqSegm(M,P,Q)<>0.K) & for P1,Q1
  st [:P1,Q1:] c= Indices M & card P1 = card Q1 & Det EqSegm(M,P1,Q1) <> 0.K
  holds card P1 <= it;
  existence
  proof
    defpred P[Nat] means ex P,Q st [:P,Q:] c= Indices M & card P=card Q & card
    Q=$1 & Det EqSegm(M,P,Q)<>0.K;
A1: ex k be Nat st P[k]
    proof
      set E = the empty finite without_zero Subset of NAT;
      reconsider E as finite without_zero Subset of NAT;
      take card E;
      take E,E;
A2:   E c= Seg len M;
A3:   E c= Seg width M;
      Det EqSegm(M,E,E) = 1_K by MATRIXR2:41;
      hence thesis by A2,A3,Th67;
    end;
A4: for k be Nat st P[k] holds k <= len M
    proof
      let k be Nat;
A5:   card Seg len M =len M by FINSEQ_1:57;
      assume P[k];
      then consider P,Q such that
A6:   [:P,Q:] c= Indices M and
A7:   card P=card Q and
A8:   card Q=k and
      Det EqSegm(M,P,Q)<>0.K;
      P c= Seg len M by A6,A7,Th67;
      hence thesis by A7,A8,A5,NAT_1:43;
    end;
    consider k be Nat such that
A9: P[k] and
A10: for n be Nat st P[n] holds n <= k from NAT_1:sch 6(A4,A1);
    take k;
    thus thesis by A9,A10;
  end;
  uniqueness
  proof
    let n1,n2 be Element of NAT such that
A11: ex P,Q st [:P,Q:]c=Indices M & card P=card Q & card P=n1& Det
    EqSegm(M,P,Q)<>0.K and
A12: for P1,Q1 st [:P1,Q1:] c= Indices M & card P1=card Q1 & Det
    EqSegm(M,P1,Q1) <> 0.K holds card P1 <= n1 and
A13: ex P,Q st [:P,Q:]c=Indices M & card P=card Q & card P=n2& Det
    EqSegm(M,P,Q)<>0.K and
A14: for P1,Q1 st [:P1,Q1:] c= Indices M & card P1=card Q1 & Det
    EqSegm(M,P1,Q1) <> 0.K holds card P1 <= n2;
A15: n2<= n1 by A12,A13;
    n1<=n2 by A11,A14;
    hence thesis by A15,XXREAL_0:1;
  end;
end;

theorem Th73:
  for P,Q st [:P,Q:] c= Indices M & card P = card Q holds card P
  <= len M & card Q <= width M
proof
  let P,Q such that
A1: [:P,Q:] c= Indices M and
A2: card P = card Q;
  Q c= Seg width M by A1,A2,Th67;
  then
A3: card Q <=card Seg width M by NAT_1:43;
  P c= Seg len M by A1,A2,Th67;
  then card P<=card Seg len M by NAT_1:43;
  hence thesis by A3,FINSEQ_1:57;
end;

theorem Th74:
  the_rank_of M <= len M & the_rank_of M <= width M
proof
  ex P,Q st [:P,Q:] c= Indices M & card P = card Q & card P = the_rank_of
  M & Det EqSegm(M,P,Q)<>0.K by Def4;
  hence thesis by Th73;
end;

Lm5: [:rng nt,rng mt:] c= Indices M & (n=0 iff m=0) implies ex P1,P2 st P1 =
rng nt & P2 = rng mt
proof
  assume that
A1: [:rng nt,rng mt:] c= Indices M and
A2: n=0 iff m=0;
  rng nt is without_zero
  proof
A3: Indices M=[:Seg len M,Seg width M:] by FINSEQ_1:def 3;
    assume
A4: 0 in rng nt;
    rng mt<>{} by A2,A4;
    then rng nt c= Seg len M by A1,A3,ZFMISC_1:114;
    hence thesis by A4;
  end;
  then
A5: rng nt is finite without_zero Subset of NAT by FINSEQ_1:def 4;
  rng mt is without_zero
  proof
    assume
A6: 0 in rng mt;
    rng nt<>{} by A2,A6;
    then rng mt c= Seg width M by A1,ZFMISC_1:114;
    hence thesis by A6;
  end;
  then rng mt is finite without_zero Subset of NAT by FINSEQ_1:def 4;
  hence thesis by A5;
end;

theorem Th75:
  [:rng nt1,rng nt2:] c= Indices M & Det Segm(M,nt1,nt2)<>0.K
implies ex P1,P2 st P1 = rng nt1 & P2 = rng nt2 & card P1 = card P2 & card P1 =
  n & Det EqSegm(M,P1,P2) <>0.K
proof
  assume that
A1: [:rng nt1,rng nt2:] c= Indices M and
A2: Det Segm(M,nt1,nt2)<>0.K;
  n=0 iff n=0;
  then consider P1,P2 such that
A3: P1 = rng nt1 and
A4: P2 = rng nt2 by A1,Lm5;
  nt2 is one-to-one by A2,Th31;
  then
A5: card P2 =len nt2 by A4,FINSEQ_4:62;
  nt1 is one-to-one by A2,Th27;
  then
A6: card P1 =len nt1 by A3,FINSEQ_4:62;
  then reconsider SP1=Sgm P1,SP2=Sgm P2 as Element of n-tuples_on NAT by A5,
CARD_1:def 7;
A7: rng SP2=P2 by FINSEQ_1:def 14;
  rng SP1=P1 by FINSEQ_1:def 14;
  then
A8: Det Segm(M,nt1,nt2) = Det Segm(M,SP1,SP2) or -Det Segm(M,nt1,nt2) = Det
  Segm(M,SP1,SP2) by A3,A4,A7,Th36;
A9: len nt1=n by CARD_1:def 7;
A10: len nt2=n by CARD_1:def 7;
  Segm(M,Sgm P1,Sgm P2) = Segm(M,P1,P2)
    .= EqSegm(M,P1,P2) by A6,A5,A9,A10,Def3;
  hence thesis by A2,A3,A4,A6,A5,A9,A10,A8,VECTSP_1:28;
end;

theorem Th76:
  for RANK be Element of NAT holds the_rank_of M = RANK iff (ex
rt1,rt2 be Element of RANK-tuples_on NAT st [:rng rt1,rng rt2:] c= Indices M &
Det Segm(M,rt1,rt2)<>0.K) & for n,nt1,nt2 st [:rng nt1,rng nt2:] c= Indices M &
  Det Segm(M,nt1,nt2)<>0.K holds n <= RANK
proof
  let RANK be Element of NAT;
  thus the_rank_of M = RANK implies (ex rt1,rt2 be Element of RANK-tuples_on
NAT st [:rng rt1,rng rt2:] c= Indices M & Det Segm(M,rt1,rt2)<>0.K) & for n,nt1
,nt2 st [:rng nt1,rng nt2:] c= Indices M & Det Segm(M,nt1,nt2)<>0.K holds n <=
  RANK
  proof
    assume
A1: the_rank_of M = RANK;
    then consider P,Q such that
A2: [:P,Q:] c= Indices M and
A3: card P = card Q and
A4: card P = RANK and
A5: Det EqSegm(M,P,Q)<>0.K by Def4;
    reconsider Sp=Sgm P,Sq=Sgm Q as Element of RANK-tuples_on NAT by A3,A4;
A6: rng Sp=P by FINSEQ_1:def 14;
A7: rng Sq=Q by FINSEQ_1:def 14;
    EqSegm(M,P,Q) = Segm(M,P,Q) by A3,Def3
      .= Segm(M,Sgm P,Sgm Q);
    hence
    ex rt1,rt2 be Element of RANK-tuples_on NAT st [:rng rt1,rng rt2:] c=
    Indices M & Det Segm(M,rt1,rt2)<>0.K by A2,A3,A4,A5,A6,A7;
    let n,nt1,nt2 such that
A8: [:rng nt1,rng nt2:] c= Indices M and
A9: Det Segm(M,nt1,nt2)<>0.K;
    ex P1,P2 st P1 = rng nt1 & P2 = rng nt2 & card P1=card P2 & card
    P1 = n & Det EqSegm(M,P1,P2) <>0.K by A8,A9,Th75;
    hence thesis by A1,A8,Def4;
  end;
  assume that
A10: ex rt1,rt2 be Element of RANK-tuples_on NAT st [:rng rt1,rng rt2:]
  c= Indices M & Det Segm(M,rt1,rt2)<>0.K and
A11: for n for nt1,nt2 st [:rng nt1,rng nt2:] c= Indices M & Det Segm(M,
  nt1,nt2)<>0.K holds n <= RANK;
  consider rt1,rt2 be Element of RANK-tuples_on NAT such that
A12: [:rng rt1,rng rt2:] c= Indices M and
A13: Det Segm(M,rt1,rt2)<>0.K by A10;
  consider P,Q such that
A14: [:P,Q:] c= Indices M and
A15: card P = card Q and
A16: card P = the_rank_of M and
A17: Det EqSegm(M,P,Q)<>0.K by Def4;
  ex P1,P2 st P1 = rng rt1 & P2 = rng rt2 & card P1=card P2 & card P1
  = RANK & Det EqSegm(M,P1,P2) <>0.K by A12,A13,Th75;
  then
A18: RANK <= card P by A12,A16,Def4;
  reconsider SP=Sgm P,SQ=Sgm Q as Element of (card P)-tuples_on NAT by A15;
A19: rng SP=P by FINSEQ_1:def 14;
A20: rng SQ=Q by FINSEQ_1:def 14;
  EqSegm(M,P,Q) = Segm(M,P,Q) by A15,Def3
    .= Segm(M,Sgm P,Sgm Q);
  then card P <= RANK by A11,A14,A15,A17,A19,A20;
  hence thesis by A16,A18,XXREAL_0:1;
end;

theorem Th77:
  n = 0 or m = 0 implies the_rank_of Segm(M,nt,mt) = 0
proof
  set S=Segm(M,nt,mt);
  assume n=0 or m = 0;
  then len S=0 or width S=0 by Th1,MATRIX_0:def 2;
  hence thesis by Th74;
end;

theorem Th78:
  [:rng nt,rng mt:] c= Indices M implies the_rank_of M >=
  the_rank_of Segm(M,nt,mt)
proof
  assume
A1: [:rng nt,rng mt:] c= Indices M;
  per cases;
  suppose
    n=0 or m=0;
    hence thesis by Th77;
  end;
  suppose
A2: n>0 & m>0;
A3: dom mt=Seg m by FINSEQ_2:124;
A4: dom nt=Seg n by FINSEQ_2:124;
    set S=Segm(M,nt,mt);
    set RS=the_rank_of S;
    consider rt1,rt2 be Element of RS-tuples_on NAT such that
A5: [:rng rt1,rng rt2:] c= Indices S and
A6: Det Segm(S,rt1,rt2)<>0.K by Th76;
    set mr=mt*rt2;
A7: ex R1,R2 be finite without_zero Subset of NAT st R1 = rng rt1 & R2 =
    rng rt2 & card R1=card R2 & card R1 = RS & Det EqSegm(S,R1,R2) <>0.K by A5
,A6,Th75;
    set nr=nt*rt1;
A8: rng mr c= rng mt by RELAT_1:26;
    len S=n by A2,Th1;
    then
A9: rng rt1 c= dom nt by A5,A7,A4,Th67;
    then dom nr=dom rt1 by RELAT_1:27;
    then
A10: dom nr=Seg RS by FINSEQ_2:124;
    width S=m by A2,Th1;
    then
A11: rng rt2 c= dom mt by A5,A7,A3,Th67;
    then dom mr=dom rt2 by RELAT_1:27;
    then
A12: dom mr=Seg RS by FINSEQ_2:124;
    rng mt c= NAT by FINSEQ_1:def 4;
    then
A13: rng mr c= NAT by A8;
    set SS=Segm(S,rt1,rt2);
A14: rng nr c= rng nt by RELAT_1:26;
    rng nt c= NAT by FINSEQ_1:def 4;
    then
A15: rng nr c= NAT by A14;
    reconsider nr,mr as FinSequence by A9,A11,FINSEQ_1:16;
    reconsider nr,mr as FinSequence of NAT by A15,A13,FINSEQ_1:def 4;
A16: len nr=RS by A10,FINSEQ_1:def 3;
    len mr=RS by A12,FINSEQ_1:def 3;
    then reconsider nr,mr as Element of RS-tuples_on NAT by A16,FINSEQ_2:92;
    set MR=Segm(M,nr,mr);
    now
      let i,j such that
A17:  [i,j] in Indices SS;
      reconsider I=i,J=j,rtI=rt1.i,rtJ=rt2.j as Element of NAT by
ORDINAL1:def 12;
A18:  [rt1.I,rt2.J] in Indices S by A5,A17,Th17;
A19:  Indices SS=[:dom nr,dom mr:] by A10,A12,MATRIX_0:24;
      then
A20:  i in dom nr by A17,ZFMISC_1:87;
A21:  j in dom mr by A17,A19,ZFMISC_1:87;
      [i,j] in Indices MR by A17,MATRIX_0:26;
      hence MR*(i,j) = M*(nr.I,mr.J) by Def1
        .= M*(nt.rtI,mr.J) by A20,FUNCT_1:12
        .= M*(nt.rtI,mt.rtJ) by A21,FUNCT_1:12
        .= S*(rt1.I,rt2.J) by A18,Def1
        .= SS*(i,j) by A17,Def1;
    end;
    then
A22: SS=MR by MATRIX_0:27;
    [:rng nr,rng mr:] c= [:rng nt,rng mt:] by A14,A8,ZFMISC_1:96;
    then [:rng nr,rng mr:] c= Indices M by A1;
    hence thesis by A6,A22,Th76;
  end;
end;

theorem Th79:
  [:P,Q:] c= Indices M implies the_rank_of M >= the_rank_of Segm(M ,P,Q)
proof
A1: rng Sgm P=P by FINSEQ_1:def 14;
A2: rng Sgm Q=Q by FINSEQ_1:def 14;
  assume [:P,Q:] c= Indices M;
  hence thesis by A1,A2,Th78;
end;

theorem Th80:
  P c= P1 & Q c= Q1 implies the_rank_of Segm(M,P,Q) <= the_rank_of
  Segm(M,P1,Q1)
proof
  assume that
A1: P c= P1 and
A2: Q c= Q1;
  set S1=Segm(M,P1,Q1);
  set S=Segm(M,P,Q);
  consider P2,Q2 such that
A3: [:P2,Q2:] c= Indices S and
A4: card P2 = card Q2 and
A5: card P2 = the_rank_of S and
A6: Det EqSegm(S,P2,Q2)<>0.K by Def4;
  P2={} iff Q2={} by A4;
  then consider P3,Q3 be without_zero finite Subset of NAT such that
A7: P3 c= P and
A8: Q3 c= Q and
  P3 = Sgm P.:P2 and
  Q3=Sgm Q.:Q2 and
A9: card P3=card P2 and
A10: card Q3=card Q2 and
A11: Segm(S,P2,Q2) = Segm(M,P3,Q3) by A3,Th57;
  reconsider P4=Sgm P1"P3, Q4=Sgm Q1"Q3 as without_zero finite Subset of NAT
  by Th53;
A12: card Q4=card P2 by A2,A4,A8,A10,Lm2,XBOOLE_1:1;
A13: card P4=card P2 by A1,A7,A9,Lm2,XBOOLE_1:1;
A14: rng Sgm Q4=Q4 by FINSEQ_1:def 14;
A15: Q3 c= Q1 by A2,A8;
A16: P3 c= P1 by A1,A7;
  rng Sgm P4=P4 by FINSEQ_1:def 14;
  then
A17: [:P4,Q4:] c= Indices S1 by A16,A15,A14,Th56;
  Segm(S1,P4,Q4) = Segm(M,P3,Q3) by A16,A15,Th56;
  then EqSegm(S,P2,Q2) = Segm(S1,P4,Q4) by A4,A11,Def3
    .= EqSegm(S1,P4,Q4) by A4,A10,A15,A13,Def3,Lm2;
  hence thesis by A5,A6,A13,A12,A17,Def4;
end;

theorem Th81:
  for f,g be Function st rng f c= rng g ex h be Function st dom h
  = dom f & rng h c= dom g & f = g*h
proof
  let f,g be Function such that
A1: rng f c= rng g;
  defpred P[object,object] means f.$1=g.$2;
A2: for x being object st x in dom f
ex y being object st y in dom g & P[x,y] by A1,FUNCT_1:114;
  consider h be Function of dom f,dom g such that
A3: for x being object st x in dom f holds P[x,h.x] from FUNCT_2:sch 1(A2);
  per cases;
  suppose
    dom g={};
    then rng g={} by RELAT_1:42;
    then
A4: f=g*{} by A1;
    rng {} c= dom g;
    hence thesis by A4;
  end;
  suppose
A5: dom g<>{};
A6: rng h c= dom g by RELAT_1:def 19;
A7: dom h=dom f by A5,FUNCT_2:def 1;
    then
A8: dom (g*h)=dom f by A6,RELAT_1:27;
    now
      let x being object such that
A9:   x in dom f;
      thus f.x = g.(h.x) by A3,A9
        .= (g*h).x by A8,A9,FUNCT_1:12;
    end;
    hence thesis by A7,A6,A8,FUNCT_1:2;
  end;
end;

theorem Th82:
  [:rng nt,rng mt:] = Indices M implies the_rank_of M =
  the_rank_of Segm(M,nt,mt)
proof
  set RM=the_rank_of M;
  set S=Segm(M,nt,mt);
  consider rt1,rt2 be Element of RM-tuples_on NAT such that
A1: [:rng rt1,rng rt2:] c= Indices M and
A2: Det Segm(M,rt1,rt2)<>0.K by Th76;
  assume
A3: [:rng nt,rng mt:] = Indices M;
A4: now
    per cases;
    suppose
      RM=0;
      hence RM <= the_rank_of S;
    end;
    suppose
A5:   RM>0;
      then len rt2>0;
      then
A6:   rt2<>{};
      len rt1>0 by A5;
      then
A7:   rt1<>{};
      then rng nt<>{} by A3,A1,A6;
      then
   dom nt<>{} by RELAT_1:42;
then A8:    n <> 0;
      then
A9:  width S=m by Th1;
A10:  dom mt =Seg m by FINSEQ_2:124;
      set MR=Segm(M,rt1,rt2);
A11:  dom rt2=Seg RM by FINSEQ_2:124;
      rng rt1 c= rng nt by A3,A1,A6,ZFMISC_1:114;
      then consider R1 be Function such that
A12:  dom R1 = dom rt1 and
A13:  rng R1 c= dom nt and
A14:  rt1 = nt*R1 by Th81;
      rng rt2 c= rng mt by A3,A1,A7,ZFMISC_1:114;
      then consider R2 be Function such that
A15:  dom R2 = dom rt2 and
A16:  rng R2 c= dom mt and
A17:  rt2 = mt*R2 by Th81;
A18:  dom rt1=Seg RM by FINSEQ_2:124;
      then reconsider R1,R2 as FinSequence by A12,A15,A11,FINSEQ_1:def 2;
A19:  rng R1 c= NAT by A13,XBOOLE_1:1;
      rng R2 c= NAT by A16,XBOOLE_1:1;
      then reconsider R1,R2 as FinSequence of NAT by A19,FINSEQ_1:def 4;
A20:  len R1=RM by A12,A18,FINSEQ_1:def 3;
      len R2=RM by A15,A11,FINSEQ_1:def 3;
      then reconsider R1,R2 as Element of RM-tuples_on NAT by A20,FINSEQ_2:92;
      set SR=Segm(S,R1,R2);
      len S=n by Th1,A8;
      then
A21:  Indices S=[:Seg n,Seg m:] by A9,FINSEQ_1:def 3;
      now
A22:    dom mt=Seg m by FINSEQ_2:124;
        let i,j such that
A23:    [i,j] in Indices SR;
        reconsider I=i,J=j,RI=R1.i,RJ=R2.j as Element of NAT by ORDINAL1:def 12
;
A24:    dom nt=Seg n by FINSEQ_2:124;
A25:    Indices SR=[:dom R1,dom R2:] by A12,A15,A18,A11,MATRIX_0:24;
        then
A26:    i in dom R1 by A23,ZFMISC_1:87;
A27:    j in dom R2 by A23,A25,ZFMISC_1:87;
        then
A28:    R2.j in rng R2 by FUNCT_1:def 3;
        R1.i in rng R1 by A26,FUNCT_1:def 3;
        then
A29:    [R1.I,R2.J] in Indices S by A13,A16,A21,A28,A24,A22,ZFMISC_1:87;
        [i,j] in Indices MR by A23,MATRIX_0:26;
        hence MR*(i,j) = M*(rt1.I,rt2.J) by Def1
          .= M*(nt.RI,rt2.J) by A12,A14,A26,FUNCT_1:12
          .= M*(nt.RI,mt.RJ) by A15,A17,A27,FUNCT_1:12
          .= S*(R1.I,R2.J) by A29,Def1
          .= SR*(i,j) by A23,Def1;
      end;
      then
A30:  Det SR<>0.K by A2,MATRIX_0:27;
      dom nt=Seg n by FINSEQ_2:124;
      then [:rng R1,rng R2:] c= Indices S by A13,A16,A10,A21,ZFMISC_1:96;
      hence RM <= the_rank_of S by A30,Th76;
    end;
  end;
  RM >= the_rank_of S by A3,Th78;
  hence thesis by A4,XXREAL_0:1;
end;

theorem Th83:
  for M be Matrix of n,K holds the_rank_of M = n iff Det M <> 0.K
proof
  let M be Matrix of n,K;
A1: [:Seg n,Seg n:] c= Indices M by MATRIX_0:24;
A2: len M=n by MATRIX_0:24;
  then
A3: the_rank_of M <= n by Th74;
A4: width M=n by MATRIX_0:24;
  then
A5: M = Segm(M,Seg n,Seg n) by A2,Th46
    .= EqSegm(M,Seg n,Seg n) by Def3;
A6: card Seg n=n by FINSEQ_1:57;
  thus the_rank_of M = n implies Det M <> 0.K
  proof
    assume the_rank_of M = n;
    then consider P,Q such that
A7: [:P,Q:] c= Indices M and
A8: card P = card Q and
A9: card P = n and
A10: Det EqSegm(M,P,Q)<>0.K by Def4;
    P c= Seg n by A2,A7,A8,Th67;
    then
A11: P=Seg n by A6,A9,CARD_2:102;
    Q c= Seg n by A4,A7,A8,Th67;
    then Q=Seg n by A6,A8,A9,CARD_2:102;
    then M = Segm(M,P,Q) by A2,A4,A11,Th46
      .= EqSegm(M,P,Q) by A8,Def3;
    hence thesis by A9,A10;
  end;
  assume Det M <> 0.K;
  then the_rank_of M >= n by A6,A5,A1,Def4;
  hence thesis by A3,XXREAL_0:1;
end;

theorem
  the_rank_of M = the_rank_of (M@)
proof
  consider P,Q such that
A1: [:P,Q:] c= Indices M and
A2: card P = card Q and
A3: card P = the_rank_of M and
A4: Det EqSegm(M,P,Q)<>0.K by Def4;
A5: [:Q,P:] c= Indices (M@) by A1,A2,Th69;
  consider P1,Q1 such that
A6: [:P1,Q1:] c= Indices (M@) and
A7: card P1 = card Q1 and
A8: card P1 = the_rank_of (M@) and
A9: Det EqSegm(M@,P1,Q1)<>0.K by Def4;
A10: [:Q1,P1:] c= Indices M by A6,A7,Th69;
  then Det EqSegm(M,Q1,P1)<>0.K by A7,A9,Th70;
  then
A11: the_rank_of M >= the_rank_of (M@) by A7,A8,A10,Def4;
  Det EqSegm(M@,Q,P)<>0.K by A1,A2,A4,Th70;
  then the_rank_of (M@) >= the_rank_of M by A2,A3,A5,Def4;
  hence thesis by A11,XXREAL_0:1;
end;

Lm6: a <> 0.K implies power(K).(a,n)<>0.K
proof
  defpred P[Nat] means for n st n=$1 holds power(K).(a,n)<>0.K;
  assume
A1: a<>0.K;
A2: for k st P[k] holds P[k+1]
  proof
    let k;
    assume P[k];
    then
A3: power(K).(a,k) <>0.K;
    let n;
    assume n=k+1;
    then power(K).(a,n)=power(K).(a,k) * a by GROUP_1:def 7;
    hence thesis by A1,A3,VECTSP_1:12;
  end;
A4: P[0]
  proof
A5: 1_K<>0.K;
    let n;
    assume n=0;
    hence thesis by A5,GROUP_1:def 7;
  end;
  for k holds P[k] from NAT_1:sch 2(A4,A2);
  hence thesis;
end;

theorem
  for M be Matrix of n,m,K,F be Permutation of Seg n holds the_rank_of M
  = the_rank_of (M*F)
proof
  let M be Matrix of n,m,K,F be Permutation of Seg n;
  set P=Seg len M;
  set Q=Seg width M;
  set SP=Sgm P;
  set SQ=Sgm Q;
A1: card P=len M by FINSEQ_1:57;
A2: len M=n by MATRIX_0:def 2;
  then reconsider F9=F as Permutation of Seg card P by A1;
A3: rng F=Seg n by FUNCT_2:def 3;
A4: dom F=Seg n by FUNCT_2:52;
A5: dom SP=Seg card P by FINSEQ_3:40;
  then
A6: dom (SP*F)=dom F by A2,A1,A3,RELAT_1:27;
  then reconsider SPF=SP*F as FinSequence by A4,FINSEQ_1:def 2;
A7: rng (SP*F)=rng SP by A2,A1,A5,A3,RELAT_1:28;
  then reconsider SPF as FinSequence of NAT by FINSEQ_1:def 4;
  len SPF=card P by A2,A1,A6,A4,FINSEQ_1:def 3;
  then reconsider SPF as Element of (card P)-tuples_on NAT by FINSEQ_2:92;
A8: Indices M=[:Seg len M,Seg width M:] by FINSEQ_1:def 3;
A9: rng SQ=Q by FINSEQ_1:def 14;
A10: rng SP=P by FINSEQ_1:def 14;
  Segm(M,SPF,SQ) = Segm(M,P,Q) * F9 by Th33
    .= M*F by Th46;
  hence thesis by A7,A8,A10,A9,Th82;
end;

theorem
  a <> 0.K implies the_rank_of M = the_rank_of (a*M)
proof
  consider P,Q such that
A1: [:P,Q:] c= Indices M and
A2: card P = card Q and
A3: card P = the_rank_of M and
A4: Det EqSegm(M,P,Q)<>0.K by Def4;
  consider P1,Q1 such that
A5: [:P1,Q1:] c= Indices (a*M) and
A6: card P1 = card Q1 and
A7: card P1 = the_rank_of (a*M) and
A8: Det EqSegm(a*M,P1,Q1)<>0.K by Def4;
A9: Indices M = Indices (a*M) by MATRIXR1:18;
  then Det EqSegm(a*M,P1,Q1)=power(K).(a,card P1)*Det EqSegm(M,P1,Q1) by A5,A6
,Th72;
  then Det EqSegm(M,P1,Q1)<>0.K by A8;
  then
A10: the_rank_of M >= the_rank_of (a*M) by A9,A5,A6,A7,Def4;
  assume a<>0.K;
  then
A11: power(K).(a,card P)<>0.K by Lm6;
  Det EqSegm(a*M,P,Q)=power(K).(a,card P)*Det EqSegm(M,P,Q) by A1,A2,Th72;
  then Det EqSegm(a*M,P,Q)<>0.K by A4,A11,VECTSP_1:12;
  then the_rank_of (a*M) >= the_rank_of M by A9,A1,A2,A3,Def4;
  hence thesis by A10,XXREAL_0:1;
end;

theorem Th87:
  for p,pf be FinSequence of K, f be Function st pf = p * f & rng
  f c= dom p holds (a*p) * f = a * pf
proof
  let p,pf be FinSequence of K, f be Function such that
A1: pf = p * f and
A2: rng f c= dom p;
  len (a*p)=len p by MATRIXR1:16;
  then
A3: dom (a*p)=Seg len p by FINSEQ_1:def 3;
A4: Seg len p=dom p by FINSEQ_1:def 3;
  then
A5: dom (a*p*f)=dom f by A2,A3,RELAT_1:27;
  len (a*pf)=len pf by MATRIXR1:16;
  then
A6: dom (a*pf)=Seg len pf by FINSEQ_1:def 3;
A7: Seg len pf =dom pf by FINSEQ_1:def 3;
  then
A8: dom (a*pf)=dom f by A1,A2,A6,RELAT_1:27;
  now
    set KK=the carrier of K;
A9: rng pf c= KK by FINSEQ_1:def 4;
    let x being object such that
A10: x in dom (a*pf);
A11: f.x in rng f by A8,A10,FUNCT_1:def 3;
    then
A12: f.x in dom p by A2;
    pf.x in rng pf by A6,A7,A10,FUNCT_1:def 3;
    then reconsider pf9x=pf.x as Element of K by A9;
A13: p.(f.x) in rng p by A2,A11,FUNCT_1:def 3;
    thus (a*pf).x = a*pf9x by A10,FVSUM_1:50
      .= (a*p).(f.x) by A1,A3,A4,A6,A7,A10,A12,A13,FUNCT_1:12,FVSUM_1:50
      .= ((a*p)*f).x by A5,A8,A10,FUNCT_1:12;
  end;
  hence thesis by A1,A2,A6,A7,A5,FUNCT_1:2,RELAT_1:27;
end;

theorem Th88:
  for p,pf,q,qf be FinSequence of K, f be Function st pf = p * f &
  rng f c= dom p & qf = q * f & rng f c= dom q holds (p+q) * f = pf + qf
proof
  let p,pf,q,qf be FinSequence of K, f be Function such that
A1: pf = p * f and
A2: rng f c= dom p and
A3: qf = q * f and
A4: rng f c= dom q;
A5: dom pf=dom f by A1,A2,RELAT_1:27;
  set KK=the carrier of K;
A6: dom pf=Seg len pf by FINSEQ_1:def 3;
A7: dom qf=dom f by A3,A4,RELAT_1:27;
  then len qf=len pf by A5,A6,FINSEQ_1:def 3;
  then reconsider pf9=pf,qf9=qf as Element of (len pf)-tuples_on KK by
FINSEQ_2:92;
A8: dom (pf9+qf9)=dom f by A5,A6,FINSEQ_2:124;
  set pq=p+q;
A9: rng q c= KK by FINSEQ_1:def 4;
  rng p c= KK by FINSEQ_1:def 4;
  then [:rng p,rng q:]c=[:KK,KK:] by A9,ZFMISC_1:96;
  then [:rng p, rng q:] c= dom the addF of K by FUNCT_2:def 1;
  then
A10: dom pq=dom p /\ dom q by FUNCOP_1:69;
  then
A11: rng f c= dom pq by A2,A4,XBOOLE_1:19;
A12: now
A13: rng qf c= KK by FINSEQ_1:def 4;
A14: rng pf c= KK by FINSEQ_1:def 4;
    let x being object such that
A15: x in dom f;
A16: f.x in rng f by A15,FUNCT_1:def 3;
    dom p=Seg len p by FINSEQ_1:def 3;
    then f.x in Seg len p by A2,A16;
    then reconsider n=x,fx=f.x as Element of NAT by A5,A15;
A17: qf.x in rng qf by A7,A15,FUNCT_1:def 3;
    pf.x in rng pf by A5,A15,FUNCT_1:def 3;
    then reconsider pfn=pf.n,qfn=qf.n as Element of K by A14,A17,A13;
A18: pfn=p.fx by A1,A15,FUNCT_1:13;
A19: qfn=q.fx by A3,A15,FUNCT_1:13;
    thus (pq*f).x = pq.fx by A15,FUNCT_1:13
      .= pfn+qfn by A11,A16,A18,A19,FVSUM_1:17
      .= (pf9+qf9).x by A5,A6,A15,FVSUM_1:18;
  end;
  dom (pq*f)=dom f by A2,A4,A10,RELAT_1:27,XBOOLE_1:19;
  hence thesis by A8,A12;
end;

theorem Th89:
  a<>0.K implies the_rank_of M9 = the_rank_of RLine(M9,i,a*Line(M9 ,i))
proof
  set L=Line(M9,i);
  set aL=a*L;
  set R=RLine(M9,i,aL);
A1: Indices M9=Indices R by MATRIX_0:26;
  consider P,Q such that
A2: [:P,Q:] c= Indices M9 and
A3: card P = card Q and
A4: card P = the_rank_of M9 and
A5: Det EqSegm(M9,P,Q)<>0.K by Def4;
  assume
A6: a<>0.K;
A7: now
    per cases;
    suppose
A8:   i in P;
A9:   len L=width M9 by MATRIX_0:def 7;
      then
A10:  dom L=Seg width M9 by FINSEQ_1:def 3;
A11:  rng Sgm Q=Q by FINSEQ_1:def 14;
A13:  dom Sgm P=Seg card P by FINSEQ_3:40;
      rng Sgm P=P by FINSEQ_1:def 14;
      then consider x being object such that
A14:  x in dom Sgm P and
A15:  Sgm P.x=i by A8,FUNCT_1:def 3;
      reconsider x as Element of NAT by A14;
A16:  Q c= Seg width M9 by A2,A3,Th67;
      then Line(Segm(M9,P,Q),x) = L * Sgm Q by A14,A15,A13,Th47;
      then
A17:  (a*Line(Segm(M9,P,Q),x)) = aL * Sgm Q by A11,A16,A10,Th87;
A18:  len aL=len L by MATRIXR1:16;
      RLine(EqSegm(M9,P,Q),x,a*Line(EqSegm(M9,P,Q),x)) = RLine(Segm(M9,P,
      Q),x,a*Line(EqSegm(M9,P,Q),x)) by A3,Def3
        .= RLine(Segm(M9,P,Q),x,a*Line(Segm(M9,P,Q),x)) by A3,Def3
        .= Segm(R,P,Q) by A2,A15,A9,A17,A18,Th59
        .= EqSegm(R,P,Q) by A3,Def3;
      then Det EqSegm(R,P,Q)= a * Det EqSegm(M9,P,Q) by A14,A13,MATRIX11:35;
      then Det EqSegm(R,P,Q)<>0.K by A6,A5,VECTSP_1:12;
      hence the_rank_of R >= the_rank_of M9 by A2,A3,A4,A1,Def4;
    end;
    suppose
A19:  not i in P;
      EqSegm(M9,P,Q) = Segm(M9,P,Q) by A3,Def3
        .= Segm(R,P,Q) by A2,A19,Th60
        .= EqSegm(R,P,Q) by A3,Def3;
      hence the_rank_of R >= the_rank_of M9 by A2,A3,A4,A5,A1,Def4;
    end;
  end;
  consider P1,Q1 such that
A20: [:P1,Q1:] c= Indices R and
A21: card P1 = card Q1 and
A22: card P1 = the_rank_of R and
A23: Det EqSegm(R,P1,Q1)<>0.K by Def4;
  now
    per cases;
    suppose
A24:  i in P1;
A25:  len L=width M9 by MATRIX_0:def 7;
      then
A26:  dom L=Seg width M9 by FINSEQ_1:def 3;
A27:  rng Sgm Q1=Q1 by FINSEQ_1:def 14;
A29:  dom Sgm P1=Seg card P1 by FINSEQ_3:40;
      rng Sgm P1=P1 by FINSEQ_1:def 14;
      then consider x being object such that
A30:  x in dom Sgm P1 and
A31:  Sgm P1.x=i by A24,FUNCT_1:def 3;
      reconsider x as Element of NAT by A30;
A32:  Q1 c= Seg width M9 by A1,A20,A21,Th67;
      then Line(Segm(M9,P1,Q1),x) = L * Sgm Q1 by A30,A31,A29,Th47;
      then
A33:  (a*Line(Segm(M9,P1,Q1),x)) = aL * Sgm Q1 by A27,A32,A26,Th87;
A34:  len aL=len L by MATRIXR1:16;
      RLine(EqSegm(M9,P1,Q1),x,a*Line(EqSegm(M9,P1,Q1),x)) =RLine(Segm(M9
      ,P1,Q1),x,a*Line(EqSegm(M9,P1,Q1),x)) by A21,Def3
        .=RLine(Segm(M9,P1,Q1),x,a*Line(Segm(M9,P1,Q1),x)) by A21,Def3
        .=Segm(R,P1,Q1) by A1,A20,A31,A25,A33,A34,Th59
        .=EqSegm(R,P1,Q1) by A21,Def3;
      then Det EqSegm(R,P1,Q1)=a*Det EqSegm(M9,P1,Q1) by A30,A29,MATRIX11:35;
      then Det EqSegm(M9,P1,Q1)<>0.K by A23;
      hence the_rank_of M9 >= the_rank_of R by A1,A20,A21,A22,Def4;
    end;
    suppose
A35:  not i in P1;
      EqSegm(M9,P1,Q1) = Segm(M9,P1,Q1) by A21,Def3
        .= Segm(R,P1,Q1) by A1,A20,A35,Th60
        .= EqSegm(R,P1,Q1) by A21,Def3;
      hence the_rank_of M9 >= the_rank_of R by A1,A20,A21,A22,A23,Def4;
    end;
  end;
  hence thesis by A7,XXREAL_0:1;
end;

theorem Th90:
  Line(M,i)=(width M) |-> 0.K implies the_rank_of DelLine(M,i) = the_rank_of M
proof
  set D=DelLine(M,i);
A1: Indices M=[:Seg len M,Seg width M:] by FINSEQ_1:def 3;
A2: Segm(M,Seg len M \ {i},Seg width M) = D by Th51;
  consider P,Q such that
A3: [:P,Q:] c= Indices D and
A4: card P = card Q and
A5: card P = the_rank_of D and
A6: Det EqSegm(D,P,Q)<>0.K by Def4;
  EqSegm(D,P,Q)=Segm(D,P,Q) by A4,Def3;
  then
A7: the_rank_of Segm(D,P,Q)=card P by A6,Th83;
  P={} iff Q={} by A4;
  then consider P2,Q2 such that
A8: P2 c= Seg len M \ {i} and
A9: Q2 c= Seg width M and
  P2 = Sgm (Seg len M \ {i}).:P and
  Q2=Sgm (Seg width M).:Q and
  card P2=card P and
  card Q2=card Q and
A10: Segm(D,P,Q) = Segm(M,P2,Q2) by A3,A2,Th57;
  Seg len M \ {i} c= Seg len M by XBOOLE_1:36;
  then P2 c= Seg len M by A8;
  then [:P2,Q2:] c= Indices M by A9,A1,ZFMISC_1:96;
  then
A11: the_rank_of D <= the_rank_of M by A5,A10,A7,Th79;
  consider p,q be without_zero finite Subset of NAT such that
A12: [:p,q:] c= Indices M and
A13: card p = card q and
A14: card p = the_rank_of M and
A15: Det EqSegm(M,p,q)<>0.K by Def4;
  EqSegm(M,p,q)=Segm(M,p,q) by A13,Def3;
  then
A16: the_rank_of Segm(M,p,q)=card p by A15,Th83;
  assume
A17: Line(M,i)=(width M) |-> 0.K;
  not i in p
  proof
    assume
A18: i in p;
    then reconsider i0=i as non zero Element of NAT;
    {i} c= p by A18,ZFMISC_1:31;
    then consider q1 be without_zero finite Subset of NAT such that
A19: q1 c= q and
A20: card {i} = card q1 and
A21: Det EqSegm(M,{i0},q1) <> 0.K by A13,A15,Th65;
    consider y being object such that
A22: {y}=q1 by A20,CARD_2:42;
A23: card { i } = 1 by CARD_1:30;
A24: q c= Seg width M by A12,A13,Th67;
    y in {y} by TARSKI:def 1;
    then reconsider y as non zero Element of NAT by A22;
    y in q1 by A22,TARSKI:def 1;
    then
A25: y in q by A19;
    then
A26: M*(i0,y)=Line(M,i).y by A24,MATRIX_0:def 7;
A27: Line(M,i).y =0.K by A17,A25,A24,FINSEQ_2:57;
    EqSegm(M,{i0},q1) = Segm(M,{i0},{y}) by A20,A22,Def3
      .= <*<* 0.K *>*> by A26,A27,Th44;
    hence thesis by A21,A23,MATRIX_3:34;
  end;
  then
A28: p\{i}=p by ZFMISC_1:57;
  p c= Seg len M by A12,A13,Th67;
  then
A29: p c= Seg len M\{i} by A28,XBOOLE_1:33;
  q c= Seg width M by A12,A13,Th67;
  then the_rank_of Segm(M,p,q)<=the_rank_of D by A2,A29,Th80;
  hence thesis by A11,A14,A16,XXREAL_0:1;
end;

theorem Th91:
  for p st len p = width M9 holds the_rank_of DelLine(M9,i) =
  the_rank_of RLine(M9,i,0.K*p)
proof
  let p such that
A1: len p = width M9;
  set R=RLine(M9,i,0.K*p);
A2: Seg len M9=dom M9 by FINSEQ_1:def 3;
A3: len M9=n9 by MATRIX_0:def 2;
  per cases;
  suppose
A4: not i in dom M9;
    then R=M9 by A2,Th40;
    hence thesis by A4,FINSEQ_3:104;
  end;
  suppose
A5: i in dom M9;
   then
A6: n9 <> 0 by A2,A3;
    set KK=the carrier of K;
A7: p is Element of (len p)-tuples_on KK by FINSEQ_2:92;
A8: len (0.K *p)=len p by MATRIXR1:16;
    then Line(R,i)=0.K * p by A1,A2,A3,A5,MATRIX11:28;
    then
A9: Line(R,i)=(len p) |-> 0.K by A7,FVSUM_1:58;
    reconsider 0p=0.K*p as Element of KK* by FINSEQ_1:def 11;
    R=Replace(M9,i,0p) by A1,A8,MATRIX11:29;
    then
A11: Replace(R,i,0p)=Replace(M9,i,0p) by FUNCT_7:34;
A12: width R=m9 by Th1,A6;
    width M9=m9 by Th1,A6;
    then the_rank_of R=the_rank_of DelLine(R,i) by A1,A12,A9,Th90;
    hence thesis by A11,COMPUT_1:4;
  end;
end;

theorem Th92:
  j in Seg len M9 & (i=j implies a <> - 1_K) implies the_rank_of
  M9 = the_rank_of RLine(M9,i,Line(M9,i)+a*Line(M9,j))
proof
  assume that
A1: j in Seg len M9 and
A2: i=j implies a <> - 1_K;
  per cases;
  suppose
    not i in Seg len M9;
    hence thesis by Th40;
  end;
  suppose
A3: i in Seg len M9;
    set KK=the carrier of K;
    set W=width M9;
    set Lj=Line(M9,j);
    set Li=Line(M9,i);
    set R=RLine(M9,i,Li+a*Lj);
    reconsider Li9=Li,Lj9=Lj,LL=Li+a*Lj as Element of KK* by FINSEQ_1:def 11;
A4: len Li=W by CARD_1:def 7;
    then
A5: dom Li=Seg W by FINSEQ_1:def 3;
A6: len (Li+a*Lj)=W by CARD_1:def 7;
    then
A7: W=width R by MATRIX11:def 3;
    then
A8: RLine(R,i,Li) = Replace(R,i,Li9) by A4,MATRIX11:29
      .= Replace(Replace(M9,i,LL),i,Li9) by A6,MATRIX11:29
      .= Replace(M9,i,Li9) by FUNCT_7:34
      .= RLine(M9,i,Li) by A4,MATRIX11:29
      .= M9 by MATRIX11:30;
A9: len M9=n9 by MATRIX_0:def 2;
    then
A10: Line(R,i)=Li + a*Lj by A3,A6,MATRIX11:28;
A11: len Lj=W by CARD_1:def 7;
    then
A12: dom Lj=Seg W by FINSEQ_1:def 3;
    len (a*Lj)=W by CARD_1:def 7;
    then
A13: dom (a*Lj)=Seg W by FINSEQ_1:def 3;
A14: Indices R=Indices M9 by MATRIX_0:26;
    consider P1,Q1 such that
A15: [:P1,Q1:] c= Indices M9 and
A16: card P1 = card Q1 and
A17: card P1=the_rank_of M9 and
A18: Det EqSegm(M9,P1,Q1)<>0.K by Def4;
A19: EqSegm(M9,P1,Q1)=Segm(M9,P1,Q1) by A16,Def3;
A20: EqSegm(R,P1,Q1)=Segm(R,P1,Q1) by A16,Def3;
A21: RLine(R,i,Lj) = Replace(R,i,Lj9) by A11,A7,MATRIX11:29
      .= Replace(Replace(M9,i,LL),i,Lj9) by A6,MATRIX11:29
      .= Replace(M9,i,Lj9) by FUNCT_7:34
      .= RLine(M9,i,Lj) by A11,MATRIX11:29;
A22: now
      per cases;
      suppose
        not i in P1;
        then Segm(M9,P1,Q1) = Segm(R,P1,Q1) by A15,Th60;
        hence the_rank_of R>=the_rank_of M9
        by A14,A15,A16,A17,A18,A20,A19,Def4;
      end;
      suppose
A23:    i in P1;
        set SM=EqSegm(M9,P1,Q1);
        set SR=EqSegm(R,P1,Q1);
A24:    rng Lj c= KK by FINSEQ_1:def 4;
A26:    dom Sgm P1=Seg card P1 by FINSEQ_3:40;
A27:    Q1 c= Seg W by A15,A16,Th67;
A28:    dom Sgm Q1=Seg card Q1 by FINSEQ_3:40;
A29:    rng Sgm Q1 c= Seg W by A27,FINSEQ_1:def 14;
        then
A30:    dom (Lj*Sgm Q1)=dom Sgm Q1 by A12,RELAT_1:27;
        then reconsider LjQ=Lj*Sgm Q1 as FinSequence by A28,FINSEQ_1:def 2;
        rng LjQ c= rng Lj by RELAT_1:26;
        then rng LjQ c= the carrier of K by A24;
        then reconsider LjQ as FinSequence of K by FINSEQ_1:def 4;
A31:    len LjQ=card P1 by A16,A30,A28,FINSEQ_1:def 3;
        rng Sgm P1=P1 by FINSEQ_1:def 14;
        then consider m be object such that
A32:    m in dom Sgm P1 and
A33:    Sgm P1.m=i by A23,FUNCT_1:def 3;
        reconsider m as Element of NAT by A32;
A34:    len Line(SM,m)=width SM by MATRIX_0:def 7;
A35:    Line(SM,m)=Line(M9,i)*Sgm Q1 by A19,A32,A33,A26,A27,Th47;
        then
A36:    RLine(SR,m,Line(SM,m))=Segm(M9,P1,Q1) by A4,A7,A8,A14,A15,A16,A20,A33
,Th59;
        Q1 c= Seg width R by A14,A15,A16,Th67;
        then
A37:    Line(SR,m) = Line(R,i)*Sgm Q1 by A20,A32,A33,A26,Th47;
A38:    RLine(SR,m,LjQ)=Segm(RLine(M9,i,Lj),P1,Q1) by A11,A7,A21,A14,A15,A16
,A20,A33,Th59;
A39:    a *LjQ=(a*Lj)*Sgm Q1 by A12,A29,Th87;
A40:    len LjQ=len(a*LjQ) by MATRIXR1:16;
A41:    width SM=card P1 by MATRIX_0:24;
A42:    Segm(RLine(M9,i,Lj),P1,Q1)=EqSegm(RLine(M9,i,Lj),P1,Q1) by A16,Def3;
        SR = RLine(SR,m,Line(SR,m)) by MATRIX11:30
          .= RLine(SR,m,Line(SM,m) + a *LjQ) by A10,A5,A13,A29,A37,A35,A39,Th88
;
        then
A43:    Det SR = Det RLine(SR,m,Line(SM,m)) + Det RLine(SR,m,a * LjQ) by A32
,A26,A31,A40,A34,A41,MATRIX11:36
          .= Det RLine(SR,m,Line(SM,m)) + a*Det RLine(SR,m,LjQ) by A32,A26,A31,
MATRIX11:34
          .= Det SM+a*Det EqSegm(RLine(M9,i,Lj),P1,Q1) by A16,A36,A38,A42,Def3;
        per cases;
        suppose
          Det SR <>0.K;
          hence the_rank_of M9<=the_rank_of R by A14,A15,A16,A17,Def4;
        end;
        suppose
A44:      Det SR = 0.K;
          reconsider j0=j as non zero Element of NAT by A1;
          per cases;
          suppose
A45:        i=j;
            then Det SR = Det SM + a * Det SM by A43,MATRIX11:30
              .= 1_K * Det SM + a * Det SM
              .= (1_K+a)*Det SM by VECTSP_1:def 7;
            then 1_K+a=0.K by A18,A44,VECTSP_1:12;
            then a = 0.K - 1_K by VECTSP_2:2
              .= 0.K+(-1_K)
              .= -1_K by RLVECT_1:def 4;
            hence the_rank_of R>=the_rank_of M9 by A2,A45;
          end;
          suppose
A46:        i<>j & j in P1;
            rng Sgm P1=P1 by FINSEQ_1:def 14;
            then consider l be object such that
A47:        l in dom Sgm P1 and
A48:        Sgm P1.l=j0 by A46,FUNCT_1:def 3;
            reconsider l as Element of NAT by A47;
            0.K=Det RLine(SM,m,Line(SM,l))by A32,A33,A26,A46,A47,A48,
MATRIX11:51;
            then
A49:        0.K = a * Det RLine(SM,m,Line(SM,l));
            RLine(SM,m,Line(SM,l))=EqSegm(RLine(M9,i,Lj),P1,Q1) by A11,A15,A16
,A19,A33,A26,A27,A38,A42,A47,A48,Th47,Th59;
            hence the_rank_of R >= the_rank_of M9 by A18,A43,A44,A49,
RLVECT_1:def 4;
          end;
          suppose
A50:        i<>j & not j in P1;
            set Pij=P1\{i}\/{j0};
A51:        not i in P1\{i} by ZFMISC_1:56;
A52:        [:Pij,Q1:] c= Indices R by A1,A9,A14,A15,A16,A23,A50,Th68;
            a*Det EqSegm(RLine(M9,i,Lj),P1,Q1)<>0.K by A18,A43,A44,
RLVECT_1:def 4;
            then
A53:        Det EqSegm(RLine(M9,i,Lj),P1,Q1)<>0.K;
            Det EqSegm(RLine(M9,i,Lj),P1,Q1)=Det EqSegm(M9,Pij,Q1) or
Det EqSegm(RLine(M9,i,Lj),P1,Q1)=-Det EqSegm(M9,Pij,Q1) by A1,A9,A15,A16,A23
,A50,Th68;
            then
A54:        Det EqSegm(M9,Pij,Q1)<>0.K by A53,VECTSP_2:3;
            not i in {j} by A50,TARSKI:def 1;
            then
A55:        not i in Pij by A51,XBOOLE_0:def 3;
A56:        card P1 = card Pij by A1,A9,A15,A16,A23,A50,Th68;
            then EqSegm(M9,Pij,Q1) = Segm(M9,Pij,Q1) by A16,Def3
              .= Segm(R,Pij,Q1) by A14,A52,A55,Th60
              .= EqSegm(R,Pij,Q1) by A16,A56,Def3;
            hence the_rank_of R >= the_rank_of M9 by A16,A17,A54,A56,A52,Def4;
          end;
        end;
      end;
    end;
    consider P,Q such that
A57: [:P,Q:] c= Indices R and
A58: card P = card Q and
A59: card P = the_rank_of R and
A60: Det EqSegm(R,P,Q)<>0.K by Def4;
A61: EqSegm(R,P,Q)=Segm(R,P,Q) by A58,Def3;
A62: EqSegm(M9,P,Q)=Segm(M9,P,Q) by A58,Def3;
    now
      per cases;
      suppose
        not i in P;
        then Segm(M9,P,Q) = Segm(R,P,Q) by A57,A14,Th60;
        hence the_rank_of R<=the_rank_of M9
        by A57,A58,A59,A60,A61,A62,A14,Def4;
      end;
      suppose
A63:    i in P;
        set SM=EqSegm(M9,P,Q);
        set SR=EqSegm(R,P,Q);
A64:    rng Lj c= KK by FINSEQ_1:def 4;
A66:    dom Sgm P=Seg card P by FINSEQ_3:40;
A67:    Q c= Seg W by A57,A58,A14,Th67;
A68:    dom Sgm Q=Seg card Q by FINSEQ_3:40;
A69:    rng Sgm Q c= Seg W by A67,FINSEQ_1:def 14;
        then
A70:    dom (Lj*Sgm Q)=dom Sgm Q by A12,RELAT_1:27;
        then reconsider LjQ=Lj*Sgm Q as FinSequence by A68,FINSEQ_1:def 2;
        rng LjQ c= rng Lj by RELAT_1:26;
        then rng LjQ c= the carrier of K by A64;
        then reconsider LjQ as FinSequence of K by FINSEQ_1:def 4;
A71:    len LjQ=card P by A58,A70,A68,FINSEQ_1:def 3;
        rng Sgm P=P by FINSEQ_1:def 14;
        then consider m be object such that
A72:    m in dom Sgm P and
A73:    Sgm P.m=i by A63,FUNCT_1:def 3;
        reconsider m as Element of NAT by A72;
A74:    len Line(SM,m)=width SM by MATRIX_0:def 7;
A75:    Line(SM,m) = Line(M9,i) * Sgm Q by A62,A72,A73,A66,A67,Th47;
        then
A76:    RLine(SR,m,Line(SM,m))=Segm(M9,P,Q) by A4,A7,A8,A57,A58,A61,A73,Th59;
        Q c= Seg width R by A57,A58,Th67;
        then
A77:    Line(SR,m) = Line(R,i) * Sgm Q by A61,A72,A73,A66,Th47;
A78:    RLine(SR,m,LjQ)=Segm(RLine(M9,i,Lj),P,Q) by A11,A7,A21,A57,A58,A61,A73
,Th59;
A79:    a *LjQ=(a*Lj)*Sgm Q by A12,A69,Th87;
A80:    len LjQ=len(a*LjQ) by MATRIXR1:16;
A81:    width SM=card P by MATRIX_0:24;
A82:    Segm(RLine(M9,i,Lj),P,Q)=EqSegm(RLine(M9,i,Lj),P,Q) by A58,Def3;
        SR = RLine(SR,m,Line(SR,m)) by MATRIX11:30
          .= RLine(SR,m,Line(SM,m) + a *LjQ) by A10,A5,A13,A69,A77,A75,A79,Th88
;
        then
A83:    Det SR = Det RLine(SR,m,Line(SM,m)) + Det RLine(SR,m,a * LjQ) by A72
,A66,A71,A80,A74,A81,MATRIX11:36
          .= Det RLine(SR,m,Line(SM,m)) + a*Det RLine(SR,m,LjQ) by A72,A66,A71,
MATRIX11:34
          .= Det SM+a*Det EqSegm(RLine(M9,i,Lj),P,Q) by A58,A76,A78,A82,Def3;
        per cases;
        suppose
          Det EqSegm(M9,P,Q) <>0.K;
          hence the_rank_of R<=the_rank_of M9 by A57,A58,A59,A14,Def4;
        end;
        suppose
A84:      Det EqSegm(M9,P,Q) =0.K;
          reconsider j0=j as non zero Element of NAT by A1;
          per cases;
          suppose
            i=j;
            then Det SR = Det SM + a * Det SM by A83,MATRIX11:30
              .= 1_K * Det SM + a * Det SM
              .= (1_K+a)*Det SM by VECTSP_1:def 7;
            hence the_rank_of R<=the_rank_of M9 by A60,A84;
          end;
          suppose
A85:        i<>j & j in P;
            rng Sgm P=P by FINSEQ_1:def 14;
            then consider l be object such that
A86:        l in dom Sgm P and
A87:        Sgm P.l=j0 by A85,FUNCT_1:def 3;
            reconsider l as Element of NAT by A86;
A88:        RLine(SM,m,Line(SM,l)) = EqSegm(RLine(M9,i,Lj),P,Q) by A11,A57,A58
,A62,A14,A73,A66,A67,A78,A82,A86,A87,Th47,Th59;
            0.K=Det RLine(SM,m,Line(SM,l))by A72,A73,A66,A85,A86,A87,
MATRIX11:51;
            then 0.K = a * Det RLine(SM,m,Line(SM,l))
              .= Det SM + a* Det EqSegm(RLine(M9,i,Lj),P,Q) by A84,A88,
RLVECT_1:def 4;
            hence the_rank_of R <= the_rank_of M9 by A60,A83;
          end;
          suppose
A89:        i<>j & not j in P;
            set Pij=P\{i}\/{j0};
A90:        card P = card Pij by A1,A9,A57,A58,A63,A89,Th68;
            a*Det EqSegm(RLine(M9,i,Lj),P,Q)<>0.K by A60,A83,A84,RLVECT_1:def 4
;
            then
A91:        Det EqSegm(RLine(M9,i,Lj),P,Q)<>0.K;
            Det EqSegm(RLine(M9,i,Lj),P,Q)=Det EqSegm(M9,Pij,Q) or Det
EqSegm(RLine(M9,i,Lj),P,Q)=-Det EqSegm(M9,Pij,Q) by A1,A9,A57,A58,A14,A63,A89
,Th68;
            then
A92:        Det EqSegm(M9,Pij,Q)<>0.K by A91,VECTSP_2:3;
            [:Pij,Q:] c= Indices M9 by A1,A9,A57,A58,A14,A63,A89,Th68;
            hence the_rank_of R <= the_rank_of M9 by A58,A59,A92,A90,Def4;
          end;
        end;
      end;
    end;
    hence thesis by A22,XXREAL_0:1;
  end;
end;

theorem Th93:
  j in Seg len M9 & j<>i implies the_rank_of DelLine(M9,i) =
  the_rank_of RLine(M9,i,a*Line(M9,j))
proof
  assume that
A1: j in Seg len M9 and
A2: i<>j;
  per cases;
  suppose
A3: i in Seg len M9;
    set Li=Line(M9,i);
    set W=width M9;
    set R=RLine(M9,i,0.K*Li);
A4: W=len (0.K*Li) by CARD_1:def 7;
    then
A5: len R=len M9 by MATRIX11:def 3;
    set Lj=Line(M9,j);
A6: W=len (a*Lj) by CARD_1:def 7;
    reconsider 0Li=0.K*Li,aLj=a*Lj as Element of (the carrier of K)* by
FINSEQ_1:def 11;
    width R=W by A4,MATRIX11:def 3;
    then
A7: RLine(R,i,aLj) = Replace(R,i,aLj) by A6,MATRIX11:29
      .= Replace(Replace(M9,i,0Li),i,aLj) by A4,MATRIX11:29
      .= Replace(M9,i,aLj) by FUNCT_7:34
      .= RLine(M9,i,aLj) by A6,MATRIX11:29;
A8: len M9=n9 by MATRIX_0:def 2;
    then
A9: Line(R,j) =Line(M9,j) by A1,A2,MATRIX11:28;
    Line(R,i)=0.K*Li by A3,A4,A8,MATRIX11:28;
    then
A10: Line(R,i)+a*Line(R,j) = (W|->0.K)+a*Line(M9,j)by A9,FVSUM_1:58
      .= a*Line(M9,j) by FVSUM_1:21;
    W=len Li by CARD_1:def 7;
    hence the_rank_of DelLine(M9,i) = the_rank_of R by Th91
      .= the_rank_of RLine(M9,i,a*Lj)by A1,A2,A5,A10,A7,Th92;
  end;
  suppose
A11: not i in Seg len M9;
    then not i in dom M9 by FINSEQ_1:def 3;
    then DelLine(M9,i)=M9 by FINSEQ_3:104;
    hence thesis by A11,Th40;
  end;
end;

theorem Th94:
  the_rank_of M > 0 iff ex i,j st [i,j] in Indices M & M*(i,j) <> 0.K
proof
  set r=the_rank_of M;
  thus r > 0 implies ex i,j st [i,j] in Indices M & M*(i,j) <> 0.K
  proof
    consider P,Q such that
A1: [:P,Q:] c= Indices M and
A2: card P = card Q and
A3: card P = r and
A4: Det EqSegm(M,P,Q)<>0.K by Def4;
    assume r>0;
    then consider x being object such that
A5: x in P by A3,CARD_1:27,XBOOLE_0:def 1;
    reconsider x as non zero Element of NAT by A5;
    {x} c= P by A5,ZFMISC_1:31;
    then consider Q1 such that
A6: Q1 c= Q and
A7: card {x} = card Q1 and
A8: Det EqSegm(M,{x},Q1) <> 0.K by A2,A4,Th65;
    consider y being object such that
A9: {y}=Q1 by A7,CARD_2:42;
    y in {y} by TARSKI:def 1;
    then reconsider y as non zero Element of NAT by A9;
    take x,y;
    y in Q1 by A9,TARSKI:def 1;
    then [x,y] in [:P,Q:] by A5,A6,ZFMISC_1:87;
    hence [x,y] in Indices M by A1;
A10: card { x } = 1 by CARD_1:30;
    EqSegm(M,{x},Q1) = Segm(M,{x},{y}) by A7,A9,Def3
      .= <*<* M*(x,y) *>*> by Th44;
    hence thesis by A8,A10,MATRIX_3:34;
  end;
  given i,j such that
A11: [i,j] in Indices M and
A12: M*(i,j) <> 0.K;
A13: j in Seg width M by A11,ZFMISC_1:87;
  Indices M = [:Seg len M,Seg width M:] by FINSEQ_1:def 3;
  then
A14: i in Seg len M by A11,ZFMISC_1:87;
  then reconsider i,j as non zero Element of NAT by A13;
A15: card { i } = 1 by CARD_1:30;
A16: card {j}=1 by CARD_1:30;
  then EqSegm(M,{i},{j}) = Segm(M,{i},{j}) by Def3,CARD_1:30
    .= <*<* M*(i,j) *>*> by Th44;
  then
A17: Det EqSegm(M,{i},{j})<>0.K by A12,A15,MATRIX_3:34;
A18: {j} c= Seg width M by A13,ZFMISC_1:31;
  {i} c= Seg len M by A14,ZFMISC_1:31;
  then [:{i},{j}:] c= Indices M by A15,A16,A18,Th67;
  hence thesis by A15,A16,A17,Def4;
end;

theorem
  the_rank_of M = 0 iff M = 0.(K,len M,width M)
proof
  set NULL=0.(K,len M,width M);
  reconsider M9=M as Matrix of len M,width M,K by MATRIX_0:51;
  thus the_rank_of M = 0 implies M = 0.(K,len M,width M)
  proof
    assume
A1: the_rank_of M = 0;
    now
A2:   Indices M9=Indices NULL by MATRIX_0:26;
      let i,j such that
A3:   [i,j] in Indices M9;
      reconsider i9=i,j9=j as Element of NAT by ORDINAL1:def 12;
      M*(i9,j9)=0.K by A1,A3,Th94;
      hence M9*(i,j)=NULL*(i,j) by A3,A2,MATRIX_3:1;
    end;
    hence thesis by MATRIX_0:27;
  end;
  assume
A4: M = NULL;
  assume the_rank_of M<>0;
  then ex i,j st [i,j] in Indices M & M*(i,j) <> 0.K by Th94;
  hence thesis by A4,MATRIX_3:1;
end;

theorem Th96:
  the_rank_of M = 1 iff (ex i,j st [i,j] in Indices M & M*(i,j) <>
  0.K) & for i0,j0,n0,m0 st i0<>j0 & n0<>m0 & [:{i0,j0},{n0,m0}:] c= Indices M
  holds Det EqSegm(M,{i0,j0},{n0,m0}) = 0.K
proof
  consider P,Q such that
A1: [:P,Q:] c= Indices M and
A2: card P = card Q and
A3: card P = the_rank_of M and
A4: Det EqSegm(M,P,Q)<>0.K by Def4;
  thus the_rank_of M = 1 implies (ex i,j st [i,j] in Indices M & M*(i,j)<>0.K)
  & for i0,j0,n0,m0 st i0<>j0 & n0<>m0 & [:{i0,j0},{n0,m0}:] c= Indices M holds
  Det EqSegm(M,{i0,j0},{n0,m0}) = 0.K
  proof
    assume
A5: the_rank_of M = 1;
    hence ex i,j st [i,j] in Indices M & M*(i,j) <> 0.K by Th94;
    let i0,j0,n0,m0 such that
A6: i0<>j0 and
A7: n0<>m0 and
A8: [:{i0,j0},{n0,m0}:] c= Indices M;
A9: card {n0,m0}=2 by A7,CARD_2:57;
    assume
A10: Det EqSegm(M,{i0,j0},{n0,m0}) <> 0.K;
    card {i0,j0} =2 by A6,CARD_2:57;
    hence thesis by A5,A8,A10,A9,Def4;
  end;
  assume ex i,j st [i,j] in Indices M & M*(i,j) <> 0.K;
  then
A11: the_rank_of M>0 by Th94;
  assume
A12: for i0,j0,n0,m0 st i0<>j0 & n0<>m0 & [:{i0,j0},{n0,m0}:]c=Indices M
  holds Det EqSegm(M,{i0,j0},{n0,m0}) = 0.K;
  assume the_rank_of M <> 1;
  then card P>1 by A11,A3,NAT_1:25;
  then card P>=1+1 by NAT_1:13;
  then consider P1 be finite Subset of P such that
A13: card P1=2 by FINSEQ_4:72;
  not 0 in P1;
  then reconsider P1 as without_zero finite Subset of NAT by MEASURE6:def 2
,XBOOLE_1:1;
  consider Q1 such that
A14: Q1 c=Q and
A15: card P1=card Q1 and
A16: Det EqSegm(M,P1,Q1)<>0.K by A2,A4,Th65;
  consider n,m be object such that
A17: n <> m and
A18: Q1 = {n,m} by A13,A15,CARD_2:60;
A19: n in Q1 by A18,TARSKI:def 2;
  m in Q1 by A18,TARSKI:def 2;
  then reconsider n,m as non zero Element of NAT by A19;
  consider i,j be object such that
A20: i <> j and
A21: P1 = {i,j} by A13,CARD_2:60;
A22: i in P1 by A21,TARSKI:def 2;
  j in P1 by A21,TARSKI:def 2;
  then reconsider i,j as non zero Element of NAT by A22;
  [:P1,Q1:] c= [:P,Q:] by A14,ZFMISC_1:96;
  then [:{i,j},{n,m}:] c= Indices M by A1,A21,A18;
  hence thesis by A12,A20,A21,A16,A17,A18;
end;

theorem Th97:
  the_rank_of M = 1 iff (ex i,j st [i,j] in Indices M & M*(i,j) <>
0.K) & for i,j,n,m st [:{i,j},{n,m}:] c= Indices M holds M*(i,n) * (M*(j,m)) =
  M*(i,m) * (M*(j,n))
proof
  thus the_rank_of M=1 implies (ex i,j st [i,j] in Indices M & M*(i,j)<>0.K)&
for i,j,n,m st [:{i,j},{n,m}:]c=Indices M holds M*(i,n)*(M*(j,m))=M*(i,m)*(M*(j
  ,n))
  proof
    assume
A1: the_rank_of M=1;
    hence ex i,j st [i,j] in Indices M & M*(i,j)<>0.K by Th96;
    let i,j,n,p be Nat such that
A2: [:{i,j},{n,p}:] c= Indices M;
    per cases;
    suppose
      i=j or n=p;
      hence thesis;
    end;
    suppose
A3:   i<>j & n<>p;
      Indices M=[:Seg len M,Seg width M:] by FINSEQ_1:def 3;
      then
A4:   {i,j}c=Seg len M by A2,ZFMISC_1:114;
A5:   i in {i,j} by TARSKI:def 2;
A6:   n in {n,p} by TARSKI:def 2;
A7:   p in {n,p} by TARSKI:def 2;
A8:   j in {i,j} by TARSKI:def 2;
      {n,p}c=Seg width M by A2,ZFMISC_1:114;
      then reconsider I=i,J=j,P=p,N=n as non zero Element of NAT by A4,A5,A8,A7
,A6;
A9:   card {I,J}=2 by A3,CARD_2:57;
      set JP=M*(J,P);
      set JN=M*(J,N);
      set IP=M*(I,P);
      set IN=M*(I,N);
A10:  Det EqSegm(M,{I,J},{N,P}) = 0.K by A1,A2,A3,Th96;
      card {N,P}=2 by A3,CARD_2:57;
      then
A11:  EqSegm(M,{I,J},{N,P})=Segm(M,{I,J},{N,P}) by A9,Def3;
      per cases by A3,XXREAL_0:1;
      suppose
        I<J & N<P;
        then 0.K = Det(IN,IP)][(JN,JP) by A9,A11,A10,Th45
          .= IN*JP-IP*JN by MATRIX_9:13;
        hence thesis by VECTSP_1:19;
      end;
      suppose
        I<J & N>P;
        then 0.K = Det(IP,IN)][(JP,JN) by A9,A11,A10,Th45
          .= IP*JN-IN*JP by MATRIX_9:13;
        hence thesis by VECTSP_1:19;
      end;
      suppose
        I>J & N<P;
        then 0.K = Det(JN,JP)][(IN,IP) by A9,A11,A10,Th45
          .= JN*IP-JP*IN by MATRIX_9:13;
        hence thesis by VECTSP_1:19;
      end;
      suppose
        I>J & N>P;
        then 0.K = Det(JP,JN)][(IP,IN) by A9,A11,A10,Th45
          .= JP*IN-JN*IP by MATRIX_9:13;
        hence thesis by VECTSP_1:19;
      end;
    end;
  end;
  assume that
A12: ex i,j st [i,j] in Indices M & M*(i,j) <> 0.K and
A13: for i,j,n,m st [:{i,j},{n,m}:] c= Indices M holds M*(i,n)*(M*(j,m))
  =M*(i,m)*(M*(j,n));
  now
    let i0,j0,n0,m0 such that
A14: i0<>j0 and
A15: n0<>m0 and
A16: [:{i0,j0},{n0,m0}:] c= Indices M;
A17: card {i0,j0}=2 by A14,CARD_2:57;
    set JM=M*(j0,m0);
    set JN=M*(j0,n0);
    set IM=M*(i0,m0);
    set IN=M*(i0,n0);
A18: IN*JM=IM*JN by A13,A16;
    card {n0,m0}=2 by A15,CARD_2:57;
    then
A19: EqSegm(M,{i0,j0},{n0,m0})=Segm(M,{i0,j0},{n0,m0}) by A17,Def3;
    per cases by A14,A15,XXREAL_0:1;
    suppose
      i0<j0 & n0<m0;
      then EqSegm(M,{i0,j0},{n0,m0}) = (IN,IM)][(JN,JM) by A19,Th45;
      hence Det EqSegm(M,{i0,j0},{n0,m0}) = IN*JM-IM*JN by A17,MATRIX_9:13
        .= 0.K by A18,VECTSP_1:19;
    end;
    suppose
      i0<j0 & n0>m0;
      then EqSegm(M,{i0,j0},{n0,m0} )= (IM,IN)][(JM,JN) by A19,Th45;
      hence Det EqSegm(M,{i0,j0},{n0,m0}) = IM*JN-IN*JM by A17,MATRIX_9:13
        .= 0.K by A18,VECTSP_1:19;
    end;
    suppose
      i0>j0 & n0<m0;
      then EqSegm(M,{i0,j0},{n0,m0}) = (JN,JM)][(IN,IM) by A19,Th45;
      hence Det EqSegm(M,{i0,j0},{n0,m0}) = JN*IM-JM*IN by A17,MATRIX_9:13
        .= 0.K by A18,VECTSP_1:19;
    end;
    suppose
      i0>j0 & n0>m0;
      then EqSegm(M,{i0,j0},{n0,m0})=(JM,JN)][(IM,IN) by A19,Th45;
      hence Det EqSegm(M,{i0,j0},{n0,m0}) = JM*IN-JN*IM by A17,MATRIX_9:13
        .= 0.K by A18,VECTSP_1:19;
    end;
  end;
  hence thesis by A12,Th96;
end;

theorem
  the_rank_of M = 1 iff ex i st i in Seg len M & (ex j st j in Seg width
  M & M*(i,j) <> 0.K) & for k st k in Seg len M ex a st Line(M,k) =a*Line(M,i)
proof
A1: Indices M=[:Seg len M,Seg width M:] by FINSEQ_1:def 3;
  thus the_rank_of M = 1 implies ex i st i in Seg len M & (ex j st j in Seg
width M & M*(i,j) <> 0.K) & for k st k in Seg len M ex a st Line(M,k) = a*Line(
  M,i)
  proof
    assume
A2: the_rank_of M = 1;
    then consider i,j such that
A3: [i,j] in Indices M and
A4: M*(i,j) <> 0.K by Th97;
    take i;
A5: j in Seg width M by A3,ZFMISC_1:87;
    hence
    i in Seg len M & ex j st j in Seg width M & M*(i,j) <> 0.K by A1,A3,A4,
ZFMISC_1:87;
    set Li=Line(M,i);
    set ij=M*(i,j);
    let k such that
A6: k in Seg len M;
    set Lk=Line(M,k);
    set kj=M*(k,j);
    take a=kj * ij";
A7: i in Seg len M by A1,A3,ZFMISC_1:87;
A8: now
      let n such that
A9:   1<=n and
A10:  n<=width M;
A11:  n in Seg width M by A9,A10;
      then
A12:  {j,n} c= Seg width M by A5,ZFMISC_1:32;
      Li.n = M*(i,n) by A11,MATRIX_0:def 7;
      then
A13:  (a*Li).n=a*(M*(i,n)) by A11,FVSUM_1:51;
A14:  kj = kj * 1_K
        .= kj * (ij * ij") by A4,VECTSP_1:def 10
        .= a * ij by GROUP_1:def 3;
      {i,k} c= Seg len M by A7,A6,ZFMISC_1:32;
      then [:{i,k},{j,n}:] c= Indices M by A1,A12,ZFMISC_1:96;
      then
A15:  ij*(M*(k,n)) = a*ij *(M*(i,n)) by A2,A14,Th97
        .= ij * (a * (M*(i,n))) by GROUP_1:def 3;
      Lk.n=M*(k,n) by A11,MATRIX_0:def 7;
      hence Lk.n=(a*Li).n by A4,A15,A13,VECTSP_2:8;
    end;
A16: len (a*Li)=width M by CARD_1:def 7;
    len Lk=width M by CARD_1:def 7;
    hence thesis by A16,A8;
  end;
  given i such that
A17: i in Seg len M and
A18: ex j st j in Seg width M & M*(i,j) <> 0.K and
A19: for k st k in Seg len M ex a st Line(M,k) = a*Line(M,i);
A20: now
    set Li=Line(M,i);
    let I,J,n,m be Nat such that
A21: [:{I,J},{n,m}:]c=Indices M;
A22: {n,m} c= Seg width M by A21,ZFMISC_1:114;
    then
A23: n in Seg width M by ZFMISC_1:32;
    then
A24: Li.n=M*(i,n) by MATRIX_0:def 7;
    set LJ=Line(M,J);
    set LI=Line(M,I);
A25: {I,J} c= Seg len M by A1,A21,ZFMISC_1:114;
    then I in Seg len M by ZFMISC_1:32;
    then consider a such that
A26: LI = a*Li by A19;
    J in Seg len M by A25,ZFMISC_1:32;
    then consider b such that
A27: LJ = b*Li by A19;
    LJ.n=M*(J,n) by A23,MATRIX_0:def 7;
    then
A28: M*(J,n)= b * (M*(i,n)) by A27,A23,A24,FVSUM_1:51;
A29: m in Seg width M by A22,ZFMISC_1:32;
    then
A30: Li.m=M*(i,m) by MATRIX_0:def 7;
    LJ.m=M*(J,m) by A29,MATRIX_0:def 7;
    then
A31: M*(J,m)= b *(M*(i,m)) by A27,A29,A30,FVSUM_1:51;
    LI.m=M*(I,m) by A29,MATRIX_0:def 7;
    then
A32: M*(I,m)= a * (M*(i,m)) by A26,A29,A30,FVSUM_1:51;
    LI.n=M*(I,n) by A23,MATRIX_0:def 7;
    then M*(I,n)= a * (M*(i,n)) by A26,A23,A24,FVSUM_1:51;
    hence M*(I,n) * (M*(J,m)) = (a * (M*(i,n)) * b) * (M*(i,m)) by A31,
GROUP_1:def 3
      .= (b *(M*(i,n)) * a) * (M*(i,m)) by GROUP_1:def 3
      .= M*(I,m) * (M*(J,n)) by A28,A32,GROUP_1:def 3;
  end;
  consider j such that
A33: j in Seg width M and
A34: M*(i,j) <> 0.K by A18;
  [i,j] in Indices M by A1,A17,A33,ZFMISC_1:87;
  hence thesis by A34,A20,Th97;
end;

registration
  let K;
  cluster diagonal for Matrix of K;
  existence
  proof
    set E = the diagonal Matrix of 1,K;
    take E;
    thus thesis;
  end;
end;

theorem Th99:
  for M be diagonal Matrix of K for NonZero1 be set st NonZero1 = {i
where i is Element of NAT:[i,i] in Indices M & M*(i,i)<>0.K} for P,Q st [:P,Q:]
c= Indices M & card P = card Q & Det EqSegm(M,P,Q)<>0.K holds P c= NonZero1 & Q
  c= NonZero1
proof
  let M be diagonal Matrix of K;
  let NonZero1 be set such that
A1: NonZero1={i where i is Element of NAT:[i,i] in Indices M&M*(i,i)<>0.K };
  let P,Q such that
A2: [:P,Q:] c= Indices M and
A3: card P = card Q and
A4: Det EqSegm(M,P,Q)<>0.K;
  set S=Segm(M,P,Q);
  set SQ=Sgm Q;
  set SP=Sgm P;
  set ES=EqSegm(M,P,Q);
A5: Indices S=[:Seg len S,Seg width S:] by FINSEQ_1:def 3;
A6: ES=S by A3,Def3;
  thus P c= NonZero1
  proof
    assume not P c= NonZero1;
    then consider x being object such that
A7: x in P and
A8: not x in NonZero1;
A10: rng SP=P by FINSEQ_1:def 14;
    then consider y being object such that
A11: y in dom SP and
A12: SP.y=x by A7,FUNCT_1:def 3;
    reconsider x,y as Element of NAT by A7,A11;
    set L=Line(S,y);
A13: dom SP=Seg card P by FINSEQ_3:40;
A14: rng SQ=Q by FINSEQ_1:def 14;
A15: now
      let i such that
A16:  1<=i and
A17:  i<=width S;
A18:  i in Seg width S by A16,A17;
      then
A19:  L.i=S*(y,i) by MATRIX_0:def 7;
      y in Seg len S by A3,A13,A11,MATRIX_0:24;
      then
A20:  [y,i] in Indices S by A5,A18,ZFMISC_1:87;
      then
A21:  S*(y,i)=M*(x,SQ.i) by A12,Def1;
A22:  0.K*0.K=0.K;
A23:  SQ.i<>x or SQ.i=x;
      [x,SQ.i] in Indices M by A2,A10,A14,A12,A20,Th17;
      then L.i=0.K by A1,A8,A21,A19,A23,MATRIX_1:def 10;
      hence L.i=(0.K*L).i by A18,A22,FVSUM_1:51;
    end;
A24: len L=width S by MATRIX_0:def 7;
    len L=len (0.K* L) by MATRIXR1:16;
    then Line(S,y) = 0.K*Line(S,y) by A24,A15;
    then
A25: Det(RLine(ES,y,Line(ES,y))) = 0.K*Det(ES) by A6,A13,A11,MATRIX11:35;
    RLine(ES,y,Line(ES,y))=ES by MATRIX11:30;
    hence thesis by A4,A25;
  end;
A26: dom S=Seg len S by FINSEQ_1:def 3;
A27: len S=card P by A3,MATRIX_0:24;
A28: width S=card P by A3,MATRIX_0:24;
  thus Q c= NonZero1
  proof
A30: dom SQ=Seg card Q by FINSEQ_3:40;
    assume not Q c= NonZero1;
    then consider x being object such that
A31: x in Q and
A32: not x in NonZero1;
A33: rng SQ=Q by FINSEQ_1:def 14;
    then consider y being object such that
A34: y in dom SQ and
A35: SQ.y=x by A31,FUNCT_1:def 3;
    reconsider x,y as Element of NAT by A31,A34;
    set C=Col(ES,y);
A36: rng SP=P by FINSEQ_1:def 14;
    now
      let k be Element of NAT such that
A37:  k in Seg card P;
A38:  S*(k,y)=C.k by A6,A27,A26,A37,MATRIX_0:def 8;
A39:  [k,y] in Indices S by A3,A5,A27,A28,A30,A34,A37,ZFMISC_1:87;
      then
A40:  S*(k,y)=M*(SP.k,x) by A35,Def1;
A41:  SP.k<>x or SP.k=x;
      [SP.k,x] in Indices M by A2,A36,A33,A35,A39,Th17;
      hence C.k=0.K by A1,A32,A40,A38,A41,MATRIX_1:def 10;
    end;
    hence thesis by A3,A4,A30,A34,MATRIX_9:53;
  end;
end;

theorem Th100:
  for M be diagonal Matrix of K for P st [:P,P:] c= Indices M
  holds Segm(M,P,P) is diagonal
proof
  let M be diagonal Matrix of K;
  let P such that
A1: [:P,P:] c= Indices M;
  set S=Segm(M,P,P);
  set SP=Sgm P;
  let i,j be Nat such that
A2: i in Seg card P and
A3: j in Seg card P and
A4: i <> j;
A6: SP is one-to-one by FINSEQ_3:92;
  [i,j] in [:Seg card P,Seg card P:] by A2,A3,ZFMISC_1:87;
  then
A7: [i,j] in Indices S by MATRIX_0:24;
  dom SP=Seg card P by FINSEQ_3:40;
  then
A8: SP.i<>SP.j by A2,A3,A4,A6;
  rng SP=P by FINSEQ_1:def 14;
  then
A9: [SP.i,SP.j] in Indices M by A1,A7,Th17;
  S*(i,j)=M*(SP.i,SP.j) by A7,Def1;
  hence thesis by A9,A8,MATRIX_1:def 10;
end;

theorem
  for M be diagonal Matrix of K for NonZero1 be set st NonZero1={i where i
is Element of NAT:[i,i] in Indices M & M*(i,i)<>0.K} holds the_rank_of M = card
  NonZero1
proof
  let M be diagonal Matrix of K;
  consider P,Q such that
A1: [:P,Q:] c= Indices M and
A2: card P = card Q and
A3: card P = the_rank_of M and
A4: Det EqSegm(M,P,Q)<>0.K by Def4;
  let NZ be set such that
A5: NZ={i where i is Element of NAT:[i,i] in Indices M & M*(i,i)<>0.K};
A6: NZ c= Seg width M
  proof
    let x be object;
    assume x in NZ;
    then ex i be Element of NAT st x=i & [i,i] in Indices M & M*(i,i)<>0.K by
A5;
    hence thesis by ZFMISC_1:87;
  end;
  then not 0 in NZ;
  then reconsider nz=NZ as without_zero finite Subset of NAT by A6,
MEASURE6:def 2,XBOOLE_1:1;
  set S=Segm(M,nz,nz);
  NZ c= dom M
  proof
    let x be object;
    assume x in NZ;
    then ex i be Element of NAT st x=i & [i,i] in Indices M & M*(i,i)<>0.K by
A5;
    hence thesis by ZFMISC_1:87;
  end;
  then
A7: [:nz,nz:] c= Indices M by A6,ZFMISC_1:96;
  then reconsider S as diagonal Matrix of card nz,K by Th100;
  set d=diagonal_of_Matrix S;
  now
    per cases by NAT_1:14;
    suppose
      card nz=0;
      then Det S=1_K by MATRIXR2:41;
      hence Det S<>0.K;
    end;
    suppose
A8:   card nz>=1;
      set Sn=Sgm nz;
A9:   now
A10:    rng Sn=nz by FINSEQ_1:def 14;
A11:    dom d=Seg len d by FINSEQ_1:def 3;
A12:    len d=card nz by MATRIX_3:def 10;
        let k be Nat such that
A13:    k in dom d;
A14:    d.k=S*(k,k) by A13,A11,A12,MATRIX_3:def 10;
        dom Sn=dom d by A11,A12,FINSEQ_3:40;
        then Sn.k in nz by A13,A10,FUNCT_1:def 3;
        then
A15:    ex i be Element of NAT st i=Sn.k & [i,i] in Indices M & M*(i,i)<>
        0.K by A5;
        Indices S=[:Seg card nz,Seg card nz:] by MATRIX_0:24;
        then [k,k] in Indices S by A13,A11,A12,ZFMISC_1:87;
        hence d.k <> 0.K by A14,A15,Def1;
      end;
      Det S = Product d by A8,MATRIX_7:17;
      hence Det S<>0.K by A9,FVSUM_1:82;
    end;
  end;
  then Det EqSegm(M,nz,nz)<>0.K by Def3;
  then
A16: the_rank_of M >= card nz by A7,Def4;
  P c= nz by A5,A1,A2,A4,Th99;
  then card P <= card nz by NAT_1:43;
  hence thesis by A16,A3,XXREAL_0:1;
end;

reserve v,v1,v2,u,w for Vector of n-VectSp_over K,
  t,t1,t2 for Element of n -tuples_on the carrier of K,

  L for Linear_Combination of n-VectSp_over K,
  M,M1 for Matrix of m,n,K;

theorem Th102:
  the carrier of n -VectSp_over K = n-tuples_on the carrier of K
& 0.(n -VectSp_over K) = n |-> 0.K & ( t1 = v1 & t2 = v2 implies t1 + t2 = v1 +
  v2 ) & ( t = v implies a * t = a * v )
proof
A1: the addLoopStr of n -VectSp_over K=n-Group_over K by PRVECT_1:def 5;
A2: n-Group_over K=addLoopStr(# n-tuples_on the carrier of K, product(the
    addF of K,n), (n |-> 0.K) qua Element of n-tuples_on the carrier of K#)
by PRVECT_1:def 3;
  hence the carrier of n -VectSp_over K = n-tuples_on the carrier of K & 0.(n
  -VectSp_over K) =(n |-> 0.K) by A1;
  thus t1 = v1 & t2 = v2 implies t1 + t2 = v1 + v2 by A2,A1,PRVECT_1:def 1;
  assume
A3: t=v;
  rng t c= the carrier of K by RELAT_1:def 19;
  then
A4: (id (the carrier of K))*t=t by RELAT_1:53;
  thus a*v = (n-Mult_over K).(a,v) by PRVECT_1:def 5
    .= (the multF of K)[;](a,t) by A3,PRVECT_1:def 4
    .= a*t by A4,FUNCOP_1:34;
end;

registration
  let K,n;
  cluster n -VectSp_over K -> right_complementable Abelian add-associative
     right_zeroed;
  coherence
  proof
    set nV = n -VectSp_over K;
A1: now
      let v,u;
      reconsider V=v,U=u as Element of n-tuples_on the carrier of K by Th102;
      thus v + u = V + U by Th102
        .= U + V by FINSEQOP:33
        .= u + v by Th102;
    end;
A2: now
      let v;
      reconsider V=v,n0=0.nV as Element of n-tuples_on the carrier of K by
Th102;
      thus v + 0.nV = V + n0 by Th102
        .= V + (n|->0.K) by Th102
        .= v by FVSUM_1:21;
    end;
A3: nV is right_complementable
    proof
      reconsider N=n as Element of NAT by ORDINAL1:def 12;
      let v;
      reconsider V=v as Element of N-tuples_on the carrier of K by Th102;
      reconsider u=-V as Element of nV by Th102;
      v + u = V+ -V by Th102
        .= n|->0.K by FVSUM_1:26
        .= 0.nV by Th102;
      hence ex u st v+u=0.nV;
    end;
    now
      let u,v,w;
      reconsider V=v,U=u,W=w,UV=u+v,VW=v+w as Element of n-tuples_on the
      carrier of K by Th102;
      thus (u + v) + w = UV + W by Th102
        .= (U + V) + W by Th102
        .= U + (V + W) by FINSEQOP:28
        .= U + VW by Th102
        .= u + (v + w) by Th102;
    end;
    hence thesis by A2,A3,A1,RLVECT_1:def 2,def 3,def 4;
  end;
end;

registration
  let K,n;
  cluster -> Function-like Relation-like for Vector of n-VectSp_over K;
  correctness
  proof
    let v be Element of n-VectSp_over K;
    v is Element of n-tuples_on the carrier of K by Th102;
    hence thesis;
  end;
end;

Lm7: rng M is Subset of n-VectSp_over K
proof
  rng M c= the carrier of n-VectSp_over K
  proof
    consider m such that
A1: for x st x in rng M ex p st x = p & len p = m by MATRIX_0:9;
    let x be object such that
A2: x in rng M;
    consider p such that
A3: x=p and
    len p =m by A2,A1;
    len p=n by A2,A3,MATRIX_0:def 2;
    then p is Element of n-tuples_on the carrier of K by FINSEQ_2:92;
    then p in n-tuples_on the carrier of K;
    hence thesis by A3,Th102;
  end;
  hence thesis;
end;

notation
  let K,m,n;
  let M be Matrix of m,n,K;
  synonym lines↑ M for rng M;
  synonym M is without_repeated_line for M is one-to-one;
end;

definition
  let K be Field,m,n;
  let M be Matrix of m,n,K;
  redefine func lines M -> Subset of n-VectSp_over K;  :: redefines lines (MATRIX13, synonym) → rng (FUNCT_1, redefinition) → rng (RELAT_1, synonym) → proj2 (XTUPLE_0, definition)
  coherence by Lm7;
end;

theorem Th103:
  x in lines M iff ex i st i in Seg m & x = Line(M,i)
proof
  thus x in lines M implies ex i st i in Seg m & x = Line(M,i)
  proof
    assume x in lines M;
    then consider i be object such that
A1: i in dom M and
A2: M.i=x by FUNCT_1:def 3;
A3: len M=m by MATRIX_0:def 2;
    reconsider i as Element of NAT by A1;
A4: dom M=Seg len M by FINSEQ_1:def 3;
    then M.i=Line(M,i) by A1,A3,MATRIX_0:52;
    hence thesis by A1,A2,A4,A3;
  end;
  given i such that
A5: i in Seg m and
A6: x = Line(M,i);
A7: len M=m by MATRIX_0:def 2;
  dom M=Seg len M by FINSEQ_1:def 3;
  then M.i in rng M by A5,A7,FUNCT_1:def 3;
  hence thesis by A5,A6,MATRIX_0:52;
end;

theorem
  for V be finite Subset of n-VectSp_over K ex M be Matrix of card V,n,K
  st M is without_repeated_line & lines M = V
proof
  let V be finite Subset of n-VectSp_over K;
  set cV=card V;
  card Seg cV=cV by FINSEQ_1:57;
  then Seg cV,V are_equipotent by CARD_1:5;
  then consider m be Function such that
A1: m is one-to-one and
A2: dom m = Seg cV and
A3: rng m=V by WELLORD2:def 4;
  reconsider M=m as FinSequence by A2,FINSEQ_1:def 2;
  now
    let x;
    assume x in rng M;
    then reconsider p=x as Element of n-tuples_on the carrier of K by A3,Th102;
    len p=n by CARD_1:def 7;
    hence ex p st x = p & len p = n;
  end;
  then reconsider M as Matrix of K by MATRIX_0:9;
A4: len M=cV by A2,FINSEQ_1:def 3;
  the carrier of n -VectSp_over K = n-tuples_on the carrier of K by Th102;
  then for p st p in rng M holds len p=n by A3,CARD_1:def 7;
  then M is Matrix of cV,n,K by A4,MATRIX_0:def 2;
  hence thesis by A1,A3;
end;

definition
  let K,n;
  let F be FinSequence of n-VectSp_over K;
  func FinS2MX F -> Matrix of len F,n,K equals
  F;
  coherence
  proof
A1: F is FinSequence of n-tuples_on the carrier of K by Th102;
    now
A2:   rng F c= n-tuples_on the carrier of K by A1,FINSEQ_1:def 4;
      let x;
      assume x in rng F;
      then reconsider p=x as Element of n-tuples_on the carrier of K by A2;
      len p=n by CARD_1:def 7;
      hence ex p st x = p & len p = n;
    end;
    then reconsider F9=F as Matrix of K by MATRIX_0:9;
    now
A3:   rng F9 c= n-tuples_on the carrier of K by A1,FINSEQ_1:def 4;
      let p;
      assume p in rng F9;
      hence len p=n by A3,CARD_1:def 7;
    end;
    hence thesis by MATRIX_0:def 2;
  end;
end;

definition
  let K,m,n;
  let M be Matrix of m,n,K;
  func MX2FinS M -> FinSequence of n-VectSp_over K equals
  M;
  coherence
  proof
    lines M is Subset of n-VectSp_over K;
    hence thesis by FINSEQ_1:def 4;
  end;
end;

theorem Th105:
  the_rank_of M = m implies M is without_repeated_line
proof
  assume
A1: the_rank_of M = m;
A2: len M = m by MATRIX_0:def 2;
  assume not M is without_repeated_line;
  then consider x1,x2 be object such that
A3: x1 in dom M and
A4: x2 in dom M and
A5: M.x1=M.x2 and
A6: x1<>x2;
  reconsider x1,x2 as Element of NAT by A3,A4;
  consider k such that
A7: len M = k + 1 and
A8: len Del(M,x1) = k by A3,FINSEQ_3:104;
A9: dom M=Seg len M by FINSEQ_1:def 3;
  then
A10: M.x2=Line(M,x2) by A4,A2,MATRIX_0:52;
  M.x1=Line(M,x1) by A3,A9,A2,MATRIX_0:52;
  then M = RLine(M,x1,Line(M,x2)) by A5,A10,MATRIX11:30
    .= RLine(M,x1,1_K*Line(M,x2)) by FVSUM_1:57;
  then m = the_rank_of DelLine(M,x1) by A1,A4,A6,A9,Th93;
  then m <= k by A8,Th74;
  hence thesis by A2,A7,NAT_1:13;
end;

theorem Th106:
  i in Seg len M & a = L.(M.i) implies Line(FinS2MX(L (#) MX2FinS
  M),i) = a * Line(M,i)
proof
  assume that
A1: i in Seg len M and
A2: a = L.(M.i);
  set MX=MX2FinS M;
  set LM=L (#) MX;
  i in dom M by A1,FINSEQ_1:def 3;
  then
A3: M.i=MX/.i by PARTFUN1:def 6;
  len M=m by MATRIX_0:def 2;
  then
A4: Line(M,i)=M.i by A1,MATRIX_0:52;
  then reconsider
  L=Line(M,i) as Element of n-tuples_on the carrier of K by A3,Th102;
  set FLM = FinS2MX LM;
A5: len LM=len M by VECTSP_6:def 5;
  then
A6: i in dom FLM by A1,FINSEQ_1:def 3;
  Line(FLM,i)=FLM.i by A1,A5,MATRIX_0:52;
  hence Line(FLM,i) = a *MX/.i by A2,A3,A6,VECTSP_6:def 5
    .= a*L by A3,A4,Th102
    .= a*Line(M,i);
end;

theorem Th107:
  M is without_repeated_line & Carrier L c= lines M & i in Seg n
  implies (Sum L).i = Sum Col(FinS2MX(L (#) MX2FinS M),i)
proof
  assume that
A1: M is without_repeated_line and
A2: Carrier L c= lines M and
A3: i in Seg n;
  set MX=MX2FinS M;
  set V=n-VectSp_over K;
  set LM=L (#) MX;
A4: len LM=len M by VECTSP_6:def 5;
  set FLM = FinS2MX LM;
  set C=Col(FLM,i);
  len LM=len C by MATRIX_0:def 8;
  then consider g be sequence of  the carrier of K such that
A5: Sum C = g.(len M) and
A6: g.0 = 0.K and
A7: for j be Nat,a st j < len M & a = C.(j+1) holds g.(j+1)
  = g.j+a by A4,RLVECT_1:def 12;
  Sum L = Sum LM by A1,A2,VECTSP_9:3;
  then consider f be sequence of  the carrier of V such that
A8: Sum L = f.(len M) and
A9: f.0 = 0.V and
A10: for j be Nat,v st j < len M & v = LM.(j+1) holds f.(j+1)
  = f.j+v by A4,RLVECT_1:def 12;
  defpred P[Nat] means $1 <= len M implies for v be Element of V st v=f.$1
  holds v.i=g.$1;
A11: len M=m by MATRIX_0:def 2;
A12: for k st P[k] holds P[k+1]
  proof
    reconsider N=n as Element of NAT by ORDINAL1:def 12;
    let k such that
A13: P[k];
    set k1=k+1;
    reconsider kk=k as Element of NAT by ORDINAL1:def 12;
    assume
A14: k1 <= len M;
    then
A15: k<len M by NAT_1:13;
A16: width FLM=n by A4,A14,Th1;
    1<=k1 by NAT_1:14;
    then
A17: k1 in Seg len M by A14;
    then
A18: k1 in dom FLM by A4,FINSEQ_1:def 3;
A19: MX.k1=Line(M,k1) by A11,A17,MATRIX_0:52;
    then MX.k1 in lines M by A11,A17,Th103;
    then reconsider MXK1=MX.k1 as Element of V;
    k1 in dom MX by A17,FINSEQ_1:def 3;
    then MX/.k1=MX.k1 by PARTFUN1:def 6;
    then
A20: LM.k1 = L.MXK1 * MXK1 by A18,VECTSP_6:def 5;
    then reconsider LMK1=LM.k1 as Element of V;
    let v;
    assume v=f.k1;
    then
A21: v=LMK1 +f.kk by A10,A15;
    reconsider lmk1=LMK1,mxk1=MXK1,fk=f.kk as Element of N-tuples_on the
    carrier of K by Th102;
    LMK1 = L.MXK1 * mxk1 by A20,Th102
      .= Line(FLM,k1) by A17,A19,Th106;
    then
A22: LMK1.i = FLM*(k1,i) by A3,A16,MATRIX_0:def 7;
    dom lmk1=Seg n by FINSEQ_2:124;
    then
A23: lmk1.i in rng lmk1 by A3,FUNCT_1:def 3;
    rng lmk1 c= the carrier of K by FINSEQ_1:def 4;
    then reconsider lmk1i=lmk1.i as Element of K by A23;
    C.k1 = FLM*(k1,i) by A18,MATRIX_0:def 8;
    then
A24: g.k1=lmk1i + g.kk by A7,A22,A15;
A25: LMK1 +f.kk=lmk1 +fk by Th102;
    fk.i = g.kk by A13,A14,NAT_1:13;
    hence v.i=g.k1 by A3,A24,A21,A25,FVSUM_1:18;
  end;
A26: P[0]
  proof
    assume 0 <= len M;
A27: 0.V=n|->0.K by Th102;
    let v;
    assume v=f.0;
    hence v.i=g.0 by A3,A9,A6,A27,FINSEQ_2:57;
  end;
  for k holds P[k] from NAT_1:sch 2(A26,A12);
  hence thesis by A8,A5;
end;

theorem Th108:
  for M,M1 st M is without_repeated_line & for i st i in Seg m
  holds ex a st Line(M1,i) = a * Line(M,i) holds ex L be Linear_Combination of
  lines M st L (#) MX2FinS M = M1
proof
  let M,M1 such that
A1: M is without_repeated_line and
A2: for i st i in Seg m ex a st Line(M1,i) = a * Line(M,i);
  set V=n-VectSp_over K;
  defpred P[set,set] means for i st $1=i ex a st a=$2 & Line(M1,i) = a * Line(
  M,i);
A3: for k st k in Seg len M ex x be Element of K st P[k,x]
  proof
A4: len M=m by MATRIX_0:def 2;
    let k;
    assume k in Seg len M;
    then consider a such that
A5: Line(M1,k) = a * Line(M,k) by A2,A4;
    take a;
    thus thesis by A5;
  end;
  consider p such that
A6: dom p = Seg len M and
A7: for k st k in Seg len M holds P[k,p.k] from FINSEQ_1:sch 5(A3);
  defpred Q[object,object] means
   for v st $1=v holds (not v in lines M implies $2=0.
  K) & (v in lines M implies for k st k in Seg m & v=Line(M,k) holds $2=p.k);
A8: for x being object st x in the carrier of V
ex y being object st y in the carrier of K & Q[x,y]
  proof
    let x be object;
    assume x in the carrier of V;
    then reconsider v=x as Element of V;
    per cases;
    suppose
A9:   v in lines M;
A10:  rng p c= the carrier of K by FINSEQ_1:def 4;
      consider j such that
A11:  j in Seg m and
A12:  v=Line(M,j) by A9,Th103;
      len M=m by MATRIX_0:def 2;
      then p.j in rng p by A6,A11,FUNCT_1:def 3;
      then reconsider pj=p.j as Element of the carrier of K by A10;
      take pj;
      thus pj in the carrier of K;
      let w such that
A13:  w=x;
      thus not w in lines M implies pj=0.K by A9,A13;
      thus w in lines M implies for k st k in Seg m & w=Line(M,k) holds pj = p
      .k
      proof
        len M=m by MATRIX_0:def 2;
        then
A14:    dom M=Seg m by FINSEQ_1:def 3;
A15:    M.j=Line(M,j) by A11,MATRIX_0:52;
        assume w in lines M;
        let k such that
A16:    k in Seg m and
A17:    w=Line(M,k);
        M.k=Line(M,k) by A16,MATRIX_0:52;
        hence thesis by A1,A11,A12,A13,A16,A17,A14,A15;
      end;
    end;
    suppose
A18:  not v in lines M;
      take 0K=0.K;
      thus 0K in the carrier of K;
      let w such that
A19:  w=x;
      thus not w in lines M implies 0K=0.K;
      thus thesis by A18,A19;
    end;
  end;
  consider l be Function of the carrier of V,the carrier of K such that
A20: for x being object st x in the carrier of V holds Q[x,l.x]
from FUNCT_2:sch 1(A8
  );
  reconsider L=l as Element of Funcs(the carrier of V, the carrier of K) by
FUNCT_2:8;
  for v st not v in lines M holds L.v = 0.K by A20;
  then reconsider L as Linear_Combination of V by VECTSP_6:def 1;
A21: Carrier L c= lines M
  proof
    let x be object;
    assume x in Carrier L;
    then ex v st x = v & L.v <> 0.K by VECTSP_6:1;
    hence thesis by A20;
  end;
  set MX=MX2FinS M;
A22: len M=m by MATRIX_0:def 2;
  reconsider L as Linear_Combination of lines M by A21,VECTSP_6:def 4;
  set LM=L(#)MX;
A23: len LM=len M by VECTSP_6:def 5;
A24: now
    let k such that
A25: 1<=k and
A26: k<=m;
A27: k in Seg m by A25,A26;
    then consider a such that
A28: p.k=a and
A29: Line(M1,k) = a * Line(M,k) by A7,A22;
    dom MX = Seg m by A22,FINSEQ_1:def 3;
    then
A30: MX/.k=M.k by A27,PARTFUN1:def 6;
A31: Line(M,k) in lines M by A27,Th103;
    then reconsider
    LMk=Line(M,k) as Element of n-tuples_on the carrier of K by Th102;
A32: LMk=M.k by A27,MATRIX_0:52;
    dom LM=Seg m by A22,A23,FINSEQ_1:def 3;
    then
A33: LM.k=L.(MX/.k) * MX/.k by A27,VECTSP_6:def 5;
    L.LMk =p.k by A20,A27,A31;
    then LM.k=a * LMk by A28,A33,A30,A32,Th102;
    hence M1.k=LM.k by A27,A29,MATRIX_0:52;
  end;
  len M1=m by MATRIX_0:def 2;
  hence thesis by A22,A23,A24,FINSEQ_1:14;
end;

theorem Th109:
  for M st M is without_repeated_line holds ( for i st i in Seg m
holds Line(M,i) <> n |-> 0.K ) & ( for M1 st (for i st i in Seg m ex a st Line(
M1,i) = a * Line(M,i))& for j st j in Seg n holds Sum Col(M1,j) = 0.K holds M1
  = 0.(K,m,n) ) iff lines M is linearly-independent
proof
  set V=n-VectSp_over K;
  set n0=n|->0.K;
A1: len n0=n by CARD_1:def 7;
  let M such that
A2: M is without_repeated_line;
  thus (for i st i in Seg m holds Line(M,i) <> n |-> 0.K ) & (for M1 st (for i
st i in Seg m ex a st Line(M1,i) = a * Line(M,i)) & (for j st j in Seg n holds
  Sum Col(M1,j)=0.K) holds M1 = 0.(K,m,n) ) implies lines M is
  linearly-independent
  proof
    set MX=MX2FinS M;
    set V=n-VectSp_over K;
    assume that
A3: for i st i in Seg m holds Line(M,i) <> n |-> 0.K and
A4: for M1 st (for i st i in Seg m ex a st Line(M1,i)=a*Line(M,i))&
    for j st j in Seg n holds Sum Col(M1,j)=0.K holds M1 = 0.(K,m,n);
    let L be Linear_Combination of lines M such that
A5: Sum L = 0.V;
    set LM=L (#) MX;
    set FLM = FinS2MX LM;
A6: len LM= len MX by VECTSP_6:def 5;
A7: len M=m by MATRIX_0:def 2;
    then reconsider flm=FLM as Matrix of m,n,K by A6;
A8: for i st i in Seg m ex a st Line(flm,i)=a*Line(M,i)
    proof
      let i such that
A9:   i in Seg m;
      Line(M,i) in lines M by A9,Th103;
      then reconsider LM=Line(M,i) as Element of V;
      reconsider LLM=L.LM as Element of K;
      Line(M,i)=M.i by A9,MATRIX_0:52;
      then Line(flm,i)=LLM*Line(M,i) by A7,A9,Th106;
      hence thesis;
    end;
A10: len (n|->0.K)=n by CARD_1:def 7;
    assume Carrier L<>{};
    then consider x being object such that
A11: x in Carrier L by XBOOLE_0:def 1;
    Carrier L c= lines M by VECTSP_6:def 4;
    then consider i such that
A12: i in Seg m and
A13: x=Line(M,i) by A11,Th103;
    consider v such that
A14: x=v and
A15: L.v<>0.K by A11,VECTSP_6:1;
    reconsider LM=Line(M,i) as Element of n-tuples_on the carrier of K by A13
,A14,Th102;
    Line(M,i)=M.i by A12,MATRIX_0:52;
    then
A16: Line(flm,i) = (L.v) * LM by A7,A12,A13,A14,Th106;
    now
      let j such that
A17:  j in Seg n;
A18:  (n|->0.K).j=0.K by A17,FINSEQ_2:57;
      Carrier L c= lines M by VECTSP_6:def 4;
      then (Sum L).j = Sum Col(flm,j) by A2,A17,Th107;
      hence Sum Col(flm,j) = 0.K by A5,A18,Th102;
    end;
    then flm=0.(K,m,n) by A4,A8;
    then
A19: flm.i=n|->0.K by A12,FUNCOP_1:7;
A20: dom LM=Seg n by FINSEQ_2:124;
    len LM=n by CARD_1:def 7;
    then consider j such that
A21: 1<=j and
A22: j<= n and
A23: LM.j <> (n|->0.K).j by A3,A12,A10,FINSEQ_1:14;
A24: j in Seg n by A21,A22;
    then
A25: LM.j<>0.K by A23,FINSEQ_2:57;
    j in Seg n by A21,A22;
    then
A26: LM.j in rng LM by A20,FUNCT_1:def 3;
    rng LM c= the carrier of K by RELAT_1:def 19;
    then reconsider LMj=LM.j as Element of K by A26;
A27: ((L.v) * LM).j=(L.v)*LMj by A24,FVSUM_1:51;
    flm.i = Line(flm,i) by A12,MATRIX_0:52;
    then Line(flm,i).j=0.K by A19,A24,FINSEQ_2:57;
    hence thesis by A15,A25,A27,A16,VECTSP_1:12;
  end;
  assume
A28: lines M is linearly-independent;
  hereby
    let i;
    assume i in Seg m;
    then Line(M,i) in lines M by Th103;
    then Line(M,i)<>0.V by A28,VECTSP_7:2;
    hence Line(M,i) <> n |-> 0.K by Th102;
  end;
  let M1 such that
A29: for i st i in Seg m ex a st Line(M1,i) = a * Line(M,i) and
A30: for j st j in Seg n holds Sum Col(M1,j)=0.K;
  consider L be Linear_Combination of lines M such that
A31: L (#) MX2FinS M = M1 by A2,A29,Th108;
A32: Carrier L c= lines M by VECTSP_6:def 4;
A33: now
    let j such that
A34: 1<=j and
A35: j<=n;
A36: j in Seg n by A34,A35;
    hence (Sum L).j = Sum Col(FinS2MX(L (#) MX2FinS M),j) by A2,A32,Th107
      .= 0.K by A30,A31,A36
      .= n0.j by A36,FINSEQ_2:57;
  end;
  reconsider SumL=Sum L as Element of n-tuples_on the carrier of K by Th102;
  len SumL=n by CARD_1:def 7;
  then SumL = n0 by A1,A33
    .= 0.V by Th102;
  then
A37: Carrier L={} by A28;
  assume M1 <> 0.(K,m,n);
  then consider I,J be Nat such that
A38: [I,J] in Indices M1 and
A39: M1*(I,J)<>(0.(K,m,n))*(I,J) by MATRIX_0:27;
  [I,J] in Indices 0.(K,m,n) by A38,MATRIX_0:26;
  then
A40: M1*(I,J)<>0.K by A39,MATRIX_3:1;
  reconsider ii=I,jj=J as Element of NAT by ORDINAL1:def 12;
A41: Indices M1=Indices M by MATRIX_0:26;
  then Indices M1 = [:Seg len M, Seg width M :] by FINSEQ_1:def 3;
  then
A42: ii in Seg len M by A38,ZFMISC_1:87;
A43: len M=m by MATRIX_0:def 2;
  then Line(M,ii) in lines M by A42,Th103;
  then reconsider Mii=M.ii as Element of V by A42,A43,MATRIX_0:52;
A44: jj in Seg width M by A38,A41,ZFMISC_1:87;
  then
A45: Line(M,ii).jj=M*(ii,jj) by MATRIX_0:def 7;
  jj in Seg width M1 by A38,ZFMISC_1:87;
  then M1*(I,J) = Line(FinS2MX(L (#) MX2FinS M),ii).jj by A31,MATRIX_0:def 7
    .= ((L.Mii)* Line(M,ii)).jj by A42,Th106
    .= (L.Mii) *(M*(ii,jj)) by A44,A45,FVSUM_1:51;
  then L.Mii<>0.K by A40;
  hence thesis by A37,VECTSP_6:1;
end;

theorem Th110:
  the_rank_of M = m implies lines M is linearly-independent
proof
  assume
A1: the_rank_of M = m;
  reconsider N=n as Element of NAT by ORDINAL1:def 12;
  set V=n-VectSp_over K;
  per cases;
  suppose
    m=0;
    then len M=0 by MATRIX_0:def 2;
    then M = {};
    hence thesis;
  end;
  suppose
A2: m<>0;
    then
A3: width M=n by Th1;
A4: M is without_repeated_line by A1,Th105;
A5: now
      set n0=n|->0.K;
      set NULL=0.(K,m,n);
      let M1 such that
A6:   for i st i in Seg m ex a st Line(M1,i) = a * Line(M,i) and
A7:   for j st j in Seg n holds Sum Col(M1,j) = 0.K;
      assume M1 <> 0.(K,m,n);
      then consider i,j such that
A8:   [i,j] in Indices M1 and
A9:   M1*(i,j)<>NULL*(i,j) by MATRIX_0:27;
      reconsider i,j as Element of NAT by ORDINAL1:def 12;
A10:  len M=m by MATRIX_0:def 2;
      Indices M1=Indices NULL by MATRIX_0:26;
      then
A11:  M1*(i,j)<>0.K by A8,A9,MATRIX_3:1;
A12:  Indices M=[:Seg m,Seg n:] by A3,MATRIX_0:25;
      Indices M1=Indices M by MATRIX_0:26;
      then
A13:  i in Seg m by A12,A8,ZFMISC_1:87;
      then consider a such that
A14:  Line(M1,i) = a * Line(M,i) by A6;
A15:  width M1=n by A2,Th1;
      then
A16:  j in Seg n by A8,ZFMISC_1:87;
      then
A17:  Line(M,i).j=M*(i,j) by A3,MATRIX_0:def 7;
      set R=RLine(M,i,a*Line(M,i));
      consider L be Linear_Combination of lines M such that
A18:  L (#) MX2FinS M = M1 by A1,A6,Th105,Th108;
      set LM=L (#) MX2FinS M;
      len M1=len M by A18,VECTSP_6:def 5;
      then consider f be sequence of  the carrier of V such that
A19:  Sum LM= f.m and
A20:  f.0 = 0.V and
A21:  for j be Nat,v st j < m & v = LM.(j+1) holds f.(j+1)
      = f.j+v by A18,A10,RLVECT_1:def 12;
      set RR=RLine(R,i,n0);
A22:  len RR=m by MATRIX_0:def 2;
      defpred P[Nat] means $1 < i implies for t st t=f.$1 holds the_rank_of R=
      the_rank_of RLine(R,i,Line(R,i)+t);
      width M = len Line(M,i) by MATRIX_0:def 7
        .= len (a*Line(M,i)) by MATRIXR1:16;
      then
A23:  width R=width M by MATRIX11:def 3;
A24:  for k st P[k] holds P[k+1]
      proof
        let k such that
A25:    P[k];
        reconsider kk=k as Element of NAT by ORDINAL1:def 12;
        set k1=k+1;
A26:    1<=k1 by NAT_1:14;
A27:    i<=m by A13,FINSEQ_1:1;
        reconsider LR=Line(R,i),LM1=Line(M1,k1) as Element of N-tuples_on the
        carrier of K by A2,Th1;
        assume
A28:    k1 < i;
        let t such that
A29:    t = f.k1;
        reconsider t1=f.kk,T=t as Element of N-tuples_on the carrier of K by
Th102;
        set RR=RLine(R,i,Line(R,i)+t1);
        reconsider LRt=LR+t,LRt1=LR+t1 as Element of (the carrier of K)* by
FINSEQ_1:def 11;
A30:    len (LR+T)=n by CARD_1:def 7;
A31:    len (LR+t1)=width R by A3,A23,CARD_1:def 7;
        then width RR=width R by MATRIX11:def 3;
        then
A32:    RLine(RR,i,LR+t) = Replace(RR,i,LRt) by A3,A23,A30,MATRIX11:29
          .= Replace(Replace(R,i,LRt1),i,LRt) by A31,MATRIX11:29
          .= Replace(R,i,LRt) by FUNCT_7:34
          .= RLine(R,i,LR+t)by A3,A23,A30,MATRIX11:29;
        i<=m by A13,FINSEQ_1:1;
        then k1 <m by A28,XXREAL_0:2;
        then
A33:    k1 in Seg m by A26;
        then
A34:    Line(M1,k1)=M1.k1 by MATRIX_0:52;
        Line(M1,k1) in lines M1 by A33,Th103;
        then reconsider LMk1=LM.k1 as Element of V by A18,A33,MATRIX_0:52;
        consider a such that
A35:    Line(M1,k1) = a * Line(M,k1) by A6,A33;
A36:    Line(M,k1) = Line(R,k1) by A28,A33,MATRIX11:28
          .= Line(RR,k1) by A28,A33,MATRIX11:28;
        k < i by A28,NAT_1:13;
        then k<m by A27,XXREAL_0:2;
        then t = f.kk+LMk1 by A21,A29
          .= t1+Line(M1,k1) by A15,A18,A34,Th102;
        then
A37:    LR+t = LR+t1 + LM1 by FINSEQOP:28
          .= Line(RR,i) + a * Line(RR,k1) by A13,A35,A31,A36,MATRIX11:28;
A38:    len RR=m by MATRIX_0:def 2;
        the_rank_of R=the_rank_of RR by A25,A28,NAT_1:13;
        hence thesis by A28,A33,A38,A32,A37,Th92;
      end;
      defpred Q[Nat] means i<=$1 & $1<=m implies for t st t=f.$1 holds
      the_rank_of R=the_rank_of RLine(R,i,t);
A39:  P[0]
      proof
        assume 0<i;
        let t;
        assume t=f.0;
        then t = n|-> 0.K by A20,Th102;
        then Line(R,i)+t=Line(R,i) by A3,A23,FVSUM_1:21;
        hence thesis by MATRIX11:30;
      end;
A40:  for k holds P[k] from NAT_1:sch 2(A39,A24);
A41:  for k st Q[k] holds Q[k+1]
      proof
        let k such that
A42:    Q[k];
        reconsider kk=k as Element of NAT by ORDINAL1:def 12;
        reconsider t1=f.kk as Element of N-tuples_on the carrier of K by Th102;
        set k1=k+1;
        reconsider LR=Line(R,i),LM1=Line(M1,k1) as Element of n-tuples_on the
        carrier of K by A2,Th1;
        assume that
A43:    i<=k1 and
A44:    k1<=m;
A45:    k<m by A44,NAT_1:13;
        1<=k1 by NAT_1:14;
        then
A46:    k1 in Seg m by A44;
        then
A47:    Line(M1,k1)=M1.k1 by MATRIX_0:52;
        Line(M1,k1) in lines M1 by A46,Th103;
        then reconsider LMk1=LM.k1 as Element of V by A18,A46,MATRIX_0:52;
        let t;
        assume t=f.k1;
        then
A48:    t = f.kk+LMk1 by A21,A45
          .= t1+LM1 by A18,A47,Th102;
        consider b such that
A49:    Line(M1,k1) = b * Line(M,k1) by A6,A46;
        reconsider T=t,T1=t1 as Element of (the carrier of K)* by
FINSEQ_1:def 11;
        per cases by A43,XXREAL_0:1;
        suppose
A50:      i=k1;
          len LM1=n by CARD_1:def 7;
          then LR=LM1 by A3,A14,A46,A50,MATRIX11:28;
          then
A51:      LR+t1=t by A48,FINSEQOP:33;
          k<i by A50,NAT_1:13;
          hence thesis by A40,A51;
        end;
        suppose
A52:      i<k1;
          set RR=RLine(R,i,t1);
A53:      len t1=width R by A3,A23,CARD_1:def 7;
          then Line(RR,i)=t1 by A13,MATRIX11:28;
          then
A54:      t = Line(RR,i)+b* Line(R,k1) by A46,A49,A48,A52,MATRIX11:28
            .= Line(RR,i)+ b * Line(RR,k1) by A46,A52,MATRIX11:28;
A55:      len t=n by CARD_1:def 7;
          width RR=width R by A53,MATRIX11:def 3;
          then
A56:      RLine(RR,i,t) = Replace(RR,i,T)by A3,A23,A55,MATRIX11:29
            .= Replace(Replace(R,i,T1),i,T) by A53,MATRIX11:29
            .= Replace(R,i,T) by FUNCT_7:34
            .= RLine(R,i,t) by A3,A23,A55,MATRIX11:29;
A57:      len RR=m by MATRIX_0:def 2;
          the_rank_of R=the_rank_of RLine(R,i,t1) by A42,A44,A52,NAT_1:13;
          hence thesis by A46,A52,A54,A56,A57,Th92;
        end;
      end;
A58:  Q[0] by A13;
A59:  for k holds Q[k] from NAT_1:sch 2(A58,A41);
      reconsider SumLM=Sum LM as Element of n-tuples_on the carrier of K by
Th102;
A60:  now
        let j such that
A61:    1<=j and
A62:    j<=n;
A63:    j in Seg n by A61,A62;
A64:    Carrier L c= lines M by VECTSP_6:def 4;
        M1 = FinS2MX(L (#) MX2FinS M) by A18;
        then Sum Col(M1,j) = (Sum L).j by A1,A63,A64,Th105,Th107
          .= SumLM.j by A4,A64,VECTSP_9:3;
        hence SumLM.j = 0.K by A7,A63
          .= n0.j by A63,FINSEQ_2:57;
      end;
      dom RR=Seg len RR by FINSEQ_1:def 3;
      then consider k such that
A65:  m = k + 1 and
A66:  len Del(RR,i) = k by A13,A22,FINSEQ_3:104;
A67:  len SumLM=n by CARD_1:def 7;
      M1*(i,j) = Line(M1,i).j by A15,A16,MATRIX_0:def 7
        .= a * (M*(i,j)) by A3,A16,A14,A17,FVSUM_1:51;
      then a<>0.K by A11;
      then
A68:  m=the_rank_of R by A1,Th89;
A69:  len n0=n by CARD_1:def 7;
      then
A70:  width RR=width R by A3,A23,MATRIX11:def 3;
A71:  Line(RR,i)=n0 by A3,A13,A23,A69,MATRIX11:28;
      i<=m by A13,FINSEQ_1:1;
      then m=the_rank_of RLine(R,i,n0) by A68,A19,A59,A67,A69,A60,FINSEQ_1:14;
      then m=the_rank_of DelLine(RR,i) by A3,A23,A71,A70,Th90;
      then m<=k by A66,Th74;
      hence contradiction by A65,NAT_1:13;
    end;
    now
A72:  len M = m by MATRIX_0:def 2;
A73:  dom M=Seg len M by FINSEQ_1:def 3;
      let i;
      assume i in Seg m;
      then consider k such that
A74:  m = k + 1 and
A75:  len Del(M,i) = k by A73,A72,FINSEQ_3:104;
      assume Line(M,i) = n |-> 0.K;
      then the_rank_of DelLine(M,i) = m by A1,A3,Th90;
      then m<= k by A75,Th74;
      hence contradiction by A74,NAT_1:13;
    end;
    hence thesis by A4,A5,Th109;
  end;
end;

theorem Th111:
  for M be diagonal Matrix of n,K st the_rank_of M = n holds lines M is
  Basis of n-VectSp_over K
proof
  let M be diagonal Matrix of n,K such that
A1: the_rank_of M = n;
  set lM=lines M;
  set V=n-VectSp_over K;
  reconsider V9=V as Subspace of V by VECTSP_4:24;
  now
    let v;
    thus v in Lin lM implies v in V9;
    thus v in V9 implies v in Lin lM
    proof
      reconsider t=v as Element of n-tuples_on the carrier of K by Th102;
      assume v in V9;
      deffunc F(Nat)=(t/.$1)*(M*($1,$1)")*Line(M,$1);
      consider f be FinSequence of (width M)-tuples_on the carrier of K such
      that
A2:   len f = n and
A3:   for j st j in dom f holds f.j = F(j) from FINSEQ_2:sch 1;
A4:   dom f = Seg n by A2,FINSEQ_1:def 3;
      width M=n by MATRIX_0:24;
      then reconsider f as FinSequence of the carrier of V by Th102;
      reconsider M1=FinS2MX f as Matrix of n,K by A2;
      now
        let i such that
A5:     i in Seg n;
        Line(M1,i) = M1.i by A5,MATRIX_0:52
          .= F(i) by A3,A4,A5;
        hence ex a st Line(M1,i) = a * Line(M,i);
      end;
      then consider L be Linear_Combination of lM such that
A6:   L (#) MX2FinS M = M1 by A1,Th105,Th108;
      set MX=MX2FinS M;
A7:   len t=n by CARD_1:def 7;
      reconsider SumL=Sum L as Element of n-tuples_on the carrier of K by Th102
;
A8:   Carrier L c= lM by VECTSP_6:def 4;
A9:   now
        set diag=diagonal_of_Matrix M;
        let i such that
A10:    1<=i and
A11:    i<=n;
A12:    i in Seg n by A10,A11;
        then
A13:    diag.i=M*(i,i) by MATRIX_3:def 10;
    len diag=n by MATRIX_3:def 10;
        then
A14:    dom diag=Seg n by FINSEQ_1:def 3;
A15:    width M=n by MATRIX_0:24;
        then
A16:    Line(M,i).i = M*(i,i) by A12,MATRIX_0:def 7;
        set C=Col(M1,i);
A17:    dom t=Seg n by FINSEQ_2:124;
        len C=len M1 by MATRIX_0:def 8;
        then
A18:    dom C=Seg len M1 by FINSEQ_1:def 3;
        len M=n by MATRIX_0:24;
        then
A19:    dom M=Seg n by FINSEQ_1:def 3;
A20:    Det M<>0.K by A1,Th83;
A21:    len M1=n by MATRIX_0:24;
        then
A22:    dom M1=Seg n by FINSEQ_1:def 3;
        Det M=Product diag by A10,A11,MATRIX_7:17,NAT_1:14;
        then
A23:    diag.i<>0.K by A12,A20,A14,FVSUM_1:82;
A24:    Line(M1,i) = M1.i by A12,MATRIX_0:52
          .= (t/.i)*((M*(i,i))")*Line(M,i) by A3,A12,A22;
A25:    width M1=n by MATRIX_0:24;
        now
          let k such that
A26:      k in dom C and
A27:      k<>i;
A28:      [k,i] in Indices M by A21,A15,A12,A18,A19,A26,ZFMISC_1:87;
A29:      Line(M,k).i = M*(k,i) by A15,A12,MATRIX_0:def 7
            .= 0.K by A27,A28,MATRIX_1:def 10;
A30:      (MX/.k) = (M.k) by A21,A18,A19,A26,PARTFUN1:def 6
            .= Line(M,k) by A21,A18,A26,MATRIX_0:52;
          Line(M1,k) = M1.k by A18,A26,MATRIX_0:52
            .= L.(MX/.k)* MX/.k by A6,A21,A18,A22,A26,VECTSP_6:def 5
            .= L.(MX/.k)* Line(M,k) by A15,A30,Th102;
          then Line(M1,k).i = L.(MX/.k) * 0.K by A15,A12,A29,FVSUM_1:51
            .= 0.K;
          hence 0.K = M1*(k,i) by A25,A12,MATRIX_0:def 7
            .= C.k by A21,A18,A22,A26,MATRIX_0:def 8;
        end;
        then C.i = Sum C by A21,A12,A18,MATRIX_3:12
          .= SumL.i by A1,A6,A8,A12,Th105,Th107;
        hence SumL.i = M1*(i,i) by A12,A22,MATRIX_0:def 8
          .= Line(M1,i).i by A25,A12,MATRIX_0:def 7
          .= (t/.i)*((M*(i,i))")*(M*(i,i)) by A15,A12,A24,A16,FVSUM_1:51
          .= (t/.i)*((M*(i,i)")*(M*(i,i))) by GROUP_1:def 3
          .= (t/.i)*1_K by A23,A13,VECTSP_1:def 10
          .= t/.i
          .= t.i by A12,A17,PARTFUN1:def 6;
      end;
      len SumL=n by CARD_1:def 7;
      then SumL=t by A7,A9;
      hence thesis by VECTSP_7:7;
    end;
  end;
  then
A31: Lin lM = the ModuleStr of V by VECTSP_4:30;
  lines M is linearly-independent by A1,Th110;
  hence thesis by A31,VECTSP_7:def 3;
end;

Lm8: lines 1.(K,n) is Basis of n-VectSp_over K & the_rank_of 1.(K,n)=n
proof
  set ONE=1.(K,n);
  n=0 or n>=1 by NAT_1:14;
  then
A1: Det ONE=1_K by MATRIXR2:41,MATRIX_7:16;
  for i,j st [i,j] in Indices ONE & ONE*(i,j) <> 0.K holds i=j by
MATRIX_1:def 3;
  then
A2: ONE is diagonal by MATRIX_1:def 10;
  1_K<>0.K;
  then the_rank_of ONE=n by A1,Th83;
  hence thesis by A2,Th111;
end;

registration
  let K,n;
  cluster n -VectSp_over K -> finite-dimensional;
  coherence
  proof
    lines 1.(K,n) is Basis of n-VectSp_over K by Lm8;
    hence thesis by MATRLIN:def 1;
  end;
end;

theorem
  dim (n-VectSp_over K) = n
proof
  set ONE=1.(K,n);
  len ONE=n by MATRIX_0:24;
  then
A1: dom ONE=Seg n by FINSEQ_1:def 3;
  then
A2: ONE.:Seg n=lines ONE by RELAT_1:113;
  the_rank_of ONE=n by Lm8;
  then ONE is without_repeated_line by Th105;
  then Seg n,ONE.:Seg n are_equipotent by A1,CARD_1:33;
  then card Seg n=card lines ONE by A2,CARD_1:5;
  then
A3: card lines ONE=n by FINSEQ_1:57;
  lines ONE is Basis of n-VectSp_over K by Lm8;
  hence thesis by A3,VECTSP_9:def 1;
end;

theorem Th113:
  for M,i,a st for j st j in Seg m holds M*(j,i) = a holds M is
  without_repeated_line iff Segm(M,Seg len M,Seg width M\{i}) is
  without_repeated_line
proof
  let M, i, a such that
A1: for j st j in Seg m holds M*(j,i) = a;
  set Sl=Sgm Seg len M;
  set SMi=Seg width M\{i};
  set S=Segm(M,Seg len M,SMi);
  set Si=Sgm SMi;
A2: len M=m by MATRIX_0:def 2;
A3: card Seg len M=len M by FINSEQ_1:57;
  len S=card Seg len M by MATRIX_0:def 2;
  then
A4: dom S=Seg m by A2,A3,FINSEQ_1:def 3;
A5: dom M=Seg m by A2,FINSEQ_1:def 3;
  thus M is without_repeated_line implies S is without_repeated_line
  proof
    assume
A7: M is without_repeated_line;
    let x1,x2 be object such that
A8: x1 in dom S and
A9: x2 in dom S and
A10: S.x1=S.x2;
    reconsider i1=x1,i2=x2 as Element of NAT by A8,A9;
A11: Sl=idseq m by A2,FINSEQ_3:48;
    then
A12: Line(M,i1) * Si = Line(M,Sl.i1) *Si by A4,A8,FINSEQ_2:49
      .= Line(S,i1) by A2,A3,A4,A8,Th47,XBOOLE_1:36
      .= S.i1 by A2,A3,A4,A8,MATRIX_0:52
      .= Line(S,i2) by A2,A3,A4,A9,A10,MATRIX_0:52
      .= Line(M,Sl.i2) * Si by A2,A3,A4,A9,Th47,XBOOLE_1:36
      .= Line(M,i2) * Si by A4,A9,A11,FINSEQ_2:49;
A13: now
      let k such that
A14:  1<=k and
A15:  k<=width M;
A16:  k in Seg width M by A14,A15;
      per cases;
      suppose
A17:    k = i;
        then
A18:    M*(i2,k)=a by A1,A4,A9;
A19:    M*(i1,k) =Line(M,i1).k by A16,MATRIX_0:def 7;
        M*(i1,k)=a by A1,A4,A8,A17;
        hence Line(M,i1).k=Line(M,i2).k by A16,A18,A19,MATRIX_0:def 7;
      end;
      suppose
A20:    k <> i;
A21:    rng Si=SMi by FINSEQ_1:def 14;
        k in SMi by A16,A20,ZFMISC_1:56;
        then consider x being object such that
A22:    x in dom Si and
A23:    Si.x=k by A21,FUNCT_1:def 3;
        thus Line(M,i1).k = (Line(M,i1)*Si).x by A22,A23,FUNCT_1:13
          .= Line(M,i2).k by A12,A22,A23,FUNCT_1:13;
      end;
    end;
A24: len Line(M,i2)=width M by CARD_1:def 7;
    len Line(M,i1)=width M by CARD_1:def 7;
    then Line(M,i1) = Line(M,i2) by A24,A13
      .= M.i2 by A4,A9,MATRIX_0:52;
    then M.i1 = M.i2 by A4,A8,MATRIX_0:52;
    hence thesis by A5,A4,A7,A8,A9;
  end;
  thus S is without_repeated_line implies M is without_repeated_line
  proof
A25: Sl=idseq m by A2,FINSEQ_3:48;
    assume
A26: S is without_repeated_line;
    let x1,x2 be object such that
A27: x1 in dom M and
A28: x2 in dom M and
A29: M.x1=M.x2;
    reconsider i1=x1,i2=x2 as Element of NAT by A27,A28;
A30: Line(M,i1)=M.i1 by A5,A27,MATRIX_0:52;
A31: Line(M,i2)=M.i2 by A5,A28,MATRIX_0:52;
    S.x1 = Line(S,i1) by A2,A3,A5,A27,MATRIX_0:52
      .= Line(M,Sl.i1) * Si by A2,A3,A5,A27,Th47,XBOOLE_1:36
      .= Line(M,i2) * Si by A5,A27,A29,A25,A30,A31,FINSEQ_2:49
      .= Line(M,Sl.i2) * Si by A5,A28,A25,FINSEQ_2:49
      .= Line(S,i2) by A2,A3,A5,A28,Th47,XBOOLE_1:36
      .= S.x2 by A2,A3,A5,A28,MATRIX_0:52;
    hence thesis by A5,A4,A26,A27,A28;
  end;
end;

theorem Th114:
  for M,i st M is without_repeated_line & lines M is
linearly-independent & for j st j in Seg m holds M*(j,i) = 0.K holds lines Segm
  (M,Seg len M,Seg width M\{i}) is linearly-independent
proof
  let M,i;
  assume that
A1: M is without_repeated_line and
A2: lines M is linearly-independent and
A3: for j st j in Seg m holds M*(j,i) = 0.K;
  set SMi=Seg width M\{i};
  set Sl=Seg len M;
  set S=Segm(M,Sl,SMi);
A5: card Sl=len M by FINSEQ_1:57;
A6: len M=m by MATRIX_0:def 2;
  per cases;
  suppose
    m=0;
    then len S=0 by A6,MATRIX_0:def 2;
    then S = {};
    hence thesis;
  end;
  suppose
    m<>0;
    then
A7: width M=n by Th1;
A8: now
      set n0=n|->0.K;
A9:   len n0=n by CARD_1:def 7;
A10:  dom Sgm SMi=Seg card SMi by FINSEQ_3:40;
      let k such that
A11:  k in Seg card Sl;
      Line(M,k) in lines M by A5,A6,A11,Th103;
      then reconsider
      LM=Line(M,k) as Element of n-tuples_on the carrier of K by Th102;
A12:  len LM=n by CARD_1:def 7;
      LM <> n0 by A1,A2,A5,A6,A11,Th109;
      then consider n9 be Nat such that
A13:  1<=n9 and
A14:  n9<=n and
A15:  LM.n9 <> n0.n9 by A12,A9;
A16:  n9 in Seg n by A13,A14;
      then
A17:  n0.n9=0.K by FINSEQ_2:57;
      Sgm Sl =idseq m by A6,FINSEQ_3:48;
      then
A18:  Sgm Sl.k = k by A5,A6,A11,FINSEQ_2:49;
A19:  rng Sgm SMi=SMi by FINSEQ_1:def 14;
      LM.n9=M*(k,n9) by A7,A16,MATRIX_0:def 7;
      then n9<>i by A3,A5,A6,A11,A15,A17;
      then n9 in SMi by A7,A16,ZFMISC_1:56;
      then consider x being object such that
A20:  x in dom Sgm SMi and
A21:  Sgm SMi.x = n9 by A19,FUNCT_1:def 3;
      assume
A22:  Line(S,k) = card SMi |-> 0.K;
      reconsider x as Element of NAT by A20;
      Line(S,k) = Line(M,Sgm Sl.k) * Sgm SMi by A11,Th47,XBOOLE_1:36;
      then Line(S,k).x=Line(M,Sgm Sl.k).n9 by A20,A21,FUNCT_1:13;
      hence contradiction by A22,A15,A17,A20,A10,A18,FINSEQ_2:57;
    end;
A23: now
      set NULL=0.(K,card Sl,card SMi);
      let M1 be Matrix of card Sl,card SMi,K such that
A24:  for i st i in Seg card Sl ex a st Line(M1,i) = a * Line(S,i) and
A25:  for j st j in Seg card SMi holds Sum Col(M1,j) = 0.K;
      defpred P[set,set] means for i st $1=i ex a st a=$2 & Line(M1,i) = a *
      Line(S,i);
A26:  for k st k in Seg m ex x be Element of K st P[k,x]
      proof
        let k;
        assume k in Seg m;
        then consider a such that
A27:    Line(M1,k) = a * Line(S,k) by A5,A6,A24;
        take a;
        thus thesis by A27;
      end;
      consider p such that
A28:  dom p = Seg m and
A29:  for k st k in Seg m holds P[k,p.k] from FINSEQ_1:sch 5(A26);
      deffunc F(Nat)=p/.$1 * Line(M,$1);
      consider f be FinSequence of (width M)-tuples_on the carrier of K such
      that
A30:  len f = m and
A31:  for j st j in dom f holds f.j = F(j) from FINSEQ_2:sch 1;
      reconsider f9=f as FinSequence of the carrier of n-VectSp_over K by A7
,Th102;
      FinS2MX f9 is Matrix of m,n,K by A30;
      then reconsider Mf=f as Matrix of m,n,K;
A32:  dom f = Seg m by A30,FINSEQ_1:def 3;
      len Mf = m by MATRIX_0:def 2;
      then
A33:  dom Mf = Seg m by FINSEQ_1:def 3;
A34:  now
A35:    len M1=m by A5,A6,MATRIX_0:def 2;
A36:    len Mf=m by MATRIX_0:def 2;
A37:    dom Mf=Seg len Mf by FINSEQ_1:def 3;
A38:    dom M1=Seg len M1 by FINSEQ_1:def 3;
        let j such that
A39:    j in Seg n;
        set C=Col(Mf,j);
A40:    len C = len Mf by MATRIX_0:def 8
          .= m by MATRIX_0:def 2;
        per cases;
        suppose
A41:      j=i;
          set m0=m|->0.K;
A42:      now
            let n9 be Nat such that
A43:        1<=n9 and
A44:        n9<=m;
A45:        width M = n by A43,A44,Th1;
A46:        width Mf=n by A43,A44,Th1;
A47:        n9 in Seg m by A43,A44;
            then
A48:        Mf.n9 = Mf/.n9 by A33,PARTFUN1:def 6;
            0.K = M*(n9,i) by A3,A47
              .= Line(M,n9).i by A39,A41,A45,MATRIX_0:def 7;
            then p/.n9*0.K = (p/.n9 * Line(M,n9)).i by A39,A41,A45,FVSUM_1:51
              .= (Mf/.n9).i by A31,A32,A47,A48
              .= Line(Mf,n9).i by A47,A48,MATRIX_0:52
              .= Mf*(n9,i) by A39,A41,A46,MATRIX_0:def 7
              .= Col(Mf,i).n9 by A36,A37,A47,MATRIX_0:def 8;
            hence Col(Mf,j).n9 = 0.K by A41
              .= m0.n9 by A47,FINSEQ_2:57;
          end;
          len m0=m by CARD_1:def 7;
          then C=m0 by A40,A42;
          hence Sum C=0.K by MATRIX_3:11;
        end;
        suppose
A49:      j<>i;
A50:      rng Sgm SMi=SMi by FINSEQ_1:def 14;
          j in SMi by A7,A39,A49,ZFMISC_1:56;
          then consider x being object such that
A51:      x in dom Sgm SMi and
A52:      Sgm SMi.x=j by A50,FUNCT_1:def 3;
          reconsider x as Element of NAT by A51;
          set C1=Col(M1,x);
A53:      dom Sgm SMi =Seg card SMi by FINSEQ_3:40;
A54:      now
            let n9 be Nat such that
A55:        1<=n9 and
A56:        n9<=m;
A57:        width Mf=n by A55,A56,Th1;
A58:        width S=card SMi by A6,A55,A56,Th1;
A59:        Sgm Sl=idseq m by A6,FINSEQ_3:48;
A60:        width M1=card SMi by A6,A55,A56,Th1;
A61:        Line(M,n9).j=M*(n9,j ) by A7,A39,MATRIX_0:def 7;
A62:        n9 in Seg m by A55,A56;
            then consider a such that
A63:        a=p.n9 and
A64:        Line(M1,n9) = a * Line(S,n9) by A29;
A65:        Mf.n9 = Mf/.n9 by A33,A62,PARTFUN1:def 6;
            (idseq m).n9=n9 by A62,FINSEQ_2:49;
            then Line(M,n9) * Sgm SMi=Line(S,n9) by A5,A6,A62,A59,Th47,
XBOOLE_1:36;
            then
A66:        Line(S,n9).x = Line(M,n9).j by A51,A52,FUNCT_1:13;
            thus C.n9 = Mf*(n9,j) by A36,A37,A62,MATRIX_0:def 8
              .= Line(Mf,n9).j by A39,A57,MATRIX_0:def 7
              .= (Mf/.n9).j by A62,A65,MATRIX_0:52
              .= (p/.n9 * Line(M,n9)).j by A31,A32,A62,A65
              .= (a * Line(M,n9)).j by A28,A62,A63,PARTFUN1:def 6
              .= a* (M*(n9,j)) by A7,A39,A61,FVSUM_1:51
              .= (a*Line(S,n9)).x by A51,A53,A58,A66,A61,FVSUM_1:51
              .= M1*(n9,x) by A51,A53,A60,A64,MATRIX_0:def 7
              .= C1.n9 by A35,A38,A62,MATRIX_0:def 8;
          end;
A67:      len C=len Mf by MATRIX_0:def 8;
          len C1=len M1 by MATRIX_0:def 8;
          then C=C1 by A36,A35,A67,A54;
          hence Sum C=0.K by A25,A51,A53;
        end;
      end;
      now
        let j such that
A68:    j in Seg m;
        take pj=p/.j;
        thus Line(Mf,j) = Mf.j by A68,MATRIX_0:52
          .= pj * Line(M,j) by A31,A32,A68;
      end;
      then
A69:  Mf = 0.(K,m,n) by A1,A2,A34,Th109;
A70:  now
        let j such that
A71:    1<=j and
A72:    j<=m;
A73:    j in Seg m by A71,A72;
        then consider a such that
A74:    a=p.j and
A75:    Line(M1,j) = a * Line(S,j) by A29;
A76:    Line(0.(K,m,n),j) = 0.(K,m,n).j by A73,MATRIX_0:52
          .= n |-> 0.K by A73,FUNCOP_1:7;
        p.j=p/.j by A28,A73,PARTFUN1:def 6;
        then
A77:    a * Line(M,j) = Mf.j by A31,A32,A73,A74
          .= Line(Mf,j) by A73,MATRIX_0:52;
A78:    rng Sgm SMi =SMi by FINSEQ_1:def 14;
        Sgm Sl =idseq m by A6,FINSEQ_3:48;
        then Sgm Sl.j = j by A73,FINSEQ_2:49;
        then
A79:    Line(S,j) = Line(M,j) * Sgm SMi by A5,A6,A73,Th47,XBOOLE_1:36;
        Seg n /\ SMi = SMi by A7,XBOOLE_1:28,36;
        then
A80:    Sgm SMi " (Seg n) = Sgm SMi "(rng Sgm SMi) by A78,RELAT_1:133
          .= dom Sgm SMi by RELAT_1:134
          .= Seg card SMi by FINSEQ_3:40;
        dom Line(M,j) = Seg len Line(M,j) by FINSEQ_1:def 3
          .= Seg width M by CARD_1:def 7;
        then Line(M1,j) = Line(0.(K,m,n),j)*Sgm SMi by A69,A75,A77,A78,A79,Th87
,XBOOLE_1:36
          .= card SMi |-> 0.K by A80,A76,FUNCOP_1:19
          .= NULL.j by A5,A6,A73,FUNCOP_1:7;
        hence M1.j = NULL.j by A5,A6,A73,MATRIX_0:52;
      end;
A81:  len NULL=m by A5,A6,MATRIX_0:def 2;
      len M1=m by A5,A6,MATRIX_0:def 2;
      hence M1 = NULL by A81,A70;
    end;
    S is without_repeated_line by A1,A3,Th113;
    hence thesis by A8,A23,Th109;
  end;
end;

theorem Th115:
  for V be VectSp of K for U be finite Subset of V st U is
linearly-independent for u, v be Vector of V st u in U & v in U & u <> v holds
  U\{u} \/ {u+a*v} is linearly-independent
proof
  let V be VectSp of K;
  let U be finite Subset of V such that
A1: U is linearly-independent;
  let u, v be Vector of V such that
A2: u in U and
A3: v in U and
A4: u<>v;
  set ua=u+a*v;
  set Uu=U\{u};
  set Uua=Uu\/{ua};
  per cases;
  suppose
    u=ua;
    hence thesis by A1,A2,ZFMISC_1:116;
  end;
  suppose
A5: u<>ua;
    now
      let L be Linear_Combination of Uua such that
A6:   Sum(L)=0.V;
      per cases;
      suppose
A7:     L.ua=0.K;
        Carrier L c= Uu
        proof
          let x be object;
          assume
A8:       x in Carrier L;
          then consider v be Vector of V such that
A9:       x = v and
A10:      L.v <> 0.K by VECTSP_6:1;
          Carrier L c= Uua by VECTSP_6:def 4;
          then v in Uu or v in {ua} & not v in {ua} by A7,A8,A9,A10,
TARSKI:def 1,XBOOLE_0:def 3;
          hence thesis by A9;
        end;
        then reconsider L9=L as Linear_Combination of Uu by VECTSP_6:def 4;
A11:    Sum L9=0.V by A6;
        Uu is linearly-independent by A1,VECTSP_7:1,XBOOLE_1:36;
        hence Carrier L={} by A11;
      end;
      suppose
A12:    L.ua<>0.K;
A13:    Carrier L c= Uua by VECTSP_6:def 4;
        Uu c= U by XBOOLE_1:36;
        then Uua c=U\/{ua} by XBOOLE_1:13;
        then
A14:    Carrier L c= U\/{ua} by A13;
        ua in {ua} by TARSKI:def 1;
        then ua in Lin{ua} by VECTSP_7:8;
        then consider Lua be Linear_Combination of {ua} such that
A15:    ua=Sum Lua by VECTSP_7:7;
        reconsider LLua=L.ua * Lua as Linear_Combination of {ua} by VECTSP_6:31
;
A16:    Carrier LLua c= {ua} by VECTSP_6:def 4;
        then not u in Carrier LLua by A5,TARSKI:def 1;
        then
A17:    LLua.u=0.K by VECTSP_6:2;
        v in {v} by TARSKI:def 1;
        then v in Lin{v} by VECTSP_7:8;
        then consider Lv be Linear_Combination of {v} such that
A18:    v=Sum Lv by VECTSP_7:7;
        reconsider LLv=(L.ua*a) * Lv as Linear_Combination of {v} by
VECTSP_6:31;
A19:    Carrier LLv c= {v} by VECTSP_6:def 4;
        then not u in Carrier LLv by A4,TARSKI:def 1;
        then
A20:    LLv.u=0.K by VECTSP_6:2;
        v <> ua
        proof
          assume v=u+a*v;
          then v-a*v = u+(a*v-a*v) by RLVECT_1:def 3
            .= u+0.V by VECTSP_1:16
            .= u by RLVECT_1:def 4;
          then u = 1_K*v+-a*v
            .= 1_K*v+(-a)*v by VECTSP_1:21
            .= (1_K-a)*v by VECTSP_1:def 15;
          then
A21:      {v,u} is linearly-dependent by A4,VECTSP_7:5;
          {v,u} c= U by A2,A3,ZFMISC_1:32;
          hence thesis by A1,A21,VECTSP_7:1;
        end;
        then not ua in Carrier LLv by A19,TARSKI:def 1;
        then
A22:    LLv.ua=0.K by VECTSP_6:2;
A23:    u + a * v <> 0.V
        proof
          {v,u} c= U by A2,A3,ZFMISC_1:32;
          then
A24:      {v,u} is linearly-independent by A1,VECTSP_7:1;
A25:      1_K*u = u;
          assume 0.V=u + a * v;
          then 1_K=0.K by A4,A24,A25,VECTSP_7:6;
          hence thesis;
        end;
A26:    u<>0.V by A1,A2,VECTSP_7:2;
        Lua.ua * ua = ua by A15,VECTSP_6:17
          .= 1_K*ua;
        then
A27:    Lua.ua=1_K by A23,VECTSP10:4;
        u in {u} by TARSKI:def 1;
        then u in Lin{u} by VECTSP_7:8;
        then consider Lu be Linear_Combination of {u} such that
A28:    u=Sum Lu by VECTSP_7:7;
        reconsider LLu=L.ua * Lu as Linear_Combination of {u} by VECTSP_6:31;
A29:    Carrier LLu c= {u} by VECTSP_6:def 4;
        then not ua in Carrier LLu by A5,TARSKI:def 1;
        then
A30:    LLu.ua=0.K by VECTSP_6:2;
        {u} c= U by A2,ZFMISC_1:31;
        then
A31:    Carrier LLu c= U by A29;
        L+ LLv+LLu-LLua = L+(LLv+LLu)-LLua by VECTSP_6:26
          .= L+(LLv+LLu)+(-LLua) by VECTSP_6:def 11
          .= L+(LLv+LLu+(-LLua)) by VECTSP_6:26
          .= L+ (LLv+LLu-LLua) by VECTSP_6:def 11;
        then
A32:    Carrier (L+ LLv+LLu-LLua)c=Carrier L\/Carrier (LLv+LLu-LLua) by
VECTSP_6:23;
A33:    Carrier (LLv+LLu-LLua) c= Carrier (LLv+LLu) \/Carrier LLua by
VECTSP_6:41;
A34:    Carrier (LLv+ LLu) c= Carrier LLv \/ Carrier LLu by VECTSP_6:23;
        {v} c= U by A3,ZFMISC_1:31;
        then Carrier LLv c= U by A19;
        then Carrier LLv \/ Carrier LLu c= U by A31,XBOOLE_1:8;
        then Carrier (LLv+ LLu) c= U by A34;
        then Carrier(LLv+LLu)\/Carrier LLua c= U\/{ua} by A16,XBOOLE_1:13;
        then Carrier (LLv+LLu-LLua) c= U\/{ua} by A33;
        then Carrier L\/Carrier (LLv+LLu-LLua)c=U\/{ua} by A14,XBOOLE_1:8;
        then
A35:    Carrier (L+ LLv+LLu-LLua) c= U\/{ua} by A32;
A36:    (L+ LLv+LLu-LLua).ua=(L+ LLv+LLu+(-LLua)).ua by VECTSP_6:def 11
          .= (L+ LLv+LLu).ua + (-LLua).ua by VECTSP_6:22
          .= (L+ LLv).ua+ LLu.ua + (-LLua).ua by VECTSP_6:22
          .= L.ua+ 0.K+ 0.K + (-LLua).ua by A22,A30,VECTSP_6:22
          .= L.ua+ 0.K + (-LLua).ua by RLVECT_1:def 4
          .= L.ua+(-LLua).ua by RLVECT_1:def 4
          .= L.ua-LLua.ua by VECTSP_6:36
          .= L.ua - L.ua*1_K by A27,VECTSP_6:def 9
          .= L.ua - L.ua
          .= 0.K by VECTSP_1:19;
        Carrier (L+ LLv+LLu-LLua) c= U
        proof
          let x be object;
          assume
A37:      x in Carrier (L+ LLv+LLu-LLua);
          assume not x in U;
          then
A38:      x in {ua} by A35,A37,XBOOLE_0:def 3;
          ex v be Element of V st x=v & (L+ LLv+LLu-LLua).v<>0.K by A37,
VECTSP_6:1;
          hence contradiction by A36,A38,TARSKI:def 1;
        end;
        then reconsider LLL=L+LLv+LLu-LLua as Linear_Combination of U by
VECTSP_6:def 4;
A39:    not u in Uu by ZFMISC_1:56;
        not u in {ua} by A5,TARSKI:def 1;
        then not u in Carrier L by A13,A39,XBOOLE_0:def 3;
        then
A40:    L.u=0.K by VECTSP_6:2;
        Lu.u * u = u by A28,VECTSP_6:17
          .= 1_K*u;
        then
A41:    Lu.u=1_K by A26,VECTSP10:4;
        LLL.u = (L+ LLv+LLu+(-LLua)).u by VECTSP_6:def 11
          .= (L+ LLv+LLu).u + (-LLua).u by VECTSP_6:22
          .= (L+ LLv).u+ LLu.u + (-LLua).u by VECTSP_6:22
          .= L.u+ LLv.u+ LLu.u + (-LLua).u by VECTSP_6:22
          .= 0.K+ 0.K + LLu.u -0.K by A20,A17,A40,VECTSP_6:36
          .= 0.K+LLu.u -0.K by RLVECT_1:def 4
          .= LLu.u-0.K by RLVECT_1:def 4
          .= LLu.u by VECTSP_1:18
          .= L.ua*1_K by A41,VECTSP_6:def 9
          .= L.ua;
        then
A42:    u in Carrier LLL by A12,VECTSP_6:1;
        Sum (L+ LLv+LLu-LLua)=Sum (L+LLv+LLu) - Sum LLua by VECTSP_6:47
          .= Sum (L+LLv)+ Sum LLu - Sum LLua by VECTSP_6:44
          .= Sum L+ Sum LLv+ Sum LLu - Sum LLua by VECTSP_6:44
          .= Sum L+ Sum LLv+ Sum LLu - L.ua * ua by A15,VECTSP_6:45
          .= Sum L+ Sum LLv+ (L.ua)*u - L.ua * ua by A28,VECTSP_6:45
          .= Sum L+ (a*L.ua)*v+ (L.ua)*u-L.ua*ua by A18,VECTSP_6:45
          .= Sum L+L.ua*(a*v)+L.ua*u-L.ua*ua by VECTSP_1:def 16
          .= Sum L+(L.ua*(a*v) + L.ua*u)-L.ua*ua by RLVECT_1:def 3
          .= Sum L+ L.ua*(a*v+ u)- L.ua*ua by VECTSP_1:def 14
          .= Sum L+ (L.ua*ua- L.ua*ua) by RLVECT_1:def 3
          .= 0.V+ 0.V by A6,VECTSP_1:16
          .= 0.V by RLVECT_1:def 4;
        hence Carrier L={} by A1,A42;
      end;
    end;
    hence thesis;
  end;
end;

theorem Th116:
  for V be VectSp of K for u, v be Vector of V holds x in Lin {u,
  v} iff ex a,b st x = a * u + b * v
proof
  let V be VectSp of K;
  let u, v be Vector of V;
  per cases;
  suppose
A1: u=v;
    then
A2: {u,v}={u} by ENUMSET1:29;
    thus x in Lin {u,v} implies ex a,b st x = a * u + b * v
    proof
      assume x in Lin{u,v};
      then consider a such that
A3:   x=a*u by A2,VECTSP10:3;
      x = a*u+0.V by A3,RLVECT_1:def 4
        .= a*u+0.K*v by VECTSP10:1;
      hence thesis;
    end;
    given a,b such that
A4: x = a * u + b * v;
    x=(a+b)*u by A1,A4,VECTSP_1:def 15;
    hence thesis by A2,VECTSP10:3;
  end;
  suppose
A5: u<>v;
    thus x in Lin {u,v} implies ex a,b st x = a * u + b * v
    proof
      assume x in Lin {u,v};
      then consider L be Linear_Combination of {u,v} such that
A6:   x=Sum L by VECTSP_7:7;
      x=L.u*u+L.v*v by A5,A6,VECTSP_6:18;
      hence thesis;
    end;
    deffunc F(set) = 0.K;
    given a,b such that
A7: x = a * u + b * v;
    consider L be Function of the carrier of V, the carrier of K such that
A8: L.u = a & L.v=b and
A9: for z be Element of V st z <> u & z<>v holds L.z = F(z) from
    FUNCT_2:sch 7(A5);
    reconsider L as Element of Funcs(the carrier of V,the carrier of K) by
FUNCT_2:8;
    now
      let z be Vector of V such that
A10:  not z in {u,v};
A11:  z<>u by A10,TARSKI:def 2;
      z <> v by A10,TARSKI:def 2;
      hence L.z = 0.K by A9,A11;
    end;
    then reconsider L as Linear_Combination of V by VECTSP_6:def 1;
    Carrier L c= {u,v}
    proof
      let x be object such that
A12:  x in Carrier L;
      L.x <> 0.K by A12,VECTSP_6:2;
      then x = v or x=u by A9,A12;
      hence thesis by TARSKI:def 2;
    end;
    then reconsider L as Linear_Combination of {u,v} by VECTSP_6:def 4;
    Sum(L) = x by A5,A7,A8,VECTSP_6:18;
    hence thesis by VECTSP_7:7;
  end;
end;

theorem Th117:
  for M st lines M is linearly-independent & M is
without_repeated_line for i,j st j in Seg len M & i <> j holds RLine(M,i,Line(M
  ,i) + a*Line(M,j)) is without_repeated_line & lines RLine(M,i,Line(M,i) + a*
  Line(M,j)) is linearly-independent
proof
  let M such that
A1: lines M is linearly-independent and
A2: M is without_repeated_line;
  set V=n-VectSp_over K;
  let i,j such that
A3: j in Seg len M and
A4: i<>j;
  set Lj=Line(M,j);
  set Li=Line(M,i);
  set R=RLine(M,i,Li+a*Lj);
  per cases;
  suppose
    not i in Seg len M;
    hence thesis by A1,A2,Th40;
  end;
  suppose
A5: i in Seg len M;
    reconsider N=n as Element of NAT by ORDINAL1:def 12;
A6: dom M=Seg len M by FINSEQ_1:def 3;
    then
A7: M.i<>M.j by A2,A3,A4,A5;
A8: len M=m by MATRIX_0:def 2;
    then
A9: Lj in lines M by A3,Th103;
A10: Li in lines M by A5,A8,Th103;
    then reconsider LI=Li,LJ=Lj as Vector of V by A9;
    reconsider li=LI,lj=LJ as Element of N-tuples_on the carrier of K by Th102;
A11: M.i=Li by A5,A8,MATRIX_0:52;
    m <> 0 by A5,A8;
    then
A12: n=width M by Th1;
A13: M.j=Lj by A3,A8,MATRIX_0:52;
A14: for k st k in Seg m & k<>i holds Line(R,k)<>Li + a*Lj
    proof
      a*lj = a*LJ by Th102;
      then li+a*lj = LI+a*LJ by Th102
        .= (1_K)*LI+a*LJ;
      then
A15:  li+a*lj in Lin {LI,LJ} by Th116;
      let k such that
A16:  k in Seg m and
A17:  k<>i;
      set Lk=Line(M,k);
      assume
A18:  Line(R,k)=Li+a*Lj;
A19:  Line(R,k) = Line(M,k) by A16,A17,MATRIX11:28;
A20:  Lj<>Lk
      proof
        {LI,LJ} c= lines M by A10,A9,ZFMISC_1:32;
        then
A21:    {LI,LJ} is linearly-independent by A1,VECTSP_7:1;
        assume
A22:    Lj=Lk;
A23:    (1_K+(-1_K)*a)*LJ=(1_K+(-1_K)*a)*lj by Th102;
A24:    (-1_K)*LI=(-1_K)*li by Th102;
        0.V = n|->0.K by Th102
          .= lj+-(li+a*lj) by A19,A18,A22,FVSUM_1:26
          .= lj+(-li+-a*lj) by FVSUM_1:31
          .= lj+((-1_K)*li+-a*lj) by FVSUM_1:59
          .= lj+((-1_K)*li+(-1_K)*(a*lj)) by FVSUM_1:59
          .= lj+((-1_K)*li+((-1_K)*a)*lj) by FVSUM_1:54
          .= lj+(((-1_K)*a)*lj+(-1_K)*li) by FINSEQOP:33
          .= lj+((-1_K)*a)*lj+(-1_K)*li by FINSEQOP:28
          .= 1_K*lj+((-1_K)*a)*lj+(-1_K)*li by FVSUM_1:57
          .= (1_K+(-1_K)*a)*lj+(-1_K)*li by FVSUM_1:55
          .= (1_K+(-1_K)*a)*LJ+(-1_K)*LI by A24,A23,Th102;
        then -1_K=0.K by A7,A11,A13,A21,VECTSP_7:6;
        hence thesis by VECTSP_1:28;
      end;
A25:  Lk in lines M by A16,Th103;
      then reconsider LK=Lk as Vector of V;
      reconsider KIJ={LK,LI,LJ} as Subset of V;
A26:  KIJ is linearly-independent by A1,A10,A9,A25,VECTSP_7:1,ZFMISC_1:133;
A27:  Lk in KIJ by ENUMSET1:def 1;
A28:  M.k=Lk by A16,MATRIX_0:52;
      M.i<>M.k by A2,A5,A8,A6,A16,A17;
      then KIJ \ {LK} = {LI, LJ} by A11,A20,A28,ENUMSET1:86;
      hence thesis by A19,A18,A15,A27,A26,VECTSP_9:14;
    end;
    reconsider LiaLj=li+a*lj as Element of (the carrier of K)* by
FINSEQ_1:def 11;
    reconsider LL=LiaLj as set;
    set iLL=i.-->LL;
A29: len (li+a*lj)=n by CARD_1:def 7;
    then RLine(M,i,li+a*lj) = Replace(M, i, LiaLj) by A12,MATRIX11:29
      .= M+*iLL by A5,A6,FUNCT_7:def 3;
    then
A30: lines RLine(M,i,Li+a*Lj) = M.:(dom M\dom iLL)\/rng iLL by FRECHET:12
      .= M.:(dom M\{i})\/rng iLL
      .= M.:(dom M\{i})\/{LL} by FUNCOP_1:8
      .= (M.:dom M\M.:{i})\/{LL} by A2,FUNCT_1:64
      .= (lines M\Im(M,i))\/{LL} by RELAT_1:113
      .= (lines M\{LI})\/{li+a*lj} by A5,A6,A11,FUNCT_1:59;
A31: Line(R,i)=Li+a*Lj by A5,A8,A29,A12,MATRIX11:28;
    now
A32:  len R=m by MATRIX_0:def 2;
      let x1,x2 be object such that
A33:  x1 in dom R and
A34:  x2 in dom R and
A35:  R.x1=R.x2;
      reconsider i1=x1,i2=x2 as Element of NAT by A33,A34;
A36:  dom R=Seg len R by FINSEQ_1:def 3;
      then
A37:  R.i1=Line(R,i1) by A33,A32,MATRIX_0:52;
A38:  R.i2=Line(R,i2) by A34,A36,A32,MATRIX_0:52;
      per cases;
      suppose
        i1=i & i2=i;
        hence x1=x2;
      end;
      suppose
        i1=i & i2<>i or i1<>i & i2=i;
        hence x1=x2 by A14,A31,A33,A34,A35,A36,A32,A37,A38;
      end;
      suppose
A39:    i1<>i & i2<>i;
        then
A40:    R.i2=Line(M,i2) by A34,A36,A32,A38,MATRIX11:28;
A41:    Line(M,i1) = M.i1 by A33,A36,A32,MATRIX_0:52;
A42:    Line(M,i2) = M.i2 by A34,A36,A32,MATRIX_0:52;
        R.i1=Line(M,i1) by A33,A36,A32,A37,A39,MATRIX11:28;
        hence x1=x2 by A2,A8,A6,A33,A34,A35,A36,A32,A41,A40,A42;
      end;
    end;
    hence R is without_repeated_line;
A43: a*lj = a*LJ by Th102;
    lines M\{LI}\/{LI+a*LJ} is linearly-independent by A1,A7,A11,A13,A10,A9
,Th115;
    hence thesis by A43,A30,Th102;
  end;
end;

theorem Th118:
  P c= Seg m implies lines Segm(M,P,Seg n) c= lines M
proof
  set S=Segm(M,P,Seg n);
  assume
A1: P c= Seg m;
A2: rng Sgm P = P by FINSEQ_1:def 14;
  let x be object;
  assume x in lines S;
  then consider i such that
A3: i in Seg card P and
A4: x = Line(S,i) by Th103;
  Seg m <> {} by A1,A3;
  then m <> 0;
  then width M=n by Th1;
  then
A5: Line(S,i)=Line(M,Sgm P.i) by A3,Th48;
  dom Sgm P=Seg card P by FINSEQ_3:40;
  then Sgm P.i in rng Sgm P by A3,FUNCT_1:def 3;
  hence thesis by A1,A4,A2,A5,Th103;
end;

theorem Th119:
  P c= Seg m & lines M is linearly-independent implies lines Segm
  (M,P,Seg n) is linearly-independent
proof
  assume that
A1: P c= Seg m and
A2: lines M is linearly-independent;
  card Seg n=n by FINSEQ_1:57;
  hence thesis by A1,A2,Th118,VECTSP_7:1;
end;

theorem Th120:
  P c= Seg m & M is without_repeated_line implies Segm(M,P,Seg n)
  is without_repeated_line
proof
  assume that
A1: P c= Seg m and
A2: M is without_repeated_line;
  set S=Segm(M,P,Seg n);
  let x1,x2 be object such that
A3: x1 in dom S and
A4: x2 in dom S and
A5: S.x1=S.x2;
  reconsider i1=x1,i2=x2 as Element of NAT by A3,A4;
  len S=card P by MATRIX_0:def 2;
  then
A6: dom S=Seg card P by FINSEQ_1:def 3;
  then
A7: Line(S,i1)=S.i1 by A3,MATRIX_0:52;
A8: Line(S,i2)=S.i2 by A4,A6,MATRIX_0:52;
A9: Sgm P is one-to-one by FINSEQ_3:92;
A10: dom Sgm P=dom S by A6,FINSEQ_3:40;
  Seg m<>{} by A1,A3,A6;
  then m <> 0;
  then
A11: width M=n by Th1;
  then
A12: Line(S,i1) = Line(M,Sgm P.i1) by A3,A6,Th48;
A13: Line(S,i2) = Line(M,Sgm P.i2) by A4,A6,A11,Th48;
A14: len M=m by MATRIX_0:def 2;
A15: rng Sgm P=P by FINSEQ_1:def 14;
  then
A16: Sgm P.i2 in P by A4,A10,FUNCT_1:def 3;
  then
A17: Line(M,Sgm P.i2)=M.(Sgm P.i2) by A1,MATRIX_0:52;
A18: Sgm P.i1 in P by A3,A10,A15,FUNCT_1:def 3;
  then Sgm P.i1 in Seg m by A1;
  then
A19: Sgm P.i1 in dom M by A14,FINSEQ_1:def 3;
  Sgm P.i2 in Seg m by A1,A16;
  then
A20: Sgm P.i2 in dom M by A14,FINSEQ_1:def 3;
  Line(M,Sgm P.i1)=M.(Sgm P.i1) by A1,A18,MATRIX_0:52;
  then Sgm P.i1=Sgm P.i2 by A2,A5,A12,A13,A7,A8,A17,A19,A20;
  hence thesis by A3,A4,A10,A9;
end;

theorem Th121:
  for M be Matrix of m,n,K holds lines M is linearly-independent
  & M is without_repeated_line iff the_rank_of M = m
proof
  defpred P[Nat] means for m,n st m=$1 for M be Matrix of m,n,K holds lines M
  is linearly-independent & M is without_repeated_line iff the_rank_of M = m;
A1: for k st P[k] holds P[k+1]
  proof
    let k such that
A2: P[k];
    let m,n such that
A3: m=k+1;
    let M be Matrix of m,n,K;
    thus lines M is linearly-independent & M is without_repeated_line implies
    the_rank_of M = m
    proof
A4:   k<m by A3,NAT_1:13;
A5:   len (n|->0.K)=n by CARD_1:def 7;
      k<m by A3,NAT_1:13;
      then
A6:   Seg k c= Seg m by FINSEQ_1:5;
A7:   m in Seg m by A3,FINSEQ_1:4;
      then Line(M,m) in lines M by Th103;
      then reconsider
      LM=Line(M,m) as Element of n-tuples_on the carrier of K by Th102;
A8:   len LM=n by CARD_1:def 7;
      assume that
A9:   lines M is linearly-independent and
A10:  M is without_repeated_line;
      LM <> n |-> 0.K by A9,A10,A7,Th109;
      then consider i such that
A11:  1<=i and
A12:  i<=n and
A13:  LM.i<>(n|->0.K).i by A8,A5;
      defpred Q[Nat] means $1<m implies ex M1 be Matrix of m,n,K st Line(M1,m)
=Line(M,m) & lines M1 is linearly-independent & M1 is without_repeated_line &
the_rank_of M1=the_rank_of M & for j st j <= $1 & j in Seg m holds M1*(j,i)=0.K
      ;
A14:  i in Seg n by A11,A12;
      then
A15:  LM.i<>0.K by A13,FINSEQ_2:57;
      len Line(M,m)=width M by MATRIX_0:def 7;
      then
A16:  LM.i=M*(m,i) by A8,A14,MATRIX_0:def 7;
A17:  for l st Q[l] holds Q[l+1]
      proof
        set Mmi=M*(m,i);
        let L be Nat such that
A18:    Q[L];
        set L1=L+1;
        assume
A19:    L1<m;
        then consider M1 be Matrix of m,n,K such that
A20:    Line(M1,m)=Line(M,m) and
A21:    lines M1 is linearly-independent and
A22:    M1 is without_repeated_line and
A23:    the_rank_of M1=the_rank_of M and
A24:    for j st j <= L & j in Seg m holds M1*(j,i) = 0.K by A18,NAT_1:13;
        set MLi=M1*(L1,i);
        take R=RLine(M1,L1,Line(M1,L1)+((-(Mmi"*MLi))*Line(M1,m)));
        len M1=m by MATRIX_0:def 2;
        hence Line(R,m)=Line(M,m) & lines R is linearly-independent & R is
without_repeated_line & the_rank_of R=the_rank_of M by A7,A19,A20,A21,A22,A23
,Th92,Th117,MATRIX11:28;
        set LMm=Line(M1,m);
        set LML=Line(M1,L1);
        let j such that
A25:    j <= L1 and
A26:    j in Seg m;
        m <> 0 by A26;
        then
A27:    width M1=n by Th1;
        then
A28:    LML.i=MLi by A14,MATRIX_0:def 7;
        0+1<=L1 by NAT_1:13;
        then
A29:    L1 in Seg m by A19;
        len (LML+(-(Mmi"*MLi))*LMm) = width M1 by CARD_1:def 7;
        then
A30:    Line(R,L1) = LML+(-(Mmi"*MLi))*LMm by A29,MATRIX11:28;
        m <> 0 by A26;
        then
        width M=n by Th1;
        then LMm.i=M*(m,i) by A14,A20,MATRIX_0:def 7;
        then ((-(Mmi"*MLi))*LMm).i=(-(Mmi" * MLi)) *Mmi by A14,A27,FVSUM_1:51;
        then
A31:    Line(R,L1).i = MLi+(-(Mmi" * MLi)) *Mmi by A14,A27,A28,A30,FVSUM_1:18
          .= MLi+(-(1_K*(Mmi" * MLi))) *Mmi
          .= MLi+(-1_K)*(Mmi" * MLi) *Mmi by VECTSP_1:9
          .= MLi+(-1_K)*(Mmi" * MLi *Mmi) by GROUP_1:def 3
          .= MLi+(-1_K)*(Mmi" * Mmi* MLi ) by GROUP_1:def 3
          .= MLi+(-1_K)*(1_K* MLi) by A15,A16,VECTSP_1:def 10
          .= MLi+(-1_K)*MLi
          .= MLi+(-(1_K)*MLi) by VECTSP_1:9
          .= MLi+(-MLi)
          .= 0.K by RLVECT_1:5;
        m <> 0 by A26;
        then
A32:    width R=n by Th1;
        per cases by A25,NAT_1:9;
        suppose
          j=L1;
          hence thesis by A14,A32,A31,MATRIX_0:def 7;
        end;
        suppose
A33:      j<=L;
          then
A34:      j<L1 by NAT_1:13;
          thus 0.K = M1*(j,i) by A24,A26,A33
            .= Line(M1,j).i by A14,A27,MATRIX_0:def 7
            .= Line(R,j).i by A26,A34,MATRIX11:28
            .= R*(j,i) by A14,A32,MATRIX_0:def 7;
        end;
      end;
A35:  Q[0]
      proof
        assume 0<m;
        take M;
        thus thesis by A9,A10;
      end;
      for l holds Q[l] from NAT_1:sch 2(A35,A17);
      then consider M1 be Matrix of m,n,K such that
A36:  Line(M1,m)=Line(M,m) and
A37:  lines M1 is linearly-independent and
A38:  M1 is without_repeated_line and
A39:  the_rank_of M1=the_rank_of M and
A40:  for j st j <= k & j in Seg m holds M1*(j,i)=0.K by A4;
      set S=Segm(M1,Seg k,Seg n);
A41:  card Seg k=k by FINSEQ_1:57;
      then
A42:  len S=k by MATRIX_0:def 2;
A43:  card Seg n=n by FINSEQ_1:57;
A44:  now
A45:    (Sgm Seg n).i = (idseq n).i by FINSEQ_3:48
          .= i by A14,FINSEQ_2:49;
        let j such that
A46:    j in Seg k;
A47:    j<=k by A46,FINSEQ_1:1;
A48:    (Sgm Seg k).j = (idseq k).j by FINSEQ_3:48
          .= j by A46,FINSEQ_2:49;
        width S=n by A43,A46,Th1;
        then [j,i] in [:Seg k,Seg width S:] by A14,A46,ZFMISC_1:87;
        then [j,i] in Indices S by A42,FINSEQ_1:def 3;
        hence S*(j,i) = M1*((Sgm Seg k).j,(Sgm Seg n).i) by Def1
          .= 0.K by A40,A6,A46,A48,A45,A47;
      end;
      set SwS=Seg width S;
      set SSS=Segm(S,Seg k,SwS\{i});
A49:  width M1=n by A3,Th1;
      S is without_repeated_line by A38,A6,Th120;
      then
A50:  SSS is without_repeated_line by A41,A42,A44,Th113;
      lines S is linearly-independent by A37,A6,Th119;
      then lines SSS is linearly-independent by A38,A6,A41,A42,A44,Th114,Th120;
      then the_rank_of SSS=k by A2,A41,A50;
      then consider P,Q such that
A51:  [:P,Q:] c= Indices SSS and
A52:  card P = card Q and
A53:  card P = k and
A54:  Det EqSegm(SSS,P,Q)<>0.K by Def4;
      P={} iff Q={} by A52;
      then consider P1,Q1 such that
A55:  P1 c= Seg k and
A56:  Q1 c= Seg width S\{i} and
      P1 = (Sgm Seg k).:P and
      Q1=Sgm (Seg width S\{i}).:Q and
A57:  card P1=card P and
A58:  card Q1=card Q and
A59:  Segm(SSS,P,Q) = Segm(S,P1,Q1) by A51,Th57;
      Seg width S\{i} c= Seg width S by XBOOLE_1:36;
      then
A60:  Q1 c= Seg width S by A56;
      then [:P1,Q1:] c= [:Seg k,Seg width S:] by A55,ZFMISC_1:96;
      then
A61:  [:P1,Q1:] c= Indices S by A42,FINSEQ_1:def 3;
A62:  now
        per cases;
        suppose
          k=0;
          then width S=0 by A42,MATRIX_0:def 3;
          then Seg width S c= Seg n;
          hence Q1 c= Seg n by A60;
        end;
        suppose
          k>0;
          hence Q1 c= Seg n by A43,A60,Th1;
        end;
      end;
      P1={} iff Q1={} by A52,A57,A58;
      then consider P2,Q2 such that
A63:  P2 c= Seg k and
A64:  Q2 c= Seg n and
A65:  P2= Sgm (Seg k).:P1 and
A66:  Q2=Sgm (Seg n).:Q1 and
A67:  card P2=card P1 and
A68:  card Q2=card Q1 and
A69:  Segm(S,P1,Q1) = Segm(M1,P2,Q2) by A61,Th57;
A70:  Q2 = (idseq n).:Q1 by A66,FINSEQ_3:48
        .= Q1 by A62,FRECHET:13;
      reconsider i,m as non zero Element of NAT by A3,A11,ORDINAL1:def 12;
      set Q2i=Q2\/{i};
      set SQ2i=Sgm Q2i;
      {i} c= Seg n by A14,ZFMISC_1:31;
      then
A72:  Q2i c= Seg n by A64,XBOOLE_1:8;
A73:  rng SQ2i=Q2i by FINSEQ_1:def 14;
A74:  P2 = (idseq k).:P1 by A65,FINSEQ_3:48
        .= P1 by A55,FRECHET:13;
A75:  EqSegm(SSS,P,Q) = Segm(S,P1,Q1) by A52,A59,Def3
        .= EqSegm(M1,P1,Q1) by A52,A57,A58,A69,A74,A70,Def3;
A76:  len EqSegm(M1,P2,Q2)=k by A53,A57,A67,MATRIX_0:def 2;
A77:  len M1=m by Th1;
      then
A78:  the_rank_of M1 <= m by Th74;
      set P2m=P2\/{m};
      set ES=EqSegm(M1,P2m,Q2i);
A79:  P2 c= Seg m by A6,A63;
      i in {i} by TARSKI:def 1;
      then
A80:  i in Q2i by XBOOLE_0:def 3;
      i in {i} by TARSKI:def 1;
      then
A81:  not i in Q2 by A56,A70,XBOOLE_0:def 5;
      then
A82:  card Q2i=m by A3,A52,A53,A58,A68,CARD_2:41;
      then dom SQ2i=Seg m by FINSEQ_3:40;
      then consider Si be object such that
A83:  Si in Seg m and
A84:  SQ2i.Si=i by A80,A73,FUNCT_1:def 3;
      reconsider Si as Element of NAT by A83;
      k<m by A3,NAT_1:13;
      then
A85:  not m in P2 by A55,A74,FINSEQ_1:1;
      then
A86:  card P2m=m by A3,A53,A57,A67,CARD_2:41;
      then
A87:  len Delete(ES,m,Si)=m-'1 by MATRIX_0:def 2;
A88:  {m} c= Seg m by A7,ZFMISC_1:31;
      then P2m c= Seg m by A79,XBOOLE_1:8;
      then [:P2m,Q2i:] c= [:Seg m,Seg n:] by A72,ZFMISC_1:96;
      then
A89:  [:P2m,Q2i:] c= Indices M1 by A77,A49,FINSEQ_1:def 3;
      card Seg m=m by FINSEQ_1:57;
      then
A90:  P2m=Seg m by A88,A79,A86,CARD_2:102,XBOOLE_1:8;
A91:  now
A92:    dom ES=Seg len ES by FINSEQ_1:def 3;
A93:    dom M1=Seg len M1 by FINSEQ_1:def 3;
A94:    m=len ES by A86,MATRIX_0:def 2;
        let j such that
A95:    j in Seg m;
        Col(M1,i) = Col(Segm(M1,P2m,Q2i),Si) by A77,A82,A83,A84,A90,Th50
          .= Col(ES,Si) by A3,A53,A57,A67,A85,A82,Def3,CARD_2:41;
        hence ES*(j,Si) = Col(M1,i).j by A95,A94,A92,MATRIX_0:def 8
          .= M1*(j,i) by A77,A95,A93,MATRIX_0:def 8;
      end;
      then
A96:  ES*(m,Si) = M1*(m,i) by A3,FINSEQ_1:4
        .= Line(M,m).i by A14,A36,A49,MATRIX_0:def 7;
      set LC=LaplaceExpC(ES,Si);
      len LC = m by A86,LAPLACE:def 8;
      then
A97:  dom LC=Seg m by FINSEQ_1:def 3;
      now
        let j such that
A98:    j in Seg m and
A99:    j<>m;
        reconsider J=j as Element of NAT by ORDINAL1:def 12;
        j<=m by A98,FINSEQ_1:1;
        then j<=k by A3,A99,NAT_1:9;
        then 0.K = M1*(j,i) by A40,A98
          .= ES*(j,Si) by A91,A98;
        hence 0.K = ES*(j,Si)*Cofactor(ES,J,Si)
          .= LC.j by A97,A98,LAPLACE:def 8;
      end;
      then
A100: LC.m = Sum LC by A7,A97,MATRIX_3:12
        .= Det ES by A86,A83,LAPLACE:27;
      reconsider mSi=m+Si as Element of NAT;
      -1_K<>0.K by VECTSP_1:28;
      then
A101: power(K).(-1_K,mSi)<>0.K by Lm6;
      Sgm P2m.m = (idseq m).m by A90,FINSEQ_3:48
        .= m by A7,FINSEQ_2:49;
      then Delete(ES,m,Si) = EqSegm(M1,P2m\{m},Q2i\{i}) by A7,A86,A82,A83,A84
,Th64
        .= EqSegm(M1,P2,Q2i\{i}) by A85,ZFMISC_1:117
        .= EqSegm(M1,P2,Q2) by A81,ZFMISC_1:117;
      then power(K).(-1_K,mSi)*Minor(ES,m,Si)<>0.K by A53,A54,A74,A70,A75,A86
,A87,A76,A101,VECTSP_1:12;
      then ES*(m,Si)* Cofactor(ES,m,Si)<>0.K by A15,A96,VECTSP_1:12;
      then Det ES<>0.K by A7,A97,A100,LAPLACE:def 8;
      then the_rank_of M1 >= m by A89,A86,A82,Def4;
      hence thesis by A39,A78,XXREAL_0:1;
    end;
    thus thesis by Th105,Th110;
  end;
A102: P[0]
  proof
    let m,n such that
A103: m=0;
    let M be Matrix of m,n,K;
 len M=0 by A103,MATRIX_0:def 2;
    then M={};
    hence thesis by A103,Th74;
  end;
  for k holds P[k] from NAT_1:sch 2(A102,A1);
  hence thesis;
end;

theorem Th122:
  for U be Subset of n-VectSp_over K st U c= lines M ex P st P c=
  Seg m & lines Segm(M,P,Seg n) = U & Segm(M,P,Seg n) is without_repeated_line
proof
  defpred P[object,object] means
    ex i st i in Seg m & Line(M,i)=$1 & $2=i;
  let U be Subset of n-VectSp_over K such that
A1: U c= lines M;
A2: for x being object st x in U ex y being object st y in Seg m & P[x,y]
  proof
    let x be object;
    assume x in U;
    then consider i such that
A3: i in Seg m and
A4: x=Line(M,i) by A1,Th103;
    take i;
    thus thesis by A3,A4;
  end;
  consider f be Function of U,Seg m such that
A5: for x being object st x in U holds P[x,f.x] from FUNCT_2:sch 1(A2);
A6: rng f c= Seg m by RELAT_1:def 19;
  then not 0 in rng f;
  then reconsider P=rng f as without_zero finite Subset of NAT by A6,
MEASURE6:def 2,XBOOLE_1:1;
  set S=Segm(M,P,Seg n);
A7: rng Sgm P=P by FINSEQ_1:def 14;
A8: lines S c= U
  proof
A9: rng Sgm P=P by FINSEQ_1:def 14;
    let x be object;
A10: dom S = Seg len S by FINSEQ_1:def 3
      .= Seg card P by MATRIX_0:def 2;
    assume
A11: x in lines S;
    then consider y being object such that
A12: y in dom S and
A13: S.y=x by FUNCT_1:def 3;
    lines S c= lines M by A6,Th118;
    then
A14: M<>{} by A11;
    len M=m by MATRIX_0:def 2;
    then
A15: width M=n by A14,Th1;
    reconsider y as Element of NAT by A12;
    dom Sgm P = Seg card P by FINSEQ_3:40;
    then Sgm P.y in rng Sgm P by A12,A10,FUNCT_1:def 3;
    then consider z be object such that
A16: z in dom f and
A17: f.z=Sgm P.y by A9,FUNCT_1:def 3;
    ex i st i in Seg m & Line(M,i)=z & f.z=i by A5,A16;
    then z = Line(S,y) by A12,A10,A17,A15,Th48
      .= x by A12,A13,A10,MATRIX_0:52;
    hence thesis by A16;
  end;
  take P;
  thus P c= Seg m by RELAT_1:def 19;
  U c= lines S
  proof
    let x be object;
A18: dom Sgm P=Seg card P by FINSEQ_3:40;
    assume
A19: x in U;
    then consider i such that
A20: i in Seg m and
A21: Line(M,i)=x and
A22: f.x=i by A5;
    dom f=U by A20,FUNCT_2:def 1;
    then i in P by A19,A22,FUNCT_1:def 3;
    then i in rng Sgm P by FINSEQ_1:def 14;
    then consider y being object such that
A23: y in dom Sgm P and
A24: Sgm P.y=i by FUNCT_1:def 3;
    reconsider y as Element of NAT by A23;
    m <> 0 by A20;
        then
    width M=n by Th1;
    then Line(S,y)=x by A21,A23,A24,A18,Th48;
    hence thesis by A23,A18,Th103;
  end;
  hence U=lines S by A8,XBOOLE_0:def 10;
  let x1,x2 be object such that
A25: x1 in dom S and
A26: x2 in dom S and
A27: S.x1=S.x2;
A28: dom S = Seg len S by FINSEQ_1:def 3
    .= Seg card P by MATRIX_0:def 2;
  then
A29: dom Sgm P=dom S by FINSEQ_3:40;
  reconsider i1=x1,i2=x2 as Element of NAT by A25,A26;
A30: dom Sgm P = Seg card P by FINSEQ_3:40;
  then Sgm P.i1 in rng Sgm P by A25,A28,FUNCT_1:def 3;
  then consider y1 be object such that
A31: y1 in dom f and
A32: f.y1=Sgm P.i1 by A7,FUNCT_1:def 3;
A33: ex j1 be Nat st j1 in Seg m & Line(M,j1)=y1 & f.y1=j1 by A5,A31;
        then m <> 0;
        then
A34: width M=n by Th1;
  Sgm P.i2 in rng Sgm P by A26,A28,A30,FUNCT_1:def 3;
  then consider y2 be object such that
A35: y2 in dom f and
A36: f.y2=Sgm P.i2 by A7,FUNCT_1:def 3;
  ex j2 be Nat st j2 in Seg m & Line(M,j2)=y2 & f.y2=j2 by A5,A35;
  then
A37: Line(S,i2)=y2 by A26,A28,A36,A34,Th48;
A38: Sgm P is one-to-one by FINSEQ_3:92;
A39: Line(S,i1)=S.i1 by A25,A28,MATRIX_0:52;
  Line(S,i1)=y1 by A25,A28,A32,A33,A34,Th48;
  then Sgm P.i1=Sgm P.i2 by A26,A27,A28,A32,A36,A37,A39,MATRIX_0:52;
  hence thesis by A25,A26,A29,A38;
end;

theorem
  for RANK be Element of NAT holds the_rank_of M = RANK iff (ex U be
finite Subset of n-VectSp_over K st U is linearly-independent & U c= lines M &
  card U = RANK) & for W be finite Subset of n-VectSp_over K st W is
  linearly-independent & W c= lines M holds card W <= RANK
proof
  let R be Element of NAT;
A1: len M=m by MATRIX_0:def 2;
A2: card Seg n=n by FINSEQ_1:57;
A3: for W be finite Subset of n-VectSp_over K st W is linearly-independent
  & W c= lines M holds card W <= the_rank_of M
  proof
    let W be finite Subset of n-VectSp_over K such that
A4: W is linearly-independent and
A5: W c= lines M;
    consider P1 such that
A6: P1 c= Seg m and
A7: lines Segm(M,P1,Seg n) = W and
A8: Segm(M,P1,Seg n) is without_repeated_line by A5,Th122;
    set S1=Segm(M,P1,Seg n);
A9: S1.:dom S1=lines S1 by RELAT_1:113;
    dom S1,S1.:dom S1 are_equipotent by A8,CARD_1:33;
    then
A10: card W = card dom S1 by A7,A9,CARD_1:5
      .= card Seg len S1 by FINSEQ_1:def 3
      .= card Seg card P1 by MATRIX_0:def 2
      .= card P1 by FINSEQ_1:57;
    per cases;
    suppose
      card P1=0;
      hence thesis by A10;
    end;
    suppose
      card P1>0;
      then
  Seg m <>{} by A6;
        then
A11:      m <> 0;
        then
A12:  len M=m by Th1;
      width M=n by Th1,A11;
      then [:P1,Seg n:] c= [:Seg len M,Seg width M:] by A6,A12,ZFMISC_1:96;
      then [:P1,Seg n:] c= Indices M by FINSEQ_1:def 3;
      then the_rank_of S1 <= the_rank_of M by Th79;
      hence thesis by A2,A4,A7,A8,A10,Th121;
    end;
  end;
A13: now
    per cases;
    suppose
      len M=0;
      then width M=0 by MATRIX_0:def 3;
      hence Seg width M c= Seg n;
    end;
    suppose
      len M>0;
      then m>0 by MATRIX_0:def 2;
      hence Seg width M c= Seg n by Th1;
    end;
  end;
  consider P,Q such that
A14: [:P,Q:] c= Indices M and
A15: card P = card Q and
A16: card P = the_rank_of M and
A17: Det EqSegm(M,P,Q)<>0.K by Def4;
  Q c= Seg width M by A14,A15,Th67;
  then
A18: Q c= Seg n by A13;
  set S=Segm(M,P,Seg n);
A19: len S=card P by MATRIX_0:def 2;
  Segm(M,P,Q)=EqSegm(M,P,Q) by A15,Def3;
  then
A20: the_rank_of EqSegm(M,P,Q) <= the_rank_of S by A18,Th80;
A21: the_rank_of S<=len S by Th74;
  the_rank_of EqSegm(M,P,Q) = card P by A17,Th83;
  then
A22: the_rank_of S = card P by A20,A19,A21,XXREAL_0:1;
  then
A23: lines S is linearly-independent by Th121;
  S is without_repeated_line by A22,Th121;
  then
A24: dom S,S.:dom S are_equipotent by CARD_1:33;
  S.:dom S=lines S by RELAT_1:113;
  then
A25: card lines S = card dom S by A24,CARD_1:5
    .= card Seg len S by FINSEQ_1:def 3
    .= card Seg card P by MATRIX_0:def 2
    .= card P by FINSEQ_1:57;
A26: P c= Seg len M by A14,A15,Th67;
  then lines S c= lines M by A1,Th118;
  hence the_rank_of M = R implies (ex U be finite Subset of n-VectSp_over K st
U is linearly-independent & U c= lines M & card U = R) & for W be finite Subset
of n-VectSp_over K st W is linearly-independent & W c= lines M holds card W <=
  R by A16,A23,A25,A2,A3;
  assume that
A27: ex U be finite Subset of n-VectSp_over K st U is
  linearly-independent & U c= lines M & card U = R and
A28: for W be finite Subset of n-VectSp_over K st W is
  linearly-independent & W c= lines M holds card W <= R;
A29: R <= the_rank_of M by A3,A27;
  the_rank_of M <= R by A16,A23,A25,A26,A1,A2,A28,Th118;
  hence thesis by A29,XXREAL_0:1;
end;