theorem
  T is struct-invariant implies for r being Element of T,s holds
  Hom(T,x1,x2).s.r = Hom(Free(S,X),x1,x2).s.r
  proof assume
AA: for o for p being Element of Args(o,T) st Den(o,T).p = Den(o,Free(S,X)).p
    for s,x1,x2 holds
    Den(o,T).(Hom(T,x1,x2)#p) = Den(o,Free(S,X)).(Hom(T,x1,x2)#p);
    set h = Hom(T,x1,x2);
    set g = Hom(Free(S,X),x1,x2);
    defpred P[Element of T] means
    h.(the_sort_of $1).$1 = g.(the_sort_of $1).$1;
A1: for s,x,r st r = x-term holds P[r]
    proof let s1,x11,r; assume
A2:   r = x11-term;
      then
A3:   the_sort_of r = the_sort_of @r = s1 by SORT,Lem00;
      per cases;
      suppose s = s1 & x11 = x1;
        then h.s1.r = x2-term & g.s1.r = x2-term by A2,HOM;
        hence thesis by A3;
      end;
      suppose s = s1 & x11 = x2;
        then h.s1.r = x1-term & g.s1.r = x1-term by A2,HOM;
        hence thesis by A3;
      end;
      suppose s <> s1 or x11 <> x1 & x11 <> x2;
        then h.s1.r = r & g.s1.r = r by A2,HOM;
        hence thesis by A3;
      end;
    end;
A4: for o,p,r st r = o-term p &
    for t being Element of T st t in rng p holds P[t]
    holds P[r]
    proof
      let o,p,r;
      assume Z0: r = o-term p;
      assume Z1: for t being Element of T st t in rng p holds P[t];
A6:   r = Den(o,Free(S,X)).p by Z0,MSAFREE4:13;
A7:   r in (the Sorts of T).the_sort_of r &
      the_sort_of r = the_sort_of @r = the_result_sort_of o
      by Z0,SORT,Lem00;
      then reconsider q = p as Element of Args(o,T) by A6,MSAFREE4:def 8;
      r = Den(o,T).q by A6,A7,MSAFREE4:def 8;
      then
A8:   Den(o,T).(Hom(T,x1,x2)#q) = Den(o,Free(S,X)).(Hom(T,x1,x2)#q)
      by AA,A6;
      g#p = h#q
      proof
B1:     dom (g#p) = dom the_arity_of o = dom (h#q) by MSUALG_3:6;
        hence len (g#p) = len (h#q) by FINSEQ_3:29;
        let i be Nat; assume
C0:     1 <= i <= len(g#p);
        then
C1:     i in dom(g#p) by FINSEQ_3:25;
C3:     dom p = dom the_arity_of o by MSUALG_6:2;
        then
C5:     q/.i = q.i in (the Sorts of T).((the_arity_of o)/.i)
        by C0,B1,PARTFUN1:def 6,FINSEQ_3:25,MSUALG_6:2;
        then
C4:     the_sort_of (q/.i) = (the_arity_of o)/.i & p.i in rng p
        by B1,C1,C3,SORT,FUNCT_1:def 3;
        thus ((g)#p).i = ((g).((the_arity_of o)/.i)).(q/.i)
        by C0,C3,C5,B1,FINSEQ_3:25,MSUALG_3:def 6
        .= ((h).((the_arity_of o)/.i)).(q/.i) by C4,C5,Z1
        .= ((h)#q).i by C0,C3,C5,B1,FINSEQ_3:25,MSUALG_3:def 6;
      end;
      then g.(the_result_sort_of o).r = Den(o,Free(S,X)).(h#q)
      by A6,MSUALG_6:def 2,MSUALG_3:def 7
      .= h.(the_result_sort_of o).(Den(o,T).q)
      by A8,MSUALG_6:def 2,MSUALG_3:def 7
      .= h.(the_result_sort_of o).r by A6,A7,MSAFREE4:def 8;
      hence P[r] by A7;
    end;
    let r be Element of T,s;
A9: P[r] from TermAlgebraInd(A1,A4);
    the_sort_of r = s by SORT;
    hence thesis by A9;
  end;
