reserve i,j,m,n,k for Nat,
  x,y for set,
  K for Field,
  a,a1,a2 for Element of K,
  D for non empty set,
  d,d1,d2 for Element of D,
  M,M1,M2 for (Matrix of D),
  A,A1,A2,B1,B2 for (Matrix of K),
  f,g for FinSequence of NAT;
reserve F,F1,F2 for FinSequence_of_Matrix of D,
  G,G9,G1,G2 for FinSequence_of_Matrix of K;

theorem Th35:
  block_diagonal(F1^F2,d) = block_diagonal(<*block_diagonal(F1,d) *>^F2,d)
proof
  set F12=F1^F2;
  set D1=block_diagonal(F1,d);
  set D2=block_diagonal(F2,d);
  set D12=block_diagonal(F12,d);
  set DF=<*D1*>^F2;
  set DF2=block_diagonal(DF,d);
  set LF1=Len F1;
  set WF1=Width F1;
  set LF2=Len F2;
  set WF2=Width F2;
  set LF=Len F12;
  set WF=Width F12;
A1: LF = LF1^LF2 by Th14;
  len D12= Sum LF by Def5;
  then
A2: len D12=Sum LF1+Sum LF2 by A1,RVSUM_1:75;
A3: Len <*D1*>=<*len D1*> by Th15;
  then
A4: Sum Len<*D1*>=len D1 by RVSUM_1:73;
A5: block_diagonal(<*D1*>,d)=D1 by Th34;
A6: Sum WF1=width D1 by Def5;
A7: Len DF=(Len <*D1*>)^LF2 by Th14;
A8: WF=WF1^WF2 by Th18;
  len DF2=Sum Len DF by Def5;
  then
A9: len DF2=len D1+Sum LF2 by A7,A3,RVSUM_1:76;
A10: Width <*D1*>=<*width D1*> by Th19;
  then
A11: Sum Width <*D1*> =width D1 by RVSUM_1:73;
A12: Sum LF1=len D1 by Def5;
A13: width D1=Sum WF1 by Def5;
A14: width D12 = Sum WF by Def5;
  then
A15: width D12=Sum WF1+Sum WF2 by A8,RVSUM_1:75;
A16: Width DF=( Width<*D1*>)^WF2 by Th18;
A17: len D1=Sum LF1 by Def5;
  width DF2=Sum Width DF by Def5;
  then
A18: width DF2=width D1+Sum WF2 by A16,A10,RVSUM_1:76;
A19: Indices D12 = [:Seg len D12,Seg width D12:] by FINSEQ_1:def 3
    .= Indices DF2 by A2,A15,A17,A13,A9,A18,FINSEQ_1:def 3;
  now
A20: dom D12=Seg len D12 by FINSEQ_1:def 3;
    let i,j such that
A21: [i,j] in Indices D12;
    i in dom D12 by A21,ZFMISC_1:87;
    then
A22: 1<=i by A20,FINSEQ_1:1;
 j in Seg width D12 by A21,ZFMISC_1:87;
    then
A23: 1<=j by FINSEQ_1:1;
    now
      per cases;
      suppose
A24:    i <= Sum LF1 & j<=Sum WF1;
        then
A25:    i in dom D1 by A12,A22,FINSEQ_3:25;
        j in Seg width D1 by A6,A23,A24;
        then
A26:    [i,j] in Indices D1 by A25,ZFMISC_1:87;
        hence D12*(i,j) = D1*(i,j) by Th26
          .= DF2*(i,j) by A5,A26,Th26;
      end;
      suppose
A27:    i> Sum LF1 & j <=Sum WF1 or i<= Sum LF1 & j >Sum WF1;
        hence D12*(i,j) = d by A21,Th29
          .= DF2*(i,j) by A17,A13,A4,A11,A19,A21,A27,Th29;
      end;
      suppose
A28:    i > Sum LF1 & j>Sum WF1;
        then reconsider ii=i-Sum LF1,jj=j-Sum WF1 as Element of NAT by NAT_1:21
;
A29:    jj<>0 by A28;
A30:    i=ii+Sum LF1;
A31:    j=jj+Sum WF1;
        ii<>0 by A28;
        then
A32:    [ii,jj] in Indices D2 by A21,A30,A31,A29,Th27;
        hence D12*(i,j) = D2*(ii,jj) by A30,A31,Th28
          .= DF2*(i,j) by A17,A13,A4,A11,A30,A31,A32,Th28;
      end;
    end;
    hence D12*(i,j)=DF2*(i,j);
  end;
  hence thesis by A14,A8,A2,A17,A13,A9,A18,MATRIX_0:21,RVSUM_1:75;
end;
