reserve x,y,z for set;
reserve f,f1,f2,f3 for FinSequence,
  p,p1,p2,p3 for set,
  i,k for Nat;

theorem Th14:
  (f1^f2)|Seg(len f1 + i) = f1^(f2|Seg i)
proof
A1: dom(f1^(f2|Seg i)) c= Seg(len f1 + i)
  proof
    let x be object;
    assume
A2: x in dom(f1^(f2|Seg i));
    then reconsider j = x as Nat;
    per cases by A2,FINSEQ_1:25;
    suppose
A3:   j in dom f1;
      len f1 <= len f1 + i by NAT_1:11;
      then
A4:   Seg len f1 c= Seg(len f1 + i) by FINSEQ_1:5;
      j in Seg len f1 by A3,FINSEQ_1:def 3;
      hence thesis by A4;
    end;
    suppose
      ex n being Nat st n in dom(f2|Seg i) & j=len f1 + n;
      then consider k be Nat such that
A5:   k in dom(f2|Seg i) and
A6:   j = len f1 + k;
A7:   k <= j by A6,NAT_1:11;
      dom(f2|Seg i) = dom f2 /\ Seg i by RELAT_1:61;
      then k in Seg i by A5,XBOOLE_0:def 4;
      then k <= i by FINSEQ_1:1;
      then
A8:   j <= len f1 + i by A6,XREAL_1:6;
      1 <= k by A5,FINSEQ_3:25;
      then 1 <= j by A7,XXREAL_0:2;
      hence thesis by A8;
    end;
  end;
A9: dom(f1^f2) /\ Seg(len f1 + i) c= dom(f1^(f2|Seg i))
  proof
    let x be object;
    assume
A10: x in dom(f1^f2) /\ Seg(len f1 + i);
    then
A11: x in dom(f1^f2) by XBOOLE_0:def 4;
    reconsider j = x as Nat by A10;
    per cases by A11,FINSEQ_1:25;
    suppose
A12:  j in dom f1;
      dom f1 c= dom(f1^(f2|Seg i)) by FINSEQ_1:26;
      hence thesis by A12;
    end;
    suppose
      ex n being Nat st n in dom f2 & j=len f1 + n;
      then consider k be Nat such that
A13:  k in dom f2 and
A14:  j = len f1 + k;
A15:  1 <= k by A13,FINSEQ_3:25;
A16:  dom(f2|Seg i) = dom f2 /\ Seg i by RELAT_1:61;
      j in Seg(len f1 + i) by A10,XBOOLE_0:def 4;
      then j <= len f1 + i by FINSEQ_1:1;
      then k <= i by A14,XREAL_1:6;
      then k in Seg i by A15;
      then k in dom(f2|Seg i) by A13,A16,XBOOLE_0:def 4;
      hence thesis by A14,FINSEQ_1:28;
    end;
  end;
A17: dom((f1^f2)|Seg(len f1 + i)) = dom(f1^f2) /\ Seg(len f1 + i) by RELAT_1:61
;
A18: now
    let k be Nat;
    assume
A19: k in dom((f1^f2)|Seg(len f1 + i));
    then
A20: 1 <= k by FINSEQ_3:25;
    per cases;
    suppose
      k <= len f1;
      then
A21:  k in dom f1 by A20,FINSEQ_3:25;
      thus ((f1^f2)|Seg(len f1 + i)).k = (f1^f2).k by A19,FUNCT_1:47
        .= f1.k by A21,FINSEQ_1:def 7
        .= (f1^(f2|Seg i)).k by A21,FINSEQ_1:def 7;
    end;
    suppose
A22:  k > len f1;
      then reconsider j = k - len f1 as Element of NAT by INT_1:5;
      j > 0 by A22,XREAL_1:50;
      then
A23:  1 <= j by NAT_1:14;
A24:  k = len f1 + j;
A25:  not k in dom f1 by A22,FINSEQ_3:25;
      k in dom(f1^f2) by A17,A19,XBOOLE_0:def 4;
      then
A26:  ex n being Nat st n in dom f2 & k =len f1 + n by A25,FINSEQ_1:25;
      k in Seg(len f1 + i) by A17,A19,XBOOLE_0:def 4;
      then k <= len f1 + i by FINSEQ_1:1;
      then j <= i by A24,XREAL_1:6;
      then
A27:  j in Seg i by A23;
      dom(f2|Seg i) = (dom f2) /\ Seg i by RELAT_1:61;
      then
A28:  j in dom(f2|Seg i) by A27,A26,XBOOLE_0:def 4;
      thus ((f1^f2)|Seg(len f1 + i)).k = (f1^f2).k by A19,FUNCT_1:47
        .= f2.j by A26,FINSEQ_1:def 7
        .= (f2|Seg i).j by A28,FUNCT_1:47
        .= (f1^(f2|Seg i)).k by A24,A28,FINSEQ_1:def 7;
    end;
  end;
  f1^(f2|Seg i) c= f1^f2 by Th13,RELAT_1:59;
  then dom(f1^(f2|Seg i)) c= dom(f1^f2) by RELAT_1:11;
  then dom(f1^(f2|Seg i)) c= dom(f1^f2) /\ Seg(len f1 + i) by A1,XBOOLE_1:19;
  then dom((f1^f2)|Seg(len f1 + i)) = dom(f1^(f2|Seg i)) by A17,A9;
  hence thesis by A18,FINSEQ_1:13;
end;
