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 Th90:
  for R being NF-var terminating with_UN_property invariant stable
  ManySortedRelation of Free(S,X)
  for t holds R.the_sort_of t reduces t, (canonical_homomorphism NFAlgebra R).t
  proof
    let R be NF-var terminating with_UN_property invariant stable
    ManySortedRelation of Free(S,X);
    let t;
    set T = NFAlgebra R;
    set H = canonical_homomorphism T;
    defpred P[Element of Free(S,X)] means R.the_sort_of $1 reduces $1,H.$1;
A1: for s,x holds P[x-term] by REWRITE1:12;
A2: 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];
A3:   o-term p = Den(o,Free(S,X)).p by MSAFREE4:13;
A4:   the_sort_of (o-term p) = the_result_sort_of o by Th8;
      then H.(o-term p) = H.(the_result_sort_of o).(o-term p) by ABBR
      .= Den(o,T).(H#p) by A3,MSUALG_3:def 7,MSAFREE4:def 10
      .= nf (Den(o,Free(S,X)).(H#p), R.the_result_sort_of o)
      by MSAFREE4:def 20;
      then
A5:   H.(o-term p) is_a_normal_form_of Den(o,Free(S,X)).(H#p),
      R.the_result_sort_of o by REWRITE1:54;
      per cases;
      suppose len p = 0;
        then dom p = Seg 0 = {} by FINSEQ_1:def 3;
        then dom (H#p) = dom the_arity_of o = {} = dom p by MSUALG_6:2;
        then H#p = {} = p;
        then o-term p = Den(o,Free(S,X)).(H#p) &
        nf(Den(o,Free(S,X)).(H#p), R.the_result_sort_of o) =
        Den(o,T).(H#p) = H.(the_result_sort_of o).(Den(o,Free(S,X)).p)
        by MSUALG_3:def 7,MSAFREE4:13,def 20,def 10;
        then
A6:     H.(the_result_sort_of o).(Den(o,Free(S,X)).p) is_a_normal_form_of
        o-term p, R.the_result_sort_of o by REWRITE1:54;
        the_sort_of (o-term p) = the_result_sort_of o by Th8;
        hence thesis by A3,A6,ABBR;
      end;
      suppose
B0:     len p <> 0;
        deffunc F(FinSequence,Nat) = $1+*($2,(H#p).$2);
        defpred Q[Nat,set,set] means
        ex r being FinSequence st $2 = r & $3 = F(r,$1+1);
A7:     for r being Element of Args(o,Free(S,X))
        for n being Nat st 1 <= n <= len p holds
        F(r,n) in Args(o,Free(S,X))
        proof
          Args(o,T) c= Args(o,Free(S,X)) by MSAFREE4:41;
          then
C1:       H#p in Args(o,Free(S,X));
          let r be Element of Args(o,Free(S,X));
          let n be Nat; assume 1 <= n <= len p;
          then n in dom p = dom the_arity_of o by MSUALG_3:6,FINSEQ_3:25;
          then (H#p).n in (the Sorts of Free(S,X)).((the_arity_of o)/.n)
          by C1,MSUALG_6:2;
          hence thesis by MSUALG_6:7;
        end;
A6:     for n being Nat st 1 <= n & n < len p
        for x being Element of Args(o,Free(S,X))
        ex y being Element of Args(o,Free(S,X)) st Q[n,x,y]
        proof
          let n be Nat;
          assume 1 <= n;
          assume Z1: n < len p;
          let x be Element of Args(o,Free(S,X));
          1 <= n+1 <= len p by Z1,NAT_1:12,13;
          then reconsider y = F(x,n+1) as Element of Args(o,Free(S,X)) by A7;
          take y;
          thus Q[n,x,y];
        end;
B2:     len p >= 0+1 by B0,NAT_1:13;
        reconsider f1 = F(p,1) as Element of Args(o,Free(S,X))
        by A7,B2;
        consider f being FinSequence of Args(o,Free(S,X)) such that
B3:     len f = len p & (f.1 = f1 or len p = 0) &
        for n st 1 <= n & n < len p holds Q[n,f.n,f.(n+1)]
        from RECDEF_1:sch 4(A6);
B6:     dom f = dom p by B3,FINSEQ_3:29;
        defpred S[Nat] means $1 <= len p implies dom (f.$1) = dom p &
        (for i st 1 <= i <= $1 holds f.$1.i = (H#p).i) &
        (for i st $1+1 <= i <= len p holds f.$1.i = p.i);
BA:     S[1]
        proof
          assume 1 <= len p;
          then
C0:       1 in dom p by FINSEQ_3:25;
          thus dom (f.1) = dom p by B0,B3,FUNCT_7:30;
          hereby
            let i; assume 1 <= i <= 1;
            then i = 1 by XXREAL_0:1;
            hence f.1.i = (H#p).i by B0,B3,C0,FUNCT_7:31;
          end;
          let i; assume
C1:       1+1 <= i <= len p;
          i > 1 by C1,NAT_1:13;
          hence f.1.i = p.i by B0,B3,FUNCT_7:32;
        end;
BB:     for j st j >= 1 & S[j] holds S[j+1]
        proof let j; assume that
D1:       j >= 1 & S[j] and
D2:       j+1 <= len p;
D7:       j+1 >= 1 & j <= j+1 by NAT_1:12;
          consider r being FinSequence such that
D4:       f.j = r & f.(j+1) = F(r,j+1) by D1,B3,D2,NAT_1:13;
          thus dom (f.(j+1)) = dom p by D1,D7,D4,D2,XXREAL_0:2,FUNCT_7:30;
          hereby let i; assume
D6:         1 <= i <= j+1;
            per cases by NAT_1:13;
            suppose i <= j;
              then f.j.i = (H#p).i & i < j+1 by D1,D2,D6,NAT_1:13;
              hence f.(j+1).i = (H#p).i by D4,FUNCT_7:32;
            end;
            suppose i >= j+1;
              then i = j+1 by D6,XXREAL_0:1;
              hence f.(j+1).i = (H#p).i
              by D1,D2,D7,D4,FINSEQ_3:25,XXREAL_0:2,FUNCT_7:31;
            end;
          end;
          let i; assume
D8:       j+1+1 <= i <= len p;
D10:      j+1 < i by D8,NAT_1:13;
          then f.j.i = p.i by D1,D2,D7,D8,XXREAL_0:2;
          hence f.(j+1).i = p.i by D4,D10,FUNCT_7:32;
        end;
BC:     for j st j >= 1 holds S[j] from NAT_1:sch 8(BA,BB);
        defpred R[Nat] means $1 <= len p implies
        R.the_result_sort_of o reduces o-term p, Den(o,Free(S,X)).(f.$1);
B4:     R[1]
        proof
          assume 1 <= len p;
          then
C0:       1 in dom p = dom the_arity_of o = dom (H#p)
          by FINSEQ_3:25,MSUALG_6:2;
          then
C1:       p/.1 = p.1 in rng p by PARTFUN1:def 6,FUNCT_1:def 3;
          then P[p/.1] by Z0;
          then
C2:       R.the_sort_of (p/.1) reduces p/.1,H.(the_sort_of (p/.1)).(p/.1)
          by ABBR;
          reconsider t = (H#p)/.1 as Element of Free(S,X) by MSAFREE4:39;
C3:       the_sort_of (p/.1) = (the_arity_of o)/.1 by C0,Th4A;
          then H.(the_sort_of (p/.1)).(p/.1) = (H#p).1 = t &
          p+*(1,p/.1) = p by C0,C1,PARTFUN1:def 6,FUNCT_7:35,MSUALG_3:def 6;
          hence R.the_result_sort_of o reduces o-term p, Den(o,Free(S,X)).(f.1)
          by A3,B0,B3,C0,C2,C3,Th113;
        end;
B5:     for i st i >= 1 & R[i] holds R[i+1]
        proof let i; assume
D1:       i >= 1 & R[i] & i+1 <= len p;
          then
D2:       i < len p & 1 <= i+1 by NAT_1:13;
          then
C0:       i in dom p & i+1 in dom p = dom the_arity_of o = dom (H#p)
          by D1,FINSEQ_3:25,MSUALG_6:2;
          then
C1:       p/.(i+1) = p.(i+1) in rng p by PARTFUN1:def 6,FUNCT_1:def 3;
          then P[p/.(i+1)] by Z0;
          then
C2:       R.the_sort_of (p/.(i+1)) reduces p/.(i+1),
          H.(the_sort_of (p/.(i+1))).(p/.(i+1))
          by ABBR;
          reconsider t = (H#p)/.(i+1) as Element of Free(S,X) by MSAFREE4:39;
          reconsider fi = f.i, fi1 = f.(i+1) as Element of Args(o,Free(S,X))
          by B6,D2,D1,FINSEQ_3:25,FUNCT_1:102;
D3:       fi.(i+1) = p.(i+1) & dom fi = dom the_arity_of o
          by BC,D1,D2,MSUALG_6:2;
C3:       the_sort_of (p/.(i+1)) = (the_arity_of o)/.(i+1) by C0,Th4A;
          then
C4:       H.(the_sort_of (p/.(i+1))).(p/.(i+1)) = (H#p).(i+1) = t &
          fi+*(i+1,p/.(i+1)) = fi
          by D3,C0,C1,PARTFUN1:def 6,FUNCT_7:35,MSUALG_3:def 6;
          then
C5:       R.the_result_sort_of o reduces Den(o,Free(S,X)).(fi),
          Den(o,Free(S,X)).(fi+*(i+1,t)) by D3,C0,C2,C3,Th113;
          consider r being FinSequence such that
C6:       fi = r & fi1 = F(r,i+1) by B3,D1,NAT_1:13;
          thus thesis by C4,C5,C6,D1,NAT_1:13,REWRITE1:16;
        end;
BD:     for i st i >= 1 holds R[i] from NAT_1:sch 8(B4,B5);
        reconsider fl = f.len p as Element of Args(o,Free(S,X))
        by B6,FUNCT_1:102,B2,FINSEQ_3:25;
        fl = H#p
        proof
E1:       dom fl = dom the_arity_of o = dom (H#p) & dom the_arity_of o = dom p
          by MSUALG_6:2;
          hence len fl = len (H#p) by FINSEQ_3:29;
E2:       len fl = len p by E1,FINSEQ_3:29;
          let i; assume 1 <= i <= len fl;
          hence fl.i = (H#p).i by BC,B2,E2;
        end;
        then R.the_result_sort_of o reduces o-term p, Den(o,Free(S,X)).(H#p)
        by B2,BD;
        hence P[o-term p] by A4,A5,REWRITE1:16;
      end;
    end;
    thus P[t] from TermInd(A1,A2);
  end;
