reserve k,n for Nat,
  x,y,z,y1,y2 for object,X,Y for set,
  f,g for Function;
reserve p,q,r,s,t for XFinSequence;
reserve D for set;

theorem Th37:
  p <> {} implies ex q,x st p=q^<%x%>
proof
  assume p <> {};
  then consider n being Nat such that
A1: len p = n+1 by NAT_1:6;
A2: dom p = Segm(n+1) by A1;
  reconsider n as Element of NAT by ORDINAL1:def 12;
  set q=p| n;
  dom q = len p /\ n & Segm n c= Segm len p by A1,NAT_1:11,39,RELAT_1:61;
  then
A3: dom q = n by XBOOLE_1:28;
A4: for x being object st x in dom p holds p.x = (q^<%p.(len p - 1)%>).x
  proof
    let x be object;
    assume
A5: x in dom p;
    then reconsider k = x as Element of NAT;
A6: now
      assume
A7:   k in n;
      hence p.k=q.k by A3,FUNCT_1:47
        .=(q^<%p.(len p - 1)%>).k by A3,A7,Def3;
    end;
A8: now
      0 in Segm(0+1) by NAT_1:45;
      then
A9:   0 in dom <%p.(len p - 1)%> by Def4;
      assume
A10:   k in {n};
      hence (q^<%p.(len p - 1)%>).k =(q^<%p.(len p - 1)%>).(len q + 0) by A3,
TARSKI:def 1
        .=<%p.(len p - 1)%>.0 by A9,Def3
        .=p.k by A1,A10,TARSKI:def 1;
    end;
    k in Segm n \/ {n} by A5,Th1,A2;
    hence thesis by A6,A8,XBOOLE_0:def 3;
  end;
  take q;
  take p.(len p - 1);
  dom(q^<%p.(len p - 1)%>) = (len q + len <%p.(len p - 1)%>) by Def3
    .= dom p by A1,A3,Th30;
  hence q^<%p.(len p - 1)%>=p by A4;
end;
