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