reserve
  a,b for object, I,J for set, f for Function, R for Relation,
  i,j,n for Nat, m for (Element of NAT),
  S for non empty non void ManySortedSign,
  s,s1,s2 for SortSymbol of S,
  o for OperSymbol of S,
  X for non-empty ManySortedSet of the carrier of S,
  x,x1,x2 for (Element of X.s), x11 for (Element of X.s1),
  T for all_vars_including inheriting_operations free_in_itself
  (X,S)-terms MSAlgebra over S,
  g for Translation of Free(S,X),s1,s2,
  h for Endomorphism of Free(S,X);
reserve
  r,r1,r2 for (Element of T),
  t,t1,t2 for (Element of Free(S,X));

theorem Th01:
  for t,t1 being Tree, p,q being FinSequence of NAT st p in t &
  q in t with-replacement(p,t1) holds (not p is_a_prefix_of q implies q in t) &
  for r being FinSequence of NAT st q = p^r holds r in t1
  proof
    let t,t1 be Tree;
    let p,q be FinSequence of NAT;
    assume Z0: p in t;
    assume Z1: q in t with-replacement(p,t1);
    thus (not p is_a_prefix_of q implies q in t)
    proof
      assume not p is_a_prefix_of q;
      then not ex r being FinSequence of NAT st r in t1 & q = p^r by TREES_1:1;
      hence q in t by Z0,Z1,TREES_1:def 9;
    end;
    let r be FinSequence of NAT;
    assume Z3: q = p^r;
    then p c= q by TREES_1:1;
    then p c< q or p = q & p = p^{} by XBOOLE_0:def 8,FINSEQ_1:34;
    then ex r being FinSequence of NAT st r in t1 & q = p^r
    by Z0,Z1,TREES_1:22,def 9;
    hence r in t1 by Z3,FINSEQ_1:33;
  end;
