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 Lem8B:
  for p,q,r being FinSequence st q is_a_prefix_of p^r holds
  q is_a_prefix_of p or p is_a_prefix_of q
  proof
    let p,q,r be FinSequence;
    given i such that
Z0: q = (p^r)|Seg i;
    per cases;
    suppose len p <= i;
      then consider j such that
A1:   i = (len p)+j by NAT_1:10;
      q = p^(r|Seg j) by Z0,A1,FINSEQ_6:14;
      hence thesis by TREES_1:1;
    end;
    suppose len p >= i;
      then q = p|Seg i by Z0,LemP;
      hence thesis by TREES_1:def 1;
    end;
  end;
