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 Th135:
  for t
  for h being Endomorphism of Free(S,X) holds dom t c= dom (h.t) &
  for I st
  I = {xi where xi is Element of dom t: ex s,x st t.xi = [x,s]}
  holds t|((dom t) \ I) = (h.t)|((dom t) \ I)
  proof
    let t;
    let h be Endomorphism of Free(S,X);
    defpred P[Element of Free(S,X)] means dom $1 c= dom (h.$1) & for I st
    I = {xi where xi is Element of dom $1: ex s,x st $1.xi = [x,s]}
    holds $1|((dom $1) \ I) = (h.$1)|((dom $1) \ I);
A1: P[x-term]
    proof
      {} in dom (h.(x-term)) by TREES_1:22;
      then {{}} c= dom (h.(x-term));
      hence dom (x-term) c= dom (h.(x-term)) by TREES_1:29;
      let I; assume
A2:   I = {xi where xi is Node of x-term: ex s,x1 st (x-term).xi = [x1,s]};
      {} in dom (x-term) & (x-term).{} = [x,s] by TREES_1:22,TREES_4:3;
      then {} in I by A2;
      then {{}} c= I;
      then dom (x-term) c= I by TREES_1:29;
      then (x-term)|((dom(x-term))\I) = {} &
      (h.(x-term))|((dom(x-term))\I) = {};
      hence thesis;
    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];
      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;
      thus
B3:   dom(o-term p) c= dom(h.(o-term p))
      proof let a;
        assume a in dom(o-term p);
        then per cases by TREES_4:11;
        suppose a = {};
          hence thesis by TREES_1:22;
        end;
        suppose
          ex i being Nat, T being DecoratedTree, r being Node of T st
          i < len p & T = p.(i+1) & a = <*i*>^r;
          then consider i being Nat, T being DecoratedTree, r being Node of T
          such that
A7:       i < len p & T = p.(i+1) & a = <*i*>^r;
          1 <= i+1 <= len p by A7,NAT_1:12,13;
          then
A8:       i+1 in dom p by FINSEQ_3:25;
          then reconsider T as Element of Free(S,X) by A7,FUNCT_1:102;
          T in rng p by A7,A8,FUNCT_1:def 3;
          then dom T c= dom (h.T) by Z0;
          then
A9:       r in dom(h.T);
A10:      (h#p).(i+1) = h.((the_arity_of o)/.(i+1)).T by A7,A8,MSUALG_3:def 6
          .= h.((the_arity_of o)/.(i+1)).(p/.(i+1)) by A7,A8,PARTFUN1:def 6
          .= h.(the_sort_of (p/.(i+1))).(p/.(i+1)) by A8,Th4A
          .= h.(p/.(i+1)) by ABBR
          .= h.T by A7,A8,PARTFUN1:def 6;
          dom (h#p) = dom the_arity_of o = dom p by MSUALG_6:2;
          then len(h#p) = len p by FINSEQ_3:29;
          hence thesis by A7,A9,A10,A6,TREES_4:11;
        end;
      end;
      let I; assume
A4:   I = {xi where xi is Node of o-term p: ex s,x st (o-term p).xi = [x,s]};
B2:   (dom (o-term p))\I c= dom(h.(o-term p)) by B3;
      thus dom((o-term p)|((dom (o-term p))\I))
      = dom((h.(o-term p))|((dom (o-term p))\I)) by B2,RELAT_1:62;
      let q being object; assume
BB:   q in dom((o-term p)|((dom (o-term p))\I));
      reconsider q as Node of o-term p by BB;
B6:   ((o-term p)|((dom (o-term p))\I)).q = (o-term p).q &
      ((h.(o-term p))|((dom (o-term p))\I)).q = h.(o-term p).q
      by BB,FUNCT_1:49;
      per cases by TREES_4:11;
      suppose q = {};
        then (o-term p).q = [o,the carrier of S] = (o-term (h#p)).q
        by TREES_4:def 4;
        hence thesis by A6,B6;
      end;
      suppose
        ex i being Nat, T being DecoratedTree, r being Node of T st
        i < len p & T = p.(i+1) & q = <*i*>^r;
        then consider i being Nat, T being DecoratedTree, r being Node of T
        such that
A7:     i < len p & T = p.(i+1) & q = <*i*>^r;
        1 <= i+1 <= len p by A7,NAT_1:12,13;
        then
A8:     i+1 in dom p by FINSEQ_3:25;
        then reconsider T as Element of Free(S,X) by A7,FUNCT_1:102;
        set II = {xi where xi is Node of T: ex s,x st T.xi = [x,s]};
        T in rng p by A7,A8,FUNCT_1:def 3;
        then
B9:     dom T c= dom (h.T) & T|((dom T)\II) = (h.T)|((dom T)\II) by Z0;
B8:     (o-term p).q = T.r by A7,TREES_4:12;
        r nin II
        proof
          assume r in II;
          then consider xi being Node of T such that
B7:       r = xi & ex s,x st T.xi = [x,s];
          q in I by A4,B8,B7;
          hence contradiction by BB,XBOOLE_0:def 5;
        end;
        then r in (dom T)\II by XBOOLE_0:def 5;
        then
A11:    T.r = (T|((dom T)\II)).r = h.T.r by B9,FUNCT_1:49;
A10:    (h#p).(i+1) = h.((the_arity_of o)/.(i+1)).T by A7,A8,MSUALG_3:def 6
        .= h.((the_arity_of o)/.(i+1)).(p/.(i+1)) by A7,A8,PARTFUN1:def 6
        .= h.(the_sort_of (p/.(i+1))).(p/.(i+1)) by A8,Th4A
        .= h.(p/.(i+1)) by ABBR
        .= h.T by A7,A8,PARTFUN1:def 6;
        dom (h#p) = dom the_arity_of o = dom p by MSUALG_6:2;
        then len(h#p) = len p & r in dom(h.T) by B9,FINSEQ_3:29;
        hence thesis by B6,B8,A6,A7,A10,A11,TREES_4:12;
      end;
    end;
    thus P[t] from TermInd(A1,A3);
  end;
