reserve
  X,x,y,z for set,
  k,n,m for Nat ,
  f for Function,
  p,q,r for FinSequence of NAT;
reserve p1,p2,p3 for FinSequence;
reserve T,T1 for Tree;

theorem Th20:
  for r being FinSequence st q^r in T holds q in T
proof
  let r be FinSequence;
  assume
A1: q^r in T;
  then reconsider p = q^r as FinSequence of NAT by Th18;
  reconsider s = p|Seg len q as FinSequence of NAT by FINSEQ_1:18;
 len p = len q + len r by FINSEQ_1:22;
then  len q <= len p by NAT_1:11;
then A2: len s = len q by FINSEQ_1:17;
 now
    let n be Nat;
    assume 1 <= n & n <= len q;
then A3: n in Seg len q by FINSEQ_1:1;
 Seg len q = dom q by FINSEQ_1:def 3;
then  p.n = q.n by A3,FINSEQ_1:def 7;
    hence q.n = s.n by A3,FUNCT_1:49;
  end;
then  q = s by A2,FINSEQ_1:14;
then A4: q is_a_prefix_of p;
 now
    assume q <> p;
then  q is_a_proper_prefix_of p by A4;
then A5: q in ProperPrefixes p by Def2;
 ProperPrefixes p c= T by A1,Def3;
    hence thesis by A5;
  end;
  hence thesis by A1;
end;
