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;
reserve S,S1,S2 for FinSequence_of_Square-Matrix of D,
  R,R1,R2 for FinSequence_of_Square-Matrix of K;
reserve N for (Matrix of n,K),
  N1 for (Matrix of m,K);
reserve p,p1 for FinSequence of K;

theorem Th71:
  len A1 = len B1 & len A2 = len B2 & width A1 = width B1 & width
A2 = width B2 implies block_diagonal(<*A1,A2*>,a1) + block_diagonal(<*B1,B2*>,
  a2) = block_diagonal(<*A1,A2*>(+)<*B1,B2*>,a1+a2)
proof
  assume that
A1: len A1 = len B1 and
A2: len A2 = len B2 and
A3: width A1 = width B1 and
A4: width A2 = width B2;
  set b12=<*B1,B2*>;
  set a12=<*A1,A2*>;
  set AB2=A2+B2;
  set AB1=A1+B1;
  set ab=a12(+)b12;
  set bA=block_diagonal(a12,a1);
  set bB=block_diagonal(b12,a2);
  set bAB=block_diagonal(ab,a1+a2);
A5: len (bA+bB)=len bA by MATRIX_3:def 3;
  width (bA+bB)=width bA by MATRIX_3:def 3;
  then reconsider bAbB=bA+bB as Matrix of len bA,width bA,K by A5,MATRIX_0:51;
A6: len AB1=len A1 by MATRIX_3:def 3;
A7: len bA=Sum Len a12 by Def5;
A8: Sum Len a12=len A1+len A2 by Th16;
A9: len AB2=len A2 by MATRIX_3:def 3;
A10: Sum Width b12=width B1+width B2 by Th20;
A11: len bAB=Sum Len ab by Def5;
A12: width bB=Sum Width b12 by Def5;
A13: width bA=Sum Width a12 by Def5;
A14: width AB2=width A2 by MATRIX_3:def 3;
A15: width AB1=width A1 by MATRIX_3:def 3;
A16: Len ab=Len a12 by Th66;
A17: ab = <*AB1,AB2*> by Th70;
  now
A18: dom bA =Seg len bA by FINSEQ_1:def 3;
    let i such that
A19: 1<= i and
A20: i<=len bAB;
A21: i in Seg len bAB by A19,A20;
    then
A22: bAB.i=Line(block_diagonal(<*AB1,AB2*>,a1+a2),i) by A17,A11,MATRIX_0:52;
A23: bAbB.i=Line(bA+bB,i) by A16,A7,A11,A21,MATRIX_0:52;
A24: dom (A1^A2)=Seg len bAB by A8,A16,A11,FINSEQ_1:def 7;
    now
      per cases by A21,A24,FINSEQ_1:25;
      suppose
A25:    i in dom A1;
A26:    len Line(B1,i)=width B1 by CARD_1:def 7;
A27:    dom A1=dom B1 by A1,FINSEQ_3:29;
A28:    len Line(A1,i)=width A1 by CARD_1:def 7;
        dom A1=dom AB1 by A6,FINSEQ_3:29;
        hence bAB.i = Line(AB1,i)^(width AB2|->(a1+a2)) by A22,A25,Th23
          .= (Line(A1,i)+Line(B1,i))^(width AB2|->(a1+a2)) by A3,A25,Lm8
          .= (Line(A1,i)+Line(B1,i))^ ((width AB2|->a1)+(width AB2|->a2)) by
FVSUM_1:20
          .= (Line(A1,i)^(width A2|->a1))+ (Line(B1,i)^(width B2|->a2)) by A3
,A4,A14,A28,A26,Th1
          .= Line(bA,i)+(Line(B1,i)^(width B2|->a2)) by A25,Th23
          .= Line(bA,i)+Line(bB,i) by A25,A27,Th23
          .= bAbB.i by A3,A4,A10,A16,A7,A13,A12,A11,A21,A18,A23,Lm8,Th20;
      end;
      suppose
A29:    ex n st n in dom A2 & i=len A1+n;
A30:    len (width AB1|->a1)=width AB1 by CARD_1:def 7;
A31:    dom A2=dom B2 by A2,FINSEQ_3:29;
A32:    len (width AB1|->a2)=width AB1 by CARD_1:def 7;
        consider n such that
A33:    n in dom A2 and
A34:    i=len A1+n by A29;
        dom A2=dom AB2 by A9,FINSEQ_3:29;
        hence bAB.i = (width AB1|->(a1+a2))^Line(AB2,n) by A6,A22,A33,A34,Th23
          .= (width AB1|->(a1+a2))^(Line(A2,n)+Line(B2,n)) by A4,A33,Lm8
          .= ((width AB1|->a1)+(width AB1|->a2))^ (Line(A2,n)+Line(B2,n)) by
FVSUM_1:20
          .= ((width AB1|->a1)^Line(A2,n))+ ((width AB1|->a2)^Line(B2,n)) by
A30,A32,Th1
          .=Line(bA,i)+((width B1|->a2)^Line(B2,n)) by A3,A15,A33,A34,Th23
          .=Line(bA,i)+Line(bB,i) by A1,A33,A34,A31,Th23
          .=bAbB.i by A3,A4,A10,A16,A7,A13,A12,A11,A21,A18,A23,Lm8,Th20;
      end;
    end;
    hence bAB.i=(bA+bB).i;
  end;
  hence thesis by A16,A7,A11,A5;
end;
