reserve
  a for natural Number,
  k,l,m,n,k1,b,c,i for Nat,
  x,y,z,y1,y2 for object,
  X,Y for set,
  f,g for Function;
reserve p,q,r,s,t for FinSequence;
reserve D for set;

theorem Th46:
  p <> {} implies ex q,x st p = q^<*x*>
proof
  assume p <> {};
  then consider n be Nat such that
A1: len p = n + 1 by NAT_1:6;
  reconsider n as Element of NAT by ORDINAL1:def 12;
  reconsider q=p|Seg n as FinSequence by Th15;
  take q;
  take p.(len p);
A2: dom q = dom p /\ Seg n by RELAT_1:61
    .= Seg len p /\ Seg n by Def3;
  Seg n c= Seg len p by Th5,A1,NAT_1:11;
  then
A3: dom q = Seg n by A2,XBOOLE_1:28;
A4: dom(q^<*p.(len p)*>) = Seg len (q^<*p.(len p)*>) by Def3
    .= Seg(len q + len <*p.(len p)*>) by Th22
    .= Seg(len q + 1) by Th39
    .= Seg len p by A1,A3,Def3
    .= dom p by Def3;
  for x being object st x in dom p holds p.x = (q^<*p.(len p)*>).x
  proof
    let x be object;
    assume
A5: x in dom p;
    then reconsider k = x as Element of NAT;
    k in Seg(n+1) by A1,A5,Def3;
    then
A6: k in Seg n \/ {n+1} by Th9;
A7: now
      assume
A8:   k in Seg n;
      hence p.k=q.k by A3,FUNCT_1:47
        .=(q^<*p.(len p)*>).k by A3,A8,Def7;
    end;
    now
      assume
A9:   k in {n+1};
      1 in Seg 1;
      then
A10:  1 in dom <*p.(len p)*> by Def8;
      thus (q^<*p.(len p)*>).k =(q^<*p.(len p)*>).(n+1) by A9,TARSKI:def 1
        .=(q^<*p.(len p)*>).(len q + 1) by A3,Def3
        .=<*p.(len p)*>.1 by A10,Def7
        .=p.k by A1,A9,TARSKI:def 1;
    end;
    hence thesis by A6,A7,XBOOLE_0:def 3;
  end;
  hence q^<*p.(len p)*>=p by A4;
end;
