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));
reserve
  Y for infinite-yielding ManySortedSet of the carrier of S,
  y,y1 for (Element of Y.s), y11 for (Element of Y.s1),
  Q for all_vars_including inheriting_operations free_in_itself
  (Y,S)-terms MSAlgebra over S,
  q,q1 for (Element of Args(o,Free(S,Y))),
  u,u1,u2 for (Element of Q),
  v,v1,v2 for (Element of Free(S,Y)),
  Z for non-trivial ManySortedSet of the carrier of S,
  z,z1 for (Element of Z.s),
  l,l1 for (Element of Free(S,Z)),
  R for all_vars_including inheriting_operations free_in_itself
  (Z,S)-terms MSAlgebra over S,
  k,k1 for Element of Args(o,Free(S,Z));
reserve c,c1,c2 for set, d,d1 for DecoratedTree;

theorem ThL0:
  for p being non empty Tree-yielding FinSequence holds
  Leaves tree p = {<*i*>^q where i where q is FinSequence of NAT,
  d is Tree: q in Leaves d & i+1 in dom p & d = p.(i+1)}
  proof
    let p be non empty Tree-yielding FinSequence;
    set i0 = the Element of dom p;
    reconsider d0 = p.i0 as Tree by TREES_3:22;
    consider j such that
A0: i0 = 1+j by NAT_1:10,FINSEQ_3:25;
    i0 <= len p by FINSEQ_3:25;
    then
A3: j < len p & <*>NAT in d0 by A0,NAT_1:13,TREES_1:22;
A2: <*j*>^({} qua FinSequence) in tree p by A0,A3,TREES_3:def 15;
    thus Leaves tree p c= {<*i*>^q where i where q is FinSequence of NAT,
    d is Tree: q in Leaves d & i+1 in dom p & d = p.(i+1)}
    proof let a; reconsider x = a as set by TARSKI:1;
      assume
A1:   a in Leaves tree p; then reconsider x = a as Element of tree p;
      per cases by TREES_3:def 15;
      suppose x = {};
        then not {} is_a_proper_prefix_of <*j*> by A1,A2,TREES_1:def 5;
        hence thesis by XBOOLE_1:61;
      end;
      suppose
        ex i st ex q being FinSequence st i < len p & q in p.(i+1) &
        x = <*i*>^q;
        then consider i being Nat, q being FinSequence such that
A2:     i < len p & q in p.(i+1) & x = <*i*>^q;
        1 <= i+1 <= len p by A2,NAT_1:11,13;
        then
AB:     i+1 in dom p & p is Tree-yielding by FINSEQ_3:25;
        then p.(i+1) in rng p & rng p is constituted-Trees
        by FUNCT_1:def 3,TREES_3:def 9;
        then reconsider p1 = p.(i+1) as Tree;
        reconsider q0 = q as Element of p1 by A2;
        now assume
AA:       q0 nin Leaves p1;
          consider r being FinSequence of NAT such that
A3:       r in p1 & q0 is_a_proper_prefix_of r by AA,TREES_1:def 5;
          consider w being FinSequence such that
A5:       r = q^w by A3,XBOOLE_0:def 8,TREES_1:1;
          <*i*>^r = <*i*>^q^w by A5,FINSEQ_1:32;
          then <*i*>^q is_a_prefix_of <*i*>^r & <*i*>^q <> <*i*>^r
          by A3,FINSEQ_1:33,TREES_1:1;
          then x is_a_proper_prefix_of <*i*>^r & <*i*>^r in tree p
          by A2,A3,XBOOLE_0:def 8,TREES_3:def 15;
          hence contradiction by A1,TREES_1:def 5;
        end;
        hence thesis by A2,AB;
      end;
    end;
    let x be object; assume
    x in {<*i*>^q where i where q is FinSequence of NAT,
    d is Tree: q in Leaves d & i+1 in dom p & d = p.(i+1)};
    then consider i being Nat, q being FinSequence of NAT, d being Tree
    such that
B1: x = <*i*>^q & q in Leaves d & i+1 in dom p & d = p.(i+1);
    i+1 <= len p by B1,FINSEQ_3:25;
    then i < len p by NAT_1:13;
    then reconsider r = x as Element of tree p by B1,TREES_3:48;
    assume x nin Leaves tree p;
    then consider q0 being FinSequence of NAT such that
B4: q0 in tree p & r is_a_proper_prefix_of q0 by TREES_1:def 5;
    consider w being FinSequence such that
B6: q0 = <*i*>^q^w by B1,B4,XBOOLE_0:def 8,TREES_1:1;
B7: q0 = <*i*>^(q^w) by B6,FINSEQ_1:32;
    then
B9: q^w is FinSequence of NAT by FINSEQ_1:36;
    q^w in d & q is_a_proper_prefix_of q^w
    by B1,B4,B7,TREES_3:48,TREES_1:49;
    hence contradiction by B1,B9,TREES_1:def 5;
  end;
