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;
reserve
  w for (Element of Args(o,T)),
  p,p1 for Element of Args(o,Free(S,X));
reserve C for (context of x), C1 for (context of y), C9 for (context of z),
  C11 for (context of x11), C12 for (context of y11), D for context of s,X;
reserve
  S9 for sufficiently_rich non empty non void ManySortedSign,
  s9 for SortSymbol of S9,
  o9 for s9-dependent OperSymbol of S9,
  X9 for non-trivial ManySortedSet of the carrier of S9,
  x9 for (Element of X9.s9);
reserve h1 for x-constant Homomorphism of Free(S,X), T,
  h2 for y-constant Homomorphism of Free(S,Y), Q;
reserve
  s2 for s1-reachable SortSymbol of S,
  g1 for Translation of Free(S,Y),s1,s2,
  g for Translation of Free(S,X),s1,s2;

theorem Th137:
  for t st I = {xi where xi is Element of dom t: ex s,x st t.xi = [x,s]}
  for xi being Node of h.t holds
  xi in (dom t)\I or ex nu being Element of dom t st nu in I &
  ex mu being Node of (h.t)|nu st xi = nu^mu
  proof
    let t;
    defpred P[Element of Free(S,X)] means for I st
    I = {xi where xi is Element of dom $1: ex s,x st $1.xi = [x,s]}
    for xi being Node of h.$1 holds
    xi in (dom $1)\I or ex nu being Element of dom $1 st nu in I &
    ex mu being Node of (h.$1)|nu st xi = nu^mu;
A1: P[x-term]
    proof
      let I; assume
A2:   I = {xi where xi is Node of x-term: ex s1,x11 st (x-term).xi = [x11,s1]};
      let xi being Node of h.(x-term);
      assume xi nin (dom(x-term))\I;
      reconsider nu = {} as Node of x-term by TREES_1:22;
      take nu; (x-term).nu = [x,s];
      hence nu in I by A2;
      reconsider mu = xi as Node of (h.(x-term))|nu by TREES_9:1;
      take mu; thus xi = nu^mu;
    end;
A3: for o,p st for t st t in rng p holds P[t] holds P[o-term p]
    proof
      let o,p;
      assume Z0: for t st t in rng p holds P[t];
      let I; assume
A4:   I = {xi where xi is Node of o-term p: ex s,x st (o-term p).xi = [x,s]};
      let xi being Node of h.(o-term p);
      assume
A5:   xi nin (dom(o-term p))\I;
      the_sort_of (o-term p) = the_result_sort_of o by Th8;
      then
A6:   h.(o-term p) = h.(the_result_sort_of o).(o-term p) by ABBR
      .= h.(the_result_sort_of o).(Den(o,Free(S,X)).p) by MSAFREE4:13
      .= Den(o,Free(S,X)).(h#p) by MSUALG_6:def 2,MSUALG_3:def 7
      .= o-term (h#p) by MSAFREE4:13;
      then per cases by TREES_4:11;
      suppose xi = {};
        then
B0:     (o-term p).xi = [o,the carrier of S] & xi in dom (o-term p)
        by TREES_1:22,TREES_4:def 4;
        xi nin I
        proof
          assume xi in I;
          then consider nu being Node of o-term p such that
B1:       xi = nu & ex s,x st (o-term p).nu = [x,s] by A4;
          consider s,x such that
B2:       (o-term p).xi = [x,s] by B1;
          s in the carrier of S = s by B0,B2,XTUPLE_0:1;
          hence contradiction;
        end;
        hence thesis by B0,A5,XBOOLE_0:def 5;
      end;
      suppose
        ex i being Nat, T being DecoratedTree, q being Node of T st
        i < len (h#p) & T = (h#p).(i+1) & xi = <*i*>^q;
        then consider i being Nat, T being DecoratedTree, q being Node of T
        such that
B3:     i < len (h#p) & T = (h#p).(i+1) & xi = <*i*>^q;
        dom (h#p) = dom the_arity_of o = dom p by MSUALG_6:2;
        then
BA:     len (h#p) = len p by FINSEQ_3:29;
        then 1 <= i+1 <= len p by B3,NAT_1:12,13;
        then
B4:     i+1 in dom p by FINSEQ_3:25;
        then reconsider t = p.(i+1) as Element of Free(S,X) by FUNCT_1:102;
        set II = {xi where xi is Element of dom t: ex s,x st t.xi = [x,s]};
B5:     t = p/.(i+1) by B4,PARTFUN1:def 6;
B6:     T = h.((the_arity_of o)/.(i+1)).t by B3,B4,MSUALG_3:def 6
        .= h.(the_sort_of (p/.(i+1))).t by B4,Th4A
        .= h.t by B5,ABBR;
        then reconsider q as Node of h.t;
        t in rng p by B4,FUNCT_1:def 3;
        then per cases by Z0;
        suppose
BB:       q in (dom t)\II;
          then
B7:       q in dom t & q nin II by XBOOLE_0:def 5;
B8:       xi in dom (o-term p) by B3,BA,BB,TREES_4:11;
          xi nin I
          proof
            assume xi in I;
            then consider nu being Node of o-term p such that
B1:         xi = nu & ex s,x st (o-term p).nu = [x,s] by A4;
            consider s,x such that
B2:         (o-term p).xi = [x,s] by B1;
            t.q = [x,s] by B2,B3,BA,BB,TREES_4:12;
            hence contradiction by B7;
          end;
          hence thesis by A5,B8,XBOOLE_0:def 5;
        end;
        suppose ex nu being Element of dom t st nu in II &
          ex mu being Node of (h.t)|nu st q = nu^mu;
          then consider nu being Node of t, mu being Node of (h.t)|nu such that
C1:       nu in II & q = nu^mu;
          reconsider inu = <*i*>^nu as Node of o-term p by B3,BA,TREES_4:11;
          take inu;
          consider xi1 being Node of t such that
C2:       nu = xi1 & ex s,x st t.xi1 = [x,s] by C1;
          ex s,x st (o-term p).inu = [x,s] by C2,B3,BA,TREES_4:12;
          hence inu in I by A4;
          h.t = (h.(o-term p))|<*i*> &
          inu in dom(o-term p) c= dom(h.(o-term p))
          by B3,A6,B6,Th135,TREES_4:def 4;
          then reconsider mu as Node of (h.(o-term p))|inu by TREES_9:3;
          take mu;
          thus thesis by B3,C1,FINSEQ_1:32;
        end;
      end;
    end;
    P[t] from TermInd(A1,A3);
    hence thesis;
  end;
