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;
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;
reserve P,P1,P2,Q,Q1,Q2 for without_zero finite Subset of NAT;
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 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;
