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);

theorem
  for t being Element of Free(S,Z) holds
  the_sort_of t = s implies
  (canonical_homomorphism R).(C9-sub(t))
  = (canonical_homomorphism R).(C9-sub @((canonical_homomorphism R).t))
  proof let t be Element of Free(S,Z); assume
A1: the_sort_of t = s;
    set H = canonical_homomorphism R;
    defpred P[context of z] means
    H.($1-sub(t)) = H.($1-sub @(H.t));
B1: the_sort_of @(H.t) = the_sort_of (H.t) by Lem00
    .= the_sort_of t by Lem0;
B3: the_sort_of ((z-term)-sub @(H.t)) = the_sort_of (z-term) by SORT
    .= s by SORT;
A2: P[z-term]
    proof
B5:   dom(H**H) = (dom H)/\dom H = dom H = the carrier of S
      by PARTFUN1:def 2,PBOOLE:def 19;
B6:   t in (the Sorts of Free(S,Z)).s & (the Sorts of R).s <> {} &
      H.s is Function of (the Sorts of Free(S,Z)).s, (the Sorts of R).s
      by A1,SORT;
B4:   (z-term)-sub t = t & (z-term)-sub @(H.t) = H.t = H.s.t
      by A1,B1,Th41,ABBR;
      hence H.((z-term)-sub t) = (H**H).s.t by MSAFREE4:48
      .= ((H.s)*(H.s)).t by B5,PBOOLE:def 19
      .= (H.s).((z-term)-sub @(H.t)) by B4,B6,FUNCT_2:15
      .= H.((z-term)-sub @(H.t)) by B3,ABBR;
    end;
A3: now
      let o be OperSymbol of S, p be Element of Args(o,Free(S,Z));
      assume
A4:   p is z-context_including;
      assume
A5:   P[z-context_in p];
      let C be context of z such that
A6:   C = o-term p;
C2:   the_sort_of ((z-context_in p)-sub t) =
      the_sort_of (z-context_in p) = (the_arity_of o).(z-context_pos_in p)
      by A4,Th46,SORT;
      then reconsider w = p+*(z-context_pos_in p,(z-context_in p)-sub t) as
      Element of Args(o,Free(S,Z)) by A4,Th42;
      Args(o,R) c= Args(o, Free(S,Z)) by MSAFREE4:41;
      then reconsider q = H#w, r = H#p as Element of Args(o,Free(S,Z));
C1:   the_sort_of @(H.t) = the_sort_of (H.t) by Lem00 .= s by A1,Lem0;
C3:   the_sort_of ((z-context_in p)-sub @(H.t))
      = the_sort_of (z-context_in p) by SORT;
      reconsider m = p+*(z-context_pos_in p, (z-context_in p)-sub @(H.t)) as
      Element of Args(o,Free(S,Z)) by A4,C2,C3,Th42;
A9:   q = r+*(z-context_pos_in p,H.((z-context_in p)-sub @(H.t)))
      by A5,A4,Th71,Th47
      .= H#m by A4,Th71,Th47;
      C-sub t = o-term w by A1,A4,A6,Th43;
      then
      H.(C-sub t) = H.(the_sort_of (o-term w)).(o-term w) by ABBR
      .= H.(the_result_sort_of o).(o-term w) by Th8
      .= H.(the_result_sort_of o).(Den(o,Free(S,Z)).w) by MSAFREE4:13
      .= Den(o,R).(H#w) by MSAFREE4:def 10,MSUALG_3:def 7
      .= H.(the_result_sort_of o).(Den(o,Free(S,Z)).m)
      by A9,MSAFREE4:def 10,MSUALG_3:def 7
      .= H.(the_result_sort_of o).(o-term m) by MSAFREE4:13
      .= H.(the_sort_of (o-term m)).(o-term m) by Th8
      .= H.(o-term m) by ABBR
      .= H.(C-sub @(H.t)) by C1,A4,A6,Th43;
      hence P[C];
    end;
    thus P[C9] from ContextInd(A2,A3);
  end;
