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 Th41:
  i in dom A & width A = width DelLine(A,i) implies DelLine(
  block_diagonal(<*A*>^G,a),i) = block_diagonal(<*DelLine(A,i)*>^G,a)
proof
  assume that
A1: i in dom A and
A2: width A= width DelLine(A,i);
A3: i in Seg len A by A1,FINSEQ_1:def 3;
  set da=DelLine(A,i);
  consider m such that
A4: len A = m + 1 and
A5: len da = m by A1,FINSEQ_3:104;
  set bG=block_diagonal(G,a);
  set DA=<*da*>;
  set AA=<*A*>;
  set BG=<*bG*>;
  set bAG=block_diagonal(<*A,bG*>,a);
  set bdAG=block_diagonal(<*da,bG*>,a);
A6: Seg len bAG=dom bAG by FINSEQ_1:def 3;
A7: len bAG=Sum Len (AA^BG) by Def5;
  then
A8: len bAG=len A +len bG by Th16;
  then len bAG>=len A by NAT_1:11;
  then
A9: Seg len A c= Seg len bAG by FINSEQ_1:5;
A10: len bdAG=Sum Len (DA^BG) by Def5;
  then
A11: len bdAG=m+len bG by A5,Th16;
A12: len bAG=(m+len bG) +1 by A4,A8;
A13: len bdAG=len da +len bG by A10,Th16;
A14: now
    m+len bG <=len bAG by A12,NAT_1:11;
    then
A15: Seg (m+len bG) c= Seg len bAG by FINSEQ_1:5;
    reconsider da9=da as Matrix of len da,width da,K by MATRIX_0:51;
    reconsider A9=A as Matrix of len A,width A,K by MATRIX_0:51;
    let j such that
A16: 1<=j and
A17: j<=m+len bG;
A18: j in Seg (m+len bG) by A16,A17;
A19: 1<=1+j by NAT_1:11;
    j+1<=len bAG by A12,A17,XREAL_1:7;
    then
A20: j+1 in Seg len bAG by A19;
    now
      per cases;
      suppose
A21:    j<i;
        i<=len A by A3,FINSEQ_1:1;
        then
A22:    j<len A by A21,XXREAL_0:2;
        then
A23:    j<=m by A4,NAT_1:13;
        then
A24:    j in dom da by A5,A16,FINSEQ_3:25;
A25:    j in dom A by A16,A22,FINSEQ_3:25;
A26:    j in Seg m by A16,A23;
        j in Seg len A by A16,A22;
        then
A27:    Line(A9,j) = A.j by MATRIX_0:52
          .= da9.j by A21,FINSEQ_3:110
          .= Line(da,j) by A5,A26,MATRIX_0:52;
        thus Del(bAG,i).j = bAG.j by A21,FINSEQ_3:110
          .= Line(bAG,j) by A7,A18,A15,MATRIX_0:52
          .= Line(da,j)^(width bG |-> a) by A25,A27,Th23
          .= Line(bdAG,j) by A24,Th23
          .= bdAG.j by A5,A10,A13,A18,MATRIX_0:52;
      end;
      suppose
A28:    j>=i;
        then
A29:    Del(bAG,i).j = bAG.(j+1) by A12,A9,A3,A6,A17,FINSEQ_3:111
          .= Line(bAG,j+1) by A7,A20,MATRIX_0:52;
        now
          per cases;
          suppose
A30:        j+1<=len A;
            then
A31:        j+1 in dom A by A19,FINSEQ_3:25;
A32:        j<=m by A4,A30,XREAL_1:8;
            then
A33:        j in Seg m by A16;
A34:        j in dom da by A5,A16,A32,FINSEQ_3:25;
            j+1 in Seg len A by A19,A30;
            then Line(A9,j+1) = A.(j+1) by MATRIX_0:52
              .= da9.j by A1,A4,A28,A32,FINSEQ_3:111
              .= Line(da,j) by A5,A33,MATRIX_0:52;
            hence Del(bAG,i).j = Line(da,j)^(width bG |-> a) by A29,A31,Th23
              .= Line(bdAG,j) by A34,Th23;
          end;
          suppose
A35:        j+1>len A;
            then reconsider jL=j+1-len A as Element of NAT by NAT_1:21;
            jL<>0 by A35;
            then
A36:        jL>=1 by NAT_1:14;
            jL+len A<=len bG+len A by A8,A12,A17,XREAL_1:7;
            then jL<=len bG by XREAL_1:8;
            then
A37:        jL in dom bG by A36,FINSEQ_3:25;
            thus Del(bAG,i).j = Line(bAG,jL+len A) by A29
              .= (width da|->a)^Line(bG,jL) by A2,A37,Th23
              .= Line(bdAG,jL+len da) by A37,Th23
              .= Line(bdAG,j) by A4,A5;
          end;
        end;
        hence Del(bAG,i).j=bdAG.j by A5,A10,A13,A18,MATRIX_0:52;
      end;
    end;
    hence Del(bAG,i).j=bdAG.j;
  end;
A38: block_diagonal(DA^G,a)=bdAG by Th36;
A39: block_diagonal(AA^G,a)=bAG by Th36;
  len Del(bAG,i)=m+len bG by A12,A9,A3,A6,FINSEQ_3:109;
  hence thesis by A11,A39,A38,A14;
end;
