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 Th57:
  (P = {} iff Q={}) & [:P,Q:] c= Indices Segm(A,P1,Q1) implies ex
P2,Q2 st P2 c= P1 & Q2 c= Q1 & P2 = Sgm P1.:P & Q2=Sgm Q1.:Q & card P2=card P &
  card Q2=card Q & Segm(Segm(A,P1,Q1),P,Q) = Segm(A,P2,Q2)
proof
  assume that
A1: P = {} iff Q={} and
A2: [:P,Q:] c= Indices Segm(A,P1,Q1);
  set S=Segm(A,P1,Q1);
A3: now
    per cases;
    suppose
      P={};
      hence P c= Seg card P1 & Q c= Seg card Q1 by A1;
    end;
    suppose
A4:   P<>{};
      then
A5:   Q c= Seg width S by A2,ZFMISC_1:114;
A6:   len S=card P1 by MATRIX_0:def 2;
A7:   Indices S=[:Seg len S,Seg width S:] by FINSEQ_1:def 3;
      then len S<>0 by A1,A2,A4;
      hence P c= Seg card P1 & Q c= Seg card Q1 by A1,A2,A7,A5,A6,Th1,
ZFMISC_1:114;
    end;
  end;
  set SQ=Sgm Q1;
  set SP=Sgm P1;
A9: SP is one-to-one by FINSEQ_3:92;
A11: SQ is one-to-one by FINSEQ_3:92;
A12: rng SQ=Q1 by FINSEQ_1:def 14;
  then
A13: SQ.:Q c= Q1 by RELAT_1:111;
  then
A14: not 0 in SQ.:Q;
  rng SP=P1 by FINSEQ_1:def 14;
  then
A15: SP.:P c= P1 by RELAT_1:111;
  then not 0 in SP.:P;
  then reconsider
  P2=SP.:P,Q2=SQ.:Q as without_zero finite Subset of NAT by A15,A13,A14,
MEASURE6:def 2,XBOOLE_1:1;
A16: dom SQ=Seg card Q1 by FINSEQ_3:40;
  then
A17: SQ " Q2 = Q by A3,A11,FUNCT_1:94;
A18: dom SP=Seg card P1 by FINSEQ_3:40;
  then P,P2 are_equipotent by A3,A9,CARD_1:33;
  then
A19: card P=card P2 by CARD_1:5;
  Q,Q2 are_equipotent by A3,A16,A11,CARD_1:33;
  then
A20: card Q=card Q2 by CARD_1:5;
  SP " P2 = P by A3,A18,A9,FUNCT_1:94;
  then Segm(Segm(A,P1,Q1),P,Q)=Segm(A,P2,Q2) by A15,A13,A17,Th56;
  hence thesis by A12,A15,A19,A20,RELAT_1:111;
end;
