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
  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;
