reserve x,y for set,
  i,j,k,l,m,n for Nat,
  K for Field,
  N for without_zero finite Subset of NAT,
  a,b for Element of K,
  A,B,B1,B2,X,X1,X2 for (Matrix of K),
  A9 for (Matrix of m,n,K),
  B9 for (Matrix of m,k,K);
reserve D for non empty set,
  bD for FinSequence of D,
  b,f,g for FinSequence of K,
  MD for Matrix of D;

theorem Th68:
  for A st ( width A = 0 implies len A = 0 ) holds dim
  Space_of_Solutions_of A = width A - the_rank_of A
proof
  let A such that
A1: width A = 0 implies len A = 0;
  set W=width A;
  set L=len A;
  reconsider A9=A as Matrix of L,W,K by MATRIX_0:51;
  per cases;
  suppose
A2: the_rank_of A=0;
    dim ((width A)-VectSp_over K)=width A by MATRIX13:112;
    hence thesis by A1,A2,Th63;
  end;
  suppose
A3: the_rank_of A>0;
    defpred P[set,set] means for A1 be Matrix of L,W,K st A1=$1 holds
    Space_of_Solutions_of A9=Space_of_Solutions_of A1;
    deffunc F(Matrix of L,W,K,Nat,Nat,Element of K) =$1;
A4: W>0 by A3,MATRIX13:74;
A5: for A1 be Matrix of L,W,K,B1 be Matrix of L,W,K st P[A1,B1] for a be
Element of K for i,j st j in dom A1 & (i = j implies a <> -1_K ) holds P[RLine(
    A1,i,Line(A1,i) + a*Line(A1,j)),F(B1,i,j,a)]
    proof
      let A1 be Matrix of L,W,K,B1 be Matrix of L,W,K such that
A6:   P[A1,B1];
      let a be Element of K;
A7:   dom A1 = Seg len A1 by FINSEQ_1:def 3
        .= Seg L by MATRIX_0:def 2;
      let i,j;
      assume j in dom A1 &( i = j implies a <> -1_K);
      then Space_of_Solutions_of RLine(A1,i,Line(A1,i) + a*Line(A1,j)) =
      Space_of_Solutions_of A1 by A4,A7,Th65
        .= Space_of_Solutions_of A9 by A6;
      hence thesis;
    end;
A8: P[A9,A9];
    consider A1 be Matrix of L,W,K,B1 be Matrix of L,W,K,N such that
A9: N c= Seg W and
A10: the_rank_of A9 = the_rank_of A1 & the_rank_of A9 = card N and
A11: P[A1,B1] & Segm(A1,Seg card N,N) = 1.(K,card N) and
A12: for i st i in dom A1 & i > card N holds Line(A1,i) = W|->0.K and
    for i,j st i in Seg card N & j in Seg width A1 & j < Sgm N.i holds A1*
    (i,j) = 0.K from GAUSS2(A8,A5);
A13: 0<L by A3,MATRIX13:74;
    then
A14: width A1=W by MATRIX_0:23;
    then
A15: card Seg width A1=W by FINSEQ_1:57;
    then
A16: card (Seg W\N)=W-card N by A9,A14,CARD_2:44;
    set SN=Segm(A1,Seg card N,Seg width A1);
A17: Seg card N c= Seg card N;
A18: W-'card N=W-card N by A9,A14,A15,NAT_1:43,XREAL_1:233;
    Sgm (Seg card N) = idseq card N by FINSEQ_3:48
      .= id Seg card N;
    then
A19: Seg card N=Sgm (Seg card N)"(Seg card N) by A17,FUNCT_2:94;
    Sgm (Seg width A1) = idseq width A1 by FINSEQ_3:48
      .= id Seg width A1;
    then N=Sgm (Seg width A1)"N by A9,A14,FUNCT_2:94;
    then
A20: Segm(SN,Seg card N,N)=1.(K,card N) by A9,A11,A14,A19,MATRIX13:56;
A21: card Seg card N=card N by FINSEQ_1:57;
A22: Seg len A1=dom A1 by FINSEQ_1:def 3;
A23: now
      let i such that
A24:  i in (dom A1) \ Seg card N;
      not i in Seg card N by A24,XBOOLE_0:def 5;
      then
A25:  i<1 or i > card N;
      i in dom A1 by A24,XBOOLE_0:def 5;
      hence Line(A1,i) = width A1 |-> 0.K by A12,A22,A14,A25,FINSEQ_1:1;
    end;
    card N <= len A1 by A10,MATRIX13:74;
    then
A26: Seg card N c= Seg len A1 by FINSEQ_1:5;
    width A1>0 by A4,A13,MATRIX_0:23;
    then
A27: Space_of_Solutions_of SN = Space_of_Solutions_of A1 by A3,A10,A26,A22,A23
,Th66
      .= Space_of_Solutions_of A9 by A11;
    per cases;
    suppose
A28:  W-'card N=0;
      then SN=1.(K,card N) by A9,A11,A14,A21,A18,CARD_2:102;
      hence thesis by A10,A27,A18,A28,Lm8;
    end;
    suppose
A29:  W-'card N>0;
      then W-'card N+0>0;
      then W-'card N>=1 by NAT_1:19;
      then
A30:  Det 1.(K,W-'card N)=1_K by MATRIX_7:16;
A31:  card Seg (W-'card N)=W-'card N & 0.K<>1_K by FINSEQ_1:57;
      consider MVectors be Matrix of W-'card N,W,K such that
A32:  Segm(MVectors,Seg (W-'card N),Seg W \ N) = 1.(K,W-'card N) and
      Segm(MVectors,Seg (W-'card N),N)=-Segm(SN,Seg card N,Seg W \N)@ and
A33:  Lin(lines MVectors) = Space_of_Solutions_of A9 by A3,A9,A10,A27,A21,A15
,A20,A29,Th67;
      len MVectors=W-'card N by A29,MATRIX_0:23;
      then
A34:  W-'card N>=the_rank_of MVectors by MATRIX13:74;
A35:  Seg W \ N c= Seg W by XBOOLE_1:36;
      Indices MVectors=[:Seg (W-'card N),Seg W:] by A29,MATRIX_0:23;
      then
A36:  [:Seg (W-'card N),Seg W \ N:] c= Indices MVectors by A35,ZFMISC_1:95;
      reconsider B=lines MVectors as Subset of W-VectSp_over K;
A37:  dom MVectors=Seg len MVectors & len MVectors=W-'card N by FINSEQ_1:def 3
,MATRIX_0:def 2;
      EqSegm(MVectors,Seg (W-'card N),Seg W \ N)=1.(K,W-'card N) by A16,A18,A32
,FINSEQ_1:57,MATRIX13:def 3;
      then
A38:  W-'card N<=the_rank_of MVectors by A16,A18,A36,A30,A31,MATRIX13:def 4;
      then MVectors is without_repeated_line by A34,MATRIX13:105,XXREAL_0:1;
      then Seg (W-'card N),B are_equipotent by A37,WELLORD2:def 4;
      then
A39:  card B = card Seg (W-'card N) by CARD_1:5
        .= W-'card N by FINSEQ_1:57;
      the_rank_of MVectors = W-'card N by A38,A34,XXREAL_0:1;
      then lines MVectors is linearly-independent by MATRIX13:121;
      hence thesis by A10,A18,A33,A39,VECTSP_9:26;
    end;
  end;
end;
