 reserve X,Y for set,
         n,m,k,i for Nat,
         r for Real,
         R for Element of F_Real,
         K for Field,
         f,f1,f2,g1,g2 for FinSequence,
         rf,rf1,rf2 for real-valued FinSequence,
         cf,cf1,cf2 for complex-valued FinSequence,
         F for Function;

theorem Th7:
  for P be Permutation of dom f st f1 = f*P
    ex Q be Permutation of dom(f-X) st f1-X = (f-X)*Q
proof
  let P be Permutation of dom f such that
   A1: f1=f*P;
  reconsider p=P as one-to-one Function;
  A2: rng P=dom f by FUNCT_2:def 3;
  then A3: dom(p")=dom f by FUNCT_1:33;
  A4: P.:(f1"X)=P.:(P"(f"X)) by A1,RELAT_1:146
   .=f"X by A2,FUNCT_1:77,RELAT_1:132;
  A5: dom P=dom f by FUNCT_2:52;
  then A6: dom f1=dom f by A1,A2,RELAT_1:27;
  set DfX=(dom f1)\f1"X;
  set DX=(dom f)\f"X;
  A7: card DX=card(dom f)-card(f"X) by CARD_2:44,RELAT_1:132;
  A9: dom Sgm DX=Seg card DX by FINSEQ_3:40;
  A10: p"(f"X)=(p").:(f"X) by FUNCT_1:85;
  f1"X=P"(f"X) by A1,RELAT_1:146;
  then A11: f"X,f1"X are_equipotent by A3,A10,CARD_1:33,RELAT_1:132;
  A13: rng(P*Sgm DfX)=P.:(rng Sgm DfX) by RELAT_1:127
   .=P.:DfX by FINSEQ_1:def 14
   .=(P.:(dom P))\P.:(f1"X) by A5,A6,FUNCT_1:64
   .=DX by A4,A2,RELAT_1:113;
  reconsider SDX=Sgm DX as one-to-one Function by FINSEQ_3:92;
  A14: dom(SDX")=rng SDX by FUNCT_1:33;
  card(dom f)=len f by CARD_1:62;
  then A15: dom(f-X)=dom SDX by A7,A9,FINSEQ_3:62;
  card DfX=card(dom f1)-card(f1"X) by CARD_2:44,RELAT_1:132;
  then card DX=card DfX by A11,A6,A7,CARD_1:5;
  then A16: dom SDX=dom Sgm DfX by A9,FINSEQ_3:40;
  A17: rng Sgm DX=DX by FINSEQ_1:def 14;
  rng(SDX")=dom SDX by FUNCT_1:33;
  then A18: rng((SDX")*(P*Sgm DfX))=dom SDX by A17,A14,A13,RELAT_1:28;
  rng Sgm DfX=DfX by FINSEQ_1:def 14;
  then dom(P*Sgm DfX)=dom Sgm DfX by A5,A6,RELAT_1:27,XBOOLE_1:36;
  then dom((SDX")*(P*Sgm DfX))=dom Sgm DfX by A17,A14,A13,RELAT_1:27;
  then reconsider Q=(SDX")*(P*Sgm DfX) as Function of dom(f-X),dom(f-X)
    by A18,A15,A16,FUNCT_2:1;
  A19: Q is onto by A18,A15,FUNCT_2:def 3;
  Sgm DfX is one-to-one by FINSEQ_3:92;
  then reconsider Q as Permutation of dom(f-X) by A19;
  SDX*(SDX")=id DX by A17,FUNCT_1:39;
  then A20: SDX*Q=(id DX)*(P*Sgm DfX) by RELAT_1:36
   .=P*Sgm DfX by A13,RELAT_1:53;
  (f-X)*Q=f*SDX*Q by FINSEQ_3:def 1
   .=f*(P*Sgm DfX) by A20,RELAT_1:36
   .=f1*Sgm DfX by A1,RELAT_1:36
   .=f1-X by FINSEQ_3:def 1;
  hence thesis;
end;
