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