 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 Th12:
  ex Y be Subset of NAT st
    Seq((f1^f2) |X) = Seq(f1|X)^Seq(f2|Y) &
    for n st n>0 holds n in Y iff n+len f1 in X/\dom(f1^f2)
proof
  set f12=f1^f2;
  set n1=len f1,n2=len f2;
  set X12=X/\dom f12;
  set X1=X12/\Seg n1,X2=X12\(Seg n1);
  set Y2={i where i is Element of NAT:i+n1 in X2};
  Y2 c=NAT
  proof
   let x be object;
   assume x in Y2;
   then ex i be Element of NAT st i=x & i+n1 in X2;
   hence thesis;
  end;
  then reconsider Y2 as Subset of NAT;
  set Sf2=n1 Shift f2;
  A1: f12=f1\/Sf2 by VALUED_1:49;
  take Y2;
  A2: X12/\dom Sf2 c=X2
  proof
   let x be object;
   assume A3: x in X12/\dom Sf2;
   then x in dom Sf2 by XBOOLE_0:def 4;
   then x in {k+n1 where k is Nat:k in dom f2} by VALUED_1:def 12;
   then consider k be Nat such that
    A4: x=k+n1 and
    A5: k in dom f2;
   1<=k by A5,FINSEQ_3:25;
   then 1+n1<=k+n1 by XREAL_1:6;
   then n1<k+n1 by NAT_1:13;
   then A6: not x in Seg n1 by A4,FINSEQ_1:1;
   x in X12 by A3,XBOOLE_0:def 4;
   hence thesis by A6,XBOOLE_0:def 5;
  end;
  A7: now let i;
   thus i+n1 in X2 implies i in Y2
   proof
    assume A8: i+n1 in X2;
    i in NAT by ORDINAL1:def 12;
    hence thesis by A8;
   end;
   assume i in Y2;
   then ex j be Element of NAT st i=j & j+n1 in X2;
   hence i+n1 in X2;
  end;
  f1|X1 c=f1 & f2|Y2 c=f2 by RELAT_1:59;
  then consider ss be FinSubsequence such that
   A9: ss=(f1|X1)\/(n1 Shift(f2|Y2)) & (Seq(f1|X1))^(Seq(f2|Y2))=Seq ss
    by VALUED_1:64;
  A10: dom f1=Seg n1 by FINSEQ_1:def 3;
  then (dom f12)/\Seg n1=Seg n1 by FINSEQ_1:26,XBOOLE_1:28;
  then A11: f1|X=f1| (X/\((dom f12)/\Seg n1)) by A10,RELAT_1:157
   .=f1|X1 by XBOOLE_1:16;
  X2 c=X12/\dom Sf2
  proof
   let x be object;
   assume A12: x in X2;
   then A13: not x in Seg n1 by XBOOLE_0:def 5;
   A14: x in X12 by A12,XBOOLE_0:def 5;
   then x in dom f12 by XBOOLE_0:def 4;
   then consider k be Nat such that
    A15: k in dom f2 & x=n1+k by A10,A13,FINSEQ_1:25;
   x in {i+n1 where i is Nat:i in dom f2} by A15;
   then x in dom Sf2 by VALUED_1:def 12;
   hence thesis by A14,XBOOLE_0:def 4;
  end;
  then A16: X2=X12/\dom Sf2 by A2;
  f12|X=f12|X12 by RELAT_1:157;
  then f12|X=f12*(id X12) by RELAT_1:65
   .=(f1*(id X12))\/(Sf2*(id X12)) by A1,RELAT_1:32
   .=(f1|X12)\/(Sf2*(id X12)) by RELAT_1:65
   .=(f1|X12)\/(Sf2|X12) by RELAT_1:65
   .=(f1|X12)\/(Sf2|X2) by A16,RELAT_1:157
   .=(f1|X1)\/(Sf2|X2) by A10,RELAT_1:157;
  hence Seq((f1^f2) |X)=Seq(f1|X)^Seq(f2|Y2) by A7,A11,A9,Th11;
  let n;
  assume n>0;
  then n+n1> (0 qua Nat)+n1 by XREAL_1:6;
  then A17: not n+n1 in Seg n1 by FINSEQ_1:1;
  hereby assume n in Y2;
   then n+n1 in X2 by A7;
   hence n+n1 in X12 by XBOOLE_0:def 5;
  end;
  assume n+n1 in X12;
  then n+n1 in X2 by A17,XBOOLE_0:def 5;
  hence n in Y2 by A7;
end;
