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;

theorem Th99:
  for M be diagonal Matrix of K for NonZero1 be set st NonZero1 = {i
where i is Element of NAT:[i,i] in Indices M & M*(i,i)<>0.K} for P,Q st [:P,Q:]
c= Indices M & card P = card Q & Det EqSegm(M,P,Q)<>0.K holds P c= NonZero1 & Q
  c= NonZero1
proof
  let M be diagonal Matrix of K;
  let NonZero1 be set such that
A1: NonZero1={i where i is Element of NAT:[i,i] in Indices M&M*(i,i)<>0.K };
  let P,Q such that
A2: [:P,Q:] c= Indices M and
A3: card P = card Q and
A4: Det EqSegm(M,P,Q)<>0.K;
  set S=Segm(M,P,Q);
  set SQ=Sgm Q;
  set SP=Sgm P;
  set ES=EqSegm(M,P,Q);
A5: Indices S=[:Seg len S,Seg width S:] by FINSEQ_1:def 3;
A6: ES=S by A3,Def3;
  thus P c= NonZero1
  proof
    assume not P c= NonZero1;
    then consider x being object such that
A7: x in P and
A8: not x in NonZero1;
A10: rng SP=P by FINSEQ_1:def 14;
    then consider y being object such that
A11: y in dom SP and
A12: SP.y=x by A7,FUNCT_1:def 3;
    reconsider x,y as Element of NAT by A7,A11;
    set L=Line(S,y);
A13: dom SP=Seg card P by FINSEQ_3:40;
A14: rng SQ=Q by FINSEQ_1:def 14;
A15: now
      let i such that
A16:  1<=i and
A17:  i<=width S;
A18:  i in Seg width S by A16,A17;
      then
A19:  L.i=S*(y,i) by MATRIX_0:def 7;
      y in Seg len S by A3,A13,A11,MATRIX_0:24;
      then
A20:  [y,i] in Indices S by A5,A18,ZFMISC_1:87;
      then
A21:  S*(y,i)=M*(x,SQ.i) by A12,Def1;
A22:  0.K*0.K=0.K;
A23:  SQ.i<>x or SQ.i=x;
      [x,SQ.i] in Indices M by A2,A10,A14,A12,A20,Th17;
      then L.i=0.K by A1,A8,A21,A19,A23,MATRIX_1:def 6;
      hence L.i=(0.K*L).i by A18,A22,FVSUM_1:51;
    end;
A24: len L=width S by MATRIX_0:def 7;
    len L=len (0.K* L) by MATRIXR1:16;
    then Line(S,y) = 0.K*Line(S,y) by A24,A15;
    then
A25: Det(RLine(ES,y,Line(ES,y))) = 0.K*Det(ES) by A6,A13,A11,MATRIX11:35;
    RLine(ES,y,Line(ES,y))=ES by MATRIX11:30;
    hence thesis by A4,A25;
  end;
A26: dom S=Seg len S by FINSEQ_1:def 3;
A27: len S=card P by A3,MATRIX_0:24;
A28: width S=card P by A3,MATRIX_0:24;
  thus Q c= NonZero1
  proof
A30: dom SQ=Seg card Q by FINSEQ_3:40;
    assume not Q c= NonZero1;
    then consider x being object such that
A31: x in Q and
A32: not x in NonZero1;
A33: rng SQ=Q by FINSEQ_1:def 14;
    then consider y being object such that
A34: y in dom SQ and
A35: SQ.y=x by A31,FUNCT_1:def 3;
    reconsider x,y as Element of NAT by A31,A34;
    set C=Col(ES,y);
A36: rng SP=P by FINSEQ_1:def 14;
    now
      let k be Element of NAT such that
A37:  k in Seg card P;
A38:  S*(k,y)=C.k by A6,A27,A26,A37,MATRIX_0:def 8;
A39:  [k,y] in Indices S by A3,A5,A27,A28,A30,A34,A37,ZFMISC_1:87;
      then
A40:  S*(k,y)=M*(SP.k,x) by A35,Def1;
A41:  SP.k<>x or SP.k=x;
      [SP.k,x] in Indices M by A2,A36,A33,A35,A39,Th17;
      hence C.k=0.K by A1,A32,A40,A38,A41,MATRIX_1:def 6;
    end;
    hence thesis by A3,A4,A30,A34,MATRIX_9:53;
  end;
end;
