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;

theorem Th66:
  (canonical_homomorphism T)**Hom(Free(S,X),x,x1) =
  Hom(T,x,x1)**canonical_homomorphism T
  proof
    set H = canonical_homomorphism T;
    set h = Hom(T,x,x1);
    set g = Hom(Free(S,X),x,x1);
    defpred P[Element of Free(S,X)] means (H**g).$1 = (h**H).$1;
A1: for s,x holds P[x-term]
    proof
      let s1; let a be Element of X.s1;
      set r = a-term;
      the_sort_of r = s1 by SORT;
      then
B1:   (H**g).r = (H**g).s1.r & (h**H).r = (h**H).s1.r & H.r = H.s1.r by ABBR;
B2:   (H**g).s1 = (H.s1)*(g.s1) & (h**H).s1 = (h.s1)*(H.s1) by MSUALG_3:2;
B3:   (H**g).r = H.s1.(g.s1.r) & (h**H).r = h.s1.(H.s1.r) by B1,B2,FUNCT_2:15;
      per cases;
      suppose
C1:     s = s1 & a = x;
        then g.s1.r = x1-term & h.s1.r = x1-term by HOM;
        hence thesis by C1,B3;
      end;
      suppose
C2:     s = s1 & a = x1;
        then g.s1.r = x-term & h.s1.r = x-term by HOM;
        hence thesis by C2,B3;
      end;
      suppose
        s <> s1 or a <> x & a <> x1;
        then g.s1.r = r & h.s1.r = r by HOM;
        hence thesis by B3;
      end;
    end;
A2: for o being OperSymbol of S, p being Element of Args(o,Free(S,X))
    st for t being Element of Free(S,X) st t in rng p holds P[t]
    holds P[o-term p]
    proof
      let o be OperSymbol of S;
      let p be Element of Args(o,Free(S,X));
      assume Z0: for t being Element of Free(S,X) st t in rng p holds P[t];
A4:   Den(o,Free(S,X)).p = o-term p by MSAFREE4:13;
      set q = o-term p;
      set r = the_sort_of q;
A5:   r = the_result_sort_of o by Th8;
A10:  g is_homomorphism Free(S,X),Free(S,X) & h is_homomorphism T,T &
      H is_homomorphism Free(S,X),T by MSUALG_6:def 2,MSAFREE4:def 10;
A8:   (H**g)#p = (h**H)#p
      proof
A9:     dom ((H**g)#p) = dom the_arity_of o = dom ((h**H)#p) by MSUALG_3:6;
        hence len ((H**g)#p) = len ((h**H)#p) by FINSEQ_3:29;
        let i be Nat; assume
C0:     1 <= i <= len ((H**g)#p);
        then
C1:     i in dom ((H**g)#p) by FINSEQ_3:25;
C3:     dom p = dom the_arity_of o by MSUALG_6:2;
        then
C5:     p/.i = p.i in (the Sorts of Free(S,X)).((the_arity_of o)/.i)
        by C0,A9,FINSEQ_3:25,PARTFUN1:def 6,MSUALG_6:2;
        then
C4:     the_sort_of (p/.i) = (the_arity_of o)/.i & p.i in rng p
        by A9,C1,C3,SORT,FUNCT_1:def 3;
        thus ((H**g)#p).i = ((H**g).((the_arity_of o)/.i)).(p/.i)
        by C0,C3,C5,A9,FINSEQ_3:25,MSUALG_3:def 6
        .= (H**g).(p/.i) by C4,ABBR
        .= (h**H).(p/.i) by Z0,C4,C5
        .= ((h**H).((the_arity_of o)/.i)).(p/.i) by C4,ABBR
        .= ((h**H)#p).i by C0,C3,C5,A9,FINSEQ_3:25,MSUALG_3:def 6;
      end;
      thus (H**g).q = (H**g).r.q by ABBR
      .= Den(o,T).((h**H)#p) by A8,A4,A5,A10,MSUALG_3:10,def 7
      .= (h**H).r.q by A4,A5,A10,MSUALG_3:10,def 7
      .= (h**H).q by ABBR;
    end;
    let s;
    thus (H**g).s = (h**H).s
    proof
      let t be Element of (the Sorts of Free(S,X)).s;
A3:   P[t] from TermInd(A1,A2);
      the_sort_of t = s by SORT;
      then (H**g).t = (H**g).s.t & (h**H).t = (h**H).s.t by ABBR;
      hence thesis by A3;
    end;
  end;
